]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/extra/AliRsnTOFCorrectionESD.cxx
Migration of PWG2/RESONANCES -> PWGLF/RESONANCES
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / extra / AliRsnTOFCorrectionESD.cxx
1 //
2 // Class AliRsnTOFCorrectionESD
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()   ]
6 // - a value equal to a given reference     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18
19 #include <Riostream.h>
20
21 #include "AliLog.h"
22 #include "AliESDEvent.h"
23 #include "AliTOFT0maker.h"
24 #include "AliTOFcalib.h"
25 #include "AliCDBManager.h"
26
27 #include "AliRsnTOFCorrectionESD.h"
28
29 ClassImp(AliRsnTOFCorrectionESD)
30
31 //Bool_t         AliRsnTOFCorrectionESD::fgTOFcalibrateESD = kTRUE;
32 Bool_t         AliRsnTOFCorrectionESD::fgTOFcorrectTExp  = kTRUE;
33 Bool_t         AliRsnTOFCorrectionESD::fgTOFuseT0        = kTRUE;
34 Bool_t         AliRsnTOFCorrectionESD::fgTOFtuneMC       = kFALSE;
35 Double_t       AliRsnTOFCorrectionESD::fgTOFresolution   = 100.0;
36 AliTOFT0maker* AliRsnTOFCorrectionESD::fgTOFmaker        = 0x0;
37 AliTOFcalib*   AliRsnTOFCorrectionESD::fgTOFcalib        = 0x0;
38 Int_t          AliRsnTOFCorrectionESD::fgLastRun         = -1;
39
40 //_________________________________________________________________________________________________
41 AliRsnTOFCorrectionESD::AliRsnTOFCorrectionESD(Bool_t isMC, Double_t tofRes)
42    : fOwnESDpid(kFALSE), fESDpid(0x0)
43 {
44 //
45 // Default constructor.
46 //
47
48    fgTOFtuneMC     = isMC;
49    fgTOFresolution = tofRes;
50 }
51
52 //_________________________________________________________________________________________________
53 AliRsnTOFCorrectionESD::AliRsnTOFCorrectionESD(const AliRsnTOFCorrectionESD& copy)
54    : TObject(copy), fOwnESDpid(copy.fOwnESDpid), fESDpid(copy.fESDpid)
55 {
56 //
57 // Copy constructor
58 //
59 }
60
61 //_________________________________________________________________________________________________
62 AliRsnTOFCorrectionESD& AliRsnTOFCorrectionESD::operator=(const AliRsnTOFCorrectionESD& copy)
63 {
64 //
65 // Assignment operator
66 //
67   if (this == &copy)
68     return *this;
69    fOwnESDpid = copy.fOwnESDpid;
70    fESDpid    = copy.fESDpid;
71
72    return (*this);
73 }
74
75 //_________________________________________________________________________________________________
76 void AliRsnTOFCorrectionESD::ProcessEvent(AliESDEvent *esd)
77 {
78 //
79 // Repeats the PID for current event.
80 // In order to avoid to repeat the initialization of calib object
81 // when this is not needed, this function uses the data-members
82 // to check if the run has changed.
83 //
84
85    // compare run number with static data member
86    Int_t run = esd->GetRunNumber();
87
88    // initialize only if run number has changed
89    if (run != fgLastRun) {
90       AliInfo("============================================================================================");
91       AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", fgLastRun, run));
92       AliInfo("============================================================================================");
93       fgLastRun = run;
94
95       AliCDBManager::Instance()->SetDefaultStorage("raw://");
96       AliCDBManager::Instance()->SetRun(fgLastRun);
97
98       if (fgTOFmaker) delete fgTOFmaker;
99       if (fgTOFcalib) delete fgTOFcalib;
100
101       fgTOFcalib = new AliTOFcalib();
102       if (fgTOFtuneMC) {
103          fgTOFcalib->SetRemoveMeanT0(kFALSE);
104          fgTOFcalib->SetCalibrateTOFsignal(kFALSE);
105       } else {
106          fgTOFcalib->SetRemoveMeanT0(kTRUE);
107          fgTOFcalib->SetCalibrateTOFsignal(kTRUE);
108       }
109       if (fgTOFcorrectTExp) fgTOFcalib->SetCorrectTExp(kTRUE);
110       fgTOFcalib->Init();
111
112       fgTOFmaker = new AliTOFT0maker(fESDpid, fgTOFcalib);
113       fgTOFmaker->SetTimeResolution(fgTOFresolution);
114    }
115
116    // if the ESDpid object is not present, create it
117    if (!fESDpid) {
118       fESDpid = new AliESDpid;
119       fOwnESDpid = kTRUE;
120    }
121
122    // repeat the calibration and PID computations
123    /*if (fgTOFcalibrateESD)*/ fgTOFcalib->CalibrateESD(esd);
124    if (fgTOFtuneMC) fgTOFmaker->TuneForMC(esd);
125    if (fgTOFuseT0) {
126       fgTOFmaker->ComputeT0TOF(esd);
127       fgTOFmaker->ApplyT0TOF(esd);
128       fESDpid->MakePID(esd, kFALSE, 0.);
129    }
130 }