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"
31 ClassImp(AliVZEROReconstructor)
33 //_____________________________________________________________________________
34 AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
37 fCalibData(GetCalibData())
39 // Default constructor
40 // Get calibration data
42 // fCalibData = GetCalibData();
46 //_____________________________________________________________________________
47 AliVZEROReconstructor& AliVZEROReconstructor::operator =
48 (const AliVZEROReconstructor& /*reconstructor*/)
50 // assignment operator
52 Fatal("operator =", "assignment operator not implemented");
56 //_____________________________________________________________________________
57 AliVZEROReconstructor::~AliVZEROReconstructor()
64 //_____________________________________________________________________________
65 void AliVZEROReconstructor::Init()
69 fESDVZERO = new AliESDVZERO;
72 //______________________________________________________________________
73 void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
75 // converts RAW to digits
78 AliError("No digits tree!");
82 TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit");
83 digitsTree->Branch("VZERODigit", &digitsArray);
86 AliVZERORawStream rawStream(rawReader);
87 if (rawStream.Next()) {
88 Int_t ADC_max[64], adc[64], time[64];
89 for(Int_t i=0; i<64; i++) {
90 // Search for the maximun charge in the train of 21 LHC clocks
91 // regardless of the integrator which has been operated:
93 for(Int_t iClock=0; iClock<21; iClock++){
94 if((Int_t)rawStream.GetPedestal(i,iClock) > ADC_max[i])
95 {ADC_max[i]=(Int_t)rawStream.GetPedestal(i,iClock);}
97 // Convert i (FEE channel numbering) to j (aliroot channel numbering)
98 Int_t j = rawStream.GetOfflineChannel(i);
100 time[j] = rawStream.GetTime(i);
102 // Channels(aliroot numbering) will be ordered in the tree
103 for(Int_t iChannel = 0; iChannel < 64; iChannel++) {
104 new ((*digitsArray)[digitsArray->GetEntriesFast()])
105 AliVZEROdigit(iChannel,adc[iChannel],time[iChannel]);
112 //______________________________________________________________________
113 void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
114 AliESDEvent* esd) const
116 // fills multiplicities to the ESD
119 AliError("No digits tree!");
123 TClonesArray* digitsArray = NULL;
124 TBranch* digitBranch = digitsTree->GetBranch("VZERODigit");
125 digitBranch->SetAddress(&digitsArray);
127 const Float_t mip0=110.0;
128 Short_t Multiplicity[64];
133 for (Int_t i=0; i<64; i++){
139 // loop over VZERO entries to get multiplicity
140 Int_t nEntries = (Int_t)digitsTree->GetEntries();
141 for (Int_t e=0; e<nEntries; e++) {
142 digitsTree->GetEvent(e);
144 Int_t nDigits = digitsArray->GetEntriesFast();
146 for (Int_t d=0; d<nDigits; d++) {
147 AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d);
148 Int_t pmNumber = digit->PMNumber();
149 // Pedestal retrieval and suppression:
150 Int_t pedestal = int(fCalibData->GetPedestal(d));
151 adc[pmNumber] = (Short_t) digit->ADC() - pedestal;
152 time[pmNumber] = (Short_t) digit->Time();
153 // cut of ADC at MIP/2
154 if (adc[pmNumber] > (mip[pmNumber]/2))
155 mult[pmNumber] += float(adc[pmNumber])/mip[pmNumber];
156 } // end of loop over digits
157 } // end of loop over events in digits tree
159 for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);
160 fESDVZERO->SetMultiplicity(Multiplicity);
161 fESDVZERO->SetADC(adc);
162 fESDVZERO->SetTime(time);
164 // now get the trigger mask
166 AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
167 TriggerMask->SetAdcThreshold(mip0/2.0);
168 TriggerMask->SetTimeWindowWidthBBA(50);
169 TriggerMask->SetTimeWindowWidthBGA(20);
170 TriggerMask->SetTimeWindowWidthBBC(50);
171 TriggerMask->SetTimeWindowWidthBGC(20);
172 TriggerMask->FillMasks(digitsTree,digitsArray);
174 fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
175 fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
176 fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
177 fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
180 AliDebug(1, Form("Writing VZERO data to ESD tree"));
181 esd->SetVZEROData(fESDVZERO);
185 //_____________________________________________________________________________
186 AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
190 Bool_t deleteManager = kFALSE;
192 AliCDBManager *manager = AliCDBManager::Instance();
193 AliCDBStorage *defstorage = manager->GetDefaultStorage();
195 if(!defstorage || !(defstorage->Contains("VZERO"))){
196 AliWarning("No default storage set or default storage doesn't contain VZERO!");
197 manager->SetDefaultStorage(uri);
198 deleteManager = kTRUE;
201 AliCDBStorage *storage = manager->GetDefaultStorage();
204 AliCDBManager::Instance()->UnsetDefaultStorage();
205 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
211 //_____________________________________________________________________________
212 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
214 // Gets calibration object for VZERO set
216 AliCDBManager *man = AliCDBManager::Instance();
218 AliCDBEntry *entry=0;
220 entry = man->Get("VZERO/Calib/Data");
223 // AliWarning("Load of calibration data from default storage failed!");
224 // AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
225 // Int_t runNumber = man->GetRun();
226 // entry = man->GetStorage("local://$ALICE_ROOT")
227 // ->Get("VZERO/Calib/Data",runNumber);
231 // Retrieval of data in directory VZERO/Calib/Data:
233 AliVZEROCalibData *calibdata = 0;
235 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
236 if (!calibdata) AliFatal("No calibration data from calibration database !");