]>
Commit | Line | Data |
---|---|---|
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 | ||
34 | #include <TArrayI.h> | |
35 | #include <TGraph.h> | |
36 | #include <TMath.h> | |
37 | #include <Riostream.h> | |
38 | ||
39 | ClassImp(AliT0Reconstructor) | |
40 | ||
41 | AliT0Reconstructor:: AliT0Reconstructor(): AliReconstructor(), | |
42 | fdZonA(0), | |
43 | fdZonC(0), | |
44 | fZposition(0), | |
45 | fParam(NULL), | |
46 | fAmpLEDrec(), | |
47 | fQTC(0), | |
48 | fAmpLED(0), | |
49 | fCalib() | |
50 | { | |
51 | //constructor | |
52 | ||
53 | fParam = AliT0Parameters::Instance(); | |
54 | fParam->Init(); | |
55 | ||
56 | for (Int_t i=0; i<24; i++){ | |
57 | TGraph* gr = fParam ->GetAmpLEDRec(i); | |
58 | if (gr) fAmpLEDrec.AddAtAndExpand(gr,i) ; | |
59 | TGraph* gr1 = fParam ->GetAmpLED(i); | |
60 | if (gr1) fAmpLED.AddAtAndExpand(gr1,i) ; | |
61 | TGraph* gr2 = fParam ->GetQTC(i); | |
62 | if (gr2) fQTC.AddAtAndExpand(gr2,i) ; | |
63 | } | |
64 | ||
65 | ||
66 | fdZonC = TMath::Abs(fParam->GetZPositionShift("T0/C/PMT1")); | |
67 | fdZonA = TMath::Abs(fParam->GetZPositionShift("T0/A/PMT15")); | |
68 | ||
69 | fCalib = new AliT0Calibrator(); | |
70 | ||
71 | } | |
72 | //____________________________________________________________________ | |
73 | ||
74 | AliT0Reconstructor::AliT0Reconstructor(const AliT0Reconstructor &r): | |
75 | AliReconstructor(r), | |
76 | fdZonA(0), | |
77 | fdZonC(0), | |
78 | fZposition(0), | |
79 | fParam(NULL), | |
80 | fAmpLEDrec(0), | |
81 | fQTC(0), | |
82 | fAmpLED(0), | |
83 | fCalib() | |
84 | ||
85 | { | |
86 | // | |
87 | // AliT0Reconstructor copy constructor | |
88 | // | |
89 | ||
90 | ((AliT0Reconstructor &) r).Copy(*this); | |
91 | ||
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | AliT0Reconstructor &AliT0Reconstructor::operator=(const AliT0Reconstructor &r) | |
96 | { | |
97 | // | |
98 | // Assignment operator | |
99 | // | |
100 | if (this != &r) ((AliT0Reconstructor &) r).Copy(*this); | |
101 | return *this; | |
102 | ||
103 | } | |
104 | ||
105 | //_____________________________________________________________________________ | |
106 | ||
107 | void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const | |
108 | ||
109 | { | |
110 | // T0 digits reconstruction | |
111 | Int_t refAmp = GetRecoParam()->GetRefAmp(); | |
112 | ||
113 | TArrayI * timeCFD = new TArrayI(24); | |
114 | TArrayI * timeLED = new TArrayI(24); | |
115 | TArrayI * chargeQT0 = new TArrayI(24); | |
116 | TArrayI * chargeQT1 = new TArrayI(24); | |
117 | ||
118 | ||
119 | Float_t channelWidth = fParam->GetChannelWidth() ; | |
120 | Float_t meanVertex = fParam->GetMeanVertex(); | |
121 | Float_t c = 0.0299792; // cm/ps | |
122 | Float_t vertex = 9999999; | |
123 | Int_t timeDiff=999999, meanTime=999999, timeclock=999999; | |
124 | ||
125 | ||
126 | AliDebug(1,Form("Start DIGITS reconstruction ")); | |
127 | ||
128 | ||
129 | TBranch *brDigits=digitsTree->GetBranch("T0"); | |
130 | AliT0digit *fDigits = new AliT0digit() ; | |
131 | if (brDigits) { | |
132 | brDigits->SetAddress(&fDigits); | |
133 | }else{ | |
134 | AliError(Form("EXEC Branch T0 digits not found")); | |
135 | return; | |
136 | } | |
137 | ||
138 | digitsTree->GetEvent(0); | |
139 | digitsTree->GetEntry(0); | |
140 | brDigits->GetEntry(0); | |
141 | fDigits->GetTimeCFD(*timeCFD); | |
142 | fDigits->GetTimeLED(*timeLED); | |
143 | fDigits->GetQT0(*chargeQT0); | |
144 | fDigits->GetQT1(*chargeQT1); | |
145 | Int_t onlineMean = fDigits->MeanTime(); | |
146 | Int_t ref = fDigits->RefPoint(); | |
147 | ||
148 | ||
149 | Float_t besttimeA=999999; | |
150 | Float_t besttimeC=999999; | |
151 | Int_t pmtBestA=99999; | |
152 | Int_t pmtBestC=99999; | |
153 | ||
154 | AliT0RecPoint* frecpoints= new AliT0RecPoint (); | |
155 | clustersTree->Branch( "T0", "AliT0RecPoint" ,&frecpoints, 405,1); | |
156 | ||
157 | Float_t time[24], adc[24]; | |
158 | for (Int_t ipmt=0; ipmt<24; ipmt++) { | |
159 | if(timeCFD->At(ipmt)>0 ){ | |
160 | if(( chargeQT1->At(ipmt) - chargeQT0->At(ipmt))>0) | |
161 | adc[ipmt] = chargeQT1->At(ipmt) - chargeQT0->At(ipmt); | |
162 | else | |
163 | adc[ipmt] = 0; | |
164 | ||
165 | time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, adc[ipmt], timeCFD->At(ipmt)) ; | |
166 | ||
167 | Double_t sl = Double_t(timeLED->At(ipmt) - timeCFD->At(ipmt)); | |
168 | // time[ipmt] = fCalib-> WalkCorrection( ipmt, Int_t(sl), timeCFD[ipmt],"cosmic" ) ; | |
169 | AliDebug(10,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", | |
170 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); | |
171 | ||
172 | Double_t ampMip =((TGraph*)fAmpLED.At(ipmt))->Eval(sl); | |
173 | Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]); | |
174 | AliDebug(10,Form(" Amlitude in MIPS LED %f , QTC %f in channels %i\n ",ampMip,qtMip, adc[ipmt])); | |
175 | ||
176 | frecpoints->SetTime(ipmt, Float_t(time[ipmt]) ); | |
177 | frecpoints->SetAmp(ipmt, Float_t( ampMip)); //for cosmic &pp beam | |
178 | frecpoints->SetAmpLED(ipmt, Float_t(qtMip)); | |
179 | ||
180 | } | |
181 | else { | |
182 | time[ipmt] = 0; | |
183 | adc[ipmt] = 0; | |
184 | } | |
185 | } | |
186 | ||
187 | for (Int_t ipmt=0; ipmt<12; ipmt++){ | |
188 | if(time[ipmt] > 1 ) { | |
189 | if(time[ipmt]<besttimeC){ | |
190 | besttimeC=time[ipmt]; //timeC | |
191 | pmtBestC=ipmt; | |
192 | } | |
193 | } | |
194 | } | |
195 | for ( Int_t ipmt=12; ipmt<24; ipmt++){ | |
196 | if(time[ipmt] > 1) { | |
197 | if(time[ipmt]<besttimeA) { | |
198 | besttimeA=time[ipmt]; //timeA | |
199 | pmtBestA=ipmt;} | |
200 | } | |
201 | } | |
202 | if(besttimeA !=999999) frecpoints->SetTimeBestA(Int_t(besttimeA)); | |
203 | if( besttimeC != 999999 ) frecpoints->SetTimeBestC(Int_t(besttimeC)); | |
204 | AliDebug(10,Form(" besttimeA %f ch, besttimeC %f ch",besttimeA, besttimeC)); | |
205 | if(besttimeA !=999999 && besttimeC != 999999 ){ | |
206 | // timeDiff = (besttimeC - besttimeA)*channelWidth; | |
207 | timeDiff = (besttimeA - besttimeC)*channelWidth; | |
208 | meanTime = Float_t((besttimeA + besttimeC)/2);// * channelWidth); | |
209 | timeclock = Float_t(meanTime - ref); | |
210 | vertex = meanVertex - c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2; | |
211 | } | |
212 | frecpoints->SetVertex(vertex); | |
213 | frecpoints->SetMeanTime(meanTime); | |
214 | frecpoints->SetT0clock(timeclock); | |
215 | //online mean | |
216 | frecpoints->SetOnlineMean(Int_t(onlineMean)); | |
217 | AliDebug(10,Form(" timeDiff %i #channel, meanTime %i #channel, vertex %f cm online mean %i timeclock %i ps",timeDiff, meanTime,vertex, Int_t(onlineMean), timeclock)); | |
218 | ||
219 | // } | |
220 | ||
221 | clustersTree->Fill(); | |
222 | ||
223 | delete timeCFD; | |
224 | delete timeLED; | |
225 | delete chargeQT0; | |
226 | delete chargeQT1; | |
227 | } | |
228 | ||
229 | ||
230 | //_______________________________________________________________________ | |
231 | ||
232 | void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) const | |
233 | { | |
234 | // T0 raw -> | |
235 | // | |
236 | // reference amplitude and time ref. point from reco param | |
237 | ||
238 | Int_t refAmp = GetRecoParam()->GetRefAmp(); | |
239 | Int_t refPoint = GetRecoParam()->GetRefPoint(); | |
240 | ||
241 | Int_t allData[110][5]; | |
242 | ||
243 | Int_t timeCFD[24], timeLED[24], chargeQT0[24], chargeQT1[24]; | |
244 | Int_t timeDiff=999999, meanTime=999999, timeclock=999999; | |
245 | Float_t c = 0.0299792458; // cm/ps | |
246 | Float_t vertex = 9999999; | |
247 | Int_t onlineMean=0; | |
248 | for (Int_t i0=0; i0<105; i0++) | |
249 | { | |
250 | for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0; | |
251 | } | |
252 | ||
253 | Float_t besttimeA=9999999; | |
254 | Float_t besttimeC=9999999; | |
255 | Int_t pmtBestA=99999; | |
256 | Int_t pmtBestC=99999; | |
257 | Float_t meanVertex = fParam->GetMeanVertex(); | |
258 | ||
259 | AliT0RecPoint* frecpoints= new AliT0RecPoint (); | |
260 | ||
261 | recTree->Branch( "T0", "AliT0RecPoint" ,&frecpoints, 405,1); | |
262 | ||
263 | AliDebug(10," before read data "); | |
264 | AliT0RawReader myrawreader(rawReader); | |
265 | ||
266 | UInt_t type =rawReader->GetType(); | |
267 | ||
268 | if (!myrawreader.Next()) | |
269 | AliDebug(1,Form(" no raw data found!!")); | |
270 | else | |
271 | { | |
272 | if(type == 7) { //only physics | |
273 | for (Int_t i=0; i<105; i++) { | |
274 | for (Int_t iHit=0; iHit<5; iHit++) | |
275 | { | |
276 | allData[i][iHit] = myrawreader.GetData(i,iHit); | |
277 | } | |
278 | } | |
279 | ||
280 | Int_t ref = allData[refPoint][0]-5000.; | |
281 | Float_t channelWidth = fParam->GetChannelWidth() ; | |
282 | ||
283 | // Int_t meanT0 = fParam->GetMeanT0(); | |
284 | ||
285 | ||
286 | for (Int_t in=0; in<12; in++) | |
287 | { | |
288 | timeCFD[in] = allData[in+1][0] ; | |
289 | timeCFD[in+12] = allData[in+56+1][0] ; | |
290 | timeLED[in] = allData[in+12+1][0] ; | |
291 | timeLED[in+12] = allData[in+68+1][0] ; | |
292 | AliDebug(10, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ", | |
293 | in, timeCFD[in],timeCFD[in+12],timeLED[in], | |
294 | timeLED[in+12])); | |
295 | } | |
296 | ||
297 | for (Int_t in=0; in<12; in++) | |
298 | { | |
299 | chargeQT0[in]=allData[2*in+25][0]; | |
300 | chargeQT1[in]=allData[2*in+26][0]; | |
301 | } | |
302 | ||
303 | for (Int_t in=12; in<24; in++) | |
304 | { | |
305 | chargeQT0[in]=allData[2*in+57][0]; | |
306 | chargeQT1[in]=allData[2*in+58][0]; | |
307 | } | |
308 | ||
309 | // } //cosmic with physics event | |
310 | for (Int_t in=0; in<24; in++) | |
311 | AliDebug(10, Form(" readed Raw %i %i %i %i %i", | |
312 | in, timeLED[in],timeCFD[in],chargeQT0[in],chargeQT1[in])); | |
313 | onlineMean = allData[49][0]; | |
314 | ||
315 | Float_t time[24], adc[24]; | |
316 | for (Int_t ipmt=0; ipmt<24; ipmt++) { | |
317 | if(timeCFD[ipmt]>0 && timeLED[ipmt]>0){ | |
318 | //for simulated data | |
319 | //for physics data | |
320 | if(( chargeQT1[ipmt] - chargeQT0[ipmt])>0) | |
321 | adc[ipmt] = chargeQT1[ipmt] - chargeQT0[ipmt]; | |
322 | else | |
323 | adc[ipmt] = 0; | |
324 | ||
325 | ||
326 | time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, adc[ipmt], timeCFD[ipmt] ) ; | |
327 | ||
328 | Double_t sl = timeLED[ipmt] - timeCFD[ipmt]; | |
329 | // time[ipmt] = fCalib-> WalkCorrection( ipmt, Int_t(sl), timeCFD[ipmt] ) ; | |
330 | AliDebug(10,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ", | |
331 | ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl))); | |
332 | Double_t ampMip =( (TGraph*)fAmpLED.At(ipmt))->Eval(sl); | |
333 | Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]); | |
334 | AliDebug(10,Form(" Amlitude in MIPS LED %f ; QTC %f; in channels %i\n ",ampMip,qtMip, adc[ipmt])); | |
335 | ||
336 | frecpoints->SetTime(ipmt, Float_t(time[ipmt]) ); | |
337 | frecpoints->SetAmp(ipmt, Float_t( ampMip)); //for cosmic &pp beam | |
338 | frecpoints->SetAmpLED(ipmt, Float_t(qtMip)); | |
339 | ||
340 | } | |
341 | else { | |
342 | time[ipmt] = 0; | |
343 | adc[ipmt] = 0; | |
344 | } | |
345 | } | |
346 | ||
347 | for (Int_t ipmt=0; ipmt<12; ipmt++){ | |
348 | if(time[ipmt] > 1 ) { | |
349 | if(time[ipmt]<besttimeC){ | |
350 | besttimeC=time[ipmt]; //timeC | |
351 | pmtBestC=ipmt; | |
352 | } | |
353 | } | |
354 | } | |
355 | for ( Int_t ipmt=12; ipmt<24; ipmt++){ | |
356 | if(time[ipmt] > 1) { | |
357 | if(time[ipmt]<besttimeA) { | |
358 | besttimeA=time[ipmt]; //timeA | |
359 | pmtBestA=ipmt;} | |
360 | } | |
361 | } | |
362 | if(besttimeA !=9999999) frecpoints->SetTimeBestA(Int_t(besttimeA)); | |
363 | if( besttimeC != 9999999 ) frecpoints->SetTimeBestC(Int_t(besttimeC)); | |
364 | AliDebug(5,Form(" pmtA %i besttimeA %f ps, pmtC %i besttimeC %f #channel", | |
365 | pmtBestA,besttimeA, pmtBestC, besttimeC)); | |
366 | if(besttimeA <9999999 && besttimeC < 9999999 ){ | |
367 | timeDiff = ( besttimeA - besttimeC) *channelWidth; | |
368 | meanTime = Float_t((besttimeA + besttimeC)/2.); | |
369 | timeclock = Float_t(meanTime - ref); | |
370 | vertex = meanVertex - c*(timeDiff)/2.; //+ (fdZonA - fdZonC)/2; | |
371 | } | |
372 | } //if phys event | |
373 | frecpoints->SetT0clock(timeclock); | |
374 | frecpoints->SetVertex(vertex); | |
375 | frecpoints->SetMeanTime(Int_t(meanTime)); | |
376 | frecpoints->SetOnlineMean(Int_t(onlineMean)); | |
377 | AliDebug(5,Form(" timeDiff %f #channel, meanTime %f #channel, vertex %f cm meanVertex %f online mean %i ",timeDiff, meanTime,vertex,meanVertex, onlineMean)); | |
378 | ||
379 | ||
380 | } // if (else )raw data | |
381 | recTree->Fill(); | |
382 | if(frecpoints) delete frecpoints; | |
383 | } | |
384 | ||
385 | ||
386 | //____________________________________________________________ | |
387 | ||
388 | void AliT0Reconstructor::FillESD(TTree */*digitsTree*/, TTree *clustersTree, AliESDEvent *pESD) const | |
389 | { | |
390 | ||
391 | /*************************************************** | |
392 | Resonstruct digits to vertex position | |
393 | ****************************************************/ | |
394 | ||
395 | AliDebug(1,Form("Start FillESD T0")); | |
396 | ||
397 | TTree *treeR = clustersTree; | |
398 | ||
399 | AliT0RecPoint* frecpoints= new AliT0RecPoint (); | |
400 | if (!frecpoints) { | |
401 | AliError("Reconstruct Fill ESD >> no recpoints found"); | |
402 | return; | |
403 | } | |
404 | ||
405 | AliDebug(1,Form("Start FillESD T0")); | |
406 | TBranch *brRec = treeR->GetBranch("T0"); | |
407 | if (brRec) { | |
408 | brRec->SetAddress(&frecpoints); | |
409 | }else{ | |
410 | AliError(Form("EXEC Branch T0 rec not found")); | |
411 | return; | |
412 | } | |
413 | ||
414 | brRec->GetEntry(0); | |
415 | Float_t amp[24], time[24]; | |
416 | Float_t zPosition = frecpoints -> GetVertex(); | |
417 | Float_t timeStart = frecpoints -> GetMeanTime() ; | |
418 | Float_t timeClock = frecpoints -> GetT0clock() ; | |
419 | for ( Int_t i=0; i<24; i++) { | |
420 | time[i] = Float_t (frecpoints -> GetTime(i)); // ps to ns | |
421 | amp[i] = frecpoints -> GetAmp(i); | |
422 | } | |
423 | pESD->SetT0zVertex(zPosition); //vertex Z position | |
424 | pESD->SetT0(timeStart); // interaction time | |
425 | pESD->SetT0clock(timeClock); // interaction time with ref.point(spectrum) | |
426 | pESD->SetT0time(time); // best TOF on each PMT | |
427 | pESD->SetT0amplitude(amp); // number of particles(MIPs) on each PMT | |
428 | ||
429 | AliDebug(1,Form(" Z position %f cm, T0 %f ps",zPosition , timeStart)); | |
430 | ||
431 | } // vertex in 3 sigma | |
432 | ||
433 | ||
434 | ||
435 | ||
436 | ||
437 |