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