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