]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/TenderSupplies/AliT0TenderSupply.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliT0TenderSupply.cxx
CommitLineData
40d5596c 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\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
15\r
16///////////////////////////////////////////////////////////////////////////\r
17// //\r
18// T0 Tender supply //\r
19// //\r
20// //\r
21///////////////////////////////////////////////////////////////////////////\r
22\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
31\r
32ClassImp(AliT0TenderSupply)\r
33\r
34//________________________________________________________________________\r
35AliT0TenderSupply::AliT0TenderSupply():\r
36 AliTenderSupply(),\r
37 fCorrectMeanTime(kFALSE),\r
38 fCorrectStartTimeOnAmplSatur(kFALSE),\r
39 fAmplitudeThreshold(100), \r
40 fPass4LHC11aCorrection(kFALSE)\r
41{\r
42 //\r
43 // default constructor\r
44 //\r
45 for(int i=0; i<4; i++) fTimeOffset[i]=0;\r
46}\r
47\r
48//________________________________________________________________________\r
49AliT0TenderSupply::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
55{\r
56 //\r
57 // constructor\r
58 //\r
59 for(int i=0; i<4; i++) fTimeOffset[i]=0;\r
60\r
61}\r
62\r
63//________________________________________________________________________\r
64AliT0TenderSupply::~AliT0TenderSupply(){\r
65 //\r
66 // destructor\r
67 //\r
68 \r
69}\r
70\r
71//________________________________________________________________________\r
72void AliT0TenderSupply::Init(){\r
73 // Init\r
74 //\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
78\r
79 fCorrectMeanTime = kFALSE; //reset\r
80 for(int i=0; i<4; i++) fTimeOffset[i]=0;\r
81\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
87 \r
88 AliCDBManager* ocdbMan = AliCDBManager::Instance();\r
89 ocdbMan->SetRun(fTender->GetRun()); \r
90 AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");\r
91 if(entry) {\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
95 } else {\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
98 }\r
99 } \r
100 \r
101 // LHC11h\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
107 }\r
108\r
109\r
110\r
111}\r
112\r
113//________________________________________________________________________\r
114void AliT0TenderSupply::ProcessEvent(){\r
115\r
116 //\r
117 // loop over all online T0 candidates and flag\r
118 // selected daughter tracks using the status bis of the TObject\r
119 //\r
120\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
126 \r
127 if(fTender->RunChanged()){\r
128 Init();\r
129 if (fTender->GetRun()>=139699&& fTender->GetRun()<=146860){\r
130 AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler*> (fTender->GetESDhandler());\r
131 if (esdIH) {\r
132 TTree *tree= (TTree*)esdIH->GetTree();\r
133 TFile *file= (TFile*)tree->GetCurrentFile();\r
134 if (file){\r
135 TString fileName(file->GetName());\r
136 if (fileName.Contains("pass4") ) fPass4LHC11aCorrection=kTRUE;\r
137 }\r
138 }\r
139 }\r
140 }\r
141 \r
142 if(fPass4LHC11aCorrection) {\r
143 const Double32_t* mean = event->GetT0TOF();\r
144 event->SetT0TOF(0, (mean[1]+mean[2])/2.);\r
145 \r
146 }\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
152\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
160 }\r
161 }\r
162 }\r
163\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
168\r
169 event->SetT0TOF(0, timeOrAplusOrC);\r
170 event->SetT0TOF(1, timeOrA);\r
171 }\r
172 }\r
173\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
181 }\r
182 }\r
183 //...........................................\r
184\r
185\r
186}\r
187\r
188\r