]>
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" |
b0d2c2d3 | 26 | #include "AliVZEROReconstructor.h" |
2eb38194 | 27 | #include "AliVZERORawStream.h" |
b14e6eb4 | 28 | #include "AliESDEvent.h" |
a055ee24 | 29 | #include "AliVZEROTriggerMask.h" |
b090e6a3 | 30 | #include "AliESDfriend.h" |
31 | #include "AliESDVZEROfriend.h" | |
b0d2c2d3 | 32 | |
b0d2c2d3 | 33 | ClassImp(AliVZEROReconstructor) |
34 | ||
ce7090f5 | 35 | //_____________________________________________________________________________ |
cb2228e6 | 36 | AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(), |
35b120ff | 37 | fESDVZERO(0x0), |
38 | fESD(0x0), | |
b090e6a3 | 39 | fESDVZEROfriend(0x0), |
cb2228e6 | 40 | fCalibData(GetCalibData()) |
ce7090f5 | 41 | { |
42 | // Default constructor | |
ce7090f5 | 43 | // Get calibration data |
44 | ||
35b120ff | 45 | // fCalibData = GetCalibData(); |
44b6212f | 46 | |
ce7090f5 | 47 | } |
48 | ||
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliVZEROReconstructor& AliVZEROReconstructor::operator = | |
52 | (const AliVZEROReconstructor& /*reconstructor*/) | |
53 | { | |
54 | // assignment operator | |
55 | ||
56 | Fatal("operator =", "assignment operator not implemented"); | |
57 | return *this; | |
58 | } | |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | AliVZEROReconstructor::~AliVZEROReconstructor() | |
62 | { | |
63 | // destructor | |
44b6212f | 64 | |
b090e6a3 | 65 | delete fESDVZERO; |
66 | delete fESDVZEROfriend; | |
35b120ff | 67 | } |
68 | ||
69 | //_____________________________________________________________________________ | |
d76c31f4 | 70 | void AliVZEROReconstructor::Init() |
35b120ff | 71 | { |
ef314913 | 72 | // initializer |
ce7090f5 | 73 | |
35b120ff | 74 | fESDVZERO = new AliESDVZERO; |
b090e6a3 | 75 | fESDVZEROfriend = new AliESDVZEROfriend; |
35b120ff | 76 | } |
77 | ||
78 | //______________________________________________________________________ | |
2e0ee64a | 79 | void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
35b120ff | 80 | { |
44b6212f | 81 | // converts RAW to digits - pedestal is subtracted |
ef314913 | 82 | |
2e0ee64a | 83 | if (!digitsTree) { |
84 | AliError("No digits tree!"); | |
85 | return; | |
86 | } | |
35b120ff | 87 | |
2e0ee64a | 88 | TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit"); |
89 | digitsTree->Branch("VZERODigit", &digitsArray); | |
90 | ||
b090e6a3 | 91 | fESDVZEROfriend->Reset(); |
92 | ||
2e0ee64a | 93 | rawReader->Reset(); |
94 | AliVZERORawStream rawStream(rawReader); | |
9d62c464 | 95 | if (rawStream.Next()) { |
d0502ab2 | 96 | Int_t ADC_max[64], adc[64], time[64], width[64], BBFlag[64], BGFlag[64]; |
9d62c464 | 97 | for(Int_t i=0; i<64; i++) { |
44b6212f | 98 | // Search for the maximum charge in the train of 21 LHC clocks |
9d62c464 | 99 | // regardless of the integrator which has been operated: |
100 | ADC_max[i] = 0; | |
d0502ab2 | 101 | Int_t imax = 0; |
9d62c464 | 102 | for(Int_t iClock=0; iClock<21; iClock++){ |
103 | if((Int_t)rawStream.GetPedestal(i,iClock) > ADC_max[i]) | |
d0502ab2 | 104 | {ADC_max[i]=(Int_t)rawStream.GetPedestal(i,iClock); |
105 | imax = iClock;} | |
9d62c464 | 106 | } |
107 | // Convert i (FEE channel numbering) to j (aliroot channel numbering) | |
d0502ab2 | 108 | Int_t j = rawStream.GetOfflineChannel(i); |
109 | adc[j] = ADC_max[i]; | |
110 | time[j] = rawStream.GetTime(i); | |
111 | width[j] = rawStream.GetWidth(i); | |
112 | BBFlag[j] = rawStream.GetBBFlag(i,imax); | |
113 | BGFlag[j] = rawStream.GetBGFlag(i,imax); | |
b090e6a3 | 114 | |
115 | // Filling the esd friend object | |
116 | fESDVZEROfriend->SetBBScalers(j,rawStream.GetBBScalers(i)); | |
117 | fESDVZEROfriend->SetBGScalers(j,rawStream.GetBGScalers(i)); | |
118 | for (Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++) { | |
119 | fESDVZEROfriend->SetChargeMB(j,iBunch,rawStream.GetChargeMB(i,iBunch)); | |
120 | fESDVZEROfriend->SetIntMBFlag(j,iBunch,rawStream.GetIntMBFlag(i,iBunch)); | |
121 | fESDVZEROfriend->SetBBMBFlag(j,iBunch,rawStream.GetBBMBFlag(i,iBunch)); | |
122 | fESDVZEROfriend->SetBGMBFlag(j,iBunch,rawStream.GetBGMBFlag(i,iBunch)); | |
123 | } | |
124 | for (Int_t iEv = 0; iEv < AliESDVZEROfriend::kNEvOfInt; iEv++) { | |
125 | fESDVZEROfriend->SetPedestal(j,iEv,rawStream.GetPedestal(i,iEv)); | |
126 | fESDVZEROfriend->SetIntegratorFlag(j,iEv,rawStream.GetIntegratorFlag(i,iEv)); | |
127 | fESDVZEROfriend->SetBBFlag(j,iEv,rawStream.GetBBFlag(i,iEv)); | |
128 | fESDVZEROfriend->SetBGFlag(j,iEv,rawStream.GetBGFlag(i,iEv)); | |
129 | } | |
130 | fESDVZEROfriend->SetTime(j,rawStream.GetTime(i)); | |
131 | fESDVZEROfriend->SetWidth(j,rawStream.GetWidth(i)); | |
9d62c464 | 132 | } |
b090e6a3 | 133 | |
134 | // Filling the esd friend object | |
135 | fESDVZEROfriend->SetTriggerInputs(rawStream.GetTriggerInputs()); | |
136 | fESDVZEROfriend->SetTriggerInputsMask(rawStream.GetTriggerInputsMask()); | |
137 | ||
138 | for(Int_t iScaler = 0; iScaler < AliESDVZEROfriend::kNScalers; iScaler++) | |
139 | fESDVZEROfriend->SetTriggerScalers(iScaler,rawStream.GetTriggerScalers(iScaler)); | |
140 | ||
141 | for (Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++) | |
142 | fESDVZEROfriend->SetBunchNumbersMB(iBunch,rawStream.GetBunchNumbersMB(iBunch)); | |
143 | ||
144 | ||
9d62c464 | 145 | // Channels(aliroot numbering) will be ordered in the tree |
146 | for(Int_t iChannel = 0; iChannel < 64; iChannel++) { | |
147 | new ((*digitsArray)[digitsArray->GetEntriesFast()]) | |
d0502ab2 | 148 | AliVZEROdigit(iChannel, adc[iChannel], time[iChannel], |
149 | width[iChannel], BBFlag[iChannel], BGFlag[iChannel]); | |
9d62c464 | 150 | } |
2e0ee64a | 151 | } |
152 | ||
153 | digitsTree->Fill(); | |
154 | } | |
155 | ||
156 | //______________________________________________________________________ | |
157 | void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/, | |
b14e6eb4 | 158 | AliESDEvent* esd) const |
2e0ee64a | 159 | { |
ef314913 | 160 | // fills multiplicities to the ESD |
161 | ||
2e0ee64a | 162 | if (!digitsTree) { |
163 | AliError("No digits tree!"); | |
164 | return; | |
165 | } | |
a055ee24 | 166 | |
2e0ee64a | 167 | TClonesArray* digitsArray = NULL; |
168 | TBranch* digitBranch = digitsTree->GetBranch("VZERODigit"); | |
169 | digitBranch->SetAddress(&digitsArray); | |
35b120ff | 170 | |
a055ee24 | 171 | Short_t Multiplicity[64]; |
44b6212f | 172 | Float_t mult[64]; |
173 | Short_t adc[64]; | |
28fdf12c | 174 | Short_t time[64]; |
d0502ab2 | 175 | Short_t width[64]; |
176 | Bool_t BBFlag[64]; | |
177 | Bool_t BGFlag[64]; | |
178 | ||
35b120ff | 179 | for (Int_t i=0; i<64; i++){ |
d0502ab2 | 180 | adc[i] = 0; |
181 | mult[i] = 0.0; | |
182 | time[i] = 0; | |
183 | width[i] = 0; | |
184 | BBFlag[i] = kFALSE; | |
185 | BGFlag[i] = kFALSE; | |
a055ee24 | 186 | } |
35b120ff | 187 | |
a055ee24 | 188 | // loop over VZERO entries to get multiplicity |
2e0ee64a | 189 | Int_t nEntries = (Int_t)digitsTree->GetEntries(); |
35b120ff | 190 | for (Int_t e=0; e<nEntries; e++) { |
2e0ee64a | 191 | digitsTree->GetEvent(e); |
35b120ff | 192 | |
2e0ee64a | 193 | Int_t nDigits = digitsArray->GetEntriesFast(); |
35b120ff | 194 | |
195 | for (Int_t d=0; d<nDigits; d++) { | |
63627899 | 196 | AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d); |
197 | Int_t pmNumber = digit->PMNumber(); | |
198 | // Pedestal retrieval and suppression: | |
199 | Int_t pedestal = int(fCalibData->GetPedestal(d)); | |
d0502ab2 | 200 | adc[pmNumber] = (Short_t) digit->ADC() - pedestal; |
201 | time[pmNumber] = (Short_t) digit->Time(); | |
202 | width[pmNumber] = (Short_t) digit->Width(); | |
203 | BBFlag[pmNumber]= digit->BBFlag(); | |
204 | BGFlag[pmNumber]= digit->BGFlag(); | |
44b6212f | 205 | // printf("PM = %d, MIP per ADC channel = %f \n",pmNumber, GetMIP(pmNumber)); |
206 | // cut of ADC at 1MIP/2 | |
207 | if (adc[pmNumber] > (int(1.0/GetMIP(pmNumber)) /2) ) | |
208 | mult[pmNumber] += float(adc[pmNumber])*GetMIP(pmNumber); | |
35b120ff | 209 | } // end of loop over digits |
35b120ff | 210 | } // end of loop over events in digits tree |
211 | ||
d0502ab2 | 212 | for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5); |
213 | ||
a055ee24 | 214 | fESDVZERO->SetMultiplicity(Multiplicity); |
28fdf12c | 215 | fESDVZERO->SetADC(adc); |
216 | fESDVZERO->SetTime(time); | |
d0502ab2 | 217 | fESDVZERO->SetWidth(width); |
218 | fESDVZERO->SetBBFlag(BBFlag); | |
219 | fESDVZERO->SetBGFlag(BGFlag); | |
a055ee24 | 220 | |
221 | // now get the trigger mask | |
222 | ||
223 | AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask(); | |
44b6212f | 224 | TriggerMask->SetAdcThreshold(20.0/2.0); |
a055ee24 | 225 | TriggerMask->SetTimeWindowWidthBBA(50); |
226 | TriggerMask->SetTimeWindowWidthBGA(20); | |
227 | TriggerMask->SetTimeWindowWidthBBC(50); | |
228 | TriggerMask->SetTimeWindowWidthBGC(20); | |
229 | TriggerMask->FillMasks(digitsTree,digitsArray); | |
230 | ||
231 | fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A()); | |
232 | fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A()); | |
233 | fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C()); | |
234 | fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C()); | |
35b120ff | 235 | |
2e0ee64a | 236 | if (esd) { |
44b6212f | 237 | AliDebug(1, Form("Writing VZERO data to ESD tree")); |
238 | esd->SetVZEROData(fESDVZERO); | |
2e0ee64a | 239 | } |
b090e6a3 | 240 | |
241 | if (esd) { | |
242 | AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend"); | |
243 | if (fr) { | |
244 | AliDebug(1, Form("Writing VZERO friend data to ESD tree")); | |
245 | fr->SetVZEROfriend(fESDVZEROfriend); | |
246 | } | |
247 | } | |
35b120ff | 248 | } |
249 | ||
ce7090f5 | 250 | //_____________________________________________________________________________ |
251 | AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri) | |
252 | { | |
ef314913 | 253 | // Sets the storage |
254 | ||
ce7090f5 | 255 | Bool_t deleteManager = kFALSE; |
256 | ||
257 | AliCDBManager *manager = AliCDBManager::Instance(); | |
258 | AliCDBStorage *defstorage = manager->GetDefaultStorage(); | |
259 | ||
260 | if(!defstorage || !(defstorage->Contains("VZERO"))){ | |
261 | AliWarning("No default storage set or default storage doesn't contain VZERO!"); | |
262 | manager->SetDefaultStorage(uri); | |
263 | deleteManager = kTRUE; | |
264 | } | |
265 | ||
266 | AliCDBStorage *storage = manager->GetDefaultStorage(); | |
267 | ||
268 | if(deleteManager){ | |
44b6212f | 269 | AliCDBManager::Instance()->UnsetDefaultStorage(); |
270 | defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy() | |
ce7090f5 | 271 | } |
272 | ||
273 | return storage; | |
274 | } | |
275 | ||
276 | //_____________________________________________________________________________ | |
277 | AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const | |
278 | { | |
ef314913 | 279 | // Gets calibration object for VZERO set |
ce7090f5 | 280 | |
c0b82b5a | 281 | AliCDBManager *man = AliCDBManager::Instance(); |
ce7090f5 | 282 | |
c0b82b5a | 283 | AliCDBEntry *entry=0; |
284 | ||
285 | entry = man->Get("VZERO/Calib/Data"); | |
286 | ||
94a600a1 | 287 | // if(!entry){ |
288 | // AliWarning("Load of calibration data from default storage failed!"); | |
289 | // AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)"); | |
290 | // Int_t runNumber = man->GetRun(); | |
291 | // entry = man->GetStorage("local://$ALICE_ROOT") | |
292 | // ->Get("VZERO/Calib/Data",runNumber); | |
293 | // | |
294 | // } | |
c0b82b5a | 295 | |
296 | // Retrieval of data in directory VZERO/Calib/Data: | |
297 | ||
c0b82b5a | 298 | AliVZEROCalibData *calibdata = 0; |
299 | ||
300 | if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject(); | |
94a600a1 | 301 | if (!calibdata) AliFatal("No calibration data from calibration database !"); |
ce7090f5 | 302 | |
303 | return calibdata; | |
304 | } | |
44b6212f | 305 | |
306 | //_____________________________________________________________________________ | |
307 | Float_t AliVZEROReconstructor::GetMIP(Int_t channel) const { | |
308 | ||
309 | // Computes the MIP conversion factor - MIP per ADC channel - | |
310 | // Argument passed is the PM number (aliroot numbering) | |
311 | ||
312 | Float_t P0[64] = { | |
313 | 7.094891, 7.124938, 7.089708, 7.098169, 7.094482, 7.147250, 7.170978, 7.183392, | |
314 | 7.145760, 7.148096, 7.153840, 7.143544, 7.186069, 7.194580, 7.203516, 7.195176, | |
315 | 7.188333, 7.198607, 7.209412, 7.226565, 7.221695, 7.205132, 7.191238, 7.227724, | |
316 | 7.232810, 7.252655, 7.230309, 7.273518, 7.273518, 7.242969, 7.252859, 7.252655, | |
317 | 7.026802, 7.079913, 7.134147, 7.092387, 7.079561, 7.072848, 7.123192, 7.003141, | |
318 | 7.024667, 7.124784, 7.123442, 7.129744, 7.110671, 7.143031, 7.139439, 7.178109, | |
319 | 7.247803, 7.139396, 7.293809, 7.094454, 6.992198, 7.206448, 7.244765, 7.056197, | |
320 | 7.263595, 7.138569, 7.089582, 7.215683, 7.266183, 7.165123, 7.243276, 7.235135 }; | |
321 | Float_t P1[64] = { | |
322 | 0.135569, 0.146405, 0.142425, 0.144278, 0.142307, 0.141648, 0.128477, 0.138239, | |
323 | 0.144173, 0.143419, 0.143572, 0.144482, 0.138024, 0.136542, 0.135955, 0.138537, | |
324 | 0.148521, 0.141999, 0.139627, 0.130014, 0.134970, 0.135635, 0.139094, 0.140634, | |
325 | 0.137971, 0.142080, 0.142793, 0.142778, 0.142778, 0.146045, 0.139133, 0.142080, | |
326 | 0.144121, 0.142311, 0.136564, 0.142686, 0.138792, 0.166285, 0.136387, 0.155391, | |
327 | 0.176082, 0.140408, 0.164738, 0.144270, 0.142766, 0.147486, 0.141951, 0.138012, | |
328 | 0.132394, 0.142849, 0.140477, 0.144592, 0.141558, 0.157646, 0.143758, 0.173385, | |
329 | 0.146489, 0.143279, 0.145230, 0.147203, 0.147333, 0.144979, 0.148597, 0.138985 }; | |
330 | ||
331 | // High Voltage retrieval from Calibration Data Base: | |
332 | Float_t HV = fCalibData->GetMeanHV(channel); | |
333 | Float_t MIP = 0.5/TMath::Exp((TMath::Log(HV) - P0[channel] )/P1[channel]); | |
334 | return MIP; | |
335 | ||
336 | } |