]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCDigitizer.cxx
Correct the way primary photons are in EMCAL acceptance, change some histograms title...
[u/mrichter/AliRoot.git] / TPC / AliTPCDigitizer.cxx
index b5aada7be3d127b09588f6a4e19a5e38b9cf6c79..2ff41a12abc97e7fdfa2d89b7522670b8eaeeeaf 100644 (file)
@@ -38,6 +38,7 @@
 #include <TFile.h>
 #include <TDirectory.h>
 #include <Riostream.h>
+#include <TParameter.h>
 
 #include "AliTPCDigitizer.h"
 
@@ -106,7 +107,7 @@ void AliTPCDigitizer::ExecFast(Option_t* option)
   char s[100]; 
   char ss[100];
   TString optionString = option;
-  if (optionString.Data() == "deb") {
+  if (!strcmp(optionString.Data(),"deb")) {
     cout<<"AliTPCDigitizer::Exec: called with option deb "<<endl;
     fDebug = 3;
   }
@@ -146,20 +147,33 @@ void AliTPCDigitizer::ExecFast(Option_t* option)
    }
   }
   
-  pTPC->GenerNoise(500000); //create teble with noise
+  pTPC->GenerNoise(500000); //create table with noise
   //
   Int_t nInputs = fManager->GetNinputs();
   Int_t * masks = new Int_t[nInputs];
   for (Int_t i=0; i<nInputs;i++)
     masks[i]= fManager->GetMask(i);
   Short_t **pdig= new Short_t*[nInputs];   //pointers to the expanded digits array
-  Int_t **ptr=  new Int_t*[nInputs];       //pointers to teh expanded tracks array
+  Int_t **ptr=  new Int_t*[nInputs];       //pointers to the expanded tracks array
   Bool_t *active=  new Bool_t[nInputs];    //flag for active input segments
-
+  Char_t phname[100];
   
   //create digits array for given sectors
   // make indexes
-  
+  //
+  //create branch's in TPC treeD
+  orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+  ogime = orl->GetLoader("TPCLoader");
+  TTree * tree  = ogime->TreeD();
+  AliSimDigits * digrow = new AliSimDigits;  
+
+  if (tree == 0x0)
+   {
+     ogime->MakeTree("D");
+     tree  = ogime->TreeD();
+   }
+  tree->Branch("Segment","AliSimDigits",&digrow);
+  //  
   AliSimDigits ** digarr = new AliSimDigits*[nInputs]; 
   for (Int_t i1=0;i1<nInputs; i1++)
     {
@@ -174,28 +188,44 @@ void AliTPCDigitizer::ExecFast(Option_t* option)
        {
         cerr<<"AliTPCDigitizer: Input tree with SDigits not found in"
             <<" input "<< i1<<endl;
+        for (Int_t i2=0;i2<i1+1; i2++){ 
+          
+          if(digarr[i2])  delete digarr[i2];
+       }
+        delete [] digarr;
+        delete [] active;
+        delete []masks;
+        delete []pdig;
+        delete []ptr;
         return;
        }
-    
+
+      sprintf(phname,"lhcphase%d",i1);
+      TParameter<float> *ph = (TParameter<float>*)treear->GetUserInfo()
+                              ->FindObject("lhcphase0");
+      if(!ph){
+        cerr<<"AliTPCDigitizer: LHC phase  not found in"
+            <<" input "<< i1<<endl;
+        for (Int_t i2=0;i2<i1+1; i2++){ 
+          if(digarr[i2])  delete digarr[i2];
+       }
+        delete [] digarr;
+        delete [] active;
+        delete []masks;
+        delete []pdig;
+        delete []ptr;
+        return;
+      }
+      tree->GetUserInfo()->Add(new TParameter<float>(phname,ph->GetVal()));
+             //
       if (treear->GetIndex()==0)  
        treear->BuildIndex("fSegmentID","fSegmentID");
       treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
     }
 
 
-  //create branch's in TPC treeD
-  AliSimDigits * digrow = new AliSimDigits;
 
-  orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
-  ogime = orl->GetLoader("TPCLoader");
-  
-  TTree * tree  = ogime->TreeD();
-  if (tree == 0x0)
-   {
-     ogime->MakeTree("D");
-     tree  = ogime->TreeD();
-   }
-  tree->Branch("Segment","AliSimDigits",&digrow);
+
   //
 
   param->SetZeroSup(2);
@@ -311,7 +341,11 @@ void AliTPCDigitizer::ExecFast(Option_t* option)
         pdig1++;
         ptr1++;
      }
-    
+    //
+    //  glitch filter
+    //
+    digrow->GlitchFilter();
+    //
     digrow->CompresBuffer(1,zerosup);
     digrow->CompresTrackBuffer(1);
     tree->Fill();
@@ -344,7 +378,7 @@ void AliTPCDigitizer::ExecSave(Option_t* option)
   //output stored in TreeTPCD
 
   TString optionString = option;
-  if (optionString.Data() == "deb") {
+  if (!strcmp(optionString.Data(),"deb")) {
     cout<<"AliTPCDigitizer::Exec: called with option deb "<<endl;
     fDebug = 3;
   }
@@ -357,8 +391,8 @@ void AliTPCDigitizer::ExecSave(Option_t* option)
   ogime = orl->GetLoader("TPCLoader");
   
   rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
-  gime = rl->GetLoader("TPCLoader");
-  
+  //gime = rl->GetLoader("TPCLoader");
+  rl->GetLoader("TPCLoader");
   rl->LoadgAlice();
   AliRun* alirun = rl->GetAliRun();
   
@@ -368,26 +402,37 @@ void AliTPCDigitizer::ExecSave(Option_t* option)
   printf("noise %f \n",  param->GetNoise()*param->GetNoiseNormFac());
   //
   Int_t nInputs = fManager->GetNinputs();
+  // stupid protection...
+  if (nInputs <= 0) return;
+  //
   Int_t * masks = new Int_t[nInputs];
   for (Int_t i=0; i<nInputs;i++)
     masks[i]= fManager->GetMask(i);
 
   AliSimDigits ** digarr = new AliSimDigits*[nInputs]; 
+  for(Int_t ii=0;ii<nInputs;ii++) digarr[ii]=0;
+
   for (Int_t i1=0;i1<nInputs; i1++)
    {
-    digarr[i1]=0;
+     //digarr[i1]=0;
     //    intree[i1]
     rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(i1));
     gime = rl->GetLoader("TPCLoader");
 
     TTree * treear =  gime->TreeS();
-    TBranch * br = treear->GetBranch("fSegmentID");
-    if (br) br->GetFile()->cd();
+    //
     if (!treear) {      
-      cerr<<" TPC -  not existing input = \n"<<i1<<" ";      
+      cerr<<" TPC -  not existing input = \n"<<i1<<" "; 
+      delete [] masks;  
+      for(Int_t i=0; i<nInputs; i++) delete digarr[i];
+      delete [] digarr;
+      return;   
     } 
+    //
+    TBranch * br = treear->GetBranch("fSegmentID");
+    if (br) br->GetFile()->cd();
     treear->GetBranch("Segment")->SetAddress(&digarr[i1]);
-  }
+   }
   
   rl = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
   gime = rl->GetLoader("TPCLoader");
@@ -518,6 +563,6 @@ void AliTPCDigitizer::ExecSave(Option_t* option)
     
   delete digrow;     
   for (Int_t i1=0;i1<nInputs; i1++) delete digarr[i1];
-  delete []masks;
-  delete digarr;  
+  delete [] masks;
+  delete [] digarr;  
 }