]>
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 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// // | |
20 | /// class for VZERO reconstruction // | |
21 | /// // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include <TH1F.h> | |
25 | #include <TF1.h> | |
26 | #include <TParameter.h> | |
27 | ||
28 | #include "AliRunLoader.h" | |
29 | #include "AliRawReader.h" | |
30 | #include "AliGRPObject.h" | |
31 | #include "AliCDBManager.h" | |
32 | #include "AliCDBStorage.h" | |
33 | #include "AliCDBEntry.h" | |
34 | #include "AliVZEROReconstructor.h" | |
35 | #include "AliVZERORawStream.h" | |
36 | #include "AliVZEROConst.h" | |
37 | #include "AliESDEvent.h" | |
38 | #include "AliVZEROTriggerMask.h" | |
39 | #include "AliESDfriend.h" | |
40 | #include "AliESDVZEROfriend.h" | |
41 | #include "AliVZEROdigit.h" | |
42 | #include "AliVZEROCalibData.h" | |
43 | #include "AliRunInfo.h" | |
44 | #include "AliCTPTimeParams.h" | |
45 | #include "AliLHCClockPhase.h" | |
46 | ||
47 | ClassImp(AliVZEROReconstructor) | |
48 | ||
49 | //_____________________________________________________________________________ | |
50 | AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(), | |
51 | fESDVZERO(0x0), | |
52 | fESD(0x0), | |
53 | fESDVZEROfriend(0x0), | |
54 | fCalibData(NULL), | |
55 | fTriggerData(NULL), | |
56 | fTimeSlewing(NULL), | |
57 | fSaturationCorr(NULL), | |
58 | fCollisionMode(0), | |
59 | fBeamEnergy(0.), | |
60 | fDigitsArray(0) | |
61 | { | |
62 | // Default constructor | |
63 | // Get calibration data | |
64 | ||
65 | fCalibData = GetCalibData(); | |
66 | ||
67 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming"); | |
68 | if (!entry) AliFatal("CTP timing parameters are not found in OCDB !"); | |
69 | AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject(); | |
70 | Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0; | |
71 | ||
72 | AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign"); | |
73 | if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !"); | |
74 | AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject(); | |
75 | l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0); | |
76 | ||
77 | AliCDBEntry *entry2 = AliCDBManager::Instance()->Get("VZERO/Calib/TimeDelays"); | |
78 | if (!entry2) AliFatal("VZERO time delays are not found in OCDB !"); | |
79 | TH1F *delays = (TH1F*)entry2->GetObject(); | |
80 | ||
81 | AliCDBEntry *entry3 = AliCDBManager::Instance()->Get("VZERO/Calib/TimeSlewing"); | |
82 | if (!entry3) AliFatal("VZERO time slewing function is not found in OCDB !"); | |
83 | fTimeSlewing = (TF1*)entry3->GetObject(); | |
84 | ||
85 | AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase"); | |
86 | if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !"); | |
87 | AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject(); | |
88 | ||
89 | for(Int_t i = 0 ; i < 64; ++i) { | |
90 | Int_t board = AliVZEROCalibData::GetBoardNumber(i); | |
91 | fTimeOffset[i] = (((Float_t)fCalibData->GetRollOver(board)- | |
92 | (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0+ | |
93 | fCalibData->GetTimeOffset(i)- | |
94 | l1Delay- | |
95 | phase->GetMeanPhase()+ | |
96 | delays->GetBinContent(i+1)+ | |
97 | kV0Offset); | |
98 | } | |
99 | ||
100 | AliCDBEntry *entry5 = AliCDBManager::Instance()->Get("VZERO/Calib/Saturation"); | |
101 | if (!entry5) AliFatal("Saturation entry is not found in OCDB !"); | |
102 | fSaturationCorr = (TObjArray*)entry5->GetObject(); | |
103 | ||
104 | AliCDBEntry *entry6 = AliCDBManager::Instance()->Get("VZERO/Trigger/Data"); | |
105 | if (!entry6) AliFatal("VZERO trigger config data is not found in OCDB !"); | |
106 | fTriggerData = (AliVZEROTriggerData*)entry6->GetObject(); | |
107 | } | |
108 | ||
109 | ||
110 | //_____________________________________________________________________________ | |
111 | AliVZEROReconstructor& AliVZEROReconstructor::operator = | |
112 | (const AliVZEROReconstructor& /*reconstructor*/) | |
113 | { | |
114 | // assignment operator | |
115 | ||
116 | Fatal("operator =", "assignment operator not implemented"); | |
117 | return *this; | |
118 | } | |
119 | ||
120 | //_____________________________________________________________________________ | |
121 | AliVZEROReconstructor::~AliVZEROReconstructor() | |
122 | { | |
123 | // destructor | |
124 | ||
125 | if(fESDVZERO) | |
126 | delete fESDVZERO; | |
127 | if(fESDVZEROfriend) | |
128 | delete fESDVZEROfriend; | |
129 | if(fDigitsArray) | |
130 | delete fDigitsArray; | |
131 | } | |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | void AliVZEROReconstructor::Init() | |
135 | { | |
136 | // initializer | |
137 | ||
138 | fESDVZERO = new AliESDVZERO; | |
139 | fESDVZEROfriend = new AliESDVZEROfriend; | |
140 | ||
141 | GetCollisionMode(); // fCollisionMode =1 for Pb-Pb simulated data | |
142 | } | |
143 | ||
144 | //______________________________________________________________________ | |
145 | void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const | |
146 | { | |
147 | // converts RAW to digits | |
148 | ||
149 | if (!digitsTree) { | |
150 | AliError("No digits tree!"); | |
151 | return; | |
152 | } | |
153 | ||
154 | if (!fDigitsArray) | |
155 | fDigitsArray = new TClonesArray("AliVZEROdigit", 64); | |
156 | digitsTree->Branch("VZERODigit", &fDigitsArray); | |
157 | ||
158 | fESDVZEROfriend->Reset(); | |
159 | ||
160 | rawReader->Reset(); | |
161 | AliVZERORawStream rawStream(rawReader); | |
162 | if (rawStream.Next()) { | |
163 | ||
164 | Int_t aBBflagsV0A = 0; | |
165 | Int_t aBBflagsV0C = 0; | |
166 | Int_t aBGflagsV0A = 0; | |
167 | Int_t aBGflagsV0C = 0; | |
168 | ||
169 | for(Int_t iChannel=0; iChannel < 64; ++iChannel) { | |
170 | Int_t offlineCh = rawStream.GetOfflineChannel(iChannel); | |
171 | // ADC charge samples | |
172 | Short_t chargeADC[AliVZEROdigit::kNClocks]; | |
173 | for(Int_t iClock=0; iClock < AliVZEROdigit::kNClocks; ++iClock) { | |
174 | chargeADC[iClock] = rawStream.GetPedestal(iChannel,iClock); | |
175 | } | |
176 | // Integrator flag | |
177 | Bool_t integrator = rawStream.GetIntegratorFlag(iChannel,AliVZEROdigit::kNClocks/2); | |
178 | // Beam-beam and beam-gas flags | |
179 | if(offlineCh<32) { | |
180 | if (rawStream.GetBBFlag(iChannel,AliVZEROdigit::kNClocks/2)) aBBflagsV0C |= (1 << offlineCh); | |
181 | if (rawStream.GetBGFlag(iChannel,AliVZEROdigit::kNClocks/2)) aBGflagsV0C |= (1 << offlineCh); | |
182 | } else { | |
183 | if (rawStream.GetBBFlag(iChannel,AliVZEROdigit::kNClocks/2)) aBBflagsV0A |= (1 << (offlineCh-32)); | |
184 | if (rawStream.GetBGFlag(iChannel,AliVZEROdigit::kNClocks/2)) aBGflagsV0A |= (1 << (offlineCh-32)); | |
185 | } | |
186 | // HPTDC data (leading time and width) | |
187 | Int_t board = AliVZEROCalibData::GetBoardNumber(offlineCh); | |
188 | Float_t time = rawStream.GetTime(iChannel)*fCalibData->GetTimeResolution(board); | |
189 | Float_t width = rawStream.GetWidth(iChannel)*fCalibData->GetWidthResolution(board); | |
190 | // Add a digit | |
191 | if(!fCalibData->IsChannelDead(iChannel)){ | |
192 | new ((*fDigitsArray)[fDigitsArray->GetEntriesFast()]) | |
193 | AliVZEROdigit(offlineCh, time, | |
194 | width,integrator, | |
195 | chargeADC); | |
196 | } | |
197 | ||
198 | // Filling the part of esd friend object that is available only for raw data | |
199 | fESDVZEROfriend->SetBBScalers(offlineCh,rawStream.GetBBScalers(iChannel)); | |
200 | fESDVZEROfriend->SetBGScalers(offlineCh,rawStream.GetBGScalers(iChannel)); | |
201 | for (Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++) { | |
202 | fESDVZEROfriend->SetChargeMB(offlineCh,iBunch,rawStream.GetChargeMB(iChannel,iBunch)); | |
203 | fESDVZEROfriend->SetIntMBFlag(offlineCh,iBunch,rawStream.GetIntMBFlag(iChannel,iBunch)); | |
204 | fESDVZEROfriend->SetBBMBFlag(offlineCh,iBunch,rawStream.GetBBMBFlag(iChannel,iBunch)); | |
205 | fESDVZEROfriend->SetBGMBFlag(offlineCh,iBunch,rawStream.GetBGMBFlag(iChannel,iBunch)); | |
206 | } | |
207 | for (Int_t iEv = 0; iEv < AliESDVZEROfriend::kNEvOfInt; iEv++) { | |
208 | fESDVZEROfriend->SetBBFlag(offlineCh,iEv,rawStream.GetBBFlag(iChannel,iEv)); | |
209 | fESDVZEROfriend->SetBGFlag(offlineCh,iEv,rawStream.GetBGFlag(iChannel,iEv)); | |
210 | } | |
211 | } | |
212 | ||
213 | // Filling the global part of esd friend object that is available only for raw data | |
214 | rawStream.FillTriggerBits(fTriggerData); | |
215 | fESDVZEROfriend->SetTriggerInputs(rawStream.GetTriggerInputs()); | |
216 | fESDVZEROfriend->SetTriggerInputsMask(rawStream.GetTriggerInputsMask()); | |
217 | ||
218 | for(Int_t iScaler = 0; iScaler < AliESDVZEROfriend::kNScalers; iScaler++) | |
219 | fESDVZEROfriend->SetTriggerScalers(iScaler,rawStream.GetTriggerScalers(iScaler)); | |
220 | ||
221 | for(Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++) | |
222 | fESDVZEROfriend->SetBunchNumbersMB(iBunch,rawStream.GetBunchNumbersMB(iBunch)); | |
223 | ||
224 | // Store the BB and BG flags in the digits tree (user info) | |
225 | digitsTree->GetUserInfo()->Add(new TParameter<int>("BBflagsV0A",aBBflagsV0A)); | |
226 | digitsTree->GetUserInfo()->Add(new TParameter<int>("BBflagsV0C",aBBflagsV0C)); | |
227 | digitsTree->GetUserInfo()->Add(new TParameter<int>("BGflagsV0A",aBGflagsV0A)); | |
228 | digitsTree->GetUserInfo()->Add(new TParameter<int>("BGflagsV0C",aBGflagsV0C)); | |
229 | ||
230 | UShort_t chargeA,chargeC; | |
231 | rawStream.CalculateChargeForCentrTriggers(fTriggerData,chargeA,chargeC); | |
232 | digitsTree->GetUserInfo()->Add(new TParameter<int>("ChargeA",(Int_t)chargeA)); | |
233 | digitsTree->GetUserInfo()->Add(new TParameter<int>("ChargeC",(Int_t)chargeC)); | |
234 | digitsTree->GetUserInfo()->Add(new TParameter<int>("TriggerInputs",(Int_t)rawStream.GetTriggerInputs())); | |
235 | ||
236 | digitsTree->Fill(); | |
237 | } | |
238 | ||
239 | fDigitsArray->Clear(); | |
240 | } | |
241 | ||
242 | //______________________________________________________________________ | |
243 | void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/, | |
244 | AliESDEvent* esd) const | |
245 | { | |
246 | // fills multiplicities to the ESD - pedestal is now subtracted | |
247 | ||
248 | if (!digitsTree) { | |
249 | AliError("No digits tree!"); | |
250 | return; | |
251 | } | |
252 | ||
253 | TBranch* digitBranch = digitsTree->GetBranch("VZERODigit"); | |
254 | digitBranch->SetAddress(&fDigitsArray); | |
255 | ||
256 | Float_t mult[64]; | |
257 | Float_t adc[64]; | |
258 | Float_t time[64]; | |
259 | Float_t width[64]; | |
260 | Bool_t aBBflag[64]; | |
261 | Bool_t aBGflag[64]; | |
262 | ||
263 | for (Int_t i=0; i<64; i++){ | |
264 | adc[i] = 0.0; | |
265 | mult[i] = 0.0; | |
266 | time[i] = kInvalidTime; | |
267 | width[i] = 0.0; | |
268 | aBBflag[i] = kFALSE; | |
269 | aBGflag[i] = kFALSE; | |
270 | } | |
271 | ||
272 | Int_t aBBflagsV0A = 0; | |
273 | Int_t aBBflagsV0C = 0; | |
274 | Int_t aBGflagsV0A = 0; | |
275 | Int_t aBGflagsV0C = 0; | |
276 | ||
277 | if (digitsTree->GetUserInfo()->FindObject("BBflagsV0A")) { | |
278 | aBBflagsV0A = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BBflagsV0A"))->GetVal(); | |
279 | } | |
280 | else { | |
281 | if (esd && (esd->GetEventType() == 7)) | |
282 | AliWarning("V0A beam-beam flags not found in digits tree UserInfo!"); | |
283 | } | |
284 | ||
285 | if (digitsTree->GetUserInfo()->FindObject("BBflagsV0C")) { | |
286 | aBBflagsV0C = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BBflagsV0C"))->GetVal(); | |
287 | } | |
288 | else { | |
289 | if (esd && (esd->GetEventType() == 7)) | |
290 | AliWarning("V0C beam-beam flags not found in digits tree UserInfo!"); | |
291 | } | |
292 | ||
293 | if (digitsTree->GetUserInfo()->FindObject("BGflagsV0A")) { | |
294 | aBGflagsV0A = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BGflagsV0A"))->GetVal(); | |
295 | } | |
296 | else { | |
297 | if (esd && (esd->GetEventType() == 7)) | |
298 | AliWarning("V0A beam-gas flags not found in digits tree UserInfo!"); | |
299 | } | |
300 | ||
301 | if (digitsTree->GetUserInfo()->FindObject("BGflagsV0C")) { | |
302 | aBGflagsV0C = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BGflagsV0C"))->GetVal(); | |
303 | } | |
304 | else { | |
305 | if (esd && (esd->GetEventType() == 7)) | |
306 | AliWarning("V0C beam-gas flags not found in digits tree UserInfo!"); | |
307 | } | |
308 | ||
309 | // Beam-beam and beam-gas flags (hardware) | |
310 | for (Int_t iChannel = 0; iChannel < 64; ++iChannel) { | |
311 | if(iChannel < 32) { | |
312 | aBBflag[iChannel] = (aBBflagsV0C >> iChannel) & 0x1; | |
313 | aBGflag[iChannel] = (aBGflagsV0C >> iChannel) & 0x1; | |
314 | } | |
315 | else { | |
316 | aBBflag[iChannel] = (aBBflagsV0A >> (iChannel-32)) & 0x1; | |
317 | aBGflag[iChannel] = (aBGflagsV0A >> (iChannel-32)) & 0x1; | |
318 | } | |
319 | } | |
320 | ||
321 | // Fill the trigger charges and bits | |
322 | UShort_t chargeA = 0; | |
323 | UShort_t chargeC = 0; | |
324 | UShort_t triggerInputs = 0; | |
325 | if (digitsTree->GetUserInfo()->FindObject("ChargeA")) { | |
326 | chargeA = (UShort_t)(((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("ChargeA"))->GetVal()); | |
327 | } | |
328 | else { | |
329 | if (esd && (esd->GetEventType() == 7)) | |
330 | AliWarning("V0A trigger charge not found in digits tree UserInfo!"); | |
331 | } | |
332 | ||
333 | if (digitsTree->GetUserInfo()->FindObject("ChargeC")) { | |
334 | chargeC = (UShort_t)(((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("ChargeC"))->GetVal()); | |
335 | } | |
336 | else { | |
337 | if (esd && (esd->GetEventType() == 7)) | |
338 | AliWarning("V0C trigger charge not found in digits tree UserInfo!"); | |
339 | } | |
340 | ||
341 | if (digitsTree->GetUserInfo()->FindObject("TriggerInputs")) { | |
342 | triggerInputs = (UShort_t)(((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("TriggerInputs"))->GetVal()); | |
343 | } | |
344 | else { | |
345 | if (esd && (esd->GetEventType() == 7)) | |
346 | AliWarning("V0C trigger charge not found in digits tree UserInfo!"); | |
347 | } | |
348 | ||
349 | fESDVZERO->SetTriggerChargeA(chargeA); | |
350 | fESDVZERO->SetTriggerChargeC(chargeC); | |
351 | fESDVZERO->SetTriggerBits(triggerInputs); | |
352 | fESDVZERO->SetBit(AliESDVZERO::kTriggerChargeBitsFilled,kTRUE); | |
353 | ||
354 | Int_t nEntries = (Int_t)digitsTree->GetEntries(); | |
355 | for (Int_t e=0; e<nEntries; e++) { | |
356 | digitsTree->GetEvent(e); | |
357 | ||
358 | Int_t nDigits = fDigitsArray->GetEntriesFast(); | |
359 | ||
360 | for (Int_t d=0; d<nDigits; d++) { | |
361 | AliVZEROdigit* digit = (AliVZEROdigit*) fDigitsArray->At(d); | |
362 | Int_t pmNumber = digit->PMNumber(); | |
363 | ||
364 | // Pedestal retrieval and suppression | |
365 | Bool_t integrator = digit->Integrator(); | |
366 | Float_t maxadc = 0; | |
367 | Int_t imax = -1; | |
368 | Float_t adcPedSub[AliVZEROdigit::kNClocks]; | |
369 | for(Int_t iClock=0; iClock < AliVZEROdigit::kNClocks; ++iClock) { | |
370 | Short_t charge = digit->ChargeADC(iClock); | |
371 | Bool_t iIntegrator = (iClock%2 == 0) ? integrator : !integrator; | |
372 | Int_t k = pmNumber + 64*iIntegrator; | |
373 | adcPedSub[iClock] = (Float_t)charge - fCalibData->GetPedestal(k); | |
374 | if(adcPedSub[iClock] <= GetRecoParam()->GetNSigmaPed()*fCalibData->GetSigma(k)) { | |
375 | adcPedSub[iClock] = 0; | |
376 | continue; | |
377 | } | |
378 | if(iClock < GetRecoParam()->GetStartClock() || iClock > GetRecoParam()->GetEndClock()) continue; | |
379 | if(adcPedSub[iClock] > maxadc) { | |
380 | maxadc = adcPedSub[iClock]; | |
381 | imax = iClock; | |
382 | } | |
383 | } | |
384 | ||
385 | if (imax != -1) { | |
386 | Int_t start = imax - GetRecoParam()->GetNPreClocks(); | |
387 | if (start < 0) start = 0; | |
388 | Int_t end = imax + GetRecoParam()->GetNPostClocks(); | |
389 | if (end > 20) end = 20; | |
390 | for(Int_t iClock = start; iClock <= end; iClock++) { | |
391 | adc[pmNumber] += adcPedSub[iClock]; | |
392 | } | |
393 | } | |
394 | ||
395 | // HPTDC leading time and width | |
396 | // Correction for slewing and various time delays | |
397 | time[pmNumber] = CorrectLeadingTime(pmNumber,digit->Time(),adc[pmNumber]); | |
398 | width[pmNumber] = digit->Width(); | |
399 | ||
400 | if (adc[pmNumber] > 0) { | |
401 | AliDebug(1,Form("PM = %d ADC = %f TDC %f (%f) Int %d (%d %d %d %d %d) %f %f %f %f %d %d",pmNumber, adc[pmNumber], | |
402 | digit->Time(),time[pmNumber], | |
403 | integrator, | |
404 | digit->ChargeADC(8),digit->ChargeADC(9),digit->ChargeADC(10), | |
405 | digit->ChargeADC(11),digit->ChargeADC(12), | |
406 | fCalibData->GetPedestal(pmNumber),fCalibData->GetSigma(pmNumber), | |
407 | fCalibData->GetPedestal(pmNumber+64),fCalibData->GetSigma(pmNumber+64), | |
408 | aBBflag[pmNumber],aBGflag[pmNumber])); | |
409 | }; | |
410 | ||
411 | TF1 *saturationFunc = (TF1*)fSaturationCorr->UncheckedAt(pmNumber); | |
412 | if (!saturationFunc) AliFatal(Form("Saturation correction for channel %d is not found!",pmNumber)); | |
413 | AliDebug(1,Form("Saturation PM=%d %f %f",pmNumber,adc[pmNumber],saturationFunc->Eval(adc[pmNumber]))); | |
414 | mult[pmNumber] = saturationFunc->Eval(adc[pmNumber])*fCalibData->GetMIPperADC(pmNumber); | |
415 | ||
416 | // Fill ESD friend object | |
417 | for (Int_t iEv = 0; iEv < AliESDVZEROfriend::kNEvOfInt; iEv++) { | |
418 | fESDVZEROfriend->SetPedestal(pmNumber,iEv,(Float_t)digit->ChargeADC(iEv)); | |
419 | fESDVZEROfriend->SetIntegratorFlag(pmNumber,iEv,(iEv%2 == 0) ? integrator : !integrator); | |
420 | } | |
421 | fESDVZEROfriend->SetTime(pmNumber,digit->Time()); | |
422 | fESDVZEROfriend->SetWidth(pmNumber,digit->Width()); | |
423 | ||
424 | } // end of loop over digits | |
425 | } // end of loop over events in digits tree | |
426 | ||
427 | fESDVZERO->SetBit(AliESDVZERO::kCorrectedLeadingTime,kTRUE); | |
428 | fESDVZERO->SetMultiplicity(mult); | |
429 | fESDVZERO->SetADC(adc); | |
430 | fESDVZERO->SetTime(time); | |
431 | fESDVZERO->SetWidth(width); | |
432 | fESDVZERO->SetBit(AliESDVZERO::kOnlineBitsFilled,kTRUE); | |
433 | fESDVZERO->SetBBFlag(aBBflag); | |
434 | fESDVZERO->SetBGFlag(aBGflag); | |
435 | fESDVZERO->SetBit(AliESDVZERO::kCorrectedForSaturation,kTRUE); | |
436 | ||
437 | // now fill the V0 decision and channel flags | |
438 | { | |
439 | AliVZEROTriggerMask triggerMask; | |
440 | triggerMask.SetRecoParam(GetRecoParam()); | |
441 | triggerMask.FillMasks(fESDVZERO, fCalibData, fTimeSlewing); | |
442 | } | |
443 | ||
444 | if (esd) { | |
445 | AliDebug(1, Form("Writing VZERO data to ESD tree")); | |
446 | esd->SetVZEROData(fESDVZERO); | |
447 | } | |
448 | ||
449 | if (esd) { | |
450 | AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend"); | |
451 | if (fr) { | |
452 | AliDebug(1, Form("Writing VZERO friend data to ESD tree")); | |
453 | fr->SetVZEROfriend(fESDVZEROfriend); | |
454 | } | |
455 | } | |
456 | ||
457 | fDigitsArray->Clear(); | |
458 | } | |
459 | ||
460 | //_____________________________________________________________________________ | |
461 | AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri) | |
462 | { | |
463 | // Sets the storage | |
464 | ||
465 | Bool_t deleteManager = kFALSE; | |
466 | ||
467 | AliCDBManager *manager = AliCDBManager::Instance(); | |
468 | AliCDBStorage *defstorage = manager->GetDefaultStorage(); | |
469 | ||
470 | if(!defstorage || !(defstorage->Contains("VZERO"))){ | |
471 | AliWarning("No default storage set or default storage doesn't contain VZERO!"); | |
472 | manager->SetDefaultStorage(uri); | |
473 | deleteManager = kTRUE; | |
474 | } | |
475 | ||
476 | AliCDBStorage *storage = manager->GetDefaultStorage(); | |
477 | ||
478 | if(deleteManager){ | |
479 | AliCDBManager::Instance()->UnsetDefaultStorage(); | |
480 | defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy() | |
481 | } | |
482 | ||
483 | return storage; | |
484 | } | |
485 | ||
486 | //____________________________________________________________________________ | |
487 | void AliVZEROReconstructor::GetCollisionMode() | |
488 | { | |
489 | // Retrieval of collision mode | |
490 | ||
491 | TString beamType = GetRunInfo()->GetBeamType(); | |
492 | if(beamType==AliGRPObject::GetInvalidString()){ | |
493 | AliError("VZERO cannot retrieve beam type"); | |
494 | return; | |
495 | } | |
496 | ||
497 | if( (beamType.CompareTo("P-P") ==0) || (beamType.CompareTo("p-p") ==0) ){ | |
498 | fCollisionMode=0; | |
499 | } | |
500 | else if( (beamType.CompareTo("Pb-Pb") ==0) || (beamType.CompareTo("A-A") ==0) ){ | |
501 | fCollisionMode=1; | |
502 | } | |
503 | ||
504 | fBeamEnergy = GetRunInfo()->GetBeamEnergy(); | |
505 | if(fBeamEnergy==AliGRPObject::GetInvalidFloat()) { | |
506 | AliError("Missing value for the beam energy ! Using 0"); | |
507 | fBeamEnergy = 0.; | |
508 | } | |
509 | ||
510 | AliDebug(1,Form("\n ++++++ Beam type and collision mode retrieved as %s %d @ %1.3f GeV ++++++\n\n",beamType.Data(), fCollisionMode, fBeamEnergy)); | |
511 | ||
512 | } | |
513 | ||
514 | //_____________________________________________________________________________ | |
515 | AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const | |
516 | { | |
517 | // Gets calibration object for VZERO set | |
518 | ||
519 | AliCDBManager *man = AliCDBManager::Instance(); | |
520 | ||
521 | AliCDBEntry *entry=0; | |
522 | ||
523 | entry = man->Get("VZERO/Calib/Data"); | |
524 | ||
525 | AliVZEROCalibData *calibdata = 0; | |
526 | ||
527 | if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject(); | |
528 | if (!calibdata) AliFatal("No calibration data from calibration database !"); | |
529 | ||
530 | return calibdata; | |
531 | } | |
532 | ||
533 | Float_t AliVZEROReconstructor::CorrectLeadingTime(Int_t i, Float_t time, Float_t adc) const | |
534 | { | |
535 | // Correct the leading time | |
536 | // for slewing effect and | |
537 | // misalignment of the channels | |
538 | if (time < 1e-6) return kInvalidTime; | |
539 | ||
540 | // Channel alignment and general offset subtraction | |
541 | if (i < 32) time -= kV0CDelayCables; | |
542 | time -= fTimeOffset[i]; | |
543 | ||
544 | // In case of pathological signals | |
545 | if (adc < 1e-6) return time; | |
546 | ||
547 | // Slewing correction | |
548 | Float_t thr = fCalibData->GetCalibDiscriThr(i,kTRUE); | |
549 | time -= fTimeSlewing->Eval(adc/thr); | |
550 | ||
551 | return time; | |
552 | } |