]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFanalyzeSDigitsV2.C
Added possibility to run without AliTOFcalib object; read t0spread from AliESDEvent
[u/mrichter/AliRoot.git] / TOF / AliTOFanalyzeSDigitsV2.C
index 6241cec51185424d6472c31fcb9f1451eb135df0..1733f2c319e12fe4505570b83a5881f3db4a1301 100644 (file)
@@ -1,23 +1,37 @@
-Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=15, Int_t iEvNum=0)
+Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=0, Int_t iEvNum=-1, Int_t nEvent=0)
 {
+
+  /////////////////////////////////////////////////////////////////////////
   //
   // Analyzes the TOF sdigits and fills QA-histograms 
-  // report problems to pierella@bo.infn.it
-  // iEvNum=0 means all events in the file
+  // iEvNum=-1 and nEvent=0 means all events in the file
+  // 
+  // root[0] .L AliTOFanalyzeSDigitsV2.C
+  // root[1] AliTOFanalyzeSDigitsV2()
+  //
+  // If you want analyze only the sdigits in the 2th event
+  // (existing int the header file), see in the following:
+  //
+  // root[0] .L AliTOFanalyzeSDigitsV2.C
+  // root[1] AliTOFanalyzeSDigitsV2(0,2,1)
   //
   // Updated to the new I/O by: A. De Caro, C. Zampolli
+  //
+  // Report problems to: decaro@sa.infn.it
+  //
+  /////////////////////////////////////////////////////////////////////////
 
   Int_t rc = 0;
 
   // adc and tdc
-  TH1F *htdc  = new TH1F("htdc","TDC [bin]",5000,0.,150000.);
-  TH1F *hadc   = new TH1F("hadc","ADC [bin]",100,0., 3000.);
+  TH1F *htdc     = new TH1F("htdc","TDC [bin]",5000,0.,150000.);
+  TH1F *hadc     = new TH1F("hadc","ADC [bin]",100,0., 3000.);
   // TOF sdigit volumes
-  TH1F *hsector  = new TH1F("hsector","Sector",20,0.,20.);
-  TH1F *hplate   = new TH1F("hplate","Plate ", 6,0., 6.);
-  TH1F *hstrip   = new TH1F("hstrip","Strip ",25,0.,25.);
-  TH1F *hpadz    = new TH1F("hpadz","Pad along z ",3,0.,3.);
-  TH1F *hpadx    = new TH1F("hpadx","Pad along x",50,0.,50.);
+  TH1F *hsector  = new TH1F("hsector","Sector",18,0.,18.);
+  TH1F *hplate   = new TH1F("hplate","Plate ", 5,0., 5.);
+  TH1F *hstrip   = new TH1F("hstrip","Strip ",20,0.,20.);
+  TH1F *hpadz    = new TH1F("hpadz","Pad along z ",2,0.,2.);
+  TH1F *hpadx    = new TH1F("hpadx","Pad along x",48,0.,48.);
   // ADC-TDC correlation
   TH2F *h2tdcVSadc = new TH2F("h2tdcVSadc","TDC [bin] VS ADC [bin]",500,0.,150000.,100,0.,3000.);
   
@@ -29,12 +43,12 @@ Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=15, Int_t iEvNum=0)
 
   if (gAlice) 
     {
-      delete gAlice->GetRunLoader();
+      delete AliRunLoader::Instance();
       delete gAlice;
       gAlice = 0x0;
    }
   
-  AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::fgkDefaultEventFolderName,"read");
+  AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
   if (!rl)
     {
       cerr<<"Can't load RunLoader from file"<<"!\n";
@@ -52,6 +66,8 @@ Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=15, Int_t iEvNum=0)
       return rc;
     }
 
+  rl->LoadHeader();
+
   AliLoader *tofl = rl->GetLoader("TOFLoader");
   AliTOF *tof = (AliTOF *) rl->GetAliRun()->GetDetector("TOF");
 
@@ -62,35 +78,39 @@ Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=15, Int_t iEvNum=0)
       return rc;
     }
   
-  cout << "First " << ndump << " SDigits found in TOF TreeS branch have:" << endl;
+  cout << "First " << ndump << " SDigits found in TOF TreeS branch have: \n";
 
