1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 /////////////////////////////////////////////////////////////////////
22 // Base simulation functions for ITS //
25 /////////////////////////////////////////////////////////////////////
27 #include "TClonesArray.h"
28 #include "TObjArray.h"
33 #include "AliCDBManager.h"
35 #include "AliCDBStorage.h"
36 #include "AliCDBEntry.h"
37 #include "AliCDBMetaData.h"
39 #include "AliITSdigit.h"
40 #include "AliITSdigitSPD.h"
41 #include "AliITSdigitSDD.h"
42 #include "AliITSdigitSSD.h"
43 #include "AliITSDetTypeSim.h"
44 #include "AliITSpListItem.h"
45 #include "AliITSresponseSDD.h"
46 #include "AliITSCalibrationSDD.h"
47 #include "AliITSMapSDD.h"
48 #include "AliITSDriftSpeedArraySDD.h"
49 #include "AliITSDriftSpeedSDD.h"
50 #include "AliITSCalibrationSSD.h"
51 #include "AliITSNoiseSSD.h"
52 #include "AliITSGainSSD.h"
53 #include "AliITSBadChannelsSSD.h"
54 #include "AliITSCalibrationSSD.h"
55 #include "AliITSsegmentationSPD.h"
56 #include "AliITSsegmentationSDD.h"
57 #include "AliITSsegmentationSSD.h"
58 #include "AliITSsimulation.h"
59 #include "AliITSsimulationSPD.h"
60 #include "AliITSsimulationSDD.h"
61 #include "AliITSsimulationSSD.h"
64 const Int_t AliITSDetTypeSim::fgkNdettypes = 3;
65 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD = 240;
66 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD = 260;
67 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698;
69 ClassImp(AliITSDetTypeSim)
71 //----------------------------------------------------------------------
72 AliITSDetTypeSim::AliITSDetTypeSim():
74 fSimulation(), // [NDet]
75 fSegmentation(), // [NDet]
76 fCalibration(), // [NMod]
77 fPreProcess(), // [] e.g. Fill fHitModule with hits
78 fPostProcess(), // [] e.g. Wright Raw data
79 fNSDigits(0), //! number of SDigits
80 fSDigits("AliITSpListItem",1000),
81 fNDigits(0), //! number of Digits
82 fRunNumber(0), //! Run number (to access DB)
83 fDigits(), //! [NMod][NDigits]
85 fHitClassName(), // String with Hit class name.
86 fSDigClassName(),// String with SDigit class name.
87 fDigClassName(), // String with digit class name.
88 fLoader(0), // local pointer to loader
89 fFirstcall(kTRUE){ // flag
90 // Default Constructor
96 // A properly zero-ed AliITSDetTypeSim class.
98 fSimulation = new TObjArray(fgkNdettypes);
99 fSegmentation = new TObjArray(fgkNdettypes);
100 fSegmentation->SetOwner(kTRUE);
101 fDigits = new TObjArray(fgkNdettypes);
102 fNDigits = new Int_t[fgkNdettypes];
103 fDDLMapSDD=new AliITSDDLModuleMapSDD();
104 fNMod[0] = fgkDefaultNModulesSPD;
105 fNMod[1] = fgkDefaultNModulesSDD;
106 fNMod[2] = fgkDefaultNModulesSSD;
109 //----------------------------------------------------------------------
110 AliITSDetTypeSim::~AliITSDetTypeSim(){
120 fSimulation->Delete();
125 fSegmentation->Delete();
126 delete fSegmentation;
129 if(fCalibration && fRunNumber<0){
130 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
131 GetITSgeom()->GetStartSPD()))->GetResponse();
132 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
133 GetITSgeom()->GetStartSDD()))->GetResponse();
134 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
135 GetITSgeom()->GetStartSSD()))->GetResponse();
136 if(rspd) delete rspd;
137 if(rsdd) delete rsdd;
138 if(rssd) delete rssd;
139 fCalibration->Delete();
144 fPreProcess->Delete();
149 fPostProcess->Delete();
153 if(fDDLMapSDD) delete fDDLMapSDD;
154 if(fNDigits) delete [] fNDigits;
156 if (fLoader)fLoader->GetModulesFolder()->Remove(this);
157 fLoader = 0; // Not deleting it.
165 //----------------------------------------------------------------------
166 AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source),
167 fSimulation(source.fSimulation), // [NDet]
168 fSegmentation(source.fSegmentation), // [NDet]
169 fCalibration(source.fCalibration), // [NMod]
170 fPreProcess(source.fPreProcess), // [] e.g. Fill fHitModule with hits
171 fPostProcess(source.fPostProcess), // [] e.g. Wright Raw data
172 fNSDigits(source.fNSDigits), //! number of SDigits
173 fSDigits(*((TClonesArray*)source.fSDigits.Clone())),
174 fNDigits(source.fNDigits), //! number of Digits
175 fRunNumber(source.fRunNumber), //! Run number (to access DB)
176 fDigits(source.fDigits), //! [NMod][NDigits]
177 fDDLMapSDD(source.fDDLMapSDD),
178 fHitClassName(source.fHitClassName), // String with Hit class name.
179 fSDigClassName(source.fSDigClassName),// String with SDigit class name.
180 fDigClassName(), // String with digit class name.
181 fLoader(source.fLoader), // local pointer to loader
182 fFirstcall(source.fFirstcall)
184 // Copy Constructor for object AliITSDetTypeSim not allowed
185 for(Int_t i=0;i<fgkNdettypes;i++){
186 fDigClassName[i] = source.fDigClassName[i];
189 //----------------------------------------------------------------------
190 AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
191 // The = operator for object AliITSDetTypeSim
193 this->~AliITSDetTypeSim();
194 new(this) AliITSDetTypeSim(source);
198 //______________________________________________________________________
199 void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
200 // Sets/replaces the existing AliITSgeom object kept in AliITSLoader
203 // AliITSgoem *geom The AliITSgeom object to be used.
209 Error("SetITSgeom","No pointer to loader - nothing done");
213 fLoader->SetITSgeom(geom); // protections in AliITSLoader::SetITSgeom
217 //______________________________________________________________________
218 void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){
219 // Sets the local copy of the AliITSLoader, and passes on the
220 // AliITSgeom object as needed.
222 // AliITSLoader *loader pointer to AliITSLoader for local use
228 if(fLoader==loader) return; // Same do nothing
229 if(fLoader){ // alread have an existing loader
231 "Already have an exisiting loader ptr=%p Nothing done",
236 //______________________________________________________________________
237 void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){
239 //Set simulation model for detector type
241 if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes);
242 fSimulation->AddAt(sim,dettype);
244 //______________________________________________________________________
245 AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype){
247 //Get simulation model for detector type
249 Warning("GetSimulationModel","fSimulation is 0!");
252 return (AliITSsimulation*)(fSimulation->At(dettype));
254 //______________________________________________________________________
255 AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module){
257 //Get simulation model by module number
258 if(GetITSgeom()==0) {
259 Warning("GetSimulationModelByModule","GetITSgeom() is 0!");
263 return GetSimulationModel(GetITSgeom()->GetModuleType(module));
265 //_______________________________________________________________________
266 void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){
267 // Set default segmentation model objects
268 AliITSsegmentation *seg;
270 if(fSegmentation==0x0){
271 fSegmentation = new TObjArray(fgkNdettypes);
272 fSegmentation->SetOwner(kTRUE);
274 if(GetSegmentationModel(idet))
275 delete (AliITSsegmentation*)fSegmentation->At(idet);
277 seg = new AliITSsegmentationSPD();
279 seg = new AliITSsegmentationSDD();
281 seg = new AliITSsegmentationSSD();
283 SetSegmentationModel(idet,seg);
285 //______________________________________________________________________
286 void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,
287 AliITSsegmentation *seg){
289 //Set segmentation model for detector type
290 if(fSegmentation==0x0){
291 fSegmentation = new TObjArray(fgkNdettypes);
292 fSegmentation->SetOwner(kTRUE);
294 fSegmentation->AddAt(seg,dettype);
296 //______________________________________________________________________
297 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype){
298 //Get segmentation model for detector type
300 if(fSegmentation==0) {
301 Warning("GetSegmentationModel","fSegmentation is 0!");
304 return (AliITSsegmentation*)(fSegmentation->At(dettype));
306 //_______________________________________________________________________
307 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module){
308 //Get segmentation model by module number
310 Warning("GetSegmentationModelByModule","GetITSgeom() is 0!");
313 return GetSegmentationModel(GetITSgeom()->GetModuleType(module));
315 //_______________________________________________________________________
316 void AliITSDetTypeSim::CreateCalibrationArray() {
317 //Create the container of calibration functions with correct size
319 Warning("CreateCalibration","pointer to calibration object exists\n");
320 fCalibration->Delete();
324 Int_t nModTot = GetITSgeom()->GetIndexMax();
325 fCalibration = new TObjArray(nModTot);
326 fCalibration->SetOwner(kTRUE);
327 fCalibration->Clear();
329 //_______________________________________________________________________
330 void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){
331 //Set response model for modules
333 if (fCalibration==0) CreateCalibrationArray();
335 if (fCalibration->At(iMod)!=0)
336 delete (AliITSCalibration*) fCalibration->At(iMod);
337 fCalibration->AddAt(resp, iMod);
339 //______________________________________________________________________
340 void AliITSDetTypeSim::ResetCalibrationArray(){
341 //resets response array
342 if(fCalibration && fRunNumber<0){ // if fRunNumber<0 fCalibration is owner
343 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
344 GetITSgeom()->GetStartSPD()))->GetResponse();
345 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
346 GetITSgeom()->GetStartSDD()))->GetResponse();
347 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
348 GetITSgeom()->GetStartSSD()))->GetResponse();
349 if(rspd) delete rspd;
350 if(rsdd) delete rsdd;
351 if(rssd) delete rssd;
352 fCalibration->Clear();
353 }else if (fCalibration && fRunNumber>=0){
354 fCalibration->Clear();
357 //______________________________________________________________________
358 void AliITSDetTypeSim::ResetSegmentation(){
359 //Resets segmentation array
360 if(fSegmentation) fSegmentation->Clear();
362 //_______________________________________________________________________
363 AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod){
364 //Get response model for module number iMod
366 if(fCalibration==0) {
367 AliError("fCalibration is 0!");
370 return (AliITSCalibration*)(fCalibration->At(iMod));
372 //_______________________________________________________________________
373 void AliITSDetTypeSim::SetDefaults(){
374 //Set defaults for segmentation and response
377 Warning("SetDefaults","GetITSgeom() is 0!");
380 if (fCalibration==0) {
381 CreateCalibrationArray();
385 if(!GetCalibration()){AliFatal("Exit"); exit(0);}
387 SetDigitClassName(0,"AliITSdigitSPD");
388 SetDigitClassName(1,"AliITSdigitSDD");
389 SetDigitClassName(2,"AliITSdigitSSD");
391 for(Int_t idet=0;idet<fgkNdettypes;idet++){
392 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
395 //______________________________________________________________________
396 Bool_t AliITSDetTypeSim::GetCalibration() {
397 // Get Default calibration if a storage is not defined.
400 AliITSCalibration* cal = GetCalibrationModel(0);
407 SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
408 Int_t run=GetRunNumber();
410 Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
411 Bool_t isCacheActive = kTRUE;
412 if(GetRunNumber()<0){
413 isCacheActive=kFALSE;
414 fCalibration->SetOwner(kTRUE);
417 fCalibration->SetOwner(kFALSE);
420 AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
422 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead", run);
423 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
424 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD",run);
425 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD",run);
426 AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD",run);
427 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD",run);
428 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
429 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
430 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
431 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
433 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
434 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
435 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
437 if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD ||
438 !entry2SPD || !entry2SDD || !entry2SSD || !drSpSDD || !ddlMapSDD || !mapASDD ||!mapTSDD){
439 AliFatal("Calibration object retrieval failed! ");
443 // if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD ||
444 // !entry2SPD || !entry2SDD || !entry2SSD){
445 // AliFatal("Calibration object retrieval failed! ");
449 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
450 if(!isCacheActive)entrySPD->SetObject(NULL);
451 entrySPD->SetOwner(kTRUE);
453 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
454 if(!isCacheActive)entry2SPD->SetObject(NULL);
455 entry2SPD->SetOwner(kTRUE);
457 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
458 if(!isCacheActive)entrySDD->SetObject(NULL);
459 entrySDD->SetOwner(kTRUE);
461 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
462 if(!isCacheActive)entry2SDD->SetObject(NULL);
463 entry2SDD->SetOwner(kTRUE);
465 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
466 if(!isCacheActive)drSpSDD->SetObject(NULL);
467 drSpSDD->SetOwner(kTRUE);
469 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
470 if(!isCacheActive)ddlMapSDD->SetObject(NULL);
471 ddlMapSDD->SetOwner(kTRUE);
473 TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
474 if(!isCacheActive)mapASDD->SetObject(NULL);
475 mapASDD->SetOwner(kTRUE);
477 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
478 if(!isCacheActive)mapTSDD->SetObject(NULL);
479 mapTSDD->SetOwner(kTRUE);
482 TObjArray *calSSD = (TObjArray *)entrySSD->GetObject();
483 if(!isCacheActive)entrySSD->SetObject(NULL);
484 entrySSD->SetOwner(kTRUE);
487 TObjArray *noiseSSD = (TObjArray *)entryNoiseSSD->GetObject();
488 if(!isCacheActive)entryNoiseSSD->SetObject(NULL);
489 entryNoiseSSD->SetOwner(kTRUE);
491 TObjArray *gainSSD = (TObjArray *)entryGainSSD->GetObject();
492 if(!isCacheActive)entryGainSSD->SetObject(NULL);
493 entryGainSSD->SetOwner(kTRUE);
495 TObjArray *badchannelsSSD = (TObjArray *)entryBadChannelsSSD->GetObject();
496 if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL);
497 entryBadChannelsSSD->SetOwner(kTRUE);
499 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
500 if(!isCacheActive)entry2SSD->SetObject(NULL);
501 entry2SSD->SetOwner(kTRUE);
503 // DB entries are deleted. In this way metadeta objects are deleted as well
507 delete entryNoiseSSD;
509 delete entryBadChannelsSSD;
519 AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
521 if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!calSDD) || (!drSp) || (!ddlsdd)
522 || (!mapAn) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) {
523 AliWarning("Can not get calibration from calibration database !");
527 fNMod[0] = calSPD->GetEntries();
528 fNMod[1] = calSDD->GetEntries();
529 fNMod[2] = noiseSSD->GetEntries();
530 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
531 fNMod[0], fNMod[1], fNMod[2]));
532 AliITSCalibration* cal;
533 for (Int_t i=0; i<fNMod[0]; i++) {
534 cal = (AliITSCalibration*) calSPD->At(i);
535 cal->SetResponse(pSPD);
536 SetCalibrationModel(i, cal);
539 fDDLMapSDD->SetDDLMap(ddlsdd);
541 for (Int_t i=0; i<fgkDefaultNModulesSDD; i++) {
543 Int_t iMod = i + fgkDefaultNModulesSPD;
544 fDDLMapSDD->FindInDDLMap(iMod,iddl,icarlos);
546 AliITSCalibrationSDD* calsdddead=new AliITSCalibrationSDD();
547 calsdddead->SetResponse(pSDD);
548 calsdddead->SetBad();
549 AliITSDriftSpeedSDD* driftspdef = new AliITSDriftSpeedSDD();
550 AliITSDriftSpeedArraySDD* arrdrsp=new AliITSDriftSpeedArraySDD(1);
551 arrdrsp->AddDriftSpeed(driftspdef);
552 calsdddead->SetDriftSpeed(0,arrdrsp);
553 calsdddead->SetDriftSpeed(1,arrdrsp);
554 SetCalibrationModel(iMod, calsdddead);
555 AliWarning(Form("SDD module %d not present in DDL map: set it as dead",iMod));
557 cal = (AliITSCalibration*) calSDD->At(i);
558 cal->SetResponse(pSDD);
561 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
562 AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
563 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
564 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
565 AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
566 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
567 cal->SetDriftSpeed(0,arr0);
568 cal->SetDriftSpeed(1,arr1);
573 SetCalibrationModel(iMod, cal);
577 for (Int_t i=0; i<fNMod[2]; i++) {
578 AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
579 calibSSD->SetResponse((AliITSresponse*)pSSD);
581 AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
582 calibSSD->SetNoise(noise);
583 AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
584 calibSSD->SetGain(gain);
585 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
586 calibSSD->SetBadChannels(bad);
588 Int_t iMod = i + fgkDefaultNModulesSPD + fgkDefaultNModulesSDD;
589 SetCalibrationModel(iMod, calibSSD);
594 //_______________________________________________________________________
595 void AliITSDetTypeSim::SetDefaultSimulation(){
596 //Set default simulation for detector type
599 Warning("SetDefaultSimulation","GetITSgeom() is 0!");
603 Warning("SetDefaultSimulation","fCalibration is 0!");
606 if(fSegmentation==0){
607 Warning("SetDefaultSimulation","fSegmentation is 0!");
608 for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i);
609 }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){
610 Warning("SetDefaultSimulation",
611 "Segmentation not defined for det %d - Default taken\n!",i);
612 SetDefaultSegmentation(i);
614 AliITSsimulation* sim;
616 for(Int_t idet=0;idet<fgkNdettypes;idet++){
619 sim = GetSimulationModel(idet);
621 sim = new AliITSsimulationSPD(this);
622 SetSimulationModel(idet,sim);
627 sim = GetSimulationModel(idet);
629 sim = new AliITSsimulationSDD(this);
630 SetSimulationModel(idet,sim);
635 sim = GetSimulationModel(idet);
637 sim = new AliITSsimulationSSD(this);
638 SetSimulationModel(idet,sim);
644 //___________________________________________________________________
645 void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, Char_t* name){
646 // Set branch address for the ITS summable digits Trees.
653 sprintf(branchname,"%s",name);
654 branch = treeS->GetBranch(branchname);
655 TClonesArray *sdigi = &fSDigits;
656 if (branch) branch->SetAddress(&sdigi);
659 //___________________________________________________________________
660 void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, Char_t* name){
661 // Set branch address for the digit Trees.
663 const char *det[3] = {"SPD","SDD","SSD"};
672 fDigits = new TObjArray(fgkNdettypes);
674 for(Int_t i=0;i<fgkNdettypes;i++){
675 Char_t* digclass = GetDigitClassName(i);
677 if(i==0) SetDigitClassName(i,"AliITSdigitSPD");
678 if(i==1) SetDigitClassName(i,"AliITSdigitSDD");
679 if(i==2) SetDigitClassName(i,"AliITSdigitSSD");
680 digclass = GetDigitClassName(i);
682 TString classn = digclass;
683 if(!(fDigits->At(i))){
684 fDigits->AddAt(new TClonesArray(classn.Data(),1000),i);
689 if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]);
690 else sprintf(branchname,"%sDigits%d",name,i+1);
692 branch = treeD->GetBranch(branchname);
693 if(branch) branch->SetAddress(&((*fDigits)[i]));
698 //___________________________________________________________________
699 void AliITSDetTypeSim::ResetDigits(){
700 // Reset number of digits and the digits array for the ITS detector.
703 Error("ResetDigits","fDigits is null!");
706 for(Int_t i=0;i<fgkNdettypes;i++){
710 //___________________________________________________________________
711 void AliITSDetTypeSim::ResetDigits(Int_t branch){
712 // Reset number of digits and the digits array for this branch.
714 if(fDigits->At(branch)){
715 ((TClonesArray*)fDigits->At(branch))->Clear();
717 if(fNDigits) fNDigits[branch]=0;
723 //_______________________________________________________________________
724 void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
725 // Standard Summable digits to Digits function.
727 Warning("SDigitsToDigits","GetITSgeom() is null!!");
731 const char *all = strstr(opt,"All");
732 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
734 if( !det[0] && !det[1] && !det[2] ) all = "All";
736 static Bool_t setDef = kTRUE;
737 if(setDef) SetDefaultSimulation();
740 AliITSsimulation *sim =0;
741 TTree* trees = fLoader->TreeS();
742 if( !(trees && GetSDigits()) ){
743 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
746 sprintf(name,"%s",name);
747 TBranch* brchSDigits = trees->GetBranch(name);
750 for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){
751 id = GetITSgeom()->GetModuleType(module);
752 if (!all && !det[id]) continue;
753 sim = (AliITSsimulation*)GetSimulationModel(id);
755 Error("SDigit2Digits","The simulation class was not "
756 "instanciated for module %d type %s!",module,
757 GetITSgeom()->GetModuleTypeName(module));
760 sim->InitSimulationModule(module,gAlice->GetEvNumber());
763 brchSDigits->GetEvent(module);
764 sim->AddSDigitsToModule(&fSDigits,0);
765 sim->FinishSDigitiseModule();
766 fLoader->TreeD()->Fill();
769 fLoader->TreeD()->GetEntries();
770 fLoader->TreeD()->AutoSave();
771 fLoader->TreeD()->Reset();
773 //_________________________________________________________
774 void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){
775 //Adds the module full of summable digits to the summable digits tree.
777 new(fSDigits[fNSDigits++]) AliITSpListItem(sdig);
779 //__________________________________________________________
780 void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){
781 // Add a simulated digit.
783 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
786 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
789 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
792 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
796 //______________________________________________________________________
797 void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,
798 Int_t *tracks,Int_t *hits,Float_t *charges,
800 // Add a simulated digit to the list.
802 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
805 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits);
808 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks,
809 hits,charges,sigexpanded);
812 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits);
816 //______________________________________________________________________
817 void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun,
818 AliCDBMetaData &md) {
819 // Store calibration in the calibration database
820 // The database must be created in an external piece of code (i.e.
821 // a configuration macro )
823 if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
824 AliWarning("No storage set! Will use dummy one");
825 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
829 AliError("AliITSCalibration classes are not defined - nothing done");
832 AliCDBId idRespSPD("ITS/Calib/SPDDead",firstRun, lastRun);
833 AliCDBId idRespSDD("ITS/Calib/CalibSDD",firstRun, lastRun);
834 AliCDBId idRespSSD("ITS/Calib/CalibSSD",firstRun, lastRun);
836 TObjArray respSPD(fNMod[0]);
837 TObjArray respSDD(fNMod[1]-fNMod[0]);
838 TObjArray respSSD(fNMod[2]-fNMod[1]);
839 respSPD.SetOwner(kFALSE);
840 respSSD.SetOwner(kFALSE);
841 respSSD.SetOwner(kFALSE);
843 Int_t index[fgkNdettypes];
844 for (Int_t i = 0; i<fgkNdettypes; i++ ) {
846 for (Int_t j = 0; j<=i; j++ )
850 for (Int_t i = 0; i<index[0]; i++ )
851 respSPD.Add(fCalibration->At(i));
853 for (Int_t i = index[0]; i<index[1]; i++ )
854 respSDD.Add(fCalibration->At(i));
856 for (Int_t i = index[1]; i<index[2]; i++ )
857 respSSD.Add(fCalibration->At(i));
859 AliCDBManager::Instance()->Put(&respSPD, idRespSPD, &md);
860 AliCDBManager::Instance()->Put(&respSDD, idRespSDD, &md);
861 AliCDBManager::Instance()->Put(&respSSD, idRespSSD, &md);