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