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