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