ROOT logo
//
// Class AliRsnTOFCorrectionESD
//
// General implementation of a single cut strategy, which can be:
// - a value contained in a given interval  [--> IsBetween()   ]
// - a value equal to a given reference     [--> MatchesValue()]
//
// In all cases, the reference value(s) is (are) given as data members
// and each kind of cut requires a given value type (Int, UInt, Double),
// but the cut check procedure is then automatized and chosen thanks to
// an enumeration of the implemented cut types.
// At the end, the user (or any other point which uses this object) has
// to use the method IsSelected() to check if this cut has been passed.
//
// authors: Martin Vala (martin.vala@cern.ch)
//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
//

#include <Riostream.h>

#include "AliLog.h"
#include "AliESDEvent.h"
#include "AliTOFT0maker.h"
#include "AliTOFcalib.h"
#include "AliCDBManager.h"

#include "AliRsnTOFCorrectionESD.h"

ClassImp(AliRsnTOFCorrectionESD)

//Bool_t         AliRsnTOFCorrectionESD::fgTOFcalibrateESD = kTRUE;
Bool_t         AliRsnTOFCorrectionESD::fgTOFcorrectTExp  = kTRUE;
Bool_t         AliRsnTOFCorrectionESD::fgTOFuseT0        = kTRUE;
Bool_t         AliRsnTOFCorrectionESD::fgTOFtuneMC       = kFALSE;
Double_t       AliRsnTOFCorrectionESD::fgTOFresolution   = 100.0;
AliTOFT0maker* AliRsnTOFCorrectionESD::fgTOFmaker        = 0x0;
AliTOFcalib*   AliRsnTOFCorrectionESD::fgTOFcalib        = 0x0;
Int_t          AliRsnTOFCorrectionESD::fgLastRun         = -1;

//_________________________________________________________________________________________________
AliRsnTOFCorrectionESD::AliRsnTOFCorrectionESD(Bool_t isMC, Double_t tofRes)
   : fOwnESDpid(kFALSE), fESDpid(0x0)
{
//
// Default constructor.
//

   fgTOFtuneMC     = isMC;
   fgTOFresolution = tofRes;
}

//_________________________________________________________________________________________________
AliRsnTOFCorrectionESD::AliRsnTOFCorrectionESD(const AliRsnTOFCorrectionESD& copy)
   : TObject(copy), fOwnESDpid(copy.fOwnESDpid), fESDpid(copy.fESDpid)
{
//
// Copy constructor
//
}

//_________________________________________________________________________________________________
AliRsnTOFCorrectionESD& AliRsnTOFCorrectionESD::operator=(const AliRsnTOFCorrectionESD& copy)
{
//
// Assignment operator
//
  if (this == &copy)
    return *this;
   fOwnESDpid = copy.fOwnESDpid;
   fESDpid    = copy.fESDpid;

   return (*this);
}

