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