end-of-line normalization
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliT0TenderSupply.cxx
CommitLineData
7fac8669 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// T0 Tender supply //
19// //
20// //
21///////////////////////////////////////////////////////////////////////////
22
23#include <AliESDEvent.h>
24#include <AliESDtrack.h>
25#include <AliTender.h>
26#include <AliT0TenderSupply.h>
27#include <AliCDBManager.h>
28#include <AliCDBEntry.h>
29#include <AliT0CalibSeasonTimeShift.h>
30#include <AliESDInputHandler.h>
31
32ClassImp(AliT0TenderSupply)
33
34//________________________________________________________________________
35AliT0TenderSupply::AliT0TenderSupply():
36 AliTenderSupply(),
37 fCorrectMeanTime(kFALSE),
38 fCorrectStartTimeOnAmplSatur(kFALSE),
39 fAmplitudeThreshold(100),
40 fPass4LHC11aCorrection(kFALSE)
41{
42 //
43 // default constructor
44 //
45 for(int i=0; i<4; i++) fTimeOffset[i]=0;
46}
47
48//________________________________________________________________________
49AliT0TenderSupply::AliT0TenderSupply(const char *name, const AliTender *tender):
50 AliTenderSupply(name,tender),
51 fCorrectMeanTime(kFALSE),
52 fCorrectStartTimeOnAmplSatur(kFALSE),
53 fAmplitudeThreshold(100),
54 fPass4LHC11aCorrection(kFALSE)
55{
56 //
57 // constructor
58 //
59 for(int i=0; i<4; i++) fTimeOffset[i]=0;
60
61}
62
63//________________________________________________________________________
64AliT0TenderSupply::~AliT0TenderSupply(){
65 //
66 // destructor
67 //
68
69}
70
71//________________________________________________________________________
72void AliT0TenderSupply::Init(){
73 // Init
74 //
75 Int_t run = fTender->GetRun();
76 if (run == 0) return; // to skip first init, when we don't have yet a run number
77 Printf("----------- TZERO Tender ----------------");
78
79 fCorrectMeanTime = kFALSE; //reset
80 for(int i=0; i<4; i++) fTimeOffset[i]=0;
81
82 // align T0s for LHC10def periods
83 if (fTender->GetRun()>=122195 && fTender->GetRun()<=130850){
84 Printf("Loading TZERO OCBD entries");
85 fCorrectMeanTime=kTRUE;
86 Printf("fCorrectMeanTime %i \n", fCorrectMeanTime);
87
88 AliCDBManager* ocdbMan = AliCDBManager::Instance();
89 ocdbMan->SetRun(fTender->GetRun());
90 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
91 if(entry) {
92 AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
93 Float_t *t0means = clb->GetT0Means();
94 for (Int_t i=0;i<4;i++) fTimeOffset[i] = t0means[i];
95 } else {
96 for (Int_t i=0;i<4;i++) fTimeOffset[i] = 0;
97 AliWarning("T0Tender no T0 entry found T0shift set to 0");
98 }
99 }
100
101 // LHC11h
102 fCorrectStartTimeOnAmplSatur = kFALSE;
103 fAmplitudeThreshold = 100; //in mips
104 if(167693<= run && run<=170593){
105 fCorrectStartTimeOnAmplSatur = kTRUE;
106 fAmplitudeThreshold = 50; //in mips
107 }
108
109
110
111}
112
113//________________________________________________________________________
114void AliT0TenderSupply::ProcessEvent(){
115
116 //
117 // loop over all online T0 candidates and flag
118 // selected daughter tracks using the status bis of the TObject
119 //
120
121 AliESDEvent *event=fTender->GetEvent();
122 if (!event) return;
123 //...........................................
124 //Do something when the run number changed, like loading OCDB entries etc.
125 if(fTender->RunChanged()) Init();
126
127 if(fTender->RunChanged()){
128 Init();
129 if (fTender->GetRun()>=139699&& fTender->GetRun()<=146860){
130 AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler*> (fTender->GetESDhandler());
131 if (esdIH) {
132 TTree *tree= (TTree*)esdIH->GetTree();
133 TFile *file= (TFile*)tree->GetCurrentFile();
134 if (file){
135 TString fileName(file->GetName());
136 if (fileName.Contains("pass4") ) fPass4LHC11aCorrection=kTRUE;
137 }
138 }
139 }
140 }
141
142 if(fPass4LHC11aCorrection) {
143 const Double32_t* mean = event->GetT0TOF();
144 event->SetT0TOF(0, (mean[1]+mean[2])/2.);
145
146 }
147 //...........................................
148 if(fCorrectStartTimeOnAmplSatur){
149 //correct A side ORA on amplitude saturation
150 const Double32_t* time = event->GetT0time();
151 const Double32_t* amplitude = event->GetT0amplitude();
152
153 Int_t idxOfFirstPmtA = -1;
154 Double32_t timeOrA = 99999;
155 for(int ipmt=12; ipmt<24; ipmt++){ //loop over A side
156 if( amplitude[ipmt] < fAmplitudeThreshold){
157 if( time[ipmt] > -200 && time[ipmt]!=0 && time[ipmt] < timeOrA ){
158 timeOrA = time[ipmt];
159 idxOfFirstPmtA = ipmt;
160 }
161 }
162 }
163
164 if(idxOfFirstPmtA>-1){ //a hit in aside with less than 40 mips
165 const Double32_t* mean = event->GetT0TOF();
166 Double32_t timeOrC = mean[2];
167 Double32_t timeOrAplusOrC = (timeOrA+timeOrC)/2;
168
169 event->SetT0TOF(0, timeOrAplusOrC);
170 event->SetT0TOF(1, timeOrA);
171 }
172 }
173
174 //...........................................
175 if(fCorrectMeanTime) {
176 // correct mean time offsets
177 const Double32_t* mean = event->GetT0TOF();
178 for(int it0=0; it0<3; it0++){
179 if( mean[it0] < 10000 || (mean[it0]>6499000 && mean[it0]<6555000 ) )
180 event->SetT0TOF(it0, mean[it0] - fTimeOffset[it0]);
181 }
182 }
183 //...........................................
184
185
186}
187
188