]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSDetTypeSim.cxx
A more elaborate approach for associating the reconstructed and MC pileup vertices
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeSim.cxx
index bf8fcc5d27ee3e717efb6202d4a8697056234ad0..8be79cd2e493b03c16fbf1d54c2d815d06b43704 100644 (file)
@@ -73,6 +73,8 @@ const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD =  240;
 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD =  260;
 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698;
 
+using std::endl;
+using std::cout;
 ClassImp(AliITSDetTypeSim)
 
 //----------------------------------------------------------------------
@@ -83,6 +85,7 @@ fSegmentation(), // [NDet]
 fCalibration(),     // [NMod]
 fSSDCalibration(0),
 fSPDNoisy(0),
+fSPDSparseDead(0),
 fNSDigits(0),    //! number of SDigits
 fSDigits("AliITSpListItem",1000),   
 fNDigits(0),     //! number of Digits
@@ -114,9 +117,6 @@ fTriggerConditions(NULL)
   fDDLMapSDD=new AliITSDDLModuleMapSDD();
   fSimuPar= new AliITSSimuParam();
   fSSDCalibration=new AliITSCalibrationSSD();
-  fNMod[0] = fgkDefaultNModulesSPD;
-  fNMod[1] = fgkDefaultNModulesSDD;
-  fNMod[2] = fgkDefaultNModulesSSD;
   SetRunNumber();
 }
 //----------------------------------------------------------------------
@@ -158,6 +158,13 @@ AliITSDetTypeSim::~AliITSDetTypeSim(){
        fSPDNoisy = 0;
       }
     }
+    if(fSPDSparseDead){
+    if(!(AliCDBManager::Instance()->GetCacheFlag())) {
+       fSPDSparseDead->Delete();
+       delete fSPDSparseDead;
+       fSPDSparseDead = 0;
+      }
+    }
     if(fSimuPar) delete fSimuPar;
     if(fRespSDD){
       if(!(AliCDBManager::Instance()->GetCacheFlag())){
@@ -178,40 +185,41 @@ AliITSDetTypeSim::~AliITSDetTypeSim(){
     fDigits=0;
 }
 //----------------------------------------------------------------------
-AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source),
-fSimulation(source.fSimulation),   // [NDet]
-fSegmentation(source.fSegmentation), // [NDet]
-fCalibration(source.fCalibration),     // [NMod]
-fSSDCalibration(source.fSSDCalibration),
-fSPDNoisy(source.fSPDNoisy),
-fNSDigits(source.fNSDigits),    //! number of SDigits
-fSDigits(*((TClonesArray*)source.fSDigits.Clone())),
-fNDigits(source.fNDigits),     //! number of Digits
-fRunNumber(source.fRunNumber),   //! Run number (to access DB)
-fDigits(source.fDigits),       //! [NMod][NDigits]
-fSimuPar(source.fSimuPar),
-fDDLMapSDD(source.fDDLMapSDD),
-fRespSDD(source.fRespSDD),
-fAveGainSDD(source.fAveGainSDD),
-fkDigClassName(), // String with digit class name.
-fLoader(source.fLoader),      // local pointer to loader
-fFirstcall(source.fFirstcall),
-fFOGenerator(source.fFOGenerator),
-fTriggerConditions(source.fTriggerConditions) 
-{
-    // Copy Constructor for object AliITSDetTypeSim not allowed
-  for(Int_t i=0;i<fgkNdettypes;i++){
-    fkDigClassName[i] = source.fkDigClassName[i];
-  }
-}
-//----------------------------------------------------------------------
-AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
-    // The = operator for object AliITSDetTypeSim
+// AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source),
+// fSimulation(source.fSimulation),   // [NDet]
+// fSegmentation(source.fSegmentation), // [NDet]
+// fCalibration(source.fCalibration),     // [NMod]
+// fSSDCalibration(source.fSSDCalibration),
+// fSPDNoisy(source.fSPDNoisy),
+// fSPDSparseDead(source.fSPDSparseDead),
+// fNSDigits(source.fNSDigits),    //! number of SDigits
+// fSDigits(*((TClonesArray*)source.fSDigits.Clone())),
+// fNDigits(source.fNDigits),     //! number of Digits
+// fRunNumber(source.fRunNumber),   //! Run number (to access DB)
+// fDigits(source.fDigits),       //! [NMod][NDigits]
+// fSimuPar(source.fSimuPar),
+// fDDLMapSDD(source.fDDLMapSDD),
+// fRespSDD(source.fRespSDD),
+// fAveGainSDD(source.fAveGainSDD),
+// fkDigClassName(), // String with digit class name.
+// fLoader(source.fLoader),      // local pointer to loader
+// fFirstcall(source.fFirstcall),
+// fFOGenerator(source.fFOGenerator),
+// fTriggerConditions(source.fTriggerConditions) 
+// {
+//     // Copy Constructor for object AliITSDetTypeSim not allowed
+//   for(Int_t i=0;i<fgkNdettypes;i++){
+//     fkDigClassName[i] = source.fkDigClassName[i];
+//   }
+// }
+// //----------------------------------------------------------------------
+// AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
+//     // The = operator for object AliITSDetTypeSim
  
-  this->~AliITSDetTypeSim();
-  new(this) AliITSDetTypeSim(source);
-  return *this;
-}
+//   this->~AliITSDetTypeSim();
+//   new(this) AliITSDetTypeSim(source);
+//   return *this;
+// }
 
 //______________________________________________________________________
 void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
