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