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