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