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