1 /**************************************************************************
\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
\r
4 * Author: The ALICE Off-line Project. *
\r
5 * Contributors are mentioned in the code where appropriate. *
\r
7 * Permission to use, copy, modify and distribute this software and its *
\r
8 * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * without fee, provided that the above copyright notice appears in all *
\r
10 * copies and that both the copyright notice and this permission notice *
\r
11 * appear in the supporting documentation. The authors make no claims *
\r
12 * about the suitability of this software for any purpose. It is *
\r
13 * provided "as is" without express or implied warranty. *
\r
14 **************************************************************************/
\r
16 ///////////////////////////////////////////////////////////////////////////
\r
18 // T0 Tender supply //
\r
21 ///////////////////////////////////////////////////////////////////////////
\r
23 #include <AliESDEvent.h>
\r
24 #include <AliESDtrack.h>
\r
25 #include <AliTender.h>
\r
26 #include <AliT0TenderSupply.h>
\r
27 #include <AliCDBManager.h>
\r
28 #include <AliCDBEntry.h>
\r
29 #include <AliT0CalibSeasonTimeShift.h>
\r
30 #include <AliESDInputHandler.h>
\r
32 ClassImp(AliT0TenderSupply)
\r
34 //________________________________________________________________________
\r
35 AliT0TenderSupply::AliT0TenderSupply():
\r
37 fCorrectMeanTime(kFALSE),
\r
38 fCorrectStartTimeOnAmplSatur(kFALSE),
\r
39 fAmplitudeThreshold(100),
\r
40 fPass4LHC11aCorrection(kFALSE)
\r
43 // default constructor
\r
45 for(int i=0; i<4; i++) fTimeOffset[i]=0;
\r
48 //________________________________________________________________________
\r
49 AliT0TenderSupply::AliT0TenderSupply(const char *name, const AliTender *tender):
\r
50 AliTenderSupply(name,tender),
\r
51 fCorrectMeanTime(kFALSE),
\r
52 fCorrectStartTimeOnAmplSatur(kFALSE),
\r
53 fAmplitudeThreshold(100),
\r
54 fPass4LHC11aCorrection(kFALSE)
\r
59 for(int i=0; i<4; i++) fTimeOffset[i]=0;
\r
63 //________________________________________________________________________
\r
64 AliT0TenderSupply::~AliT0TenderSupply(){
\r
71 //________________________________________________________________________
\r
72 void AliT0TenderSupply::Init(){
\r
75 Int_t run = fTender->GetRun();
\r
76 if (run == 0) return; // to skip first init, when we don't have yet a run number
\r
77 Printf("----------- TZERO Tender ----------------");
\r
79 fCorrectMeanTime = kFALSE; //reset
\r
80 for(int i=0; i<4; i++) fTimeOffset[i]=0;
\r
82 // align T0s for LHC10def periods
\r
83 if (fTender->GetRun()>=122195 && fTender->GetRun()<=130850){
\r
84 Printf("Loading TZERO OCBD entries");
\r
85 fCorrectMeanTime=kTRUE;
\r
86 Printf("fCorrectMeanTime %i \n", fCorrectMeanTime);
\r
88 AliCDBManager* ocdbMan = AliCDBManager::Instance();
\r
89 ocdbMan->SetRun(fTender->GetRun());
\r
90 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
\r
92 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
\r
93 Float_t *t0means = clb->GetT0Means();
\r
94 for (Int_t i=0;i<4;i++) fTimeOffset[i] = t0means[i];
\r
96 for (Int_t i=0;i<4;i++) fTimeOffset[i] = 0;
\r
97 AliWarning("T0Tender no T0 entry found T0shift set to 0");
\r
102 fCorrectStartTimeOnAmplSatur = kFALSE;
\r
103 fAmplitudeThreshold = 100; //in mips
\r
104 if(167693<= run && run<=170593){
\r
105 fCorrectStartTimeOnAmplSatur = kTRUE;
\r
106 fAmplitudeThreshold = 50; //in mips
\r
113 //________________________________________________________________________
\r
114 void AliT0TenderSupply::ProcessEvent(){
\r
117 // loop over all online T0 candidates and flag
\r
118 // selected daughter tracks using the status bis of the TObject
\r
121 AliESDEvent *event=fTender->GetEvent();
\r
122 if (!event) return;
\r
123 //...........................................
\r
124 //Do something when the run number changed, like loading OCDB entries etc.
\r
125 if(fTender->RunChanged()) Init();
\r
127 if(fTender->RunChanged()){
\r
129 if (fTender->GetRun()>=139699&& fTender->GetRun()<=146860){
\r
130 AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler*> (fTender->GetESDhandler());
\r
132 TTree *tree= (TTree*)esdIH->GetTree();
\r
133 TFile *file= (TFile*)tree->GetCurrentFile();
\r
135 TString fileName(file->GetName());
\r
136 if (fileName.Contains("pass4") ) fPass4LHC11aCorrection=kTRUE;
\r
142 if(fPass4LHC11aCorrection) {
\r
143 const Double32_t* mean = event->GetT0TOF();
\r
144 event->SetT0TOF(0, (mean[1]+mean[2])/2.);
\r
147 //...........................................
\r
148 if(fCorrectStartTimeOnAmplSatur){
\r
149 //correct A side ORA on amplitude saturation
\r
150 const Double32_t* time = event->GetT0time();
\r
151 const Double32_t* amplitude = event->GetT0amplitude();
\r
153 Int_t idxOfFirstPmtA = -1;
\r
154 Double32_t timeOrA = 99999;
\r
155 for(int ipmt=12; ipmt<24; ipmt++){ //loop over A side
\r
156 if( amplitude[ipmt] < fAmplitudeThreshold){
\r
157 if( time[ipmt] > -200 && time[ipmt]!=0 && time[ipmt] < timeOrA ){
\r
158 timeOrA = time[ipmt];
\r
159 idxOfFirstPmtA = ipmt;
\r
164 if(idxOfFirstPmtA>-1){ //a hit in aside with less than 40 mips
\r
165 const Double32_t* mean = event->GetT0TOF();
\r
166 Double32_t timeOrC = mean[2];
\r
167 Double32_t timeOrAplusOrC = (timeOrA+timeOrC)/2;
\r
169 event->SetT0TOF(0, timeOrAplusOrC);
\r
170 event->SetT0TOF(1, timeOrA);
\r
174 //...........................................
\r
175 if(fCorrectMeanTime) {
\r
176 // correct mean time offsets
\r
177 const Double32_t* mean = event->GetT0TOF();
\r
178 for(int it0=0; it0<3; it0++){
\r
179 if( mean[it0] < 10000 || (mean[it0]>6499000 && mean[it0]<6555000 ) )
\r
180 event->SetT0TOF(it0, mean[it0] - fTimeOffset[it0]);
\r
183 //...........................................
\r