//_________________________________________________________________________________________________
void AliRsnTOFCorrectionESD::ProcessEvent(AliESDEvent *esd)
{
//
// Repeats the PID for current event.
// In order to avoid to repeat the initialization of calib object
// when this is not needed, this function uses the data-members
// to check if the run has changed.
//

   // compare run number with static data member
   Int_t run = esd->GetRunNumber();

   // initialize only if run number has changed
   if (run != fgLastRun) {
      AliInfo("============================================================================================");
      AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", fgLastRun, run));
      AliInfo("============================================================================================");
      fgLastRun = run;

      AliCDBManager::Instance()->SetDefaultStorage("raw://");
      AliCDBManager::Instance()->SetRun(fgLastRun);

      if (fgTOFmaker) delete fgTOFmaker;
      if (fgTOFcalib) delete fgTOFcalib;

      fgTOFcalib = new AliTOFcalib();
      if (fgTOFtuneMC) {
         fgTOFcalib->SetRemoveMeanT0(kFALSE);
         fgTOFcalib->SetCalibrateTOFsignal(kFALSE);
      } else {
         fgTOFcalib->SetRemoveMeanT0(kTRUE);
         fgTOFcalib->SetCalibrateTOFsignal(kTRUE);
      }
      if (fgTOFcorrectTExp) fgTOFcalib->SetCorrectTExp(kTRUE);
      fgTOFcalib->Init();

      fgTOFmaker = new AliTOFT0maker(fESDpid, fgTOFcalib);
      fgTOFmaker->SetTimeResolution(fgTOFresolution);
   }

   // if the ESDpid object is not present, create it
   if (!fESDpid) {
      fESDpid = new AliESDpid;
      fOwnESDpid = kTRUE;
   }

   // repeat the calibration and PID computations
   /*if (fgTOFcalibrateESD)*/ fgTOFcalib->CalibrateESD(esd);
   if (fgTOFtuneMC) fgTOFmaker->TuneForMC(esd);
   if (fgTOFuseT0) {
      fgTOFmaker->ComputeT0TOF(esd);
      fgTOFmaker->ApplyT0TOF(esd);
      fESDpid->MakePID(esd, kFALSE, 0.);
   }
}
 AliRsnTOFCorrectionESD.cxx:1
 AliRsnTOFCorrectionESD.cxx:2
 AliRsnTOFCorrectionESD.cxx:3
 AliRsnTOFCorrectionESD.cxx:4
 AliRsnTOFCorrectionESD.cxx:5
 AliRsnTOFCorrectionESD.cxx:6
 AliRsnTOFCorrectionESD.cxx:7
 AliRsnTOFCorrectionESD.cxx:8
 AliRsnTOFCorrectionESD.cxx:9
 AliRsnTOFCorrectionESD.cxx:10
 AliRsnTOFCorrectionESD.cxx:11
 AliRsnTOFCorrectionESD.cxx:12
 AliRsnTOFCorrectionESD.cxx:13
 AliRsnTOFCorrectionESD.cxx:14
 AliRsnTOFCorrectionESD.cxx:15
 AliRsnTOFCorrectionESD.cxx:16
 AliRsnTOFCorrectionESD.cxx:17
 AliRsnTOFCorrectionESD.cxx:18
 AliRsnTOFCorrectionESD.cxx:19
 AliRsnTOFCorrectionESD.cxx:20
 AliRsnTOFCorrectionESD.cxx:21
 AliRsnTOFCorrectionESD.cxx:22
 AliRsnTOFCorrectionESD.cxx:23
 AliRsnTOFCorrectionESD.cxx:24
 AliRsnTOFCorrectionESD.cxx:25
 AliRsnTOFCorrectionESD.cxx:26
 AliRsnTOFCorrectionESD.cxx:27
 AliRsnTOFCorrectionESD.cxx:28
 AliRsnTOFCorrectionESD.cxx:29
 AliRsnTOFCorrectionESD.cxx:30
 AliRsnTOFCorrectionESD.cxx:31
 AliRsnTOFCorrectionESD.cxx:32
 AliRsnTOFCorrectionESD.cxx:33
 AliRsnTOFCorrectionESD.cxx:34
 AliRsnTOFCorrectionESD.cxx:35
 AliRsnTOFCorrectionESD.cxx:36
 AliRsnTOFCorrectionESD.cxx:37
 AliRsnTOFCorrectionESD.cxx:38
 AliRsnTOFCorrectionESD.cxx:39
 AliRsnTOFCorrectionESD.cxx:40
 AliRsnTOFCorrectionESD.cxx:41
 AliRsnTOFCorrectionESD.cxx:42
 AliRsnTOFCorrectionESD.cxx:43
 AliRsnTOFCorrectionESD.cxx:44
 AliRsnTOFCorrectionESD.cxx:45
 AliRsnTOFCorrectionESD.cxx:46
 AliRsnTOFCorrectionESD.cxx:47
 AliRsnTOFCorrectionESD.cxx:48
 AliRsnTOFCorrectionESD.cxx:49
 AliRsnTOFCorrectionESD.cxx:50
 AliRsnTOFCorrectionESD.cxx:51
 AliRsnTOFCorrectionESD.cxx:52
 AliRsnTOFCorrectionESD.cxx:53
 AliRsnTOFCorrectionESD.cxx:54
 AliRsnTOFCorrectionESD.cxx:55
 AliRsnTOFCorrectionESD.cxx:56
 AliRsnTOFCorrectionESD.cxx:57
 AliRsnTOFCorrectionESD.cxx:58
 AliRsnTOFCorrectionESD.cxx:59
 AliRsnTOFCorrectionESD.cxx:60
 AliRsnTOFCorrectionESD.cxx:61
 AliRsnTOFCorrectionESD.cxx:62
 AliRsnTOFCorrectionESD.cxx:63
 AliRsnTOFCorrectionESD.cxx:64
 AliRsnTOFCorrectionESD.cxx:65
 AliRsnTOFCorrectionESD.cxx:66
 AliRsnTOFCorrectionESD.cxx:67
 AliRsnTOFCorrectionESD.cxx:68
 AliRsnTOFCorrectionESD.cxx:69
 AliRsnTOFCorrectionESD.cxx:70
 AliRsnTOFCorrectionESD.cxx:71
 AliRsnTOFCorrectionESD.cxx:72
 AliRsnTOFCorrectionESD.cxx:73
 AliRsnTOFCorrectionESD.cxx:74
 AliRsnTOFCorrectionESD.cxx:75
 AliRsnTOFCorrectionESD.cxx:76
 AliRsnTOFCorrectionESD.cxx:77
 AliRsnTOFCorrectionESD.cxx:78
 AliRsnTOFCorrectionESD.cxx:79
 AliRsnTOFCorrectionESD.cxx:80
 AliRsnTOFCorrectionESD.cxx:81
 AliRsnTOFCorrectionESD.cxx:82
 AliRsnTOFCorrectionESD.cxx:83
 AliRsnTOFCorrectionESD.cxx:84
 AliRsnTOFCorrectionESD.cxx:85
 AliRsnTOFCorrectionESD.cxx:86
 AliRsnTOFCorrectionESD.cxx:87
 AliRsnTOFCorrectionESD.cxx:88
 AliRsnTOFCorrectionESD.cxx:89
 AliRsnTOFCorrectionESD.cxx:90
 AliRsnTOFCorrectionESD.cxx:91
 AliRsnTOFCorrectionESD.cxx:92
 AliRsnTOFCorrectionESD.cxx:93
 AliRsnTOFCorrectionESD.cxx:94
 AliRsnTOFCorrectionESD.cxx:95
 AliRsnTOFCorrectionESD.cxx:96
 AliRsnTOFCorrectionESD.cxx:97
 AliRsnTOFCorrectionESD.cxx:98
 AliRsnTOFCorrectionESD.cxx:99
 AliRsnTOFCorrectionESD.cxx:100
 AliRsnTOFCorrectionESD.cxx:101
 AliRsnTOFCorrectionESD.cxx:102
 AliRsnTOFCorrectionESD.cxx:103
 AliRsnTOFCorrectionESD.cxx:104
 AliRsnTOFCorrectionESD.cxx:105
 AliRsnTOFCorrectionESD.cxx:106
 AliRsnTOFCorrectionESD.cxx:107
 AliRsnTOFCorrectionESD.cxx:108
 AliRsnTOFCorrectionESD.cxx:109
 AliRsnTOFCorrectionESD.cxx:110
 AliRsnTOFCorrectionESD.cxx:111
 AliRsnTOFCorrectionESD.cxx:112
 AliRsnTOFCorrectionESD.cxx:113
 AliRsnTOFCorrectionESD.cxx:114
 AliRsnTOFCorrectionESD.cxx:115
 AliRsnTOFCorrectionESD.cxx:116
 AliRsnTOFCorrectionESD.cxx:117
 AliRsnTOFCorrectionESD.cxx:118
 AliRsnTOFCorrectionESD.cxx:119
 AliRsnTOFCorrectionESD.cxx:120
 AliRsnTOFCorrectionESD.cxx:121
 AliRsnTOFCorrectionESD.cxx:122
 AliRsnTOFCorrectionESD.cxx:123
 AliRsnTOFCorrectionESD.cxx:124
 AliRsnTOFCorrectionESD.cxx:125
 AliRsnTOFCorrectionESD.cxx:126
 AliRsnTOFCorrectionESD.cxx:127
 AliRsnTOFCorrectionESD.cxx:128
 AliRsnTOFCorrectionESD.cxx:129
 AliRsnTOFCorrectionESD.cxx:130