1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 /// class for VZERO reconstruction //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliRunLoader.h"
25 #include "AliRawReader.h"
26 #include "AliVZEROReconstructor.h"
27 #include "AliVZERORawStream.h"
28 #include "AliESDEvent.h"
29 #include "AliVZEROTriggerMask.h"
30 #include "AliESDfriend.h"
31 #include "AliESDVZEROfriend.h"
33 ClassImp(AliVZEROReconstructor)
35 //_____________________________________________________________________________
36 AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
40 fCalibData(GetCalibData())
42 // Default constructor
43 // Get calibration data
45 // fCalibData = GetCalibData();
50 //_____________________________________________________________________________
51 AliVZEROReconstructor& AliVZEROReconstructor::operator =
52 (const AliVZEROReconstructor& /*reconstructor*/)
54 // assignment operator
56 Fatal("operator =", "assignment operator not implemented");
60 //_____________________________________________________________________________
61 AliVZEROReconstructor::~AliVZEROReconstructor()
66 delete fESDVZEROfriend;
69 //_____________________________________________________________________________
70 void AliVZEROReconstructor::Init()
74 fESDVZERO = new AliESDVZERO;
75 fESDVZEROfriend = new AliESDVZEROfriend;
78 //______________________________________________________________________
79 void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
81 // converts RAW to digits - pedestal is subtracted
84 AliError("No digits tree!");
88 TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit");
89 digitsTree->Branch("VZERODigit", &digitsArray);
91 fESDVZEROfriend->Reset();
94 AliVZERORawStream rawStream(rawReader);
95 if (rawStream.Next()) {
96 Int_t ADC_max[64], adc[64], time[64], width[64], BBFlag[64], BGFlag[64];
97 for(Int_t i=0; i<64; i++) {
98 // Search for the maximum charge in the train of 21 LHC clocks
99 // regardless of the integrator which has been operated:
102 for(Int_t iClock=0; iClock<21; iClock++){
103 if((Int_t)rawStream.GetPedestal(i,iClock) > ADC_max[i])
104 {ADC_max[i]=(Int_t)rawStream.GetPedestal(i,iClock);
107 // Convert i (FEE channel numbering) to j (aliroot channel numbering)
108 Int_t j = rawStream.GetOfflineChannel(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);
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));
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));
130 fESDVZEROfriend->SetTime(j,rawStream.GetTime(i));
131 fESDVZEROfriend->SetWidth(j,rawStream.GetWidth(i));
134 // Filling the esd friend object
135 fESDVZEROfriend->SetTriggerInputs(rawStream.GetTriggerInputs());
136 fESDVZEROfriend->SetTriggerInputsMask(rawStream.GetTriggerInputsMask());
138 for(Int_t iScaler = 0; iScaler < AliESDVZEROfriend::kNScalers; iScaler++)
139 fESDVZEROfriend->SetTriggerScalers(iScaler,rawStream.GetTriggerScalers(iScaler));
141 for (Int_t iBunch = 0; iBunch < AliESDVZEROfriend::kNBunches; iBunch++)
142 fESDVZEROfriend->SetBunchNumbersMB(iBunch,rawStream.GetBunchNumbersMB(iBunch));
145 // Channels(aliroot numbering) will be ordered in the tree
146 for(Int_t iChannel = 0; iChannel < 64; iChannel++) {
147 new ((*digitsArray)[digitsArray->GetEntriesFast()])
148 AliVZEROdigit(iChannel, adc[iChannel], time[iChannel],
149 width[iChannel], BBFlag[iChannel], BGFlag[iChannel]);
156 //______________________________________________________________________
157 void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
158 AliESDEvent* esd) const
160 // fills multiplicities to the ESD
163 AliError("No digits tree!");
167 TClonesArray* digitsArray = NULL;
168 TBranch* digitBranch = digitsTree->GetBranch("VZERODigit");
169 digitBranch->SetAddress(&digitsArray);
171 Short_t Multiplicity[64];
179 for (Int_t i=0; i<64; i++){
188 // loop over VZERO entries to get multiplicity
189 Int_t nEntries = (Int_t)digitsTree->GetEntries();
190 for (Int_t e=0; e<nEntries; e++) {
191 digitsTree->GetEvent(e);
193 Int_t nDigits = digitsArray->GetEntriesFast();
195 for (Int_t d=0; d<nDigits; d++) {
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));
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();
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);
209 } // end of loop over digits
210 } // end of loop over events in digits tree
212 for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);
214 fESDVZERO->SetMultiplicity(Multiplicity);
215 fESDVZERO->SetADC(adc);
216 fESDVZERO->SetTime(time);
217 fESDVZERO->SetWidth(width);
218 fESDVZERO->SetBBFlag(BBFlag);
219 fESDVZERO->SetBGFlag(BGFlag);
221 // now get the trigger mask
223 AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
224 TriggerMask->SetAdcThreshold(20.0/2.0);
225 TriggerMask->SetTimeWindowWidthBBA(50);
226 TriggerMask->SetTimeWindowWidthBGA(20);
227 TriggerMask->SetTimeWindowWidthBBC(50);
228 TriggerMask->SetTimeWindowWidthBGC(20);
229 TriggerMask->FillMasks(digitsTree,digitsArray);
231 fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
232 fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
233 fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
234 fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
237 AliDebug(1, Form("Writing VZERO data to ESD tree"));
238 esd->SetVZEROData(fESDVZERO);
242 AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend");
244 AliDebug(1, Form("Writing VZERO friend data to ESD tree"));
245 fr->SetVZEROfriend(fESDVZEROfriend);
250 //_____________________________________________________________________________
251 AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
255 Bool_t deleteManager = kFALSE;
257 AliCDBManager *manager = AliCDBManager::Instance();
258 AliCDBStorage *defstorage = manager->GetDefaultStorage();
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;
266 AliCDBStorage *storage = manager->GetDefaultStorage();
269 AliCDBManager::Instance()->UnsetDefaultStorage();
270 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
276 //_____________________________________________________________________________
277 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
279 // Gets calibration object for VZERO set
281 AliCDBManager *man = AliCDBManager::Instance();
283 AliCDBEntry *entry=0;
285 entry = man->Get("VZERO/Calib/Data");
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);
296 // Retrieval of data in directory VZERO/Calib/Data:
298 AliVZEROCalibData *calibdata = 0;
300 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
301 if (!calibdata) AliFatal("No calibration data from calibration database !");
306 //_____________________________________________________________________________
307 Float_t AliVZEROReconstructor::GetMIP(Int_t channel) const {
309 // Computes the MIP conversion factor - MIP per ADC channel -
310 // Argument passed is the PM number (aliroot numbering)
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 };
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 };
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]);