1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///_________________________________________________________________________
20 /// This class constructs Digits out of Hits
24 // --- Standard library ---
26 // --- ROOT system ---
31 // --- AliRoot header files ---
32 #include "AliVZEROConst.h"
35 #include "AliVZEROhit.h"
36 #include "AliRunLoader.h"
37 #include "AliLoader.h"
38 #include "AliRunDigitizer.h"
39 #include "AliCDBManager.h"
40 #include "AliCDBStorage.h"
41 #include "AliCDBEntry.h"
42 #include "AliVZEROCalibData.h"
44 #include "AliVZEROdigit.h"
45 #include "AliVZERODigitizer.h"
47 ClassImp(AliVZERODigitizer)
49 AliVZERODigitizer::AliVZERODigitizer()
51 fCalibData(GetCalibData()),
52 fPhotoCathodeEfficiency(0.18),
54 fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
59 // default constructor
64 // fPhotoCathodeEfficiency = 0.18;
65 // fPMVoltage = 768.0;
66 // fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
68 // fCalibData = GetCalibData();
71 //____________________________________________________________________________
72 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
73 :AliDigitizer(manager),
74 fCalibData(GetCalibData()),
75 fPhotoCathodeEfficiency(0.18),
77 fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
87 // fPhotoCathodeEfficiency = 0.18;
88 // fPMVoltage = 768.0;
89 // fPMGain = TMath::Power( (fPMVoltage / 112.5) ,7.04277 );
91 // fCalibData = GetCalibData();
95 //____________________________________________________________________________
96 AliVZERODigitizer::~AliVZERODigitizer()
107 //_____________________________________________________________________________
108 Bool_t AliVZERODigitizer::Init()
110 // Initialises the digitizer
112 // Initialises the Digit array
113 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
118 //____________________________________________________________________________
119 void AliVZERODigitizer::Exec(Option_t* /*option*/)
121 // Creates digits from hits
123 Int_t map[80]; // 48 values on V0C + 32 on V0A
124 Int_t adc[64]; // 32 PMs on V0C + 32 PMs on V0A
125 Float_t time[80], time_ref[80], time2[64];
126 Float_t adc_gain[80];
128 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
130 // Retrieval of ADC gain values from local CDB
131 // I use only the first 64th values of the calibration array in CDB
132 // as I have no beam burst structure - odd or even beam burst number
134 // Reminder : We have 16 scintillating cells mounted on 8 PMs
135 // on Ring 3 and Ring 4 in V0C - added to produce ADC outputs
138 for(Int_t i=0; i<16; i++) { adc_gain[i] = fCalibData->GetGain(i) ; };
140 for(Int_t j=16; j<48; j=j+2) {
142 adc_gain[j] = fCalibData->GetGain(i) ;
143 adc_gain[j+1] = fCalibData->GetGain(i) ; }
144 for(Int_t i=48; i<80; i++) { adc_gain[i] = fCalibData->GetGain(i-16) ; }
146 // for(Int_t i=0; i<80; i++) { printf(" i = %d gain = %f\n\n", i, adc_gain[i] );}
148 AliRunLoader* outRunLoader =
149 AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
151 Error("Exec", "Can not get output Run Loader");
154 AliLoader* outLoader = outRunLoader->GetLoader("VZEROLoader");
156 Error("Exec", "Can not get output VZERO Loader");
159 outLoader->LoadDigits("update");
160 if (!outLoader->TreeD()) outLoader->MakeTree("D");
161 outLoader->MakeDigitsContainer();
162 TTree* treeD = outLoader->TreeD();
163 Int_t bufsize = 16000;
164 treeD->Branch("VZERODigit", &fDigits, bufsize);
166 for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) {
167 AliRunLoader* runLoader =
168 AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
169 AliLoader* loader = runLoader->GetLoader("VZEROLoader");
171 Error("Exec", "Can not get VZERO Loader for input %d", iInput);
174 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
176 AliVZERO* vzero = (AliVZERO*) runLoader->GetAliRun()->GetDetector("VZERO");
178 Error("Exec", "No VZERO detector for input %d", iInput);
182 TTree* treeH = loader->TreeH();
184 Error("Exec", "Cannot get TreeH for input %d", iInput);
187 for(Int_t i=0; i<80; i++) {map[i] = 0; time[i] = 0.0;}
189 TClonesArray* hits = vzero->Hits();
191 // Now makes Digits from hits
193 Int_t nTracks = (Int_t) treeH->GetEntries();
194 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
195 for (Int_t i=0; i<80; i++) {time_ref[i] = 999999.0;}
197 treeH->GetEvent(iTrack);
198 Int_t nHits = hits->GetEntriesFast();
199 for (Int_t iHit = 0; iHit < nHits; iHit++) {
200 AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit);
201 Int_t nPhot = hit->Nphot();
202 Int_t cell = hit->Cell();
204 Float_t dt_scintillator = gRandom->Gaus(0,0.7);
205 Float_t t = dt_scintillator + 1e9*hit->Tof();
207 if(t < time_ref[cell]) time_ref[cell] = t;
208 time[cell] = TMath::Min(t,time_ref[cell]);
213 loader->UnloadHits();
217 // Now builds the scintillator cell response (80 cells i.e. 80 responses)
219 for (Int_t i=0; i<80; i++) {
220 Float_t q1 = Float_t ( map[i] )* cPM * kQe;
221 Float_t noise = gRandom->Gaus(10.5,3.22);
222 Float_t pmResponse = q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau))
224 map[i] = Int_t( pmResponse * adc_gain[i]);
227 // Now transforms 80 cell responses into 64 photomultiplier responses
229 for (Int_t j=0; j<32; j++){
233 for (Int_t j=48; j<80; j++){
235 time2[j-16]= time[j];}
237 for (Int_t j=0; j<16; j++){
238 adc[16+j] = map [16+2*j]+ map [16+2*j+1];
239 Float_t min_time = TMath::Min(time [16+2*j],time [16+2*j+1]);
240 time2[16+j] = min_time;
242 time2[16+j] = TMath::Max(time[16+2*j],time[16+2*j+1]);
247 // Now add digits to the digit Tree
249 for (Int_t i=0; i<64; i++) {
251 // printf(" Event, cell, adc, tof = %d %d %d %f\n",
252 // outRunLoader->GetEventNumber(),i, map[i], time2[i]*10.0);
253 // multiply by 10 to have 100 ps per channel :
254 AddDigit(i, adc[i], Int_t(time2[i]*10.0) );
259 outLoader->WriteDigits("OVERWRITE");
260 outLoader->UnloadDigits();
264 //____________________________________________________________________________
265 void AliVZERODigitizer::AddDigit(Int_t PMnumber, Int_t adc, Int_t time)
270 TClonesArray &ldigits = *fDigits;
271 new(ldigits[fNdigits++]) AliVZEROdigit(PMnumber,adc,time);
273 //____________________________________________________________________________
274 void AliVZERODigitizer::ResetDigit()
280 if (fDigits) fDigits->Delete();
283 //____________________________________________________________________________
284 AliVZEROCalibData* AliVZERODigitizer::GetCalibData() const
287 AliCDBManager *man = AliCDBManager::Instance();
289 AliCDBEntry *entry=0;
291 entry = man->Get("VZERO/Calib/Data");
294 AliWarning("Load of calibration data from default storage failed!");
295 AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
296 Int_t runNumber = man->GetRun();
297 entry = man->GetStorage("local://$ALICE_ROOT")
298 ->Get("VZERO/Calib/Data",runNumber);
302 // Retrieval of data in directory VZERO/Calib/Data:
305 AliVZEROCalibData *calibdata = 0;
307 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
308 if (!calibdata) AliError("No calibration data from calibration database !");