]>
Commit | Line | Data |
---|---|---|
9edefa04 | 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 | ||
7ca4655f | 18 | #include <TClonesArray.h> |
9edefa04 | 19 | #include <TClass.h> |
6f5308d9 | 20 | #include <TGeoManager.h> |
9edefa04 | 21 | |
aacedc3e | 22 | #include "AliITSdigit.h" |
88cb7938 | 23 | #include "AliITSLoader.h" |
7d62fb64 | 24 | #include "AliRunLoader.h" |
ad7f2bfa | 25 | #include "AliObjectLoader.h" |
6def2bd2 | 26 | #include "AliITSInitGeometry.h" |
13033bec | 27 | #include "AliLog.h" |
88cb7938 | 28 | |
aacedc3e | 29 | /////////////////////////////////////////////////////////////////////////// |
eeac5f9f | 30 | // Loader for ITS |
31 | // it manages the I/O for: | |
32 | // raw clusters, primary vertices | |
33 | // V0 and cascade | |
34 | // and tracks propagated to the origin | |
aacedc3e | 35 | ////////////////////////////////////////////////////////////////////////// |
88cb7938 | 36 | const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC"; |
37 | const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB"; | |
38 | const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex"; | |
566abf75 | 39 | const TString AliITSLoader::fgkDefaultV0ContainerName = "V0"; |
40 | const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade"; | |
88cb7938 | 41 | ClassImp(AliITSLoader) |
42 | ||
aacedc3e | 43 | /**********************************************************************/ |
e56160b8 | 44 | AliITSLoader::AliITSLoader():AliLoader(), |
45 | fITSpid(0), | |
46 | fGeom(0){ | |
eeac5f9f | 47 | // Default constructor |
aacedc3e | 48 | } |
49 | /*********************************************************************/ | |
50 | AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername): | |
e56160b8 | 51 | AliLoader(name,topfoldername), |
52 | fITSpid(0), | |
53 | fGeom(0){ | |
54 | //Constructor | |
aacedc3e | 55 | AliDataLoader* rawClustersDataLoader = new AliDataLoader( |
56 | fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName, | |
57 | "Raw Clusters"); | |
58 | fDataLoaders->Add(rawClustersDataLoader); | |
59 | rawClustersDataLoader->SetEventFolder(fEventFolder); | |
60 | rawClustersDataLoader->SetFolder(GetDetectorDataFolder()); | |
61 | ||
62 | AliDataLoader* backTracksDataLoader = new AliDataLoader( | |
63 | fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName, | |
64 | "Back Propagated Tracks"); | |
65 | fDataLoaders->Add(backTracksDataLoader); | |
66 | backTracksDataLoader->SetEventFolder(fEventFolder); | |
67 | backTracksDataLoader->SetFolder(GetDetectorDataFolder()); | |
eeac5f9f | 68 | |
aacedc3e | 69 | AliDataLoader* vertexDataLoader = new AliDataLoader( |
70 | fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName, | |
71 | "Primary Vertices","O"); | |
72 | fDataLoaders->Add(vertexDataLoader); | |
73 | vertexDataLoader->SetEventFolder(fEventFolder); | |
74 | vertexDataLoader->SetFolder(GetDetectorDataFolder()); | |
75 | ||
76 | AliDataLoader* v0DataLoader = new AliDataLoader( | |
77 | fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices"); | |
78 | fDataLoaders->Add(v0DataLoader); | |
79 | v0DataLoader->SetEventFolder(fEventFolder); | |
80 | v0DataLoader->SetFolder(GetDetectorDataFolder()); | |
81 | ||
82 | AliDataLoader* cascadeDataLoader = new AliDataLoader( | |
83 | fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName, | |
84 | "Cascades"); | |
85 | fDataLoaders->Add(cascadeDataLoader); | |
86 | cascadeDataLoader->SetEventFolder(fEventFolder); | |
87 | cascadeDataLoader->SetFolder(GetDetectorDataFolder()); | |
ad7f2bfa | 88 | |
89 | // 2009/03/03: addition of object loader for fast-or signals (Henrik Tydesjo) | |
90 | AliDataLoader* dl = GetDigitsDataLoader(); | |
91 | AliBaseLoader* foLoader = new AliObjectLoader("AliITSFOSignalsSPD",dl); | |
92 | dl->AddBaseLoader(foLoader); | |
93 | ||
eeac5f9f | 94 | } |
aacedc3e | 95 | /**********************************************************************/ |
96 | AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder): | |
e56160b8 | 97 | AliLoader(name,topfolder), |
98 | fITSpid(0), | |
99 | fGeom(0){ | |
aacedc3e | 100 | //ctor |
101 | AliDataLoader* rawClustersDataLoader = new AliDataLoader( | |
102 | fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName, | |
103 | "Raw Clusters"); | |
104 | fDataLoaders->Add(rawClustersDataLoader); | |
105 | rawClustersDataLoader->SetEventFolder(fEventFolder); | |
106 | rawClustersDataLoader->SetFolder(GetDetectorDataFolder()); | |
eeac5f9f | 107 | |
aacedc3e | 108 | AliDataLoader* backTracksDataLoader = new AliDataLoader( |
109 | fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName, | |
110 | "Back Propagated Tracks"); | |
111 | fDataLoaders->Add(backTracksDataLoader); | |
112 | backTracksDataLoader->SetEventFolder(fEventFolder); | |
113 | backTracksDataLoader->SetFolder(GetDetectorDataFolder()); | |
114 | ||
115 | AliDataLoader* vertexDataLoader = new AliDataLoader( | |
116 | fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName, | |
117 | "Primary Vertices","O"); | |
118 | fDataLoaders->Add(vertexDataLoader); | |
119 | vertexDataLoader->SetEventFolder(fEventFolder); | |
120 | vertexDataLoader->SetFolder(GetDetectorDataFolder()); | |
121 | ||
122 | AliDataLoader* v0DataLoader = new AliDataLoader( | |
123 | fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices"); | |
124 | fDataLoaders->Add(v0DataLoader); | |
125 | v0DataLoader->SetEventFolder(fEventFolder); | |
126 | v0DataLoader->SetFolder(GetDetectorDataFolder()); | |
127 | ||
128 | AliDataLoader* cascadeDataLoader = new AliDataLoader( | |
129 | fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName, | |
130 | "Cascades"); | |
131 | fDataLoaders->Add(cascadeDataLoader); | |
132 | cascadeDataLoader->SetEventFolder(fEventFolder); | |
133 | cascadeDataLoader->SetFolder(GetDetectorDataFolder()); | |
ad7f2bfa | 134 | |
135 | // 2009/03/03: addition of object loader for fast-or signals (Henrik Tydesjo) | |
136 | AliDataLoader* dl = GetDigitsDataLoader(); | |
137 | AliBaseLoader* foLoader = new AliObjectLoader("AliITSFOSignalsSPD",dl); | |
138 | dl->AddBaseLoader(foLoader); | |
139 | ||
140 | ||
88cb7938 | 141 | } |
e62c1aea | 142 | |
e62c1aea | 143 | |
aacedc3e | 144 | /**********************************************************************/ |
145 | AliITSLoader::~AliITSLoader(){ | |
146 | //destructor | |
147 | AliDataLoader* dl = 0; | |
148 | UnloadRawClusters(); | |
149 | dl = GetRawClLoader(); | |
150 | fDataLoaders->Remove(dl); | |
88cb7938 | 151 | |
aacedc3e | 152 | UnloadBackTracks(); |
153 | dl = GetBackTracksDataLoader(); | |
154 | fDataLoaders->Remove(dl); | |
155 | ||
156 | UnloadVertices(); | |
157 | dl = GetVertexDataLoader(); | |
158 | fDataLoaders->Remove(dl); | |
159 | ||
160 | UnloadV0s(); | |
161 | dl = GetV0DataLoader(); | |
162 | fDataLoaders->Remove(dl); | |
163 | ||
164 | UnloadCascades(); | |
165 | dl = GetCascadeDataLoader(); | |
166 | fDataLoaders->Remove(dl); | |
e56160b8 | 167 | |
8e50d897 | 168 | if(fGeom)delete fGeom; |
023ae34b | 169 | fGeom = 0; |
88cb7938 | 170 | } |
7d62fb64 | 171 | /* |
aacedc3e | 172 | //---------------------------------------------------------------------- |
173 | AliITS* AliITSLoader::GetITS(){ | |
174 | // Returns the pointer to the ITS, kept on the file. A short cut metthod | |
175 | // Inputs: | |
176 | // none. | |
177 | // Outputs: | |
178 | // none. | |
179 | // Returns: | |
180 | // Returns a pointer to the ITS, if not found returns 0. | |
181 | AliITS *its; | |
566abf75 | 182 | |
aacedc3e | 183 | if(gAlice){ |
184 | its = dynamic_cast<AliITS*> (gAlice->GetDetector( | |
185 | GetDetectorName().Data())); | |
186 | if(its) return its; | |
187 | } // end if gAlice | |
188 | AliRunLoader *rl=0; | |
189 | rl = GetRunLoader(); | |
190 | if(!rl) return 0; | |
191 | AliRun *ar=0; | |
192 | ar = rl->GetAliRun(); | |
193 | if(!ar) return 0; | |
194 | its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data())); | |
195 | return its; | |
88cb7938 | 196 | } |
aacedc3e | 197 | //---------------------------------------------------------------------- |
198 | void AliITSLoader::SetupDigits(AliITS *its){ | |
199 | // Sets up to store ITS Digits in side AliITS::fDtype TObjArray | |
200 | // Inputs: | |
201 | // AliITS *its Pointer to the ITS | |
202 | // Outputs: | |
203 | // none. | |
204 | // Return: | |
205 | // none. | |
88cb7938 | 206 | |
aacedc3e | 207 | its->SetTreeAddressD(TreeD()); |
208 | } | |
7d62fb64 | 209 | */ |
aacedc3e | 210 | //---------------------------------------------------------------------- |
211 | void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n, | |
212 | const Char_t **digclass){ | |
213 | // Sets up digPerDet to store ITS Digits. | |
214 | // Inputs: | |
215 | // TObjArray *digPerDet A pointer to a TObject Array size>=3. | |
216 | // Int_t n The size of the TObjArray and digclass array | |
217 | // Char_t **digclass Array of digit class names | |
218 | // Outputs: | |
219 | // TObjArray *digPerDet Setup and linked to the tree of digits | |
220 | // Return: | |
221 | // none. | |
222 | Int_t i,m; | |
223 | TClonesArray *cl = 0; | |
224 | TTree *td = 0; | |
225 | TBranch *br = 0; | |
226 | Char_t branch[13]; | |
227 | const Char_t *det[3] = {"SPD","SDD","SSD"}; | |
228 | ||
229 | if(!digPerDet){ | |
230 | Error("SetUpDigits","TObject Array digPerDet does not exist"); | |
231 | return; | |
232 | } // end if | |
233 | m = digPerDet->GetSize(); | |
234 | if(m<n){ | |
235 | Error("SetUpDigits","TObject Array digPerDet=%p must have a size" | |
236 | " at least that of n=%d",digPerDet,n); | |
237 | } // end if | |
238 | if(m<3){ | |
239 | Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2", | |
240 | digPerDet); | |
241 | return; | |
242 | } // end if | |
243 | td = TreeD(); | |
244 | for(i=0;i<n;i++){ | |
245 | if(digPerDet->At(i)==0){ // set up TClones Array | |
246 | digPerDet->AddAt(new TClonesArray(digclass[i],1000),i); | |
247 | if(n==3) sprintf(branch,"ITSDigits%s",det[i]); | |
248 | else sprintf(branch,"ITSDigits%d",i+1); | |
249 | br = td->GetBranch(branch); | |
250 | br->SetAddress(&((*digPerDet)[i])); | |
251 | continue; // do next one. | |
252 | } // end if | |
253 | cl = dynamic_cast<TClonesArray*> (digPerDet->At(i)); | |
254 | if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray | |
255 | Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be " | |
256 | "zeroed or filled with TClonesArrays",i,digPerDet); | |
257 | return; | |
258 | } // end if | |
259 | if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){ | |
260 | Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be" | |
261 | "derived from AliITSdigit",i,digPerDet->At(i)); | |
262 | } // end if | |
263 | cl->Clear(); | |
264 | if(n==3) sprintf(branch,"ITSDigits%s",det[i]); | |
265 | else sprintf(branch,"ITSDigits%d",i+1); | |
266 | br = td->GetBranch(branch); | |
267 | br->SetAddress(&((*digPerDet)[i])); | |
268 | continue; | |
269 | } // end for i | |
270 | } | |
271 | //--------------------------------------------------------------------- | |
272 | AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module, | |
273 | Int_t digit){ | |
274 | // Gets the digit for for a specific detector type and module. | |
275 | // To be used in conjustion with Setupdigits(AliITS *its). | |
276 | // Inputs: | |
277 | // TObjArray *digPereDet Pointer to the Array of digits | |
278 | // Int_t module Module number | |
279 | // Int_t digit Digit number | |
280 | // Outputs: | |
281 | // none. | |
282 | // Return: | |
283 | // returns the pointer to the digit. if zero then last digit for that | |
284 | // module. | |
285 | ||
286 | if(digPerDet==0){ | |
287 | Error("GetDigit","digPerDet=%p, module=%d, digit=%d", | |
288 | digPerDet,module,digit); | |
289 | return 0; | |
290 | } // end if | |
291 | return 0; | |
292 | } | |
7d62fb64 | 293 | /* |
aacedc3e | 294 | //--------------------------------------------------------------------- |
295 | AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){ | |
296 | // Gets the digit for for a specific detector type and module. | |
297 | // To be used in conjustion with Setupdigits(AliITS *its). | |
298 | // Inputs: | |
299 | // AliITS *its Pointer to the ITS | |
300 | // Int_t module Module number | |
301 | // Int_t digit Digit number | |
302 | // Outputs: | |
303 | // none. | |
304 | // Return: | |
305 | // returns the pointer to the digit. if zero then last digit for that | |
306 | // module. | |
307 | //AliITSDetType *idtype; | |
308 | AliITSgeom *geom = its->GetITSgeom(); | |
309 | Int_t idet = geom->GetModuleType(module); | |
310 | TClonesArray *digits; | |
311 | ||
312 | its->ResetDigits(); | |
313 | TreeD()->GetEvent(module); | |
314 | digits = its->DigitsAddress(idet); | |
315 | if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range. | |
316 | return (AliITSdigit*) digits->At(digit); | |
317 | } // end if | |
318 | return 0; | |
319 | } | |
7d62fb64 | 320 | */ |
aacedc3e | 321 | //---------------------------------------------------------------------- |
88cb7938 | 322 | void AliITSLoader::MakeTree(Option_t *opt){ |
aacedc3e | 323 | // invokes AliLoader::MakeTree + specific ITS tree(s) |
324 | // Valid options: H,S,D,R,T and C (C=raw clusters) | |
325 | AliLoader::MakeTree(opt); | |
326 | const char *oC = strstr(opt,"C"); | |
327 | if (oC) MakeRawClustersContainer(); | |
328 | ||
329 | const char *oB = strstr(opt,"B"); | |
330 | if (oB) MakeBackTracksContainer(); | |
331 | ||
332 | const char *oV0 = strstr(opt,"V0"); | |
333 | if (oV0) MakeV0Container(); | |
334 | ||
335 | const char *oX = strstr(opt,"X"); | |
336 | if (oX) MakeCascadeContainer(); | |
88cb7938 | 337 | } |
7d62fb64 | 338 | |
339 | //---------------------------------------------------------------------- | |
8e50d897 | 340 | AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) { |
7d62fb64 | 341 | // retrieves the ITS geometry from file |
8e50d897 | 342 | if(fGeom && !force)return fGeom; |
343 | if(fGeom && force){ | |
344 | delete fGeom; | |
345 | fGeom = 0; | |
346 | } | |
6f5308d9 | 347 | if(!gGeoManager){ |
348 | AliError("gGeoManager is a null pointer - ITS geometry not built"); | |
349 | return fGeom; | |
350 | } | |
108bd0fe | 351 | AliITSInitGeometry initgeom; |
6def2bd2 | 352 | fGeom = initgeom.CreateAliITSgeom(); |
353 | AliDebug(1,"AliITSgeom object has been initialized from TGeo\n"); | |
108bd0fe | 354 | AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data())); |
8e50d897 | 355 | return fGeom; |
7d62fb64 | 356 | } |
023ae34b | 357 | //______________________________________________________________________ |
358 | void AliITSLoader::SetITSgeom(AliITSgeom *geom){ | |
359 | // Replaces the AliITSgeom object read from file with the one | |
360 | // given. | |
361 | // Inputs: | |
362 | // AliITSgeom *geom The AliITSgeom object to replace the one | |
363 | // read from the file | |
364 | // Outputs: | |
365 | // none. | |
366 | // Return: | |
367 | // none. | |
368 | ||
369 | if(fGeom==geom) return; // Same do nothing | |
370 | if(fGeom) { | |
371 | delete fGeom; | |
372 | fGeom=0; | |
373 | }// end if | |
374 | fGeom=geom; | |
375 | } | |
ad7f2bfa | 376 | //______________________________________________________________________ |
377 | AliBaseLoader* AliITSLoader::GetFOSignalsLoader() { | |
378 | // return pointer to FO signals base loader | |
379 | AliDataLoader* dl = GetDigitsDataLoader(); | |
380 | if (!dl) { | |
381 | AliError("Data loader is NULL."); | |
382 | return NULL; | |
383 | } | |
384 | return dl->GetBaseLoader("AliITSFOSignalsSPD"); | |
385 | } | |
7d62fb64 | 386 |