]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFT0.cxx
used run 170162 as reference
[u/mrichter/AliRoot.git] / TOF / AliTOFT0.cxx
index 46d00d256f96b08a4239716bac0628b9f8b7bde1..b3e992be3460c13c88882139aca871548fdddf2e 100644 (file)
@@ -16,6 +16,7 @@
 /* $Id$ */
 
 //_________________________________________________________________________
+//
 // This is a TTask that made the calculation of the Time zero using TOF.
 // Description: The algorithm used to calculate the time zero of
 // interaction using TOF detector is the following.
@@ -61,7 +62,7 @@
 // The strong assumption is the MC selection of primary particles. It
 // will be introduced in the future also some more realistic
 // simulation about this point.
-
+//
 // Use case:
 // root [0] AliTOFT0 * tzero = new AliTOFT0("galice.root")
 // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
 //                   misidentified tracks and a comparison about the
 //                   true configuration (known from MC) and the best
 //                   assignment
+//
 //-- Author: F. Pierella
-//////////////////////////////////////////////////////////////////////////////
-
-#include <Riostream.h>
-#include <stdlib.h>
+//
+//_________________________________________________________________________
 
-#include <TBenchmark.h>
 #include <TCanvas.h>
 #include <TClonesArray.h>
 #include <TFile.h>
-#include <TFolder.h>
+//#include <TFolder.h>
 #include <TFrame.h>
 #include <TH1.h>
 #include <TParticle.h>
-#include <TROOT.h>
-#include <TSystem.h>
+#include <TBenchmark.h>
 #include <TTask.h>
 #include <TTree.h>
-#include <TVirtualMC.h>
+#include <TRandom.h>
+#include <TROOT.h>
 
-#include "AliDetector.h"
+#include "AliLoader.h"
 #include "AliMC.h"
 #include "AliRun.h"
 
-#include "AliTOF.h"
-#include "AliTOFT0.h"
 #include "AliTOFhitT0.h"
-#include "AliTOFv4T0.h"
-#include "AliTOFv5T0.h"
+#include "AliTOFT0.h"
+#include "AliTOF.h"
+
+extern TROOT *gROOT;
+extern TRandom *gRandom;
+extern TBenchmark *gBenchmark;
+
+extern AliRun *gAlice;
 
 ClassImp(AliTOFT0)
 
 //____________________________________________________________________________ 
-  AliTOFT0::AliTOFT0():TTask("AliTOFT0","") 
+AliTOFT0::AliTOFT0():
+  TTask("AliTOFT0",""),
+  fNevents(0),
+  fTimeResolution(0),
+  fLowerMomBound(0),
+  fUpperMomBound(0),
+  fT0File(""),
+  fHeadersFile("")
 {
   // ctor
-  fNevents = 0 ;
 }
            
 //____________________________________________________________________________ 
-  AliTOFT0::AliTOFT0(char* headerFile, Int_t nEvents):TTask("AliTOFT0","") 
+AliTOFT0::AliTOFT0(char* headerFile, Int_t nEvents):
+  TTask("AliTOFT0",""), 
+  fNevents(nEvents),
+  fTimeResolution(1.2e-10),
+  fLowerMomBound(1.5),
+  fUpperMomBound(2.),
+  fT0File(""),
+  fHeadersFile(headerFile)
 {
   //
   //
   //
 
-  fNevents=nEvents ; // Number of events for which calculate the T0, 
+  //fNevents=nEvents ; // Number of events for which calculate the T0, 
                      // default 0: it means all evens in current file
-  fLowerMomBound=1.5; // [GeV/c] default value
-  fUpperMomBound=2. ; // [GeV/c] default value
-  fTimeResolution   = 1.2e-10; // 120 ps by default    
-  fHeadersFile = headerFile ;
+  //fLowerMomBound=1.5; // [GeV/c] default value
+  //fUpperMomBound=2. ; // [GeV/c] default value
+  //fTimeResolution   = 1.2e-10; // 120 ps by default  
+  //fHeadersFile = headerFile ;
 
   TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
 
@@ -143,13 +159,35 @@ ClassImp(AliTOFT0)
 }
 
 //____________________________________________________________________________ 
-  AliTOFT0::AliTOFT0(const AliTOFT0 & tzero):TTask("AliTOFT0","")
+AliTOFT0::AliTOFT0(const AliTOFT0 & tzero):
+  TTask("AliTOFT0",""),
+  fNevents(0),
+  fTimeResolution(0),
+  fLowerMomBound(0),
+  fUpperMomBound(0),
+  fT0File(""),
+  fHeadersFile("")
 {
   // copy ctr
 
 ( (AliTOFT0 &)tzero ).Copy(*this);
 }
 
