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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
18 // T0 Tender supply //
21 ///////////////////////////////////////////////////////////////////////////
23 #include <AliESDEvent.h>
24 #include <AliESDtrack.h>
26 #include <AliTender.h>
27 #include <AliT0TenderSupply.h>
28 #include <AliCDBManager.h>
29 #include <AliCDBEntry.h>
30 #include <AliT0CalibSeasonTimeShift.h>
31 #include <AliESDInputHandler.h>
33 ClassImp(AliT0TenderSupply)
35 //________________________________________________________________________
36 AliT0TenderSupply::AliT0TenderSupply():
38 fCorrectMeanTime(kFALSE),
39 fCorrectStartTimeOnAmplSatur(kFALSE),
40 fAmplitudeThreshold(100),
41 fPass4LHC11aCorrection(kFALSE)
44 // default constructor
46 for(int i=0; i<4; i++) fTimeOffset[i]=0;
49 //________________________________________________________________________
50 AliT0TenderSupply::AliT0TenderSupply(const char *name, const AliTender *tender):
51 AliTenderSupply(name,tender),
52 fCorrectMeanTime(kFALSE),
53 fCorrectStartTimeOnAmplSatur(kFALSE),
54 fAmplitudeThreshold(100),
55 fPass4LHC11aCorrection(kFALSE)
60 for(int i=0; i<3; i++) fTimeOffset[i]=0;
64 //________________________________________________________________________
65 AliT0TenderSupply::~AliT0TenderSupply(){
72 //________________________________________________________________________
73 void AliT0TenderSupply::Init(){
76 Int_t run = fTender->GetRun();
77 if (run == 0) return; // to skip first init, when we don't have yet a run number
78 fPass4LHC11aCorrection=kFALSE;
81 fCorrectMeanTime = kFALSE; //reset
82 for(int i=0; i<4; i++) fTimeOffset[i]=0;
85 fCorrectStartTimeOnAmplSatur = kFALSE;
86 fAmplitudeThreshold = 100; //in mips
88 if(167693<= run && run<=170593){ // LHC11h
89 fCorrectStartTimeOnAmplSatur = kTRUE;
90 fAmplitudeThreshold = 50; //in mips
95 //________________________________________________________________________
96 void AliT0TenderSupply::ProcessEvent(){
98 // loop over all online T0 candidates and flag
99 // selected daughter tracks using the status bis of the TObject
102 AliESDEvent *event=fTender->GetEvent();
104 //...........................................
105 //Do something when the run number changed, like loading OCDB entries etc.
106 if(fTender->RunChanged()){
108 if (fTender->GetRun()>=139699&& fTender->GetRun()<=146860){
109 AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler*> (fTender->GetESDhandler());
111 TTree *tree= (TTree*)esdIH->GetTree();
112 TFile *file= (TFile*)tree->GetCurrentFile();
114 TString fileName(file->GetName());
115 if (fileName.Contains("pass4") ) fPass4LHC11aCorrection=kTRUE;
121 if(fPass4LHC11aCorrection) {
122 const Double32_t* mean = event->GetT0TOF();
123 event->SetT0TOF(0, (mean[1]+mean[2])/2.);
126 //...........................................
127 if(fCorrectStartTimeOnAmplSatur){
128 //correct A side ORA on amplitude saturation
129 const Double32_t* time = event->GetT0time();
130 const Double32_t* amplitude = event->GetT0amplitude();
132 Int_t idxOfFirstPmtA = -1;
133 Double32_t timeOrA = 99999;
134 for(int ipmt=12; ipmt<24; ipmt++){ //loop over A side
135 if( amplitude[ipmt] < fAmplitudeThreshold){
136 if( time[ipmt] > -200 && time[ipmt]!=0 && time[ipmt] < timeOrA ){
137 timeOrA = time[ipmt];
138 idxOfFirstPmtA = ipmt;
143 if(idxOfFirstPmtA>-1){ //a hit in aside with less than 40 mips
144 const Double32_t* mean = event->GetT0TOF();
145 Double32_t timeOrC = mean[2];
146 Double32_t timeOrAplusOrC = (timeOrA+timeOrC)/2;
148 event->SetT0TOF(0, timeOrAplusOrC);
149 event->SetT0TOF(1, timeOrA);
153 //...........................................
154 Float_t *t0means=0x0;
155 if(fCorrectMeanTime) {
156 AliCDBManager* ocdbMan = AliCDBManager::Instance();
157 ocdbMan->SetRun(fTender->GetRun());
158 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
160 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
161 t0means= clb->GetT0Means();
163 for (Int_t i=0;i<4;i++) t0means[i]=0;
164 AliWarning("T0Tender no T0 entry found T0shift set to 0");
167 // correct mean time offsets
168 const Double32_t* mean = event->GetT0TOF();
169 for(int it0=0; it0<3; it0++){
170 if(-2000 < mean[it0]){
171 event->SetT0TOF(it0, mean[it0] - t0means[it0]);
175 //...........................................