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 ///////////////////////////////////////////////////////////////////////////////
19 // TOF tender: - load updated calibrations (for TOF and T0)
20 // - set tofHeader if missing in ESDs (2010 data)
23 // Contacts: Pietro.Antonioli@bo.infn.it //
24 // Francesco.Noferini@bo.infn.it //
25 ///////////////////////////////////////////////////////////////////////////////
32 #include <AliESDEvent.h>
33 #include <AliESDtrack.h>
34 #include <AliESDInputHandler.h>
35 #include <AliAnalysisManager.h>
36 #include <AliESDpid.h>
37 #include <AliTender.h>
39 #include <AliTOFcalib.h>
40 #include <AliTOFT0maker.h>
42 #include <AliGeomManager.h>
43 #include <AliCDBManager.h>
44 #include <AliCDBEntry.h>
45 #include <AliT0CalibSeasonTimeShift.h>
47 #include "AliTOFTenderSupply.h"
49 ClassImp(AliTOFTenderSupply)
51 Float_t AliTOFTenderSupply::fgT0Aresolution = 75.;
52 Float_t AliTOFTenderSupply::fgT0Cresolution = 65.;
54 AliTOFTenderSupply::AliTOFTenderSupply() :
58 fTimeZeroType(AliESDpid::kBest_T0),
59 fCorrectExpTimes(kTRUE),
60 fCorrectTRDBug(kFALSE),
62 fT0DetectorAdjust(kFALSE),
64 fAutomaticSettings(kTRUE),
70 fT0IntercalibrationShift(0),
72 fIsEnteringInTRD(kFALSE),
74 fIsComingOutTRD(kFALSE),
76 fRhoTRDin(288.38), // cm
77 fRhoTRDout(366.38), // cm
94 //_____________________________________________________
95 AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) :
96 AliTenderSupply(name,tender),
99 fTimeZeroType(AliESDpid::kBest_T0),
100 fCorrectExpTimes(kTRUE),
101 fCorrectTRDBug(kFALSE),
102 fLHC10dPatch(kFALSE),
103 fT0DetectorAdjust(kFALSE),
105 fAutomaticSettings(kTRUE),
111 fT0IntercalibrationShift(0),
113 fIsEnteringInTRD(kFALSE),
115 fIsComingOutTRD(kFALSE),
117 fRhoTRDin(288.38), // cm
118 fRhoTRDout(366.38), // cm
134 //_____________________________________________________
135 void AliTOFTenderSupply::Init()
138 Bool_t tenderUnsupported = kFALSE;
139 // Initialise TOF tender (this is called at each detected run change)
140 AliLog::SetClassDebugLevel("AliTOFTenderSupply",10);
142 // Setup PID object, check for MC, set AliTOFcalib and TOFT0 maker conf
143 Int_t run = fTender->GetRun();
144 if (run == 0) return; // to skip first init, when we don't have yet a run number
147 // Even if the user didn't set fIsMC, we force it on if we find the MC handler
148 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
149 if (mgr->GetMCtruthEventHandler() && !(fIsMC) ) {
150 AliWarning("This ESD is MC, fIsMC found OFF: fIsMC turned ON");
154 if (fAutomaticSettings) {
156 if (fUserRecoPass == 0) DetectRecoPass();
157 else fRecoPass = fUserRecoPass;
160 tenderUnsupported = kTRUE;
162 else if (run>=114737&&run<=117223) { //period="LHC10B";
163 if (fRecoPass == 2) {fCorrectExpTimes=kTRUE; fCorrectTRDBug=kFALSE;}
164 else if (fRecoPass == 3) {fCorrectExpTimes=kFALSE; fCorrectTRDBug=kTRUE;}
167 fTimeZeroType=AliESDpid::kTOF_T0;
168 fT0IntercalibrationShift = 0;
169 fT0DetectorAdjust=kTRUE;
171 else if (run>=118503&&run<=121040) { //period="LHC10C";
172 if (fRecoPass == 2) {fCorrectExpTimes=kTRUE; fCorrectTRDBug=kFALSE;}
173 else if (fRecoPass == 3) {fCorrectExpTimes=kFALSE; fCorrectTRDBug=kTRUE;}
176 fTimeZeroType=AliESDpid::kTOF_T0;
177 fT0IntercalibrationShift = 0;
178 fT0DetectorAdjust=kFALSE;
180 else if (run>=122195&&run<=126437) { //period="LHC10D";
181 fCorrectExpTimes=kFALSE;
184 fTimeZeroType=AliESDpid::kBest_T0;
185 fT0IntercalibrationShift = 0;
186 fT0DetectorAdjust=kTRUE;
188 else if (run>=127719&&run<=130850) { //period="LHC10E";
189 fCorrectExpTimes=kFALSE;
192 fTimeZeroType=AliESDpid::kBest_T0;
193 fT0IntercalibrationShift = 30.;
194 fT0DetectorAdjust=kTRUE;
196 else if (run>=133004&&run<=135029) { //period="LHC10F";
197 fCorrectExpTimes=kFALSE;
200 fTimeZeroType=AliESDpid::kBest_T0;
201 fT0IntercalibrationShift = 0.;
202 fT0DetectorAdjust=kTRUE;
203 AliWarning("TOF tender not supported for LHC10F period!! Settings are just a guess!!");
205 else if (run>=135654&&run<=136377) { //period="LHC10G";
206 fCorrectExpTimes=kFALSE;
209 fTimeZeroType=AliESDpid::kBest_T0;
210 fT0IntercalibrationShift = 0.;
211 fT0DetectorAdjust=kTRUE;
212 AliWarning("TOF tender not supported for LHC10G period!! Settings are just a guess!!");
214 else if (run>=136851&&run<=139517) { //period="LHC10H" - pass2;
215 fCorrectExpTimes=kFALSE;
218 fTimeZeroType=AliESDpid::kTOF_T0;
219 fT0IntercalibrationShift = 0.;
220 fT0DetectorAdjust=kTRUE;
222 else if (run>=139699) { //period="LHC11A";
224 fCorrectExpTimes=kFALSE;
227 fTimeZeroType=AliESDpid::kBest_T0;
228 fT0IntercalibrationShift = 0.;
229 fT0DetectorAdjust=kFALSE;
230 AliWarning("TOF tender not supported for LHC11A period!! Settings are just a guess!!");
232 AliError("TOF tender not supported for 2011 data!!!!!");
233 tenderUnsupported = kTRUE;
237 if (tenderUnsupported) {
238 AliInfo(" |---------------------------------------------------------------------------|");
240 AliInfo(Form(" | TOF tender is not supported for run %d |",run));
241 AliInfo(" | You cannot use TOF tender for this run, your results can be spoiled |");
242 AliInfo(" | Check TOF tender usage for run/periods at: |");
243 AliInfo(" | https://twiki.cern.ch/twiki/bin/view/ALICE/TOF. |");
244 AliInfo(" |---------------------------------------------------------------------------|");
246 AliFatal(" ------- TOF tender not to be used in this run, issuing FATAL error -------- ");
249 // Check if another tender wagon already created the esd pid object
250 // if not we create it and set it to the ESD input handler
251 fESDpid=fTender->GetESDhandler()->GetESDpid();
253 fESDpid=new AliESDpid;
254 fTender->GetESDhandler()->SetESDpid(fESDpid);
258 // Configure TOF calibration class
259 if (!fTOFCalib)fTOFCalib=new AliTOFcalib(); // create if needed
260 fTOFCalib->SetRemoveMeanT0(!(fIsMC)); // must be kFALSE on MC (default is kTRUE)
261 fTOFCalib->SetCalibrateTOFsignal(!(fIsMC)); // must be kFALSE on MC (no new calibration) (default is kTRUE)
262 fTOFCalib->SetCorrectTExp(fCorrectExpTimes); // apply a fine tuning on the expected times at low momenta
263 // (this is done for LHC10b/LHC10c pass2)
265 // Configure TOFT0 maker class
266 // if (!fTOFT0maker) fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib); // create if needed
267 if (!fTOFT0maker) fTOFT0maker = new AliTOFT0maker(fESDpid); // without passing AliTOFCalib it uses the diamond
268 fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID
269 fTOFT0maker->SetTOFT0algorithm(2);
271 AliInfo("|******************************************************|");
272 AliInfo(Form("| Alice TOF Tender Initialisation (Run %d) |",fTender->GetRun()));
273 AliInfo("| Settings: |");
274 AliInfo(Form("| Correct Exp Times : %d |",fCorrectExpTimes));
275 AliInfo(Form("| Correct TRD Bug : %d |",fCorrectTRDBug));
276 AliInfo(Form("| LHC10d patch : %d |",fLHC10dPatch));
277 AliInfo(Form("| TOF resolution for TOFT0 maker : %5.2f (ps) |",fTOFres));
278 AliInfo(Form("| timeZero selection : %d |",fTimeZeroType));
279 AliInfo(Form("| MC flag : %d |",fIsMC));
280 AliInfo(Form("| T0 detector offsets applied : %d |",fT0DetectorAdjust));
281 AliInfo(Form("| TOF/T0 intecalibration shift : %5.2f (ps) |",fT0IntercalibrationShift));
282 AliInfo("|******************************************************|");
287 //_____________________________________________________
288 void AliTOFTenderSupply::ProcessEvent()
291 // Use updated calibrations for TOF and T0, reapply PID information
292 // For MC: timeZero sampling and additional smearing for T0
294 if (fDebugLevel > 1) AliInfo("process event");
296 AliESDEvent *event=fTender->GetEvent();
298 if (fDebugLevel > 1) AliInfo("event read");
302 if (fTender->RunChanged()){
305 Int_t versionNumber = GetOCDBVersion(fTender->GetRun());
306 fTOFCalib->SetRunParamsSpecificVersion(versionNumber);
307 fTOFCalib->Init(fTender->GetRun());
309 if(event->GetT0TOF()){ // read T0 detector correction from OCDB
311 if (fT0DetectorAdjust) {
312 AliCDBManager* ocdbMan = AliCDBManager::Instance();
313 ocdbMan->SetRun(fTender->GetRun());
314 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
316 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
317 Float_t *t0means= clb->GetT0Means();
318 // Float_t *t0sigmas = clb->GetT0Sigmas();
319 fT0shift[0] = t0means[0] + fT0IntercalibrationShift;
320 fT0shift[1] = t0means[1] + fT0IntercalibrationShift;
321 fT0shift[2] = t0means[2] + fT0IntercalibrationShift;
322 fT0shift[3] = t0means[3] + fT0IntercalibrationShift;
324 for (Int_t i=0;i<4;i++) fT0shift[i]=0;
325 AliWarning("TofTender no T0 entry found T0shift set to 0");
328 for (Int_t i=0;i<4;i++) fT0shift[i]=0;
334 fTOFCalib->CalibrateESD(event); //recalculate TOF signal (no harm for MC, see settings inside init)
337 // patches for various reconstruction bugs
338 if (fLHC10dPatch && !(fIsMC)) RecomputeTExp(event); // LHC10d pass2: fake full TRD geometry
339 if (fCorrectTRDBug && !(fIsMC)) FixTRDBug(event); // LHC10b,c pass3: wrong TRD dE/dx
341 Double_t startTime = 0.;
342 if(fIsMC) startTime = fTOFCalib->TuneForMC(event,fTOFres); // this is for old MC when we didn't jitter startTime in MC
344 if (fDebugLevel > 1) Printf(" TofTender: startTime %f",startTime);
345 if (fDebugLevel > 1) Printf(" TofTender: T0 time (orig) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
347 // event by event TO detector treatment
348 if(event->GetT0TOF()){ // protection: we adjust T0 only if it is there....
350 if (event->GetT0TOF(0) == 0) event->SetT0TOF(0, 9999999.); // in case no information we set to unknown
351 if (event->GetT0TOF(1) == 0) event->SetT0TOF(1, 99999.);
352 if (event->GetT0TOF(2) == 0) event->SetT0TOF(2, 99999.);
354 if(!fIsMC){ // data: apply shifts to align around Zero
355 event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]);
356 event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]);
357 event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]);
359 // MC: add smearing for realistic T0A and T0C resolution
360 Double_t defResolutionT0A = 33.; // in future we will get this from ESDrun data structure or via OCDB
361 Double_t defResolutionT0C = 30.; // for the moment we don't trust them
362 if ( (fgT0Aresolution > defResolutionT0A) && (event->GetT0TOF(1)<90000.) ) { // add smearing only if signal is there
363 Double_t addedSmearingT0A = TMath::Sqrt(fgT0Aresolution*fgT0Aresolution - defResolutionT0A*defResolutionT0A);
364 Double_t smearingT0A = gRandom->Gaus(0.,addedSmearingT0A);
365 event->SetT0TOF(1,event->GetT0TOF(1) + smearingT0A);
367 if ( (fgT0Cresolution > defResolutionT0C) && (event->GetT0TOF(2)<90000.) ) { // add smearing only if signal is there
368 Double_t addedSmearingT0C = TMath::Sqrt(fgT0Cresolution*fgT0Cresolution - defResolutionT0C*defResolutionT0C);
369 Double_t smearingT0C = gRandom->Gaus(0.,addedSmearingT0C);
370 event->SetT0TOF(2,event->GetT0TOF(2) + smearingT0C);
372 if (event->GetT0TOF(0)<90000.) { // we recompute the AND only if it is already there...
373 Double_t smearedT0AC = (event->GetT0TOF(1)+event->GetT0TOF(2))/2.;
374 event->SetT0TOF(0,smearedT0AC);
376 if (fDebugLevel > 1) Printf(" TofTender: T0 time (postSmear) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
377 // add finally the timeZero offset also to the T0 detector information
378 event->SetT0TOF(0,event->GetT0TOF(0) + startTime);
379 event->SetT0TOF(1,event->GetT0TOF(1) + startTime);
380 event->SetT0TOF(2,event->GetT0TOF(2) + startTime);
381 if (fDebugLevel > 1) Printf(" TofTender: T0 time (postStart) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
383 // after shifts adjust (data) or smearing+offset (MC) we 'clean' to default if signals not there
384 if(event->GetT0TOF(0) > 900000) event->SetT0TOF(0, 999999.);
385 if(event->GetT0TOF(1) > 90000) event->SetT0TOF(1, 99999.);
386 if(event->GetT0TOF(2) > 90000) event->SetT0TOF(2, 99999.);
388 if (fDebugLevel > 1) Printf(" TofTender: T0 time (FINAL) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
390 //compute timeZero of the event via TOF-TO
391 fTOFT0maker->ComputeT0TOF(event);
392 fTOFT0maker->WriteInESD(event);
394 //set preferred startTime
395 fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTimeZeroType);
397 // recalculate PID probabilities
398 // this is for safety, especially if the user doesn't attach a PID tender after TOF tender
399 Int_t ntracks=event->GetNumberOfTracks();
400 // AliESDtrack *track = NULL;
401 // Float_t tzeroTrack = 0;
402 for(Int_t itrack = 0; itrack < ntracks; itrack++){
403 // track = event->GetTrack(itrack);
404 // tzeroTrack = fESDpid->GetTOFResponse().GetStartTime(track->P());
405 // Printf("================> Track # %d mom: %f tzeroTrack %f",itrack,track->P(),tzeroTrack);
406 fESDpid->MakeTOFPID(event->GetTrack(itrack),0);
413 //_____________________________________________________
414 void AliTOFTenderSupply::RecomputeTExp(AliESDEvent *event) const
421 /* loop over tracks */
422 AliESDtrack *track = NULL;
423 for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
424 /* get track and calibrate */
425 track = event->GetTrack(itrk);
426 RecomputeTExp(track);
431 //_____________________________________________________
432 void AliTOFTenderSupply::RecomputeTExp(AliESDtrack *track) const
435 THIS METHOD IS BASED ON THEORETICAL EXPECTED TIME COMPUTED
436 USING AVERAGE MOMENTUM BETWEEN INNER/OUTER TRACK PARAMS
437 IT IS A ROUGH APPROXIMATION APPLIED TO FIX LHC10d-pass2 DATA
438 WHERE A WRONG GEOMETRY (FULL TRD) WAS INSERTED
441 Double_t texp[AliPID::kSPECIES];
442 if (!track || !(track->GetStatus() & AliESDtrack::kTOFout)) return;
445 /* get track params */
446 Float_t l = track->GetIntegratedLength();
447 Float_t p = track->P();
448 if (track->GetInnerParam() && track->GetOuterParam()) {
449 Float_t pin = track->GetInnerParam()->P();
450 Float_t pout = track->GetOuterParam()->P();
451 p = 0.5 * (pin + pout);
453 /* loop over particle types and compute expected time */
454 for (Int_t ipart = 0; ipart < AliPID::kSPECIES; ipart++)
455 texp[ipart] = GetExpTimeTh(AliPID::ParticleMass(ipart), p, l) - 37.;
456 // 37 is a final semiempirical offset to further adjust (calibrations were
457 // done with "standard" integratedTimes)
458 /* set integrated times */
459 track->SetIntegratedTimes(texp);
464 //______________________________________________________________________________
465 void AliTOFTenderSupply::DetectRecoPass()
468 // Detect reconstruction information
474 //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... )
475 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
476 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
477 if (!inputHandler) return;
479 TTree *tree= (TTree*)inputHandler->GetTree();
480 TFile *file= (TFile*)tree->GetCurrentFile();
483 AliFatal("Current file not found");
487 //find pass from file name (UGLY, but not stored in ESD... )
488 TString fileName(file->GetName());
489 if (fileName.Contains("pass1") ) {
491 } else if (fileName.Contains("pass2") ) {
493 } else if (fileName.Contains("pass3") ) {
496 if (fRecoPass == 0) {
497 AliInfo(Form("From file name %s reco pass cannot be detected",fileName.Data()));
498 AliInfo("Change file name or use SetUserRecoPass method");
499 AliFatal("------------- TOF tender cannot run with reco pass unspecified, issuing FATAL error ---------- ");
504 //______________________________________________________________________________
505 void AliTOFTenderSupply::InitGeom()
508 if (fGeomSet == kTRUE) return;
510 // Printf("\n \n ----- calling InitGeom to fix TRD Bug ----- \n \n");
511 AliCDBManager * man = AliCDBManager::Instance();
512 man->SetDefaultStorage("raw://");
513 fCDBkey = man->SetLock(kFALSE, fCDBkey);
514 Int_t run = fTender->GetRun();
515 // Printf(" ---------> run is %d",run);
517 AliCDBEntry *entry = (AliCDBEntry*)man->Get("GRP/Geometry/Data");
519 AliGeomManager::LoadGeometry();
520 AliGeomManager::ApplyAlignObjsFromCDB("ITS TPC TRD TOF");
521 // fCDBkey = man->SetLock(kTRUE, fCDBkey);
522 // Printf("\n \n ----- Geometry loaded ------ \n \n");
529 //______________________________________________________________________________
530 void AliTOFTenderSupply::FixTRDBug(AliESDEvent* event)
532 // recompute texp fixing wrong dE/dx from TRD (LHC10b,c pass3)
536 if (fGeomSet == kFALSE) InitGeom();
538 // Printf("Running FixTRD bug ");
539 /* loop over tracks */
540 AliESDtrack *track = NULL;
541 for (Int_t itrk = 0; itrk < event->GetNumberOfTracks(); itrk++) {
542 track = event->GetTrack(itrk);
548 //_____________________________________________________
549 void AliTOFTenderSupply::FixTRDBug(AliESDtrack *track)
556 ULong_t status=track->GetStatus();
557 if (!( ( (status & AliVTrack::kITSrefit)==AliVTrack::kITSrefit ) &&
558 ( (status & AliVTrack::kTPCrefit)==AliVTrack::kTPCrefit ) &&
559 ( (status & AliVTrack::kTPCout)==AliVTrack::kTPCout ) &&
560 ( (status & AliVTrack::kTOFout)==AliVTrack::kTOFout ) &&
561 ( (status & AliVTrack::kTIME)==AliVTrack::kTIME ) ) ) return;
563 fIsEnteringInTRD=kFALSE;
565 fIsComingOutTRD=kFALSE;
568 // Printf("Track reached TOF %f",track->P());
569 Double_t correctionTimes[5] = {0.,0.,0.,0.,0.}; // to be added to the expected times
570 FindTRDFix(track, correctionTimes);
571 Double_t expectedTimes[5] = {0.,0.,0.,0.,0.}; track->GetIntegratedTimes(expectedTimes);
572 // Printf("Exp. times: %f %f %f %f %f",
573 // expectedTimes[0],expectedTimes[1],expectedTimes[2],expectedTimes[3],expectedTimes[4]);
574 // Printf("Corr. times: %f %f %f %f %f",
575 // correctionTimes[0],correctionTimes[1],correctionTimes[2],correctionTimes[3],correctionTimes[4]);
577 for (Int_t jj=0; jj<5; jj++) expectedTimes[jj]+=correctionTimes[jj];
578 track->SetIntegratedTimes(expectedTimes);
583 //________________________________________________________________________
584 void AliTOFTenderSupply::FindTRDFix(AliESDtrack *track,Double_t *corrections)
587 Double_t pT = track->Pt();
588 ULong_t status=track->GetStatus();
589 Bool_t isTRDout = (status & AliVTrack::kTRDout)==AliVTrack::kTRDout;
591 Double_t length = 0.;
593 Double_t xyzIN[3]={0.,0.,0.};
594 fIsEnteringInTRD = track->GetXYZAt(fRhoTRDin,fMagField,xyzIN);
596 Double_t xyzOUT[3]={0.,0.,0.};
597 fIsComingOutTRD = track->GetXYZAt(fRhoTRDout,fMagField,xyzOUT);
599 if (fIsEnteringInTRD && fIsComingOutTRD) {
602 Double_t phiIN = TMath::Pi()+TMath::ATan2(-xyzIN[1],-xyzIN[0]);
603 phiIN *= TMath::RadToDeg();
604 fInTRD = ( (phiIN>= 0. && phiIN<= 40.) ||
605 (phiIN>=140. && phiIN<=220.) ||
606 (phiIN>=340. && phiIN<=360.) ); // TRD SMs installed @ 2010
608 Double_t phiOUT = TMath::Pi()+TMath::ATan2(-xyzOUT[1],-xyzOUT[0]);
609 phiOUT *= TMath::RadToDeg();
610 fOutTRD = ( (phiOUT>= 0. && phiOUT<= 40.) ||
611 (phiOUT>=140. && phiOUT<=220.) ||
612 (phiOUT>=340. && phiOUT<=360.) ); // TRD SMs installed @ 2010
616 if (fInTRD || fOutTRD) {
618 if ( ( fInTRD && fOutTRD ) || ( fInTRD && !fOutTRD ) ) {
619 length = EstimateLengthInTRD1(track);
620 } else if ( !fInTRD && fOutTRD ) {
621 length = EstimateLengthInTRD2(track);
624 } else { // ( !fInTRD && !fOutTRD )
626 length = EstimateLengthOutTRD(track);
631 // Printf("estimated length in TRD %f [isTRDout %d]",length,isTRDout);
632 CorrectDeltaTimes(pT,length,isTRDout,corrections);
636 //________________________________________________________________________
637 void AliTOFTenderSupply::CorrectDeltaTimes(Double_t pT,
640 Double_t *corrections)
643 corrections[2] = CorrectExpectedPionTime(pT,length,flagTRDout);
644 corrections[0] = corrections[2]; // x electrons used pion corrections
645 corrections[1] = corrections[2]; // x muons used pion corrections
646 corrections[3] = CorrectExpectedKaonTime(pT,length,flagTRDout);
647 corrections[4] = CorrectExpectedProtonTime(pT,length,flagTRDout);
651 //________________________________________________________________________
652 Double_t AliTOFTenderSupply::CorrectExpectedPionTime(Double_t pT,
656 // correction for expected time for pions
660 // Printf("Flags Ent In ComingOut Out %d %d %d %d",fIsEnteringInTRD,fInTRD,fIsComingOutTRD,fOutTRD);
661 if (!fIsEnteringInTRD || !fIsComingOutTRD) { // zone 5
663 Float_t p[2]={0.,0.};
668 p[0] = 180.; p[1] = 0.;
669 } else if (pT>=0.30 && pT<0.35) {
670 p[0] = 740.; p[1] = -1800.;
671 } else if (pT>=0.35 && pT<0.40) {
672 p[0] = 488.; p[1] =-1080.;
673 } else if (pT>=0.40 && pT<0.45) {
674 p[0] = 179.; p[1] = -307.;
675 } else if (pT>=0.45 && pT<0.50) {
676 p[0] = 97.; p[1] = -123.;
677 } else { //if (pT>=0.50)
678 p[0] = 120.; p[1] = -172.;
684 p[0] = 70.; p[1] = 0.;
685 } else if (pT>=0.30 && pT<0.35) {
686 p[0] = 339.; p[1] = -927.;
687 } else if (pT>=0.35 && pT<0.40) {
688 p[0] = 59.; p[1] = -121.;
689 } else if (pT>=0.40 && pT<0.50) {
690 p[0] = 21.; p[1] = -24.;
691 } else { //if (pT>=0.50)
692 p[0] = 42.; p[1] = -67.;
697 delta = p[0]+p[1]*pT;
698 // Printf("Pion time: %f %f %f %f",p[0],p[1],length,delta);
702 Float_t p[2] = {0.,0.};
704 if ( fInTRD && fOutTRD) { // zone 1
709 p[0] = 0.; p[1] = 0.;
710 } else if (length>=130. && length<170.) {
711 p[0] = -20.5; p[1] = 0.25;
712 } else {//if (length>=170.)
713 p[0] = 22.; p[1] = 0.;
716 } else { // !isTRDout
718 p[0] = 20.; p[1] = 0.;
722 } else if (!fInTRD && !fOutTRD) { // zone 2
724 p[0] = 0.; p[1] = 0.;
726 } else if ( fInTRD && !fOutTRD) { // zone 3
731 p[0] = 17.; p[1] = 0.;
732 } else if (length>= 75. && length< 95.) {
733 p[0] = 81.; p[1] = -0.85;
734 } else if (length>= 95. && length<155.) {
735 p[0] = 0.; p[1] = 0.;
736 } else {//if (length>=155.)
737 p[0] = 10.; p[1] = 0.;
740 } else { // !isTRDout
742 p[0] = 0.; p[1] = 0.;
746 } else if (!fInTRD && fOutTRD) { // zone 4
751 p[0] = 0.; p[1] = 0.;
752 } else {//if (length>=80.)
753 p[0] = 10.; p[1] = 0.;
756 } else { // !isTRDout
759 p[0] = 0.; p[1] = 0.;
760 } else {//if (length>=30.)
761 p[0] = 6.; p[1] = 0.;
768 delta = p[0]+p[1]*length;
769 // Printf("Pion time: %f %f %f %f",p[0],p[1],length,delta);
777 //________________________________________________________________________
778 Double_t AliTOFTenderSupply::CorrectExpectedKaonTime(Double_t pT,
782 // correction for expected time for kaons
785 // Printf("Flags Ent In ComingOut Out %d %d %d %d",fIsEnteringInTRD,fInTRD,fIsComingOutTRD,fOutTRD);
787 if (!fIsEnteringInTRD || !fIsComingOutTRD) { // zone 5
789 Float_t p[2]={0.,0.};
794 p[0] = 900.; p[1] = 0.;
795 } else if (pT>=0.40 && pT<0.45) {
796 p[0] = 3100.; p[1] = -6000.;
797 } else if (pT>=0.45 && pT<0.50) {
798 p[0] = 1660.; p[1] = -2800.;
799 } else if (pT>=0.50 && pT<0.55) {
800 p[0] = 860.; p[1] = -1200.;
801 } else { //if (pT>=0.55)
802 p[0] = 200.; p[1] = 0.;
808 p[0] = 0.; p[1] = 0.;
809 } else if (pT>=0.30 && pT<0.32) {
810 p[0] = 570.; p[1] = 0.;
811 } else if (pT>=0.32 && pT<0.35) {
812 p[0] = 3171.; p[1] = -8133.;
813 } else if (pT>=0.35 && pT<0.40) {
814 p[0] = 1815.; p[1] = -4260.;
815 } else if (pT>=0.40 && pT<0.45) {
816 p[0] = 715.; p[1] = -1471.;
817 } else if (pT>=0.45 && pT<0.50) {
818 p[0] = 233.; p[1] = -407.;
819 } else if (pT>=0.50 && pT<0.55) {
820 p[0] = 408.; p[1] = -752.;
821 } else { //if (pT>=0.55)
822 p[0] = 408.-752.*0.55; p[1] = 0.;
827 delta = p[0]+p[1]*pT;
828 // Printf("Kaon time: %f %f %f %f",p[0],p[1],length,delta);
832 Float_t p[2] = {0.,0.};
834 if ( fInTRD && fOutTRD) { // zone 1
839 p[0] = 20.; p[1] = 0.;
840 } else if (length>=95. && length<195.) {
841 p[0] = -24.0; p[1] = 0.10+0.0041*length;
842 } else {//if (length>=195.)
843 p[0] = 150.; p[1] = 0.;
846 } else { // !isTRDout
848 p[0] = 40.; p[1] = 0.;
852 } else if (!fInTRD && !fOutTRD) { // zone 2
854 p[0] = 0.; p[1] = 0.;
856 } else if ( fInTRD && !fOutTRD) { // zone 3
861 p[0] = 180.; p[1] = 0.;
862 } else if (length>= 15. && length< 55.) {
863 p[0] = 215.; p[1] = -2.5;
864 } else {//if (length>=55.)
865 p[0] = 78.; p[1] = 0.;
868 } else { // !isTRDout
870 p[0] = 0.; p[1] = 0.;
874 } else if (!fInTRD && fOutTRD) { // zone 4
879 p[0] = 0.; p[1] = 0.;
880 } else if (length>= 55. && length<115.) {
881 p[0] = -85.; p[1] = 1.9;
882 } else {//if (length>=115.)
883 p[0] = 100.; p[1] = 0.;
886 } else { // !isTRDout
888 p[0] = 0.; p[1] = 0.;
894 delta = p[0]+p[1]*length;
895 // Printf("Kaon time: %f %f %f %f",p[0],p[1],length,delta);
903 //________________________________________________________________________
904 Double_t AliTOFTenderSupply::CorrectExpectedProtonTime(Double_t pT,
908 // correction for expected time for protons
911 // Printf("Flags Ent In ComingOut Out %d %d %d %d",fIsEnteringInTRD,fInTRD,fIsComingOutTRD,fOutTRD);
913 if (!fIsEnteringInTRD || !fIsComingOutTRD) { // zone 5
914 Float_t p[2]={0.,0.};
920 p[0] = 1000.; p[1] = 0.;
921 } else if (pT>=0.375 && pT<0.45) {
922 p[0] = 1500.; p[1] = 0.;
923 } else if (pT>=0.45 && pT<0.50) {
924 p[0] = 4650.; p[1] = -7000.;
925 } else if (pT>=0.50 && pT<0.55) {
926 p[0] = 3150.; p[1] = -4000.;
927 } else { //if (pT>=0.55)
928 p[0] = 3150. -4000.*0.55; p[1] = 0.;
934 p[0] = 2963.-5670.*0.032; p[1] = 0.;
935 } else if (pT>=0.32 && pT<0.35) {
936 p[0] = 2963.; p[1] = -5670.;
937 } else if (pT>=0.35 && pT<0.40) {
938 p[0] = 4270.; p[1] = -9400.;
939 } else if (pT>=0.40 && pT<0.45) {
940 p[0] = 1550.; p[1] = -2600.;
941 } else if (pT>=0.45 && pT<0.50) {
942 p[0] = 1946.; p[1] = -3480.;
943 } else if (pT>=0.50 && pT<0.55) {
944 p[0] = 1193.; p[1] = -1974.;
945 } else { //if (pT>=0.55)
946 p[0] = 1193.-1974.*0.55; p[1] = 0.;
951 delta = p[0]+p[1]*pT;
952 // Printf("Proton time: %f %f %f %f",p[0],p[1],length,delta);
956 Float_t p[2] = {0.,0.};
958 if ( fInTRD && fOutTRD) { // zone 1
963 p[0] = 0.; p[1] = 0.;
964 } else if (length>=90. && length<200.) {
965 p[0] = 1063.; p[1] = -32.+0.30*length-0.00072*length*length;
966 } else {//if (length>=200.)
967 p[0] = 900.; p[1] = 0.;
970 } else { // !isTRDout
972 p[0] = 80.; p[1] = 0.;
976 } else if (!fInTRD && !fOutTRD) { // zone 2
979 p[0] = 0.; p[1] = 0.;
982 p[0] = 0.; p[1] = 0.;
983 } else if (length>=125. && length<180.) {
984 p[0] = -132.; p[1] = 1.3;
986 p[0] = 100.; p[1] = 0.;
991 } else if ( fInTRD && !fOutTRD) { // zone 3
996 p[0] = 670.; p[1] = 0.;
997 } else if (length>= 30. && length<155.) {
998 p[0] = 944.; p[1] = -11.+0.064*length;
999 } else {//if (length>=155.)
1000 p[0] = 780.; p[1] = 0.;
1003 } else { // !isTRDout
1006 p[0] = 140.; p[1] = -4.5;
1008 p[0] = 0.; p[1] = 0.;
1013 } else if (!fInTRD && fOutTRD) { // zone 4
1018 p[0] = 130.; p[1] = 0.;
1019 } else if (length>= 45. && length<120.) {
1020 p[0] = -190.; p[1] = 6.5;
1021 } else {//if (length>=120.)
1022 p[0] = 750.; p[1] = 0.;
1025 } else { // !isTRDout
1028 p[0] = 0.; p[1] = 0.;
1029 } else if (length>= 75.5 && length<90.) {
1030 p[0] = -830.; p[1] = 11.;
1032 p[0] = 160.; p[1] = 0.;
1039 delta = p[0]+p[1]*length;
1040 // Printf("Proton time: %f %f %f %f",p[0],p[1],length,delta);
1048 //________________________________________________________________________
1049 Double_t AliTOFTenderSupply::EstimateLengthInTRD1(AliESDtrack *track)
1052 Double_t xyz0[3]={0.,0.,0.};
1053 Bool_t stayInTRD = track->GetXYZAt(fRhoTRDin,fMagField,xyz0);
1055 Double_t phi0 = TMath::Pi()+TMath::ATan2(-xyz0[1],-xyz0[0]);
1056 phi0 *= TMath::RadToDeg();
1057 stayInTRD = stayInTRD && ( (phi0>= 0. && phi0<= 40.) ||
1058 (phi0>=140. && phi0<=220.) ||
1059 (phi0>=340. && phi0<=360.) );
1061 Double_t trackLengthInTRD = 0.;
1064 Double_t b[3];track->GetBxByBz(b);
1066 Double_t xyz1[3]={0.,0.,0.};
1067 Double_t rho = fRhoTRDin;
1068 while (stayInTRD && rho<=fRhoTRDout) {
1072 for (Int_t ii=0; ii<3; ii++) xyz1[ii]=0.;
1073 stayInTRD = track->GetXYZAt(rho,fMagField,xyz1);
1074 Double_t phi1 = TMath::Pi()+TMath::ATan2(-xyz1[1],-xyz1[0]);
1075 phi1 *= TMath::RadToDeg();
1076 stayInTRD = stayInTRD && ( (phi1>= 0. && phi1<= 40.) ||
1077 (phi1>=140. && phi1<=220.) ||
1078 (phi1>=340. && phi1<=360.) );
1080 Double_t l2 = TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0]) +
1081 (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1]) +
1082 (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]));
1083 trackLengthInTRD += l2;
1085 for (Int_t ii=0; ii<3; ii++) xyz0[ii]=xyz1[ii];
1088 return trackLengthInTRD;
1092 //________________________________________________________________________
1093 Double_t AliTOFTenderSupply::EstimateLengthInTRD2(AliESDtrack *track)
1096 Double_t xyz0[3]={0.,0.,0.};
1097 Bool_t stayInTRD = track->GetXYZAt(fRhoTRDout,fMagField,xyz0);
1099 Double_t phi0 = TMath::Pi()+TMath::ATan2(-xyz0[1],-xyz0[0]);
1100 phi0 *= TMath::RadToDeg();
1101 stayInTRD = stayInTRD && ( (phi0>= 0. && phi0<= 40.) ||
1102 (phi0>=140. && phi0<=220.) ||
1103 (phi0>=340. && phi0<=360.) );
1105 Double_t trackLengthInTRD = 0.;
1108 Double_t b[3];track->GetBxByBz(b);
1110 Double_t xyz1[3]={0.,0.,0.};
1111 Double_t rho = fRhoTRDout;
1112 while (stayInTRD && rho>=fRhoTRDin) {
1116 for (Int_t ii=0; ii<3; ii++) xyz1[ii]=0.;
1117 stayInTRD = track->GetXYZAt(rho,fMagField,xyz1);
1118 Double_t phi1 = TMath::Pi()+TMath::ATan2(-xyz1[1],-xyz1[0]);
1119 phi1 *= TMath::RadToDeg();
1120 stayInTRD = stayInTRD && ( (phi1>= 0. && phi1<= 40.) ||
1121 (phi1>=140. && phi1<=220.) ||
1122 (phi1>=340. && phi1<=360.) );
1124 Double_t l2 = TMath::Sqrt((xyz0[0]-xyz1[0])*(xyz0[0]-xyz1[0]) +
1125 (xyz0[1]-xyz1[1])*(xyz0[1]-xyz1[1]) +
1126 (xyz0[2]-xyz1[2])*(xyz0[2]-xyz1[2]));
1127 trackLengthInTRD += l2;
1129 for (Int_t ii=0; ii<3; ii++) xyz0[ii]=xyz1[ii];
1132 return trackLengthInTRD;
1136 //________________________________________________________________________
1137 Double_t AliTOFTenderSupply::EstimateLengthOutTRD(AliESDtrack *track)
1140 Double_t xyz0[3]={0.,0.,0.};
1141 Bool_t stayInTRD = track->GetXYZAt(fRhoTRDin,fMagField,xyz0);
1143 Double_t phi0 = TMath::Pi()+TMath::ATan2(-xyz0[1],-xyz0[0]);
1144 phi0 *= TMath::RadToDeg();
1145 stayInTRD = stayInTRD && !( (phi0>= 0. && phi0<= 40.) ||
1146 (phi0>=140. && phi0<=220.) ||
1147 (phi0>=340. && phi0<=360.) );
1149 Double_t trackLengthInTRD = 0.;
1152 Double_t b[3];track->GetBxByBz(b);
1154 Double_t xyz1[3]={0.,0.,0.};
1155 Double_t rho = fRhoTRDin;
1156 while (stayInTRD && rho<=fRhoTRDout) {
1160 for (Int_t ii=0; ii<3; ii++) xyz1[ii]=0.;
1161 stayInTRD = track->GetXYZAt(rho,fMagField,xyz1);
1162 Double_t phi1 = TMath::Pi()+TMath::ATan2(-xyz1[1],-xyz1[0]);
1163 phi1 *= TMath::RadToDeg();
1164 stayInTRD = stayInTRD && !( (phi1>= 0. && phi1<= 40.) ||
1165 (phi1>=140. && phi1<=220.) ||
1166 (phi1>=340. && phi1<=360.) );
1168 Double_t l2 = TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0]) +
1169 (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1]) +
1170 (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2]));
1171 trackLengthInTRD += l2;
1173 for (Int_t ii=0; ii<3; ii++) xyz0[ii]=xyz1[ii];
1176 return trackLengthInTRD;
1180 //________________________________________________________________________
1181 Int_t AliTOFTenderSupply::GetOCDBVersion(Int_t runNo)
1184 if ( (runNo>=118503 && runNo <=121040) ) { // LHC10C
1185 if (fRecoPass == 2) { // on pass2
1186 if (runNo >= 119159 && runNo <= 119163) verNo=3;
1187 else if (runNo >= 119837 && runNo <= 119934) verNo=4;
1188 else if (runNo >= 120067 && runNo <= 120244) verNo=4;
1189 else if (runNo >= 120503 && runNo <= 120505) verNo=4;
1190 else if (runNo >= 120616 && runNo <= 120671) verNo=4;
1191 else if (runNo >= 120741 && runNo <= 120829) verNo=4;