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