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