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