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 fSimulation(source.fSimulation), // [NDet]
163 fSegmentation(source.fSegmentation), // [NDet]
164 fCalibration(source.fCalibration), // [NMod]
165 fPreProcess(source.fPreProcess), // [] e.g. Fill fHitModule with hits
166 fPostProcess(source.fPostProcess), // [] e.g. Wright Raw data
167 fNSDigits(source.fNSDigits), //! number of SDigits
168 fSDigits(source.fSDigits), //! [NMod][NSDigits]
169 fNDigits(source.fNDigits), //! number of Digits
170 fRunNumber(source.fRunNumber), //! Run number (to access DB)
171 fDigits(source.fDigits), //! [NMod][NDigits]
172 fHitClassName(source.fHitClassName), // String with Hit class name.
173 fSDigClassName(source.fSDigClassName),// String with SDigit class name.
174 fDigClassName(), // String with digit class name.
175 fLoader(source.fLoader), // local pointer to loader
176 fFirstcall(source.fFirstcall)
178 // Copy Constructor for object AliITSDetTypeSim not allowed
179 for(Int_t i=0;i<fgkNdettypes;i++){
180 fDigClassName[i] = source.fDigClassName[i];
183 //----------------------------------------------------------------------
184 AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
185 // The = operator for object AliITSDetTypeSim
187 this->~AliITSDetTypeSim();
188 new(this) AliITSDetTypeSim(source);
192 //______________________________________________________________________
193 void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
194 // Sets/replaces the existing AliITSgeom object kept in AliITSLoader
197 // AliITSgoem *geom The AliITSgeom object to be used.
203 Error("SetITSgeom","No pointer to loader - nothing done");
207 fLoader->SetITSgeom(geom); // protections in AliITSLoader::SetITSgeom
211 //______________________________________________________________________
212 void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){
213 // Sets the local copy of the AliITSLoader, and passes on the
214 // AliITSgeom object as needed.
216 // AliITSLoader *loader pointer to AliITSLoader for local use
222 if(fLoader==loader) return; // Same do nothing
223 if(fLoader){ // alread have an existing loader
225 "Already have an exisiting loader ptr=%p Nothing done",
230 //______________________________________________________________________
231 void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){
233 //Set simulation model for detector type
235 if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes);
236 fSimulation->AddAt(sim,dettype);
238 //______________________________________________________________________
239 AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype){
241 //Get simulation model for detector type
243 Warning("GetSimulationModel","fSimulation is 0!");
246 return (AliITSsimulation*)(fSimulation->At(dettype));
248 //______________________________________________________________________
249 AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module){
251 //Get simulation model by module number
252 if(GetITSgeom()==0) {
253 Warning("GetSimulationModelByModule","GetITSgeom() is 0!");
257 return GetSimulationModel(GetITSgeom()->GetModuleType(module));
259 //_______________________________________________________________________
260 void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){
261 // Set default segmentation model objects
262 AliITSsegmentation *seg;
264 if(fSegmentation==0x0){
265 fSegmentation = new TObjArray(fgkNdettypes);
266 fSegmentation->SetOwner(kTRUE);
268 if(GetSegmentationModel(idet))
269 delete (AliITSsegmentation*)fSegmentation->At(idet);
271 seg = new AliITSsegmentationSPD(GetITSgeom());
273 AliITSCalibration* res=GetCalibrationModel(
274 GetITSgeom()->GetStartSDD());
275 seg = new AliITSsegmentationSDD(GetITSgeom(),res);
277 seg = new AliITSsegmentationSSD(GetITSgeom());
279 SetSegmentationModel(idet,seg);
281 //______________________________________________________________________
282 void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,
283 AliITSsegmentation *seg){
285 //Set segmentation model for detector type
286 if(fSegmentation==0x0){
287 fSegmentation = new TObjArray(fgkNdettypes);
288 fSegmentation->SetOwner(kTRUE);
290 fSegmentation->AddAt(seg,dettype);
292 //______________________________________________________________________
293 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype){
294 //Get segmentation model for detector type
296 if(fSegmentation==0) {
297 Warning("GetSegmentationModel","fSegmentation is 0!");
300 return (AliITSsegmentation*)(fSegmentation->At(dettype));
302 //_______________________________________________________________________
303 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module){
304 //Get segmentation model by module number
306 Warning("GetSegmentationModelByModule","GetITSgeom() is 0!");
309 return GetSegmentationModel(GetITSgeom()->GetModuleType(module));
311 //_______________________________________________________________________
312 void AliITSDetTypeSim::CreateCalibrationArray() {
313 //Create the container of calibration functions with correct size
315 Warning("CreateCalibration","pointer to calibration object exists\n");
316 fCalibration->Delete();
320 Int_t nModTot = GetITSgeom()->GetIndexMax();
321 fCalibration = new TObjArray(nModTot);
322 fCalibration->SetOwner(kTRUE);
323 fCalibration->Clear();
325 //_______________________________________________________________________
326 void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){
327 //Set response model for modules
329 if (fCalibration==0) CreateCalibrationArray();
331 if (fCalibration->At(iMod)!=0)
332 delete (AliITSCalibration*) fCalibration->At(iMod);
333 fCalibration->AddAt(resp, iMod);
335 //______________________________________________________________________
336 void AliITSDetTypeSim::ResetCalibrationArray(){
337 //resets response array
338 if(fCalibration && fRunNumber<0){ // if fRunNumber<0 fCalibration is owner
339 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
340 GetITSgeom()->GetStartSPD()))->GetResponse();
341 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
342 GetITSgeom()->GetStartSDD()))->GetResponse();
343 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
344 GetITSgeom()->GetStartSSD()))->GetResponse();
345 if(rspd) delete rspd;
346 if(rsdd) delete rsdd;
347 if(rssd) delete rssd;
348 fCalibration->Clear();
349 }else if (fCalibration && fRunNumber>=0){
350 fCalibration->Clear();
353 //______________________________________________________________________
354 void AliITSDetTypeSim::ResetSegmentation(){
355 //Resets segmentation array
356 if(fSegmentation) fSegmentation->Clear();
358 //_______________________________________________________________________
359 AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod){
360 //Get response model for module number iMod
362 if(fCalibration==0) {
363 AliError("fCalibration is 0!");
366 return (AliITSCalibration*)(fCalibration->At(iMod));
368 //_______________________________________________________________________
369 void AliITSDetTypeSim::SetDefaults(){
370 //Set defaults for segmentation and response
373 Warning("SetDefaults","GetITSgeom() is 0!");
376 if (fCalibration==0) {
377 CreateCalibrationArray();
381 if(!GetCalibration()){AliFatal("Exit"); exit(0);}
383 for(Int_t idet=0;idet<fgkNdettypes;idet++){
386 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
387 const char *kData0=(GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
388 if (strstr(kData0,"real")) {
389 SetDigitClassName(idet,"AliITSdigit");
391 SetDigitClassName(idet,"AliITSdigitSPD");
396 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
397 AliITSCalibrationSDD* rsp =
398 (AliITSCalibrationSDD*)GetCalibrationModel(
399 GetITSgeom()->GetStartSDD());
400 const char *kopt = ((AliITSresponseSDD*)rsp->GetResponse())->
402 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) {
403 SetDigitClassName(idet,"AliITSdigit");
405 SetDigitClassName(idet,"AliITSdigitSDD");
410 if(!GetSegmentationModel(idet))SetDefaultSegmentation(idet);
411 const char *kData2 = (GetCalibrationModel(
412 GetITSgeom()->GetStartSSD())->DataType());
413 if (strstr(kData2,"real")) {
414 SetDigitClassName(idet,"AliITSdigit");
416 SetDigitClassName(idet,"AliITSdigitSSD");
421 //______________________________________________________________________
422 Bool_t AliITSDetTypeSim::GetCalibration() {
423 // Get Default calibration if a storage is not defined.
426 AliITSCalibration* cal = GetCalibrationModel(0);
433 SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
434 Int_t run=GetRunNumber();
435 if(run<0)run=0; // if the run number is not yet set, use fake run # 0
437 Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
438 Bool_t isCacheActive = kTRUE;
439 if(GetRunNumber()<0){
440 isCacheActive=kFALSE;
441 fCalibration->SetOwner(kTRUE);
444 fCalibration->SetOwner(kFALSE);
447 AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
449 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run);
450 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
451 AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
452 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
453 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
454 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
456 if(!entrySPD || !entrySDD || !entrySSD || !entry2SPD || !entry2SDD || !entry2SSD){
457 AliFatal("Calibration object retrieval failed!");
461 if(!entrySPD || !entrySDD || !entrySSD || !entry2SPD || !entry2SDD || !entry2SSD){
462 AliError("Calibration data was not found in $ALICE_ROOT!");
466 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
467 if(!isCacheActive)entrySPD->SetObject(NULL);
468 entrySPD->SetOwner(kTRUE);
470 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
471 if(!isCacheActive)entry2SPD->SetObject(NULL);
472 entry2SPD->SetOwner(kTRUE);
474 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
475 if(!isCacheActive)entrySDD->SetObject(NULL);
476 entrySDD->SetOwner(kTRUE);
478 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
479 if(!isCacheActive)entry2SDD->SetObject(NULL);
480 entry2SDD->SetOwner(kTRUE);
482 TObjArray *calSSD = (TObjArray *)entrySSD->GetObject();
483 if(!isCacheActive)entrySSD->SetObject(NULL);
484 entrySSD->SetOwner(kTRUE);
486 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
487 if(!isCacheActive)entry2SSD->SetObject(NULL);
488 entry2SSD->SetOwner(kTRUE);
490 // DB entries are deleted. In this way metadeta objects are deleted as well
500 AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
502 if ((!pSPD)||(!pSDD)||(!pSSD)) {
503 AliWarning("Can not get calibration from calibration database !");
506 if ((! calSPD)||(! calSDD)||(! calSSD)) {
507 AliWarning("Can not get calibration from calibration database !");
510 fNMod[0] = calSPD->GetEntries();
511 fNMod[1] = calSDD->GetEntries();
512 fNMod[2] = calSSD->GetEntries();
513 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
514 fNMod[0], fNMod[1], fNMod[2]));
515 AliITSCalibration* cal;
516 for (Int_t i=0; i<fNMod[0]; i++) {
517 cal = (AliITSCalibration*) calSPD->At(i);
518 cal->SetResponse(pSPD);
519 SetCalibrationModel(i, cal);
521 for (Int_t i=0; i<fNMod[1]; i++) {
522 cal = (AliITSCalibration*) calSDD->At(i);
523 cal->SetResponse(pSDD);
524 Int_t iMod = i + fNMod[0];
525 SetCalibrationModel(iMod, cal);
527 for (Int_t i=0; i<fNMod[2]; i++) {
528 cal = (AliITSCalibration*) calSSD->At(i);
529 cal->SetResponse(pSSD);
530 Int_t iMod = i + fNMod[0] + fNMod[1];
531 SetCalibrationModel(iMod, cal);
535 //_______________________________________________________________________
536 void AliITSDetTypeSim::SetDefaultSimulation(){
537 //Set default simulation for detector type
540 Warning("SetDefaultSimulation","GetITSgeom() is 0!");
544 Warning("SetDefaultSimulation","fCalibration is 0!");
547 if(fSegmentation==0){
548 Warning("SetDefaultSimulation","fSegmentation is 0!");
549 for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i);
550 }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){
551 Warning("SetDefaultSimulation",
552 "Segmentation not defined for det %d - Default taken\n!",i);
553 SetDefaultSegmentation(i);
555 AliITSsimulation* sim;
557 for(Int_t idet=0;idet<fgkNdettypes;idet++){
560 sim = GetSimulationModel(idet);
562 sim = new AliITSsimulationSPD(this);
563 SetSimulationModel(idet,sim);
568 sim = GetSimulationModel(idet);
570 sim = new AliITSsimulationSDD(this);
571 SetSimulationModel(idet,sim);
576 sim = GetSimulationModel(idet);
578 sim = new AliITSsimulationSSD(this);
579 SetSimulationModel(idet,sim);
585 //___________________________________________________________________
586 void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, Char_t* name){
587 // Set branch address for the ITS summable digits Trees.
593 if (fSDigits == 0x0){
594 fSDigits = new TClonesArray("AliITSpListItem",1000);
597 sprintf(branchname,"%s",name);
598 branch = treeS->GetBranch(branchname);
599 if (branch) branch->SetAddress(&fSDigits);
602 //___________________________________________________________________
603 void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, Char_t* name){
604 // Set branch address for the digit Trees.
606 const char *det[3] = {"SPD","SDD","SSD"};
615 fDigits = new TObjArray(fgkNdettypes);
617 for(Int_t i=0;i<fgkNdettypes;i++){
618 Char_t* digclass = GetDigitClassName(i);
620 if(i==0) SetDigitClassName(i,"AliITSdigitSPD");
621 if(i==1) SetDigitClassName(i,"AliITSdigitSDD");
622 if(i==2) SetDigitClassName(i,"AliITSdigitSSD");
623 digclass = GetDigitClassName(i);
625 TString classn = digclass;
626 if(!(fDigits->At(i))){
627 fDigits->AddAt(new TClonesArray(classn.Data(),1000),i);
632 if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]);
633 else sprintf(branchname,"%sDigits%d",name,i+1);
635 branch = treeD->GetBranch(branchname);
636 if(branch) branch->SetAddress(&((*fDigits)[i]));
641 //___________________________________________________________________
642 void AliITSDetTypeSim::ResetDigits(){
643 // Reset number of digits and the digits array for the ITS detector.
646 Error("ResetDigits","fDigits is null!");
649 for(Int_t i=0;i<fgkNdettypes;i++){
653 //___________________________________________________________________
654 void AliITSDetTypeSim::ResetDigits(Int_t branch){
655 // Reset number of digits and the digits array for this branch.
657 if(fDigits->At(branch)){
658 ((TClonesArray*)fDigits->At(branch))->Clear();
660 if(fNDigits) fNDigits[branch]=0;
666 //_______________________________________________________________________
667 void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
668 // Standard Summable digits to Digits function.
670 Warning("SDigitsToDigits","GetITSgeom() is null!!");
674 const char *all = strstr(opt,"All");
675 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
677 if( !det[0] && !det[1] && !det[2] ) all = "All";
679 static Bool_t setDef = kTRUE;
680 if(setDef) SetDefaultSimulation();
683 AliITSsimulation *sim =0;
684 TTree* trees = fLoader->TreeS();
685 if( !(trees && GetSDigits()) ){
686 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
689 sprintf(name,"%s",name);
690 TBranch* brchSDigits = trees->GetBranch(name);
693 for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){
694 id = GetITSgeom()->GetModuleType(module);
695 if (!all && !det[id]) continue;
696 sim = (AliITSsimulation*)GetSimulationModel(id);
698 Error("SDigit2Digits","The simulation class was not "
699 "instanciated for module %d type %s!",module,
700 GetITSgeom()->GetModuleTypeName(module));
703 sim->InitSimulationModule(module,gAlice->GetEvNumber());
706 brchSDigits->GetEvent(module);
707 sim->AddSDigitsToModule(fSDigits,0);
708 sim->FinishSDigitiseModule();
709 fLoader->TreeD()->Fill();
712 fLoader->TreeD()->GetEntries();
713 fLoader->TreeD()->AutoSave();
714 fLoader->TreeD()->Reset();
716 //_________________________________________________________
717 void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){
718 //Adds the module full of summable digits to the summable digits tree.
720 TClonesArray &lsdig = *fSDigits;
721 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
723 //__________________________________________________________
724 void AliITSDetTypeSim::AddRealDigit(Int_t branch, Int_t *digits){
725 // Add a real digit - as coming from data.
727 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
728 new(ldigits[fNDigits[branch]++]) AliITSdigit(digits);
730 //__________________________________________________________
731 void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){
732 // Add a simulated digit.
734 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
737 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
740 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
743 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
747 //______________________________________________________________________
748 void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,
749 Int_t *tracks,Int_t *hits,Float_t *charges){
750 // Add a simulated digit to the list.
752 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
753 AliITSCalibrationSDD *resp = 0;
756 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits);
759 resp = (AliITSCalibrationSDD*)GetCalibrationModel(
760 GetITSgeom()->GetStartSDD());
761 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks,
765 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits);
769 //______________________________________________________________________
770 void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun,
771 AliCDBMetaData &md) {
772 // Store calibration in the calibration database
773 // The database must be created in an external piece of code (i.e.
774 // a configuration macro )
776 if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
777 AliWarning("No storage set! Will use dummy one");
778 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
782 AliError("AliITSCalibration classes are not defined - nothing done");
785 AliCDBId idRespSPD("ITS/Calib/CalibSPD",firstRun, lastRun);
786 AliCDBId idRespSDD("ITS/Calib/CalibSDD",firstRun, lastRun);
787 AliCDBId idRespSSD("ITS/Calib/CalibSSD",firstRun, lastRun);
789 TObjArray respSPD(fNMod[0]);
790 TObjArray respSDD(fNMod[1]-fNMod[0]);
791 TObjArray respSSD(fNMod[2]-fNMod[1]);
792 respSPD.SetOwner(kFALSE);
793 respSSD.SetOwner(kFALSE);
794 respSSD.SetOwner(kFALSE);
796 Int_t index[fgkNdettypes];
797 for (Int_t i = 0; i<fgkNdettypes; i++ ) {
799 for (Int_t j = 0; j<=i; j++ )
803 for (Int_t i = 0; i<index[0]; i++ )
804 respSPD.Add(fCalibration->At(i));
806 for (Int_t i = index[0]; i<index[1]; i++ )
807 respSDD.Add(fCalibration->At(i));
809 for (Int_t i = index[1]; i<index[2]; i++ )
810 respSSD.Add(fCalibration->At(i));
812 AliCDBManager::Instance()->Put(&respSPD, idRespSPD, &md);
813 AliCDBManager::Instance()->Put(&respSDD, idRespSDD, &md);
814 AliCDBManager::Instance()->Put(&respSSD, idRespSSD, &md);