]>
Commit | Line | Data |
---|---|---|
3b9df642 | 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 | /* | |
17 | $Id$ | |
18 | */ | |
19 | ||
7d62fb64 | 20 | //////////////////////////////////////////////////////////////////////// |
21 | // This class defines the "Standard" reconstruction for the ITS // | |
22 | // detector. // | |
23 | // // | |
24 | //////////////////////////////////////////////////////////////////////// | |
25 | #include "TObjArray.h" | |
26 | #include "TTree.h" | |
27 | ||
28 | #include "AliITSClusterFinder.h" | |
29 | #include "AliITSClusterFinderV2.h" | |
30 | #include "AliITSClusterFinderV2SPD.h" | |
31 | #include "AliITSClusterFinderV2SDD.h" | |
32 | #include "AliITSClusterFinderV2SSD.h" | |
33 | #include "AliITSClusterFinderSPD.h" | |
34 | #include "AliITSClusterFinderSDD.h" | |
35 | #include "AliITSClusterFinderSSD.h" | |
36 | #include "AliITSclusterV2.h" | |
37 | #include "AliITSgeom.h" | |
3b9df642 | 38 | #include "AliITSDetTypeRec.h" |
7d62fb64 | 39 | #include "AliITSRawCluster.h" |
40 | #include "AliITSRawClusterSPD.h" | |
41 | #include "AliITSRawClusterSDD.h" | |
42 | #include "AliITSRawClusterSSD.h" | |
43 | #include "AliITSRecPoint.h" | |
44 | #include "AliITSresponseSPD.h" | |
45 | #include "AliITSresponseSDD.h" | |
46 | #include "AliITSresponseSSD.h" | |
47 | #include "AliITSsegmentationSPD.h" | |
48 | #include "AliITSsegmentationSDD.h" | |
49 | #include "AliITSsegmentationSSD.h" | |
50 | ||
3b9df642 | 51 | |
7d62fb64 | 52 | const Int_t AliITSDetTypeRec::fgkNdettypes = 3; |
3b9df642 | 53 | ClassImp(AliITSDetTypeRec) |
54 | ||
7d62fb64 | 55 | //________________________________________________________________ |
3b9df642 | 56 | AliITSDetTypeRec::AliITSDetTypeRec(): TObject(), |
57 | fGeom(), // | |
58 | fReconstruction(),// [NDet] | |
59 | fSegmentation(), // [NDet] | |
60 | fCalibration(), // [NMod] | |
61 | fPreProcess(), // [] e.g. Find Calibration values | |
62 | fPostProcess(), // [] e.g. find primary vertex | |
3b9df642 | 63 | fDigits(), //! [NMod][NDigits] |
64 | fClusterClassName(), // String with Cluster class name | |
65 | fDigClassName(), // String with digit class name. | |
66 | fRecPointClassName(){// String with RecPoint class name | |
67 | // Default Constructor | |
68 | // Inputs: | |
69 | // none. | |
70 | // Outputs: | |
71 | // none. | |
72 | // Return: | |
73 | // A properly zero-ed AliITSDetTypeRec class. | |
7d62fb64 | 74 | |
75 | fGeom = 0; | |
76 | fReconstruction = new TObjArray(fgkNdettypes); | |
77 | fSegmentation = 0; | |
78 | fCalibration = 0; | |
79 | fPreProcess = 0; | |
80 | fPostProcess = 0; | |
81 | fDigits = new TObjArray(fgkNdettypes); | |
82 | fNdtype = new Int_t[fgkNdettypes]; | |
83 | fCtype = new TObjArray(fgkNdettypes); | |
84 | fNctype = new Int_t[fgkNdettypes]; | |
85 | fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
86 | fNRecPoints = 0; | |
87 | fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
88 | fNClustersV2 = 0; | |
89 | ||
90 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
91 | fNdtype[i]=0; | |
92 | fNctype[i]=0; | |
93 | } | |
94 | ||
95 | SelectVertexer(" "); | |
96 | fLoader = 0; | |
97 | } | |
98 | //______________________________________________________________________ | |
99 | AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec &/*rec*/):TObject(/*rec*/){ | |
100 | // Copy constructor. | |
101 | ||
102 | Error("Copy constructor","Copy constructor not allowed"); | |
103 | ||
104 | } | |
105 | //______________________________________________________________________ | |
106 | AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& /*source*/){ | |
107 | // Assignment operator. This is a function which is not allowed to be | |
108 | // done. | |
109 | Error("operator=","Assignment operator not allowed\n"); | |
110 | return *this; | |
3b9df642 | 111 | } |
7d62fb64 | 112 | |
113 | //_____________________________________________________________________ | |
3b9df642 | 114 | AliITSDetTypeRec::~AliITSDetTypeRec(){ |
7d62fb64 | 115 | |
116 | //Destructor | |
117 | if(fGeom) delete fGeom; | |
118 | if(fReconstruction) delete fReconstruction; | |
119 | if(fSegmentation) delete fSegmentation; | |
120 | if(fCalibration) delete fCalibration; | |
121 | if(fPreProcess) delete fPreProcess; | |
122 | if(fPostProcess) delete fPostProcess; | |
123 | ||
124 | if(fDigits){ | |
125 | fDigits->Delete(); | |
126 | delete fDigits; | |
127 | fDigits=0; | |
128 | } | |
129 | if(fRecPoints){ | |
130 | fRecPoints->Delete(); | |
131 | delete fRecPoints; | |
132 | fRecPoints=0; | |
133 | } | |
134 | if(fClustersV2){ | |
135 | fClustersV2->Delete(); | |
136 | delete fClustersV2; | |
137 | fClustersV2=0; | |
138 | } | |
139 | if(fCtype) { | |
140 | fCtype->Delete(); | |
141 | delete fCtype; | |
142 | fCtype = 0; | |
143 | } | |
144 | delete [] fNctype; | |
145 | if(fLoader) delete fLoader; | |
146 | ||
147 | } | |
148 | //___________________________________________________________________ | |
149 | void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){ | |
150 | ||
151 | //Set reconstruction model for detector type | |
152 | ||
153 | if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes); | |
154 | if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype); | |
155 | fReconstruction->AddAt(clf,dettype); | |
156 | } | |
157 | //______________________________________________________________________ | |
158 | AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){ | |
159 | ||
160 | //Get reconstruction model for detector type | |
161 | if(fReconstruction==0) { | |
162 | Warning("GetReconstructionModel","fReconstruction is 0!"); | |
163 | return 0; | |
164 | } | |
165 | return (AliITSClusterFinder*)fReconstruction->At(dettype); | |
166 | } | |
167 | ||
168 | //______________________________________________________________________ | |
169 | void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){ | |
170 | ||
171 | //Set segmentation model for detector type | |
172 | ||
173 | if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes); | |
174 | if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype); | |
175 | fSegmentation->AddAt(seg,dettype); | |
176 | ||
177 | } | |
178 | //______________________________________________________________________ | |
179 | AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){ | |
180 | ||
181 | //Get segmentation model for detector type | |
182 | ||
183 | if(fSegmentation==0) { | |
184 | Warning("GetSegmentationModel","fSegmentation is 0!"); | |
185 | return 0; | |
186 | } | |
187 | return (AliITSsegmentation*)fSegmentation->At(dettype); | |
188 | ||
189 | } | |
190 | //_______________________________________________________________________ | |
3a7c3e6d | 191 | void AliITSDetTypeRec::SetCalibrationModel(Int_t dettype,AliITSresponse *resp){ |
7d62fb64 | 192 | |
193 | ||
194 | //Set segmentation model for module number | |
3a7c3e6d | 195 | if(fCalibration==0) fCalibration = new TObjArray(fgkNdettypes); |
196 | if(fCalibration->At(dettype)!=0) delete fCalibration->At(dettype); | |
197 | fCalibration->AddAt(resp,dettype); | |
7d62fb64 | 198 | |
199 | } | |
200 | //_______________________________________________________________________ | |
3a7c3e6d | 201 | AliITSresponse* AliITSDetTypeRec::GetCalibrationModel(Int_t dettype){ |
7d62fb64 | 202 | |
203 | //Get segmentation model for module number | |
204 | ||
205 | if(fCalibration==0) { | |
206 | Warning("GetalibrationModel","fResponse is 0!"); | |
207 | return 0; | |
208 | } | |
3a7c3e6d | 209 | return (AliITSresponse*)fCalibration->At(dettype); |
7d62fb64 | 210 | } |
211 | ||
212 | //______________________________________________________________________ | |
213 | void AliITSDetTypeRec::SetTreeAddress(){ | |
214 | // Set branch address for the Trees. | |
215 | ||
216 | TTree *treeR = fLoader->TreeR(); | |
217 | TTree *treeD = fLoader->TreeD(); | |
218 | ||
219 | SetTreeAddressD(treeD); | |
220 | SetTreeAddressR(treeR); | |
221 | } | |
222 | //______________________________________________________________________ | |
223 | void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){ | |
224 | // Set branch address for the tree of digits. | |
225 | ||
226 | const char *det[4] = {"SPD","SDD","SSD","ITS"}; | |
227 | TBranch *branch; | |
228 | Char_t* digclass; | |
229 | Int_t i; | |
230 | char branchname[30]; | |
231 | ||
232 | if(!treeD) return; | |
233 | if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes); | |
234 | for (i=0; i<fgkNdettypes; i++) { | |
235 | digclass = GetDigitClassName(i); | |
236 | if(!(fDigits->At(i))) { | |
237 | fDigits->AddAt(new TClonesArray(digclass,1000),i); | |
238 | }else{ | |
239 | ResetDigits(i); | |
240 | } | |
241 | if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]); | |
242 | else sprintf(branchname,"%sDigits%d",det[3],i+1); | |
243 | if (fDigits) { | |
244 | branch = treeD->GetBranch(branchname); | |
245 | if (branch) branch->SetAddress(&((*fDigits)[i])); | |
246 | } | |
247 | } | |
248 | } | |
249 | ||
250 | //_______________________________________________________________________ | |
251 | TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name, | |
252 | const char *classname, | |
253 | void* address,Int_t size, | |
254 | Int_t splitlevel, const char */*file*/) | |
255 | { | |
256 | // | |
257 | // Makes branch in given tree and diverts them to a separate file | |
258 | // | |
259 | // | |
260 | // | |
261 | ||
262 | if (tree == 0x0) { | |
263 | Error("MakeBranchInTree","Making Branch %s Tree is NULL",name); | |
264 | return 0x0; | |
265 | } | |
266 | TBranch *branch = tree->GetBranch(name); | |
267 | if (branch) { | |
268 | return branch; | |
269 | } | |
270 | if (classname){ | |
271 | branch = tree->Branch(name,classname,address,size,splitlevel); | |
272 | } | |
273 | else { | |
274 | branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel); | |
275 | } | |
276 | ||
277 | return branch; | |
278 | } | |
279 | ||
280 | //____________________________________________________________________ | |
281 | void AliITSDetTypeRec::SetDefaults(){ | |
282 | ||
283 | //Set defaults for segmentation and response | |
284 | ||
285 | ||
286 | if(fGeom==0){ | |
287 | Warning("SetDefaults","fGeom is 0!"); | |
288 | return; | |
289 | } | |
290 | ||
291 | AliITSsegmentation* seg; | |
292 | AliITSresponse* res; | |
293 | ||
294 | for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){ | |
295 | if(dettype==0){ | |
296 | seg = new AliITSsegmentationSPD(fGeom); | |
297 | SetSegmentationModel(dettype,seg); | |
3a7c3e6d | 298 | SetCalibrationModel(dettype,new AliITSresponseSPD()); |
299 | SetDigitClassName(dettype,"AliITSdigitSPD"); | |
300 | SetClusterClassName(dettype,"AliITSRawClusterSPD"); | |
301 | ||
7d62fb64 | 302 | } |
303 | if(dettype==1){ | |
304 | res = new AliITSresponseSDD("simulated"); | |
305 | seg = new AliITSsegmentationSDD(fGeom,res); | |
306 | SetSegmentationModel(dettype,seg); | |
3a7c3e6d | 307 | SetCalibrationModel(dettype,new AliITSresponseSDD("simulated")); |
308 | const char *kopt = GetCalibrationModel(dettype)->ZeroSuppOption(); | |
309 | if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) SetDigitClassName(dettype,"AliITSdigit"); | |
310 | else SetDigitClassName(dettype,"AliITSdigitSDD"); | |
311 | SetClusterClassName(dettype,"AliITSRawClusterSDD"); | |
312 | ||
7d62fb64 | 313 | } |
314 | if(dettype==2){ | |
315 | AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD(fGeom); | |
316 | seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side. | |
317 | seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side. | |
318 | seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side. | |
319 | ||
320 | SetSegmentationModel(dettype,seg2); | |
3a7c3e6d | 321 | SetCalibrationModel(dettype,new AliITSresponseSSD("simulated")); |
7d62fb64 | 322 | SetDigitClassName(dettype,"AliITSdigitSSD"); |
323 | SetClusterClassName(dettype,"AliITSRawClusterSSD"); | |
3a7c3e6d | 324 | |
325 | ||
7d62fb64 | 326 | } |
327 | ||
328 | } | |
329 | ||
330 | ||
331 | } | |
332 | ||
333 | //________________________________________________________________ | |
334 | void AliITSDetTypeRec::SetDefaultClusterFinders(){ | |
335 | ||
336 | //set defaults for standard cluster finder | |
337 | ||
338 | if(fGeom==0){ | |
339 | Warning("SetDefaults","fGeom is 0!"); | |
340 | return; | |
341 | } | |
342 | ||
343 | AliITSsegmentation* seg; | |
344 | AliITSresponse* res; | |
345 | AliITSClusterFinder *clf; | |
346 | ||
347 | MakeTreeC(); | |
348 | ||
3a7c3e6d | 349 | for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){ |
7d62fb64 | 350 | //SPD |
351 | if(dettype==0){ | |
352 | if(!GetReconstructionModel(dettype)){ | |
353 | seg = (AliITSsegmentation*)GetSegmentationModel(dettype); | |
354 | TClonesArray *dig0 = DigitsAddress(0); | |
355 | TClonesArray *rec0 = ClustersAddress(0); | |
356 | clf = new AliITSClusterFinderSPD(seg,dig0,rec0); | |
357 | SetReconstructionModel(dettype,clf); | |
358 | } | |
359 | } | |
360 | //SDD | |
361 | if(dettype==1){ | |
362 | if(!GetReconstructionModel(dettype)){ | |
363 | seg = (AliITSsegmentation*)GetSegmentationModel(dettype); | |
3a7c3e6d | 364 | res = (AliITSresponse*)GetCalibrationModel(dettype); |
7d62fb64 | 365 | TClonesArray *dig1 = DigitsAddress(1); |
366 | TClonesArray *rec1 = ClustersAddress(1); | |
367 | clf = new AliITSClusterFinderSDD(seg,res,dig1,rec1); | |
368 | SetReconstructionModel(dettype,clf); | |
369 | } | |
370 | ||
371 | } | |
372 | //SSD | |
373 | if(dettype==2){ | |
374 | if(!GetReconstructionModel(dettype)){ | |
375 | seg = (AliITSsegmentation*)GetSegmentationModel(dettype); | |
376 | TClonesArray* dig2 = DigitsAddress(2); | |
377 | clf = new AliITSClusterFinderSSD(seg,dig2); | |
378 | clf->SetITSgeom(fGeom); | |
379 | SetReconstructionModel(dettype,clf); | |
380 | } | |
381 | } | |
382 | ||
383 | } | |
384 | ||
385 | ||
386 | } | |
387 | ||
388 | //________________________________________________________________ | |
3a7c3e6d | 389 | void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){ |
7d62fb64 | 390 | |
391 | //Set defaults for cluster finder V2 | |
392 | ||
393 | if(fGeom==0){ | |
394 | Warning("SetDefaults","fGeom is 0!"); | |
395 | return; | |
396 | } | |
397 | ||
398 | AliITSsegmentation* seg; | |
399 | AliITSClusterFinder *clf; | |
400 | ||
401 | MakeTreeC(); | |
3a7c3e6d | 402 | for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){ |
7d62fb64 | 403 | //SPD |
404 | if(dettype==0){ | |
405 | if(!GetReconstructionModel(dettype)){ | |
406 | seg = (AliITSsegmentation*)GetSegmentationModel(dettype); | |
407 | clf = new AliITSClusterFinderV2SPD(fGeom); | |
408 | clf->InitGeometry(); | |
409 | clf->SetSegmentation(seg); | |
3a7c3e6d | 410 | if(!rawdata) clf->SetDigits(DigitsAddress(0)); |
7d62fb64 | 411 | SetReconstructionModel(dettype,clf); |
412 | ||
413 | } | |
414 | } | |
415 | //SDD | |
416 | if(dettype==1){ | |
417 | if(!GetReconstructionModel(dettype)){ | |
418 | seg = (AliITSsegmentation*)GetSegmentationModel(dettype); | |
419 | clf = new AliITSClusterFinderV2SDD(fGeom); | |
420 | clf->InitGeometry(); | |
421 | clf->SetSegmentation(seg); | |
3a7c3e6d | 422 | if(!rawdata) clf->SetDigits(DigitsAddress(1)); |
7d62fb64 | 423 | SetReconstructionModel(dettype,clf); |
424 | } | |
425 | ||
426 | } | |
427 | ||
428 | //SSD | |
429 | if(dettype==2){ | |
430 | if(!GetReconstructionModel(dettype)){ | |
431 | seg = (AliITSsegmentation*)GetSegmentationModel(dettype); | |
432 | clf = new AliITSClusterFinderV2SSD(fGeom); | |
433 | clf->InitGeometry(); | |
434 | clf->SetSegmentation(seg); | |
3a7c3e6d | 435 | if(!rawdata) clf->SetDigits(DigitsAddress(2)); |
7d62fb64 | 436 | SetReconstructionModel(dettype,clf); |
437 | } | |
438 | } | |
439 | ||
440 | } | |
441 | ||
442 | } | |
443 | //______________________________________________________________________ | |
444 | void AliITSDetTypeRec::MakeBranch(Option_t* option){ | |
445 | ||
446 | //Creates branches for clusters and recpoints | |
447 | Bool_t cR = (strstr(option,"R")!=0); | |
448 | Bool_t cRF = (strstr(option,"RF")!=0); | |
449 | Bool_t v2 = (strstr(option,"v2")!=0); | |
450 | ||
451 | if(cRF)cR = kFALSE; | |
452 | ||
453 | if(cR) MakeBranchR(0); | |
454 | if(cRF) MakeBranchRF(0); | |
455 | if(v2) MakeBranchR(0,"v2"); | |
456 | ||
457 | } | |
458 | ||
459 | //_____________________________________________________________ | |
460 | void AliITSDetTypeRec::MakeTreeC(){ | |
461 | ||
462 | //Create a separate tree to store the clusters | |
463 | if(!fLoader){ | |
464 | Warning("MakeTreeC","ITS loader is null!"); | |
465 | return; | |
466 | } | |
467 | if(fLoader->TreeC()== 0x0) fLoader->MakeTree("C"); | |
468 | MakeBranchC(); | |
469 | } | |
470 | ||
471 | //______________________________________________________________ | |
472 | void AliITSDetTypeRec::MakeBranchC(){ | |
473 | ||
474 | //Make branches in the tree of clusters | |
475 | ||
476 | if(!fLoader){ | |
477 | Warning("MakeBranchC","ITS loader is null!"); | |
478 | return; | |
479 | } | |
480 | TTree* lTC = fLoader->TreeC(); | |
481 | if(lTC==0x0){ | |
482 | Error("MakeTreeC","Can not get TreeC from loader"); | |
483 | return; | |
484 | } | |
485 | ||
486 | Int_t buffersize = 4000; | |
487 | Char_t branchname[30]; | |
488 | Char_t* cluclass; | |
489 | const char *det[4]={"SPD","SDD","SSD","ITS"}; | |
490 | ||
491 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
492 | cluclass = GetClusterClassName(i); | |
493 | if(fCtype==0x0) fCtype = new TObjArray(fgkNdettypes); | |
494 | if(!ClustersAddress(i)){ | |
495 | fCtype->AddAt(new TClonesArray(cluclass,1000),i); | |
496 | } | |
497 | if(fgkNdettypes==3) sprintf(branchname,"%sClusters%s",det[3],det[i]); | |
498 | else sprintf(branchname,"%sClusters%d",det[3],i+1); | |
499 | if(fCtype && lTC){ | |
500 | if(lTC->GetBranch(branchname)){ | |
501 | Warning("MakeBranchC","Branch %s already exists in TreeC",branchname); | |
502 | } else{ | |
503 | Info("MakeBranchC","Creating branch %s in TreeC",branchname); | |
504 | lTC->Branch(branchname,&((*fCtype)[i]),buffersize); | |
505 | } | |
506 | } | |
507 | ||
508 | } | |
509 | ||
510 | } | |
511 | ||
512 | //_______________________________________________________________ | |
513 | void AliITSDetTypeRec::GetTreeC(Int_t event){ | |
514 | ||
515 | //Get the clusters tree for this event and | |
516 | //sets the branch address | |
517 | ||
518 | ||
519 | if(!fLoader){ | |
520 | Warning("GetTreeC","ITS loader is null!"); | |
521 | return; | |
522 | } | |
523 | ||
524 | Char_t branchname[30]; | |
525 | const char *det[4] = {"SPD","SDD","SSD","ITS"}; | |
526 | TTree* lTC = fLoader->TreeC(); | |
527 | ||
528 | ResetClusters(); | |
529 | if(lTC) fLoader->CleanRawClusters(); | |
530 | ||
531 | TBranch* branch; | |
532 | if(lTC){ | |
533 | Char_t* cluclass; | |
534 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
535 | cluclass = GetClusterClassName(i); | |
536 | if(fCtype==0x0) fCtype = new TObjArray(fgkNdettypes); | |
537 | if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(cluclass,1000),i); | |
538 | if(fgkNdettypes==3) sprintf(branchname,"%sClusters%s",det[3],det[i]); | |
539 | else sprintf(branchname,"%sClusters%d",det[3],i+1); | |
540 | if(fCtype){ | |
541 | branch = lTC->GetBranch(branchname); | |
542 | if(branch) branch->SetAddress(&((*fCtype)[i])); | |
543 | } | |
544 | } | |
545 | } else{ | |
546 | Error("GetTreeC","cannot find clusters Tree for vent %d",event); | |
547 | } | |
548 | ||
549 | } | |
550 | ||
551 | //___________________________________________________________________ | |
552 | void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){ | |
553 | ||
554 | // Adds a raw cluster to the list | |
555 | TClonesArray &lc = *((TClonesArray*)fCtype->At(id)); | |
556 | switch(id){ | |
557 | case 0: | |
558 | new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c)); | |
559 | break; | |
560 | case 1: | |
561 | new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c)); | |
562 | break; | |
563 | case 2: | |
564 | new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c)); | |
565 | break; | |
566 | } | |
567 | } | |
568 | //___________________________________________________________________ | |
569 | void AliITSDetTypeRec::ResetDigits(){ | |
570 | // Reset number of digits and the digits array for the ITS detector. | |
571 | ||
572 | if(!fDigits) return; | |
573 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
574 | ResetDigits(i); | |
575 | } | |
576 | } | |
577 | //___________________________________________________________________ | |
578 | void AliITSDetTypeRec::ResetDigits(Int_t branch){ | |
579 | // Reset number of digits and the digits array for this branch. | |
580 | ||
581 | if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear(); | |
582 | if(fNdtype) fNdtype[branch]=0; | |
583 | ||
584 | } | |
585 | ||
586 | //__________________________________________________________________ | |
587 | void AliITSDetTypeRec::ResetClusters(){ | |
588 | ||
589 | //Resets number of clusters and the cluster array | |
590 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
591 | ResetClusters(i); | |
592 | } | |
593 | } | |
594 | ||
595 | //__________________________________________________________________ | |
596 | void AliITSDetTypeRec::ResetClusters(Int_t i){ | |
597 | ||
598 | //Resets number of clusters and the cluster array for this branch | |
599 | ||
600 | if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear(); | |
601 | if (fNctype) fNctype[i]=0; | |
602 | } | |
603 | //__________________________________________________________________ | |
604 | void AliITSDetTypeRec::MakeBranchR(const char *file, Option_t *opt){ | |
605 | ||
606 | //Creates tree branches for recpoints | |
607 | // Inputs: | |
608 | // cont char *file File name where RecPoints branch is to be written | |
609 | // to. If blank it write the SDigits to the same | |
610 | // file in which the Hits were found. | |
611 | ||
612 | if(!fLoader){ | |
613 | Warning("MakeBranchR","ITS loader is null!"); | |
614 | return; | |
615 | } | |
616 | ||
617 | Int_t buffsz = 4000; | |
618 | char branchname[30]; | |
619 | ||
620 | // only one branch for rec points for all detector types | |
621 | Bool_t oFast= (strstr(opt,"Fast")!=0); | |
622 | Bool_t v2 = (strstr(opt,"v2")!=0); | |
623 | ||
624 | Char_t detname[10] = "ITS"; | |
625 | ||
626 | ||
627 | if(oFast){ | |
628 | sprintf(branchname,"%sRecPointsF",detname); | |
629 | } else if(v2){ | |
630 | sprintf(branchname,"Clusters"); | |
631 | } else { | |
632 | sprintf(branchname,"%sRecPoints",detname); | |
633 | } | |
634 | ||
635 | if(v2){ | |
636 | ||
637 | if(!fClustersV2)fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
638 | if(fLoader->TreeR()){ | |
639 | if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
640 | MakeBranchInTree(fLoader->TreeR(),branchname,0,&fClustersV2,buffsz,99,file); | |
641 | ||
642 | } | |
643 | }else{ | |
644 | if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
645 | if (fLoader->TreeR()) { | |
646 | if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint", | |
647 | 1000); | |
648 | MakeBranchInTree(fLoader->TreeR(),branchname,0,&fRecPoints,buffsz,99,file); | |
649 | } // end if | |
650 | } | |
651 | ||
652 | } | |
653 | //______________________________________________________________________ | |
654 | void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){ | |
655 | // Set branch address for the Reconstructed points Trees. | |
3b9df642 | 656 | // Inputs: |
7d62fb64 | 657 | // TTree *treeR Tree containing the RecPoints. |
3b9df642 | 658 | // Outputs: |
7d62fb64 | 659 | // none. |
3b9df642 | 660 | // Return: |
7d62fb64 | 661 | |
662 | char branchname[30]; | |
663 | Char_t namedet[10]="ITS"; | |
664 | ||
665 | if(!treeR) return; | |
666 | if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); | |
667 | TBranch *branch1; | |
668 | sprintf(branchname,"Clusters"); | |
669 | branch1 = treeR->GetBranch(branchname); | |
670 | if(branch1){ | |
671 | if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000); | |
672 | branch1->SetAddress(&fClustersV2); | |
673 | } | |
674 | else{ | |
675 | TBranch *branch; | |
676 | sprintf(branchname,"%sRecPoints",namedet); | |
677 | branch = treeR->GetBranch(branchname); | |
678 | if (branch) { | |
679 | branch->SetAddress(&fRecPoints); | |
680 | }else { | |
681 | sprintf(branchname,"%sRecPointsF",namedet); | |
682 | branch = treeR->GetBranch(branchname); | |
683 | if (branch) { | |
684 | branch->SetAddress(&fRecPoints); | |
685 | } | |
686 | } | |
687 | } | |
3b9df642 | 688 | } |
7d62fb64 | 689 | //____________________________________________________________________ |
690 | void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){ | |
691 | // Add a reconstructed space point to the list | |
692 | // Inputs: | |
693 | // const AliITSRecPoint &r RecPoint class to be added to the tree | |
694 | // of reconstructed points TreeR. | |
695 | // Outputs: | |
696 | // none. | |
697 | // Return: | |
698 | // none. | |
699 | ||
700 | TClonesArray &lrecp = *fRecPoints; | |
701 | new(lrecp[fNRecPoints++]) AliITSRecPoint(r); | |
702 | } | |
703 | //______________________________________________________________________ | |
704 | void AliITSDetTypeRec::AddClusterV2(const AliITSclusterV2 &r){ | |
705 | // Add a reconstructed space point to the list | |
706 | // Inputs: | |
707 | // const AliITSClusterV2 &r class to be added to the tree | |
708 | // of reconstructed points TreeR. | |
709 | // Outputs: | |
710 | // none. | |
711 | // Return: | |
712 | // none. | |
713 | ||
714 | TClonesArray &lrecp = *fClustersV2; | |
715 | new(lrecp[fNClustersV2++]) AliITSclusterV2(r); | |
3a7c3e6d | 716 | } |
7d62fb64 | 717 | |
718 | //______________________________________________________________________ | |
719 | void AliITSDetTypeRec::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt, Bool_t v2){ | |
720 | // cluster finding and reconstruction of space points | |
721 | // the condition below will disappear when the geom class will be | |
722 | // initialized for all versions - for the moment it is only for v5 ! | |
723 | // 7 is the SDD beam test version | |
724 | // Inputs: | |
725 | // Int_t evNumber Event number to be processed. | |
726 | // Int_t lastentry Offset for module when not all of the modules | |
727 | // are processed. | |
728 | // Option_t *opt String indicating which ITS sub-detectors should | |
729 | // be processed. If ="All" then all of the ITS | |
730 | // sub detectors are processed. | |
731 | ||
732 | if(!fGeom){ | |
733 | Warning("DigitsToRecPoints","fGeom is null!"); | |
734 | return; | |
735 | } | |
736 | if(!fLoader){ | |
737 | Warning("DigitsToRecPoints","ITS loader is null!"); | |
738 | return; | |
739 | } | |
740 | ||
741 | const char *all = strstr(opt,"All"); | |
742 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
743 | strstr(opt,"SSD")}; | |
744 | if(!v2) SetDefaultClusterFinders(); | |
745 | else SetDefaultClusterFindersV2(); | |
746 | ||
747 | ||
748 | TTree *treeC=fLoader->TreeC(); | |
749 | if(!treeC){ | |
750 | MakeTreeC(); | |
751 | MakeBranchC(); | |
752 | } | |
753 | AliITSClusterFinder *rec = 0; | |
754 | Int_t id,module,first=0; | |
755 | for(module=0;module<fGeom->GetIndexMax();module++){ | |
756 | id = fGeom->GetModuleType(module); | |
757 | if (!all && !det[id]) continue; | |
758 | if(det[id]) first = fGeom->GetStartDet(id); | |
759 | rec = (AliITSClusterFinder*)GetReconstructionModel(id); | |
760 | TClonesArray *itsDigits = DigitsAddress(id); | |
761 | if (!rec) { | |
762 | Error("DigitsToRecPoints", | |
763 | "The reconstruction class was not instanciated! event=%d", | |
764 | evNumber); | |
765 | exit(1); | |
766 | } | |
767 | ResetDigits(); | |
768 | TTree *lTD = fLoader->TreeD(); | |
769 | if (all) { | |
770 | lTD->GetEvent(lastentry+module); | |
771 | }else { | |
772 | lTD->GetEvent(lastentry+(module-first)); | |
773 | } | |
774 | Int_t ndigits = itsDigits->GetEntriesFast(); | |
775 | if(ndigits>0){ | |
776 | rec->SetDetTypeRec(this); | |
777 | rec->SetITSgeom(fGeom); | |
778 | rec->SetDigits(DigitsAddress(id)); | |
779 | rec->SetClusters(ClustersAddress(id)); | |
780 | rec->FindRawClusters(module); | |
781 | } // end if | |
782 | fLoader->TreeR()->Fill(); | |
783 | ResetRecPoints(); | |
784 | ResetClustersV2(); | |
785 | treeC->Fill(); | |
786 | ResetClusters(); | |
787 | } | |
788 | ||
789 | fLoader->WriteRecPoints("OVERWRITE"); | |
790 | fLoader->WriteRawClusters("OVERWRITE"); | |
791 | } | |
792 | //______________________________________________________________________ | |
793 | void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader){ | |
794 | // cluster finding and reconstruction of space points | |
795 | // the condition below will disappear when the geom class will be | |
796 | // initialized for all versions - for the moment it is only for v5 ! | |
797 | // 7 is the SDD beam test version | |
798 | // Inputs: | |
799 | // Int_t evNumber Event number to be processed. | |
800 | // Int_t lastentry Offset for module when not all of the modules | |
801 | // are processed. | |
802 | // Option_t *opt String indicating which ITS sub-detectors should | |
803 | // be processed. If ="All" then all of the ITS | |
804 | // sub detectors are processed. | |
805 | // Outputs: | |
806 | // none. | |
807 | // Return: | |
808 | // none. | |
3a7c3e6d | 809 | if(!fGeom){ |
7d62fb64 | 810 | Warning("DigitsToRecPoints","fGeom is null!"); |
811 | return; | |
812 | } | |
813 | if(!fLoader){ | |
814 | Warning("DigitsToRecPoints","ITS loader is null!"); | |
815 | return; | |
816 | } | |
817 | ||
7d62fb64 | 818 | |
819 | AliITSClusterFinderV2 *rec = 0; | |
820 | Int_t id=0; | |
821 | ||
822 | if(!fLoader->TreeR()) fLoader->MakeTree("R"); | |
823 | TTree* cTree = fLoader->TreeR(); | |
824 | TClonesArray *array=new TClonesArray("AliITSclusterV2",1000); | |
825 | cTree->Branch("Clusters",&array); | |
826 | delete array; | |
827 | ||
828 | TClonesArray** clusters = new TClonesArray*[fGeom->GetIndexMax()]; | |
829 | for (Int_t iModule = 0; iModule < fGeom->GetIndexMax(); iModule++) { | |
830 | clusters[iModule] = NULL; | |
831 | } | |
832 | for(id=0;id<3;id++){ | |
833 | rec = (AliITSClusterFinderV2*)GetReconstructionModel(id); | |
834 | rec->SetITSgeom(fGeom); | |
835 | if (!rec) { | |
836 | Error("DigitsToRecPoints", | |
837 | "The reconstruction class was not instanciated"); | |
838 | exit(1); | |
839 | } | |
840 | rec->RawdataToClusters(rawReader,clusters); | |
841 | } | |
842 | Int_t nClusters =0; | |
843 | for(Int_t iModule=0;iModule<fGeom->GetIndexMax();iModule++){ | |
844 | array = clusters[iModule]; | |
845 | if(!array){ | |
846 | Error("DigitsToRecPoints","data for module %d missing!",iModule); | |
847 | array = new TClonesArray("AliITSclusterV2"); | |
848 | } | |
849 | cTree->SetBranchAddress("Clusters",&array); | |
850 | cTree->Fill(); | |
851 | nClusters+=array->GetEntriesFast(); | |
852 | delete array; | |
853 | } | |
854 | fLoader->WriteRecPoints("OVERWRITE"); | |
855 | ||
856 | delete[] clusters; | |
857 | Info("DigitsToRecPoints", "total number of found clustersV2 in ITS: %d\n", | |
858 | nClusters); | |
859 | ||
860 | } | |
861 |