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