]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROReconstructor.cxx
Conversion of data from surveyors into alignment objects
[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"
35b120ff 28#include "AliESD.h"
b0d2c2d3 29
b0d2c2d3 30ClassImp(AliVZEROReconstructor)
31
ce7090f5 32//_____________________________________________________________________________
cb2228e6 33AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
35b120ff 34 fESDVZERO(0x0),
35 fESD(0x0),
36 fRunLoader(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//_____________________________________________________________________________
65void AliVZEROReconstructor::Init(AliRunLoader* runLoader)
66{
ef314913 67// initializer
ce7090f5 68
35b120ff 69 fRunLoader = runLoader;
70 fESDVZERO = new AliESDVZERO;
71}
72
73//______________________________________________________________________
2e0ee64a 74void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
35b120ff 75{
ef314913 76// converts to digits
77
2e0ee64a 78 if (!digitsTree) {
79 AliError("No digits tree!");
80 return;
81 }
35b120ff 82
2e0ee64a 83 TClonesArray* digitsArray = new TClonesArray("AliVZEROdigit");
84 digitsTree->Branch("VZERODigit", &digitsArray);
85
86 rawReader->Reset();
87 AliVZERORawStream rawStream(rawReader);
88 while (rawStream.Next()) {
89 Int_t pmNumber = rawStream.GetCell();
90 Int_t adc = rawStream.GetADC();
91 Int_t time = rawStream.GetTime();
92 new ((*digitsArray)[digitsArray->GetEntriesFast()])
93 AliVZEROdigit(pmNumber,adc,time);
94 }
95
96 digitsTree->Fill();
97}
98
99//______________________________________________________________________
100void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
101 AliESD* esd) const
102{
ef314913 103// fills multiplicities to the ESD
104
2e0ee64a 105 if (!digitsTree) {
106 AliError("No digits tree!");
107 return;
108 }
35b120ff 109
2e0ee64a 110 TClonesArray* digitsArray = NULL;
111 TBranch* digitBranch = digitsTree->GetBranch("VZERODigit");
112 digitBranch->SetAddress(&digitsArray);
35b120ff 113
ef314913 114 Int_t nbPMV0A = 0;
115 Int_t nbPMV0C = 0;
116 Int_t mTotV0A = 0;
117 Int_t mTotV0C = 0;
118 Float_t adcV0A = 0.0;
119 Float_t adcV0C = 0.0;
120 Float_t multV0A[4];
121 Float_t multV0C[4];
122 Int_t mRingV0A[4];
123 Int_t mRingV0C[4];
35b120ff 124
ef314913 125 Int_t adc[64];
126 Float_t mip[64];
35b120ff 127 for (Int_t i=0; i<64; i++){
ef314913 128 adc[i] = 0;
129 mip[i] = 110.0;}
35b120ff 130 for (Int_t j=0; j<4; j++){
ef314913 131 multV0A[j] = 0.0;
132 multV0C[j] = 0.0;
133 mRingV0A[j] = 0;
134 mRingV0C[j] = 0;}
35b120ff 135
136 // loop over VZERO entries
2e0ee64a 137 Int_t nEntries = (Int_t)digitsTree->GetEntries();
35b120ff 138 for (Int_t e=0; e<nEntries; e++) {
2e0ee64a 139 digitsTree->GetEvent(e);
35b120ff 140
2e0ee64a 141 Int_t nDigits = digitsArray->GetEntriesFast();
35b120ff 142
143 for (Int_t d=0; d<nDigits; d++) {
2e0ee64a 144 AliVZEROdigit* digit = (AliVZEROdigit*)digitsArray->At(d);
ef314913 145 Int_t pmNumber = digit->PMNumber();
146 adc[pmNumber] = digit->ADC();
147 if (pmNumber<=31) {
148 if (pmNumber<=7) multV0C[0]=multV0C[0]+ float(adc[pmNumber])/mip[pmNumber];
149 if (pmNumber>=8 && pmNumber<=15) multV0C[1]=multV0C[1]+ float(adc[pmNumber])/mip[pmNumber];
150 if (pmNumber>=16 && pmNumber<=23) multV0C[2]=multV0C[2]+ float(adc[pmNumber])/mip[pmNumber];
151 if (pmNumber>=24 && pmNumber<=31) multV0C[3]=multV0C[3]+ float(adc[pmNumber])/mip[pmNumber];
152 adcV0C = adcV0C + float(adc[pmNumber])/mip[pmNumber];
153 if(adc[pmNumber] > 4) nbPMV0C++;
35b120ff 154 }
ef314913 155 if (pmNumber>=32) {
156 if (pmNumber>=32 && pmNumber<=39) multV0A[0]=multV0A[0]+ float(adc[pmNumber])/mip[pmNumber];
157 if (pmNumber>=40 && pmNumber<=47) multV0A[1]=multV0A[1]+ float(adc[pmNumber])/mip[pmNumber];
158 if (pmNumber>=48 && pmNumber<=55) multV0A[2]=multV0A[2]+ float(adc[pmNumber])/mip[pmNumber];
159 if (pmNumber>=56 && pmNumber<=63) multV0A[3]=multV0A[3]+ float(adc[pmNumber])/mip[pmNumber];
160 adcV0A = adcV0A + float(adc[pmNumber])/mip[pmNumber];
161 if(adc[pmNumber] > 4) nbPMV0A++;
35b120ff 162 }
163 } // end of loop over digits
164
165 } // end of loop over events in digits tree
166
ef314913 167 mTotV0A = int(adcV0A + 0.5);
168 mTotV0C = int(adcV0C + 0.5);
35b120ff 169 for (Int_t j=0; j<4; j++){
ef314913 170 mRingV0A[j] = int(multV0A[j] + 0.5);
171 mRingV0C[j] = int(multV0C[j] + 0.5);}
35b120ff 172
ef314913 173 AliDebug(1,Form("VZERO multiplicities : %d (V0A) %d (V0C)", mTotV0A, mTotV0C));
174 AliDebug(1,Form("Number of PMs fired : %d (V0A) %d (V0C)", nbPMV0A, nbPMV0C));
175
176 fESDVZERO->SetNbPMV0A(nbPMV0A);
177 fESDVZERO->SetNbPMV0C(nbPMV0C);
178 fESDVZERO->SetMTotV0A(mTotV0A);
179 fESDVZERO->SetMTotV0C(mTotV0C);
180 fESDVZERO->SetMRingV0A(mRingV0A);
181 fESDVZERO->SetMRingV0C(mRingV0C);
35b120ff 182
2e0ee64a 183 if (esd) {
184 AliDebug(1, Form("Writing VZERO data to ESD tree"));
185 esd->SetVZEROData(fESDVZERO);
186 }
35b120ff 187}
188
ce7090f5 189//_____________________________________________________________________________
190AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
191{
ef314913 192// Sets the storage
193
ce7090f5 194 Bool_t deleteManager = kFALSE;
195
196 AliCDBManager *manager = AliCDBManager::Instance();
197 AliCDBStorage *defstorage = manager->GetDefaultStorage();
198
199 if(!defstorage || !(defstorage->Contains("VZERO"))){
200 AliWarning("No default storage set or default storage doesn't contain VZERO!");
201 manager->SetDefaultStorage(uri);
202 deleteManager = kTRUE;
203 }
204
205 AliCDBStorage *storage = manager->GetDefaultStorage();
206
207 if(deleteManager){
208 AliCDBManager::Instance()->UnsetDefaultStorage();
209 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
210 }
211
212 return storage;
213}
214
215//_____________________________________________________________________________
216AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
217{
ef314913 218 // Gets calibration object for VZERO set
ce7090f5 219
c0b82b5a 220 AliCDBManager *man = AliCDBManager::Instance();
ce7090f5 221
c0b82b5a 222 AliCDBEntry *entry=0;
223
224 entry = man->Get("VZERO/Calib/Data");
225
226 if(!entry){
227 AliWarning("Load of calibration data from default storage failed!");
228 AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
229 Int_t runNumber = man->GetRun();
230 entry = man->GetStorage("local://$ALICE_ROOT")
231 ->Get("VZERO/Calib/Data",runNumber);
232
233 }
234
235 // Retrieval of data in directory VZERO/Calib/Data:
236
c0b82b5a 237 AliVZEROCalibData *calibdata = 0;
238
239 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
240 if (!calibdata) AliError("No calibration data from calibration database !");
ce7090f5 241
242 return calibdata;
243}