-  if (iEvNum == 0)
-    {
-      rl->LoadHeader();
-      TTree *TE = rl->TreeE();
-      iEvNum = (Int_t)TE->GetEntries();
-    }
+  Int_t upperLimit;
+  Int_t bottomLimit;
+
+  if (iEvNum<0) bottomLimit=0;
+  else bottomLimit = iEvNum;
+
+  if (nEvent == 0) upperLimit = (Int_t)(rl->GetNumberOfEvents());
+  else upperLimit = nEvent+bottomLimit;
 
   AliTOFSDigit *tofsdigit;
   
-  for (Int_t ievent = 0; ievent < iEvNum; ievent++) {
-    printf ("Processing event %d \n", ievent);
+  for (Int_t ievent = bottomLimit; ievent < upperLimit; ievent++) {
+
     rl->GetEvent(ievent);
+    printf ("Processing event %d \n", ievent);
     
     // Get the pointer SDigit tree
-    tofl->LoadSDigits();
+    tofl->LoadSDigits("read");
     TTree *TS=tofl->TreeS();
     tof->SetTreeAddress();
     
     if(!TS)
       {
-       cout << "<AliTOFanalyzeSDigits> No TreeS found" << endl;
+       cout << "<AliTOFanalyzeSDigits> No TreeS found \n";
        rc = 4;
        return rc;
       }
     
     TClonesArray * TOFsdigits = new TClonesArray("AliTOFSDigit",1000);
-    TOFsdigits = tof->SDigits();
+    //TOFsdigits = tof->SDigits();
+    tof->SDigits();
     TOFsdigits = TS->GetBranch("TOF")->SetAddress(&TOFsdigits); 
 
     Int_t nEntries = TS->GetEntries(); 
@@ -110,24 +130,25 @@ Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=15, Int_t iEvNum=0)
          htdc->Fill(firstTDC);
          hadc->Fill(firstADC);
          // TOF sdigit volumes
-         Int_t sector = tofsdigit->GetSector(); // range [1-18]
-         Int_t plate  = tofsdigit->GetPlate();  // range [1- 5]
-         Int_t strip  = tofsdigit->GetStrip();  // range [1-20]
-         Int_t padz   = tofsdigit->GetPadz();   // range [1- 2]
-         Int_t padx   = tofsdigit->GetPadx();   // range [1-48]
+         Int_t sector = tofsdigit->GetSector(); // range [0-17]
+         Int_t plate  = tofsdigit->GetPlate();  // range [0- 4]
+         Int_t strip  = tofsdigit->GetStrip();  // range [0-19]
+         Int_t padz   = tofsdigit->GetPadz();   // range [0- 1]
+         Int_t padx   = tofsdigit->GetPadx();   // range [0-47]
          // it is QA, then I perform QA!
-         Bool_t isSDigitBad = (sector<1 || sector>18 || plate<1 || plate >5 || padz<1 || padz>2 || padx<1 || padx>48);
+         Bool_t isSDigitBad = (sector<0 || sector>17 || plate<0 || plate >4 || padz<0 || padz>1 || padx<0 || padx>47);
          
+
          if (isSDigitBad) {
-           cout << "<AliTOFanalyzeSDigits>  strange sdigit found" << endl;
+           cout << "<AliTOFanalyzeSDigits>  strange sdigit found \n";
            rc = 4;
            return rc;
          }
          
          if(k<ndump){
-           cout << k << "-th | " << "Sector " << sector << " | Plate " << plate << " | Strip " << strip << " | PadZ " << padz << " | PadX " << padx << endl;
-           cout << k << "-th | ADC " << firstADC << " [bin] | TDC " << firstTDC << " [bin]" << endl;
-           cout << "----------------------------------------------------"<< endl;
+           cout << k << "-th | Sector " << sector << " | Plate " << plate << " | Strip " << strip << " | PadZ " << padz << " | PadX " << padx << endl;
+           cout << k << "-th | ADC " << firstADC << " [bin] | TDC " << firstTDC << " [bin] \n";
+           cout << "---------------------------------------------------- \n";
          }
          
          // filling sdigit volume histos
@@ -170,7 +191,7 @@ Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=15, Int_t iEvNum=0)
 
   if (gAlice) 
     {
-      delete gAlice->GetRunLoader();
+      delete AliRunLoader::Instance();
       delete gAlice;
       gAlice = 0x0;
     }