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