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