]>
Commit | Line | Data |
---|---|---|
b0d2c2d3 | 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 | ||
35b120ff | 24 | #include "AliRunLoader.h" |
2eb38194 | 25 | #include "AliRawReader.h" |
fe0adf2a | 26 | #include "AliGRPObject.h" |
27 | #include "AliCDBManager.h" | |
28 | #include "AliCDBStorage.h" | |
29 | #include "AliCDBEntry.h" | |
b0d2c2d3 | 30 | #include "AliVZEROReconstructor.h" |
2eb38194 | 31 | #include "AliVZERORawStream.h" |
b14e6eb4 | 32 | #include "AliESDEvent.h" |
a055ee24 | 33 | #include "AliVZEROTriggerMask.h" |
b090e6a3 | 34 | #include "AliESDfriend.h" |
35 | #include "AliESDVZEROfriend.h" | |
fad64858 | 36 | #include "AliVZEROdigit.h" |
e58b4e66 | 37 | #include "AliVZEROCalibData.h" |
75b6bc77 | 38 | #include "AliRunInfo.h" |
b0d2c2d3 | 39 | |
b0d2c2d3 | 40 | ClassImp(AliVZEROReconstructor) |
41 | ||
ce7090f5 | 42 | //_____________________________________________________________________________ |
cb2228e6 | 43 | AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(), |
fe0adf2a | 44 | fESDVZERO(0x0), |
45 | fESD(0x0), | |
46 | fESDVZEROfriend(0x0), | |
47 | fCalibData(GetCalibData()), | |
48 | fCollisionMode(0), | |
49 | fBeamEnergy(0.) | |
ce7090f5 | 50 | { |
51 | // Default constructor | |
ce7090f5 | 52 | // Get calibration data |
53 | ||
35b120ff | 54 | // fCalibData = GetCalibData(); |
44b6212f | 55 | |
ce7090f5 | 56 | } |
57 | ||
58 | ||
59 | //_____________________________________________________________________________ | |
60 | AliVZEROReconstructor& AliVZEROReconstructor::operator = | |
61 | (const AliVZEROReconstructor& /*reconstructor*/) | |
62 | { | |
63 | // assignment operator | |
64 | ||
65 | Fatal("operator =", "assignment operator not implemented"); | |
66 | return *this; | |
67 | } | |
68 | ||
69 | //_____________________________________________________________________________ | |
70 | AliVZEROReconstructor::~AliVZEROReconstructor() | |
71 | { | |
72 | // destructor | |
44b6212f | 73 | |
b090e6a3 | 74 | delete fESDVZERO; |
75 | delete fESDVZEROfriend; | |
35b120ff | 76 | } |
77 | ||
78 | //_____________________________________________________________________________ | |
d76c31f4 | 79 | void AliVZEROReconstructor::Init() |
35b120ff | 80 | { |
ef314913 | 81 | // initializer |
ce7090f5 | 82 | |
35b120ff | 83 | fESDVZERO = new AliESDVZERO; |
b090e6a3 | 84 | fESDVZEROfriend = new AliESDVZEROfriend; |
fe0adf2a | 85 | |
86 | GetCollisionMode(); // fCollisionMode =1 for Pb-Pb simulated data | |
35b120ff | 87 | } |
88 | ||
89 | //______________________________________________________________________ | |
2e0ee64a | 90 | void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
35b120ff | 91 | { |
75b6bc77 | 92 | // converts RAW to digits |
ef314913 | 93 | |
2e0ee64a | 94 | if (!digitsTree) { |
95 | AliError("No digits tree!"); | |
96 | return; | |
97 | } | |
35b120ff | 98 | |
2e0ee64a | 99 | TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit"); |
100 | digitsTree->Branch("VZERODigit", &digitsArray); | |
101 | ||
b090e6a3 | 102 | fESDVZEROfriend->Reset(); |
103 | ||
2e0ee64a | 104 | rawReader->Reset(); |
105 | AliVZERORawStream rawStream(rawReader); | |
75b6bc77 | 106 | if (rawStream.Next()) { |
107 | Float_t adc[64]; | |
6c115a32 | 108 | Float_t time[64], width[64]; |
75b6bc77 | 109 | Bool_t BBFlag[64], BGFlag[64], integrator[64]; |
9d62c464 | 110 | for(Int_t i=0; i<64; i++) { |
75b6bc77 | 111 | Int_t j = rawStream.GetOfflineChannel(i); |
112 | adc[j] = 0.0; | |
113 | time[j] = 0.0; | |
114 | width[j] = 0.0; | |
115 | BBFlag[j] = kFALSE; | |
116 | BGFlag[j] = kFALSE; | |
117 | integrator[j] = kFALSE; | |
118 | // Search for the maximum charge in the train of 21 LHC clocks | |
119 | // regardless of the integrator which has been operated: | |
120 | Float_t maxadc = 0; | |
121 | Int_t imax = -1; | |
122 | Float_t adcPedSub[21]; | |
123 | for(Int_t iClock=0; iClock<21; iClock++){ | |
124 | Bool_t iIntegrator = rawStream.GetIntegratorFlag(i,iClock); | |
125 | Int_t k = j+64*iIntegrator; | |
126 | adcPedSub[iClock] = rawStream.GetPedestal(i,iClock) - fCalibData->GetPedestal(k); | |
127 | if(adcPedSub[iClock] <= GetRecoParam()->GetNSigmaPed()*fCalibData->GetSigma(k)) { | |
128 | adcPedSub[iClock] = 0; | |
129 | continue; | |
130 | } | |
131 | if(iClock < GetRecoParam()->GetStartClock() || iClock > GetRecoParam()->GetEndClock()) continue; | |
132 | if(adcPedSub[iClock] > maxadc) { | |
133 | maxadc = adcPedSub[iClock]; | |
134 | imax = iClock; | |
135 | } | |
136 | } | |
137 | ||
138 | AliDebug(2,Form("Channel %d (online), %d (offline)",i,j)); | |
139 | if (imax != -1) { | |
140 | Int_t start = imax - GetRecoParam()->GetNPreClocks(); | |
141 | if (start < 0) start = 0; | |
142 | Int_t end = imax + GetRecoParam()->GetNPostClocks(); | |
143 | if (end > 20) end = 20; | |
144 | for(Int_t iClock = start; iClock <= end; iClock++) { | |
f93f97bb | 145 | if (iClock >= imax) { |
146 | BBFlag[j] |= rawStream.GetBBFlag(i,iClock); | |
147 | BGFlag[j] |= rawStream.GetBGFlag(i,iClock); | |
148 | } | |
75b6bc77 | 149 | if (iClock == imax) |
150 | adc[j] += rawStream.GetPedestal(i,iClock); | |
151 | else | |
152 | adc[j] += adcPedSub[iClock]; | |
153 | ||
154 | AliDebug(2,Form("clock = %d adc = %f",iClock,rawStream.GetPedestal(i,iClock))); | |
155 | } | |
156 | // Convert i (FEE channel numbering) to j (aliroot channel numbering) | |
157 | ||
158 | Int_t board = j / 8; | |
159 | time[j] = rawStream.GetTime(i)/ (25./256.) * fCalibData->GetTimeResolution(board); | |
160 | width[j] = rawStream.GetWidth(i) / 0.4 * fCalibData->GetWidthResolution(board); | |
75b6bc77 | 161 | integrator[j] = rawStream.GetIntegratorFlag(i,imax); |
162 | } | |
b090e6a3 | 163 | |
164 | // Filling the esd friend object | |
165 | fESDVZEROfriend->SetBBScalers(j,rawStream.GetBBScalers(i)); | |
166 | fESDVZEROfriend->SetBGScalers(j,rawStream.GetBGScalers(i)); | |
167 | for (Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++) { | |
db0db003 | 168 | fESDVZEROfriend->SetChargeMB(j,iBunch,rawStream.GetChargeMB(i,iBunch)); |
169 | fESDVZEROfriend->SetIntMBFlag(j,iBunch,rawStream.GetIntMBFlag(i,iBunch)); | |
170 | fESDVZEROfriend->SetBBMBFlag(j,iBunch,rawStream.GetBBMBFlag(i,iBunch)); | |
171 | fESDVZEROfriend->SetBGMBFlag(j,iBunch,rawStream.GetBGMBFlag(i,iBunch)); | |
b090e6a3 | 172 | } |
173 | for (Int_t iEv = 0; iEv < AliESDVZEROfriend::kNEvOfInt; iEv++) { | |
db0db003 | 174 | fESDVZEROfriend->SetPedestal(j,iEv,rawStream.GetPedestal(i,iEv)); |
175 | fESDVZEROfriend->SetIntegratorFlag(j,iEv,rawStream.GetIntegratorFlag(i,iEv)); | |
176 | fESDVZEROfriend->SetBBFlag(j,iEv,rawStream.GetBBFlag(i,iEv)); | |
177 | fESDVZEROfriend->SetBGFlag(j,iEv,rawStream.GetBGFlag(i,iEv)); | |
b090e6a3 | 178 | } |
e58b4e66 | 179 | fESDVZEROfriend->SetTime(j,time[j]); |
180 | fESDVZEROfriend->SetWidth(j,width[j]); | |
9d62c464 | 181 | } |
b090e6a3 | 182 | |
183 | // Filling the esd friend object | |
184 | fESDVZEROfriend->SetTriggerInputs(rawStream.GetTriggerInputs()); | |
185 | fESDVZEROfriend->SetTriggerInputsMask(rawStream.GetTriggerInputsMask()); | |
186 | ||
187 | for(Int_t iScaler = 0; iScaler < AliESDVZEROfriend::kNScalers; iScaler++) | |
db0db003 | 188 | fESDVZEROfriend->SetTriggerScalers(iScaler,rawStream.GetTriggerScalers(iScaler)); |
b090e6a3 | 189 | |
db0db003 | 190 | for(Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++) |
191 | fESDVZEROfriend->SetBunchNumbersMB(iBunch,rawStream.GetBunchNumbersMB(iBunch)); | |
b090e6a3 | 192 | |
193 | ||
9d62c464 | 194 | // Channels(aliroot numbering) will be ordered in the tree |
195 | for(Int_t iChannel = 0; iChannel < 64; iChannel++) { | |
7495d2be | 196 | if(fCalibData->IsChannelDead(iChannel)){ |
197 | adc[iChannel] = (Float_t) kInvalidADC; | |
198 | time[iChannel] = (Float_t) kInvalidTime; | |
199 | } | |
75b6bc77 | 200 | if (adc[iChannel] > 0) |
201 | new ((*digitsArray)[digitsArray->GetEntriesFast()]) | |
d0502ab2 | 202 | AliVZEROdigit(iChannel, adc[iChannel], time[iChannel], |
fad64858 | 203 | width[iChannel], BBFlag[iChannel], BGFlag[iChannel],integrator[iChannel]); |
7495d2be | 204 | |
f0ff6fad | 205 | } |
206 | digitsTree->Fill(); | |
2e0ee64a | 207 | } |
2e0ee64a | 208 | } |
209 | ||
210 | //______________________________________________________________________ | |
211 | void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/, | |
b14e6eb4 | 212 | AliESDEvent* esd) const |
2e0ee64a | 213 | { |
75b6bc77 | 214 | // fills multiplicities to the ESD - pedestal is now subtracted |
fe0adf2a | 215 | |
2e0ee64a | 216 | if (!digitsTree) { |
fe0adf2a | 217 | AliError("No digits tree!"); |
218 | return; | |
2e0ee64a | 219 | } |
a055ee24 | 220 | |
2e0ee64a | 221 | TClonesArray* digitsArray = NULL; |
222 | TBranch* digitBranch = digitsTree->GetBranch("VZERODigit"); | |
223 | digitBranch->SetAddress(&digitsArray); | |
35b120ff | 224 | |
44b6212f | 225 | Float_t mult[64]; |
db0db003 | 226 | Float_t adc[64]; |
227 | Float_t time[64]; | |
228 | Float_t width[64]; | |
d0502ab2 | 229 | Bool_t BBFlag[64]; |
230 | Bool_t BGFlag[64]; | |
231 | ||
35b120ff | 232 | for (Int_t i=0; i<64; i++){ |
db0db003 | 233 | adc[i] = 0.0; |
d0502ab2 | 234 | mult[i] = 0.0; |
db0db003 | 235 | time[i] = 0.0; |
236 | width[i] = 0.0; | |
d0502ab2 | 237 | BBFlag[i] = kFALSE; |
238 | BGFlag[i] = kFALSE; | |
a055ee24 | 239 | } |
35b120ff | 240 | |
a055ee24 | 241 | // loop over VZERO entries to get multiplicity |
2e0ee64a | 242 | Int_t nEntries = (Int_t)digitsTree->GetEntries(); |
35b120ff | 243 | for (Int_t e=0; e<nEntries; e++) { |
2e0ee64a | 244 | digitsTree->GetEvent(e); |
35b120ff | 245 | |
2e0ee64a | 246 | Int_t nDigits = digitsArray->GetEntriesFast(); |
35b120ff | 247 | |
248 | for (Int_t d=0; d<nDigits; d++) { | |
63627899 | 249 | AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d); |
250 | Int_t pmNumber = digit->PMNumber(); | |
251 | // Pedestal retrieval and suppression: | |
75b6bc77 | 252 | Bool_t integrator = digit->Integrator(); |
f93f97bb | 253 | Int_t k = pmNumber+64*integrator; |
254 | Float_t pedestal = fCalibData->GetPedestal(k); | |
db0db003 | 255 | adc[pmNumber] = digit->ADC() - pedestal; |
256 | time[pmNumber] = digit->Time(); | |
257 | width[pmNumber] = digit->Width(); | |
258 | BBFlag[pmNumber]= digit->BBFlag(); | |
259 | BGFlag[pmNumber]= digit->BGFlag(); | |
75b6bc77 | 260 | |
261 | AliDebug(2,Form("PM = %d ADC = %f TDC %f",pmNumber, digit->ADC(),digit->Time())); | |
262 | ||
75b6bc77 | 263 | if(adc[pmNumber] > (fCalibData->GetPedestal(k) + GetRecoParam()->GetNSigmaPed()*fCalibData->GetSigma(k))) { |
264 | mult[pmNumber] += adc[pmNumber]*fCalibData->GetMIPperADC(pmNumber); | |
fe0adf2a | 265 | } |
35b120ff | 266 | } // end of loop over digits |
35b120ff | 267 | } // end of loop over events in digits tree |
6c6d6114 | 268 | |
269 | fESDVZERO->SetMultiplicity(mult); | |
28fdf12c | 270 | fESDVZERO->SetADC(adc); |
271 | fESDVZERO->SetTime(time); | |
d0502ab2 | 272 | fESDVZERO->SetWidth(width); |
273 | fESDVZERO->SetBBFlag(BBFlag); | |
274 | fESDVZERO->SetBGFlag(BGFlag); | |
a055ee24 | 275 | |
276 | // now get the trigger mask | |
277 | ||
278 | AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask(); | |
fe0adf2a | 279 | TriggerMask->SetAdcThreshold(10.0/2.0); |
a055ee24 | 280 | TriggerMask->SetTimeWindowWidthBBA(50); |
281 | TriggerMask->SetTimeWindowWidthBGA(20); | |
282 | TriggerMask->SetTimeWindowWidthBBC(50); | |
283 | TriggerMask->SetTimeWindowWidthBGC(20); | |
284 | TriggerMask->FillMasks(digitsTree,digitsArray); | |
285 | ||
286 | fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A()); | |
287 | fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A()); | |
288 | fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C()); | |
289 | fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C()); | |
35b120ff | 290 | |
2e0ee64a | 291 | if (esd) { |
44b6212f | 292 | AliDebug(1, Form("Writing VZERO data to ESD tree")); |
293 | esd->SetVZEROData(fESDVZERO); | |
2e0ee64a | 294 | } |
b090e6a3 | 295 | |
296 | if (esd) { | |
fe0adf2a | 297 | AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend"); |
298 | if (fr) { | |
299 | AliDebug(1, Form("Writing VZERO friend data to ESD tree")); | |
300 | fr->SetVZEROfriend(fESDVZEROfriend); | |
b090e6a3 | 301 | } |
302 | } | |
35b120ff | 303 | } |
304 | ||
ce7090f5 | 305 | //_____________________________________________________________________________ |
306 | AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri) | |
307 | { | |
ef314913 | 308 | // Sets the storage |
309 | ||
ce7090f5 | 310 | Bool_t deleteManager = kFALSE; |
311 | ||
312 | AliCDBManager *manager = AliCDBManager::Instance(); | |
313 | AliCDBStorage *defstorage = manager->GetDefaultStorage(); | |
314 | ||
315 | if(!defstorage || !(defstorage->Contains("VZERO"))){ | |
316 | AliWarning("No default storage set or default storage doesn't contain VZERO!"); | |
317 | manager->SetDefaultStorage(uri); | |
318 | deleteManager = kTRUE; | |
319 | } | |
320 | ||
321 | AliCDBStorage *storage = manager->GetDefaultStorage(); | |
322 | ||
323 | if(deleteManager){ | |
44b6212f | 324 | AliCDBManager::Instance()->UnsetDefaultStorage(); |
325 | defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy() | |
ce7090f5 | 326 | } |
327 | ||
328 | return storage; | |
329 | } | |
330 | ||
fe0adf2a | 331 | //____________________________________________________________________________ |
332 | void AliVZEROReconstructor::GetCollisionMode() | |
333 | { | |
75b6bc77 | 334 | // Retrieval of collision mode |
fe0adf2a | 335 | |
75b6bc77 | 336 | TString beamType = GetRunInfo()->GetBeamType(); |
fe0adf2a | 337 | if(beamType==AliGRPObject::GetInvalidString()){ |
75b6bc77 | 338 | AliError("VZERO cannot retrieve beam type"); |
fe0adf2a | 339 | return; |
340 | } | |
341 | ||
75b6bc77 | 342 | if( (beamType.CompareTo("P-P") ==0) || (beamType.CompareTo("p-p") ==0) ){ |
343 | fCollisionMode=0; | |
344 | } | |
345 | else if( (beamType.CompareTo("Pb-Pb") ==0) || (beamType.CompareTo("A-A") ==0) ){ | |
346 | fCollisionMode=1; | |
fe0adf2a | 347 | } |
fe0adf2a | 348 | |
75b6bc77 | 349 | fBeamEnergy = GetRunInfo()->GetBeamEnergy(); |
fe0adf2a | 350 | if(fBeamEnergy==AliGRPObject::GetInvalidFloat()) { |
75b6bc77 | 351 | AliError("Missing value for the beam energy ! Using 0"); |
fe0adf2a | 352 | fBeamEnergy = 0.; |
353 | } | |
354 | ||
75b6bc77 | 355 | AliDebug(1,Form("\n ++++++ Beam type and collision mode retrieved as %s %d @ %1.3f GeV ++++++\n\n",beamType.Data(), fCollisionMode, fBeamEnergy)); |
fe0adf2a | 356 | |
357 | } | |
358 | ||
ce7090f5 | 359 | //_____________________________________________________________________________ |
360 | AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const | |
361 | { | |
ef314913 | 362 | // Gets calibration object for VZERO set |
ce7090f5 | 363 | |
c0b82b5a | 364 | AliCDBManager *man = AliCDBManager::Instance(); |
ce7090f5 | 365 | |
c0b82b5a | 366 | AliCDBEntry *entry=0; |
367 | ||
368 | entry = man->Get("VZERO/Calib/Data"); | |
369 | ||
94a600a1 | 370 | // if(!entry){ |
371 | // AliWarning("Load of calibration data from default storage failed!"); | |
372 | // AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)"); | |
373 | // Int_t runNumber = man->GetRun(); | |
162637e4 | 374 | // entry = man->GetStorage("local://$ALICE_ROOT/OCDB") |
94a600a1 | 375 | // ->Get("VZERO/Calib/Data",runNumber); |
376 | // | |
377 | // } | |
c0b82b5a | 378 | |
379 | // Retrieval of data in directory VZERO/Calib/Data: | |
380 | ||
c0b82b5a | 381 | AliVZEROCalibData *calibdata = 0; |
382 | ||
383 | if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject(); | |
94a600a1 | 384 | if (!calibdata) AliFatal("No calibration data from calibration database !"); |
ce7090f5 | 385 | |
386 | return calibdata; | |
387 | } | |
44b6212f | 388 |