1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
20 // load updated calibration if needed
21 // reapply TOF pid on the fly //
23 ///////////////////////////////////////////////////////////////////////////////
25 #include <AliESDEvent.h>
26 #include <AliESDtrack.h>
27 #include <AliESDInputHandler.h>
28 #include <AliAnalysisManager.h>
29 #include <AliESDpid.h>
30 #include <AliTender.h>
32 #include <AliTOFcalib.h>
33 #include <AliTOFT0maker.h>
35 #include <AliCDBManager.h>
36 #include <AliCDBEntry.h>
37 #include <AliT0CalibSeasonTimeShift.h>
39 #include "AliTOFTenderSupply.h"
41 AliTOFTenderSupply::AliTOFTenderSupply() :
47 fCorrectExpTimes(kTRUE),
65 //_____________________________________________________
66 AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) :
67 AliTenderSupply(name,tender),
72 fCorrectExpTimes(kTRUE),
89 //_____________________________________________________
90 void AliTOFTenderSupply::Init()
93 // Initialise TOF tender
95 Printf("|******************************************************|");
96 Printf("| Alice TOF Tender Initialisation |");
104 // Check if another detector already created the esd pid object
105 // if not we create it and set it to the ESD input handler
106 fESDpid=fTender->GetESDhandler()->GetESDpid();
108 fESDpid=new AliESDpid;
109 fTender->GetESDhandler()->SetESDpid(fESDpid);
112 //Set proper resolution in case of MC
113 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
114 if (mgr->GetMCtruthEventHandler()) fIsMC=kTRUE;
118 // Create TOF calibration classes
121 fTOFCalib=new AliTOFcalib();
122 fTOFCalib->SetRemoveMeanT0(!(fIsMC)); // must be kFALSE on MC (default is kTRUE)
123 fTOFCalib->SetCalibrateTOFsignal(!(fIsMC)); // must be kFALSE on MC (no new calibration) (default is kTRUE)
124 fTOFCalib->SetCorrectTExp(fCorrectExpTimes); // apply a fine tuning on the expected times at low momenta
125 // fTOFCalib->Init();
128 fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib);
129 fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID
131 Printf("| Settings: |");
132 Printf("| Correct Exp Times : %d |",fCorrectExpTimes);
133 Printf("| LHC10d patch : %d |",fLHC10dPatch);
134 Printf("| TOF resolution for TOFT0 maker : %5.2f (ps) |",fTOFres);
135 Printf("| timeZero selection : %d |",fTimeZeroType);
136 Printf("|******************************************************|");
141 //_____________________________________________________
142 void AliTOFTenderSupply::ProcessEvent()
145 // Reapply pid information
148 //no corrections for MC
149 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
150 if (mgr->GetMCtruthEventHandler()) return;
152 AliESDEvent *event=fTender->GetEvent();
155 // Printf("AliTOFTenderSupply: process event\n");
157 //recalculate TOF signal
158 if (fTender->RunChanged()){
159 Printf("AliTOFTenderSupply: INIT at run %d\n",fTender->GetRun());
160 fTOFCalib->Init(fTender->GetRun());
162 if(event->GetT0TOF()){ // read T0 detector correction from OCDB
164 AliCDBManager* ocdbMan = AliCDBManager::Instance();
165 ocdbMan->SetRun(fTender->GetRun());
166 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
168 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
169 Float_t *t0means= clb->GetT0Means();
170 // Float_t *t0sigmas = clb->GetT0Sigmas();
171 fT0shift[0] = t0means[0];
172 fT0shift[1] = t0means[1];
173 fT0shift[2] = t0means[2];
174 fT0shift[3] = t0means[3];
178 fTOFCalib->CalibrateESD(event);
180 if (fLHC10dPatch) RecomputeTExp(event);
183 Float_t t0true = fTOFT0maker->TuneForMC(event);
185 if(event->GetT0TOF()){// add the t0 smearing also to the T0 detector information
186 event->SetT0TOF(0,event->GetT0TOF(0) + t0true);
187 event->SetT0TOF(1,event->GetT0TOF(1) + t0true);
188 event->SetT0TOF(2,event->GetT0TOF(2) + t0true);
192 if(event->GetT0TOF()){ // write the T0 detector corrected times
193 if(event->GetT0TOF(0) == 0) event->SetT0TOF(0, 9999999.);
194 if(event->GetT0TOF(1) == 0) event->SetT0TOF(1, 99999.);
195 if(event->GetT0TOF(2) == 0) event->SetT0TOF(2, 99999.);
198 event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]);
199 event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]);
200 event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]);
202 if(event->GetT0TOF(0) > 9000000) event->SetT0TOF(0, 9999999.);
203 if(event->GetT0TOF(1) > 90000) event->SetT0TOF(1, 99999.);
204 if(event->GetT0TOF(2) > 90000) event->SetT0TOF(2, 99999.);
208 //Calculate event time zero
209 fTOFT0maker->ComputeT0TOF(event);
210 fTOFT0maker->WriteInESD(event);
212 // subtract the T0-TOF information to the TOF times
214 fTOFT0maker->ApplyT0TOF(event);
219 // recalculate PID probabilities
222 fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTimeZeroType);
224 Int_t ntracks=event->GetNumberOfTracks();
225 for(Int_t itrack = 0; itrack < ntracks; itrack++){
226 fESDpid->MakeTOFPID(event->GetTrack(itrack),0);
233 //_____________________________________________________
234 void AliTOFTenderSupply::RecomputeTExp(AliESDEvent *event) const
241 /* loop over tracks */
242 AliESDtrack *track = NULL;
243 for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
244 /* get track and calibrate */
245 track = event->GetTrack(itrk);
246 RecomputeTExp(track);
251 //_____________________________________________________
252 void AliTOFTenderSupply::RecomputeTExp(AliESDtrack *track) const
255 THIS METHOD IS BASED ON THEORETICAL EXPECTED TIME COMPUTED
256 USING AVERAGE MOMENTUM BETWEEN INNER/OUTER TRACK PARAMS
257 IT IS A ROUGH APPROXIMATION APPLIED TO FIX LHC10d-pass2 DATA
258 WHERE A WRONG GEOMETRY (FULL TRD) WAS INSERTED
261 Double_t texp[AliPID::kSPECIES];
262 if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) return;
265 /* get track params */
266 Float_t l = track->GetIntegratedLength();
267 Float_t p = track->P();
268 if (track->GetInnerParam() && track->GetOuterParam()) {
269 Float_t pin = track->GetInnerParam()->P();
270 Float_t pout = track->GetOuterParam()->P();
271 p = 0.5 * (pin + pout);
273 /* loop over particle types and compute expected time */
274 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
275 texp[ipart] = GetExpTimeTh(AliPID::ParticleMass(ipart), p, l) - 37.;
276 // 37 is a final semiempirical offset to further adjust (calibrations were
277 // done with "standard" integratedTimes)
278 /* set integrated times */
279 track->SetIntegratedTimes(texp);