]>
Commit | Line | Data |
---|---|---|
dc7ca31d | 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 | /* $Id$ */ | |
72e48d95 | 17 | /********************************************************************* |
18 | * T0 reconstruction and filling ESD | |
19 | * - reconstruct mean time (interation time) | |
20 | * - vertex position | |
21 | * - multiplicity | |
22 | ********************************************************************/ | |
dc7ca31d | 23 | |
af885e0f | 24 | #include <AliESDEvent.h> |
dc7ca31d | 25 | #include "AliLog.h" |
dc7ca31d | 26 | #include "AliT0RecPoint.h" |
27 | #include "AliRawReader.h" | |
28 | #include "AliT0RawReader.h" | |
dc7ca31d | 29 | #include "AliT0digit.h" |
30 | #include "AliT0Reconstructor.h" | |
31 | #include "AliT0Parameters.h" | |
c41ceaac | 32 | #include "AliT0Calibrator.h" |
58bd3a16 | 33 | #include "AliESDfriend.h" |
b0e13b29 | 34 | #include "AliESDTZERO.h" |
73df58ab | 35 | #include "AliESDTZEROfriend.h" |
8f8d0732 | 36 | #include "AliLog.h" |
85f61e3b | 37 | #include "AliCDBEntry.h" |
38 | #include "AliCDBManager.h" | |
39 | #include "AliCTPTimeParams.h" | |
40 | #include "AliLHCClockPhase.h" | |
669dc07f | 41 | #include "AliT0CalibSeasonTimeShift.h" |
4cbe597e | 42 | #include "AliESDRun.h" |
dc7ca31d | 43 | |
44 | #include <TArrayI.h> | |
45 | #include <TGraph.h> | |
aad72f45 | 46 | #include <TMath.h> |
b09247a2 | 47 | #include <Riostream.h> |
dc7ca31d | 48 | |
49 | ClassImp(AliT0Reconstructor) | |
50 | ||
c41ceaac | 51 | AliT0Reconstructor:: AliT0Reconstructor(): AliReconstructor(), |
f16935f7 | 52 | fdZonA(0), |
53 | fdZonC(0), | |
54 | fZposition(0), | |
55 | fParam(NULL), | |
2e6a5ee0 | 56 | fAmpLEDrec(), |
c883fdf2 | 57 | fQTC(0), |
58 | fAmpLED(0), | |
58bd3a16 | 59 | fCalib(), |
60 | fLatencyHPTDC(9000), | |
61 | fLatencyL1(0), | |
62 | fLatencyL1A(0), | |
73df58ab | 63 | fLatencyL1C(0), |
85f61e3b | 64 | fGRPdelays(0), |
669dc07f | 65 | fTimeMeanShift(0x0), |
66 | fTimeSigmaShift(0x0), | |
b0e13b29 | 67 | fESDTZEROfriend(NULL), |
4debc5c4 | 68 | fESDTZERO(NULL), |
69 | fIsCDFfromGRP(kFALSE) | |
58bd3a16 | 70 | |
e0bba6cc | 71 | { |
612737bb | 72 | for (Int_t i=0; i<24; i++) fTime0vertex[i] =0; |
4cbe597e | 73 | |
72e48d95 | 74 | //constructor |
85f61e3b | 75 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming"); |
76 | if (!entry) AliFatal("CTP timing parameters are not found in OCDB !"); | |
77 | AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject(); | |
78 | Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0; | |
79 | ||
80 | AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign"); | |
81 | if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !"); | |
82 | AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject(); | |
83 | l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0); | |
84 | ||
85 | AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase"); | |
86 | if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !"); | |
87 | AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject(); | |
993257ce | 88 | |
85f61e3b | 89 | fGRPdelays = l1Delay - phase->GetMeanPhase(); |
993257ce | 90 | |
669dc07f | 91 | AliCDBEntry *entry5 = AliCDBManager::Instance()->Get("T0/Calib/TimeAdjust"); |
92 | if (entry5) { | |
93 | AliT0CalibSeasonTimeShift *timeshift = (AliT0CalibSeasonTimeShift*)entry5->GetObject(); | |
94 | fTimeMeanShift = timeshift->GetT0Means(); | |
95 | fTimeSigmaShift = timeshift->GetT0Sigmas(); | |
993257ce | 96 | } |
669dc07f | 97 | else |
98 | AliWarning("Time Adjust is not found in OCDB !"); | |
612737bb | 99 | |
74adb36a | 100 | fParam = AliT0Parameters::Instance(); |
101 | fParam->Init(); | |
c883fdf2 | 102 | |
74adb36a | 103 | for (Int_t i=0; i<24; i++){ |
2e6a5ee0 | 104 | TGraph* gr = fParam ->GetAmpLEDRec(i); |
29ed1d0e | 105 | if (gr) fAmpLEDrec.AddAtAndExpand(gr,i) ; |
c883fdf2 | 106 | TGraph* gr1 = fParam ->GetAmpLED(i); |
107 | if (gr1) fAmpLED.AddAtAndExpand(gr1,i) ; | |
108 | TGraph* gr2 = fParam ->GetQTC(i); | |
539b9cb9 | 109 | if (gr2) fQTC.AddAtAndExpand(gr2,i) ; |
612737bb | 110 | fTime0vertex[i] = fParam->GetCFD(i); |
612737bb | 111 | } |
58bd3a16 | 112 | fLatencyL1 = fParam->GetLatencyL1(); |
612737bb | 113 | fLatencyL1A = fParam->GetLatencyL1A(); |
58bd3a16 | 114 | fLatencyL1C = fParam->GetLatencyL1C(); |
115 | fLatencyHPTDC = fParam->GetLatencyHPTDC(); | |
9d026202 | 116 | AliDebug(2,Form(" LatencyL1 %f latencyL1A %f latencyL1C %f latencyHPTDC %f \n",fLatencyL1, fLatencyL1A, fLatencyL1C, fLatencyHPTDC)); |
612737bb | 117 | |
118 | for (Int_t i=0; i<24; i++) { | |
4debc5c4 | 119 | if( fTime0vertex[i] < 500 || fTime0vertex[i] > 60000) |
120 | { fTime0vertex[i] =( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4; | |
121 | fIsCDFfromGRP=kTRUE; | |
122 | } | |
993257ce | 123 | AliDebug(2,Form("OCDB mean CFD time %i %f \n",i, fTime0vertex[i])); |
612737bb | 124 | } |
8f620945 | 125 | //here real Z position |
126 | fdZonC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1")); | |
127 | fdZonA = TMath::Abs(fParam->GetZPosition("T0/A/PMT15")); | |
993257ce | 128 | |
12e9daf9 | 129 | fCalib = new AliT0Calibrator(); |
73df58ab | 130 | fESDTZEROfriend = new AliESDTZEROfriend(); |
b0e13b29 | 131 | fESDTZERO = new AliESDTZERO(); |
993257ce | 132 | |
b0e13b29 | 133 | |
dc7ca31d | 134 | } |
c41ceaac | 135 | |
136 | //_____________________________________________________________________________ | |
dc7ca31d | 137 | void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const |
138 | { | |
94c27e4f | 139 | // T0 digits reconstruction |
ce50812a | 140 | Int_t refAmp = 0 ; /*Int_t (GetRecoParam()->GetRefAmp());*/ |
776de217 | 141 | |
c41ceaac | 142 | TArrayI * timeCFD = new TArrayI(24); |
143 | TArrayI * timeLED = new TArrayI(24); | |
144 | TArrayI * chargeQT0 = new TArrayI(24); | |
145 | TArrayI * chargeQT1 = new TArrayI(24); | |
74adb36a | 146 | |
d0bcd1fb | 147 | |
ce50812a | 148 | Float_t c = 29.9792458; // cm/ns |
8955c6b4 | 149 | Float_t channelWidth = fParam->GetChannelWidth() ; |
eadc5bd4 | 150 | Double32_t vertex = 9999999, meanVertex = 0 ; |
adf36b9d | 151 | Double32_t timeDiff=999999, meanTime=999999, timeclock=999999; |
ce50812a | 152 | |
94c27e4f | 153 | |
dc7ca31d | 154 | AliDebug(1,Form("Start DIGITS reconstruction ")); |
94c27e4f | 155 | |
ce50812a | 156 | Float_t lowAmpThreshold = GetRecoParam()->GetAmpLowThreshold(); |
157 | Float_t highAmpThreshold = GetRecoParam()->GetAmpHighThreshold(); | |
13e2fbbd | 158 | printf("Reconstruct(TTree*digitsTree highAmpThreshold %f lowAmpThreshold %f \n",lowAmpThreshold, highAmpThreshold); |
ea72dbfe | 159 | |
160 | //shift T0A, T0C , T0AC | |
161 | Float_t shiftA = GetRecoParam() -> GetLow(310); | |
162 | Float_t shiftC = GetRecoParam() -> GetLow(311); | |
163 | Float_t shiftAC = GetRecoParam() -> GetLow(312); | |
993257ce | 164 | AliDebug(2, Form("Reconstruct(TTree*digitsTree shiftA %f shiftC %f shiftAC %f \n",shiftA, shiftC, shiftAC)); |
165 | ||
ce50812a | 166 | Double32_t besttimeA=9999999; Double32_t besttimeA_best=9999999; |
167 | Double32_t besttimeC=9999999; Double32_t besttimeC_best=9999999; | |
168 | Int_t timeDelayCFD[24]; | |
169 | Int_t badpmt[24]; | |
170 | //Bad channel | |
171 | for (Int_t i=0; i<24; i++) { | |
172 | badpmt[i] = GetRecoParam() -> GetBadChannels(i); | |
173 | timeDelayCFD[i] = Int_t (fParam->GetTimeDelayCFD(i)); | |
174 | } | |
175 | fCalib->SetEq(0); | |
d0bcd1fb | 176 | TBranch *brDigits=digitsTree->GetBranch("T0"); |
e0bba6cc | 177 | AliT0digit *fDigits = new AliT0digit() ; |
dc7ca31d | 178 | if (brDigits) { |
179 | brDigits->SetAddress(&fDigits); | |
180 | }else{ | |
f16935f7 | 181 | AliError(Form("EXEC Branch T0 digits not found")); |
ce50812a | 182 | return; |
dc7ca31d | 183 | } |
e0bba6cc | 184 | |
c41ceaac | 185 | digitsTree->GetEvent(0); |
186 | digitsTree->GetEntry(0); | |
187 | brDigits->GetEntry(0); | |
188 | fDigits->GetTimeCFD(*timeCFD); | |
189 | fDigits->GetTimeLED(*timeLED); | |
190 | fDigits->GetQT0(*chargeQT0); | |
191 | fDigits->GetQT1(*chargeQT1); | |
446d6ec4 | 192 | Int_t onlineMean = fDigits->MeanTime(); |
ce50812a | 193 | |
adf36b9d | 194 | Bool_t tr[5]; |
195 | for (Int_t i=0; i<5; i++) tr[i]=false; | |
c41ceaac | 196 | |
dc7ca31d | 197 | |
7e08771f | 198 | AliT0RecPoint frecpoints; |
199 | AliT0RecPoint * pfrecpoints = &frecpoints; | |
200 | clustersTree->Branch( "T0", "AliT0RecPoint" ,&pfrecpoints); | |
94c27e4f | 201 | |
195e1353 | 202 | Float_t time[24], adc[24], adcmip[24]; |
dc7ca31d | 203 | for (Int_t ipmt=0; ipmt<24; ipmt++) { |
ce50812a | 204 | if(timeCFD->At(ipmt)>0 ) { |
5773ee77 | 205 | Float_t timefull = 0.001*( timeCFD->At(ipmt) - 511 - timeDelayCFD[ipmt]) * channelWidth; |
eadc5bd4 | 206 | frecpoints.SetTimeFull(ipmt, 0 ,timefull) ; |
ce50812a | 207 | if(( chargeQT1->At(ipmt) - chargeQT0->At(ipmt))>0) |
d0bcd1fb | 208 | adc[ipmt] = chargeQT1->At(ipmt) - chargeQT0->At(ipmt); |
a7027400 | 209 | else |
d0bcd1fb | 210 | adc[ipmt] = 0; |
211 | ||
ce50812a | 212 | time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, Int_t(adc[ipmt]), timeCFD->At(ipmt)) ; |
5773ee77 | 213 | time[ipmt] = time[ipmt] - 511; |
d0bcd1fb | 214 | Double_t sl = Double_t(timeLED->At(ipmt) - timeCFD->At(ipmt)); |
8f620945 | 215 | // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD->At(ipmt) ) ; |
eadc5bd4 | 216 | AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", |
ce50812a | 217 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); |
218 | ||
644a358e | 219 | Double_t ampMip = 0; |
220 | TGraph* ampGraph = (TGraph*)fAmpLED.At(ipmt); | |
221 | if (ampGraph) ampMip = ampGraph->Eval(sl); | |
222 | Double_t qtMip = 0; | |
223 | TGraph* qtGraph = (TGraph*)fQTC.At(ipmt); | |
224 | if (qtGraph) qtMip = qtGraph->Eval(adc[ipmt]); | |
669dc07f | 225 | AliDebug(5,Form(" Amlitude in MIPS LED %f , QTC %f in channels %f\n ",ampMip,qtMip, adc[ipmt])); |
7e08771f | 226 | frecpoints.SetTime(ipmt, Float_t(time[ipmt]) ); |
227 | frecpoints.SetAmpLED(ipmt, Float_t( ampMip)); | |
228 | frecpoints.SetAmp(ipmt, Float_t(qtMip)); | |
195e1353 | 229 | adcmip[ipmt]=qtMip; |
d0bcd1fb | 230 | |
dc7ca31d | 231 | } |
232 | else { | |
eadc5bd4 | 233 | time[ipmt] = -99999; |
dc7ca31d | 234 | adc[ipmt] = 0; |
b0ab3f59 | 235 | adcmip[ipmt] = 0; |
ce50812a | 236 | |
dc7ca31d | 237 | } |
238 | } | |
94c27e4f | 239 | |
dc7ca31d | 240 | for (Int_t ipmt=0; ipmt<12; ipmt++){ |
993257ce | 241 | if(time[ipmt] !=0 && time[ipmt] > 0 |
ce50812a | 242 | && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold ) |
243 | { | |
244 | if(time[ipmt]<besttimeC) besttimeC=time[ipmt]; //timeC | |
245 | if(TMath::Abs(time[ipmt])<TMath::Abs(besttimeC_best)) | |
246 | besttimeC_best=time[ipmt]; //timeC | |
dc7ca31d | 247 | } |
dc7ca31d | 248 | } |
ce50812a | 249 | for ( Int_t ipmt=12; ipmt<24; ipmt++) |
250 | { | |
993257ce | 251 | if(time[ipmt] != 0 && time[ipmt] > 0 |
ce50812a | 252 | && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold) |
253 | { | |
254 | if(time[ipmt]<besttimeA) besttimeA=time[ipmt]; | |
255 | if(TMath::Abs(time[ipmt] ) < TMath::Abs(besttimeA_best)) | |
256 | besttimeA_best=time[ipmt]; //timeA | |
257 | } | |
dc7ca31d | 258 | } |
ce50812a | 259 | |
260 | if( besttimeA < 999999 && besttimeA!=0) { | |
eadc5bd4 | 261 | frecpoints.SetTimeBestA((besttimeA_best * channelWidth - fdZonA/c) ); |
ea72dbfe | 262 | frecpoints.SetTime1stA((besttimeA * channelWidth - fdZonA/c - shiftA) ); |
adf36b9d | 263 | tr[1]=true; |
264 | } | |
ce50812a | 265 | |
266 | if( besttimeC < 999999 && besttimeC!=0) { | |
eadc5bd4 | 267 | frecpoints.SetTimeBestC((besttimeC_best * channelWidth - fdZonC/c) ); |
ea72dbfe | 268 | frecpoints.SetTime1stC((besttimeC * channelWidth - fdZonC/c - shiftC) ); |
adf36b9d | 269 | tr[2]=true; |
270 | } | |
ce50812a | 271 | |
272 | AliDebug(5,Form("1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f ", | |
273 | besttimeA, besttimeA_best, | |
274 | besttimeC, besttimeC_best) ); | |
275 | ||
adf36b9d | 276 | if(besttimeA <999999 && besttimeC < 999999 ){ |
9b83615d | 277 | // timeDiff = (besttimeC - besttimeA)*channelWidth; |
278 | timeDiff = (besttimeA - besttimeC)*channelWidth; | |
ce50812a | 279 | meanTime = channelWidth * (besttimeA_best + besttimeC_best)/2. ; |
ea72dbfe | 280 | timeclock = channelWidth * (besttimeA + besttimeC)/2. - shiftAC ; |
eadc5bd4 | 281 | vertex = meanVertex - 0.001* c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2; |
adf36b9d | 282 | tr[0]=true; |
283 | } | |
7e08771f | 284 | frecpoints.SetVertex(vertex); |
eadc5bd4 | 285 | frecpoints.SetMeanTime(meanTime ); |
286 | frecpoints.SetT0clock(timeclock ); | |
7e08771f | 287 | frecpoints.SetT0Trig(tr); |
ce50812a | 288 | |
eadc5bd4 | 289 | AliDebug(5,Form("fRecPoints::: 1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f vertex %f", |
ce50812a | 290 | frecpoints.Get1stTimeA(), frecpoints.GetBestTimeA(), |
291 | frecpoints.Get1stTimeC(), frecpoints.GetBestTimeC(), | |
eadc5bd4 | 292 | vertex ) ); |
ce50812a | 293 | |
669dc07f | 294 | AliDebug(5,Form("T0 triggers %d %d %d %d %d",tr[0],tr[1],tr[2],tr[3],tr[4])); |
ce50812a | 295 | |
adf36b9d | 296 | //online mean |
7e08771f | 297 | frecpoints.SetOnlineMean(Int_t(onlineMean)); |
b5a9f753 | 298 | AliDebug(10,Form(" timeDiff %f #channel, meanTime %f #channel, vertex %f cm online mean %i timeclock %f ps",timeDiff, meanTime,vertex, Int_t(onlineMean), timeclock)); |
adf36b9d | 299 | |
830172c8 | 300 | clustersTree->Fill(); |
ce50812a | 301 | |
bd375212 | 302 | delete timeCFD; |
303 | delete timeLED; | |
304 | delete chargeQT0; | |
305 | delete chargeQT1; | |
dc7ca31d | 306 | } |
307 | ||
308 | ||
c41ceaac | 309 | //_______________________________________________________________________ |
310 | ||
311 | void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) const | |
312 | { | |
94c27e4f | 313 | // T0 raw -> |
539b9cb9 | 314 | // |
993257ce | 315 | |
b0e13b29 | 316 | Float_t meanOrA = fTime0vertex[0] + 587; |
317 | Float_t meanOrC = fTime0vertex[0] + 678; | |
318 | Float_t meanTVDC = fTime0vertex[0] + 2564; | |
993257ce | 319 | Float_t meanQT1 = fTime0vertex[0] + 2564; |
320 | Float_t meanQT0 = fTime0vertex[0] + 3564; | |
321 | ||
82540e64 | 322 | Int_t timeDelayCFD[24]; |
5773ee77 | 323 | Int_t corridor = GetRecoParam() -> GetCorridor(); |
4debc5c4 | 324 | if(fIsCDFfromGRP) corridor *=5; |
325 | AliDebug(10,Form("fIsCDFfromGRP %i corridor %i \n",fIsCDFfromGRP, corridor) ); | |
612737bb | 326 | Int_t badpmt[24]; |
38cbfa7c | 327 | //Bad channel |
58432641 | 328 | for (Int_t i=0; i<24; i++) { |
329 | badpmt[i] = GetRecoParam() -> GetBadChannels(i); | |
82540e64 | 330 | timeDelayCFD[i] = Int_t (fParam->GetTimeDelayCFD(i)); |
58432641 | 331 | } |
ce50812a | 332 | Int_t equalize = GetRecoParam() -> GetEq(); |
4debc5c4 | 333 | AliDebug(10,Form( "AliT0Reconstructor::Reconstruct::: RecoParam %i \n",equalize ) ); |
ce50812a | 334 | fCalib->SetEq(equalize); |
d3e04608 | 335 | Int_t low[500], high[500]; |
13e2fbbd | 336 | Float_t timefull=-99999;; |
337 | Float_t tvdc = -99999; Float_t ora = -99999; Float_t orc = -99999; | |
993257ce | 338 | |
e8ed1cd0 | 339 | Int_t allData[110][5]; |
2e6a5ee0 | 340 | |
e8ed1cd0 | 341 | Int_t timeCFD[24], timeLED[24], chargeQT0[24], chargeQT1[24]; |
ce50812a | 342 | Float_t time2zero[24]; |
612737bb | 343 | Double32_t timeDiff, meanTime, timeclock; |
344 | timeDiff = meanTime = timeclock = 9999999; | |
adf36b9d | 345 | Float_t c = 29.9792458; // cm/ns |
346 | Double32_t vertex = 9999999; | |
776de217 | 347 | Int_t onlineMean=0; |
9480f05f | 348 | Float_t meanVertex = 0; |
b7fd8e80 | 349 | Int_t pedestal[24]; |
612737bb | 350 | for (Int_t i0=0; i0<24; i0++) { |
5773ee77 | 351 | low[i0] = Int_t(fTime0vertex[i0]) - corridor; |
352 | high[i0] = Int_t(fTime0vertex[i0]) + corridor; | |
353 | time2zero[i0] = 99999; | |
354 | pedestal[i0]=Int_t (GetRecoParam()->GetLow(100+i0) ); | |
612737bb | 355 | } |
356 | ||
669dc07f | 357 | for (Int_t i0=0; i0<110; i0++) |
b0e13b29 | 358 | for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0; |
612737bb | 359 | |
360 | Float_t lowAmpThreshold = GetRecoParam()->GetAmpLowThreshold(); | |
361 | Float_t highAmpThreshold = GetRecoParam()->GetAmpHighThreshold(); | |
fd3fb735 | 362 | |
ce50812a | 363 | Double32_t besttimeA=9999999; Double32_t besttimeA_best=9999999; |
364 | Double32_t besttimeC=9999999; Double32_t besttimeC_best=9999999; | |
365 | ||
366 | Float_t channelWidth = fParam->GetChannelWidth() ; | |
b0e13b29 | 367 | |
7e08771f | 368 | AliT0RecPoint frecpoints; |
369 | AliT0RecPoint * pfrecpoints = &frecpoints; | |
bce12dc5 | 370 | |
7e08771f | 371 | recTree->Branch( "T0", "AliT0RecPoint" ,&pfrecpoints); |
2e6a5ee0 | 372 | |
bce12dc5 | 373 | AliDebug(10," before read data "); |
374 | AliT0RawReader myrawreader(rawReader); | |
776de217 | 375 | |
376 | UInt_t type =rawReader->GetType(); | |
377 | ||
bce12dc5 | 378 | if (!myrawreader.Next()) |
379 | AliDebug(1,Form(" no raw data found!!")); | |
380 | else | |
381 | { | |
38cbfa7c | 382 | for (Int_t i=0; i<24; i++) |
383 | { | |
384 | timeCFD[i]=0; timeLED[i]=0; chargeQT0[i]=0; chargeQT1[i]=0; | |
385 | } | |
9120829d | 386 | |
38cbfa7c | 387 | if(type == 7 ) { //only physics |
669dc07f | 388 | for (Int_t i=0; i<107; i++) { |
bce12dc5 | 389 | for (Int_t iHit=0; iHit<5; iHit++) |
390 | { | |
391 | allData[i][iHit] = myrawreader.GetData(i,iHit); | |
392 | } | |
8f620945 | 393 | } |
8f620945 | 394 | |
9120829d | 395 | Int_t fBCID=Int_t (rawReader->GetBCID()); |
396 | Int_t trmbunch= myrawreader.GetTRMBunchID(); | |
397 | AliDebug(10,Form(" CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch )); | |
398 | if( (trmbunch-fBCID)!=37 ) { | |
399 | AliDebug(0,Form("wrong :::: CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch )); | |
400 | // type = -1; | |
401 | } | |
85f61e3b | 402 | for (Int_t in=0; in<12; in++) |
403 | { | |
404 | for (Int_t iHit=0; iHit<5; iHit++) | |
38cbfa7c | 405 | { |
612737bb | 406 | if(allData[in+1][iHit] > low[in] && |
407 | allData[in+1][iHit] < high[in]) | |
38cbfa7c | 408 | { |
85f61e3b | 409 | timeCFD[in] = allData[in+1][iHit] ; |
794ab872 | 410 | break; |
38cbfa7c | 411 | } |
85f61e3b | 412 | } |
413 | for (Int_t iHit=0; iHit<5; iHit++) | |
414 | { | |
794ab872 | 415 | if(allData[in+1+56][iHit] > low[in+12] && |
416 | allData[in+1+56][iHit] < high[in+12]) | |
38cbfa7c | 417 | { |
85f61e3b | 418 | timeCFD[in+12] = allData[in+56+1][iHit] ; |
419 | break; | |
38cbfa7c | 420 | } |
38cbfa7c | 421 | } |
612737bb | 422 | timeLED[in+12] = allData[in+68+1][0] ; |
423 | timeLED[in] = allData[in+12+1][0] ; | |
ce50812a | 424 | AliDebug(50, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ", |
85f61e3b | 425 | in, timeCFD[in],timeCFD[in+12],timeLED[in], |
612737bb | 426 | timeLED[in+12])); |
38cbfa7c | 427 | |
8f620945 | 428 | } |
429 | ||
85f61e3b | 430 | for (Int_t in=0; in<12; in++) |
431 | { | |
993257ce | 432 | for (Int_t iHit=0; iHit<5; iHit++) |
433 | { | |
434 | if (allData[2*in+26][iHit] > fTime0vertex[0]+2000 && | |
4debc5c4 | 435 | allData[2*in+26][iHit] <fTime0vertex[0]+3000 ) { |
436 | chargeQT1[in]=allData[2*in+26][0]; | |
437 | break; | |
438 | } | |
439 | } | |
440 | ||
441 | for (Int_t iHit=0; iHit<5; iHit++) | |
442 | { | |
443 | if( (allData[2*in+25][iHit] - chargeQT1[in])>800 | |
444 | && chargeQT1[in]>0) | |
794ab872 | 445 | { |
794ab872 | 446 | chargeQT0[in]=allData[2*in+25][0]; |
794ab872 | 447 | AliDebug(25, Form(" readed Raw %i %i %i", |
448 | in, chargeQT0[in],chargeQT1[in])); | |
993257ce | 449 | break; |
794ab872 | 450 | } |
993257ce | 451 | } |
85f61e3b | 452 | } |
453 | for (Int_t in=12; in<24; in++) | |
454 | { | |
993257ce | 455 | for (Int_t iHit=0; iHit<5; iHit++) |
456 | { | |
4debc5c4 | 457 | if (allData[2*in+58][iHit] > fTime0vertex[0]+2000 && |
458 | allData[2*in+58][iHit] <fTime0vertex[0]+3000 ) | |
459 | { | |
460 | chargeQT1[in]=allData[2*in+58][0]; | |
461 | break; | |
462 | } | |
463 | } | |
464 | for (Int_t iHit=0; iHit<5; iHit++) | |
465 | { | |
466 | if( (allData[2*in+57][iHit] - chargeQT1[in])>800 && | |
467 | chargeQT1[in]>0 ) | |
468 | { | |
469 | chargeQT0[in]=allData[2*in+57][0]; | |
470 | AliDebug(25, Form(" readed Raw %i %i %i", | |
471 | in, chargeQT0[in],chargeQT1[in])); | |
472 | break; | |
473 | } | |
474 | } | |
85f61e3b | 475 | } |
476 | ||
8f226345 | 477 | onlineMean = allData[49][0]; |
478 | ||
195e1353 | 479 | Double32_t time[24], adc[24], adcmip[24], noncalibtime[24]; |
8f620945 | 480 | for (Int_t ipmt=0; ipmt<24; ipmt++) { |
5773ee77 | 481 | if(timeCFD[ipmt] > 0 && (chargeQT0[ipmt] - chargeQT1[ipmt])> 0 ){ |
482 | //for simulated data | |
d0bcd1fb | 483 | //for physics data |
993257ce | 484 | adc[ipmt] = chargeQT0[ipmt] - chargeQT1[ipmt]; |
c8d939c8 | 485 | Int_t refAmp = Int_t (fTime0vertex[ipmt]); |
486 | time[ipmt] = fCalib-> WalkCorrection( refAmp, ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ; | |
d0bcd1fb | 487 | Double_t sl = timeLED[ipmt] - timeCFD[ipmt]; |
8f620945 | 488 | // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ; |
73df58ab | 489 | AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", |
d0bcd1fb | 490 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); |
644a358e | 491 | Double_t ampMip = 0; |
492 | TGraph * ampGraph = (TGraph*)fAmpLED.At(ipmt); | |
493 | if (ampGraph) ampMip = ampGraph->Eval(sl); | |
494 | Double_t qtMip = 0; | |
495 | TGraph * qtGraph = (TGraph*)fQTC.At(ipmt); | |
496 | if (qtGraph) qtMip = qtGraph->Eval(adc[ipmt]); | |
345f03db | 497 | AliDebug(10,Form(" Amlitude in MIPS LED %f ; QTC %f; in channels %f\n ",ampMip,qtMip, adc[ipmt])); |
13e2fbbd | 498 | if( equalize ==0 ) |
499 | frecpoints.SetTime(ipmt, Float_t(time[ipmt]) ); | |
500 | else | |
501 | frecpoints.SetTime(ipmt, Float_t(time[ipmt] + fTime0vertex[ipmt]) ); | |
502 | // frecpoints.SetTime(ipmt, Float_t(time[ipmt] ) ); | |
4debc5c4 | 503 | if(qtMip<0) qtMip=0; |
ce50812a | 504 | frecpoints.SetAmp(ipmt, Double32_t( qtMip)); |
505 | adcmip[ipmt]=qtMip; | |
5773ee77 | 506 | frecpoints.SetAmpLED(ipmt, Double32_t(ampMip)); |
ce50812a | 507 | noncalibtime[ipmt]= Double32_t (timeCFD[ipmt]); |
13e2fbbd | 508 | } |
509 | else { | |
ce50812a | 510 | time[ipmt] = -9999; |
2e6a5ee0 | 511 | adc[ipmt] = 0; |
b0ab3f59 | 512 | adcmip[ipmt] = 0; |
ce50812a | 513 | noncalibtime[ipmt] = -9999; |
13e2fbbd | 514 | } |
2e6a5ee0 | 515 | } |
ce50812a | 516 | fESDTZEROfriend->SetT0timeCorr(noncalibtime) ; |
517 | ||
2e6a5ee0 | 518 | for (Int_t ipmt=0; ipmt<12; ipmt++){ |
ce50812a | 519 | if(time[ipmt] !=0 && time[ipmt] > -9000 |
520 | /*&& badpmt[ipmt]==0 */ | |
13e2fbbd | 521 | && adcmip[ipmt]>lowAmpThreshold ) |
73df58ab | 522 | { |
ce50812a | 523 | if(time[ipmt]<besttimeC) besttimeC=time[ipmt]; //timeC |
524 | if(TMath::Abs(time[ipmt])<TMath::Abs(besttimeC_best)) | |
525 | besttimeC_best=time[ipmt]; //timeC | |
2e6a5ee0 | 526 | } |
2e6a5ee0 | 527 | } |
73df58ab | 528 | for ( Int_t ipmt=12; ipmt<24; ipmt++) |
529 | { | |
ce50812a | 530 | if(time[ipmt] != 0 && time[ipmt] > -9000 |
531 | /* && badpmt[ipmt]==0*/ | |
13e2fbbd | 532 | && adcmip[ipmt]>lowAmpThreshold ) |
73df58ab | 533 | { |
ce50812a | 534 | if(time[ipmt]<besttimeA) besttimeA=time[ipmt]; |
535 | if(TMath::Abs(time[ipmt] ) < TMath::Abs(besttimeA_best)) | |
536 | besttimeA_best=time[ipmt]; //timeA | |
73df58ab | 537 | } |
2e6a5ee0 | 538 | } |
ce50812a | 539 | |
540 | if(besttimeA < 999999 && besttimeA!=0 ) { | |
541 | if( equalize ==0 ) | |
542 | frecpoints.SetTime1stA((besttimeA * channelWidth)- 1000.*fLatencyHPTDC + 1000.*fLatencyL1A - 1000.*fGRPdelays - fTimeMeanShift[1] ); | |
543 | else | |
544 | { | |
545 | frecpoints.SetTimeBestA((besttimeA_best * channelWidth )); | |
546 | frecpoints.SetTime1stA((besttimeA * channelWidth - fTimeMeanShift[1])); | |
547 | } | |
548 | } | |
549 | if( besttimeC < 999999 && besttimeC!=0) { | |
550 | if( equalize ==0 ) | |
551 | frecpoints.SetTime1stC((besttimeC * channelWidth)- 1000.*fLatencyHPTDC +1000.*fLatencyL1C - 1000.*fGRPdelays - fTimeMeanShift[2]); | |
552 | else | |
553 | { | |
554 | frecpoints.SetTimeBestC((besttimeC_best * channelWidth )); | |
555 | frecpoints.SetTime1stC((besttimeC * channelWidth - fTimeMeanShift[2])); | |
556 | } | |
557 | } | |
558 | AliDebug(5,Form("1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f ", | |
559 | besttimeA, besttimeA_best, | |
560 | besttimeC, besttimeC_best) ); | |
561 | AliDebug(5,Form("fRecPoints::: 1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f shiftA %f shiftC %f ", | |
562 | frecpoints.Get1stTimeA(), frecpoints.GetBestTimeA(), | |
563 | frecpoints.Get1stTimeC(), frecpoints.GetBestTimeC(), | |
564 | fTimeMeanShift[1],fTimeMeanShift[2] ) ); | |
565 | if( besttimeC < 999999 && besttimeA < 999999) { | |
c8d939c8 | 566 | if(equalize ==0 ) |
597a8434 | 567 | timeclock = (channelWidth*(besttimeC + besttimeA)/2.- 1000.*fLatencyHPTDC +1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0]); |
c8d939c8 | 568 | else |
569 | { | |
570 | timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - fTimeMeanShift[0]; | |
571 | meanTime = channelWidth * Float_t(besttimeA_best + besttimeC_best )/2.; | |
572 | } | |
612737bb | 573 | timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth ; |
9480f05f | 574 | vertex = meanVertex - c*(timeDiff)/2. ; //+ (fdZonA - fdZonC)/2; |
ce50812a | 575 | } |
576 | ||
776de217 | 577 | } //if phys event |
ce50812a | 578 | AliDebug(1,Form(" timeDiff %f #channel, meanTime %f #ps, TOFmean%f vertex %f cm meanVertex %f \n",timeDiff, meanTime,timeclock, vertex,meanVertex)); |
579 | frecpoints.SetT0clock(timeclock); | |
580 | frecpoints.SetVertex(vertex); | |
581 | frecpoints.SetMeanTime(meanTime); | |
582 | frecpoints.SetOnlineMean(Int_t(onlineMean)); | |
adf36b9d | 583 | |
ce50812a | 584 | // Set triggers |
adf36b9d | 585 | Bool_t tr[5]; |
92f6bfd3 | 586 | Int_t trchan[5] = {50,51,52,55,56}; |
587 | Float_t lowtr[5] = {meanTVDC-700, meanOrA-700, meanOrC-700, meanOrC-1000, meanOrC-1000 }; | |
588 | Float_t hightr[5] = {meanTVDC+700, meanOrA+700, meanOrC+700, meanOrC+1000, meanOrC+1000}; | |
ce50812a | 589 | |
82540e64 | 590 | for (Int_t i=0; i<5; i++) tr[i] = false; |
adf36b9d | 591 | for (Int_t itr=0; itr<5; itr++) { |
b0e13b29 | 592 | for (Int_t iHit=0; iHit<1; iHit++) |
38cbfa7c | 593 | { |
594 | Int_t trr=trchan[itr]; | |
92f6bfd3 | 595 | if( allData[trr][iHit] > lowtr[itr] && allData[trr][iHit] < hightr[itr]) tr[itr]=true; |
ce50812a | 596 | |
597 | AliDebug(15,Form("Reconstruct ::: T0 triggers iHit %i tvdc %d orA %d orC %d centr %d semicentral %d",iHit, tr[0],tr[1],tr[2],tr[3],tr[4])); | |
b0e13b29 | 598 | } |
adf36b9d | 599 | } |
7e08771f | 600 | frecpoints.SetT0Trig(tr); |
b0e13b29 | 601 | |
ce50812a | 602 | // all times with amplitude correction |
603 | Float_t timecent; | |
b0e13b29 | 604 | for (Int_t iHit=0; iHit<5; iHit++) |
605 | { | |
ce50812a | 606 | timefull = timecent = -9999; |
82540e64 | 607 | tvdc = ora = orc = -9999; |
b0e13b29 | 608 | if(allData[50][iHit]>0) |
609 | tvdc = (Float_t(allData[50][iHit]) - meanTVDC) * channelWidth* 0.001; | |
610 | if(allData[51][iHit]>0) | |
611 | ora = (Float_t(allData[51][iHit]) - meanOrA) * channelWidth* 0.001; | |
612 | ||
613 | if(allData[52][iHit]>0) | |
614 | orc = (Float_t(allData[52][iHit]) - meanOrC) * channelWidth* 0.001; | |
615 | ||
7e08771f | 616 | frecpoints.SetOrC( iHit, orc); |
617 | frecpoints.SetOrA( iHit, ora); | |
618 | frecpoints.SetTVDC( iHit, tvdc); | |
b0e13b29 | 619 | for (Int_t i0=0; i0<12; i0++) { |
ce50812a | 620 | if (equalize ==0 ) |
621 | timecent = fTime0vertex[i0] + timeDelayCFD[i0]; | |
622 | else | |
623 | timecent = fTime0vertex[i0]; | |
b0e13b29 | 624 | timefull = -9999; |
625 | if(allData[i0+1][iHit]>1) | |
ce50812a | 626 | timefull = (Float_t(allData[i0+1][iHit]) - timecent)* channelWidth* 0.001; |
7e08771f | 627 | frecpoints.SetTimeFull(i0, iHit,timefull) ; |
82540e64 | 628 | // if(allData[i0+1][iHit]>1) printf("i0 %d iHit %d data %d fTime0vertex %f timefull %f \n",i0, iHit, allData[i0+1][iHit], fTime0vertex[i0], timefull); |
b0e13b29 | 629 | |
630 | } | |
631 | ||
632 | for (Int_t i0=12; i0<24; i0++) { | |
633 | timefull = -9999; | |
ce50812a | 634 | if (equalize ==0 ) |
635 | timecent = fTime0vertex[i0] + timeDelayCFD[i0]; | |
636 | else | |
637 | timecent = fTime0vertex[i0]; | |
94b4f7e2 | 638 | if(allData[i0+45][iHit]>1) { |
ce50812a | 639 | timefull = (Float_t(allData[i0+45][iHit]) - timecent)* channelWidth* 0.001; |
94b4f7e2 | 640 | } |
82540e64 | 641 | // if(allData[i0+45][iHit]>1) printf("i0 %d iHit %d data %d fTime0vertex %f timefull %f \n",i0, iHit, allData[i0+45][iHit], fTime0vertex[i0], timefull); |
7e08771f | 642 | frecpoints.SetTimeFull(i0, iHit, timefull) ; |
b0e13b29 | 643 | } |
644 | } | |
645 | ||
646 | ||
669dc07f | 647 | //Set MPD |
4debc5c4 | 648 | Float_t mpda_start=0, mpdc_start=0; |
993257ce | 649 | for (Int_t iHit=0; iHit<5; iHit++) |
650 | { | |
651 | if (allData[54][iHit] > fTime0vertex[0]+2000 && | |
4debc5c4 | 652 | allData[54][iHit] <fTime0vertex[0]+3000 ) { |
653 | mpda_start=Float_t(allData[54][iHit]); | |
654 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDA start %f",iHit, mpda_start )); | |
655 | ||
993257ce | 656 | break; |
657 | } | |
658 | } | |
659 | for (Int_t iHit=0; iHit<5; iHit++) | |
4debc5c4 | 660 | { |
661 | if(allData[53][iHit] > fTime0vertex[0]+3000 && | |
662 | (allData[53][iHit]-mpda_start)>800 && mpda_start>0 && tr[1]) { | |
663 | frecpoints.SetMultA(Float_t(allData[53][iHit] - mpda_start) ); | |
664 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDA stop %i MPD %f",iHit, allData[53][iHit],Float_t(allData[53][iHit] - mpda_start) )); | |
993257ce | 665 | break; |
666 | } | |
4debc5c4 | 667 | } |
668 | for (Int_t iHit=0; iHit<5; iHit++) | |
669 | { | |
670 | if (allData[106][iHit] > fTime0vertex[0]+2000 && | |
671 | allData[106][iHit] <fTime0vertex[0]+3000 ) { | |
672 | mpdc_start=allData[54][iHit]; | |
673 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDC start %f ",iHit, mpdc_start)); | |
674 | break; | |
675 | } | |
676 | } | |
677 | for (Int_t iHit=0; iHit<5; iHit++) | |
678 | { | |
679 | if(allData[105][iHit] > fTime0vertex[0]+3000 && | |
680 | (allData[105][iHit]-mpdc_start)>800 && mpdc_start>0 && tr[2]) { | |
681 | frecpoints.SetMultC(Float_t(allData[105][iHit] - mpdc_start) ); | |
682 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDC stop %i MPD %f",iHit, allData[105][iHit],Float_t(allData[105][iHit] - mpdc_start) )); | |
683 | break; | |
684 | } | |
685 | } | |
669dc07f | 686 | } // if (else )raw data |
58bd3a16 | 687 | recTree->Fill(); |
58bd3a16 | 688 | } |
adf36b9d | 689 | |
690 | ||
ce50812a | 691 | //____________________________________________________________ |
adf36b9d | 692 | |
693 | void AliT0Reconstructor::FillESD(TTree */*digitsTree*/, TTree *clustersTree, AliESDEvent *pESD) const | |
694 | { | |
dc7ca31d | 695 | |
696 | /*************************************************** | |
697 | Resonstruct digits to vertex position | |
698 | ****************************************************/ | |
699 | ||
dc7ca31d | 700 | AliDebug(1,Form("Start FillESD T0")); |
b0ab3f59 | 701 | if(!pESD) { |
702 | AliError("No ESD Event"); | |
703 | return; | |
704 | } | |
4cbe597e | 705 | pESD ->SetT0spread(fTimeSigmaShift); |
706 | ||
36cde487 | 707 | |
58bd3a16 | 708 | Float_t channelWidth = fParam->GetChannelWidth() ; |
f7c2c2fc | 709 | Float_t c = 0.0299792458; // cm/ps |
adf36b9d | 710 | Float_t currentVertex=0, shift=0; |
291f31a1 | 711 | Int_t ncont=-1; |
adf36b9d | 712 | const AliESDVertex* vertex = pESD->GetPrimaryVertex(); |
713 | if (!vertex) vertex = pESD->GetPrimaryVertexSPD(); | |
714 | if (!vertex) vertex = pESD->GetPrimaryVertexTPC(); | |
715 | if (!vertex) vertex = pESD->GetVertex(); | |
716 | ||
717 | if (vertex) { | |
718 | AliDebug(2, Form("Got %s (%s) from ESD: %f", | |
719 | vertex->GetName(), vertex->GetTitle(), vertex->GetZ())); | |
720 | currentVertex = vertex->GetZ(); | |
721 | ||
722 | ncont = vertex->GetNContributors(); | |
291f31a1 | 723 | if(ncont>0 ) { |
adf36b9d | 724 | shift = currentVertex/c; |
adf36b9d | 725 | } |
726 | } | |
d76c31f4 | 727 | TTree *treeR = clustersTree; |
dc7ca31d | 728 | |
7e08771f | 729 | AliT0RecPoint frecpoints; |
730 | AliT0RecPoint * pfrecpoints = &frecpoints; | |
dc7ca31d | 731 | |
732 | AliDebug(1,Form("Start FillESD T0")); | |
733 | TBranch *brRec = treeR->GetBranch("T0"); | |
734 | if (brRec) { | |
7e08771f | 735 | brRec->SetAddress(&pfrecpoints); |
dc7ca31d | 736 | }else{ |
f16935f7 | 737 | AliError(Form("EXEC Branch T0 rec not found")); |
dc7ca31d | 738 | return; |
739 | } | |
73df58ab | 740 | |
741 | brRec->GetEntry(0); | |
742 | Double32_t amp[24], time[24], ampQTC[24], timecorr[24]; | |
743 | Double32_t* tcorr; | |
744 | for(Int_t i=0; i<24; i++) | |
745 | amp[i]=time[i]=ampQTC[i]=timecorr[i]=0; | |
746 | ||
ce50812a | 747 | //1st time |
73df58ab | 748 | Double32_t timeClock[3]; |
7e08771f | 749 | Double32_t zPosition = frecpoints.GetVertex(); |
830172c8 | 750 | |
ce50812a | 751 | timeClock[0] = frecpoints.GetT0clock() ; |
752 | timeClock[1] = frecpoints.Get1stTimeA() + shift; | |
753 | timeClock[2] = frecpoints.Get1stTimeC() - shift; | |
754 | //best time | |
755 | Double32_t timemean[3]; | |
756 | timemean[0] = frecpoints.GetMeanTime(); | |
757 | timemean[1] = frecpoints.GetBestTimeA() + shift; | |
758 | timemean[2] = frecpoints.GetBestTimeC() - shift; | |
759 | ||
760 | for(Int_t i=0; i<3; i++) { | |
761 | fESDTZERO->SetT0TOF(i,timeClock[i]); // interaction time (ns) | |
762 | fESDTZERO->SetT0TOFbest(i,timemean[i]); // interaction time (ns) | |
763 | } | |
73df58ab | 764 | for ( Int_t i=0; i<24; i++) { |
7e08771f | 765 | time[i] = frecpoints.GetTime(i); // ps to ns |
ce50812a | 766 | if ( time[i] != 0 && time[i]>-9999) { |
7e08771f | 767 | ampQTC[i] = frecpoints.GetAmp(i); |
768 | amp[i] = frecpoints.AmpLED(i); | |
612737bb | 769 | AliDebug(1,Form("T0: %i time %f ampQTC %f ampLED %f \n", i, time[i], ampQTC[i], amp[i])); |
85f61e3b | 770 | } |
73df58ab | 771 | } |
ce50812a | 772 | fESDTZERO->SetT0time(time); // best TOF on each PMT |
773 | fESDTZERO->SetT0amplitude(ampQTC); // number of particles(MIPs) on each PMT | |
7e08771f | 774 | Int_t trig= frecpoints.GetT0Trig(); |
775 | frecpoints.PrintTriggerSignals( trig); | |
92f6bfd3 | 776 | // printf(" !!!!! FillESD trigger %i \n",trig); |
b0e13b29 | 777 | fESDTZERO->SetT0Trig(trig); |
b0e13b29 | 778 | fESDTZERO->SetT0zVertex(zPosition); //vertex Z position |
669dc07f | 779 | |
7e08771f | 780 | Double32_t multA=frecpoints.GetMultA(); |
781 | Double32_t multC=frecpoints.GetMultC(); | |
b0e13b29 | 782 | fESDTZERO->SetMultA(multA); // for backward compatubility |
783 | fESDTZERO->SetMultC(multC); // for backward compatubility | |
784 | ||
785 | ||
786 | for (Int_t iHit =0; iHit<5; iHit++ ) { | |
82540e64 | 787 | AliDebug(10,Form("FillESD ::: iHit %i tvdc %f orA %f orC %f\n", iHit, |
7e08771f | 788 | frecpoints.GetTVDC(iHit), |
789 | frecpoints.GetOrA(iHit), | |
790 | frecpoints.GetOrC(iHit) )); | |
791 | fESDTZERO->SetTVDC(iHit,frecpoints.GetTVDC(iHit)); | |
792 | fESDTZERO->SetOrA(iHit,frecpoints.GetOrA(iHit)); | |
793 | fESDTZERO->SetOrC(iHit,frecpoints.GetOrC(iHit)); | |
b0e13b29 | 794 | |
795 | for (Int_t i0=0; i0<24; i0++) { | |
7e08771f | 796 | // if(frecpoints.GetTimeFull(i0,iHit)>0){ |
797 | // printf("FillESD ::: iHit %i cfd %i time %f \n", iHit, i0, frecpoints.GetTimeFull(i0,iHit)); | |
798 | fESDTZERO->SetTimeFull(i0, iHit,frecpoints.GetTimeFull(i0,iHit)); | |
94b4f7e2 | 799 | // } |
b0e13b29 | 800 | |
801 | } | |
802 | } | |
73df58ab | 803 | |
ce50812a | 804 | AliDebug(1,Form("T0: SPDshift %f Vertex %f (T0A+T0C)/2 best %f #ps T0signal %f ps OrA %f ps OrC %f ps T0trig %i\n",shift, zPosition, timemean[0], timeClock[0], timeClock[1], timeClock[2], trig)); |
b0e13b29 | 805 | |
ea1a8005 | 806 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
807 | // background flags | |
808 | Bool_t background = BackgroundFlag(); | |
809 | fESDTZERO->SetBackgroundFlag(background); | |
810 | Bool_t pileup = PileupFlag(); | |
811 | fESDTZERO->SetPileupFlag(pileup); | |
528890e5 | 812 | for (Int_t i=0; i<5; i++) { |
7e08771f | 813 | fESDTZERO->SetPileupTime(i, frecpoints.GetTVDC(i) ) ; |
814 | // printf("!!!!!! FillESD :: pileup %i %f %f \n", i,fESDTZERO->GetPileupTime(i), frecpoints.GetTVDC(i)); | |
528890e5 | 815 | } |
ea1a8005 | 816 | Bool_t sat = SatelliteFlag(); |
817 | fESDTZERO->SetSatelliteFlag(sat); | |
73df58ab | 818 | |
ea1a8005 | 819 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
73df58ab | 820 | if (pESD) { |
adf36b9d | 821 | |
73df58ab | 822 | AliESDfriend *fr = (AliESDfriend*)pESD->FindListObject("AliESDfriend"); |
823 | if (fr) { | |
82540e64 | 824 | AliDebug(10, Form("Writing TZERO friend data to ESD tree")); |
73df58ab | 825 | |
85f61e3b | 826 | // if (ncont>2) { |
73df58ab | 827 | tcorr = fESDTZEROfriend->GetT0timeCorr(); |
828 | for ( Int_t i=0; i<24; i++) { | |
85f61e3b | 829 | if(i<12 && time[i]>1) timecorr[i] = tcorr[i] - shift/channelWidth; |
830 | if(i>11 && time[i]>1) timecorr[i] = tcorr[i] + shift/channelWidth; | |
612737bb | 831 | if(time[i]>1) AliDebug(10,Form("T0 friend : %i time %f ampQTC %f ampLED %f \n", i, timecorr[i], ampQTC[i], amp[i])); |
58bd3a16 | 832 | } |
73df58ab | 833 | fESDTZEROfriend->SetT0timeCorr( timecorr) ; |
834 | fESDTZEROfriend->SetT0ampLEDminCFD(amp); | |
835 | fESDTZEROfriend->SetT0ampQTC(ampQTC); | |
85f61e3b | 836 | fr->SetTZEROfriend(fESDTZEROfriend); |
837 | // }// | |
58bd3a16 | 838 | } |
b0e13b29 | 839 | |
840 | pESD->SetTZEROData(fESDTZERO); | |
58bd3a16 | 841 | } |
73df58ab | 842 | |
dc7ca31d | 843 | } // vertex in 3 sigma |
844 | ||
ea1a8005 | 845 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
846 | //____________________________________________________________ | |
847 | ||
848 | Bool_t AliT0Reconstructor::PileupFlag() const | |
849 | { | |
850 | // | |
851 | Bool_t pileup = false; | |
528890e5 | 852 | Float_t tvdc[5]; |
ea1a8005 | 853 | for (Int_t ih=0; ih<5; ih++) |
854 | { | |
855 | tvdc[ih] = fESDTZERO->GetTVDC(ih); | |
856 | ||
528890e5 | 857 | if( tvdc[0] !=0 && tvdc[0]> -10 && tvdc[0]< 10 ) |
ea1a8005 | 858 | if(ih>0 && tvdc[ih]>20 ) pileup = true; |
528890e5 | 859 | if( tvdc[0] >20 || (tvdc[0] < -20 && tvdc[0] > -9000) ) pileup =true; |
860 | // if (pileup) printf(" !!!!! pile up %i tvdc %f \n",ih, tvdc[ih]); | |
ea1a8005 | 861 | } |
862 | ||
863 | ||
864 | return pileup; | |
865 | ||
866 | } | |
867 | ||
868 | //____________________________________________________________ | |
869 | ||
870 | Bool_t AliT0Reconstructor::BackgroundFlag() const | |
871 | { | |
9120829d | 872 | |
ea1a8005 | 873 | Bool_t background = false; |
9120829d | 874 | /* |
875 | Float_t orA = fESDTZERO->GetOrA(0); | |
876 | Float_t orC = fESDTZERO->GetOrC(0); | |
877 | Float_t tvdc = fESDTZERO->GetTVDC(ih); | |
878 | ||
879 | if ( (orA > -5 && orA <5) && (orC > -5 && orC <5) && (tvdc < -5 || tvdc > 5)) { | |
880 | background = true; | |
881 | // printf(" orA %f orC %f tvdc %f\n", orA, orC, tvdc); | |
882 | } | |
883 | */ | |
ea1a8005 | 884 | return background; |
885 | ||
886 | ||
887 | } | |
888 | ||
889 | ||
890 | //____________________________________________________________ | |
891 | ||
892 | Bool_t AliT0Reconstructor::SatelliteFlag() const | |
893 | { | |
894 | ||
ce50812a | 895 | Float_t satelliteLow = GetRecoParam() -> GetLowSatelliteThreshold(); |
896 | Float_t satelliteHigh = GetRecoParam() -> GetHighSatelliteThreshold(); | |
ea1a8005 | 897 | Bool_t satellite = false; |
898 | for (Int_t i0=0; i0<24; i0++) { | |
899 | Float_t timefull = fESDTZERO -> GetTimeFull(i0,0); | |
ce50812a | 900 | if( timefull > satelliteLow && timefull < satelliteHigh) satellite=true; |
ea1a8005 | 901 | } |
902 | ||
903 | return satellite; | |
904 | ||
905 | } |