Changes for report #74151: Important update in AliTOFPIDResponse class: use also...
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Oct 2010 15:34:58 +0000 (15:34 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Oct 2010 15:34:58 +0000 (15:34 +0000)
19 files changed:
STEER/AliESDEvent.cxx
STEER/AliESDEvent.h
STEER/AliESDpid.cxx
STEER/AliESDpid.h
STEER/AliReconstruction.cxx
STEER/AliReconstructor.h
STEER/AliTOFHeader.cxx [new file with mode: 0644]
STEER/AliTOFHeader.h [new file with mode: 0644]
STEER/AliTOFPIDResponse.cxx
STEER/AliTOFPIDResponse.h
STEER/CMakelibESD.pkg
STEER/ESDLinkDef.h
STEER/libESD.pkg
TOF/AliTOFReconstructor.cxx
TOF/AliTOFReconstructor.h
TOF/AliTOFT0maker.cxx
TOF/AliTOFT0maker.h
TOF/AliTOFcalib.cxx
TOF/AliTOFcalib.h

index 019d4d7..a19530f 100644 (file)
@@ -74,31 +74,32 @@ ClassImp(AliESDEvent)
 // here we define the names, some classes are no TNamed, therefore the classnames 
 // are the Names
   const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
-                                                      "AliESDHeader",
-                                                      "AliESDZDC",
-                                                      "AliESDFMD",
-                                                      "AliESDVZERO",
-                                                      "AliESDTZERO",
-                                                      "TPCVertex",
-                                                      "SPDVertex",
-                                                      "PrimaryVertex",
-                                                      "AliMultiplicity",
-                                                      "PHOSTrigger",
-                                                      "EMCALTrigger",
-                                                      "SPDPileupVertices",
-                                                      "TrkPileupVertices",
-                                                      "Tracks",
-                                                      "MuonTracks",
-                                                      "PmdTracks",
-                                                      "TrdTracks",
-                                                      "V0s",
-                                                      "Cascades",
-                                                      "Kinks",
-                                                      "CaloClusters",
-                                                     "EMCALCells",
-                                                     "PHOSCells",
-                                                      "AliRawDataErrorLogs",
-                                                      "AliESDACORDE"};
+                                                       "AliESDHeader",
+                                                       "AliESDZDC",
+                                                       "AliESDFMD",
+                                                       "AliESDVZERO",
+                                                       "AliESDTZERO",
+                                                       "TPCVertex",
+                                                       "SPDVertex",
+                                                       "PrimaryVertex",
+                                                       "AliMultiplicity",
+                                                       "PHOSTrigger",
+                                                       "EMCALTrigger",
+                                                       "SPDPileupVertices",
+                                                       "TrkPileupVertices",
+                                                       "Tracks",
+                                                       "MuonTracks",
+                                                       "PmdTracks",
+                                                       "TrdTracks",
+                                                       "V0s",
+                                                       "Cascades",
+                                                       "Kinks",
+                                                       "CaloClusters",
+                                                       "EMCALCells",
+                                                       "PHOSCells",
+                                                       "AliRawDataErrorLogs",
+                                                       "AliESDACORDE",
+                                                       "AliTOFHeader"};
 
 //______________________________________________________________________________
 AliESDEvent::AliESDEvent():
@@ -132,7 +133,8 @@ AliESDEvent::AliESDEvent():
   fESDOld(0),
   fESDFriendOld(0),
   fConnected(kFALSE),
-  fUseOwnList(kFALSE)
+  fUseOwnList(kFALSE),
+  fTOFHeader(0)
 {
 }
 //______________________________________________________________________________
@@ -168,7 +170,8 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0),
   fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0),
   fConnected(esd.fConnected),
-  fUseOwnList(esd.fUseOwnList)
+  fUseOwnList(esd.fUseOwnList),
+  fTOFHeader(new AliTOFHeader(*esd.fTOFHeader))
 
 {
   // CKB init in the constructor list and only add here ...
@@ -198,6 +201,7 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   AddObject(fPHOSCells);
   AddObject(fErrorLogs);
   AddObject(fESDACORDE);
+  AddObject(fTOFHeader);
 
   GetStdContent();
 
@@ -428,6 +432,11 @@ void AliESDEvent::ResetStdContent()
     fSPDMult->~AliMultiplicity();
     new (fSPDMult) AliMultiplicity();
   }
+  if(fTOFHeader){
+    fTOFHeader->~AliTOFHeader();
+    new (fTOFHeader) AliTOFHeader();
+    //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
+  }
   if(fPHOSTrigger)fPHOSTrigger->Reset(); 
   if(fEMCALTrigger)fEMCALTrigger->Reset(); 
   if(fSPDPileupVertices)fSPDPileupVertices->Delete();
@@ -1121,7 +1130,7 @@ void AliESDEvent::GetStdContent()
   fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]);
   fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]);
   fESDACORDE = (AliESDACORDE*)fESDObjects->FindObject(fgkESDListName[kESDACORDE]);
-
+  fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]);
 }
 
 void AliESDEvent::SetStdNames(){
@@ -1180,6 +1189,7 @@ void AliESDEvent::CreateStdContent()
   AddObject(new AliESDCaloCells());
   AddObject(new TClonesArray("AliRawDataErrorLog",0));
   AddObject(new AliESDACORDE()); 
+  AddObject(new AliTOFHeader());
 
   // check the order of the indices against enum...
 
@@ -1713,3 +1723,21 @@ Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const {
     else return IsPileupFromSPD(5,0.8);
 }
 
+void  AliESDEvent::SetTOFHeader(const AliTOFHeader *header)
+{
+  //
+  // Set the TOF event_time
+  //
+
+  if (fTOFHeader) {
+    *fTOFHeader=*header;
+    //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
+  }
+  else {
+    // for analysis of reconstructed events
+    // when this information is not avaliable
+    fTOFHeader = new AliTOFHeader(*header);
+    //AddObject(fTOFHeader);
+  }
+
+}
index 7e64a43..16cbc22 100644 (file)
@@ -39,6 +39,7 @@
 #include "AliESDCaloCluster.h"
 #include "AliESDCaloCells.h"
 
+#include "AliTOFHeader.h"
 
 class AliESDfriend;
 class AliESDVZERO;
@@ -93,6 +94,7 @@ public:
                       kPHOSCells,
                       kErrorLogs,
                        kESDACORDE,
+                      kTOFHeader,
                       kESDListN
   };
 
@@ -244,6 +246,13 @@ public:
 
   const AliESDVertex *GetPrimaryVertex() const;
 
+
+
+  void SetTOFHeader(const AliTOFHeader * tofEventTime);
+  const AliTOFHeader *GetTOFHeader() const {return fTOFHeader;}
+
+
+
   void SetMultiplicity(const AliMultiplicity *mul);
 
   const AliMultiplicity *GetMultiplicity() const {return fSPDMult;}
@@ -457,6 +466,11 @@ protected:
 
   static const char* fgkESDListName[kESDListN]; //!
 
