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