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