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