]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITS.cxx
Part of the Warning messages changed to AliDebug messages
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
index bf25ca02e676b3aa8b53cfc18a29e71efa703b40..48d1709b99fe7128156c28cdc15921157880cabb 100644 (file)
@@ -72,6 +72,7 @@ the AliITS class.
 #include <TString.h>
 #include <TTree.h>
 #include <TVirtualMC.h>
+#include <TArrayI.h>
 #include "AliDetector.h"
 #include "AliITS.h"
 #include "AliITSDetTypeSim.h"
@@ -125,6 +126,7 @@ fpSDigits(0)
   
 //    SetDetectors(); // default to fOpt="All". This variable not written out.
 //PH    SetMarkerColor(kRed);
+  for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0;
 }
 //______________________________________________________________________
 AliITS::AliITS(const Char_t *title):
@@ -165,6 +167,7 @@ AliITS::AliITS(const Char_t *title):
     //PH  SetMarkerColor(kRed);
     if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
     fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
+    for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0;
 }
 //______________________________________________________________________
 AliITS::AliITS(const char *name, const char *title):
@@ -201,7 +204,7 @@ AliITS::AliITS(const char *name, const char *title):
   //PH  SetMarkerColor(kRed);
   if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
   fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-
+  for (int i=fgkNTYPES;i--;) fRawID2ClusID[i] = 0;
 }
 //______________________________________________________________________
 AliITS::~AliITS(){
@@ -229,9 +232,8 @@ AliITS::~AliITS(){
 
     delete[] fIdName;  // Array of TStrings
     delete[] fIdSens;
-    Int_t size   = 0;
+    Int_t size   = AliITSgeomTGeo::GetNModules();
     if (fDetTypeSim){
-      if (GetITSgeom()) size = GetITSgeom()->GetIndexMax();
       delete fDetTypeSim;
       fDetTypeSim = 0;
     }
@@ -253,19 +255,20 @@ AliITS::~AliITS(){
       delete fpSDigits;
     }
 }
+
 //______________________________________________________________________
-AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
+AliDigitizer* AliITS::CreateDigitizer(AliDigitizationInput* digInput)const{
     // Creates the AliITSDigitizer in a standard way for use via AliModule.
     // This function can not be included in the .h file because of problems
     // with the order of inclusion (recursive).
     // Inputs:
-    //    AliRunDigitizer *manager  The Manger class for Digitization
+    //    AliDigitizationInput* digInput  The Manger class for Digitization
     // Output:
     //    none.
     // Return:
     //    A new AliITSRunDigitizer (cast as a AliDigitizer).
 
-     return new AliITSDigitizer(manager);
+     return new AliITSDigitizer(digInput);
 }
 //______________________________________________________________________
 void AliITS::Init(){
@@ -369,10 +372,10 @@ void AliITS::MakeBranchS(const char* fl){
     Error("MakeBranchS","fDetTypeSim is 0!");
   }
   Int_t buffersize = 4000;
-  char branchname[30];
+  char branchname[31];
 
   // only one branch for SDigits.
-  sprintf(branchname,"%s",GetName());
+  snprintf(branchname,30,"%s",GetName());
 
   if(fLoader->TreeS()){
     TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
@@ -405,7 +408,7 @@ void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
   const Char_t *det[3] = {"SPD","SDD","SSD"};
   const Char_t* digclass;
   Int_t buffersize = 4000;
-  Char_t branchname[30];
+  Char_t branchname[31];
   
   if(!fDetTypeSim->GetDigits()){
     fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
@@ -417,7 +420,7 @@ void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
       (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
     }
     else ResetDigits(i);  
-    if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
+    if(fgkNTYPES==3) snprintf(branchname,30,"%sDigits%s",GetName(),det[i]);
     else sprintf(branchname,"%sDigits%d",GetName(),i+1);
     TObjArray* dig = DigitsAddress(i);
     if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
@@ -473,7 +476,7 @@ void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
 }
 
 //______________________________________________________________________
-void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
+void AliITS::FillModules(Int_t /* evnt */,Int_t bgrev,Int_t /* nmodules */,
                          Option_t *option, const char *filename){
   // fill the modules with the sorted by module hits; add hits from
   // background if option=Add.
@@ -483,7 +486,6 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
   static TFile *file;
   const char *addBgr = strstr(option,"Add");
   
-  evnt = nmodules; // Dummy use of variables to remove warnings
   if (addBgr ) {
     if(first) {
       file=new TFile(filename);
@@ -495,8 +497,8 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     if(trH1) delete trH1;
     trH1=0;
     
-    char treeName[20];
-    sprintf(treeName,"TreeH%d",bgrev);
+    char treeName[21];
+    snprintf(treeName,20,"TreeH%d",bgrev);
     trH1 = (TTree*)gDirectory->Get(treeName);
     if (!trH1) {
       Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
@@ -510,8 +512,10 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     FillModules(trH1,10000000); // Default mask 10M.
     TTree *fAli=fLoader->GetRunLoader()->TreeK();
     TFile *fileAli=0;
-    if (fAli) fileAli =fAli->GetCurrentFile();
-    fileAli->cd();
+    if (fAli) {
+      fileAli =fAli->GetCurrentFile();
+      fileAli->cd();
+    }
   } // end if add
   
   
@@ -532,13 +536,14 @@ void AliITS::FillModules(TTree *treeH, Int_t mask) {
 
     if (treeH == 0x0)
      {
-       Error("FillModules","Tree is NULL");
+       AliError("Tree H  is NULL");
+       return;
      }
     Int_t lay,lad,det,index;
     AliITShit *itsHit=0;
     AliITSmodule *mod=0;
-    char branchname[20];
-    sprintf(branchname,"%s",GetName());
+    char branchname[21];
+    snprintf(branchname,20,"%s",GetName());
     TBranch *branch = treeH->GetBranch(branchname);
     if (!branch) {
         Error("FillModules","%s branch in TreeH not found",branchname);
@@ -746,16 +751,10 @@ void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
   
   ClearModules();
  
-  // Add random noise to FO signals
-  if (all || det[0]) { // SPD present
-    fDetTypeSim->ProcessNoiseForFastOr();
-  }
-
   // Add Fast-OR signals to event (only one object per event)
   if (all || det[0]) { // SPD present
-    fDetTypeSim->WriteFOSignals();
+    WriteFOSignals();
   }
-
   
   fLoader->TreeD()->GetEntries();
   fLoader->TreeD()->AutoSave();
@@ -1008,7 +1007,6 @@ void AliITS::SDigitsToDigits(Option_t *opt){
     AliError("fDetTypeSim is 0!");
     return;
   }
-
   const char *all = strstr(opt,"All");
   const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
                       strstr(opt,"SSD")};
@@ -1021,13 +1019,9 @@ void AliITS::SDigitsToDigits(Option_t *opt){
   if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
   fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
 
-  // Add random noise to FO signals
-  if (all || det[0]) { // SPD present
-    fDetTypeSim->ProcessNoiseForFastOr();
-  }
   // Add Fast-OR signals to event (only one object per event)
   if (all || det[0]) { // SPD present
-    fDetTypeSim->WriteFOSignals();
+   WriteFOSignals();
   }
 }
 
@@ -1217,7 +1211,7 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
   // Get TreeS
   //
   Int_t last   = -1;
-  Int_t size   = GetITSgeom()->GetIndexMax();
+  Int_t size   = AliITSgeomTGeo::GetNModules();
   if(!fModA) {
     fModA = new TClonesArray*[size];
     for (Int_t mod = 0; mod < size; mod++) fModA[mod] = new TClonesArray("AliITSpListItem", 10000);
@@ -1255,12 +1249,15 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
   }
   npx = segSPD->Npx();
   Double_t thr, sigma; 
-    
+
+  Int_t countRW = -1; // RS counter for raw -> cluster ID's (used in embedding)
+  const TArrayI* rawID2clusID = fRawID2ClusID[kSPD];
   AliITSRawStreamSPD inputSPD(rawReader);
   while(1){
     Bool_t next  = inputSPD.Next();
     if (!next) break;
 
+    countRW++; // RS
     Int_t module = inputSPD.GetModuleID();
     Int_t column = inputSPD.GetColumn();
     Int_t row    = inputSPD.GetRow();
@@ -1272,7 +1269,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
     TClonesArray& dum = *fModA[module];
     fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
     thr += 1.;
-    new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
+    int label = -1;
+    if (rawID2clusID) { // RS If the raw->cluster ID is set (filled by cluster finder) store cluster ID's in SDigits
+      if (rawID2clusID->GetSize()<=countRW) {AliError(Form("The buffer of rawSPD to clusSPD ID's is shorter than current rawSPD ID=%d",countRW));}
+      else label = (*rawID2clusID)[countRW];
+    }
+    new (dum[last]) AliITSpListItem(label, -1, module, index, thr);
   }
   rawReader->Reset();
 
@@ -1284,7 +1286,9 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
   Int_t scalef=AliITSsimulationSDD::ScaleFourier(segSDD);
   Int_t firstSDD=AliITSgeomTGeo::GetModuleIndex(3,1,1);
   Int_t firstSSD=AliITSgeomTGeo::GetModuleIndex(5,1,1);
-
+  //
+  countRW = -1; // RS
+  rawID2clusID = fRawID2ClusID[kSDD];
   AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
   for(Int_t iMod=firstSDD; iMod<firstSSD; iMod++){
     AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(iMod);
@@ -1299,6 +1303,7 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
   AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
   inputSDD->SetDDLModuleMap(ddlmap);
   while(inputSDD->Next()){
+    countRW++; // RS
     if(inputSDD->IsCompletedModule()==kFALSE && 
        inputSDD->IsCompletedDDL()==kFALSE){
 
@@ -1311,7 +1316,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
       if (module >= size) continue;
       last = fModA[module]->GetEntries();
       TClonesArray& dum = *fModA[module];
-      new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
+      int label = -1;
+      if (rawID2clusID) { // RS If the raw->cluster ID is set (filled by cluster finder) store cluster ID's in SDigits
+       if (rawID2clusID->GetSize()<=countRW) {AliError(Form("The buffer of rawSDD to clusSDD ID's is shorter than current rawSDD ID=%d",countRW));}
+       else label = (*rawID2clusID)[countRW];
+      }
+      new (dum[last]) AliITSpListItem(label, -1, module, index, Double_t(signal10));
       ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
     }
   }
@@ -1324,11 +1334,15 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
   AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
   npx = segSSD->Npx();
   AliITSRawStreamSSD inputSSD(rawReader);
+  countRW = -1;
+  rawID2clusID = fRawID2ClusID[kSSD];
   while(1){
     Bool_t next  = inputSSD.Next();
     if (!next) break;
-
+    countRW++; // RS
     Int_t module  = inputSSD.GetModuleID();
+    if(module<0)AliError(Form("Invalid SSD  module %d \n",module));
+    if(module<0)continue;
     Int_t side    = inputSSD.GetSideFlag();
     Int_t strip   = inputSSD.GetStrip();
     Int_t signal  = inputSSD.GetSignal();
@@ -1338,7 +1352,12 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
        
     last = fModA[module]->GetEntries();
     TClonesArray& dum = *fModA[module];
-    new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
+    int label = -1;
+    if (rawID2clusID) { // RS If the raw->cluster ID is set (filled by cluster finder) store cluster ID's in SDigits
+      if (rawID2clusID->GetSize()<=countRW) {AliError(Form("The buffer of rawSSD to clusSSD ID's is shorter than current rawSSD ID=%d",countRW));}
+      else label = (*rawID2clusID)[countRW];
+    }    
+    new (dum[last]) AliITSpListItem(label, -1, module, index, Double_t(signal));
   }
   rawReader->Reset();
   AliITSpListItem* sdig = 0;
@@ -1354,9 +1373,9 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
       Int_t nsdig =  fModA[mod]->GetEntries();
       for (Int_t ie = 0; ie < nsdig; ie++) {
        sdig = (AliITSpListItem*) (fModA[mod]->At(ie));
-       Int_t digsig = sdig->GetSignal();
+       Double_t digsig = sdig->GetSignal();
        if(mod>=firstssd) digsig*=adcToEv; // for SSD: convert back charge from ADC to electron
-       new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), digsig);
+       new (aSDigits[ie]) AliITSpListItem(sdig->GetTrack(0), -1, mod, sdig->GetIndex(), digsig);
        Float_t sig = sdig->GetSignalAfterElect();
        if(mod>=firstssd) sig*=adcToEv;
        if (sig > 0.) {
@@ -1380,7 +1399,6 @@ void AliITS::UpdateInternalGeometry(){
 
   AliITSVersion_t version = (AliITSVersion_t)IsVersion();
   Int_t minor = 0;
-  if(version==kvPPRasymmFMD) minor=2;  // default minor version for this geom.
   AliITSInitGeometry initgeom;
   AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
   SetITSgeom(geom);
@@ -1390,3 +1408,11 @@ AliTriggerDetector* AliITS::CreateTriggerDetector() const {
   // create an AliITSTrigger object (and set trigger conditions as input)
   return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
 }
+//______________________________________________________________________
+void AliITS::WriteFOSignals(){
+// This method write FO signals in Digits tree both in Hits2Digits
+// or SDigits2Digits
+
+  fDetTypeSim->ProcessNoiseForFastOr();
+  fDetTypeSim->WriteFOSignals();
+}