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