+//____________________________________________________________________________ 
+AliTOFT0& AliTOFT0::operator = (const AliTOFT0 & tzero)
+{
+  if (this==&tzero) return *this;
+
+  fNevents=tzero.fNevents;
+  fTimeResolution=tzero.fTimeResolution;
+  fLowerMomBound=tzero.fLowerMomBound;
+  fUpperMomBound=tzero.fUpperMomBound;
+  fT0File=tzero.fT0File;
+  fHeadersFile=tzero.fHeadersFile;
+  return *this;
+
+}
+
 //____________________________________________________________________________ 
   AliTOFT0::~AliTOFT0()
 {
@@ -246,15 +284,15 @@ void AliTOFT0::Exec(Option_t *option)
   }
 
   if(strstr(option,"all")){
-    cout << "Selecting primary tracks with momentum between " << fLowerMomBound << " GeV/c and " << fUpperMomBound << " GeV/c" << endl;
-    cout << "Memorandum: 0 means PION | 1 means KAON | 2 means PROTON" << endl;
+    AliInfo(Form("Selecting primary tracks with momentum between %f GeV/c and %f GeV/c",  fLowerMomBound, fUpperMomBound));
+    AliInfo("Memorandum: 0 means PION | 1 means KAON | 2 means PROTON");
   }
 
