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 "AliITSCalibrationSSD.h"
48 #include "AliITSsegmentationSPD.h"
49 #include "AliITSsegmentationSDD.h"
50 #include "AliITSsegmentationSSD.h"
51 #include "AliITSsimulation.h"
52 #include "AliITSsimulationSPD.h"
53 #include "AliITSsimulationSDD.h"
54 #include "AliITSsimulationSSD.h"
57 const Int_t AliITSDetTypeSim::fgkNdettypes = 3;
58 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD = 240;
59 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD = 260;
60 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698;
62 ClassImp(AliITSDetTypeSim)
64 //----------------------------------------------------------------------
65 AliITSDetTypeSim::AliITSDetTypeSim():
67 fSimulation(), // [NDet]
68 fSegmentation(), // [NDet]
69 fCalibration(), // [NMod]
70 fPreProcess(), // [] e.g. Fill fHitModule with hits
71 fPostProcess(), // [] e.g. Wright Raw data
72 fNSDigits(0), //! number of SDigits
73 fSDigits(), //! [NMod][NSDigits]
74 fNDigits(0), //! number of Digits
75 fRunNumber(0), //! Run number (to access DB)
76 fDigits(), //! [NMod][NDigits]
77 fHitClassName(), // String with Hit class name.
78 fSDigClassName(),// String with SDigit class name.
79 fDigClassName(), // String with digit class name.
80 fLoader(0), // local pointer to loader
81 fFirstcall(kTRUE){ // flag
82 // Default Constructor
88 // A properly zero-ed AliITSDetTypeSim class.
90 fSimulation = new TObjArray(fgkNdettypes);
91 fSegmentation = new TObjArray(fgkNdettypes);
92 fSegmentation->SetOwner(kTRUE);
93 fSDigits = new TClonesArray("AliITSpListItem",1000);
94 fDigits = new TObjArray(fgkNdettypes);
95 fNDigits = new Int_t[fgkNdettypes];
96 fNMod[0] = fgkDefaultNModulesSPD;
97 fNMod[1] = fgkDefaultNModulesSDD;
98 fNMod[2] = fgkDefaultNModulesSSD;
101 //----------------------------------------------------------------------
102 AliITSDetTypeSim::~AliITSDetTypeSim(){
112 fSimulation->Delete();
117 fSegmentation->Delete();
118 delete fSegmentation;
121 if(fCalibration && fRunNumber<0){
122 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
123 GetITSgeom()->GetStartSPD()))->GetResponse();
124 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
125 GetITSgeom()->GetStartSDD()))->GetResponse();
126 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
127 GetITSgeom()->GetStartSSD()))->GetResponse();
128 if(rspd) delete rspd;
129 if(rsdd) delete rsdd;
130 if(rssd) delete rssd;
131 fCalibration->Delete();
136 fPreProcess->Delete();
141 fPostProcess->Delete();
145 if(fNDigits) delete [] fNDigits;
147 if (fLoader)fLoader->GetModulesFolder()->Remove(this);
148 fLoader = 0; // Not deleting it.
160 //----------------------------------------------------------------------
161 AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source){
162 // Copy Constructor for object AliITSDetTypeSim not allowed
164 if(this==&source) return;
165 Error("Copy constructor",
166 "You are not allowed to make a copy of the AliITSDetTypeSim");
169 //----------------------------------------------------------------------
170 AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
171 // The = operator for object AliITSDetTypeSim
173 if(&source==this) return *this;
175 "You are not allowed to make a copy of the AliITSDetTypeSIm");
180 //______________________________________________________________________
181 void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
182 // Sets/replaces the existing AliITSgeom object kept in AliITSLoader
185 // AliITSgoem *geom The AliITSgeom object to be used.
191 Error("SetITSgeom","No pointer to loader - nothing done");
195 fLoader->SetITSgeom(geom); // protections in AliITSLoader::SetITSgeom
199 //______________________________________________________________________
200 void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){
201 // Sets the local copy of the AliITSLoader, and passes on the
202 // AliITSgeom object as needed.
204 // AliITSLoader *loader pointer to AliITSLoader for local use
210 if(fLoader==loader) return; // Same do nothing
211 if(fLoader){ // alread have an existing loader
213 "Already have an exisiting loader ptr=%p Nothing done",
218 //______________________________________________________________________
219 void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){
221 //Set simulation model for detector type
223 if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes);
224 fSimulation->AddAt(sim,dettype);
226 //______________________________________________________________________
227 AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype){
229 //Get simulation model for detector type
231 Warning("GetSimulationModel","fSimulation is 0!");
234 return (AliITSsimulation*)(fSimulation->At(dettype));
236 //______________________________________________________________________
237 AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module){
239 //Get simulation model by module number
240 if(GetITSgeom()==0) {
241 Warning("GetSimulationModelByModule","GetITSgeom() is 0!");
245 return GetSimulationModel(GetITSgeom()->GetModuleType(module));
247 //_______________________________________________________________________
248 void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){
249 // Set default segmentation model objects
250 AliITSsegmentation *seg;
252 if(fSegmentation==0x0){
253 fSegmentation = new TObjArray(fgkNdettypes);
254 fSegmentation->SetOwner(kTRUE);
256 if(GetSegmentationModel(idet))
257 delete (AliITSsegmentation*)fSegmentation->At(idet);
259 seg = new AliITSsegmentationSPD(GetITSgeom());
261 AliITSCalibration* res=GetCalibrationModel(
262 GetITSgeom()->GetStartSDD());
263 seg = new AliITSsegmentationSDD(GetITSgeom(),res);
265 seg = new AliITSsegmentationSSD(GetITSgeom());
267 SetSegmentationModel(idet,seg);
269 //______________________________________________________________________
270 void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,
271 AliITSsegmentation *seg){
273 //Set segmentation model for detector type
274 if(fSegmentation==0x0){
275 fSegmentation = new TObjArray(fgkNdettypes);
276 fSegmentation->SetOwner(kTRUE);
278 fSegmentation->AddAt(seg,dettype);
280 //______________________________________________________________________
281 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype){
282 //Get segmentation model for detector type
284 if(fSegmentation==0) {
285 Warning("GetSegmentationModel","fSegmentation is 0!");
288 return (AliITSsegmentation*)(fSegmentation->At(dettype));
290 //_______________________________________________________________________
291 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module){
292 //Get segmentation model by module number
294 Warning("GetSegmentationModelByModule","GetITSgeom() is 0!");
297 return GetSegmentationModel(GetITSgeom()->GetModuleType(module));
299 //_______________________________________________________________________
300 void AliITSDetTypeSim::CreateCalibrationArray() {
301 //Create the container of calibration functions with correct size
303 Warning("CreateCalibration","pointer to calibration object exists\n");
304 fCalibration->Delete();
308 Int_t nModTot = GetITSgeom()->GetIndexMax();
309 fCalibration = new TObjArray(nModTot);
310 fCalibration->SetOwner(kTRUE);
311 fCalibration->Clear();
313 //_______________________________________________________________________
314 void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){
315 //Set response model for modules
317 if (fCalibration==0) CreateCalibrationArray();
319 if (fCalibration->At(iMod)!=0)
320 delete (AliITSCalibration*) fCalibration->At(iMod);
321 fCalibration->AddAt(resp, iMod);
323 //______________________________________________________________________
324 void AliITSDetTypeSim::ResetCalibrationArray(){
325 //resets response array
326 if(fCalibration && fRunNumber<0){ // if fRunNumber<0 fCalibration is owner
327 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
328 GetITSgeom()->GetStartSPD()))->GetResponse();
329 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
330 GetITSgeom()->GetStartSDD()))->GetResponse();
331 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
332 GetITSgeom()->GetStartSSD()))->GetResponse();
333 if(rspd) delete rspd;
334 if(rsdd) delete rsdd;
335 if(rssd) delete rssd;
336 fCalibration->Clear();
337 }else if (fCalibration && fRunNumber>=0){
338 fCalibration->Clear();
341 //______________________________________________________________________
342 void AliITSDetTypeSim::ResetSegmentation(){
343 //Resets segmentation array
344 if(fSegmentation) fSegmentation->Clear();
346 //_______________________________________________________________________
347 AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod){
348 //Get response model for module number iMod
350 if(fCalibration==0) {
351 AliError("fCalibration is 0!");
354 return (AliITSCalibration*)(fCalibration->At(iMod));
356 //_______________________________________________________________________
357 void AliITSDetTypeSim::SetDefaults(){
358 //Set defaults for segmentation and response
361 Warning("SetDefaults","GetITSgeom() is 0!");
364 if (fCalibration==0) {
365 CreateCalibrationArray();
369 if(!GetCalibration()){AliFatal("Exit"); exit(0);}
371 for(Int_t idet=0;idet<fgkNdettypes;idet++){
374 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
375 const char *kData0=(GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
376 if (strstr(kData0,"real")) {
377 SetDigitClassName(idet,"AliITSdigit");
379 SetDigitClassName(idet,"AliITSdigitSPD");
384 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
385 AliITSCalibrationSDD* rsp =
386 (AliITSCalibrationSDD*)GetCalibrationModel(
387 GetITSgeom()->GetStartSDD());
388 const char *kopt = ((AliITSresponseSDD*)rsp->GetResponse())->
390 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) {
391 SetDigitClassName(idet,"AliITSdigit");
393 SetDigitClassName(idet,"AliITSdigitSDD");
398 if(!GetSegmentationModel(idet))SetDefaultSegmentation(idet);
399 const char *kData2 = (GetCalibrationModel(
400 GetITSgeom()->GetStartSSD())->DataType());
401 if (strstr(kData2,"real")) {
402 SetDigitClassName(idet,"AliITSdigit");
404 SetDigitClassName(idet,"AliITSdigitSSD");
409 //______________________________________________________________________
410 Bool_t AliITSDetTypeSim::GetCalibration() {
411 // Get Default calibration if a storage is not defined.
414 AliITSCalibration* cal = GetCalibrationModel(0);
421 SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
422 Int_t run=GetRunNumber();
423 if(run<0)run=0; // if the run number is not yet set, use fake run # 0
425 Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
426 Bool_t isCacheActive = kTRUE;
427 if(GetRunNumber()<0){
428 isCacheActive=kFALSE;
429 fCalibration->SetOwner(kTRUE);
432 fCalibration->SetOwner(kFALSE);
435 AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
437 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run);
438 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
439 AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
440 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
441 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
442 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
444 if(!entrySPD || !entrySDD || !entrySSD || !entry2SPD || !entry2SDD || !entry2SSD){
445 AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
446 AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
447 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
449 entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run);
450 entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
451 entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
452 entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
453 entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
454 entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
456 AliCDBManager::Instance()->SetDefaultStorage(origStorage);
460 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
461 if(!isCacheActive)entrySPD->SetObject(NULL);
462 entrySPD->SetOwner(kTRUE);
464 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
465 if(!isCacheActive)entry2SPD->SetObject(NULL);
466 entry2SPD->SetOwner(kTRUE);
468 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
469 if(!isCacheActive)entrySDD->SetObject(NULL);
470 entrySDD->SetOwner(kTRUE);
472 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
473 if(!isCacheActive)entry2SDD->SetObject(NULL);
474 entry2SDD->SetOwner(kTRUE);
476 TObjArray *calSSD = (TObjArray *)entrySSD->GetObject();
477 if(!isCacheActive)entrySSD->SetObject(NULL);
478 entrySSD->SetOwner(kTRUE);
480 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
481 if(!isCacheActive)entry2SSD->SetObject(NULL);
482 entry2SSD->SetOwner(kTRUE);
484 // DB entries are deleted. In this way metadeta objects are deleted as well
494 AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
496 if ((!pSPD)||(!pSDD)||(!pSSD)) {
497 AliWarning("Can not get calibration from calibration database !");
500 if ((! calSPD)||(! calSDD)||(! calSSD)) {
501 AliWarning("Can not get calibration from calibration database !");
504 fNMod[0] = calSPD->GetEntries();
505 fNMod[1] = calSDD->GetEntries();
506 fNMod[2] = calSSD->GetEntries();
507 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
508 fNMod[0], fNMod[1], fNMod[2]));
509 AliITSCalibration* cal;
510 for (Int_t i=0; i<fNMod[0]; i++) {
511 cal = (AliITSCalibration*) calSPD->At(i);
512 cal->SetResponse(pSPD);
513 SetCalibrationModel(i, cal);
515 for (Int_t i=0; i<fNMod[1]; i++) {
516 cal = (AliITSCalibration*) calSDD->At(i);
517 cal->SetResponse(pSDD);
518 Int_t iMod = i + fNMod[0];
519 SetCalibrationModel(iMod, cal);
521 for (Int_t i=0; i<fNMod[2]; i++) {
522 cal = (AliITSCalibration*) calSSD->At(i);
523 cal->SetResponse(pSSD);
524 Int_t iMod = i + fNMod[0] + fNMod[1];
525 SetCalibrationModel(iMod, cal);
529 //_______________________________________________________________________
530 void AliITSDetTypeSim::SetDefaultSimulation(){
531 //Set default simulation for detector type
534 Warning("SetDefaultSimulation","GetITSgeom() is 0!");
538 Warning("SetDefaultSimulation","fCalibration is 0!");
541 if(fSegmentation==0){
542 Warning("SetDefaultSimulation","fSegmentation is 0!");
543 for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i);
544 }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){
545 Warning("SetDefaultSimulation",
546 "Segmentation not defined for det %d - Default taken\n!",i);
547 SetDefaultSegmentation(i);
549 AliITSsimulation* sim;
551 for(Int_t idet=0;idet<fgkNdettypes;idet++){
554 sim = GetSimulationModel(idet);
556 sim = new AliITSsimulationSPD(this);
557 SetSimulationModel(idet,sim);
562 sim = GetSimulationModel(idet);
564 sim = new AliITSsimulationSDD(this);
565 SetSimulationModel(idet,sim);
570 sim = GetSimulationModel(idet);
572 sim = new AliITSsimulationSSD(this);
573 SetSimulationModel(idet,sim);
579 //___________________________________________________________________
580 void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, Char_t* name){
581 // Set branch address for the ITS summable digits Trees.
587 if (fSDigits == 0x0){
588 fSDigits = new TClonesArray("AliITSpListItem",1000);
591 sprintf(branchname,"%s",name);
592 branch = treeS->GetBranch(branchname);
593 if (branch) branch->SetAddress(&fSDigits);
596 //___________________________________________________________________
597 void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, Char_t* name){
598 // Set branch address for the digit Trees.
600 const char *det[3] = {"SPD","SDD","SSD"};
609 fDigits = new TObjArray(fgkNdettypes);
611 for(Int_t i=0;i<fgkNdettypes;i++){
612 Char_t* digclass = GetDigitClassName(i);
614 if(i==0) SetDigitClassName(i,"AliITSdigitSPD");
615 if(i==1) SetDigitClassName(i,"AliITSdigitSDD");
616 if(i==2) SetDigitClassName(i,"AliITSdigitSSD");
617 digclass = GetDigitClassName(i);
619 TString classn = digclass;
620 if(!(fDigits->At(i))){
621 fDigits->AddAt(new TClonesArray(classn.Data(),1000),i);
626 if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]);
627 else sprintf(branchname,"%sDigits%d",name,i+1);
629 branch = treeD->GetBranch(branchname);
630 if(branch) branch->SetAddress(&((*fDigits)[i]));
635 //___________________________________________________________________
636 void AliITSDetTypeSim::ResetDigits(){
637 // Reset number of digits and the digits array for the ITS detector.
640 Error("ResetDigits","fDigits is null!");
643 for(Int_t i=0;i<fgkNdettypes;i++){
647 //___________________________________________________________________
648 void AliITSDetTypeSim::ResetDigits(Int_t branch){
649 // Reset number of digits and the digits array for this branch.
651 if(fDigits->At(branch)){
652 ((TClonesArray*)fDigits->At(branch))->Clear();
654 if(fNDigits) fNDigits[branch]=0;
660 //_______________________________________________________________________
661 void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
662 // Standard Summable digits to Digits function.
664 Warning("SDigitsToDigits","GetITSgeom() is null!!");
668 const char *all = strstr(opt,"All");
669 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
671 if( !det[0] && !det[1] && !det[2] ) all = "All";
673 static Bool_t setDef = kTRUE;
674 if(setDef) SetDefaultSimulation();
677 AliITSsimulation *sim =0;
678 TTree* trees = fLoader->TreeS();
679 if( !(trees && GetSDigits()) ){
680 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
683 sprintf(name,"%s",name);
684 TBranch* brchSDigits = trees->GetBranch(name);
687 for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){
688 id = GetITSgeom()->GetModuleType(module);
689 if (!all && !det[id]) continue;
690 sim = (AliITSsimulation*)GetSimulationModel(id);
692 Error("SDigit2Digits","The simulation class was not "
693 "instanciated for module %d type %s!",module,
694 GetITSgeom()->GetModuleTypeName(module));
697 sim->InitSimulationModule(module,gAlice->GetEvNumber());
700 brchSDigits->GetEvent(module);
701 sim->AddSDigitsToModule(fSDigits,0);
702 sim->FinishSDigitiseModule();
703 fLoader->TreeD()->Fill();
706 fLoader->TreeD()->GetEntries();
707 fLoader->TreeD()->AutoSave();
708 fLoader->TreeD()->Reset();
710 //_________________________________________________________
711 void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){
712 //Adds the module full of summable digits to the summable digits tree.
714 TClonesArray &lsdig = *fSDigits;
715 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
717 //__________________________________________________________
718 void AliITSDetTypeSim::AddRealDigit(Int_t branch, Int_t *digits){
719 // Add a real digit - as coming from data.
721 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
722 new(ldigits[fNDigits[branch]++]) AliITSdigit(digits);
724 //__________________________________________________________
725 void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){
726 // Add a simulated digit.
728 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
731 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
734 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
737 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
741 //______________________________________________________________________
742 void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,
743 Int_t *tracks,Int_t *hits,Float_t *charges){
744 // Add a simulated digit to the list.
746 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
747 AliITSCalibrationSDD *resp = 0;
750 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits);
753 resp = (AliITSCalibrationSDD*)GetCalibrationModel(
754 GetITSgeom()->GetStartSDD());
755 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks,
759 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits);
763 //______________________________________________________________________
764 void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun,
765 AliCDBMetaData &md) {
766 // Store calibration in the calibration database
767 // The database must be created in an external piece of code (i.e.
768 // a configuration macro )
770 if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
771 AliWarning("No storage set! Will use dummy one");
772 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
776 AliError("AliITSCalibration classes are not defined - nothing done");
779 AliCDBId idRespSPD("ITS/Calib/CalibSPD",firstRun, lastRun);
780 AliCDBId idRespSDD("ITS/Calib/CalibSDD",firstRun, lastRun);
781 AliCDBId idRespSSD("ITS/Calib/CalibSSD",firstRun, lastRun);
783 TObjArray respSPD(fNMod[0]);
784 TObjArray respSDD(fNMod[1]-fNMod[0]);
785 TObjArray respSSD(fNMod[2]-fNMod[1]);
786 respSPD.SetOwner(kFALSE);
787 respSSD.SetOwner(kFALSE);
788 respSSD.SetOwner(kFALSE);
790 Int_t index[fgkNdettypes];
791 for (Int_t i = 0; i<fgkNdettypes; i++ ) {
793 for (Int_t j = 0; j<=i; j++ )
797 for (Int_t i = 0; i<index[0]; i++ )
798 respSPD.Add(fCalibration->At(i));
800 for (Int_t i = index[0]; i<index[1]; i++ )
801 respSDD.Add(fCalibration->At(i));
803 for (Int_t i = index[1]; i<index[2]; i++ )
804 respSSD.Add(fCalibration->At(i));
806 AliCDBManager::Instance()->Put(&respSPD, idRespSPD, &md);
807 AliCDBManager::Instance()->Put(&respSDD, idRespSDD, &md);
808 AliCDBManager::Instance()->Put(&respSSD, idRespSSD, &md);