]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZERODigitizer.cxx
- from Nov 1st on, libSTEER needs ROOT libTreePlayer: added to configure script
[u/mrichter/AliRoot.git] / VZERO / AliVZERODigitizer.cxx
CommitLineData
9e04c3b6 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
b0d2c2d3 16///_________________________________________________________________________
17///
18/// This class constructs Digits out of Hits
19///
20///
9e04c3b6 21
22// --- Standard library ---
9e04c3b6 23
24// --- ROOT system ---
9e04c3b6 25#include <TTree.h>
e939a978 26#include <TRandom.h>
9e04c3b6 27
28// --- AliRoot header files ---
29#include "AliVZEROConst.h"
30#include "AliRun.h"
31#include "AliVZERO.h"
32#include "AliVZEROhit.h"
9e04c3b6 33#include "AliRunLoader.h"
34#include "AliLoader.h"
9e04c3b6 35#include "AliRunDigitizer.h"
ce7090f5 36#include "AliCDBManager.h"
37#include "AliCDBStorage.h"
38#include "AliCDBEntry.h"
39#include "AliVZEROCalibData.h"
40
9e04c3b6 41#include "AliVZEROdigit.h"
b0d2c2d3 42#include "AliVZERODigitizer.h"
9e04c3b6 43
44ClassImp(AliVZERODigitizer)
45
46 AliVZERODigitizer::AliVZERODigitizer()
47{
b0d2c2d3 48 // default constructor
49
9e04c3b6 50 fNdigits = 0;
ce7090f5 51 fDigits = 0;
9e04c3b6 52
53 fPhotoCathodeEfficiency = 0.18;
54 fPMVoltage = 768.0;
ce7090f5 55 fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
56
57 fCalibData = GetCalibData();
9e04c3b6 58}
59
60//____________________________________________________________________________
61 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
62 :AliDigitizer(manager)
63
64{
65 // constructor
66
9e04c3b6 67 fNdigits = 0;
841137ce 68 fDigits = 0;
9e04c3b6 69
70 fPhotoCathodeEfficiency = 0.18;
71 fPMVoltage = 768.0;
72 fPMGain = TMath::Power( (fPMVoltage / 112.5) ,7.04277 );
ce7090f5 73
74 fCalibData = GetCalibData();
75
9e04c3b6 76}
77
78//____________________________________________________________________________
79 AliVZERODigitizer::~AliVZERODigitizer()
80{
81 // destructor
82
83 if (fDigits) {
84 fDigits->Delete();
85 delete fDigits;
b0d2c2d3 86 fDigits=0;
87 }
9e04c3b6 88}
89
b0d2c2d3 90//_____________________________________________________________________________
91Bool_t AliVZERODigitizer::Init()
9e04c3b6 92{
b0d2c2d3 93 // Initialises the digitizer
9e04c3b6 94
b0d2c2d3 95 // Initialises the Digit array
9e04c3b6 96 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
97
b0d2c2d3 98 return kTRUE;
9e04c3b6 99}
100
101//____________________________________________________________________________
b0d2c2d3 102void AliVZERODigitizer::Exec(Option_t* /*option*/)
ce7090f5 103{
b0d2c2d3 104 // Creates digits from hits
ce7090f5 105
20277079 106 Int_t map[80]; // 48 values on V0C + 32 on V0A
107 Int_t adc[64]; // 32 PMs on V0C + 32 PMs on V0A
108 Float_t time[80], time2[64], adc_gain[80];
ce7090f5 109 fNdigits = 0;
110 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
111
112 // Retrieval of ADC gain values from local CDB
113 // I use only the first 64th values of the calibration array in CDB
114 // as I have no beam burst structure - odd or even beam burst number
b0d2c2d3 115
ce7090f5 116 // Reminder : We have 16 scintillating cells mounted on 8 PMs
20277079 117 // on Ring 3 and Ring 4 in V0C - added to produce ADC outputs
118 // on these rings...
ce7090f5 119
120 for(Int_t i=0; i<16; i++) { adc_gain[i] = fCalibData->GetGain(i) ; };
121
122 for(Int_t j=16; j<48; j=j+2) {
123 Int_t i=(j+17)/2;
124 adc_gain[j] = fCalibData->GetGain(i) ;
125 adc_gain[j+1] = fCalibData->GetGain(i) ; }
126 for(Int_t i=48; i<80; i++) { adc_gain[i] = fCalibData->GetGain(i-16) ; }
127
128// for(Int_t i=0; i<80; i++) { printf(" i = %d gain = %f\n\n", i, adc_gain[i] );}
129
b0d2c2d3 130 AliRunLoader* outRunLoader =
131 AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
132 if (!outRunLoader) {
133 Error("Exec", "Can not get output Run Loader");
ce7090f5 134 return;}
135
b0d2c2d3 136 AliLoader* outLoader = outRunLoader->GetLoader("VZEROLoader");
137 if (!outLoader) {
138 Error("Exec", "Can not get output VZERO Loader");
ce7090f5 139 return;}
b0d2c2d3 140
141 outLoader->LoadDigits("update");
142 if (!outLoader->TreeD()) outLoader->MakeTree("D");
143 outLoader->MakeDigitsContainer();
ce7090f5 144 TTree* treeD = outLoader->TreeD();
b0d2c2d3 145 Int_t bufsize = 16000;
146 treeD->Branch("VZERODigit", &fDigits, bufsize);
147
148 for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) {
149 AliRunLoader* runLoader =
150 AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
151 AliLoader* loader = runLoader->GetLoader("VZEROLoader");
152 if (!loader) {
153 Error("Exec", "Can not get VZERO Loader for input %d", iInput);
ce7090f5 154 continue;}
155
b0d2c2d3 156 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
157
158 AliVZERO* vzero = (AliVZERO*) runLoader->GetAliRun()->GetDetector("VZERO");
159 if (!vzero) {
160 Error("Exec", "No VZERO detector for input %d", iInput);
ce7090f5 161 continue;}
9e04c3b6 162
b0d2c2d3 163 loader->LoadHits();
164 TTree* treeH = loader->TreeH();
165 if (!treeH) {
166 Error("Exec", "Cannot get TreeH for input %d", iInput);
ce7090f5 167 continue; }
841137ce 168
169 Float_t timeV0 = 1e12;
20277079 170 for(Int_t i=0; i<80; i++) { map[i] = 0; time[i] = 0.0; }
841137ce 171
b0d2c2d3 172 TClonesArray* hits = vzero->Hits();
9e04c3b6 173
b0d2c2d3 174// Now makes Digits from hits
9e04c3b6 175
b0d2c2d3 176 Int_t nTracks = (Int_t) treeH->GetEntries();
177 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
178 vzero->ResetHits();
179 treeH->GetEvent(iTrack);
180 Int_t nHits = hits->GetEntriesFast();
181 for (Int_t iHit = 0; iHit < nHits; iHit++) {
182 AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit);
183 Int_t nPhot = hit->Nphot();
184 Int_t cell = hit->Cell();
20277079 185 map[cell] += nPhot;
186 Float_t dt_scintillator = gRandom->Gaus(0,0.7);
841137ce 187 time[cell] = dt_scintillator + 1e9*hit->Tof();
188 if(time[cell] < timeV0) timeV0 = time[cell];
b0d2c2d3 189 } // hit loop
190 } // track loop
191
192 loader->UnloadHits();
193
194 } // input loop
20277079 195
196// Now builds the scintillator cell response (80 cells i.e. 80 responses)
841137ce 197
20277079 198 for (Int_t i=0; i<80; i++) {
199 Float_t q1 = Float_t ( map[i] )* cPM * kQe;
200 Float_t noise = gRandom->Gaus(10.5,3.22);
201 Float_t pmResponse = q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau))
202 + noise*1e-3;
203 map[i] = Int_t( pmResponse * adc_gain[i]);
204 }
205
206
207// Now transforms 80 cell responses into 64 photomultiplier responses
208
209 for (Int_t j=0; j<32; j++){
210 adc[j] = map [j];
211 time2[j]= time[j];}
212
213 for (Int_t j=48; j<80; j++){
214 adc[j-16] = map [j];
215 time2[j-16]= time[j];}
216
217 for (Int_t j=0; j<16; j++){
218 adc[16+j] = map [16 + 2*j]+ map [16 + 2*j + 1];
219 time2[16+j] = TMath::Min(time [16 + 2*j], time [16 + 2*j + 1]);}
220
221// Now add digits to the digit Tree
222
223 for (Int_t i=0; i<64; i++) {
224 if(adc[i] > 0) {
225// printf(" Event, cell, adc, tof = %d %d %d %f\n",
226// outRunLoader->GetEventNumber(),i, map[i], time[i]*100.0);
5c1828c2 227// multiply by 10 to have 100 ps per channel :
20277079 228 AddDigit(i, adc[i], Int_t(time2[i]*10.0) );
229 }
230 }
b0d2c2d3 231
20277079 232
b0d2c2d3 233 treeD->Fill();
234 outLoader->WriteDigits("OVERWRITE");
235 outLoader->UnloadDigits();
236 ResetDigit();
9e04c3b6 237}
238
239//____________________________________________________________________________
20277079 240void AliVZERODigitizer::AddDigit(Int_t PMnumber, Int_t adc, Int_t time)
9e04c3b6 241 {
242
243// Adds Digit
244
245 TClonesArray &ldigits = *fDigits;
20277079 246 new(ldigits[fNdigits++]) AliVZEROdigit(PMnumber,adc,time);
9e04c3b6 247}
248//____________________________________________________________________________
249void AliVZERODigitizer::ResetDigit()
250{
b0d2c2d3 251//
9e04c3b6 252// Clears Digits
b0d2c2d3 253//
9e04c3b6 254 fNdigits = 0;
b0d2c2d3 255 if (fDigits) fDigits->Delete();
9e04c3b6 256}
ce7090f5 257
258//____________________________________________________________________________
259AliVZEROCalibData* AliVZERODigitizer::GetCalibData() const
260
261{
c0b82b5a 262 AliCDBManager *man = AliCDBManager::Instance();
ce7090f5 263
c0b82b5a 264 AliCDBEntry *entry=0;
ce7090f5 265
c0b82b5a 266 entry = man->Get("VZERO/Calib/Data");
267
268 if(!entry){
269 AliWarning("Load of calibration data from default storage failed!");
270 AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
271 Int_t runNumber = man->GetRun();
272 entry = man->GetStorage("local://$ALICE_ROOT")
273 ->Get("VZERO/Calib/Data",runNumber);
274
275 }
276
277 // Retrieval of data in directory VZERO/Calib/Data:
ce7090f5 278
ce7090f5 279
c0b82b5a 280 AliVZEROCalibData *calibdata = 0;
ce7090f5 281
c0b82b5a 282 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
283 if (!calibdata) AliError("No calibration data from calibration database !");
ce7090f5 284
c0b82b5a 285 return calibdata;
ce7090f5 286
287}
288