]>
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 | } |
732e7ae4 | 332 | Int_t badLEDminCFD = GetRecoParam() -> GetHigh(350); |
ce50812a | 333 | Int_t equalize = GetRecoParam() -> GetEq(); |
732e7ae4 | 334 | AliDebug(10,Form( "AliT0Reconstructor::Reconstruct::: RecoParam %i LEDminCFD threshold %i \n",equalize, badLEDminCFD) ); |
ce50812a | 335 | fCalib->SetEq(equalize); |
d3e04608 | 336 | Int_t low[500], high[500]; |
13e2fbbd | 337 | Float_t timefull=-99999;; |
338 | Float_t tvdc = -99999; Float_t ora = -99999; Float_t orc = -99999; | |
993257ce | 339 | |
e8ed1cd0 | 340 | Int_t allData[110][5]; |
2e6a5ee0 | 341 | |
e8ed1cd0 | 342 | Int_t timeCFD[24], timeLED[24], chargeQT0[24], chargeQT1[24]; |
ce50812a | 343 | Float_t time2zero[24]; |
612737bb | 344 | Double32_t timeDiff, meanTime, timeclock; |
345 | timeDiff = meanTime = timeclock = 9999999; | |
adf36b9d | 346 | Float_t c = 29.9792458; // cm/ns |
347 | Double32_t vertex = 9999999; | |
776de217 | 348 | Int_t onlineMean=0; |
9480f05f | 349 | Float_t meanVertex = 0; |
b7fd8e80 | 350 | Int_t pedestal[24]; |
612737bb | 351 | for (Int_t i0=0; i0<24; i0++) { |
5773ee77 | 352 | low[i0] = Int_t(fTime0vertex[i0]) - corridor; |
353 | high[i0] = Int_t(fTime0vertex[i0]) + corridor; | |
354 | time2zero[i0] = 99999; | |
355 | pedestal[i0]=Int_t (GetRecoParam()->GetLow(100+i0) ); | |
612737bb | 356 | } |
357 | ||
669dc07f | 358 | for (Int_t i0=0; i0<110; i0++) |
b0e13b29 | 359 | for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0; |
612737bb | 360 | |
361 | Float_t lowAmpThreshold = GetRecoParam()->GetAmpLowThreshold(); | |
362 | Float_t highAmpThreshold = GetRecoParam()->GetAmpHighThreshold(); | |
fd3fb735 | 363 | |
ce50812a | 364 | Double32_t besttimeA=9999999; Double32_t besttimeA_best=9999999; |
365 | Double32_t besttimeC=9999999; Double32_t besttimeC_best=9999999; | |
366 | ||
367 | Float_t channelWidth = fParam->GetChannelWidth() ; | |
b0e13b29 | 368 | |
7e08771f | 369 | AliT0RecPoint frecpoints; |
370 | AliT0RecPoint * pfrecpoints = &frecpoints; | |
bce12dc5 | 371 | |
7e08771f | 372 | recTree->Branch( "T0", "AliT0RecPoint" ,&pfrecpoints); |
2e6a5ee0 | 373 | |
bce12dc5 | 374 | AliDebug(10," before read data "); |
375 | AliT0RawReader myrawreader(rawReader); | |
776de217 | 376 | |
377 | UInt_t type =rawReader->GetType(); | |
378 | ||
bce12dc5 | 379 | if (!myrawreader.Next()) |
380 | AliDebug(1,Form(" no raw data found!!")); | |
381 | else | |
382 | { | |
38cbfa7c | 383 | for (Int_t i=0; i<24; i++) |
384 | { | |
385 | timeCFD[i]=0; timeLED[i]=0; chargeQT0[i]=0; chargeQT1[i]=0; | |
386 | } | |
9120829d | 387 | |
38cbfa7c | 388 | if(type == 7 ) { //only physics |
669dc07f | 389 | for (Int_t i=0; i<107; i++) { |
bce12dc5 | 390 | for (Int_t iHit=0; iHit<5; iHit++) |
391 | { | |
392 | allData[i][iHit] = myrawreader.GetData(i,iHit); | |
393 | } | |
8f620945 | 394 | } |
8f620945 | 395 | |
9120829d | 396 | Int_t fBCID=Int_t (rawReader->GetBCID()); |
397 | Int_t trmbunch= myrawreader.GetTRMBunchID(); | |
398 | AliDebug(10,Form(" CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch )); | |
399 | if( (trmbunch-fBCID)!=37 ) { | |
400 | AliDebug(0,Form("wrong :::: CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch )); | |
401 | // type = -1; | |
402 | } | |
85f61e3b | 403 | for (Int_t in=0; in<12; in++) |
404 | { | |
405 | for (Int_t iHit=0; iHit<5; iHit++) | |
38cbfa7c | 406 | { |
612737bb | 407 | if(allData[in+1][iHit] > low[in] && |
408 | allData[in+1][iHit] < high[in]) | |
38cbfa7c | 409 | { |
85f61e3b | 410 | timeCFD[in] = allData[in+1][iHit] ; |
794ab872 | 411 | break; |
38cbfa7c | 412 | } |
85f61e3b | 413 | } |
414 | for (Int_t iHit=0; iHit<5; iHit++) | |
415 | { | |
794ab872 | 416 | if(allData[in+1+56][iHit] > low[in+12] && |
417 | allData[in+1+56][iHit] < high[in+12]) | |
38cbfa7c | 418 | { |
85f61e3b | 419 | timeCFD[in+12] = allData[in+56+1][iHit] ; |
420 | break; | |
38cbfa7c | 421 | } |
38cbfa7c | 422 | } |
612737bb | 423 | timeLED[in+12] = allData[in+68+1][0] ; |
424 | timeLED[in] = allData[in+12+1][0] ; | |
ce50812a | 425 | AliDebug(50, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ", |
85f61e3b | 426 | in, timeCFD[in],timeCFD[in+12],timeLED[in], |
612737bb | 427 | timeLED[in+12])); |
38cbfa7c | 428 | |
8f620945 | 429 | } |
430 | ||
85f61e3b | 431 | for (Int_t in=0; in<12; in++) |
432 | { | |
993257ce | 433 | for (Int_t iHit=0; iHit<5; iHit++) |
434 | { | |
435 | if (allData[2*in+26][iHit] > fTime0vertex[0]+2000 && | |
4debc5c4 | 436 | allData[2*in+26][iHit] <fTime0vertex[0]+3000 ) { |
437 | chargeQT1[in]=allData[2*in+26][0]; | |
438 | break; | |
439 | } | |
440 | } | |
441 | ||
442 | for (Int_t iHit=0; iHit<5; iHit++) | |
443 | { | |
444 | if( (allData[2*in+25][iHit] - chargeQT1[in])>800 | |
445 | && chargeQT1[in]>0) | |
794ab872 | 446 | { |
794ab872 | 447 | chargeQT0[in]=allData[2*in+25][0]; |
794ab872 | 448 | AliDebug(25, Form(" readed Raw %i %i %i", |
449 | in, chargeQT0[in],chargeQT1[in])); | |
993257ce | 450 | break; |
794ab872 | 451 | } |
993257ce | 452 | } |
85f61e3b | 453 | } |
454 | for (Int_t in=12; in<24; in++) | |
455 | { | |
993257ce | 456 | for (Int_t iHit=0; iHit<5; iHit++) |
457 | { | |
4debc5c4 | 458 | if (allData[2*in+58][iHit] > fTime0vertex[0]+2000 && |
459 | allData[2*in+58][iHit] <fTime0vertex[0]+3000 ) | |
460 | { | |
461 | chargeQT1[in]=allData[2*in+58][0]; | |
462 | break; | |
463 | } | |
464 | } | |
465 | for (Int_t iHit=0; iHit<5; iHit++) | |
466 | { | |
467 | if( (allData[2*in+57][iHit] - chargeQT1[in])>800 && | |
468 | chargeQT1[in]>0 ) | |
469 | { | |
470 | chargeQT0[in]=allData[2*in+57][0]; | |
471 | AliDebug(25, Form(" readed Raw %i %i %i", | |
472 | in, chargeQT0[in],chargeQT1[in])); | |
473 | break; | |
474 | } | |
475 | } | |
85f61e3b | 476 | } |
477 | ||
8f226345 | 478 | onlineMean = allData[49][0]; |
479 | ||
195e1353 | 480 | Double32_t time[24], adc[24], adcmip[24], noncalibtime[24]; |
8f620945 | 481 | for (Int_t ipmt=0; ipmt<24; ipmt++) { |
732e7ae4 | 482 | if(timeCFD[ipmt] > 0 && (chargeQT0[ipmt] - chargeQT1[ipmt])> 0 && |
483 | (timeLED[ipmt]-timeCFD[ipmt])<badLEDminCFD){ | |
5773ee77 | 484 | //for simulated data |
d0bcd1fb | 485 | //for physics data |
993257ce | 486 | adc[ipmt] = chargeQT0[ipmt] - chargeQT1[ipmt]; |
c8d939c8 | 487 | Int_t refAmp = Int_t (fTime0vertex[ipmt]); |
488 | time[ipmt] = fCalib-> WalkCorrection( refAmp, ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ; | |
d0bcd1fb | 489 | Double_t sl = timeLED[ipmt] - timeCFD[ipmt]; |
8f620945 | 490 | // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ; |
73df58ab | 491 | AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", |
d0bcd1fb | 492 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); |
644a358e | 493 | Double_t ampMip = 0; |
494 | TGraph * ampGraph = (TGraph*)fAmpLED.At(ipmt); | |
495 | if (ampGraph) ampMip = ampGraph->Eval(sl); | |
496 | Double_t qtMip = 0; | |
497 | TGraph * qtGraph = (TGraph*)fQTC.At(ipmt); | |
498 | if (qtGraph) qtMip = qtGraph->Eval(adc[ipmt]); | |
345f03db | 499 | AliDebug(10,Form(" Amlitude in MIPS LED %f ; QTC %f; in channels %f\n ",ampMip,qtMip, adc[ipmt])); |
13e2fbbd | 500 | if( equalize ==0 ) |
501 | frecpoints.SetTime(ipmt, Float_t(time[ipmt]) ); | |
502 | else | |
503 | frecpoints.SetTime(ipmt, Float_t(time[ipmt] + fTime0vertex[ipmt]) ); | |
504 | // frecpoints.SetTime(ipmt, Float_t(time[ipmt] ) ); | |
4debc5c4 | 505 | if(qtMip<0) qtMip=0; |
ce50812a | 506 | frecpoints.SetAmp(ipmt, Double32_t( qtMip)); |
507 | adcmip[ipmt]=qtMip; | |
5773ee77 | 508 | frecpoints.SetAmpLED(ipmt, Double32_t(ampMip)); |
ce50812a | 509 | noncalibtime[ipmt]= Double32_t (timeCFD[ipmt]); |
13e2fbbd | 510 | } |
511 | else { | |
ce50812a | 512 | time[ipmt] = -9999; |
2e6a5ee0 | 513 | adc[ipmt] = 0; |
b0ab3f59 | 514 | adcmip[ipmt] = 0; |
ce50812a | 515 | noncalibtime[ipmt] = -9999; |
13e2fbbd | 516 | } |
2e6a5ee0 | 517 | } |
ce50812a | 518 | fESDTZEROfriend->SetT0timeCorr(noncalibtime) ; |
519 | ||
2e6a5ee0 | 520 | for (Int_t ipmt=0; ipmt<12; ipmt++){ |
ce50812a | 521 | if(time[ipmt] !=0 && time[ipmt] > -9000 |
522 | /*&& badpmt[ipmt]==0 */ | |
13e2fbbd | 523 | && adcmip[ipmt]>lowAmpThreshold ) |
73df58ab | 524 | { |
ce50812a | 525 | if(time[ipmt]<besttimeC) besttimeC=time[ipmt]; //timeC |
526 | if(TMath::Abs(time[ipmt])<TMath::Abs(besttimeC_best)) | |
527 | besttimeC_best=time[ipmt]; //timeC | |
2e6a5ee0 | 528 | } |
2e6a5ee0 | 529 | } |
73df58ab | 530 | for ( Int_t ipmt=12; ipmt<24; ipmt++) |
531 | { | |
ce50812a | 532 | if(time[ipmt] != 0 && time[ipmt] > -9000 |
533 | /* && badpmt[ipmt]==0*/ | |
13e2fbbd | 534 | && adcmip[ipmt]>lowAmpThreshold ) |
73df58ab | 535 | { |
ce50812a | 536 | if(time[ipmt]<besttimeA) besttimeA=time[ipmt]; |
537 | if(TMath::Abs(time[ipmt] ) < TMath::Abs(besttimeA_best)) | |
538 | besttimeA_best=time[ipmt]; //timeA | |
73df58ab | 539 | } |
2e6a5ee0 | 540 | } |
ce50812a | 541 | |
542 | if(besttimeA < 999999 && besttimeA!=0 ) { | |
543 | if( equalize ==0 ) | |
544 | frecpoints.SetTime1stA((besttimeA * channelWidth)- 1000.*fLatencyHPTDC + 1000.*fLatencyL1A - 1000.*fGRPdelays - fTimeMeanShift[1] ); | |
545 | else | |
546 | { | |
547 | frecpoints.SetTimeBestA((besttimeA_best * channelWidth )); | |
548 | frecpoints.SetTime1stA((besttimeA * channelWidth - fTimeMeanShift[1])); | |
549 | } | |
550 | } | |
551 | if( besttimeC < 999999 && besttimeC!=0) { | |
552 | if( equalize ==0 ) | |
553 | frecpoints.SetTime1stC((besttimeC * channelWidth)- 1000.*fLatencyHPTDC +1000.*fLatencyL1C - 1000.*fGRPdelays - fTimeMeanShift[2]); | |
554 | else | |
555 | { | |
556 | frecpoints.SetTimeBestC((besttimeC_best * channelWidth )); | |
557 | frecpoints.SetTime1stC((besttimeC * channelWidth - fTimeMeanShift[2])); | |
558 | } | |
559 | } | |
560 | AliDebug(5,Form("1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f ", | |
561 | besttimeA, besttimeA_best, | |
562 | besttimeC, besttimeC_best) ); | |
563 | AliDebug(5,Form("fRecPoints::: 1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f shiftA %f shiftC %f ", | |
564 | frecpoints.Get1stTimeA(), frecpoints.GetBestTimeA(), | |
565 | frecpoints.Get1stTimeC(), frecpoints.GetBestTimeC(), | |
566 | fTimeMeanShift[1],fTimeMeanShift[2] ) ); | |
567 | if( besttimeC < 999999 && besttimeA < 999999) { | |
c8d939c8 | 568 | if(equalize ==0 ) |
597a8434 | 569 | timeclock = (channelWidth*(besttimeC + besttimeA)/2.- 1000.*fLatencyHPTDC +1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0]); |
c8d939c8 | 570 | else |
571 | { | |
572 | timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - fTimeMeanShift[0]; | |
573 | meanTime = channelWidth * Float_t(besttimeA_best + besttimeC_best )/2.; | |
574 | } | |
612737bb | 575 | timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth ; |
9480f05f | 576 | vertex = meanVertex - c*(timeDiff)/2. ; //+ (fdZonA - fdZonC)/2; |
ce50812a | 577 | } |
578 | ||
776de217 | 579 | } //if phys event |
ce50812a | 580 | AliDebug(1,Form(" timeDiff %f #channel, meanTime %f #ps, TOFmean%f vertex %f cm meanVertex %f \n",timeDiff, meanTime,timeclock, vertex,meanVertex)); |
581 | frecpoints.SetT0clock(timeclock); | |
582 | frecpoints.SetVertex(vertex); | |
583 | frecpoints.SetMeanTime(meanTime); | |
584 | frecpoints.SetOnlineMean(Int_t(onlineMean)); | |
adf36b9d | 585 | |
ce50812a | 586 | // Set triggers |
adf36b9d | 587 | Bool_t tr[5]; |
92f6bfd3 | 588 | Int_t trchan[5] = {50,51,52,55,56}; |
589 | Float_t lowtr[5] = {meanTVDC-700, meanOrA-700, meanOrC-700, meanOrC-1000, meanOrC-1000 }; | |
590 | Float_t hightr[5] = {meanTVDC+700, meanOrA+700, meanOrC+700, meanOrC+1000, meanOrC+1000}; | |
ce50812a | 591 | |
82540e64 | 592 | for (Int_t i=0; i<5; i++) tr[i] = false; |
adf36b9d | 593 | for (Int_t itr=0; itr<5; itr++) { |
b0e13b29 | 594 | for (Int_t iHit=0; iHit<1; iHit++) |
38cbfa7c | 595 | { |
596 | Int_t trr=trchan[itr]; | |
92f6bfd3 | 597 | if( allData[trr][iHit] > lowtr[itr] && allData[trr][iHit] < hightr[itr]) tr[itr]=true; |
ce50812a | 598 | |
599 | 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 | 600 | } |
adf36b9d | 601 | } |
7e08771f | 602 | frecpoints.SetT0Trig(tr); |
b0e13b29 | 603 | |
ce50812a | 604 | // all times with amplitude correction |
605 | Float_t timecent; | |
b0e13b29 | 606 | for (Int_t iHit=0; iHit<5; iHit++) |
607 | { | |
ce50812a | 608 | timefull = timecent = -9999; |
82540e64 | 609 | tvdc = ora = orc = -9999; |
b0e13b29 | 610 | if(allData[50][iHit]>0) |
611 | tvdc = (Float_t(allData[50][iHit]) - meanTVDC) * channelWidth* 0.001; | |
612 | if(allData[51][iHit]>0) | |
613 | ora = (Float_t(allData[51][iHit]) - meanOrA) * channelWidth* 0.001; | |
614 | ||
615 | if(allData[52][iHit]>0) | |
616 | orc = (Float_t(allData[52][iHit]) - meanOrC) * channelWidth* 0.001; | |
617 | ||
7e08771f | 618 | frecpoints.SetOrC( iHit, orc); |
619 | frecpoints.SetOrA( iHit, ora); | |
620 | frecpoints.SetTVDC( iHit, tvdc); | |
b0e13b29 | 621 | for (Int_t i0=0; i0<12; i0++) { |
ce50812a | 622 | if (equalize ==0 ) |
623 | timecent = fTime0vertex[i0] + timeDelayCFD[i0]; | |
624 | else | |
625 | timecent = fTime0vertex[i0]; | |
b0e13b29 | 626 | timefull = -9999; |
627 | if(allData[i0+1][iHit]>1) | |
ce50812a | 628 | timefull = (Float_t(allData[i0+1][iHit]) - timecent)* channelWidth* 0.001; |
7e08771f | 629 | frecpoints.SetTimeFull(i0, iHit,timefull) ; |
82540e64 | 630 | // 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 | 631 | |
632 | } | |
633 | ||
634 | for (Int_t i0=12; i0<24; i0++) { | |
635 | timefull = -9999; | |
ce50812a | 636 | if (equalize ==0 ) |
637 | timecent = fTime0vertex[i0] + timeDelayCFD[i0]; | |
638 | else | |
639 | timecent = fTime0vertex[i0]; | |
94b4f7e2 | 640 | if(allData[i0+45][iHit]>1) { |
ce50812a | 641 | timefull = (Float_t(allData[i0+45][iHit]) - timecent)* channelWidth* 0.001; |
94b4f7e2 | 642 | } |
82540e64 | 643 | // 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 | 644 | frecpoints.SetTimeFull(i0, iHit, timefull) ; |
b0e13b29 | 645 | } |
646 | } | |
647 | ||
648 | ||
669dc07f | 649 | //Set MPD |
4debc5c4 | 650 | Float_t mpda_start=0, mpdc_start=0; |
993257ce | 651 | for (Int_t iHit=0; iHit<5; iHit++) |
652 | { | |
653 | if (allData[54][iHit] > fTime0vertex[0]+2000 && | |
4debc5c4 | 654 | allData[54][iHit] <fTime0vertex[0]+3000 ) { |
655 | mpda_start=Float_t(allData[54][iHit]); | |
656 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDA start %f",iHit, mpda_start )); | |
657 | ||
993257ce | 658 | break; |
659 | } | |
660 | } | |
661 | for (Int_t iHit=0; iHit<5; iHit++) | |
4debc5c4 | 662 | { |
663 | if(allData[53][iHit] > fTime0vertex[0]+3000 && | |
664 | (allData[53][iHit]-mpda_start)>800 && mpda_start>0 && tr[1]) { | |
665 | frecpoints.SetMultA(Float_t(allData[53][iHit] - mpda_start) ); | |
666 | 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 | 667 | break; |
668 | } | |
4debc5c4 | 669 | } |
670 | for (Int_t iHit=0; iHit<5; iHit++) | |
671 | { | |
672 | if (allData[106][iHit] > fTime0vertex[0]+2000 && | |
673 | allData[106][iHit] <fTime0vertex[0]+3000 ) { | |
674 | mpdc_start=allData[54][iHit]; | |
675 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDC start %f ",iHit, mpdc_start)); | |
676 | break; | |
677 | } | |
678 | } | |
679 | for (Int_t iHit=0; iHit<5; iHit++) | |
680 | { | |
681 | if(allData[105][iHit] > fTime0vertex[0]+3000 && | |
682 | (allData[105][iHit]-mpdc_start)>800 && mpdc_start>0 && tr[2]) { | |
683 | frecpoints.SetMultC(Float_t(allData[105][iHit] - mpdc_start) ); | |
684 | AliDebug(15,Form("Reconstruct ::: T0 MPD iHit %i MPDC stop %i MPD %f",iHit, allData[105][iHit],Float_t(allData[105][iHit] - mpdc_start) )); | |
685 | break; | |
686 | } | |
687 | } | |
669dc07f | 688 | } // if (else )raw data |
58bd3a16 | 689 | recTree->Fill(); |
58bd3a16 | 690 | } |
adf36b9d | 691 | |
692 | ||
ce50812a | 693 | //____________________________________________________________ |
adf36b9d | 694 | |
695 | void AliT0Reconstructor::FillESD(TTree */*digitsTree*/, TTree *clustersTree, AliESDEvent *pESD) const | |
696 | { | |
dc7ca31d | 697 | |
698 | /*************************************************** | |
699 | Resonstruct digits to vertex position | |
700 | ****************************************************/ | |
701 | ||
dc7ca31d | 702 | AliDebug(1,Form("Start FillESD T0")); |
b0ab3f59 | 703 | if(!pESD) { |
704 | AliError("No ESD Event"); | |
705 | return; | |
706 | } | |
4cbe597e | 707 | pESD ->SetT0spread(fTimeSigmaShift); |
708 | ||
36cde487 | 709 | |
58bd3a16 | 710 | Float_t channelWidth = fParam->GetChannelWidth() ; |
f7c2c2fc | 711 | Float_t c = 0.0299792458; // cm/ps |
adf36b9d | 712 | Float_t currentVertex=0, shift=0; |
291f31a1 | 713 | Int_t ncont=-1; |
adf36b9d | 714 | const AliESDVertex* vertex = pESD->GetPrimaryVertex(); |
715 | if (!vertex) vertex = pESD->GetPrimaryVertexSPD(); | |
716 | if (!vertex) vertex = pESD->GetPrimaryVertexTPC(); | |
717 | if (!vertex) vertex = pESD->GetVertex(); | |
718 | ||
719 | if (vertex) { | |
720 | AliDebug(2, Form("Got %s (%s) from ESD: %f", | |
721 | vertex->GetName(), vertex->GetTitle(), vertex->GetZ())); | |
722 | currentVertex = vertex->GetZ(); | |
723 | ||
724 | ncont = vertex->GetNContributors(); | |
291f31a1 | 725 | if(ncont>0 ) { |
adf36b9d | 726 | shift = currentVertex/c; |
adf36b9d | 727 | } |
728 | } | |
d76c31f4 | 729 | TTree *treeR = clustersTree; |
dc7ca31d | 730 | |
7e08771f | 731 | AliT0RecPoint frecpoints; |
732 | AliT0RecPoint * pfrecpoints = &frecpoints; | |
dc7ca31d | 733 | |
734 | AliDebug(1,Form("Start FillESD T0")); | |
735 | TBranch *brRec = treeR->GetBranch("T0"); | |
736 | if (brRec) { | |
7e08771f | 737 | brRec->SetAddress(&pfrecpoints); |
dc7ca31d | 738 | }else{ |
f16935f7 | 739 | AliError(Form("EXEC Branch T0 rec not found")); |
dc7ca31d | 740 | return; |
741 | } | |
73df58ab | 742 | |
743 | brRec->GetEntry(0); | |
744 | Double32_t amp[24], time[24], ampQTC[24], timecorr[24]; | |
745 | Double32_t* tcorr; | |
746 | for(Int_t i=0; i<24; i++) | |
747 | amp[i]=time[i]=ampQTC[i]=timecorr[i]=0; | |
748 | ||
ce50812a | 749 | //1st time |
73df58ab | 750 | Double32_t timeClock[3]; |
7e08771f | 751 | Double32_t zPosition = frecpoints.GetVertex(); |
830172c8 | 752 | |
ce50812a | 753 | timeClock[0] = frecpoints.GetT0clock() ; |
754 | timeClock[1] = frecpoints.Get1stTimeA() + shift; | |
755 | timeClock[2] = frecpoints.Get1stTimeC() - shift; | |
756 | //best time | |
757 | Double32_t timemean[3]; | |
758 | timemean[0] = frecpoints.GetMeanTime(); | |
759 | timemean[1] = frecpoints.GetBestTimeA() + shift; | |
760 | timemean[2] = frecpoints.GetBestTimeC() - shift; | |
761 | ||
762 | for(Int_t i=0; i<3; i++) { | |
763 | fESDTZERO->SetT0TOF(i,timeClock[i]); // interaction time (ns) | |
764 | fESDTZERO->SetT0TOFbest(i,timemean[i]); // interaction time (ns) | |
765 | } | |
73df58ab | 766 | for ( Int_t i=0; i<24; i++) { |
7e08771f | 767 | time[i] = frecpoints.GetTime(i); // ps to ns |
ce50812a | 768 | if ( time[i] != 0 && time[i]>-9999) { |
7e08771f | 769 | ampQTC[i] = frecpoints.GetAmp(i); |
770 | amp[i] = frecpoints.AmpLED(i); | |
612737bb | 771 | AliDebug(1,Form("T0: %i time %f ampQTC %f ampLED %f \n", i, time[i], ampQTC[i], amp[i])); |
85f61e3b | 772 | } |
73df58ab | 773 | } |
ce50812a | 774 | fESDTZERO->SetT0time(time); // best TOF on each PMT |
775 | fESDTZERO->SetT0amplitude(ampQTC); // number of particles(MIPs) on each PMT | |
7e08771f | 776 | Int_t trig= frecpoints.GetT0Trig(); |
777 | frecpoints.PrintTriggerSignals( trig); | |
92f6bfd3 | 778 | // printf(" !!!!! FillESD trigger %i \n",trig); |
b0e13b29 | 779 | fESDTZERO->SetT0Trig(trig); |
b0e13b29 | 780 | fESDTZERO->SetT0zVertex(zPosition); //vertex Z position |
669dc07f | 781 | |
7e08771f | 782 | Double32_t multA=frecpoints.GetMultA(); |
783 | Double32_t multC=frecpoints.GetMultC(); | |
b0e13b29 | 784 | fESDTZERO->SetMultA(multA); // for backward compatubility |
785 | fESDTZERO->SetMultC(multC); // for backward compatubility | |
786 | ||
787 | ||
788 | for (Int_t iHit =0; iHit<5; iHit++ ) { | |
82540e64 | 789 | AliDebug(10,Form("FillESD ::: iHit %i tvdc %f orA %f orC %f\n", iHit, |
7e08771f | 790 | frecpoints.GetTVDC(iHit), |
791 | frecpoints.GetOrA(iHit), | |
792 | frecpoints.GetOrC(iHit) )); | |
793 | fESDTZERO->SetTVDC(iHit,frecpoints.GetTVDC(iHit)); | |
794 | fESDTZERO->SetOrA(iHit,frecpoints.GetOrA(iHit)); | |
795 | fESDTZERO->SetOrC(iHit,frecpoints.GetOrC(iHit)); | |
b0e13b29 | 796 | |
797 | for (Int_t i0=0; i0<24; i0++) { | |
7e08771f | 798 | // if(frecpoints.GetTimeFull(i0,iHit)>0){ |
799 | // printf("FillESD ::: iHit %i cfd %i time %f \n", iHit, i0, frecpoints.GetTimeFull(i0,iHit)); | |
800 | fESDTZERO->SetTimeFull(i0, iHit,frecpoints.GetTimeFull(i0,iHit)); | |
94b4f7e2 | 801 | // } |
b0e13b29 | 802 | |
803 | } | |
804 | } | |
73df58ab | 805 | |
ce50812a | 806 | 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 | 807 | |
ea1a8005 | 808 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
809 | // background flags | |
810 | Bool_t background = BackgroundFlag(); | |
811 | fESDTZERO->SetBackgroundFlag(background); | |
812 | Bool_t pileup = PileupFlag(); | |
813 | fESDTZERO->SetPileupFlag(pileup); | |
528890e5 | 814 | for (Int_t i=0; i<5; i++) { |
7e08771f | 815 | fESDTZERO->SetPileupTime(i, frecpoints.GetTVDC(i) ) ; |
816 | // printf("!!!!!! FillESD :: pileup %i %f %f \n", i,fESDTZERO->GetPileupTime(i), frecpoints.GetTVDC(i)); | |
528890e5 | 817 | } |
ea1a8005 | 818 | Bool_t sat = SatelliteFlag(); |
819 | fESDTZERO->SetSatelliteFlag(sat); | |
73df58ab | 820 | |
ea1a8005 | 821 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
73df58ab | 822 | if (pESD) { |
adf36b9d | 823 | |
73df58ab | 824 | AliESDfriend *fr = (AliESDfriend*)pESD->FindListObject("AliESDfriend"); |
825 | if (fr) { | |
82540e64 | 826 | AliDebug(10, Form("Writing TZERO friend data to ESD tree")); |
73df58ab | 827 | |
85f61e3b | 828 | // if (ncont>2) { |
73df58ab | 829 | tcorr = fESDTZEROfriend->GetT0timeCorr(); |
830 | for ( Int_t i=0; i<24; i++) { | |
85f61e3b | 831 | if(i<12 && time[i]>1) timecorr[i] = tcorr[i] - shift/channelWidth; |
832 | if(i>11 && time[i]>1) timecorr[i] = tcorr[i] + shift/channelWidth; | |
612737bb | 833 | 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 | 834 | } |
73df58ab | 835 | fESDTZEROfriend->SetT0timeCorr( timecorr) ; |
836 | fESDTZEROfriend->SetT0ampLEDminCFD(amp); | |
837 | fESDTZEROfriend->SetT0ampQTC(ampQTC); | |
85f61e3b | 838 | fr->SetTZEROfriend(fESDTZEROfriend); |
839 | // }// | |
58bd3a16 | 840 | } |
b0e13b29 | 841 | |
842 | pESD->SetTZEROData(fESDTZERO); | |
58bd3a16 | 843 | } |
73df58ab | 844 | |
dc7ca31d | 845 | } // vertex in 3 sigma |
846 | ||
ea1a8005 | 847 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
848 | //____________________________________________________________ | |
849 | ||
850 | Bool_t AliT0Reconstructor::PileupFlag() const | |
851 | { | |
852 | // | |
853 | Bool_t pileup = false; | |
528890e5 | 854 | Float_t tvdc[5]; |
ea1a8005 | 855 | for (Int_t ih=0; ih<5; ih++) |
856 | { | |
857 | tvdc[ih] = fESDTZERO->GetTVDC(ih); | |
858 | ||
528890e5 | 859 | if( tvdc[0] !=0 && tvdc[0]> -10 && tvdc[0]< 10 ) |
ea1a8005 | 860 | if(ih>0 && tvdc[ih]>20 ) pileup = true; |
528890e5 | 861 | if( tvdc[0] >20 || (tvdc[0] < -20 && tvdc[0] > -9000) ) pileup =true; |
862 | // if (pileup) printf(" !!!!! pile up %i tvdc %f \n",ih, tvdc[ih]); | |
ea1a8005 | 863 | } |
864 | ||
865 | ||
866 | return pileup; | |
867 | ||
868 | } | |
869 | ||
870 | //____________________________________________________________ | |
871 | ||
872 | Bool_t AliT0Reconstructor::BackgroundFlag() const | |
873 | { | |
9120829d | 874 | |
ea1a8005 | 875 | Bool_t background = false; |
9120829d | 876 | /* |
877 | Float_t orA = fESDTZERO->GetOrA(0); | |
878 | Float_t orC = fESDTZERO->GetOrC(0); | |
879 | Float_t tvdc = fESDTZERO->GetTVDC(ih); | |
880 | ||
881 | if ( (orA > -5 && orA <5) && (orC > -5 && orC <5) && (tvdc < -5 || tvdc > 5)) { | |
882 | background = true; | |
883 | // printf(" orA %f orC %f tvdc %f\n", orA, orC, tvdc); | |
884 | } | |
885 | */ | |
ea1a8005 | 886 | return background; |
887 | ||
888 | ||
889 | } | |
890 | ||
891 | ||
892 | //____________________________________________________________ | |
893 | ||
894 | Bool_t AliT0Reconstructor::SatelliteFlag() const | |
895 | { | |
896 | ||
ce50812a | 897 | Float_t satelliteLow = GetRecoParam() -> GetLowSatelliteThreshold(); |
898 | Float_t satelliteHigh = GetRecoParam() -> GetHighSatelliteThreshold(); | |
ea1a8005 | 899 | Bool_t satellite = false; |
900 | for (Int_t i0=0; i0<24; i0++) { | |
901 | Float_t timefull = fESDTZERO -> GetTimeFull(i0,0); | |
ce50812a | 902 | if( timefull > satelliteLow && timefull < satelliteHigh) satellite=true; |
ea1a8005 | 903 | } |
904 | ||
905 | return satellite; | |
906 | ||
907 | } |