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