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 "AliITSNoiseSSD.h"
49 #include "AliITSGainSSD.h"
50 #include "AliITSBadChannelsSSD.h"
51 #include "AliITSCalibrationSSD.h"
52 #include "AliITSsegmentationSPD.h"
53 #include "AliITSsegmentationSDD.h"
54 #include "AliITSsegmentationSSD.h"
55 #include "AliITSsimulation.h"
56 #include "AliITSsimulationSPD.h"
57 #include "AliITSsimulationSDD.h"
58 #include "AliITSsimulationSSD.h"
61 const Int_t AliITSDetTypeSim::fgkNdettypes = 3;
62 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD = 240;
63 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD = 260;
64 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698;
66 ClassImp(AliITSDetTypeSim)
68 //----------------------------------------------------------------------
69 AliITSDetTypeSim::AliITSDetTypeSim():
71 fSimulation(), // [NDet]
72 fSegmentation(), // [NDet]
73 fCalibration(), // [NMod]
74 fPreProcess(), // [] e.g. Fill fHitModule with hits
75 fPostProcess(), // [] e.g. Wright Raw data
76 fNSDigits(0), //! number of SDigits
77 fSDigits(), //! [NMod][NSDigits]
78 fNDigits(0), //! number of Digits
79 fRunNumber(0), //! Run number (to access DB)
80 fDigits(), //! [NMod][NDigits]
81 fHitClassName(), // String with Hit class name.
82 fSDigClassName(),// String with SDigit class name.
83 fDigClassName(), // String with digit class name.
84 fLoader(0), // local pointer to loader
85 fFirstcall(kTRUE){ // flag
86 // Default Constructor
92 // A properly zero-ed AliITSDetTypeSim class.
94 fSimulation = new TObjArray(fgkNdettypes);
95 fSegmentation = new TObjArray(fgkNdettypes);
96 fSegmentation->SetOwner(kTRUE);
97 fSDigits = new TClonesArray("AliITSpListItem",1000);
98 fDigits = new TObjArray(fgkNdettypes);
99 fNDigits = new Int_t[fgkNdettypes];
100 fNMod[0] = fgkDefaultNModulesSPD;
101 fNMod[1] = fgkDefaultNModulesSDD;
102 fNMod[2] = fgkDefaultNModulesSSD;
105 //----------------------------------------------------------------------
106 AliITSDetTypeSim::~AliITSDetTypeSim(){
116 fSimulation->Delete();
121 fSegmentation->Delete();
122 delete fSegmentation;
125 if(fCalibration && fRunNumber<0){
126 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
127 GetITSgeom()->GetStartSPD()))->GetResponse();
128 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
129 GetITSgeom()->GetStartSDD()))->GetResponse();
130 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
131 GetITSgeom()->GetStartSSD()))->GetResponse();
132 if(rspd) delete rspd;
133 if(rsdd) delete rsdd;
134 if(rssd) delete rssd;
135 fCalibration->Delete();
140 fPreProcess->Delete();
145 fPostProcess->Delete();
149 if(fNDigits) delete [] fNDigits;
151 if (fLoader)fLoader->GetModulesFolder()->Remove(this);
152 fLoader = 0; // Not deleting it.
164 //----------------------------------------------------------------------
165 AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source),
166 fSimulation(source.fSimulation), // [NDet]
167 fSegmentation(source.fSegmentation), // [NDet]
168 fCalibration(source.fCalibration), // [NMod]
169 fPreProcess(source.fPreProcess), // [] e.g. Fill fHitModule with hits
170 fPostProcess(source.fPostProcess), // [] e.g. Wright Raw data
171 fNSDigits(source.fNSDigits), //! number of SDigits
172 fSDigits(source.fSDigits), //! [NMod][NSDigits]
173 fNDigits(source.fNDigits), //! number of Digits
174 fRunNumber(source.fRunNumber), //! Run number (to access DB)
175 fDigits(source.fDigits), //! [NMod][NDigits]
176 fHitClassName(source.fHitClassName), // String with Hit class name.
177 fSDigClassName(source.fSDigClassName),// String with SDigit class name.
178 fDigClassName(), // String with digit class name.
179 fLoader(source.fLoader), // local pointer to loader
180 fFirstcall(source.fFirstcall)
182 // Copy Constructor for object AliITSDetTypeSim not allowed
183 for(Int_t i=0;i<fgkNdettypes;i++){
184 fDigClassName[i] = source.fDigClassName[i];
187 //----------------------------------------------------------------------
188 AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
189 // The = operator for object AliITSDetTypeSim
191 this->~AliITSDetTypeSim();
192 new(this) AliITSDetTypeSim(source);
196 //______________________________________________________________________
197 void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
198 // Sets/replaces the existing AliITSgeom object kept in AliITSLoader
201 // AliITSgoem *geom The AliITSgeom object to be used.
207 Error("SetITSgeom","No pointer to loader - nothing done");
211 fLoader->SetITSgeom(geom); // protections in AliITSLoader::SetITSgeom
215 //______________________________________________________________________
216 void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){
217 // Sets the local copy of the AliITSLoader, and passes on the
218 // AliITSgeom object as needed.
220 // AliITSLoader *loader pointer to AliITSLoader for local use
226 if(fLoader==loader) return; // Same do nothing
227 if(fLoader){ // alread have an existing loader
229 "Already have an exisiting loader ptr=%p Nothing done",
234 //______________________________________________________________________
235 void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){
237 //Set simulation model for detector type
239 if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes);
240 fSimulation->AddAt(sim,dettype);
242 //______________________________________________________________________
243 AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype){
245 //Get simulation model for detector type
247 Warning("GetSimulationModel","fSimulation is 0!");
250 return (AliITSsimulation*)(fSimulation->At(dettype));
252 //______________________________________________________________________
253 AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module){
255 //Get simulation model by module number
256 if(GetITSgeom()==0) {
257 Warning("GetSimulationModelByModule","GetITSgeom() is 0!");
261 return GetSimulationModel(GetITSgeom()->GetModuleType(module));
263 //_______________________________________________________________________
264 void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){
265 // Set default segmentation model objects
266 AliITSsegmentation *seg;
268 if(fSegmentation==0x0){
269 fSegmentation = new TObjArray(fgkNdettypes);
270 fSegmentation->SetOwner(kTRUE);
272 if(GetSegmentationModel(idet))
273 delete (AliITSsegmentation*)fSegmentation->At(idet);
275 seg = new AliITSsegmentationSPD(GetITSgeom());
277 AliITSCalibration* res=GetCalibrationModel(
278 GetITSgeom()->GetStartSDD());
279 seg = new AliITSsegmentationSDD(GetITSgeom(),res);
281 seg = new AliITSsegmentationSSD(GetITSgeom());
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 for(Int_t idet=0;idet<fgkNdettypes;idet++){
390 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
391 const char *kData0=(GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
392 if (strstr(kData0,"real")) {
393 SetDigitClassName(idet,"AliITSdigit");
395 SetDigitClassName(idet,"AliITSdigitSPD");
400 if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
401 AliITSCalibrationSDD* rsp =
402 (AliITSCalibrationSDD*)GetCalibrationModel(
403 GetITSgeom()->GetStartSDD());
404 const char *kopt = ((AliITSresponseSDD*)rsp->GetResponse())->
406 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) {
407 SetDigitClassName(idet,"AliITSdigit");
409 SetDigitClassName(idet,"AliITSdigitSDD");
414 if(!GetSegmentationModel(idet))SetDefaultSegmentation(idet);
415 const char *kData2 = (GetCalibrationModel(
416 GetITSgeom()->GetStartSSD())->DataType());
417 if (strstr(kData2,"real")) {
418 SetDigitClassName(idet,"AliITSdigit");
420 SetDigitClassName(idet,"AliITSdigitSSD");
425 //______________________________________________________________________
426 Bool_t AliITSDetTypeSim::GetCalibration() {
427 // Get Default calibration if a storage is not defined.
430 AliITSCalibration* cal = GetCalibrationModel(0);
437 SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
438 Int_t run=GetRunNumber();
440 Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
441 Bool_t isCacheActive = kTRUE;
442 if(GetRunNumber()<0){
443 isCacheActive=kFALSE;
444 fCalibration->SetOwner(kTRUE);
447 fCalibration->SetOwner(kFALSE);
450 AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
452 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run);
453 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
454 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
455 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
456 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
457 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
459 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
460 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
461 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
463 if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD ||
464 !entry2SPD || !entry2SDD || !entry2SSD){
465 AliFatal("Calibration object retrieval failed! ");
469 if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD ||
470 !entry2SPD || !entry2SDD || !entry2SSD){
471 AliFatal("Calibration object retrieval failed! ");
475 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
476 if(!isCacheActive)entrySPD->SetObject(NULL);
477 entrySPD->SetOwner(kTRUE);
479 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
480 if(!isCacheActive)entry2SPD->SetObject(NULL);
481 entry2SPD->SetOwner(kTRUE);
483 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
484 if(!isCacheActive)entrySDD->SetObject(NULL);
485 entrySDD->SetOwner(kTRUE);
487 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
488 if(!isCacheActive)entry2SDD->SetObject(NULL);
489 entry2SDD->SetOwner(kTRUE);
492 TObjArray *calSSD = (TObjArray *)entrySSD->GetObject();
493 if(!isCacheActive)entrySSD->SetObject(NULL);
494 entrySSD->SetOwner(kTRUE);
497 TObjArray *noiseSSD = (TObjArray *)entryNoiseSSD->GetObject();
498 if(!isCacheActive)entryNoiseSSD->SetObject(NULL);
499 entryNoiseSSD->SetOwner(kTRUE);
501 TObjArray *gainSSD = (TObjArray *)entryGainSSD->GetObject();
502 if(!isCacheActive)entryGainSSD->SetObject(NULL);
503 entryGainSSD->SetOwner(kTRUE);
505 TObjArray *badchannelsSSD = (TObjArray *)entryBadChannelsSSD->GetObject();
506 if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL);
507 entryBadChannelsSSD->SetOwner(kTRUE);
509 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
510 if(!isCacheActive)entry2SSD->SetObject(NULL);
511 entry2SSD->SetOwner(kTRUE);
513 // DB entries are deleted. In this way metadeta objects are deleted as well
517 delete entryNoiseSSD;
519 delete entryBadChannelsSSD;
525 AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
527 if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!calSDD)
528 || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) {
529 AliWarning("Can not get calibration from calibration database !");
533 fNMod[0] = calSPD->GetEntries();
534 fNMod[1] = calSDD->GetEntries();
535 fNMod[2] = noiseSSD->GetEntries();
536 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
537 fNMod[0], fNMod[1], fNMod[2]));
538 AliITSCalibration* cal;
539 for (Int_t i=0; i<fNMod[0]; i++) {
540 cal = (AliITSCalibration*) calSPD->At(i);
541 cal->SetResponse(pSPD);
542 SetCalibrationModel(i, cal);
544 for (Int_t i=0; i<fNMod[1]; i++) {
545 cal = (AliITSCalibration*) calSDD->At(i);
546 cal->SetResponse(pSDD);
547 Int_t iMod = i + fNMod[0];
548 SetCalibrationModel(iMod, cal);
550 for (Int_t i=0; i<fNMod[2]; i++) {
551 AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
552 calibSSD->SetResponse((AliITSresponse*)pSSD);
554 AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
555 calibSSD->SetNoise(noise);
556 AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
557 calibSSD->SetGain(gain);
558 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
559 calibSSD->SetBadChannels(bad);
561 Int_t iMod = i + fNMod[0] + fNMod[1];
562 SetCalibrationModel(iMod, calibSSD);
567 //_______________________________________________________________________
568 void AliITSDetTypeSim::SetDefaultSimulation(){
569 //Set default simulation for detector type
572 Warning("SetDefaultSimulation","GetITSgeom() is 0!");
576 Warning("SetDefaultSimulation","fCalibration is 0!");
579 if(fSegmentation==0){
580 Warning("SetDefaultSimulation","fSegmentation is 0!");
581 for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i);
582 }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){
583 Warning("SetDefaultSimulation",
584 "Segmentation not defined for det %d - Default taken\n!",i);
585 SetDefaultSegmentation(i);
587 AliITSsimulation* sim;
589 for(Int_t idet=0;idet<fgkNdettypes;idet++){
592 sim = GetSimulationModel(idet);
594 sim = new AliITSsimulationSPD(this);
595 SetSimulationModel(idet,sim);
600 sim = GetSimulationModel(idet);
602 sim = new AliITSsimulationSDD(this);
603 SetSimulationModel(idet,sim);
608 sim = GetSimulationModel(idet);
610 sim = new AliITSsimulationSSD(this);
611 SetSimulationModel(idet,sim);
617 //___________________________________________________________________
618 void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, Char_t* name){
619 // Set branch address for the ITS summable digits Trees.
625 if (fSDigits == 0x0){
626 fSDigits = new TClonesArray("AliITSpListItem",1000);
629 sprintf(branchname,"%s",name);
630 branch = treeS->GetBranch(branchname);
631 if (branch) branch->SetAddress(&fSDigits);
634 //___________________________________________________________________
635 void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, Char_t* name){
636 // Set branch address for the digit Trees.
638 const char *det[3] = {"SPD","SDD","SSD"};
647 fDigits = new TObjArray(fgkNdettypes);
649 for(Int_t i=0;i<fgkNdettypes;i++){
650 Char_t* digclass = GetDigitClassName(i);
652 if(i==0) SetDigitClassName(i,"AliITSdigitSPD");
653 if(i==1) SetDigitClassName(i,"AliITSdigitSDD");
654 if(i==2) SetDigitClassName(i,"AliITSdigitSSD");
655 digclass = GetDigitClassName(i);
657 TString classn = digclass;
658 if(!(fDigits->At(i))){
659 fDigits->AddAt(new TClonesArray(classn.Data(),1000),i);
664 if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]);
665 else sprintf(branchname,"%sDigits%d",name,i+1);
667 branch = treeD->GetBranch(branchname);
668 if(branch) branch->SetAddress(&((*fDigits)[i]));
673 //___________________________________________________________________
674 void AliITSDetTypeSim::ResetDigits(){
675 // Reset number of digits and the digits array for the ITS detector.
678 Error("ResetDigits","fDigits is null!");
681 for(Int_t i=0;i<fgkNdettypes;i++){
685 //___________________________________________________________________
686 void AliITSDetTypeSim::ResetDigits(Int_t branch){
687 // Reset number of digits and the digits array for this branch.
689 if(fDigits->At(branch)){
690 ((TClonesArray*)fDigits->At(branch))->Clear();
692 if(fNDigits) fNDigits[branch]=0;
698 //_______________________________________________________________________
699 void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
700 // Standard Summable digits to Digits function.
702 Warning("SDigitsToDigits","GetITSgeom() is null!!");
706 const char *all = strstr(opt,"All");
707 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
709 if( !det[0] && !det[1] && !det[2] ) all = "All";
711 static Bool_t setDef = kTRUE;
712 if(setDef) SetDefaultSimulation();
715 AliITSsimulation *sim =0;
716 TTree* trees = fLoader->TreeS();
717 if( !(trees && GetSDigits()) ){
718 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
721 sprintf(name,"%s",name);
722 TBranch* brchSDigits = trees->GetBranch(name);
725 for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){
726 id = GetITSgeom()->GetModuleType(module);
727 if (!all && !det[id]) continue;
728 sim = (AliITSsimulation*)GetSimulationModel(id);
730 Error("SDigit2Digits","The simulation class was not "
731 "instanciated for module %d type %s!",module,
732 GetITSgeom()->GetModuleTypeName(module));
735 sim->InitSimulationModule(module,gAlice->GetEvNumber());
738 brchSDigits->GetEvent(module);
739 sim->AddSDigitsToModule(fSDigits,0);
740 sim->FinishSDigitiseModule();
741 fLoader->TreeD()->Fill();
744 fLoader->TreeD()->GetEntries();
745 fLoader->TreeD()->AutoSave();
746 fLoader->TreeD()->Reset();
748 //_________________________________________________________
749 void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){
750 //Adds the module full of summable digits to the summable digits tree.
752 TClonesArray &lsdig = *fSDigits;
753 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
755 //__________________________________________________________
756 void AliITSDetTypeSim::AddRealDigit(Int_t branch, Int_t *digits){
757 // Add a real digit - as coming from data.
759 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
760 new(ldigits[fNDigits[branch]++]) AliITSdigit(digits);
762 //__________________________________________________________
763 void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){
764 // Add a simulated digit.
766 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
769 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
772 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
775 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
779 //______________________________________________________________________
780 void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,
781 Int_t *tracks,Int_t *hits,Float_t *charges){
782 // Add a simulated digit to the list.
784 TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
785 AliITSCalibrationSDD *resp = 0;
788 new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits);
791 resp = (AliITSCalibrationSDD*)GetCalibrationModel(
792 GetITSgeom()->GetStartSDD());
793 new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks,
797 new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits);
801 //______________________________________________________________________
802 void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun,
803 AliCDBMetaData &md) {
804 // Store calibration in the calibration database
805 // The database must be created in an external piece of code (i.e.
806 // a configuration macro )
808 if(!AliCDBManager::Instance()->IsDefaultStorageSet()) {
809 AliWarning("No storage set! Will use dummy one");
810 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
814 AliError("AliITSCalibration classes are not defined - nothing done");
817 AliCDBId idRespSPD("ITS/Calib/CalibSPD",firstRun, lastRun);
818 AliCDBId idRespSDD("ITS/Calib/CalibSDD",firstRun, lastRun);
819 AliCDBId idRespSSD("ITS/Calib/CalibSSD",firstRun, lastRun);
821 TObjArray respSPD(fNMod[0]);
822 TObjArray respSDD(fNMod[1]-fNMod[0]);
823 TObjArray respSSD(fNMod[2]-fNMod[1]);
824 respSPD.SetOwner(kFALSE);
825 respSSD.SetOwner(kFALSE);
826 respSSD.SetOwner(kFALSE);
828 Int_t index[fgkNdettypes];
829 for (Int_t i = 0; i<fgkNdettypes; i++ ) {
831 for (Int_t j = 0; j<=i; j++ )
835 for (Int_t i = 0; i<index[0]; i++ )
836 respSPD.Add(fCalibration->At(i));
838 for (Int_t i = index[0]; i<index[1]; i++ )
839 respSDD.Add(fCalibration->At(i));
841 for (Int_t i = index[1]; i<index[2]; i++ )
842 respSSD.Add(fCalibration->At(i));
844 AliCDBManager::Instance()->Put(&respSPD, idRespSPD, &md);
845 AliCDBManager::Instance()->Put(&respSDD, idRespSDD, &md);
846 AliCDBManager::Instance()->Put(&respSSD, idRespSSD, &md);