]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFT0.cxx
Reject clusters that are matched to more than one track
[u/mrichter/AliRoot.git] / TOF / AliTOFT0.cxx
index 71211574f6e95c3c103df3b9626e8b8b44534990..e234e150c54b3b76eb419e87728ad8031b3bb889 100644 (file)
 //
 //_________________________________________________________________________
 
-#include "TCanvas.h"
-#include "TClonesArray.h"
-#include "TFile.h"
-#include "TFolder.h"
-#include "TFrame.h"
-#include "TH1.h"
-#include "TParticle.h"
-#include "TBenchmark.h"
-#include "TTask.h"
-#include "TTree.h"
-
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+//#include <TFolder.h>
+#include <TFrame.h>
+#include <TH1.h>
+#include <TParticle.h>
+#include <TBenchmark.h>
+#include <TTask.h>
+#include <TTree.h>
+#include <TRandom.h>
+#include <TROOT.h>
+
+#include "AliLoader.h"
 #include "AliMC.h"
 #include "AliRun.h"
 
 #include "AliTOFT0.h"
 #include "AliTOF.h"
 
-extern TBenchmark *gBenchmark;
-extern TSystem *gSystem;
+//extern TROOT *gROOT;
 extern TRandom *gRandom;
-extern TROOT *gROOT;
+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() ) ;
 
@@ -145,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()
 {
@@ -248,15 +284,15 @@ void AliTOFT0::Exec(Option_t *option)
   }
 
   if(strstr(option,"all")){
-    AliInfo(Form("Selecting primary tracks with momentum between %d GeV/c and %d GeV/c",  fLowerMomBound, fUpperMomBound));
-    AliInfo("Memorandum: 0 means PION | 1 means KAON | 2 means PROTON")
+    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;
@@ -276,12 +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);
 
-      AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+      //AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
 
-      particle = mcApplication->Particle(track);
+      //particle = mcApplication->Particle(track);
       Int_t nhits = tofHits->GetEntriesFast();
 
       for (Int_t hit = 0; hit < nhits; hit++)
@@ -426,8 +462,8 @@ void AliTOFT0::Exec(Option_t *option)
            if(strstr(option,"all")){
              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   %d ", chisquare));
-             AliInfo(Form("Confidence Level (Minimum ChiSquare) %d", confLevel));
+             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){
@@ -461,10 +497,10 @@ void AliTOFT0::Exec(Option_t *option)
     nmisidentified=(nmisidentified0+nmisidentified1+nmisidentified2+nmisidentified3+nmisidentified4+nmisidentified5+nmisidentified6+nmisidentified7+nmisidentified8+nmisidentified9);
     AliInfo(Form("total number of tracks token into account  %i", 10*5*fNevents));
     Float_t badPercentage=100.*(Float_t)nmisidentified/(10*5*fNevents);
-    AliInfo(Form("total misidentified                       %i (%%) ", nmisidentified, badPercentage));
+    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);
-    AliInfo(Form("Number of set with no misidentified tracks %i (%%)", ngood, goodSetPercentage));
+    AliInfo(Form("Number of set with no misidentified tracks %i (%f %%)", ngood, goodSetPercentage));
   }
 
   // free used memory for canvas
@@ -473,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;
 
@@ -503,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;
@@ -514,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())
@@ -529,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 ;