]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROReconstructor.cxx
Online Pedestals dumped into local DB file
[u/mrichter/AliRoot.git] / VZERO / AliVZEROReconstructor.cxx
CommitLineData
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"
b0d2c2d3 30
b0d2c2d3 31ClassImp(AliVZEROReconstructor)
32
ce7090f5 33//_____________________________________________________________________________
cb2228e6 34AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
35b120ff 35 fESDVZERO(0x0),
36 fESD(0x0),
cb2228e6 37 fCalibData(GetCalibData())
ce7090f5 38{
39 // Default constructor
ce7090f5 40 // Get calibration data
41
35b120ff 42 // fCalibData = GetCalibData();
ce7090f5 43}
44
45
46//_____________________________________________________________________________
47AliVZEROReconstructor& AliVZEROReconstructor::operator =
48 (const AliVZEROReconstructor& /*reconstructor*/)
49{
50// assignment operator
51
52 Fatal("operator =", "assignment operator not implemented");
53 return *this;
54}
55
56//_____________________________________________________________________________
57AliVZEROReconstructor::~AliVZEROReconstructor()
58{
59// destructor
35b120ff 60 delete fESDVZERO;
61
62}
63
64//_____________________________________________________________________________
d76c31f4 65void AliVZEROReconstructor::Init()
35b120ff 66{
ef314913 67// initializer
ce7090f5 68
35b120ff 69 fESDVZERO = new AliESDVZERO;
70}
71
72//______________________________________________________________________
2e0ee64a 73void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
35b120ff 74{
9d62c464 75// converts RAW to digits
ef314913 76
2e0ee64a 77 if (!digitsTree) {
78 AliError("No digits tree!");
79 return;
80 }
35b120ff 81
2e0ee64a 82 TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit");
83 digitsTree->Branch("VZERODigit", &digitsArray);
84
85 rawReader->Reset();
86 AliVZERORawStream rawStream(rawReader);
9d62c464 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:
92 ADC_max[i] = 0;
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);}
96 }
97 // Convert i (FEE channel numbering) to j (aliroot channel numbering)
98 Int_t j = rawStream.GetOfflineChannel(i);
99 adc[j] = ADC_max[i];
100 time[j] = rawStream.GetTime(i);
101 }
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]);
106 }
2e0ee64a 107 }
108
109 digitsTree->Fill();
110}
111
112//______________________________________________________________________
113void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
b14e6eb4 114 AliESDEvent* esd) const
2e0ee64a 115{
ef314913 116// fills multiplicities to the ESD
117
2e0ee64a 118 if (!digitsTree) {
119 AliError("No digits tree!");
120 return;
121 }
a055ee24 122
2e0ee64a 123 TClonesArray* digitsArray = NULL;
124 TBranch* digitBranch = digitsTree->GetBranch("VZERODigit");
125 digitBranch->SetAddress(&digitsArray);
35b120ff 126
a055ee24 127 const Float_t mip0=110.0;
128 Short_t Multiplicity[64];
129 Float_t mult[64];
28fdf12c 130 Short_t adc[64];
131 Short_t time[64];
ef314913 132 Float_t mip[64];
35b120ff 133 for (Int_t i=0; i<64; i++){
ef314913 134 adc[i] = 0;
a055ee24 135 mip[i] = mip0;
136 mult[i]= 0.0;
137 }
35b120ff 138
a055ee24 139 // loop over VZERO entries to get multiplicity
2e0ee64a 140 Int_t nEntries = (Int_t)digitsTree->GetEntries();
35b120ff 141 for (Int_t e=0; e<nEntries; e++) {
2e0ee64a 142 digitsTree->GetEvent(e);
35b120ff 143
2e0ee64a 144 Int_t nDigits = digitsArray->GetEntriesFast();
35b120ff 145
146 for (Int_t d=0; d<nDigits; d++) {
2e0ee64a 147 AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d);
ef314913 148 Int_t pmNumber = digit->PMNumber();
28fdf12c 149 adc[pmNumber] = (Short_t) digit->ADC();
150 time[pmNumber] = (Short_t) digit->Time();
59063a18 151 // cut of ADC at MIP/2
a055ee24 152 if (adc[pmNumber] > (mip[pmNumber]/2))
153 mult[pmNumber] += float(adc[pmNumber])/mip[pmNumber];
35b120ff 154 } // end of loop over digits
35b120ff 155 } // end of loop over events in digits tree
156
a055ee24 157 for (Int_t j=0; j<64; j++) Multiplicity[j] = short(mult[j]+0.5);
158 fESDVZERO->SetMultiplicity(Multiplicity);
28fdf12c 159 fESDVZERO->SetADC(adc);
160 fESDVZERO->SetTime(time);
a055ee24 161
162 // now get the trigger mask
163
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);
171
172 fESDVZERO->SetBBtriggerV0A(TriggerMask->GetBBtriggerV0A());
173 fESDVZERO->SetBGtriggerV0A(TriggerMask->GetBGtriggerV0A());
174 fESDVZERO->SetBBtriggerV0C(TriggerMask->GetBBtriggerV0C());
175 fESDVZERO->SetBGtriggerV0C(TriggerMask->GetBGtriggerV0C());
35b120ff 176
2e0ee64a 177 if (esd) {
a055ee24 178 AliDebug(1, Form("Writing VZERO data to ESD tree"));
179 esd->SetVZEROData(fESDVZERO);
2e0ee64a 180 }
35b120ff 181}
182
ce7090f5 183//_____________________________________________________________________________
184AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
185{
ef314913 186// Sets the storage
187
ce7090f5 188 Bool_t deleteManager = kFALSE;
189
190 AliCDBManager *manager = AliCDBManager::Instance();
191 AliCDBStorage *defstorage = manager->GetDefaultStorage();
192
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;
197 }
198
199 AliCDBStorage *storage = manager->GetDefaultStorage();
200
201 if(deleteManager){
202 AliCDBManager::Instance()->UnsetDefaultStorage();
203 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
204 }
205
206 return storage;
207}
208
209//_____________________________________________________________________________
210AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
211{
ef314913 212 // Gets calibration object for VZERO set
ce7090f5 213
c0b82b5a 214 AliCDBManager *man = AliCDBManager::Instance();
ce7090f5 215
c0b82b5a 216 AliCDBEntry *entry=0;
217
218 entry = man->Get("VZERO/Calib/Data");
219
94a600a1 220// if(!entry){
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);
226//
227// }
c0b82b5a 228
229 // Retrieval of data in directory VZERO/Calib/Data:
230
c0b82b5a 231 AliVZEROCalibData *calibdata = 0;
232
233 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
94a600a1 234 if (!calibdata) AliFatal("No calibration data from calibration database !");
ce7090f5 235
236 return calibdata;
237}