]>
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. * | |
5 | * Contributors 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 | ||
fcf95fc7 | 20 | |
7d62fb64 | 21 | ///////////////////////////////////////////////////////////////////// |
22 | // Base simulation functions for ITS // | |
23 | // // | |
24 | // // | |
25 | ///////////////////////////////////////////////////////////////////// | |
26 | #include "TBranch.h" | |
27 | #include "TClonesArray.h" | |
28 | #include "TObjArray.h" | |
29 | #include "TTree.h" | |
30 | ||
31 | #include "AliRun.h" | |
8ba39da9 | 32 | |
33 | #include "AliCDBManager.h" | |
34 | #include "AliCDBId.h" | |
35 | #include "AliCDBStorage.h" | |
36 | #include "AliCDBEntry.h" | |
37 | #include "AliCDBMetaData.h" | |
7d62fb64 | 38 | #include "AliITSdigit.h" |
39 | #include "AliITSdigitSPD.h" | |
40 | #include "AliITSdigitSDD.h" | |
41 | #include "AliITSdigitSSD.h" | |
ef665f5e | 42 | #include "AliITSgeom.h" |
3b9df642 | 43 | #include "AliITSDetTypeSim.h" |
7d62fb64 | 44 | #include "AliITSpListItem.h" |
ef665f5e | 45 | #include "AliITSCalibration.h" |
fcf95fc7 | 46 | #include "AliITSCalibrationSDD.h" |
028a3709 | 47 | #include "AliITSMapSDD.h" |
54af1add | 48 | #include "AliITSCorrMapSDD.h" |
18da6e54 | 49 | #include "AliITSDriftSpeedArraySDD.h" |
140e5249 | 50 | #include "AliITSDriftSpeedSDD.h" |
fcf95fc7 | 51 | #include "AliITSCalibrationSSD.h" |
88128115 | 52 | #include "AliITSNoiseSSDv2.h" |
53 | #include "AliITSGainSSDv2.h" | |
54 | #include "AliITSBadChannelsSSDv2.h" | |
fb4dfab9 | 55 | #include "AliITSNoiseSSD.h" |
56 | #include "AliITSGainSSD.h" | |
57 | #include "AliITSBadChannelsSSD.h" | |
58 | #include "AliITSCalibrationSSD.h" | |
7d62fb64 | 59 | #include "AliITSsegmentationSPD.h" |
60 | #include "AliITSsegmentationSDD.h" | |
61 | #include "AliITSsegmentationSSD.h" | |
62 | #include "AliITSsimulation.h" | |
63 | #include "AliITSsimulationSPD.h" | |
64 | #include "AliITSsimulationSDD.h" | |
65 | #include "AliITSsimulationSSD.h" | |
ef665f5e | 66 | #include "AliITSDDLModuleMapSDD.h" |
ad7f2bfa | 67 | #include "AliITSTriggerConditions.h" |
68 | #include "AliBaseLoader.h" | |
7d62fb64 | 69 | |
70 | const Int_t AliITSDetTypeSim::fgkNdettypes = 3; | |
8ba39da9 | 71 | const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD = 240; |
72 | const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD = 260; | |
73 | const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698; | |
3b9df642 | 74 | |
75 | ClassImp(AliITSDetTypeSim) | |
76 | ||
77 | //---------------------------------------------------------------------- | |
78 | AliITSDetTypeSim::AliITSDetTypeSim(): | |
79 | TObject(), | |
3b9df642 | 80 | fSimulation(), // [NDet] |
81 | fSegmentation(), // [NDet] | |
fcf95fc7 | 82 | fCalibration(), // [NMod] |
ced4d9bc | 83 | fSSDCalibration(0), |
ad7f2bfa | 84 | fSPDNoisy(0), |
3b9df642 | 85 | fNSDigits(0), //! number of SDigits |
e6b4e6b9 | 86 | fSDigits("AliITSpListItem",1000), |
3b9df642 | 87 | fNDigits(0), //! number of Digits |
023ae34b | 88 | fRunNumber(0), //! Run number (to access DB) |
3b9df642 | 89 | fDigits(), //! [NMod][NDigits] |
cd2a0045 | 90 | fSimuPar(0), |
979b5a5f | 91 | fDDLMapSDD(0), |
ef665f5e | 92 | fkDigClassName(), // String with digit class name. |
023ae34b | 93 | fLoader(0), // local pointer to loader |
2f8ed7ab | 94 | fFirstcall(kTRUE), |
ad7f2bfa | 95 | fFOGenerator(), |
96 | fTriggerConditions(NULL) | |
97 | { | |
3b9df642 | 98 | // Default Constructor |
99 | // Inputs: | |
100 | // none. | |
101 | // Outputs: | |
102 | // none. | |
103 | // Return: | |
104 | // A properly zero-ed AliITSDetTypeSim class. | |
023ae34b | 105 | |
7d62fb64 | 106 | fSimulation = new TObjArray(fgkNdettypes); |
107 | fSegmentation = new TObjArray(fgkNdettypes); | |
1964ae5f | 108 | fSegmentation->SetOwner(kTRUE); |
7d62fb64 | 109 | fDigits = new TObjArray(fgkNdettypes); |
110 | fNDigits = new Int_t[fgkNdettypes]; | |
979b5a5f | 111 | fDDLMapSDD=new AliITSDDLModuleMapSDD(); |
cd2a0045 | 112 | fSimuPar= new AliITSSimuParam(); |
ced4d9bc | 113 | fSSDCalibration=new AliITSCalibrationSSD(); |
8ba39da9 | 114 | fNMod[0] = fgkDefaultNModulesSPD; |
115 | fNMod[1] = fgkDefaultNModulesSDD; | |
116 | fNMod[2] = fgkDefaultNModulesSSD; | |
117 | SetRunNumber(); | |
3b9df642 | 118 | } |
119 | //---------------------------------------------------------------------- | |
120 | AliITSDetTypeSim::~AliITSDetTypeSim(){ | |
121 | // Destructor | |
122 | // Inputs: | |
123 | // none. | |
124 | // Outputs: | |
125 | // none. | |
126 | // Return: | |
127 | // Nothing. | |
023ae34b | 128 | |
7d62fb64 | 129 | if(fSimulation){ |
023ae34b | 130 | fSimulation->Delete(); |
131 | delete fSimulation; | |
7d62fb64 | 132 | } |
023ae34b | 133 | fSimulation = 0; |
7d62fb64 | 134 | if(fSegmentation){ |
023ae34b | 135 | fSegmentation->Delete(); |
136 | delete fSegmentation; | |
7d62fb64 | 137 | } |
023ae34b | 138 | fSegmentation = 0; |
b17dae48 | 139 | if(fCalibration && fRunNumber<0){ |
bb292d31 | 140 | |
023ae34b | 141 | fCalibration->Delete(); |
142 | delete fCalibration; | |
7d62fb64 | 143 | } |
023ae34b | 144 | fCalibration = 0; |
ced4d9bc | 145 | if(fSSDCalibration) delete fSSDCalibration; |
ad7f2bfa | 146 | if(fSPDNoisy){ |
147 | if(!(AliCDBManager::Instance()->GetCacheFlag())) { | |
148 | fSPDNoisy->Delete(); | |
149 | delete fSPDNoisy; | |
150 | fSPDNoisy = 0; | |
151 | } | |
152 | } | |
cd2a0045 | 153 | if(fSimuPar) delete fSimuPar; |
979b5a5f | 154 | if(fDDLMapSDD) delete fDDLMapSDD; |
2a476797 | 155 | if(fNDigits) delete [] fNDigits; |
023ae34b | 156 | fNDigits = 0; |
157 | if (fLoader)fLoader->GetModulesFolder()->Remove(this); | |
158 | fLoader = 0; // Not deleting it. | |
e6b4e6b9 | 159 | fSDigits.Delete(); |
7d62fb64 | 160 | if (fDigits) { |
161 | fDigits->Delete(); | |
162 | delete fDigits; | |
7d62fb64 | 163 | } |
023ae34b | 164 | fDigits=0; |
3b9df642 | 165 | } |
166 | //---------------------------------------------------------------------- | |
7537d03c | 167 | AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source), |
168 | fSimulation(source.fSimulation), // [NDet] | |
169 | fSegmentation(source.fSegmentation), // [NDet] | |
170 | fCalibration(source.fCalibration), // [NMod] | |
ced4d9bc | 171 | fSSDCalibration(source.fSSDCalibration), |
ad7f2bfa | 172 | fSPDNoisy(source.fSPDNoisy), |
7537d03c | 173 | fNSDigits(source.fNSDigits), //! number of SDigits |
e6b4e6b9 | 174 | fSDigits(*((TClonesArray*)source.fSDigits.Clone())), |
7537d03c | 175 | fNDigits(source.fNDigits), //! number of Digits |
176 | fRunNumber(source.fRunNumber), //! Run number (to access DB) | |
177 | fDigits(source.fDigits), //! [NMod][NDigits] | |
cd2a0045 | 178 | fSimuPar(source.fSimuPar), |
979b5a5f | 179 | fDDLMapSDD(source.fDDLMapSDD), |
ef665f5e | 180 | fkDigClassName(), // String with digit class name. |
7537d03c | 181 | fLoader(source.fLoader), // local pointer to loader |
2f8ed7ab | 182 | fFirstcall(source.fFirstcall), |
ad7f2bfa | 183 | fFOGenerator(source.fFOGenerator), |
184 | fTriggerConditions(source.fTriggerConditions) | |
7537d03c | 185 | { |
7d62fb64 | 186 | // Copy Constructor for object AliITSDetTypeSim not allowed |
7537d03c | 187 | for(Int_t i=0;i<fgkNdettypes;i++){ |
ef665f5e | 188 | fkDigClassName[i] = source.fkDigClassName[i]; |
7537d03c | 189 | } |
3b9df642 | 190 | } |
191 | //---------------------------------------------------------------------- | |
7d62fb64 | 192 | AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){ |
3b9df642 | 193 | // The = operator for object AliITSDetTypeSim |
7d62fb64 | 194 | |
7537d03c | 195 | this->~AliITSDetTypeSim(); |
196 | new(this) AliITSDetTypeSim(source); | |
197 | return *this; | |
3b9df642 | 198 | } |
7d62fb64 | 199 | |
023ae34b | 200 | //______________________________________________________________________ |
201 | void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){ | |
202 | // Sets/replaces the existing AliITSgeom object kept in AliITSLoader | |
203 | // | |
204 | // Inputs: | |
205 | // AliITSgoem *geom The AliITSgeom object to be used. | |
206 | // Output: | |
207 | // none. | |
208 | // Return: | |
209 | // none. | |
210 | if(!fLoader){ | |
211 | Error("SetITSgeom","No pointer to loader - nothing done"); | |
212 | return; | |
213 | } | |
214 | else { | |
215 | fLoader->SetITSgeom(geom); // protections in AliITSLoader::SetITSgeom | |
216 | } | |
217 | ||
218 | } | |
219 | //______________________________________________________________________ | |
220 | void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){ | |
221 | // Sets the local copy of the AliITSLoader, and passes on the | |
222 | // AliITSgeom object as needed. | |
223 | // Inputs | |
224 | // AliITSLoader *loader pointer to AliITSLoader for local use | |
225 | // Outputs: | |
226 | // none. | |
227 | // Return: | |
228 | // none. | |
229 | ||
230 | if(fLoader==loader) return; // Same do nothing | |
231 | if(fLoader){ // alread have an existing loader | |
232 | Error("SetLoader", | |
233 | "Already have an exisiting loader ptr=%p Nothing done", | |
234 | fLoader); | |
235 | } // end if | |
236 | fLoader = loader; | |
237 | } | |
3b9df642 | 238 | //______________________________________________________________________ |
7d62fb64 | 239 | void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){ |
240 | ||
241 | //Set simulation model for detector type | |
242 | ||
243 | if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes); | |
244 | fSimulation->AddAt(sim,dettype); | |
245 | } | |
246 | //______________________________________________________________________ | |
ef665f5e | 247 | AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype) const { |
7d62fb64 | 248 | |
249 | //Get simulation model for detector type | |
250 | if(fSimulation==0) { | |
251 | Warning("GetSimulationModel","fSimulation is 0!"); | |
252 | return 0; | |
253 | } | |
254 | return (AliITSsimulation*)(fSimulation->At(dettype)); | |
255 | } | |
256 | //______________________________________________________________________ | |
ef665f5e | 257 | AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module) const { |
7d62fb64 | 258 | |
259 | //Get simulation model by module number | |
023ae34b | 260 | if(GetITSgeom()==0) { |
261 | Warning("GetSimulationModelByModule","GetITSgeom() is 0!"); | |
7d62fb64 | 262 | return 0; |
263 | } | |
264 | ||
023ae34b | 265 | return GetSimulationModel(GetITSgeom()->GetModuleType(module)); |
7d62fb64 | 266 | } |
fcf95fc7 | 267 | //_______________________________________________________________________ |
1964ae5f | 268 | void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){ |
023ae34b | 269 | // Set default segmentation model objects |
270 | AliITSsegmentation *seg; | |
1964ae5f | 271 | |
023ae34b | 272 | if(fSegmentation==0x0){ |
273 | fSegmentation = new TObjArray(fgkNdettypes); | |
274 | fSegmentation->SetOwner(kTRUE); | |
275 | } | |
276 | if(GetSegmentationModel(idet)) | |
277 | delete (AliITSsegmentation*)fSegmentation->At(idet); | |
278 | if(idet==0){ | |
d24bc9d6 | 279 | seg = new AliITSsegmentationSPD(); |
023ae34b | 280 | }else if(idet==1){ |
b27af87f | 281 | seg = new AliITSsegmentationSDD(); |
282 | AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1); | |
283 | if(cal->IsAMAt20MHz()){ | |
284 | seg->SetPadSize(seg->Dpz(0),20.); | |
285 | seg->SetNPads(seg->Npz()/2,128); | |
286 | } | |
023ae34b | 287 | }else { |
d24bc9d6 | 288 | seg = new AliITSsegmentationSSD(); |
023ae34b | 289 | } |
290 | SetSegmentationModel(idet,seg); | |
291 | } | |
7d62fb64 | 292 | //______________________________________________________________________ |
023ae34b | 293 | void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype, |
294 | AliITSsegmentation *seg){ | |
7d62fb64 | 295 | |
296 | //Set segmentation model for detector type | |
fcf95fc7 | 297 | if(fSegmentation==0x0){ |
1964ae5f | 298 | fSegmentation = new TObjArray(fgkNdettypes); |
299 | fSegmentation->SetOwner(kTRUE); | |
300 | } | |
7d62fb64 | 301 | fSegmentation->AddAt(seg,dettype); |
7d62fb64 | 302 | } |
303 | //______________________________________________________________________ | |
ef665f5e | 304 | AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype) const{ |
7d62fb64 | 305 | //Get segmentation model for detector type |
306 | ||
307 | if(fSegmentation==0) { | |
023ae34b | 308 | Warning("GetSegmentationModel","fSegmentation is 0!"); |
309 | return 0; | |
7d62fb64 | 310 | } |
311 | return (AliITSsegmentation*)(fSegmentation->At(dettype)); | |
7d62fb64 | 312 | } |
313 | //_______________________________________________________________________ | |
ef665f5e | 314 | AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module) const{ |
023ae34b | 315 | //Get segmentation model by module number |
316 | if(GetITSgeom()==0){ | |
317 | Warning("GetSegmentationModelByModule","GetITSgeom() is 0!"); | |
318 | return 0; | |
319 | } | |
320 | return GetSegmentationModel(GetITSgeom()->GetModuleType(module)); | |
7d62fb64 | 321 | } |
322 | //_______________________________________________________________________ | |
fcf95fc7 | 323 | void AliITSDetTypeSim::CreateCalibrationArray() { |
023ae34b | 324 | //Create the container of calibration functions with correct size |
325 | if (fCalibration) { | |
326 | Warning("CreateCalibration","pointer to calibration object exists\n"); | |
327 | fCalibration->Delete(); | |
328 | delete fCalibration; | |
329 | } | |
8ba39da9 | 330 | |
023ae34b | 331 | Int_t nModTot = GetITSgeom()->GetIndexMax(); |
332 | fCalibration = new TObjArray(nModTot); | |
333 | fCalibration->SetOwner(kTRUE); | |
334 | fCalibration->Clear(); | |
8ba39da9 | 335 | } |
336 | //_______________________________________________________________________ | |
fcf95fc7 | 337 | void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){ |
023ae34b | 338 | //Set response model for modules |
8ba39da9 | 339 | |
023ae34b | 340 | if (fCalibration==0) CreateCalibrationArray(); |
8ba39da9 | 341 | |
023ae34b | 342 | if (fCalibration->At(iMod)!=0) |
343 | delete (AliITSCalibration*) fCalibration->At(iMod); | |
344 | fCalibration->AddAt(resp, iMod); | |
8ba39da9 | 345 | } |
ad7f2bfa | 346 | //_______________________________________________________________________ |
347 | void AliITSDetTypeSim::SetSPDNoisyModel(Int_t iMod, AliITSCalibration *cal){ | |
348 | //Set noisy pixel info for the SPD module iMod | |
349 | if (fSPDNoisy==0) { | |
350 | fSPDNoisy = new TObjArray(fgkDefaultNModulesSPD); | |
351 | fSPDNoisy->SetOwner(kTRUE); | |
352 | fSPDNoisy->Clear(); | |
353 | } | |
354 | ||
355 | if (fSPDNoisy->At(iMod) != 0) | |
356 | delete (AliITSCalibration*) fSPDNoisy->At(iMod); | |
357 | fSPDNoisy->AddAt(cal,iMod); | |
358 | } | |
7d62fb64 | 359 | //______________________________________________________________________ |
fcf95fc7 | 360 | void AliITSDetTypeSim::ResetCalibrationArray(){ |
023ae34b | 361 | //resets response array |
362 | if(fCalibration && fRunNumber<0){ // if fRunNumber<0 fCalibration is owner | |
bb292d31 | 363 | /* |
023ae34b | 364 | AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At( |
365 | GetITSgeom()->GetStartSPD()))->GetResponse(); | |
023ae34b | 366 | AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At( |
367 | GetITSgeom()->GetStartSSD()))->GetResponse(); | |
368 | if(rspd) delete rspd; | |
023ae34b | 369 | if(rssd) delete rssd; |
bb292d31 | 370 | */ |
023ae34b | 371 | fCalibration->Clear(); |
372 | }else if (fCalibration && fRunNumber>=0){ | |
373 | fCalibration->Clear(); | |
374 | } | |
7d62fb64 | 375 | } |
376 | //______________________________________________________________________ | |
377 | void AliITSDetTypeSim::ResetSegmentation(){ | |
023ae34b | 378 | //Resets segmentation array |
379 | if(fSegmentation) fSegmentation->Clear(); | |
7d62fb64 | 380 | } |
7d62fb64 | 381 | //_______________________________________________________________________ |
ef665f5e | 382 | AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod) const { |
023ae34b | 383 | //Get response model for module number iMod |
8ba39da9 | 384 | |
023ae34b | 385 | if(fCalibration==0) { |
386 | AliError("fCalibration is 0!"); | |
387 | return 0; | |
388 | } | |
ced4d9bc | 389 | if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){ |
390 | return (AliITSCalibration*)fCalibration->At(iMod); | |
391 | }else{ | |
392 | Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD); | |
393 | fSSDCalibration->SetModule(i); | |
394 | return (AliITSCalibration*)fSSDCalibration; | |
395 | } | |
396 | ||
7d62fb64 | 397 | } |
398 | //_______________________________________________________________________ | |
ad7f2bfa | 399 | AliITSCalibration* AliITSDetTypeSim::GetSPDNoisyModel(Int_t iMod) const { |
400 | //Get SPD noisy calib for module iMod | |
401 | if(fSPDNoisy==0) { | |
402 | AliWarning("fSPDNoisy is 0!"); | |
403 | return 0; | |
404 | } | |
405 | return (AliITSCalibration*)fSPDNoisy->At(iMod); | |
406 | } | |
407 | //_______________________________________________________________________ | |
7d62fb64 | 408 | void AliITSDetTypeSim::SetDefaults(){ |
023ae34b | 409 | //Set defaults for segmentation and response |
410 | ||
411 | if(GetITSgeom()==0){ | |
412 | Warning("SetDefaults","GetITSgeom() is 0!"); | |
413 | return; | |
414 | } // end if | |
415 | if (fCalibration==0) { | |
416 | CreateCalibrationArray(); | |
417 | } // end if | |
418 | ||
419 | ResetSegmentation(); | |
420 | if(!GetCalibration()){AliFatal("Exit"); exit(0);} | |
421 | ||
fa4f0f62 | 422 | SetDigitClassName(0,"AliITSdigitSPD"); |
423 | SetDigitClassName(1,"AliITSdigitSDD"); | |
424 | SetDigitClassName(2,"AliITSdigitSSD"); | |
425 | ||
023ae34b | 426 | for(Int_t idet=0;idet<fgkNdettypes;idet++){ |
fa4f0f62 | 427 | if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet); |
428 | } | |
8ba39da9 | 429 | } |
8ba39da9 | 430 | //______________________________________________________________________ |
431 | Bool_t AliITSDetTypeSim::GetCalibration() { | |
432 | // Get Default calibration if a storage is not defined. | |
7d62fb64 | 433 | |
b17dae48 | 434 | if(!fFirstcall){ |
435 | AliITSCalibration* cal = GetCalibrationModel(0); | |
436 | if(cal)return kTRUE; | |
437 | } | |
438 | else { | |
439 | fFirstcall = kFALSE; | |
440 | } | |
441 | ||
442 | SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun()); | |
443 | Int_t run=GetRunNumber(); | |
b17dae48 | 444 | |
445 | Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag(); | |
446 | Bool_t isCacheActive = kTRUE; | |
447 | if(GetRunNumber()<0){ | |
448 | isCacheActive=kFALSE; | |
449 | fCalibration->SetOwner(kTRUE); | |
450 | } | |
451 | else{ | |
452 | fCalibration->SetOwner(kFALSE); | |
453 | } | |
454 | ||
455 | AliCDBManager::Instance()->SetCacheFlag(isCacheActive); | |
456 | ||
ad7f2bfa | 457 | AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead", run); |
458 | AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy", run); | |
459 | AliCDBEntry *foEffSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFOEfficiency", run); | |
460 | AliCDBEntry *foNoiSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFONoise", run); | |
b17dae48 | 461 | AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run); |
18da6e54 | 462 | AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD",run); |
979b5a5f | 463 | AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD",run); |
2ebd5518 | 464 | //AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD",run); |
028a3709 | 465 | AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD",run); |
fb4dfab9 | 466 | // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run); |
028a3709 | 467 | AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD"); |
468 | AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD"); | |
469 | AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD"); | |
fb4dfab9 | 470 | |
ad7f2bfa | 471 | if(!deadSPD || !noisySPD || !foEffSPD || !foNoiSPD |
472 | || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD | |
d9ed1779 | 473 | || !drSpSDD || !ddlMapSDD || !mapTSDD){ |
fb4dfab9 | 474 | AliFatal("Calibration object retrieval failed! "); |
475 | return kFALSE; | |
ad7f2bfa | 476 | } |
bb292d31 | 477 | |
06232459 | 478 | |
ad7f2bfa | 479 | TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject(); |
480 | if (!isCacheActive) deadSPD->SetObject(NULL); | |
481 | deadSPD->SetOwner(kTRUE); | |
06232459 | 482 | |
ad7f2bfa | 483 | TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject(); |
484 | if (!isCacheActive) noisySPD->SetObject(NULL); | |
485 | noisySPD->SetOwner(kTRUE); | |
486 | ||
487 | AliITSFOEfficiencySPD *calFoEffSPD = (AliITSFOEfficiencySPD*) foEffSPD->GetObject(); | |
488 | if (!isCacheActive) foEffSPD->SetObject(NULL); | |
489 | foEffSPD->SetOwner(kTRUE); | |
490 | ||
491 | AliITSFONoiseSPD *calFoNoiSPD = (AliITSFONoiseSPD*) foNoiSPD->GetObject(); | |
492 | if (!isCacheActive) foNoiSPD->SetObject(NULL); | |
493 | foNoiSPD->SetOwner(kTRUE); | |
fcf95fc7 | 494 | |
b17dae48 | 495 | TObjArray *calSDD = (TObjArray *)entrySDD->GetObject(); |
496 | if(!isCacheActive)entrySDD->SetObject(NULL); | |
8ba39da9 | 497 | entrySDD->SetOwner(kTRUE); |
06232459 | 498 | |
18da6e54 | 499 | TObjArray *drSp = (TObjArray *)drSpSDD->GetObject(); |
500 | if(!isCacheActive)drSpSDD->SetObject(NULL); | |
501 | drSpSDD->SetOwner(kTRUE); | |
502 | ||
979b5a5f | 503 | AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject(); |
504 | if(!isCacheActive)ddlMapSDD->SetObject(NULL); | |
505 | ddlMapSDD->SetOwner(kTRUE); | |
506 | ||
2ebd5518 | 507 | // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject(); |
508 | // if(!isCacheActive)mapASDD->SetObject(NULL); | |
509 | // mapASDD->SetOwner(kTRUE); | |
028a3709 | 510 | |
511 | TObjArray *mapT = (TObjArray *)mapTSDD->GetObject(); | |
512 | if(!isCacheActive)mapTSDD->SetObject(NULL); | |
513 | mapTSDD->SetOwner(kTRUE); | |
514 | ||
fb4dfab9 | 515 | /* |
b17dae48 | 516 | TObjArray *calSSD = (TObjArray *)entrySSD->GetObject(); |
517 | if(!isCacheActive)entrySSD->SetObject(NULL); | |
8ba39da9 | 518 | entrySSD->SetOwner(kTRUE); |
fb4dfab9 | 519 | */ |
520 | ||
9b4aee57 | 521 | TObject *emptyssd = 0; TString ssdobjectname; |
88128115 | 522 | AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2(); |
523 | emptyssd = (TObject *)entryNoiseSSD->GetObject(); | |
524 | ssdobjectname = emptyssd->GetName(); | |
525 | if(ssdobjectname=="TObjArray") { | |
526 | TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject(); | |
527 | ReadOldSSDNoise(noiseSSDOld, noiseSSD); | |
528 | } | |
529 | else if(ssdobjectname=="AliITSNoiseSSDv2") | |
530 | noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject(); | |
fb4dfab9 | 531 | if(!isCacheActive)entryNoiseSSD->SetObject(NULL); |
532 | entryNoiseSSD->SetOwner(kTRUE); | |
533 | ||
88128115 | 534 | AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2(); |
535 | emptyssd = (TObject *)entryGainSSD->GetObject(); | |
536 | ssdobjectname = emptyssd->GetName(); | |
537 | if(ssdobjectname=="Gain") { | |
538 | TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject(); | |
539 | ReadOldSSDGain(gainSSDOld, gainSSD); | |
540 | } | |
541 | else if(ssdobjectname=="AliITSGainSSDv2") | |
542 | gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject(); | |
fb4dfab9 | 543 | if(!isCacheActive)entryGainSSD->SetObject(NULL); |
544 | entryGainSSD->SetOwner(kTRUE); | |
545 | ||
88128115 | 546 | AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2(); |
547 | emptyssd = (TObject *)entryBadChannelsSSD->GetObject(); | |
548 | ssdobjectname = emptyssd->GetName(); | |
549 | if(ssdobjectname=="TObjArray") { | |
550 | TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject(); | |
551 | ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD); | |
552 | } | |
553 | else if(ssdobjectname=="AliITSBadChannelsSSDv2") | |
554 | badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject(); | |
fb4dfab9 | 555 | if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL); |
556 | entryBadChannelsSSD->SetOwner(kTRUE); | |
06232459 | 557 | |
88128115 | 558 | /*AliITSNoiseSSDv2 *noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject(); |
559 | if(!isCacheActive)entryNoiseSSD->SetObject(NULL); | |
560 | entryNoiseSSD->SetOwner(kTRUE); | |
561 | ||
562 | AliITSGainSSDv2 *gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject(); | |
563 | if(!isCacheActive)entryGainSSD->SetObject(NULL); | |
564 | entryGainSSD->SetOwner(kTRUE); | |
565 | ||
566 | AliITSBadChannelsSSDv2 *badchannelsSSD = | |
567 | (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject(); | |
568 | if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL); | |
569 | entryBadChannelsSSD->SetOwner(kTRUE);*/ | |
570 | ||
b17dae48 | 571 | // DB entries are deleted. In this way metadeta objects are deleted as well |
572 | if(!isCacheActive){ | |
ad7f2bfa | 573 | delete deadSPD; |
574 | delete noisySPD; | |
575 | delete foEffSPD; | |
576 | delete foNoiSPD; | |
b17dae48 | 577 | delete entrySDD; |
fb4dfab9 | 578 | delete entryNoiseSSD; |
579 | delete entryGainSSD; | |
580 | delete entryBadChannelsSSD; | |
2ebd5518 | 581 | // delete mapASDD; |
028a3709 | 582 | delete mapTSDD; |
18da6e54 | 583 | delete drSpSDD; |
979b5a5f | 584 | delete ddlMapSDD; |
b17dae48 | 585 | } |
fcf95fc7 | 586 | |
b17dae48 | 587 | AliCDBManager::Instance()->SetCacheFlag(origCacheStatus); |
588 | ||
ad7f2bfa | 589 | if ((!calDeadSPD) || (!calNoisySPD) || (!calFoEffSPD) || (!calFoNoiSPD) |
d9ed1779 | 590 | || (!calSDD) || (!drSp) || (!ddlsdd) |
ad7f2bfa | 591 | || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) { |
8ba39da9 | 592 | AliWarning("Can not get calibration from calibration database !"); |
593 | return kFALSE; | |
594 | } | |
fb4dfab9 | 595 | |
ad7f2bfa | 596 | |
597 | fNMod[0] = calDeadSPD->GetEntries(); | |
b17dae48 | 598 | fNMod[1] = calSDD->GetEntries(); |
ced4d9bc | 599 | // fNMod[2] = noiseSSD->GetEntries(); |
15e6a32c | 600 | AliDebug(1,Form("%i SPD, %i SDD and %i SSD in calibration database", |
8ba39da9 | 601 | fNMod[0], fNMod[1], fNMod[2])); |
b17dae48 | 602 | AliITSCalibration* cal; |
8ba39da9 | 603 | for (Int_t i=0; i<fNMod[0]; i++) { |
ad7f2bfa | 604 | cal = (AliITSCalibration*) calDeadSPD->At(i); |
b17dae48 | 605 | SetCalibrationModel(i, cal); |
ad7f2bfa | 606 | cal = (AliITSCalibration*) calNoisySPD->At(i); |
607 | SetSPDNoisyModel(i, cal); | |
18da6e54 | 608 | } |
140e5249 | 609 | |
ad7f2bfa | 610 | fFOGenerator.SetEfficiency(calFoEffSPD); // this cal object is used only by the generator |
611 | fFOGenerator.SetNoise(calFoNoiSPD); // this cal object is used only by the generator | |
612 | ||
140e5249 | 613 | fDDLMapSDD->SetDDLMap(ddlsdd); |
54af1add | 614 | Bool_t oldMapFormat=kFALSE; |
615 | TObject* objmap=(TObject*)mapT->At(0); | |
616 | TString cname(objmap->ClassName()); | |
617 | if(cname.CompareTo("AliITSMapSDD")==0){ | |
618 | oldMapFormat=kTRUE; | |
619 | AliInfo("SDD Maps converted to new format"); | |
620 | } | |
946db678 | 621 | |
622 | for (Int_t i=0; i<fgkDefaultNModulesSDD; i++) { | |
623 | Int_t iddl,icarlos; | |
624 | Int_t iMod = i + fgkDefaultNModulesSPD; | |
625 | fDDLMapSDD->FindInDDLMap(iMod,iddl,icarlos); | |
626 | if(iddl<0){ | |
627 | AliITSCalibrationSDD* calsdddead=new AliITSCalibrationSDD(); | |
946db678 | 628 | calsdddead->SetBad(); |
629 | AliITSDriftSpeedSDD* driftspdef = new AliITSDriftSpeedSDD(); | |
630 | AliITSDriftSpeedArraySDD* arrdrsp=new AliITSDriftSpeedArraySDD(1); | |
631 | arrdrsp->AddDriftSpeed(driftspdef); | |
632 | calsdddead->SetDriftSpeed(0,arrdrsp); | |
633 | calsdddead->SetDriftSpeed(1,arrdrsp); | |
634 | SetCalibrationModel(iMod, calsdddead); | |
635 | AliWarning(Form("SDD module %d not present in DDL map: set it as dead",iMod)); | |
636 | }else{ | |
140e5249 | 637 | cal = (AliITSCalibration*) calSDD->At(i); |
140e5249 | 638 | Int_t i0=2*i; |
639 | Int_t i1=1+2*i; | |
640 | AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0); | |
140e5249 | 641 | AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1); |
54af1add | 642 | |
643 | AliITSCorrMapSDD* mt0 = 0; | |
644 | AliITSCorrMapSDD* mt1 = 0; | |
645 | if(oldMapFormat){ | |
646 | AliITSMapSDD* oldmap0=(AliITSMapSDD*)mapT->At(i0); | |
647 | AliITSMapSDD* oldmap1=(AliITSMapSDD*)mapT->At(i1); | |
648 | mt0=oldmap0->ConvertToNewFormat(); | |
649 | mt1=oldmap1->ConvertToNewFormat(); | |
650 | }else{ | |
651 | mt0=(AliITSCorrMapSDD*)mapT->At(i0); | |
652 | mt1=(AliITSCorrMapSDD*)mapT->At(i1); | |
653 | } | |
140e5249 | 654 | cal->SetDriftSpeed(0,arr0); |
655 | cal->SetDriftSpeed(1,arr1); | |
140e5249 | 656 | cal->SetMapT(0,mt0); |
657 | cal->SetMapT(1,mt1); | |
658 | SetCalibrationModel(iMod, cal); | |
659 | } | |
660 | } | |
946db678 | 661 | |
ced4d9bc | 662 | fSSDCalibration->SetNoise(noiseSSD); |
663 | fSSDCalibration->SetGain(gainSSD); | |
88128115 | 664 | fSSDCalibration->SetBadChannels(badChannelsSSD); |
ced4d9bc | 665 | //fSSDCalibration->FillBadChipMap(); |
666 | ||
667 | ||
ced4d9bc | 668 | |
8ba39da9 | 669 | return kTRUE; |
7d62fb64 | 670 | } |
7d62fb64 | 671 | //_______________________________________________________________________ |
672 | void AliITSDetTypeSim::SetDefaultSimulation(){ | |
7d62fb64 | 673 | //Set default simulation for detector type |
674 | ||
023ae34b | 675 | if(GetITSgeom()==0){ |
676 | Warning("SetDefaultSimulation","GetITSgeom() is 0!"); | |
8ba39da9 | 677 | return; |
678 | } | |
fcf95fc7 | 679 | if(fCalibration==0){ |
680 | Warning("SetDefaultSimulation","fCalibration is 0!"); | |
7d62fb64 | 681 | return; |
682 | } | |
fcf95fc7 | 683 | if(fSegmentation==0){ |
684 | Warning("SetDefaultSimulation","fSegmentation is 0!"); | |
685 | for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i); | |
023ae34b | 686 | }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){ |
687 | Warning("SetDefaultSimulation", | |
688 | "Segmentation not defined for det %d - Default taken\n!",i); | |
689 | SetDefaultSegmentation(i); | |
1964ae5f | 690 | } |
7d62fb64 | 691 | AliITSsimulation* sim; |
692 | ||
693 | for(Int_t idet=0;idet<fgkNdettypes;idet++){ | |
694 | //SPD | |
695 | if(idet==0){ | |
023ae34b | 696 | sim = GetSimulationModel(idet); |
7d62fb64 | 697 | if(!sim){ |
8ba39da9 | 698 | sim = new AliITSsimulationSPD(this); |
7d62fb64 | 699 | SetSimulationModel(idet,sim); |
7d62fb64 | 700 | } |
701 | } | |
702 | //SDD | |
703 | if(idet==1){ | |
704 | sim = GetSimulationModel(idet); | |
705 | if(!sim){ | |
8ba39da9 | 706 | sim = new AliITSsimulationSDD(this); |
7d62fb64 | 707 | SetSimulationModel(idet,sim); |
023ae34b | 708 | } |
7d62fb64 | 709 | } |
710 | //SSD | |
711 | if(idet==2){ | |
712 | sim = GetSimulationModel(idet); | |
713 | if(!sim){ | |
8ba39da9 | 714 | sim = new AliITSsimulationSSD(this); |
7d62fb64 | 715 | SetSimulationModel(idet,sim); |
7d62fb64 | 716 | } |
7d62fb64 | 717 | } |
718 | ||
719 | } | |
720 | } | |
7d62fb64 | 721 | //___________________________________________________________________ |
a6e0ebfe | 722 | void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, const Char_t* name){ |
023ae34b | 723 | // Set branch address for the ITS summable digits Trees. |
7d62fb64 | 724 | char branchname[30]; |
725 | ||
726 | if(!treeS){ | |
727 | return; | |
728 | } | |
7d62fb64 | 729 | TBranch *branch; |
730 | sprintf(branchname,"%s",name); | |
731 | branch = treeS->GetBranch(branchname); | |
e6b4e6b9 | 732 | TClonesArray *sdigi = &fSDigits; |
733 | if (branch) branch->SetAddress(&sdigi); | |
7d62fb64 | 734 | |
735 | } | |
736 | //___________________________________________________________________ | |
a6e0ebfe | 737 | void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, const Char_t* name){ |
7d62fb64 | 738 | // Set branch address for the digit Trees. |
739 | ||
740 | const char *det[3] = {"SPD","SDD","SSD"}; | |
741 | TBranch *branch; | |
742 | ||
743 | char branchname[30]; | |
744 | ||
745 | if(!treeD){ | |
746 | return; | |
747 | } | |
748 | if(!fDigits){ | |
749 | fDigits = new TObjArray(fgkNdettypes); | |
750 | } | |
751 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
a6e0ebfe | 752 | const Char_t* digclass = GetDigitClassName(i); |
7d62fb64 | 753 | if(digclass==0x0){ |
754 | if(i==0) SetDigitClassName(i,"AliITSdigitSPD"); | |
755 | if(i==1) SetDigitClassName(i,"AliITSdigitSDD"); | |
756 | if(i==2) SetDigitClassName(i,"AliITSdigitSSD"); | |
757 | digclass = GetDigitClassName(i); | |
758 | } | |
759 | TString classn = digclass; | |
760 | if(!(fDigits->At(i))){ | |
761 | fDigits->AddAt(new TClonesArray(classn.Data(),1000),i); | |
3b9df642 | 762 | }else{ |
7d62fb64 | 763 | ResetDigits(i); |
764 | } | |
765 | ||
766 | if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]); | |
767 | else sprintf(branchname,"%sDigits%d",name,i+1); | |
768 | if(fDigits){ | |
769 | branch = treeD->GetBranch(branchname); | |
770 | if(branch) branch->SetAddress(&((*fDigits)[i])); | |
771 | } | |
772 | } | |
3b9df642 | 773 | |
3b9df642 | 774 | } |
7d62fb64 | 775 | //___________________________________________________________________ |
776 | void AliITSDetTypeSim::ResetDigits(){ | |
023ae34b | 777 | // Reset number of digits and the digits array for the ITS detector. |
7d62fb64 | 778 | |
779 | if(!fDigits){ | |
780 | Error("ResetDigits","fDigits is null!"); | |
781 | return; | |
782 | } | |
783 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
784 | ResetDigits(i); | |
785 | } | |
786 | } | |
787 | //___________________________________________________________________ | |
788 | void AliITSDetTypeSim::ResetDigits(Int_t branch){ | |
789 | // Reset number of digits and the digits array for this branch. | |
790 | ||
791 | if(fDigits->At(branch)){ | |
792 | ((TClonesArray*)fDigits->At(branch))->Clear(); | |
793 | } | |
794 | if(fNDigits) fNDigits[branch]=0; | |
795 | ||
796 | } | |
797 | ||
798 | ||
799 | ||
800 | //_______________________________________________________________________ | |
801 | void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){ | |
802 | // Standard Summable digits to Digits function. | |
023ae34b | 803 | if(!GetITSgeom()){ |
804 | Warning("SDigitsToDigits","GetITSgeom() is null!!"); | |
7d62fb64 | 805 | return; |
806 | } | |
807 | ||
808 | const char *all = strstr(opt,"All"); | |
809 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
810 | strstr(opt,"SSD")}; | |
811 | if( !det[0] && !det[1] && !det[2] ) all = "All"; | |
812 | else all = 0; | |
813 | static Bool_t setDef = kTRUE; | |
814 | if(setDef) SetDefaultSimulation(); | |
815 | setDef = kFALSE; | |
816 | ||
817 | AliITSsimulation *sim =0; | |
818 | TTree* trees = fLoader->TreeS(); | |
819 | if( !(trees && GetSDigits()) ){ | |
820 | Error("SDigits2Digits","Error: No trees or SDigits. Returning."); | |
821 | return; | |
822 | } | |
823 | sprintf(name,"%s",name); | |
824 | TBranch* brchSDigits = trees->GetBranch(name); | |
825 | ||
826 | Int_t id; | |
023ae34b | 827 | for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){ |
828 | id = GetITSgeom()->GetModuleType(module); | |
7d62fb64 | 829 | if (!all && !det[id]) continue; |
830 | sim = (AliITSsimulation*)GetSimulationModel(id); | |
831 | if(!sim){ | |
832 | Error("SDigit2Digits","The simulation class was not " | |
833 | "instanciated for module %d type %s!",module, | |
023ae34b | 834 | GetITSgeom()->GetModuleTypeName(module)); |
7d62fb64 | 835 | exit(1); |
836 | } | |
837 | sim->InitSimulationModule(module,gAlice->GetEvNumber()); | |
838 | ||
e6b4e6b9 | 839 | fSDigits.Clear(); |
7d62fb64 | 840 | brchSDigits->GetEvent(module); |
e6b4e6b9 | 841 | sim->AddSDigitsToModule(&fSDigits,0); |
7d62fb64 | 842 | sim->FinishSDigitiseModule(); |
843 | fLoader->TreeD()->Fill(); | |
844 | ResetDigits(); | |
845 | } | |
846 | fLoader->TreeD()->GetEntries(); | |
847 | fLoader->TreeD()->AutoSave(); | |
848 | fLoader->TreeD()->Reset(); | |
849 | } | |
7d62fb64 | 850 | //_________________________________________________________ |
023ae34b | 851 | void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){ |
7d62fb64 | 852 | //Adds the module full of summable digits to the summable digits tree. |
023ae34b | 853 | |
e6b4e6b9 | 854 | new(fSDigits[fNSDigits++]) AliITSpListItem(sdig); |
7d62fb64 | 855 | } |
856 | //__________________________________________________________ | |
ef665f5e | 857 | void AliITSDetTypeSim::AddSimDigit(Int_t branch, const AliITSdigit* d){ |
7d62fb64 | 858 | // Add a simulated digit. |
023ae34b | 859 | |
7d62fb64 | 860 | TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch)); |
861 | switch(branch){ | |
862 | case 0: | |
863 | new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d)); | |
864 | break; | |
865 | case 1: | |
866 | new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d)); | |
867 | break; | |
868 | case 2: | |
869 | new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d)); | |
870 | break; | |
023ae34b | 871 | } |
7d62fb64 | 872 | } |
3b9df642 | 873 | //______________________________________________________________________ |
7d62fb64 | 874 | void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits, |
83ec5e27 | 875 | Int_t *tracks,Int_t *hits,Float_t *charges, |
876 | Int_t sigexpanded){ | |
7d62fb64 | 877 | // Add a simulated digit to the list. |
878 | ||
879 | TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch)); | |
7d62fb64 | 880 | switch(branch){ |
881 | case 0: | |
882 | new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits); | |
883 | break; | |
884 | case 1: | |
7d62fb64 | 885 | new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks, |
83ec5e27 | 886 | hits,charges,sigexpanded); |
7d62fb64 | 887 | break; |
888 | case 2: | |
889 | new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits); | |
890 | break; | |
891 | } | |
3b9df642 | 892 | } |
8ba39da9 | 893 | //______________________________________________________________________ |
ef665f5e | 894 | void AliITSDetTypeSim::ReadOldSSDNoise(const TObjArray *array, |
88128115 | 895 | AliITSNoiseSSDv2 *noiseSSD) { |
896 | //Reads the old SSD calibration object and converts it to the new format | |
897 | const Int_t fgkSSDSTRIPSPERMODULE = 1536; | |
898 | const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768; | |
899 | ||
3dd31ed2 | 900 | Int_t gNMod = array->GetEntries(); |
88128115 | 901 | cout<<"Converting old calibration object for noise..."<<endl; |
902 | ||
903 | //NOISE | |
904 | Double_t noise = 0.0; | |
3dd31ed2 | 905 | for (Int_t iModule = 0; iModule < gNMod; iModule++) { |
88128115 | 906 | AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule)); |
907 | for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) { | |
908 | noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip); | |
909 | if(iStrip < fgkSSDPSIDESTRIPSPERMODULE) | |
910 | noiseSSD->AddNoiseP(iModule,iStrip,noise); | |
911 | if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE) | |
912 | noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise); | |
913 | }//loop over strips | |
914 | }//loop over modules | |
915 | } | |
916 | ||
917 | //______________________________________________________________________ | |
ef665f5e | 918 | void AliITSDetTypeSim::ReadOldSSDBadChannels(const TObjArray *array, |
88128115 | 919 | AliITSBadChannelsSSDv2 *badChannelsSSD) { |
920 | //Reads the old SSD calibration object and converts it to the new format | |
f9e8ab3f | 921 | Int_t nMod = array->GetEntries(); |
88128115 | 922 | cout<<"Converting old calibration object for bad channels..."<<endl; |
f9e8ab3f | 923 | for (Int_t iModule = 0; iModule < nMod; iModule++) { |
88128115 | 924 | //for (Int_t iModule = 0; iModule < 1; iModule++) { |
925 | AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule)); | |
926 | TArrayI arrayPSide = bad->GetBadPChannelsList(); | |
927 | for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) | |
928 | badChannelsSSD->AddBadChannelP(iModule, | |
929 | iPCounter, | |
930 | (Char_t)arrayPSide.At(iPCounter)); | |
931 | ||
932 | TArrayI arrayNSide = bad->GetBadNChannelsList(); | |
933 | for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) | |
934 | badChannelsSSD->AddBadChannelN(iModule, | |
935 | iNCounter, | |
936 | (Char_t)arrayNSide.At(iNCounter)); | |
937 | ||
938 | }//loop over modules | |
939 | } | |
940 | ||
941 | //______________________________________________________________________ | |
ef665f5e | 942 | void AliITSDetTypeSim::ReadOldSSDGain(const TObjArray *array, |
88128115 | 943 | AliITSGainSSDv2 *gainSSD) { |
944 | //Reads the old SSD calibration object and converts it to the new format | |
945 | ||
f9e8ab3f | 946 | Int_t nMod = array->GetEntries(); |
88128115 | 947 | cout<<"Converting old calibration object for gain..."<<endl; |
948 | ||
949 | //GAIN | |
f9e8ab3f | 950 | for (Int_t iModule = 0; iModule < nMod; iModule++) { |
88128115 | 951 | AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule)); |
952 | TArrayF arrayPSide = gainModule->GetGainP(); | |
953 | for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++) | |
954 | gainSSD->AddGainP(iModule, | |
955 | iPCounter, | |
956 | arrayPSide.At(iPCounter)); | |
957 | TArrayF arrayNSide = gainModule->GetGainN(); | |
958 | for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++) | |
959 | gainSSD->AddGainN(iModule, | |
960 | iNCounter, | |
961 | arrayNSide.At(iNCounter)); | |
962 | }//loop over modules | |
963 | } | |
ad7f2bfa | 964 | //______________________________________________________________________ |
965 | void AliITSDetTypeSim::ProcessSPDDigitForFastOr(UInt_t module, UInt_t colM, UInt_t rowM) { | |
966 | // Processes wether a single fired pixel will give rise to a fast-or signal | |
967 | fFOGenerator.ProcessPixelHitM(module,colM,rowM); | |
968 | } | |
969 | //_______________________________________________________________________ | |
970 | AliITSTriggerConditions* AliITSDetTypeSim::GetTriggerConditions() { | |
971 | // Get Pixel Trigger Conditions (separate method since it is used only when simulating trigger) | |
972 | if (fTriggerConditions==NULL) { // read from db | |
973 | fRunNumber = ((Int_t)AliCDBManager::Instance()->GetRun()); | |
974 | Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag(); | |
975 | Bool_t isCacheActive; | |
976 | if (fRunNumber<0) isCacheActive=kFALSE; | |
977 | else isCacheActive=kTRUE; | |
978 | AliCDBManager::Instance()->SetCacheFlag(isCacheActive); | |
979 | AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("ITS/Calib/PITConditions", fRunNumber); | |
980 | if (!pitCond) { | |
981 | AliError("Trigger conditions retrieval failed! "); | |
982 | return NULL; | |
983 | } | |
984 | fTriggerConditions = (AliITSTriggerConditions*) pitCond->GetObject(); | |
985 | if (!isCacheActive) pitCond->SetObject(NULL); | |
986 | pitCond->SetOwner(kTRUE); | |
987 | if (!isCacheActive) { | |
988 | delete pitCond; | |
989 | } | |
990 | AliCDBManager::Instance()->SetCacheFlag(origCacheStatus); | |
991 | if (fTriggerConditions==NULL) { | |
992 | AliWarning("fTriggerConditions is NULL!"); | |
993 | } | |
994 | } | |
995 | return fTriggerConditions; | |
996 | } | |
997 | //_______________________________________________________________________ | |
998 | void AliITSDetTypeSim::WriteFOSignals() { | |
999 | // write fo signals to event | |
1000 | ||
1001 | if (!fLoader) { | |
1002 | AliError("ITS loader is NULL."); | |
1003 | return; | |
1004 | } | |
1005 | ||
a0d76912 | 1006 | if(!fLoader->TreeD()){ |
1007 | AliError("No TreeD available"); | |
1008 | return; | |
ad7f2bfa | 1009 | } |
a0d76912 | 1010 | TTree *tree = fLoader->TreeD(); |
1011 | AliITSFOSignalsSPD *foSignals = new AliITSFOSignalsSPD(*GetFOSignals()); | |
1012 | tree->GetUserInfo()->Add(foSignals); | |
ad7f2bfa | 1013 | } |
8ba39da9 | 1014 |