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