+  AliTOFHeader *fTOFHeader;  //! event times (and sigmas) as estimated by TOF
+                            //  combinatorial algorithm.
+                             //  It contains also TOF time resolution
+                             //  and T0spread as written in OCDB
+
   ClassDef(AliESDEvent,11)  //ESDEvent class 
 };
 #endif 
index 7b003da..28a6b2b 100644 (file)
 //      Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
 //-----------------------------------------------------------------
 
+#include "TArrayI.h"
+#include "TArrayF.h"
+
 #include "AliLog.h"
 #include "AliPID.h"
+#include "AliTOFHeader.h"
 #include "AliESDpid.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 
 ClassImp(AliESDpid)
 
-Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t TimeZeroTOF) const {
+Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t timeZeroTOF) const {
   //
   //  Calculate probabilities for all detectors, except if TPConly==kTRUE
   //  and combine PID
@@ -42,9 +46,9 @@ Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t TimeZeroTOF
   //
 
   /*
-  Float_t TimeZeroTOF = 0;
+  Float_t timeZeroTOF = 0;
   if (subtractT0) 
-    TimeZeroTOF = event->GetT0();
+    timeZeroTOF = event->GetT0();
   */
   Int_t nTrk=event->GetNumberOfTracks();
   for (Int_t iTrk=0; iTrk<nTrk; iTrk++) {  
@@ -52,7 +56,7 @@ Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t TimeZeroTOF
     MakeTPCPID(track);
     if (!TPConly) {
       MakeITSPID(track);
-      MakeTOFPID(track, TimeZeroTOF);
+      MakeTOFPID(track, timeZeroTOF);
       //MakeHMPIDPID(track);
       //MakeTRDPID(track);
     }
@@ -169,14 +173,18 @@ void AliESDpid::MakeITSPID(AliESDtrack *track) const
 
 }
 //_________________________________________________________________________
-void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t TimeZeroTOF) const
+void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t /*timeZeroTOF*/) const
 {
   //
   //   TOF PID using gaussian response
   //
+
   if ((track->GetStatus()&AliESDtrack::kTOFout)==0) return;
   if ((track->GetStatus()&AliESDtrack::kTIME)==0) return;
 
+  Int_t ibin = fTOFResponse.GetMomBin(track->GetP());
+  Float_t timezero = fTOFResponse.GetT0bin(ibin);
+
   Double_t time[AliPID::kSPECIESN];
   track->GetIntegratedTimes(time);
 
@@ -202,14 +210,14 @@ void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t TimeZeroTOF) const
                  sigma[AliPID::kProton]
                  ));
 
-  Double_t tof = track->GetTOFsignal() - TimeZeroTOF;
+  Double_t tof = track->GetTOFsignal() - timezero;
 
   Double_t p[AliPID::kSPECIES];
   Bool_t mismatch = kTRUE, heavy = kTRUE;
   for (Int_t j=0; j<AliPID::kSPECIES; j++) {
     Double_t sig = sigma[j];
-    if (TMath::Abs(tof-time[j]) > fRange*sig) {
-      p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
+    if (TMath::Abs(tof-time[j]) > (fRange+2)*sig) {
+       p[j] = TMath::Exp(-0.5*(fRange+2)*(fRange+2))/sig;
     } else
       p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
 
@@ -229,6 +237,8 @@ void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t TimeZeroTOF) const
   track->SetTOFpid(p);
 
   if (heavy) track->ResetStatus(AliESDtrack::kTOFpid);    
+  if (!CheckTOFMatching(track)) track->SetStatus(AliESDtrack::kTOFmismatch);    
+  
 }
 //_________________________________________________________________________
 void AliESDpid::MakeTRDPID(AliESDtrack *track) const
@@ -290,3 +300,246 @@ void AliESDpid::CombinePID(AliESDtrack *track) const
 
   track->SetESDpid(p);
 }
