Version number ++
[u/mrichter/AliRoot.git] / ITS / AliITSLoader.cxx
CommitLineData
aacedc3e 1#include "AliITSdigit.h"
88cb7938 2#include "AliITSLoader.h"
7d62fb64 3#include "AliRunLoader.h"
88cb7938 4
aacedc3e 5///////////////////////////////////////////////////////////////////////////
eeac5f9f 6// Loader for ITS
7// it manages the I/O for:
8// raw clusters, primary vertices
9// V0 and cascade
10// and tracks propagated to the origin
aacedc3e 11//////////////////////////////////////////////////////////////////////////
88cb7938 12const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC";
13const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB";
14const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex";
566abf75 15const TString AliITSLoader::fgkDefaultV0ContainerName = "V0";
16const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade";
88cb7938 17ClassImp(AliITSLoader)
18
aacedc3e 19/**********************************************************************/
eeac5f9f 20 AliITSLoader::AliITSLoader():AliLoader(){
21 // Default constructor
aacedc3e 22}
23/*********************************************************************/
24AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
25AliLoader(name,topfoldername){
26 //ctor
27 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
28 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
29 "Raw Clusters");
30 fDataLoaders->Add(rawClustersDataLoader);
31 rawClustersDataLoader->SetEventFolder(fEventFolder);
32 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
33
34 AliDataLoader* backTracksDataLoader = new AliDataLoader(
35 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
36 "Back Propagated Tracks");
37 fDataLoaders->Add(backTracksDataLoader);
38 backTracksDataLoader->SetEventFolder(fEventFolder);
39 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 40
aacedc3e 41 AliDataLoader* vertexDataLoader = new AliDataLoader(
42 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
43 "Primary Vertices","O");
44 fDataLoaders->Add(vertexDataLoader);
45 vertexDataLoader->SetEventFolder(fEventFolder);
46 vertexDataLoader->SetFolder(GetDetectorDataFolder());
47
48 AliDataLoader* v0DataLoader = new AliDataLoader(
49 fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices");
50 fDataLoaders->Add(v0DataLoader);
51 v0DataLoader->SetEventFolder(fEventFolder);
52 v0DataLoader->SetFolder(GetDetectorDataFolder());
53
54 AliDataLoader* cascadeDataLoader = new AliDataLoader(
55 fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,
56 "Cascades");
57 fDataLoaders->Add(cascadeDataLoader);
58 cascadeDataLoader->SetEventFolder(fEventFolder);
59 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 60}
aacedc3e 61/**********************************************************************/
62AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder):
63AliLoader(name,topfolder) {
64 //ctor
65 AliDataLoader* rawClustersDataLoader = new AliDataLoader(
66 fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,
67 "Raw Clusters");
68 fDataLoaders->Add(rawClustersDataLoader);
69 rawClustersDataLoader->SetEventFolder(fEventFolder);
70 rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
eeac5f9f 71
aacedc3e 72 AliDataLoader* backTracksDataLoader = new AliDataLoader(
73 fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,
74 "Back Propagated Tracks");
75 fDataLoaders->Add(backTracksDataLoader);
76 backTracksDataLoader->SetEventFolder(fEventFolder);
77 backTracksDataLoader->SetFolder(GetDetectorDataFolder());
78
79 AliDataLoader* vertexDataLoader = new AliDataLoader(
80 fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,
81 "Primary Vertices","O");
82 fDataLoaders->Add(vertexDataLoader);
83 vertexDataLoader->SetEventFolder(fEventFolder);
84 vertexDataLoader->SetFolder(GetDetectorDataFolder());
85
86 AliDataLoader* v0DataLoader = new AliDataLoader(
87 fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices");
88 fDataLoaders->Add(v0DataLoader);
89 v0DataLoader->SetEventFolder(fEventFolder);
90 v0DataLoader->SetFolder(GetDetectorDataFolder());
91
92 AliDataLoader* cascadeDataLoader = new AliDataLoader(
93 fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,
94 "Cascades");
95 fDataLoaders->Add(cascadeDataLoader);
96 cascadeDataLoader->SetEventFolder(fEventFolder);
97 cascadeDataLoader->SetFolder(GetDetectorDataFolder());
88cb7938 98}
aacedc3e 99/**********************************************************************/
100AliITSLoader::~AliITSLoader(){
101 //destructor
102 AliDataLoader* dl = 0;
103 UnloadRawClusters();
104 dl = GetRawClLoader();
105 fDataLoaders->Remove(dl);
88cb7938 106
aacedc3e 107 UnloadBackTracks();
108 dl = GetBackTracksDataLoader();
109 fDataLoaders->Remove(dl);
110
111 UnloadVertices();
112 dl = GetVertexDataLoader();
113 fDataLoaders->Remove(dl);
114
115 UnloadV0s();
116 dl = GetV0DataLoader();
117 fDataLoaders->Remove(dl);
118
119 UnloadCascades();
120 dl = GetCascadeDataLoader();
121 fDataLoaders->Remove(dl);
88cb7938 122}
7d62fb64 123/*
aacedc3e 124//----------------------------------------------------------------------
125AliITS* AliITSLoader::GetITS(){
126 // Returns the pointer to the ITS, kept on the file. A short cut metthod
127 // Inputs:
128 // none.
129 // Outputs:
130 // none.
131 // Returns:
132 // Returns a pointer to the ITS, if not found returns 0.
133 AliITS *its;
566abf75 134
aacedc3e 135 if(gAlice){
136 its = dynamic_cast<AliITS*> (gAlice->GetDetector(
137 GetDetectorName().Data()));
138 if(its) return its;
139 } // end if gAlice
140 AliRunLoader *rl=0;
141 rl = GetRunLoader();
142 if(!rl) return 0;
143 AliRun *ar=0;
144 ar = rl->GetAliRun();
145 if(!ar) return 0;
146 its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
147 return its;
88cb7938 148}
aacedc3e 149//----------------------------------------------------------------------
150void AliITSLoader::SetupDigits(AliITS *its){
151 // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
152 // Inputs:
153 // AliITS *its Pointer to the ITS
154 // Outputs:
155 // none.
156 // Return:
157 // none.
88cb7938 158
aacedc3e 159 its->SetTreeAddressD(TreeD());
160}
7d62fb64 161*/
aacedc3e 162//----------------------------------------------------------------------
163void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
164 const Char_t **digclass){
165 // Sets up digPerDet to store ITS Digits.
166 // Inputs:
167 // TObjArray *digPerDet A pointer to a TObject Array size>=3.
168 // Int_t n The size of the TObjArray and digclass array
169 // Char_t **digclass Array of digit class names
170 // Outputs:
171 // TObjArray *digPerDet Setup and linked to the tree of digits
172 // Return:
173 // none.
174 Int_t i,m;
175 TClonesArray *cl = 0;
176 TTree *td = 0;
177 TBranch *br = 0;
178 Char_t branch[13];
179 const Char_t *det[3] = {"SPD","SDD","SSD"};
180
181 if(!digPerDet){
182 Error("SetUpDigits","TObject Array digPerDet does not exist");
183 return;
184 } // end if
185 m = digPerDet->GetSize();
186 if(m<n){
187 Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
188 " at least that of n=%d",digPerDet,n);
189 } // end if
190 if(m<3){
191 Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
192 digPerDet);
193 return;
194 } // end if
195 td = TreeD();
196 for(i=0;i<n;i++){
197 if(digPerDet->At(i)==0){ // set up TClones Array
198 digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
199 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
200 else sprintf(branch,"ITSDigits%d",i+1);
201 br = td->GetBranch(branch);
202 br->SetAddress(&((*digPerDet)[i]));
203 continue; // do next one.
204 } // end if
205 cl = dynamic_cast<TClonesArray*> (digPerDet->At(i));
206 if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray
207 Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
208 "zeroed or filled with TClonesArrays",i,digPerDet);
209 return;
210 } // end if
211 if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
212 Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
213 "derived from AliITSdigit",i,digPerDet->At(i));
214 } // end if
215 cl->Clear();
216 if(n==3) sprintf(branch,"ITSDigits%s",det[i]);
217 else sprintf(branch,"ITSDigits%d",i+1);
218 br = td->GetBranch(branch);
219 br->SetAddress(&((*digPerDet)[i]));
220 continue;
221 } // end for i
222}
223//---------------------------------------------------------------------
224AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
225 Int_t digit){
226 // Gets the digit for for a specific detector type and module.
227 // To be used in conjustion with Setupdigits(AliITS *its).
228 // Inputs:
229 // TObjArray *digPereDet Pointer to the Array of digits
230 // Int_t module Module number
231 // Int_t digit Digit number
232 // Outputs:
233 // none.
234 // Return:
235 // returns the pointer to the digit. if zero then last digit for that
236 // module.
237
238 if(digPerDet==0){
239 Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
240 digPerDet,module,digit);
241 return 0;
242 } // end if
243 return 0;
244}
7d62fb64 245/*
aacedc3e 246//---------------------------------------------------------------------
247AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
248 // Gets the digit for for a specific detector type and module.
249 // To be used in conjustion with Setupdigits(AliITS *its).
250 // Inputs:
251 // AliITS *its Pointer to the ITS
252 // Int_t module Module number
253 // Int_t digit Digit number
254 // Outputs:
255 // none.
256 // Return:
257 // returns the pointer to the digit. if zero then last digit for that
258 // module.
259 //AliITSDetType *idtype;
260 AliITSgeom *geom = its->GetITSgeom();
261 Int_t idet = geom->GetModuleType(module);
262 TClonesArray *digits;
263
264 its->ResetDigits();
265 TreeD()->GetEvent(module);
266 digits = its->DigitsAddress(idet);
267 if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
268 return (AliITSdigit*) digits->At(digit);
269 } // end if
270 return 0;
271}
7d62fb64 272*/
aacedc3e 273//----------------------------------------------------------------------
88cb7938 274void AliITSLoader::MakeTree(Option_t *opt){
aacedc3e 275 // invokes AliLoader::MakeTree + specific ITS tree(s)
276 // Valid options: H,S,D,R,T and C (C=raw clusters)
277 AliLoader::MakeTree(opt);
278 const char *oC = strstr(opt,"C");
279 if (oC) MakeRawClustersContainer();
280
281 const char *oB = strstr(opt,"B");
282 if (oB) MakeBackTracksContainer();
283
284 const char *oV0 = strstr(opt,"V0");
285 if (oV0) MakeV0Container();
286
287 const char *oX = strstr(opt,"X");
288 if (oX) MakeCascadeContainer();
88cb7938 289}
7d62fb64 290
291//----------------------------------------------------------------------
292AliITSgeom* AliITSLoader::GetITSgeom() {
293 // retrieves the ITS geometry from file
294 AliRunLoader *runLoader = GetRunLoader();
295 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
296 if (!runLoader->GetAliRun()) {
297 Error("GetITSgeom", "couldn't get AliRun object");
298 return NULL;
299 }
300
301 runLoader->CdGAFile();
302 AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
303 if(!geom){
304 Error("GetITSgeom","no ITS geometry available");
305 return NULL;
306 }
307
308 return geom;
309}
310