@@ -372,6 +380,19 @@ void AliITSDetTypeSim::SetSPDNoisyModel(Int_t iMod, AliITSCalibration *cal){
     delete (AliITSCalibration*) fSPDNoisy->At(iMod);
   fSPDNoisy->AddAt(cal,iMod);
 }
+//_______________________________________________________________________
+void AliITSDetTypeSim::SetSPDSparseDeadModel(Int_t iMod, AliITSCalibration *cal){
+  //Set sparse dead pixel info for the SPD module iMod
+  if (fSPDSparseDead==0) {
+    fSPDSparseDead = new TObjArray(fgkDefaultNModulesSPD);
+    fSPDSparseDead->SetOwner(kTRUE);
+    fSPDSparseDead->Clear();
+  }
+
+  if (fSPDNoisy->At(iMod) != 0)
+    delete (AliITSCalibration*) fSPDNoisy->At(iMod);
+  fSPDNoisy->AddAt(cal,iMod);
+}
 //______________________________________________________________________
 void AliITSDetTypeSim::ResetCalibrationArray(){
     //resets response array
@@ -619,13 +640,13 @@ if(!deadSPD || !noisySPD || !foEffSPD || !foNoiSPD
   }
 
 
-  fNMod[0] = calDeadSPD->GetEntries();
-  fNMod[1] = calSDD->GetEntries();
-  //  fNMod[2] = noiseSSD->GetEntries();
+  Int_t nmods0 = calDeadSPD->GetEntries();
+  Int_t nmods1 = calSDD->GetEntries();
+
   AliDebug(1,Form("%i SPD, %i SDD and %i SSD in calibration database",
-              fNMod[0], fNMod[1], fNMod[2]));
+                 nmods0,nmods1,fgkDefaultNModulesSSD));
   AliITSCalibration* cal;
-  for (Int_t i=0; i<fNMod[0]; i++) {
+  for (Int_t i=0; i<nmods0; i++) {
     cal = (AliITSCalibration*) calDeadSPD->At(i);
     SetCalibrationModel(i, cal);
     cal = (AliITSCalibration*) calNoisySPD->At(i);
@@ -755,14 +776,12 @@ void AliITSDetTypeSim::SetDefaultSimulation(){
 //___________________________________________________________________
 void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, const Char_t* name){
   // Set branch address for the ITS summable digits Trees.  
-  char branchname[30];
 
   if(!treeS){
     return;
   }
   TBranch *branch;
-  sprintf(branchname,"%s",name);
-  branch = treeS->GetBranch(branchname);
+  branch = treeS->GetBranch(name);
   TClonesArray *sdigi = &fSDigits;
   if (branch) branch->SetAddress(&sdigi);
 
@@ -774,7 +793,7 @@ void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, const Char_t* name){
   const char *det[3] = {"SPD","SDD","SSD"};
   TBranch *branch;
   
-  char branchname[30];
+  TString branchname;
   
   if(!treeD){
     return;
@@ -797,14 +816,11 @@ void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, const Char_t* name){
       ResetDigits(i);
     }
     
-    if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]);
-    else sprintf(branchname,"%sDigits%d",name,i+1);
-    if(fDigits){
-      branch = treeD->GetBranch(branchname);
-      if(branch) branch->SetAddress(&((*fDigits)[i]));
-    }
+    if(fgkNdettypes==3) branchname.Form("%sDigits%s",name,det[i]);
+    else branchname.Form("%sDigits%d",name,i+1);
+    branch = treeD->GetBranch(branchname.Data());
+    if(branch) branch->SetAddress(&((*fDigits)[i]));    
   }
-
 }
 //___________________________________________________________________
 void AliITSDetTypeSim::ResetDigits(){
@@ -842,8 +858,8 @@ void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
   const char *all = strstr(opt,"All");
   const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
                        strstr(opt,"SSD")};
-  if( !det[0] && !det[1] && !det[2] ) all = "All";
-  else all = 0;
+  if(!all && !det[0] && !det[1] && !det[2] ) all = "All";
+
   static Bool_t setDef = kTRUE;
   if(setDef) SetDefaultSimulation();
   setDef = kFALSE;
@@ -854,7 +870,7 @@ void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
     Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
     return;
   } 
-  sprintf(name,"%s",name);
+
   TBranch* brchSDigits = trees->GetBranch(name);
   
   Int_t id;
@@ -877,6 +893,8 @@ void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
     fLoader->TreeD()->Fill();
     ResetDigits();
   }
+
+  WriteFOSignals(); 
   fLoader->TreeD()->GetEntries();
   fLoader->TreeD()->AutoSave();
   fLoader->TreeD()->Reset();
@@ -1044,5 +1062,6 @@ void AliITSDetTypeSim::WriteFOSignals() {
   TTree *tree = fLoader->TreeD();
   AliITSFOSignalsSPD *foSignals = new AliITSFOSignalsSPD(*GetFOSignals()); 
   tree->GetUserInfo()->Add(foSignals);
+  fFOGenerator.ResetSignals();
 }