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 adc[pmNumber] = (Short_t) digit->ADC();
150 time[pmNumber] = (Short_t) digit->Time();
151 // cut of ADC at MIP/2
152 if (adc[pmNumber] > (mip[pmNumber]/2))
153 mult[pmNumber] += float(adc[pmNumber])/mip[pmNumber];
154 } // end of loop over digits
155 } // end of loop over events in digits tree
157 for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);
158 fESDVZERO->SetMultiplicity(Multiplicity);
159 fESDVZERO->SetADC(adc);
160 fESDVZERO->SetTime(time);
162 // now get the trigger mask
164 AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
165 TriggerMask->SetAdcThreshold(mip0/2.0);
166 TriggerMask->SetTimeWindowWidthBBA(50);
167 TriggerMask->SetTimeWindowWidthBGA(20);
168 TriggerMask->SetTimeWindowWidthBBC(50);
169 TriggerMask->SetTimeWindowWidthBGC(20);
170 TriggerMask->FillMasks(digitsTree,digitsArray);
172 fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
173 fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
174 fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
175 fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
178 AliDebug(1, Form("Writing VZERO data to ESD tree"));
179 esd->SetVZEROData(fESDVZERO);
183 //_____________________________________________________________________________
184 AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
188 Bool_t deleteManager = kFALSE;
190 AliCDBManager *manager = AliCDBManager::Instance();
191 AliCDBStorage *defstorage = manager->GetDefaultStorage();
193 if(!defstorage || !(defstorage->Contains("VZERO"))){
194 AliWarning("No default storage set or default storage doesn't contain VZERO!");
195 manager->SetDefaultStorage(uri);
196 deleteManager = kTRUE;
199 AliCDBStorage *storage = manager->GetDefaultStorage();
202 AliCDBManager::Instance()->UnsetDefaultStorage();
203 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
209 //_____________________________________________________________________________
210 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
212 // Gets calibration object for VZERO set
214 AliCDBManager *man = AliCDBManager::Instance();
216 AliCDBEntry *entry=0;
218 entry = man->Get("VZERO/Calib/Data");
221 // AliWarning("Load of calibration data from default storage failed!");
222 // AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
223 // Int_t runNumber = man->GetRun();
224 // entry = man->GetStorage("local://$ALICE_ROOT")
225 // ->Get("VZERO/Calib/Data",runNumber);
229 // Retrieval of data in directory VZERO/Calib/Data:
231 AliVZEROCalibData *calibdata = 0;
233 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
234 if (!calibdata) AliFatal("No calibration data from calibration database !");