]>
Commit | Line | Data |
---|---|---|
73df58ab | 1 | |
1b9fc3b4 | 2 | |
dc7ca31d | 3 | /************************************************************************** |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Author: The ALICE Off-line Project. * | |
7 | * Contributors are mentioned in the code where appropriate. * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /* $Id$ */ | |
72e48d95 | 19 | /********************************************************************* |
20 | * T0 reconstruction and filling ESD | |
21 | * - reconstruct mean time (interation time) | |
22 | * - vertex position | |
23 | * - multiplicity | |
24 | ********************************************************************/ | |
dc7ca31d | 25 | |
af885e0f | 26 | #include <AliESDEvent.h> |
dc7ca31d | 27 | #include "AliLog.h" |
dc7ca31d | 28 | #include "AliT0RecPoint.h" |
29 | #include "AliRawReader.h" | |
30 | #include "AliT0RawReader.h" | |
dc7ca31d | 31 | #include "AliT0digit.h" |
32 | #include "AliT0Reconstructor.h" | |
33 | #include "AliT0Parameters.h" | |
c41ceaac | 34 | #include "AliT0Calibrator.h" |
58bd3a16 | 35 | #include "AliESDfriend.h" |
73df58ab | 36 | #include "AliESDTZEROfriend.h" |
8f8d0732 | 37 | #include "AliLog.h" |
85f61e3b | 38 | #include "AliCDBEntry.h" |
39 | #include "AliCDBManager.h" | |
40 | #include "AliCTPTimeParams.h" | |
41 | #include "AliLHCClockPhase.h" | |
669dc07f | 42 | #include "AliT0CalibSeasonTimeShift.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), | |
73df58ab | 67 | fESDTZEROfriend(NULL) |
58bd3a16 | 68 | |
e0bba6cc | 69 | { |
72e48d95 | 70 | //constructor |
85f61e3b | 71 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming"); |
72 | if (!entry) AliFatal("CTP timing parameters are not found in OCDB !"); | |
73 | AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject(); | |
74 | Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0; | |
75 | ||
76 | AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign"); | |
77 | if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !"); | |
78 | AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject(); | |
79 | l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0); | |
80 | ||
81 | AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase"); | |
82 | if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !"); | |
83 | AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject(); | |
84 | ||
85f61e3b | 85 | fGRPdelays = l1Delay - phase->GetMeanPhase(); |
72e48d95 | 86 | |
669dc07f | 87 | AliCDBEntry *entry5 = AliCDBManager::Instance()->Get("T0/Calib/TimeAdjust"); |
88 | if (entry5) { | |
89 | AliT0CalibSeasonTimeShift *timeshift = (AliT0CalibSeasonTimeShift*)entry5->GetObject(); | |
90 | fTimeMeanShift = timeshift->GetT0Means(); | |
91 | fTimeSigmaShift = timeshift->GetT0Sigmas(); | |
92 | timeshift->Print(); | |
93 | } | |
94 | else | |
95 | AliWarning("Time Adjust is not found in OCDB !"); | |
96 | ||
74adb36a | 97 | fParam = AliT0Parameters::Instance(); |
98 | fParam->Init(); | |
c883fdf2 | 99 | |
74adb36a | 100 | for (Int_t i=0; i<24; i++){ |
2e6a5ee0 | 101 | TGraph* gr = fParam ->GetAmpLEDRec(i); |
29ed1d0e | 102 | if (gr) fAmpLEDrec.AddAtAndExpand(gr,i) ; |
c883fdf2 | 103 | TGraph* gr1 = fParam ->GetAmpLED(i); |
104 | if (gr1) fAmpLED.AddAtAndExpand(gr1,i) ; | |
105 | TGraph* gr2 = fParam ->GetQTC(i); | |
539b9cb9 | 106 | if (gr2) fQTC.AddAtAndExpand(gr2,i) ; |
c883fdf2 | 107 | } |
539b9cb9 | 108 | |
58bd3a16 | 109 | fLatencyL1 = fParam->GetLatencyL1(); |
110 | fLatencyL1A = fParam->GetLatencyL1A(); | |
111 | fLatencyL1C = fParam->GetLatencyL1C(); | |
112 | fLatencyHPTDC = fParam->GetLatencyHPTDC(); | |
9d026202 | 113 | AliDebug(2,Form(" LatencyL1 %f latencyL1A %f latencyL1C %f latencyHPTDC %f \n",fLatencyL1, fLatencyL1A, fLatencyL1C, fLatencyHPTDC)); |
29ed1d0e | 114 | |
adf36b9d | 115 | // fdZonC = TMath::Abs(fParam->GetZPositionShift("T0/C/PMT1")); |
116 | //fdZonA = TMath::Abs(fParam->GetZPositionShift("T0/A/PMT15")); | |
8f620945 | 117 | //here real Z position |
118 | fdZonC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1")); | |
119 | fdZonA = TMath::Abs(fParam->GetZPosition("T0/A/PMT15")); | |
539b9cb9 | 120 | |
12e9daf9 | 121 | fCalib = new AliT0Calibrator(); |
73df58ab | 122 | fESDTZEROfriend = new AliESDTZEROfriend(); |
12e9daf9 | 123 | |
dc7ca31d | 124 | } |
c41ceaac | 125 | |
126 | //_____________________________________________________________________________ | |
dc7ca31d | 127 | void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const |
94c27e4f | 128 | |
dc7ca31d | 129 | { |
94c27e4f | 130 | // T0 digits reconstruction |
38cbfa7c | 131 | Int_t refAmp = Int_t (GetRecoParam()->GetRefAmp()); |
776de217 | 132 | |
c41ceaac | 133 | TArrayI * timeCFD = new TArrayI(24); |
134 | TArrayI * timeLED = new TArrayI(24); | |
135 | TArrayI * chargeQT0 = new TArrayI(24); | |
136 | TArrayI * chargeQT1 = new TArrayI(24); | |
74adb36a | 137 | |
d0bcd1fb | 138 | |
8955c6b4 | 139 | Float_t channelWidth = fParam->GetChannelWidth() ; |
b95e8d87 | 140 | Float_t meanVertex = fParam->GetMeanVertex(); |
776de217 | 141 | Float_t c = 0.0299792; // cm/ps |
adf36b9d | 142 | Double32_t vertex = 9999999; |
143 | Double32_t timeDiff=999999, meanTime=999999, timeclock=999999; | |
776de217 | 144 | |
94c27e4f | 145 | |
dc7ca31d | 146 | AliDebug(1,Form("Start DIGITS reconstruction ")); |
94c27e4f | 147 | |
2e6a5ee0 | 148 | |
d0bcd1fb | 149 | TBranch *brDigits=digitsTree->GetBranch("T0"); |
e0bba6cc | 150 | AliT0digit *fDigits = new AliT0digit() ; |
dc7ca31d | 151 | if (brDigits) { |
152 | brDigits->SetAddress(&fDigits); | |
153 | }else{ | |
f16935f7 | 154 | AliError(Form("EXEC Branch T0 digits not found")); |
155 | return; | |
dc7ca31d | 156 | } |
e0bba6cc | 157 | |
c41ceaac | 158 | digitsTree->GetEvent(0); |
159 | digitsTree->GetEntry(0); | |
160 | brDigits->GetEntry(0); | |
161 | fDigits->GetTimeCFD(*timeCFD); | |
162 | fDigits->GetTimeLED(*timeLED); | |
163 | fDigits->GetQT0(*chargeQT0); | |
164 | fDigits->GetQT1(*chargeQT1); | |
446d6ec4 | 165 | Int_t onlineMean = fDigits->MeanTime(); |
c883fdf2 | 166 | |
adf36b9d | 167 | Bool_t tr[5]; |
168 | for (Int_t i=0; i<5; i++) tr[i]=false; | |
c41ceaac | 169 | |
adf36b9d | 170 | Double32_t besttimeA=999999; |
171 | Double32_t besttimeC=999999; | |
c41ceaac | 172 | Int_t pmtBestA=99999; |
173 | Int_t pmtBestC=99999; | |
dc7ca31d | 174 | |
94c27e4f | 175 | AliT0RecPoint* frecpoints= new AliT0RecPoint (); |
1b544d5a | 176 | clustersTree->Branch( "T0", "AliT0RecPoint" ,&frecpoints); |
94c27e4f | 177 | |
b95e8d87 | 178 | Float_t time[24], adc[24]; |
dc7ca31d | 179 | for (Int_t ipmt=0; ipmt<24; ipmt++) { |
c41ceaac | 180 | if(timeCFD->At(ipmt)>0 ){ |
d0bcd1fb | 181 | if(( chargeQT1->At(ipmt) - chargeQT0->At(ipmt))>0) |
182 | adc[ipmt] = chargeQT1->At(ipmt) - chargeQT0->At(ipmt); | |
a7027400 | 183 | else |
d0bcd1fb | 184 | adc[ipmt] = 0; |
185 | ||
38cbfa7c | 186 | time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, Int_t(adc[ipmt]), timeCFD->At(ipmt)) ; |
d0bcd1fb | 187 | |
188 | Double_t sl = Double_t(timeLED->At(ipmt) - timeCFD->At(ipmt)); | |
8f620945 | 189 | // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD->At(ipmt) ) ; |
669dc07f | 190 | AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", |
d0bcd1fb | 191 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); |
776de217 | 192 | |
d0bcd1fb | 193 | Double_t ampMip =((TGraph*)fAmpLED.At(ipmt))->Eval(sl); |
194 | Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]); | |
669dc07f | 195 | AliDebug(5,Form(" Amlitude in MIPS LED %f , QTC %f in channels %f\n ",ampMip,qtMip, adc[ipmt])); |
d0bcd1fb | 196 | |
197 | frecpoints->SetTime(ipmt, Float_t(time[ipmt]) ); | |
345f03db | 198 | frecpoints->SetAmpLED(ipmt, Float_t( ampMip)); //for cosmic &pp beam |
199 | frecpoints->SetAmp(ipmt, Float_t(qtMip)); | |
d0bcd1fb | 200 | |
dc7ca31d | 201 | } |
202 | else { | |
203 | time[ipmt] = 0; | |
204 | adc[ipmt] = 0; | |
205 | } | |
206 | } | |
94c27e4f | 207 | |
dc7ca31d | 208 | for (Int_t ipmt=0; ipmt<12; ipmt++){ |
209 | if(time[ipmt] > 1 ) { | |
c41ceaac | 210 | if(time[ipmt]<besttimeC){ |
211 | besttimeC=time[ipmt]; //timeC | |
212 | pmtBestC=ipmt; | |
dc7ca31d | 213 | } |
214 | } | |
215 | } | |
216 | for ( Int_t ipmt=12; ipmt<24; ipmt++){ | |
217 | if(time[ipmt] > 1) { | |
c41ceaac | 218 | if(time[ipmt]<besttimeA) { |
219 | besttimeA=time[ipmt]; //timeA | |
220 | pmtBestA=ipmt;} | |
dc7ca31d | 221 | } |
222 | } | |
adf36b9d | 223 | if(besttimeA < 999999) { |
8f620945 | 224 | frecpoints->SetTimeBestA(Int_t(besttimeA *channelWidth - fdZonA/c)); |
adf36b9d | 225 | tr[1]=true; |
226 | } | |
227 | if( besttimeC < 999999 ) { | |
8f620945 | 228 | frecpoints->SetTimeBestC(Int_t(besttimeC *channelWidth - fdZonA/c)); |
adf36b9d | 229 | tr[2]=true; |
230 | } | |
669dc07f | 231 | AliDebug(5,Form(" besttimeA %f ch, besttimeC %f ch",besttimeA, besttimeC)); |
adf36b9d | 232 | if(besttimeA <999999 && besttimeC < 999999 ){ |
9b83615d | 233 | // timeDiff = (besttimeC - besttimeA)*channelWidth; |
234 | timeDiff = (besttimeA - besttimeC)*channelWidth; | |
adf36b9d | 235 | meanTime = (besttimeA + besttimeC)/2;// * channelWidth); |
8f620945 | 236 | timeclock = meanTime *channelWidth -fdZonA/c ; |
adf36b9d | 237 | vertex = meanVertex - c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2; |
238 | tr[0]=true; | |
239 | } | |
240 | frecpoints->SetVertex(vertex); | |
241 | frecpoints->SetMeanTime(meanTime); | |
242 | frecpoints->SetT0clock(timeclock); | |
243 | frecpoints->SetT0Trig(tr); | |
244 | ||
669dc07f | 245 | AliDebug(5,Form("T0 triggers %d %d %d %d %d",tr[0],tr[1],tr[2],tr[3],tr[4])); |
adf36b9d | 246 | |
247 | //online mean | |
248 | frecpoints->SetOnlineMean(Int_t(onlineMean)); | |
b5a9f753 | 249 | 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 | 250 | |
251 | ||
252 | ||
253 | ||
b95e8d87 | 254 | |
dc7ca31d | 255 | clustersTree->Fill(); |
bd375212 | 256 | |
257 | delete timeCFD; | |
258 | delete timeLED; | |
259 | delete chargeQT0; | |
260 | delete chargeQT1; | |
dc7ca31d | 261 | } |
262 | ||
263 | ||
c41ceaac | 264 | //_______________________________________________________________________ |
265 | ||
266 | void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) const | |
267 | { | |
94c27e4f | 268 | // T0 raw -> |
539b9cb9 | 269 | // |
270 | // reference amplitude and time ref. point from reco param | |
271 | ||
38cbfa7c | 272 | Float_t refAmp = GetRecoParam()->GetRefAmp(); |
273 | Int_t refPoint = 0; | |
274 | //Bad channel | |
275 | Int_t badpmt = GetRecoParam()->GetRefPoint(); | |
38cbfa7c | 276 | Int_t low[110], high[110]; |
58bd3a16 | 277 | |
e8ed1cd0 | 278 | Int_t allData[110][5]; |
2e6a5ee0 | 279 | |
e8ed1cd0 | 280 | Int_t timeCFD[24], timeLED[24], chargeQT0[24], chargeQT1[24]; |
adf36b9d | 281 | Double32_t timeDiff=999999, meanTime=999999, timeclock=999999; |
282 | Float_t c = 29.9792458; // cm/ns | |
283 | Double32_t vertex = 9999999; | |
776de217 | 284 | Int_t onlineMean=0; |
9480f05f | 285 | // Float_t meanVertex = fParam->GetMeanVertex(); |
286 | Float_t meanVertex = 0; | |
669dc07f | 287 | for (Int_t i0=0; i0<110; i0++) |
bce12dc5 | 288 | { |
38cbfa7c | 289 | for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0; |
290 | low[i0] = Int_t (GetRecoParam()->GetLow(i0)); | |
291 | high[i0] = Int_t (GetRecoParam()->GetHigh(i0)); | |
1b9fc3b4 | 292 | } |
2e6a5ee0 | 293 | |
adf36b9d | 294 | Double32_t besttimeA=9999999; |
295 | Double32_t besttimeC=9999999; | |
bce12dc5 | 296 | Int_t pmtBestA=99999; |
297 | Int_t pmtBestC=99999; | |
29a60970 | 298 | |
bce12dc5 | 299 | AliT0RecPoint* frecpoints= new AliT0RecPoint (); |
300 | ||
1b544d5a | 301 | recTree->Branch( "T0", "AliT0RecPoint" ,&frecpoints); |
2e6a5ee0 | 302 | |
bce12dc5 | 303 | AliDebug(10," before read data "); |
304 | AliT0RawReader myrawreader(rawReader); | |
776de217 | 305 | |
306 | UInt_t type =rawReader->GetType(); | |
307 | ||
bce12dc5 | 308 | if (!myrawreader.Next()) |
309 | AliDebug(1,Form(" no raw data found!!")); | |
310 | else | |
311 | { | |
38cbfa7c | 312 | for (Int_t i=0; i<24; i++) |
313 | { | |
314 | timeCFD[i]=0; timeLED[i]=0; chargeQT0[i]=0; chargeQT1[i]=0; | |
315 | } | |
316 | Int_t fBCID=Int_t (rawReader->GetBCID()); | |
8f620945 | 317 | Int_t trmbunch= myrawreader.GetTRMBunchID(); |
86fd0587 | 318 | AliDebug(10,Form(" CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch )); |
319 | ||
38cbfa7c | 320 | if(type == 7 ) { //only physics |
669dc07f | 321 | for (Int_t i=0; i<107; i++) { |
bce12dc5 | 322 | for (Int_t iHit=0; iHit<5; iHit++) |
323 | { | |
324 | allData[i][iHit] = myrawreader.GetData(i,iHit); | |
325 | } | |
8f620945 | 326 | } |
327 | Int_t ref=0; | |
328 | if (refPoint>0) | |
329 | ref = allData[refPoint][0]-5000; | |
330 | ||
331 | Float_t channelWidth = fParam->GetChannelWidth() ; | |
332 | ||
333 | // Int_t meanT0 = fParam->GetMeanT0(); | |
334 | ||
85f61e3b | 335 | for (Int_t in=0; in<12; in++) |
336 | { | |
337 | for (Int_t iHit=0; iHit<5; iHit++) | |
38cbfa7c | 338 | { |
85f61e3b | 339 | if(allData[in+1][iHit] > low[in+1] && |
340 | allData[in+1][iHit] < high[in+1]) | |
38cbfa7c | 341 | { |
85f61e3b | 342 | timeCFD[in] = allData[in+1][iHit] ; |
343 | break; | |
38cbfa7c | 344 | } |
85f61e3b | 345 | } |
346 | for (Int_t iHit=0; iHit<5; iHit++) | |
347 | { | |
348 | if(allData[in+12+1][iHit] > low[in+12+1] && | |
349 | allData[in+1+12][iHit] < high[in+12+1]) | |
38cbfa7c | 350 | { |
38cbfa7c | 351 | timeLED[in] = allData[in+12+1][iHit] ; |
352 | break; | |
38cbfa7c | 353 | } |
85f61e3b | 354 | } |
355 | for (Int_t iHit=0; iHit<5; iHit++) | |
356 | { | |
357 | if(allData[in+1+56][iHit] > low[in+1+56] && | |
358 | allData[in+1+56][iHit] < high[in+1+56]) | |
38cbfa7c | 359 | { |
85f61e3b | 360 | timeCFD[in+12] = allData[in+56+1][iHit] ; |
361 | break; | |
38cbfa7c | 362 | } |
38cbfa7c | 363 | } |
364 | ||
85f61e3b | 365 | for (Int_t iHit=0; iHit<5; iHit++) |
38cbfa7c | 366 | { |
85f61e3b | 367 | if(allData[in+1+68][iHit] > low[in+1+68] && |
368 | allData[in+1+68][iHit] < high[in+1+68]) | |
369 | { | |
669dc07f | 370 | |
85f61e3b | 371 | timeLED[in+12] = allData[in+68+1][iHit] ; |
372 | break; | |
373 | } | |
38cbfa7c | 374 | } |
669dc07f | 375 | AliDebug(5, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ", |
85f61e3b | 376 | in, timeCFD[in],timeCFD[in+12],timeLED[in], |
377 | timeLED[in+12])); | |
38cbfa7c | 378 | |
8f620945 | 379 | } |
380 | ||
8f620945 | 381 | |
85f61e3b | 382 | for (Int_t in=0; in<12; in++) |
383 | { | |
384 | chargeQT0[in]=allData[2*in+25][0]; | |
385 | chargeQT1[in]=allData[2*in+26][0]; | |
386 | AliDebug(10, Form(" readed Raw %i %i %i", | |
387 | in, chargeQT0[in],chargeQT1[in])); | |
388 | } | |
389 | for (Int_t in=12; in<24; in++) | |
390 | { | |
391 | chargeQT0[in]=allData[2*in+57][0]; | |
392 | chargeQT1[in]=allData[2*in+58][0]; | |
393 | AliDebug(10, Form(" readed Raw %i %i %i", | |
394 | in, chargeQT0[in],chargeQT1[in])); | |
395 | ||
396 | } | |
397 | ||
398 | for (Int_t iHit=0; iHit<5; iHit++) | |
38cbfa7c | 399 | { |
85f61e3b | 400 | if(allData[49][iHit] > low[49] && |
401 | allData[49][iHit] < high[49]){ | |
402 | onlineMean = allData[49][iHit]; | |
403 | break; | |
404 | } | |
38cbfa7c | 405 | } |
73df58ab | 406 | Double32_t time[24], adc[24], noncalibtime[24]; |
8f620945 | 407 | for (Int_t ipmt=0; ipmt<24; ipmt++) { |
38cbfa7c | 408 | if(timeCFD[ipmt]>0 ){ |
bce12dc5 | 409 | //for simulated data |
d0bcd1fb | 410 | //for physics data |
73df58ab | 411 | if(( chargeQT0[ipmt] - chargeQT1[ipmt])>0) { |
541b42c4 | 412 | adc[ipmt] = chargeQT0[ipmt] - chargeQT1[ipmt]; |
73df58ab | 413 | } |
d0bcd1fb | 414 | else |
415 | adc[ipmt] = 0; | |
38cbfa7c | 416 | time[ipmt] = fCalib-> WalkCorrection(Int_t (refAmp), ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ; |
bce12dc5 | 417 | |
d0bcd1fb | 418 | Double_t sl = timeLED[ipmt] - timeCFD[ipmt]; |
8f620945 | 419 | // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ; |
73df58ab | 420 | AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", |
d0bcd1fb | 421 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); |
422 | Double_t ampMip =( (TGraph*)fAmpLED.At(ipmt))->Eval(sl); | |
423 | Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]); | |
345f03db | 424 | AliDebug(10,Form(" Amlitude in MIPS LED %f ; QTC %f; in channels %f\n ",ampMip,qtMip, adc[ipmt])); |
73df58ab | 425 | //bad peak removing |
73df58ab | 426 | frecpoints->SetTime(ipmt, Float_t(time[ipmt]) ); |
427 | // frecpoints->SetTime(ipmt,Double32_t(timeCFD[ipmt])); | |
345f03db | 428 | frecpoints->SetAmp(ipmt, Double32_t( qtMip)); //for cosmic &pp beam |
429 | frecpoints->SetAmpLED(ipmt, Double32_t(ampMip)); | |
73df58ab | 430 | noncalibtime[ipmt]= Double32_t (timeCFD[ipmt]); |
2e6a5ee0 | 431 | } |
432 | else { | |
433 | time[ipmt] = 0; | |
434 | adc[ipmt] = 0; | |
73df58ab | 435 | noncalibtime[ipmt] = 0; |
2e6a5ee0 | 436 | } |
437 | } | |
73df58ab | 438 | fESDTZEROfriend->SetT0timeCorr(noncalibtime) ; |
2e6a5ee0 | 439 | for (Int_t ipmt=0; ipmt<12; ipmt++){ |
c6fd4ea6 | 440 | if(time[ipmt] > 1 && ipmt != badpmt && adc[ipmt]>0.1 ) |
73df58ab | 441 | { |
442 | if(time[ipmt]<besttimeC){ | |
669dc07f | 443 | besttimeC=time[ipmt]; //timeC |
444 | pmtBestC=ipmt; | |
73df58ab | 445 | } |
2e6a5ee0 | 446 | } |
2e6a5ee0 | 447 | } |
73df58ab | 448 | for ( Int_t ipmt=12; ipmt<24; ipmt++) |
449 | { | |
c6fd4ea6 | 450 | if(time[ipmt] > 1 && ipmt != badpmt && adc[ipmt]>0.1) |
73df58ab | 451 | { |
452 | if(time[ipmt]<besttimeA) { | |
453 | besttimeA=time[ipmt]; //timeA | |
454 | pmtBestA=ipmt; | |
455 | } | |
456 | } | |
2e6a5ee0 | 457 | } |
adf36b9d | 458 | if(besttimeA < 999999) |
669dc07f | 459 | frecpoints->SetTimeBestA(besttimeA * channelWidth - 1000.*fLatencyHPTDC + 1000.*fLatencyL1A - 1000.*fGRPdelays - fTimeMeanShift[1]); |
460 | ||
adf36b9d | 461 | if( besttimeC < 999999 ) |
669dc07f | 462 | frecpoints->SetTimeBestC(besttimeC * channelWidth - 1000.*fLatencyHPTDC +1000.*fLatencyL1C - 1000.*fGRPdelays - fTimeMeanShift[2]); |
463 | AliDebug(5,Form(" pmtA %i besttimeA %f shift A %f ps, pmtC %i besttimeC %f shiftC %f ps", | |
464 | pmtBestA,besttimeA, fTimeMeanShift[1], | |
1b9fc3b4 | 465 | |
669dc07f | 466 | pmtBestC, besttimeC,fTimeMeanShift[2])); |
adf36b9d | 467 | if(besttimeA <999999 && besttimeC < 999999 ){ |
73df58ab | 468 | timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth + fLatencyL1A - fLatencyL1C; |
669dc07f | 469 | timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - 1000.*fLatencyHPTDC + 1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0]; |
adf36b9d | 470 | meanTime = (besttimeA+besttimeC-2.*Float_t(ref))/2.; |
9480f05f | 471 | vertex = meanVertex - c*(timeDiff)/2. ; //+ (fdZonA - fdZonC)/2; |
adf36b9d | 472 | } |
776de217 | 473 | } //if phys event |
669dc07f | 474 | AliDebug(10,Form(" timeDiff %f #channel, meanTime %f #channel, TOFmean%f vertex %f cm meanVertex %f online mean %f \n",timeDiff, meanTime,timeclock, vertex,meanVertex, onlineMean)); |
776de217 | 475 | frecpoints->SetT0clock(timeclock); |
476 | frecpoints->SetVertex(vertex); | |
adf36b9d | 477 | frecpoints->SetMeanTime(meanTime); |
776de217 | 478 | frecpoints->SetOnlineMean(Int_t(onlineMean)); |
adf36b9d | 479 | // Set triggers |
480 | ||
481 | Bool_t tr[5]; | |
482 | Int_t trchan[5]= {50,51,52,55,56}; | |
483 | for (Int_t i=0; i<5; i++) tr[i]=false; | |
484 | for (Int_t itr=0; itr<5; itr++) { | |
38cbfa7c | 485 | for (Int_t iHit=0; iHit<5; iHit++) |
486 | { | |
487 | Int_t trr=trchan[itr]; | |
669dc07f | 488 | if( allData[trr][iHit] > 0) tr[itr]=true; |
38cbfa7c | 489 | } |
adf36b9d | 490 | } |
38cbfa7c | 491 | frecpoints->SetT0Trig(tr); |
669dc07f | 492 | |
493 | //Set MPD | |
494 | if(allData[53][0]>0 && allData[54][0]) | |
495 | frecpoints->SetMultA(allData[53][0]-allData[54][0]); | |
496 | if(allData[105][0]>0 && allData[106][0]) | |
497 | frecpoints->SetMultC(allData[105][0]-allData[106][0]); | |
498 | ||
499 | ||
500 | } // if (else )raw data | |
58bd3a16 | 501 | recTree->Fill(); |
502 | if(frecpoints) delete frecpoints; | |
503 | } | |
adf36b9d | 504 | |
505 | ||
506 | //____________________________________________________________ | |
507 | ||
508 | void AliT0Reconstructor::FillESD(TTree */*digitsTree*/, TTree *clustersTree, AliESDEvent *pESD) const | |
509 | { | |
dc7ca31d | 510 | |
511 | /*************************************************** | |
512 | Resonstruct digits to vertex position | |
513 | ****************************************************/ | |
514 | ||
dc7ca31d | 515 | AliDebug(1,Form("Start FillESD T0")); |
58bd3a16 | 516 | Float_t channelWidth = fParam->GetChannelWidth() ; |
f7c2c2fc | 517 | Float_t c = 0.0299792458; // cm/ps |
adf36b9d | 518 | Float_t currentVertex=0, shift=0; |
519 | Int_t ncont=0; | |
520 | const AliESDVertex* vertex = pESD->GetPrimaryVertex(); | |
521 | if (!vertex) vertex = pESD->GetPrimaryVertexSPD(); | |
522 | if (!vertex) vertex = pESD->GetPrimaryVertexTPC(); | |
523 | if (!vertex) vertex = pESD->GetVertex(); | |
524 | ||
525 | if (vertex) { | |
526 | AliDebug(2, Form("Got %s (%s) from ESD: %f", | |
527 | vertex->GetName(), vertex->GetTitle(), vertex->GetZ())); | |
528 | currentVertex = vertex->GetZ(); | |
529 | ||
530 | ncont = vertex->GetNContributors(); | |
85f61e3b | 531 | // cout<<"@@ spdver "<<spdver<<" ncont "<<ncont<<endl; |
58bd3a16 | 532 | if(ncont>2 ) { |
adf36b9d | 533 | shift = currentVertex/c; |
adf36b9d | 534 | } |
535 | } | |
d76c31f4 | 536 | TTree *treeR = clustersTree; |
dc7ca31d | 537 | |
73df58ab | 538 | AliT0RecPoint* frecpoints= new AliT0RecPoint (); |
539 | if (!frecpoints) { | |
dc7ca31d | 540 | AliError("Reconstruct Fill ESD >> no recpoints found"); |
541 | return; | |
542 | } | |
543 | ||
544 | AliDebug(1,Form("Start FillESD T0")); | |
545 | TBranch *brRec = treeR->GetBranch("T0"); | |
546 | if (brRec) { | |
547 | brRec->SetAddress(&frecpoints); | |
548 | }else{ | |
f16935f7 | 549 | AliError(Form("EXEC Branch T0 rec not found")); |
dc7ca31d | 550 | return; |
551 | } | |
73df58ab | 552 | |
553 | brRec->GetEntry(0); | |
554 | Double32_t amp[24], time[24], ampQTC[24], timecorr[24]; | |
555 | Double32_t* tcorr; | |
556 | for(Int_t i=0; i<24; i++) | |
557 | amp[i]=time[i]=ampQTC[i]=timecorr[i]=0; | |
558 | ||
669dc07f | 559 | |
73df58ab | 560 | Double32_t timeClock[3]; |
561 | Double32_t zPosition = frecpoints -> GetVertex(); | |
562 | Double32_t timeStart = frecpoints -> GetMeanTime(); | |
563 | timeClock[0] = frecpoints -> GetT0clock() ; | |
564 | timeClock[1] = frecpoints -> GetBestTimeA() + shift; | |
565 | timeClock[2] = frecpoints -> GetBestTimeC() - shift; | |
566 | for ( Int_t i=0; i<24; i++) { | |
567 | time[i] = frecpoints -> GetTime(i); // ps to ns | |
568 | if ( time[i] >1) { | |
345f03db | 569 | ampQTC[i] = frecpoints -> GetAmp(i); |
570 | amp[i] = frecpoints -> AmpLED(i); | |
85f61e3b | 571 | AliDebug(1,Form("T0: time %f ampQTC %f ampLED %f \n", time[i], ampQTC[i], amp[i])); |
572 | } | |
73df58ab | 573 | } |
574 | Int_t trig= frecpoints ->GetT0Trig(); | |
575 | pESD->SetT0Trig(trig); | |
576 | ||
577 | pESD->SetT0zVertex(zPosition); //vertex Z position | |
669dc07f | 578 | |
579 | Double32_t multA=frecpoints ->GetMultA(); | |
580 | Double32_t multC=frecpoints ->GetMultC(); | |
3050a127 | 581 | // pESD->SetT0MultC(multC); // multiplicity Cside |
582 | // pESD->SetT0MultA(multA); // multiplicity Aside | |
1b9fc3b4 | 583 | pESD->SetT0(multA); // for backward compatubility |
584 | pESD->SetT0clock(multC); // for backward compatubility | |
669dc07f | 585 | |
73df58ab | 586 | for(Int_t i=0; i<3; i++) |
587 | pESD->SetT0TOF(i,timeClock[i]); // interaction time (ns) | |
588 | pESD->SetT0time(time); // best TOF on each PMT | |
345f03db | 589 | pESD->SetT0amplitude(ampQTC); // number of particles(MIPs) on each PMT |
73df58ab | 590 | |
591 | AliDebug(1,Form("T0: Vertex %f (T0A+T0C)/2 %f #channels T0signal %f ns OrA %f ns OrC %f T0trig %i\n",zPosition, timeStart, timeClock[0], timeClock[1], timeClock[2], trig)); | |
592 | ||
593 | if (pESD) { | |
adf36b9d | 594 | |
73df58ab | 595 | AliESDfriend *fr = (AliESDfriend*)pESD->FindListObject("AliESDfriend"); |
596 | if (fr) { | |
597 | AliDebug(1, Form("Writing TZERO friend data to ESD tree")); | |
598 | ||
85f61e3b | 599 | // if (ncont>2) { |
73df58ab | 600 | tcorr = fESDTZEROfriend->GetT0timeCorr(); |
601 | for ( Int_t i=0; i<24; i++) { | |
85f61e3b | 602 | if(i<12 && time[i]>1) timecorr[i] = tcorr[i] - shift/channelWidth; |
603 | if(i>11 && time[i]>1) timecorr[i] = tcorr[i] + shift/channelWidth; | |
669dc07f | 604 | if(time[i]>1) AliDebug(10,Form("T0 friend : time %f ampQTC %f ampLED %f \n", timecorr[i], ampQTC[i], amp[i])); |
58bd3a16 | 605 | } |
73df58ab | 606 | fESDTZEROfriend->SetT0timeCorr( timecorr) ; |
607 | fESDTZEROfriend->SetT0ampLEDminCFD(amp); | |
608 | fESDTZEROfriend->SetT0ampQTC(ampQTC); | |
85f61e3b | 609 | fr->SetTZEROfriend(fESDTZEROfriend); |
610 | // }// | |
58bd3a16 | 611 | } |
612 | } | |
73df58ab | 613 | |
614 | ||
615 | ||
dc7ca31d | 616 | } // vertex in 3 sigma |
617 | ||
618 | ||
619 | ||
620 | ||
621 | ||
622 |