-  if (fNevents == 0) fNevents = (Int_t) gAlice->TreeE()->GetEntries();
+  if (fNevents == 0) fNevents = (Int_t) AliRunLoader::Instance()->TreeE()->GetEntries();
 
   for (Int_t ievent = 0; ievent < fNevents; ievent++) {
     gAlice->GetEvent(ievent);
-    TTree *hitTree = detTOF->TreeH ();
+    TTree *hitTree = detTOF->GetLoader()->TreeH ();
     if (!hitTree)
       return;
     TParticle*    particle;
@@ -274,9 +312,12 @@ void AliTOFT0::Exec(Option_t *option)
     {
       if(nset>=5) break; // check on the number of set analyzed
       
-      gAlice->ResetHits();
+      gAlice->GetMCApp()->ResetHits();
       hitTree->GetEvent(track);
-      particle = gAlice->GetMCApp()->Particle(track);
+
+      //AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+
+      //particle = mcApplication->Particle(track);
       Int_t nhits = tofHits->GetEntriesFast();
 
       for (Int_t hit = 0; hit < nhits; hit++)
@@ -312,7 +353,7 @@ void AliTOFT0::Exec(Option_t *option)
            timeofflight[index]=time;
            tracktoflen[index]=toflen;
            momentum[index]=mom;
-           //      cout << timeofflight[index] << " " << tracktoflen[index] << " " << momentum[index] << endl;
+           //AliInfo(Form(" %d  %d  %d ", timeofflight[index], tracktoflen[index], momentum[index]));
            switch (abspdg) {
            case 211:
              truparticle[index]=0;
@@ -333,7 +374,7 @@ void AliTOFT0::Exec(Option_t *option)
            lasttrack=track;
            istop=0;
            selected=0;
-           //cout << "starting t0 calculation for current set" << endl;
+           //AliInfo("starting t0 calculation for current set");
            for (Int_t i1=0; i1<3;i1++) {
              beta[0]=momentum[0]/sqrt(massarray[i1]*massarray[i1]+momentum[0]*momentum[0]);
              for (Int_t i2=0; i2<3;i2++) { 
@@ -419,10 +460,10 @@ void AliTOFT0::Exec(Option_t *option)
            hchibestconflevel->Fill(confLevel);
            itimes++;
            if(strstr(option,"all")){
-             cout << "True Assignment " << truparticle[0] << truparticle[1] << truparticle[2] << truparticle[3] << truparticle[4] << truparticle[5] << truparticle[6] << truparticle[7] << truparticle[8] << truparticle[9] <<endl;
-             cout << "Best Assignment " << assparticle[0] << assparticle[1] << assparticle[2] << assparticle[3] << assparticle[4] << assparticle[5] << assparticle[6] << assparticle[7] << assparticle[8] << assparticle[9] << endl;
-             cout << "Minimum ChiSquare for current set    " << chisquare << endl;
-             cout << "Confidence Level (Minimum ChiSquare) " << confLevel << endl;
+             AliInfo(Form("True Assignment %d  %d  %d  %d  %d  %d  %d  %d  %d  %d", truparticle[0], truparticle[1], truparticle[2], truparticle[3], truparticle[4], truparticle[5], truparticle[6], truparticle[7], truparticle[8], truparticle[9]));
+             AliInfo(Form("Best Assignment %d  %d  %d  %d  %d  %d  %d  %d  %d  %d", assparticle[0], assparticle[1], assparticle[2], assparticle[3], assparticle[4], assparticle[5], assparticle[6], assparticle[7], assparticle[8], assparticle[9]));
+             AliInfo(Form("Minimum ChiSquare for current set   %f ", chisquare));
+             AliInfo(Form("Confidence Level (Minimum ChiSquare) %f", confLevel));
            }
            if (strstr(option,"visual") && itimes && (itimes%kUPDATE) == 0) {
              if (itimes == kUPDATE){
@@ -454,12 +495,12 @@ void AliTOFT0::Exec(Option_t *option)
   
   if(strstr(option,"all")){
     nmisidentified=(nmisidentified0+nmisidentified1+nmisidentified2+nmisidentified3+nmisidentified4+nmisidentified5+nmisidentified6+nmisidentified7+nmisidentified8+nmisidentified9);
-    cout << "total number of tracks token into account  " << 10*5*fNevents << endl;
+    AliInfo(Form("total number of tracks token into account  %i", 10*5*fNevents));
     Float_t badPercentage=100.*(Float_t)nmisidentified/(10*5*fNevents);
-    cout << "total misidentified                        " << nmisidentified << "("<< badPercentage << "%)" <<endl;
-    cout << "Total Number of set token into account     " << 5*fNevents << endl;
+    AliInfo(Form("total misidentified                       %i (%f %%) ", nmisidentified, badPercentage));
+    AliInfo(Form("Total Number of set token into account     %i", 5*fNevents));
     Float_t goodSetPercentage=100.*(Float_t)ngood/(5*fNevents);
-    cout << "Number of set with no misidentified tracks " << ngood << "("<< goodSetPercentage << "%)" <<endl;
+    AliInfo(Form("Number of set with no misidentified tracks %i (%f %%)", ngood, goodSetPercentage));
   }
 
   // free used memory for canvas
@@ -468,10 +509,12 @@ void AliTOFT0::Exec(Option_t *option)
   delete c3; c3=0;
 
   // generating output filename only if not previously specified using SetTZeroFile
-  char outFileName[70];
-  strcpy(outFileName,"ht010tr120ps"); // global time resolution has to be converted from Int_t to char
+
+  /*const*/ Int_t kSize = 70+fHeadersFile.Length()+1;
+  char outFileName[kSize];
+  strncpy(outFileName,"ht010tr120ps",kSize); // global time resolution has to be converted from Int_t to char
                                       // in order to have in the output filename this parameter
-  strcat(outFileName,fHeadersFile);
+  strncat(outFileName,fHeadersFile,kSize);
 
   if(fT0File.IsNull()) fT0File=outFileName;
 
@@ -485,10 +528,12 @@ void AliTOFT0::Exec(Option_t *option)
   
   if(strstr(option,"tim") || strstr(option,"all")){
     gBenchmark->Stop("TOFT0");
-    cout << "AliTOFT0:" << endl ;
+    AliInfo("AliTOFT0:");
+    /*
     cout << "   took " << gBenchmark->GetCpuTime("TOFT0") << " seconds in order to calculate T0 " 
-        <<  gBenchmark->GetCpuTime("TOFT0")/fNevents << " seconds per event " << endl ;
-    cout << endl ;
+        << gBenchmark->GetCpuTime("TOFT0")/fNevents << " seconds per event " << endl ;
+    */
+    gBenchmark->Print("TOFT0");
   }
 }
  
@@ -496,7 +541,7 @@ void AliTOFT0::Exec(Option_t *option)
 void AliTOFT0::SetTZeroFile(char * file )
 {
   //
-  //
+  // Set T0 file name
   //
   printf("Destination file : %s \n", file) ;
   fT0File=file;
@@ -507,7 +552,7 @@ void AliTOFT0::SetTZeroFile(char * file )
 void AliTOFT0::Print(Option_t* /*option*/)const
 {
   //
-  //
+  // Print class content
   //
   printf("------------------- %s -------------\n", GetName()) ;
   if(!fT0File.IsNull())
@@ -522,7 +567,9 @@ Bool_t AliTOFT0::operator==( AliTOFT0 const &tzero )const
   // Equal operator
   // 
 
-  if( (fTimeResolution==tzero.fTimeResolution)&&(fLowerMomBound==tzero.fLowerMomBound)&&(fUpperMomBound==tzero.fUpperMomBound))
+  if( (fTimeResolution==tzero.fTimeResolution)&&
+      (fLowerMomBound==tzero.fLowerMomBound)&&
+      (fUpperMomBound==tzero.fUpperMomBound))
     return kTRUE ;
   else
     return kFALSE ;