Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : // $Id$
17 :
18 : //-----------------------------------------------------------------------------
19 : /// \class AliMUONTrackStoreV1
20 : ///
21 : /// Implementation of AliMUONTrackStoreV1, which should be backward
22 : /// compatible, i.e. able to read old TreeT files
23 : ///
24 : /// \author Laurent Aphecetche, Subatech
25 : //-----------------------------------------------------------------------------
26 :
27 : #include "AliMUONTrackStoreV1.h"
28 :
29 : #include <TClonesArray.h>
30 : #include <TTree.h>
31 : #include "AliLog.h"
32 : #include "AliMUONTrack.h"
33 : #include "AliMUONTreeManager.h"
34 :
35 : /// \cond CLASSIMP
36 18 : ClassImp(AliMUONTrackStoreV1)
37 : /// \endcond
38 :
39 : //_____________________________________________________________________________
40 2 : AliMUONTrackStoreV1::AliMUONTrackStoreV1() : AliMUONVTrackStore(),
41 2 : fTracks(0x0)
42 10 : {
43 : /// Ctor
44 2 : CreateTracks();
45 4 : }
46 :
47 : //_____________________________________________________________________________
48 0 : AliMUONTrackStoreV1::AliMUONTrackStoreV1(TRootIOCtor* /*dummy*/) : AliMUONVTrackStore(),
49 0 : fTracks(0x0)
50 0 : {
51 : /// Ctor
52 0 : }
53 :
54 : //_____________________________________________________________________________
55 : AliMUONTrackStoreV1::~AliMUONTrackStoreV1()
56 12 : {
57 : /// dtor
58 4 : delete fTracks;
59 6 : }
60 :
61 : //_____________________________________________________________________________
62 : AliMUONTrack*
63 : AliMUONTrackStoreV1::Add(const AliMUONTrack& track)
64 : {
65 : /// Add a track
66 :
67 32 : if (!fTracks) CreateTracks();
68 :
69 32 : return new((*fTracks)[fTracks->GetLast()+1]) AliMUONTrack(track);
70 0 : }
71 :
72 : //_____________________________________________________________________________
73 : AliMUONTrack*
74 : AliMUONTrackStoreV1::Remove(AliMUONTrack& track)
75 : {
76 : /// Remove a track from the store
77 0 : AliMUONTrack* t = static_cast<AliMUONTrack*>(fTracks->Remove(&track));
78 0 : if (t) fTracks->Compress();
79 0 : return t;
80 : }
81 :
82 : //_____________________________________________________________________________
83 : Bool_t
84 : AliMUONTrackStoreV1::Connect(TTree& tree, Bool_t alone) const
85 : {
86 : /// Connect this store to the tree
87 0 : AliMUONTreeManager tman;
88 :
89 : Bool_t ok;
90 :
91 0 : if ( tree.GetBranch("MUONTrack") )
92 : {
93 0 : if ( alone ) tman.UpdateBranchStatuses(tree,"MUONTrack");
94 0 : ok = tman.SetAddress(tree,"MUONTrack",TracksPtr());
95 0 : }
96 : else
97 : {
98 0 : ok = tman.MakeBranch(tree,ClassName(),"TClonesArray","MUONTrack",
99 0 : TracksPtr());
100 : }
101 0 : return ok;
102 0 : }
103 :
104 : //_____________________________________________________________________________
105 : TIterator*
106 : AliMUONTrackStoreV1::CreateIterator() const
107 : {
108 : /// Create an iterator to loop over tracks
109 90 : if ( fTracks ) return fTracks->MakeIterator();
110 0 : return 0x0;
111 30 : }
112 :
113 : //_____________________________________________________________________________
114 : void
115 : AliMUONTrackStoreV1::Clear(Option_t*)
116 : {
117 : /// Reset
118 24 : if (fTracks) fTracks->Clear("C");
119 8 : }
120 :
121 : //_____________________________________________________________________________
122 : void
123 : AliMUONTrackStoreV1::CreateTracks()
124 : {
125 : /// Allocate track container
126 4 : if (fTracks)
127 : {
128 0 : AliError("Cannot allocate again fTracks as it is there already !");
129 0 : }
130 : else
131 : {
132 4 : fTracks = new TClonesArray("AliMUONTrack",10);
133 : }
134 2 : }
135 :
136 : //_____________________________________________________________________________
137 : Int_t
138 : AliMUONTrackStoreV1::GetSize() const
139 : {
140 : /// Return the number of tracks we hold
141 0 : if ( fTracks ) return fTracks->GetLast()+1;
142 0 : return 0;
143 0 : }
|