]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx
Added run list for LHC10h (runs that are not bad in pass1, from RCT)
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliTOFTenderSupply.cxx
CommitLineData
ee981ab3 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17///////////////////////////////////////////////////////////////////////////////
18// //
88ccd4cf 19// TOF tender:
20// load updated calibration if needed
21// reapply TOF pid on the fly //
ee981ab3 22// //
23///////////////////////////////////////////////////////////////////////////////
24#include <AliLog.h>
25#include <AliESDEvent.h>
88ccd4cf 26#include <AliESDtrack.h>
ee981ab3 27#include <AliESDInputHandler.h>
28#include <AliAnalysisManager.h>
29#include <AliESDpid.h>
30#include <AliTender.h>
31
32#include <AliTOFcalib.h>
33#include <AliTOFT0maker.h>
34
35#include <AliCDBManager.h>
36#include <AliCDBEntry.h>
37#include <AliT0CalibSeasonTimeShift.h>
38
39#include "AliTOFTenderSupply.h"
40
41AliTOFTenderSupply::AliTOFTenderSupply() :
42 AliTenderSupply(),
43 fESDpid(0x0),
44 fIsMC(kFALSE),
45 fApplyT0(kFALSE),
46 fTimeZeroType(3),
47 fCorrectExpTimes(kTRUE),
88ccd4cf 48 fLHC10dPatch(kFALSE),
ee981ab3 49 fTOFCalib(0x0),
50 fTOFT0maker(0x0),
51 fTOFres(100.)
52
53
54{
55 //
56 // default ctor
57 //
58
59 fT0shift[0] = 0;
60 fT0shift[1] = 0;
61 fT0shift[2] = 0;
62 fT0shift[3] = 0;
63}
64
65//_____________________________________________________
66AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) :
67 AliTenderSupply(name,tender),
68 fESDpid(0x0),
69 fIsMC(kFALSE),
70 fApplyT0(kFALSE),
71 fTimeZeroType(3),
72 fCorrectExpTimes(kTRUE),
88ccd4cf 73 fLHC10dPatch(kFALSE),
ee981ab3 74 fTOFCalib(0x0),
75 fTOFT0maker(0x0),
76 fTOFres(100.)
77
78{
79 //
80 // named ctor
81 //
82
83 fT0shift[0] = 0;
84 fT0shift[1] = 0;
85 fT0shift[2] = 0;
86 fT0shift[3] = 0;
87}
88
89//_____________________________________________________
90void AliTOFTenderSupply::Init()
91{
92 //
93 // Initialise TOF tender
94 //
95
96
97 //
98 // Setup PID object
99 //
100
101 // Check if another detector already created the esd pid object
102 // if not we create it and set it to the ESD input handler
103 fESDpid=fTender->GetESDhandler()->GetESDpid();
104 if (!fESDpid) {
105 fESDpid=new AliESDpid;
106 fTender->GetESDhandler()->SetESDpid(fESDpid);
107 }
108
109 //Set proper resolution in case of MC
110 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
111 if (mgr->GetMCtruthEventHandler()) fIsMC=kTRUE;
112
113
114 //
115 // Create TOF calibration classes
116 //
117 if (!fTOFCalib){
118 fTOFCalib=new AliTOFcalib();
119 fTOFCalib->SetCorrectTExp(fCorrectExpTimes); // apply a fine tuning on the expected times at low momenta
120 if(fIsMC) fTOFCalib->SetCalibrateTOFsignal(kFALSE); // no new calibration
121// fTOFCalib->Init();
122 }
123 if (!fTOFT0maker) {
124 fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib);
125 fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID
126 printf("tof time res = %f\n",fTOFres);
127 }
128}
129
130//_____________________________________________________
131void AliTOFTenderSupply::ProcessEvent()
132{
133 //
134 // Reapply pid information
135 //
136
137 //no corrections for MC
138 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
139 if (mgr->GetMCtruthEventHandler()) return;
140
141 AliESDEvent *event=fTender->GetEvent();
142 if (!event) return;
143
144 //recalculate TOF signal
145 if (fTender->RunChanged()){
146 fTOFCalib->Init(fTender->GetRun());
147
148 if(event->GetT0TOF()){ // read T0 detector correction from OCDB
149 // OCDB instance
150 AliCDBManager* ocdbMan = AliCDBManager::Instance();
151 ocdbMan->SetRun(fTender->GetRun());
152 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
153 if(entry) {
154 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
155 Float_t *t0means= clb->GetT0Means();
156 // Float_t *t0sigmas = clb->GetT0Sigmas();
157 fT0shift[0] = t0means[0];
158 fT0shift[1] = t0means[1];
159 fT0shift[2] = t0means[2];
160 fT0shift[3] = t0means[3];
161 }
162 }
163 }
164 fTOFCalib->CalibrateESD(event);
88ccd4cf 165
166 if (fLHC10dPatch) RecomputeTExp(event);
167
ee981ab3 168 if(fIsMC){
169 Float_t t0true = fTOFT0maker->TuneForMC(event);
170
171 if(event->GetT0TOF()){// add the t0 smearing also to the T0 detector information
172 event->SetT0TOF(0,event->GetT0TOF(0) + t0true);
173 event->SetT0TOF(1,event->GetT0TOF(1) + t0true);
174 event->SetT0TOF(2,event->GetT0TOF(2) + t0true);
175 }
176 }
177
178 if(event->GetT0TOF()){ // write the T0 detector corrected times
179 if(event->GetT0TOF(0) == 0) event->SetT0TOF(0, 9999999.);
180 if(event->GetT0TOF(1) == 0) event->SetT0TOF(1, 99999.);
181 if(event->GetT0TOF(2) == 0) event->SetT0TOF(2, 99999.);
182
183 event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]);
184 event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]);
185 event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]);
186
187 if(event->GetT0TOF(0) > 9000000) event->SetT0TOF(0, 9999999.);
188 if(event->GetT0TOF(1) > 90000) event->SetT0TOF(1, 99999.);
189 if(event->GetT0TOF(2) > 90000) event->SetT0TOF(2, 99999.);
190 }
191
192 //Calculate event time zero
193 fTOFT0maker->ComputeT0TOF(event);
194 fTOFT0maker->WriteInESD(event);
195
196 // subtract the T0-TOF information to the TOF times
197 if(fApplyT0){
198 fTOFT0maker->ApplyT0TOF(event);
199 event->SetT0(0.0);
200 }
201
202 //
203 // recalculate PID probabilities
204 //
205
206 fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTimeZeroType);
207
208 Int_t ntracks=event->GetNumberOfTracks();
209 for(Int_t itrack = 0; itrack < ntracks; itrack++){
210 fESDpid->MakeTOFPID(event->GetTrack(itrack),0);
211 }
212
213
214}
215
216
88ccd4cf 217//_____________________________________________________
218void AliTOFTenderSupply::RecomputeTExp(AliESDEvent *event) const
219{
220 /*
221 * calibrate TExp
222 */
223
224
225 /* loop over tracks */
226 AliESDtrack *track = NULL;
227 for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
228 /* get track and calibrate */
229 track = event->GetTrack(itrk);
230 RecomputeTExp(track);
231 }
232
233}
234
235//_____________________________________________________
236void AliTOFTenderSupply::RecomputeTExp(AliESDtrack *track) const
237{
238 /***
239 THIS METHOD IS BASED ON THEORETICAL EXPECTED TIME COMPUTED
240 USING AVERAGE MOMENTUM BETWEEN INNER/OUTER TRACK PARAMS
241 IT IS A ROUGH APPROXIMATION APPLIED TO FIX LHC10d-pass2 DATA
242 WHERE A WRONG GEOMETRY (FULL TRD) WAS INSERTED
243 ***/
244
245 Double_t texp[AliPID::kSPECIES];
246 if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) return;
ee981ab3 247
88ccd4cf 248
249 /* get track params */
250 Float_t l = track->GetIntegratedLength();
251 Float_t p = track->P();
252 if (track->GetInnerParam() && track->GetOuterParam()) {
253 Float_t pin = track->GetInnerParam()->P();
254 Float_t pout = track->GetOuterParam()->P();
255 p = 0.5 * (pin + pout);
256 }
257 /* loop over particle types and compute expected time */
258 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
259 texp[ipart] = GetExpTimeTh(AliPID::ParticleMass(ipart), p, l) - 37.;
260 // 37 is a final semiempirical offset to further adjust (calibrations were
261 // done with "standard" integratedTimes)
262 /* set integrated times */
263 track->SetIntegratedTimes(texp);
264
265}