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