+//_________________________________________________________________________
+Bool_t AliESDpid::CheckTOFMatching(AliESDtrack *track) const{
+    Bool_t status = kFALSE;
+    
+    Double_t exptimes[5];
+    track->GetIntegratedTimes(exptimes);
+    
+    Float_t dedx = track->GetTPCsignal();
+    Float_t time = track->GetTOFsignal();
+    
+    Float_t p = track->P();
+    
+    Double_t ptpc[3];
+    track->GetInnerPxPyPz(ptpc);
+    Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]);
+    
+    for(Int_t i=0;i < 5;i++){
+       AliPID::EParticleType type=AliPID::EParticleType(i);
+       
+       Float_t resolutionTOF = fTOFResponse.GetExpectedSigma(p, exptimes[i], AliPID::ParticleMass(i));
+       if(TMath::Abs(exptimes[i] - time) < fRange * resolutionTOF){
+           Float_t dedxExp = fTPCResponse.GetExpectedSignal(momtpc,type);
+           Float_t resolutionTPC = fTPCResponse.GetExpectedSigma(momtpc,track->GetTPCsignalN(),type);
+           
+           if(TMath::Abs(dedx - dedxExp) < fRange * resolutionTPC){
+               status = kTRUE;
+           }
+       }
+    }
+    
+    // for nuclei
+    Float_t dedxExpPr = fTPCResponse.GetExpectedSignal(momtpc,AliPID::kProton);
+    Float_t resolutionTPCpr =  fTPCResponse.GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
+    if(!status && (exptimes[4] < time && dedx > dedxExpPr + resolutionTPCpr*fRange)) status = kTRUE;
+    
+    
+    return status;
+}
+//_________________________________________________________________________
+void AliESDpid::SetTOFResponse(AliESDEvent *event,EStartTimeType_t option){
+  //
+  // Set TOF response function
+  // Input option for event_time used
+  //
+
+    Float_t t0spread = 0.; //event->GetEventTimeSpread();
+    if(t0spread < 10) t0spread = 80;
+
+    // T0 from TOF algorithm
+    //Float_t t0Gen,t0ResGen;
+    //Int_t nt0;
+    //Float_t t0ESD[fTOFResponse.GetNmomBins()],t0resESD[fTOFResponse.GetNmomBins()];
+    //Int_t it0ESD[fTOFResponse.GetNmomBins()];
+
+    Bool_t flagT0TOF=kFALSE;
+    Bool_t flagT0T0=kFALSE;
+    Float_t startTime[fTOFResponse.GetNmomBins()];
+    Float_t startTimeRes[fTOFResponse.GetNmomBins()];
+
+    Float_t estimatedT0event[fTOFResponse.GetNmomBins()];
+    Float_t estimatedT0resolution[fTOFResponse.GetNmomBins()];
+    for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+      estimatedT0event[i]=0.0;
+      estimatedT0resolution[i]=0.0;
+    }
+
+    if(event->GetT0TOF()){
+       flagT0T0=kTRUE;
+    }
+
+
+    AliTOFHeader *tofHeader =(AliTOFHeader*)event->GetTOFHeader();
+
+    if(tofHeader){
+
+      flagT0TOF=kTRUE;
+      for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+       startTime[i]=tofHeader->GetDefaultEventTimeVal();//t0Gen;
+       startTimeRes[i]=tofHeader->GetDefaultEventTimeRes();//t0ResGen;
+      }
+
+      TArrayI *ibin=tofHeader->GetNvalues();
+      TArrayF *t0Bin=tofHeader->GetEventTimeValues();
+      TArrayF *t0ResBin=tofHeader->GetEventTimeRes();
+      for(Int_t j=0;j < tofHeader->GetNbins();j++){
+       Int_t icurrent = (Int_t)ibin->GetAt(j);
+       startTime[icurrent]=t0Bin->GetAt(j);//t0ESD[j];
+       startTimeRes[icurrent]=t0ResBin->GetAt(j);//t0resESD[j];
+      }
+    }
+
+    if(option == kFILL_T0){ // T0-FILL is used
+       for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+         estimatedT0event[i]=0.0;
+         estimatedT0resolution[i]=t0spread;
+         //fT0event[i] = 0.0;
+         //fT0resolution[i] = t0spread;
+       }
+       fTOFResponse.SetT0event(estimatedT0event);
+       fTOFResponse.SetT0resolution(estimatedT0resolution);
+    }
+    if(option == kTOF_T0){ // T0-TOF is used when available (T0-FILL otherwise) from ESD
+       if(flagT0TOF){
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+             estimatedT0event[i]=0.0;
+             estimatedT0resolution[i]=t0spread;
+             //fT0event[i] = startTime[i];
+             //fT0resolution[i] = startTimeRes[i];
+           }
+           fTOFResponse.SetT0event(startTime);
+           fTOFResponse.SetT0resolution(startTimeRes);
+       }
+       else{
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+             estimatedT0event[i]=0.0;
+             estimatedT0resolution[i]=t0spread;
+             //fT0event[i] = 0.0;
+             //fT0resolution[i] = t0spread;
+           }
+           fTOFResponse.SetT0event(estimatedT0event);
+           fTOFResponse.SetT0resolution(estimatedT0resolution);
+       }
+    }
+    else if(option == kBest_T0){ // T0-T0 is used when available (T0-FILL otherwise) from ESD
+       Float_t t0AC=-10000;
+       Float_t t0A=-10000;
+       Float_t t0C=-10000;
+       if(flagT0T0){
+           t0AC= event->GetT0TOF()[0];
+           t0A= event->GetT0TOF()[1];
+           t0C= event->GetT0TOF()[2];
+       }
+
+       Float_t t0t0Best = 0;
+       Float_t t0t0BestRes = 9999;
+       if(TMath::Abs(t0AC) < 500){
+           t0t0Best = t0AC;
+           t0t0BestRes = 55;
+       }
+       else if(TMath::Abs(t0A) < 500){
+           t0t0Best = t0A;
+           t0t0BestRes = 75;
+       }
+       else if(TMath::Abs(t0C) < 500){
+           t0t0Best = t0C;
+           t0t0BestRes = 65;
+       }
+
+       if(flagT0TOF){ // if T0-TOF info is available
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+               if(t0t0BestRes<300){
+                 if(startTimeRes[i]<t0spread){
+                   Double_t wtot = 1./startTimeRes[i]/startTimeRes[i] + 1./t0t0BestRes/t0t0BestRes;
+                   Double_t t0best = startTime[i]/startTimeRes[i]/startTimeRes[i] + t0t0Best/t0t0BestRes/t0t0BestRes;
+                   estimatedT0event[i]=t0best / wtot;
+                   estimatedT0resolution[i]=1./TMath::Sqrt(wtot);
+                   //fT0event[i]=t0best / wtot;
+                   //fT0resolution[i]=1./TMath::Sqrt(wtot);
+                 }
+                 else {
+                   estimatedT0event[i]=t0t0Best;
+                   estimatedT0resolution[i]=t0t0BestRes;
+                   //fT0event[i] = t0t0Best;
+                   //fT0resolution[i] = t0t0BestRes;
+                 }
+               }
+               else{
+                 estimatedT0event[i]=startTime[i];
+                 estimatedT0resolution[i]=startTimeRes[i];
+                 //fT0event[i] = startTime[i];
+                 //fT0resolution[i] = startTimeRes[i];
+               }
+           }
+           fTOFResponse.SetT0event(estimatedT0event);
+           fTOFResponse.SetT0resolution(estimatedT0resolution);
+       }
+       else{ // if no T0-TOF info is available
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+               if(t0t0BestRes<300){
+                 estimatedT0event[i]=t0t0Best;
+                 estimatedT0resolution[i]=t0t0BestRes;
+                 //fT0event[i] = t0t0Best;
+                 //fT0resolution[i] = t0t0BestRes;
+               }
+               else{
+                 estimatedT0event[i]=0.0;
+                 estimatedT0resolution[i]=t0spread;
+                 //fT0event[i] = 0.0;
+                 //fT0resolution[i] = t0spread;
+               }
+           }
+           fTOFResponse.SetT0event(estimatedT0event);
+           fTOFResponse.SetT0resolution(estimatedT0resolution);
+       }
+    }
+    else if(option == kT0_T0){ // the best of what available (T0-FILL otherwise) from ESD
+       Float_t t0AC=-10000;
+       Float_t t0A=-10000;
+       Float_t t0C=-10000;
+       if(flagT0T0){
+           t0AC= event->GetT0TOF()[0];
+           t0A= event->GetT0TOF()[1];
+           t0C= event->GetT0TOF()[2];
+       }
+
+//     printf("T0_T0 = %f %f %f\n",t0AC,t0A,t0C);
+
+       if(TMath::Abs(t0AC) < 500){
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+             estimatedT0event[i]=t0AC;
+             estimatedT0resolution[i]=55;
+             //fT0event[i] = t0AC;
+             //fT0resolution[i] = 55;
+           }
+       }
+       else if(TMath::Abs(t0A) < 500){
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+             estimatedT0event[i]=t0A;
+             estimatedT0resolution[i]=75;
+             //fT0event[i] = t0A;
+             //fT0resolution[i] = 75;
+           }
+       }
+       else if(TMath::Abs(t0C) < 500){
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+             estimatedT0event[i]=t0C;
+             estimatedT0resolution[i]=65;
+             //fT0event[i] = t0C;
+             //fT0resolution[i] = 65;
+           }
+       }
+       else{
+           for(Int_t i=0;i<fTOFResponse.GetNmomBins();i++){
+             estimatedT0event[i]=0.0;
+             estimatedT0resolution[i]=t0spread;
+             //fT0event[i] = 0.0;
+             //fT0resolution[i] = t0spread;
+           }
+       }
+       fTOFResponse.SetT0event(estimatedT0event);
+       fTOFResponse.SetT0resolution(estimatedT0resolution);
+    }
+}
index 83ffb36..a38743d 100644 (file)
@@ -25,10 +25,11 @@ class AliESDpid {
 public:
   AliESDpid(): fRange(5.), fITSPIDmethod(kITSTruncMean), fTPCResponse(), fITSResponse(), fTOFResponse(), fTRDResponse(){;}
   virtual ~AliESDpid() {}
-  Int_t MakePID(AliESDEvent *event, Bool_t TPCOnly = kFALSE, Float_t TimeZeroTOF=0) const;
+  Int_t MakePID(AliESDEvent *event, Bool_t TPCOnly = kFALSE, Float_t timeZeroTOF=9999) const;
   void MakeTPCPID(AliESDtrack *track) const;
   void MakeITSPID(AliESDtrack *track) const;
-  void MakeTOFPID(AliESDtrack *track, Float_t TimeZeroTOF) const;
+  void MakeTOFPID(AliESDtrack *track, Float_t /*timeZeroTOF*/) const;
+  Bool_t CheckTOFMatching(AliESDtrack *track) const;
   //  void MakeHMPIDPID(AliESDtrack *track);
   void MakeTRDPID(AliESDtrack *track) const;
   void CombinePID(AliESDtrack *track) const;
@@ -37,7 +38,7 @@ public:
   void SetITSPIDmethod(ITSPIDmethod pmeth) { fITSPIDmethod = pmeth; }
 
   Float_t NumberOfSigmasTPC(const AliESDtrack *track, AliPID::EParticleType type) const;
-  Float_t NumberOfSigmasTOF(const AliESDtrack *track, AliPID::EParticleType type, const Float_t TimeZeroTOF) const;
+  Float_t NumberOfSigmasTOF(const AliESDtrack *track, AliPID::EParticleType type, const Float_t timeZeroTOF) const;
   Float_t NumberOfSigmasITS(const AliESDtrack *track, AliPID::EParticleType type) const;
 
   AliITSPIDResponse &GetITSResponse() {return fITSResponse;}
@@ -45,6 +46,8 @@ public:
   AliTOFPIDResponse &GetTOFResponse() {return fTOFResponse;}
   AliTRDPIDResponse &GetTRDResponse() {return fTRDResponse;}
 
+  enum EStartTimeType_t {kFILL_T0,kTOF_T0, kT0_T0, kBest_T0};
+  void SetTOFResponse(AliESDEvent *event,EStartTimeType_t option);
 
 private:
   Float_t           fRange;          // nSigma max in likelihood
@@ -66,10 +69,10 @@ inline Float_t AliESDpid::NumberOfSigmasTPC(const AliESDtrack *track, AliPID::EP
   return fTPCResponse.GetNumberOfSigmas(mom,track->GetTPCsignal(),track->GetTPCsignalN(),type); 
 }
 
-inline Float_t AliESDpid::NumberOfSigmasTOF(const AliESDtrack *track, AliPID::EParticleType type, const Float_t TimeZeroTOF) const {
+inline Float_t AliESDpid::NumberOfSigmasTOF(const AliESDtrack *track, AliPID::EParticleType type, const Float_t timeZeroTOF) const {
   Double_t times[AliPID::kSPECIES];
   track->GetIntegratedTimes(times);
-  return (track->GetTOFsignal() - TimeZeroTOF - times[type])/fTOFResponse.GetExpectedSigma(track->GetP(),times[type],AliPID::ParticleMass(type));
+  return (track->GetTOFsignal() - timeZeroTOF - times[type])/fTOFResponse.GetExpectedSigma(track->GetP(),times[type],AliPID::ParticleMass(type));
 }
 
 inline Float_t AliESDpid::NumberOfSigmasITS(const AliESDtrack *track, AliPID::EParticleType type) const {
index f51e4b9..031286d 100644 (file)
@@ -1887,7 +1887,10 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
     }
+
+    // AdC+FN
+    GetReconstructor(3)->FillEventTimeWithTOF(fesd,&pid);
+
     // combined PID
     pid.MakePID(fesd);
 
index 659b114..4c63b21 100644 (file)
@@ -68,6 +68,9 @@ public:
   static const AliDetectorRecoParam* GetRecoParam(Int_t iDet);
   virtual void                 GetPidSettings(AliESDpid *esdPID);
 
+  virtual void FillEventTimeWithTOF(AliESDEvent *, AliESDpid *)
+    {return;}
+
 private:
 
   AliReconstructor(const AliReconstructor &); // Not implemented
diff --git a/STEER/AliTOFHeader.cxx b/STEER/AliTOFHeader.cxx
new file mode 100644 (file)
index 0000000..4afd15e
--- /dev/null
@@ -0,0 +1,206 @@
+/**************************************************************************
+ * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------------------
+//           Implementation of the Event Time class
+//           for the Event Data Summary class
+//           This class contains the Event Time
+//           as estimated by the TOF combinatorial algorithm
+// Origin: A.De Caro, decaro@lsa.infn.it
+//-----------------------------------------------------------------
+
+//---- standard headers ----
+#include "Riostream.h"
+//---- Root headers --------
+#include "TArrayF.h"
+#include "TArrayI.h"
+//---- AliRoot headers -----
+#include "AliTOFHeader.h"
+
+
+ClassImp(AliTOFHeader)
+
+//--------------------------------------------------------------------------
+AliTOFHeader::AliTOFHeader() :
+  TObject(),
+  fDefaultEventTimeValue(0.),
+  fDefaultEventTimeRes(0.),
+  fNbins(0),
+  fEventTimeValues(new TArrayF(1)),
+  fEventTimeRes(new TArrayF(1)),
+  fNvalues(new TArrayI(1)),
+  fTOFtimeResolution(0.),
+  fT0spread(0.)
+{
+  //
+  // Default Constructor
+  //
+
+}
+
+//--------------------------------------------------------------------------
+AliTOFHeader::AliTOFHeader(Float_t defEvTime, Float_t defResEvTime,
+                          Int_t nDifPbins, Float_t *times, Float_t *res,
+                          Int_t *nPbin, Float_t tofTimeRes, Float_t t0spread) :
+  TObject(),
+  fDefaultEventTimeValue(defEvTime),
+  fDefaultEventTimeRes(defResEvTime),
+  fNbins(nDifPbins),
+  fEventTimeValues(new TArrayF(nDifPbins)),
+  fEventTimeRes(new TArrayF(nDifPbins)),
+  fNvalues(new TArrayI(nDifPbins)),
+  fTOFtimeResolution(tofTimeRes),
+  fT0spread(t0spread)
+{
+  //
+  // Constructor for vertex Z from pixels
+  //
+
+  for (Int_t ii=0; ii<fNbins; ii++) {
+    fEventTimeValues->SetAt(times[ii],ii);
+    fEventTimeRes->SetAt(res[ii],ii);
+    fNvalues->SetAt(nPbin[ii],ii);
+  }
+
+}
+
+//--------------------------------------------------------------------------
+AliTOFHeader::AliTOFHeader(const AliTOFHeader &source):
+  TObject(source),
+  fDefaultEventTimeValue(source.fDefaultEventTimeValue),
+  fDefaultEventTimeRes(source.fDefaultEventTimeRes),
+  fNbins(source.fNbins),
+  fEventTimeValues(new TArrayF(fNbins)),
+  fEventTimeRes(new TArrayF(fNbins)),
+  fNvalues(new TArrayI(fNbins)),
+  fTOFtimeResolution(source.fTOFtimeResolution),
+  fT0spread(source.fT0spread)
+{
+  //
+  // Copy constructor
+  //
+
+
+  for(Int_t i=0;i<fNbins;i++) {
+    fEventTimeValues->SetAt(source.fEventTimeValues->GetAt(i),i);
+    fEventTimeRes->SetAt(source.fEventTimeRes->GetAt(i),i);
+    fNvalues->SetAt(source.fNvalues->GetAt(i),i);
+  }
+
+}
+//--------------------------------------------------------------------------
+AliTOFHeader &AliTOFHeader::operator=(const AliTOFHeader &source){
+  //
+  // assignment operator
+  //
+  if(&source != this){
+    TObject::operator=(source);
+
+    fDefaultEventTimeValue=source.fDefaultEventTimeValue;
+    fDefaultEventTimeRes=source.fDefaultEventTimeRes;
+    fNbins=source.fNbins;
+    fEventTimeValues=new TArrayF(fNbins);
+    fEventTimeRes=new TArrayF(fNbins);
+    fNvalues=new TArrayI(fNbins);
+    fTOFtimeResolution=source.fTOFtimeResolution;
+    fT0spread=source.fT0spread;
+    for(Int_t i=0;i<fNbins;i++) {
+      fEventTimeValues->SetAt(source.fEventTimeValues->GetAt(i),i);
+      fEventTimeRes->SetAt(source.fEventTimeRes->GetAt(i),i);
+      fNvalues->SetAt(source.fNvalues->GetAt(i),i);
+    }
+  }
+  return *this;
+}
+//--------------------------------------------------------------------------
+void AliTOFHeader::Copy(TObject &obj) const {
+  
+  // this overwrites the virtual TOBject::Copy()
+  // to allow run time copying without casting
+  // in AliESDEvent
+
+  if(this==&obj)return;
+  AliTOFHeader *robj = dynamic_cast<AliTOFHeader*>(&obj);
+  if(!robj)return; // not an AliTOFHeader
+  *robj = *this;
+
+}
+
+//--------------------------------------------------------------------------
+AliTOFHeader::~AliTOFHeader()
+{
+
+  fEventTimeValues->Reset();
+  fEventTimeRes->Reset();
+  fNvalues->Reset();
+
+  delete fEventTimeValues;
+  delete fEventTimeRes;
+  delete fNvalues;
+
+}
+
+//--------------------------------------------------------------------------
+void AliTOFHeader::SetNbins(Int_t nbins)
+{
+  //
+  //
+  //
+
+  fNbins=nbins;
+  fEventTimeValues->Set(nbins);
+  fEventTimeRes->Set(nbins);
+  fNvalues->Set(nbins);
+
+}
+//--------------------------------------------------------------------------
+void AliTOFHeader::SetEventTimeValues(TArrayF *arr)
+{
+  //
+  //
+  //
+
+  fNbins=arr->GetSize();
+  fEventTimeValues->Set(arr->GetSize());
+  for (Int_t ii=0; ii<arr->GetSize(); ii++)
+    fEventTimeValues->SetAt(arr->GetAt(ii),ii);
+
+}
+//--------------------------------------------------------------------------
+void AliTOFHeader::SetEventTimeRes(TArrayF *arr)
+{
+  //
+  //
+  //
+
+  fNbins=arr->GetSize();
+  fEventTimeRes->Set(arr->GetSize());
+  for (Int_t ii=0; ii<arr->GetSize(); ii++)
+    fEventTimeRes->SetAt(arr->GetAt(ii),ii);
+
+}
+//--------------------------------------------------------------------------
+void AliTOFHeader::SetNvalues(TArrayI *arr)
+{
+  //
+  //
+  //
+
+  fNbins=arr->GetSize();
+  fNvalues->Set(arr->GetSize());
+  for (Int_t ii=0; ii<arr->GetSize(); ii++)
+    fNvalues->SetAt(arr->GetAt(ii),ii);
+
+}
diff --git a/STEER/AliTOFHeader.h b/STEER/AliTOFHeader.h
new file mode 100644 (file)
index 0000000..4d2be3a
--- /dev/null
@@ -0,0 +1,91 @@
+#ifndef ALITOFHEADER_H
+#define ALITOFHEADER_H
+/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------
+//  Class for TOF event times, time resolution and T0spread
+//          for the Event Data Summary Class
+//   Origin: A.De Caro, Salerno, decaro@sa.infn.it
+//-------------------------------------------------------
+
+/**************************************************************
+ *                                                            *
+ * This class deals with:                                     *
+ *       event time estimated by TOF combinatorial algorithm; *
+ *       event time resolution;                               *
+ *       TOF time resolution as written in TOF OCDB;          *
+ *       T0spread as written in GRP.                          *
+ *                                                            *
+ **************************************************************/
+
+#include "TObject.h"
+//#include "TArrayF.h"
+//#include "TArrayI.h"
+
+class TArrayI;
+class TArrayF;
+
+class AliTOFHeader : public TObject {
+ public:
+  AliTOFHeader();
+  AliTOFHeader(Float_t defEvTime, Float_t defResEvTime,
+              Int_t nDifPbins, Float_t *times, Float_t *res,
+              Int_t *nPbin, Float_t tofTimeRes, Float_t t0spread);
+  AliTOFHeader(const AliTOFHeader &source);
+  AliTOFHeader &operator=(const AliTOFHeader &source);
+  virtual void Copy(TObject &obj) const;
+
+  virtual ~AliTOFHeader();
+
+  void SetTOFResolution(Float_t res) {fTOFtimeResolution=res;}
+  Float_t GetTOFResolution() const {return fTOFtimeResolution;}
+
+  void SetT0spread(Float_t res) {fT0spread=res;}
+  Float_t GetT0spread() const {return fT0spread;}
+
+  Float_t GetDefaultEventTimeVal() const {return fDefaultEventTimeValue;}
+  Float_t GetDefaultEventTimeRes() const {return fDefaultEventTimeRes;}
+  TArrayF *GetEventTimeValues()    const {return fEventTimeValues;}
+  TArrayF *GetEventTimeRes()       const {return fEventTimeRes;}
+  TArrayI *GetNvalues()            const {return fNvalues;}
+  Int_t   GetNbins()               const {return fNvalues->GetSize();}
+
+  void SetDefaultEventTimeVal(Float_t val) {fDefaultEventTimeValue=val;}
+  void SetDefaultEventTimeRes(Float_t res) {fDefaultEventTimeRes=res;}
+  void SetEventTimeValues(TArrayF *arr);
+  void SetEventTimeRes(TArrayF *arr);
+  void SetNvalues(TArrayI *arr);
+  void SetNbins(Int_t nbins);
+
+ protected:
+
+  Float_t  fDefaultEventTimeValue; // TOF event time value more frequent
+  Float_t  fDefaultEventTimeRes;   // TOF event time res more frequent
+  Int_t    fNbins;                 // number of bins with TOF event
+                                  // time values different from
+                                  // default one
+  TArrayF *fEventTimeValues;       //! array for TOF event time values
+                                  //different from default one
+  TArrayF *fEventTimeRes;          //! array for TOF event time resolutions
+  TArrayI *fNvalues;               //! array for order numbers of momentum bin
+  Float_t fTOFtimeResolution;      // TOF time resolution as written in TOF OCDB
+  Float_t fT0spread;               // t0spread as written in TOF OCDB
+
+ private:
+
+  ClassDef(AliTOFHeader,1)  // Class for TOF event times and so on
+};
+
+#endif
+
+
+
+
+
+
+    
index f92d7ef..f32cc2b 100644 (file)
@@ -90,6 +90,10 @@ Double_t AliTOFPIDResponse::GetExpectedSigma(Float_t mom, Float_t time, Float_t
 }
 //_________________________________________________________________________
 Int_t AliTOFPIDResponse::GetMomBin(Float_t p) const{
+  //
+  // Returns the momentum bin index
+  //
+
   Int_t i=0;
   while(p > fPCutMin[i] && i < fNmomBins) i++;
   if(i > 0) i--;
@@ -98,6 +102,10 @@ Int_t AliTOFPIDResponse::GetMomBin(Float_t p) const{
 }
 //_________________________________________________________________________
 void AliTOFPIDResponse::SetMomBoundary(){
+  //
+  // Set boundaries for momentum bins
+  //
+
   fPCutMin[0] = 0.3;
   fPCutMin[1] = 0.5;
   fPCutMin[2] = 0.6;
@@ -110,3 +118,23 @@ void AliTOFPIDResponse::SetMomBoundary(){
   fPCutMin[9] = 2;
   fPCutMin[10] = 3;  
 }
+//_________________________________________________________________________
+Float_t AliTOFPIDResponse::GetStartTime(Float_t mom) {
+  //
+  // Returns event_time value as estimated by TOF combinatorial algorithm
+  //
+
+  Int_t ibin = GetMomBin(mom);
+  return GetT0bin(ibin);
+
+}
+//_________________________________________________________________________
+Float_t AliTOFPIDResponse::GetStartTimeRes(Float_t mom) {
+  //
+  // Returns event_time resolution as estimated by TOF combinatorial algorithm
+  //
+
+  Int_t ibin = GetMomBin(mom);
+  return GetT0binRes(ibin);
+
+}
index 2c65381..ba8df19 100644 (file)
 
 class AliTOFPIDResponse : public TObject {
 public:
+
   AliTOFPIDResponse();
   AliTOFPIDResponse(Double_t *param);
- ~AliTOFPIDResponse(){}
+  ~AliTOFPIDResponse(){}
 
   void     SetTimeResolution(Float_t res) { fSigma = res; }
   void     SetTimeZero(Double_t t0) { fTime0=t0; }
@@ -32,22 +33,28 @@ public:
 
   void     SetT0event(Float_t *t0event){for(Int_t i=0;i < fNmomBins;i++) fT0event[i] = t0event[i];};
   void     SetT0resolution(Float_t *t0resolution){for(Int_t i=0;i < fNmomBins;i++) fT0resolution[i] = t0resolution[i];};
-  //  void     LoadT0infoFromESD(Option_t *option){}; // to be added
   void     ResetT0info(){ for(Int_t i=0;i < fNmomBins;i++){ fT0event[i] = 0.0; fT0resolution[i] = 0.0;} };
   void     SetMomBoundary();
   Int_t    GetMomBin(Float_t p) const;
   Int_t    GetNmomBins(){return fNmomBins;};
-  Float_t  GetMinMom(Int_t ibin){if(ibin >=0 && ibin <= fNmomBins) return fPCutMin[ibin]; else return 0.0;};
-  Float_t  GetMaxMom(Int_t ibin){if(ibin >=0 && ibin <= fNmomBins) return fPCutMin[ibin+1]; else return 0.0;};
+  Float_t  GetMinMom(Int_t ibin) const {if(ibin >=0 && ibin <= fNmomBins) return fPCutMin[ibin]; else return 0.0;};
+  Float_t  GetMaxMom(Int_t ibin)const {if(ibin >=0 && ibin <= fNmomBins) return fPCutMin[ibin+1]; else return 0.0;};
   void     SetT0bin(Int_t ibin,Float_t t0bin){if(ibin >=0 && ibin <= fNmomBins) fT0event[ibin] = t0bin;};
   void     SetT0binRes(Int_t ibin,Float_t t0binRes){if(ibin >=0 && ibin <= fNmomBins) fT0resolution[ibin] = t0binRes;};
-  Float_t  GetT0bin(Int_t ibin){if(ibin >=0 && ibin <= fNmomBins) return fT0event[ibin]; else return 0.0;};
-  Float_t  GetT0binRes(Int_t ibin){if(ibin >=0 && ibin <= fNmomBins) return fT0resolution[ibin]; else return 0.0;};
+  Float_t  GetT0bin(Int_t ibin) const {if(ibin >=0 && ibin <= fNmomBins) return fT0event[ibin]; else return 0.0;};
+  Float_t  GetT0binRes(Int_t ibin) const {if(ibin >=0 && ibin <= fNmomBins) return fT0resolution[ibin]; else return 0.0;};
+
+  // Get Start Time for a track
+  Float_t  GetStartTime(Float_t mom);
+  Float_t  GetStartTimeRes(Float_t mom);
 
  private:
   Double_t fSigma;        // intrinsic TOF resolution
+
+  // obsolete
   Double_t fPmax;         // "maximal" probability of mismathing (at ~0.5 GeV/c)
   Double_t fTime0;        // time zero
+  //--------------
 
   // About event time (t0) info
   static const Int_t fNmomBins = 10; // number of momentum bin 
index c502d68..d52e3d4 100644 (file)
@@ -1,4 +1,4 @@
-set ( SRCS  AliESDEvent.cxx AliESDInputHandler.cxx AliESDInputHandlerRP.cxx AliESDfriend.cxx AliESD.cxx AliESDtrack.cxx AliESDfriendTrack.cxx AliESDMuonTrack.cxx AliESDPmdTrack.cxx AliESDTrdTrack.cxx AliESDHLTtrack.cxx AliESDv0.cxx AliESDcascade.cxx AliVertex.cxx AliESDVertex.cxx AliESDpid.cxx AliESDkink.cxx AliESDCaloCluster.cxx AliESDMuonCluster.cxx AliESDMuonPad.cxx AliKFParticleBase.cxx AliKFParticle.cxx AliKFVertex.cxx AliKalmanTrack.cxx AliVertexerTracks.cxx AliStrLine.cxx AliESDV0Params.cxx AliTrackPointArray.cxx AliESDFMD.cxx AliFMDMap.cxx AliFMDFloatMap.cxx AliESDMultITS.cxx AliESDVZERO.cxx AliMultiplicity.cxx AliSelector.cxx AliESDRun.cxx AliESDHeader.cxx AliESDHLTDecision.cxx AliESDZDC.cxx AliESDTZERO.cxx AliESDTZEROfriend.cxx AliESDCaloTrigger.cxx AliRawDataErrorLog.cxx AliMeanVertex.cxx AliESDCaloCells.cxx AliESDACORDE.cxx AliTriggerIR.cxx AliESDVZEROfriend.cxx AliTriggerScalersESD.cxx AliTriggerScalersRecordESD.cxx AliESDHandler.cxx AliTrackerBase.cxx)
+set ( SRCS  AliESDEvent.cxx AliESDInputHandler.cxx AliESDInputHandlerRP.cxx AliESDfriend.cxx AliESD.cxx AliESDtrack.cxx AliESDfriendTrack.cxx AliESDMuonTrack.cxx AliESDPmdTrack.cxx AliESDTrdTrack.cxx AliESDHLTtrack.cxx AliESDv0.cxx AliESDcascade.cxx AliVertex.cxx AliESDVertex.cxx AliESDpid.cxx AliESDkink.cxx AliESDCaloCluster.cxx AliESDMuonCluster.cxx AliESDMuonPad.cxx AliKFParticleBase.cxx AliKFParticle.cxx AliKFVertex.cxx AliKalmanTrack.cxx AliVertexerTracks.cxx AliStrLine.cxx AliESDV0Params.cxx AliTrackPointArray.cxx AliESDFMD.cxx AliFMDMap.cxx AliFMDFloatMap.cxx AliESDMultITS.cxx AliESDVZERO.cxx AliMultiplicity.cxx AliSelector.cxx AliESDRun.cxx AliESDHeader.cxx AliESDHLTDecision.cxx AliESDZDC.cxx AliESDTZERO.cxx AliESDTZEROfriend.cxx AliESDCaloTrigger.cxx AliRawDataErrorLog.cxx AliMeanVertex.cxx AliESDCaloCells.cxx AliESDACORDE.cxx AliTriggerIR.cxx AliESDVZEROfriend.cxx AliTriggerScalersESD.cxx AliTriggerScalersRecordESD.cxx AliESDHandler.cxx AliTrackerBase.cxx  AliTOFHeader.cxx)
 
 string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
 
index 72dda03..f94368e 100644 (file)
@@ -88,6 +88,7 @@
 #pragma link C++ class  AliTriggerScalersRecordESD+;
 #pragma link C++ class  AliESDHandler+;
 #pragma link C++ class  AliTrackerBase+;
+#pragma link C++ class  AliTOFHeader+;
 
 #pragma link C++ function operator*(const AliFMDMap&,const AliFMDMap&);
 #pragma link C++ function operator/(const AliFMDMap&,const AliFMDMap&);
index 992bd04..245ed7a 100644 (file)
@@ -32,7 +32,8 @@ SRCS = AliESDEvent.cxx AliESDInputHandler.cxx AliESDInputHandlerRP.cxx AliESDfri
        AliTriggerScalersESD.cxx \
        AliTriggerScalersRecordESD.cxx \
        AliESDHandler.cxx \
-       AliTrackerBase.cxx
+       AliTrackerBase.cxx \
+       AliTOFHeader.cxx
 
 HDRS:= $(SRCS:.cxx=.h) 
 
index 16fccb1..aba6987 100644 (file)
 #include "TString.h"
 
 #include "AliLog.h"
+#include "AliESDEvent.h"
+#include "AliESDpid.h"
 #include "AliRawReader.h"
+#include "AliTOFHeader.h"
 
 #include "AliTOFClusterFinder.h"
 #include "AliTOFClusterFinderV1.h"
 #include "AliTOFtrackerMI.h"
 #include "AliTOFtracker.h"
 #include "AliTOFtrackerV1.h"
+#include "AliTOFT0maker.h"
 #include "AliTOFReconstructor.h"
 
 class TTree;
 
-class AliESDEvent;
-
 ClassImp(AliTOFReconstructor)
 
  //____________________________________________________________________
 AliTOFReconstructor::AliTOFReconstructor() 
   : AliReconstructor(),
-    fTOFcalib(0)
+    fTOFcalib(0)/*,
+                 fTOFT0maker(0)*/
 {
 //
 // ctor
@@ -78,7 +81,11 @@ AliTOFReconstructor::~AliTOFReconstructor()
 //
 // dtor
 //
+
   delete fTOFcalib;
+
+  //delete fTOFT0maker;
+
 }
 
 //_____________________________________________________________________________
@@ -243,3 +250,23 @@ AliTracker* AliTOFReconstructor::CreateTracker() const
   return tracker;
 
 }
+
+//_____________________________________________________________________________
+void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
+{
+  //
+  // Fill AliESDEvent::fTOFHeader variable
+  // It contains the event_time estiamted by the TOF combinatorial algorithm
+  //
+
+  Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
+  AliTOFT0maker *tofT0maker = new AliTOFT0maker(esdPID,fTOFcalib);
+  //AliTOFT0maker tofT0maker = AliTOFT0maker(esdPID,fTOFcalib);
+  tofT0maker->SetTimeResolution(tofResolution);
+  tofT0maker->ComputeT0TOF(event);
+  tofT0maker->WriteInESD(event);
+  tofT0maker->~AliTOFT0maker();
+  delete tofT0maker;
+
+}
+
index 4a36137..5b44c8d 100644 (file)
@@ -20,6 +20,7 @@ class TTree;
 class AliESDEvent;
 class AliRawReader;
 class AliTOFcalib;
+//class AliTOFT0maker;
 
 class AliTOFReconstructor: public AliReconstructor {
 public:
@@ -40,11 +41,14 @@ public:
 
   static const AliTOFRecoParam* GetRecoParam() { return dynamic_cast<const AliTOFRecoParam*>(AliReconstructor::GetRecoParam(3)); } // getting RecoParam obj
 
+  virtual void FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID);
+
 private:
   AliTOFReconstructor(const AliTOFReconstructor &); //Not implemented
   AliTOFReconstructor& operator=(const AliTOFReconstructor &); //Not implemented
 
   AliTOFcalib    *fTOFcalib;    // pointer to TOF calib class
+  //AliTOFT0maker  *fTOFT0maker;  // pointer to TOF T0 maker class
 
   ClassDef(AliTOFReconstructor, 3)   // class for the TOF reconstruction
 };
index 3ee891b..d9af732 100644 (file)
@@ -46,6 +46,7 @@
 #include "AliTOFT0v1.h"
 #include "AliTOFT0maker.h"
 #include "AliPID.h"
+#include "AliLog.h"
 #include "AliESDpid.h"
 #include "AliESDEvent.h"
 #include "TFile.h"
@@ -53,6 +54,7 @@
 #include "AliTOFcalib.h"
 #include "AliTOFRunParams.h"
 #include "TRandom.h"
+#include "AliTOFHeader.h"
 
 ClassImp(AliTOFT0maker)
            
@@ -424,3 +426,89 @@ AliTOFT0maker::TuneForMC(AliESDEvent *esd){ // return true T0 event
   //
   return t0;
 }
+//_________________________________________________________________________
+void     AliTOFT0maker::WriteInESD(AliESDEvent *esd){
+  //
+  // Write t0Gen, t0ResGen, nt0;
+  //       t0resESD[0:nt0], it0ESD[0:nt0]
+  // in the AliESDEvent
+  //
+    Int_t nMomBins = fPIDesd->GetTOFResponse().GetNmomBins();
+
+    Int_t nt0=0;
+    Float_t *t0 = new Float_t[nMomBins];
+    Float_t *t0res = new Float_t[nMomBins];
+    Int_t *multT0 = new Int_t[nMomBins];
+
+    for(Int_t i=0;i<nMomBins;i++){
+//     printf("START %i) %f %f\n",i,fT0event[i],fT0resolution[i]);
+       multT0[i]=0;
+       Bool_t kNewT0=kTRUE;
+       for(Int_t j=0;j < nt0;j++){
+           if(TMath::Abs(fPIDesd->GetTOFResponse().GetT0bin(i) - t0[j])<0.1){
+               kNewT0=kFALSE;
+               multT0[j]++;
+               j=nMomBins*10;
+           }
+       }
+       if(kNewT0){
+           t0[nt0]=fPIDesd->GetTOFResponse().GetT0bin(i);
+           t0res[nt0]=fPIDesd->GetTOFResponse().GetT0binRes(i);
+           nt0++;
+       }
+    }
+
+    Int_t iMultT0=0,nmult=0;
+    for(Int_t j=0;j < nt0;j++){ // find the most frequent
+       if(multT0[j] > nmult){
+           iMultT0 = j;
+           nmult = multT0[j];
+       }
+    }
+
+    Float_t *t0ESD = new Float_t[nMomBins];
+    Float_t *t0resESD = new Float_t[nMomBins];
+    Int_t *it0ESD = new Int_t[nMomBins];
+    
+    Float_t t0Gen,t0ResGen;
+    t0Gen = t0[iMultT0];
+    t0ResGen = t0res[iMultT0];
+    nt0=0;
+    //  printf("T0 to ESD\n%f %f\n",t0Gen,t0ResGen);
+    for(Int_t i=0;i<nMomBins;i++){
+       if(TMath::Abs(fPIDesd->GetTOFResponse().GetT0bin(i) - t0Gen)>0.1){
+           t0ESD[nt0]=fPIDesd->GetTOFResponse().GetT0bin(i);
+           t0resESD[nt0]=fPIDesd->GetTOFResponse().GetT0binRes(i);
+           it0ESD[nt0]=i;
+//         printf("%i) %f %f %i\n",nt0,t0ESD[nt0],t0resESD[nt0],it0ESD[nt0]);
+           nt0++;
+       }
+    }
+
+    // Write  t0Gen,t0ResGen; nt0; t0resESD[0:nt0],it0ESD[0:nt0] in the AliESDEvent
+
+   AliTOFHeader *tofHeader =
+       new AliTOFHeader(t0Gen,t0ResGen,nt0,
+                        t0ESD,t0resESD,it0ESD,fTimeResolution,fT0spreadExt);
+  
+    esd->SetTOFHeader(tofHeader);
+
+    AliInfo(Form("resTOF=%f T0spread=%f t0Gen=%f t0resGen=%f",fTimeResolution,fT0spreadExt,t0Gen,t0ResGen));
+    AliInfo(Form("%d ",nt0));
+    for (Int_t ii=0; ii<nt0; ii++)
+      AliInfo(Form("pBin=%d t0val=%f t0res=%f",it0ESD[ii],t0ESD[ii],t0resESD[ii]));
+    
+    delete[] t0;
+    t0 = NULL;
+    delete[] t0res;
+    t0res = NULL;
+    delete[] multT0;
+    multT0 = NULL;
+    delete[] t0ESD;
+    t0ESD = NULL;
+    delete[] t0resESD;
+    t0resESD = NULL;
+    delete[] it0ESD;
+    it0ESD = NULL;
+
+}
index bb679ef..aa86d18 100644 (file)
@@ -47,9 +47,13 @@ public:
   
   Float_t  TuneForMC(AliESDEvent *esd); // set enabled channeld, add a smeared t0, add a TOF smearing, return true(smeared) T0 event
   
-  void SetT0spread(Float_t t0spread){fT0spreadExt=t0spread;};
+  void SetT0spread(Float_t t0spread){fT0spreadExt=t0spread;}; // get T0spread
+  Float_t GetT0spread() const {return fT0spreadExt;} // get T0spread
+
   void SetT0fill(Float_t t0fill){fT0fillExt=t0fill;};
   
+  void WriteInESD(AliESDEvent *esd);
+
  private:
   
   AliTOFT0maker(const AliTOFT0maker &);
index 1202ca0..c8e1258 100644 (file)
@@ -903,7 +903,24 @@ void AliTOFcalib::WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun
   const Char_t *sel1 = "RecoParam" ;
   TString out(Form("%s/%s",sel,sel1));
   AliCDBId id(out,minrun,maxrun);
-  man->Put(param,id,md);
+
+  TObjArray *arr=new TObjArray(1);
+  arr->AddLast(param);
+  man->Put(arr,id,md);
+  //man->Put(param,id,md);
+  delete md;
+}
+//_____________________________________________________________________________
+void AliTOFcalib::WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TObjArray *arr){
+  //Write reconstruction parameters to the CDB
+
+  AliCDBManager *man = AliCDBManager::Instance();
+  AliCDBMetaData *md = new AliCDBMetaData();
+  md->SetResponsible("Silvia Arcelli");
+  const Char_t *sel1 = "RecoParam" ;
+  TString out(Form("%s/%s",sel,sel1));
+  AliCDBId id(out,minrun,maxrun);
+  man->Put(arr,id,md);
   delete md;
 }
 //_____________________________________________________________________________
index 28441bd..5e950d4 100644 (file)
@@ -121,6 +121,7 @@ public:
   Bool_t ReadParOnlineHWFromCDB(const Char_t *sel, Int_t nrun);      // old, before unification of status info
   Bool_t ReadParOfflineFromCDB(const Char_t *sel, Int_t nrun);
   void WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFRecoParam *param);
+  void WriteRecParOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun, TObjArray *arr);
   AliTOFRecoParam * ReadRecParFromCDB(const Char_t *sel, Int_t nrun, Int_t eventType=0);
   void CreateTreeFromCDB(Int_t minrun, Int_t maxrun);
   void CreateTreeFromFile(Int_t minrun, Int_t maxrun);