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