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 **************************************************************************/
16 ///_________________________________________________________________________
18 /// This class constructs Digits out of Hits
22 // --- Standard library ---
24 // --- ROOT system ---
28 // --- AliRoot header files ---
29 #include "AliVZEROConst.h"
32 #include "AliVZEROhit.h"
33 #include "AliRunLoader.h"
34 #include "AliLoader.h"
35 #include "AliRunDigitizer.h"
36 #include "AliCDBManager.h"
37 #include "AliCDBStorage.h"
38 #include "AliCDBEntry.h"
39 #include "AliVZEROCalibData.h"
41 #include "AliVZEROdigit.h"
42 #include "AliVZERODigitizer.h"
44 ClassImp(AliVZERODigitizer)
46 AliVZERODigitizer::AliVZERODigitizer()
48 fCalibData(GetCalibData()),
49 fPhotoCathodeEfficiency(0.18),
51 fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
56 // default constructor
61 // fPhotoCathodeEfficiency = 0.18;
62 // fPMVoltage = 768.0;
63 // fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
65 // fCalibData = GetCalibData();
68 //____________________________________________________________________________
69 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
70 :AliDigitizer(manager),
71 fCalibData(GetCalibData()),
72 fPhotoCathodeEfficiency(0.18),
74 fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
84 // fPhotoCathodeEfficiency = 0.18;
85 // fPMVoltage = 768.0;
86 // fPMGain = TMath::Power( (fPMVoltage / 112.5) ,7.04277 );
88 // fCalibData = GetCalibData();
92 //____________________________________________________________________________
93 AliVZERODigitizer::~AliVZERODigitizer()
104 //_____________________________________________________________________________
105 Bool_t AliVZERODigitizer::Init()
107 // Initialises the digitizer
109 // Initialises the Digit array
110 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
115 //____________________________________________________________________________
116 void AliVZERODigitizer::Exec(Option_t* /*option*/)
118 // Creates digits from hits
120 Int_t map[80]; // 48 values on V0C + 32 on V0A
121 Int_t adc[64]; // 32 PMs on V0C + 32 PMs on V0A
122 Float_t time[80], time_ref[80], time2[64];
123 Float_t adc_gain[80];
125 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
127 // Retrieval of ADC gain values from local CDB
128 // I use only the first 64th values of the calibration array in CDB
129 // as I have no beam burst structure - odd or even beam burst number
131 // Reminder : We have 16 scintillating cells mounted on 8 PMs
132 // on Ring 3 and Ring 4 in V0C - added to produce ADC outputs
135 for(Int_t i=0; i<16; i++) { adc_gain[i] = fCalibData->GetGain(i) ; };
137 for(Int_t j=16; j<48; j=j+2) {
139 adc_gain[j] = fCalibData->GetGain(i) ;
140 adc_gain[j+1] = fCalibData->GetGain(i) ; }
141 for(Int_t i=48; i<80; i++) { adc_gain[i] = fCalibData->GetGain(i-16) ; }
143 // for(Int_t i=0; i<80; i++) { printf(" i = %d gain = %f\n\n", i, adc_gain[i] );}
145 AliRunLoader* outRunLoader =
146 AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
148 Error("Exec", "Can not get output Run Loader");
151 AliLoader* outLoader = outRunLoader->GetLoader("VZEROLoader");
153 Error("Exec", "Can not get output VZERO Loader");
156 outLoader->LoadDigits("update");
157 if (!outLoader->TreeD()) outLoader->MakeTree("D");
158 outLoader->MakeDigitsContainer();
159 TTree* treeD = outLoader->TreeD();
160 Int_t bufsize = 16000;
161 treeD->Branch("VZERODigit", &fDigits, bufsize);
163 for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) {
164 AliRunLoader* runLoader =
165 AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
166 AliLoader* loader = runLoader->GetLoader("VZEROLoader");
168 Error("Exec", "Can not get VZERO Loader for input %d", iInput);
171 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
173 AliVZERO* vzero = (AliVZERO*) runLoader->GetAliRun()->GetDetector("VZERO");
175 Error("Exec", "No VZERO detector for input %d", iInput);
179 TTree* treeH = loader->TreeH();
181 Error("Exec", "Cannot get TreeH for input %d", iInput);
184 for(Int_t i=0; i<80; i++) {map[i] = 0; time[i] = 0.0;}
186 TClonesArray* hits = vzero->Hits();
188 // Now makes Digits from hits
190 Int_t nTracks = (Int_t) treeH->GetEntries();
191 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
192 for (Int_t i=0; i<80; i++) {time_ref[i] = 999999.0;}
194 treeH->GetEvent(iTrack);
195 Int_t nHits = hits->GetEntriesFast();
196 for (Int_t iHit = 0; iHit < nHits; iHit++) {
197 AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit);
198 Int_t nPhot = hit->Nphot();
199 Int_t cell = hit->Cell();
201 Float_t dt_scintillator = gRandom->Gaus(0,0.7);
202 Float_t t = dt_scintillator + 1e9*hit->Tof();
204 if(t < time_ref[cell]) time_ref[cell] = t;
205 time[cell] = TMath::Min(t,time_ref[cell]);
210 loader->UnloadHits();
214 // Now builds the scintillator cell response (80 cells i.e. 80 responses)
216 for (Int_t i=0; i<80; i++) {
217 Float_t q1 = Float_t ( map[i] )* cPM * kQe;
218 Float_t noise = gRandom->Gaus(10.5,3.22);
219 Float_t pmResponse = q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau))
221 map[i] = Int_t( pmResponse * adc_gain[i]);
224 // Now transforms 80 cell responses into 64 photomultiplier responses
226 for (Int_t j=0; j<32; j++){
230 for (Int_t j=48; j<80; j++){
232 time2[j-16]= time[j];}
234 for (Int_t j=0; j<16; j++){
235 adc[16+j] = map [16+2*j]+ map [16+2*j+1];
236 Float_t min_time = TMath::Min(time [16+2*j],time [16+2*j+1]);
237 time2[16+j] = min_time;
239 time2[16+j] = TMath::Max(time[16+2*j],time[16+2*j+1]);
244 // Now add digits to the digit Tree
246 for (Int_t i=0; i<64; i++) {
248 // printf(" Event, cell, adc, tof = %d %d %d %f\n",
249 // outRunLoader->GetEventNumber(),i, map[i], time2[i]*10.0);
250 // multiply by 10 to have 100 ps per channel :
251 AddDigit(i, adc[i], Int_t(time2[i]*10.0) );
256 outLoader->WriteDigits("OVERWRITE");
257 outLoader->UnloadDigits();
261 //____________________________________________________________________________
262 void AliVZERODigitizer::AddDigit(Int_t PMnumber, Int_t adc, Int_t time)
267 TClonesArray &ldigits = *fDigits;
268 new(ldigits[fNdigits++]) AliVZEROdigit(PMnumber,adc,time);
270 //____________________________________________________________________________
271 void AliVZERODigitizer::ResetDigit()
277 if (fDigits) fDigits->Delete();
280 //____________________________________________________________________________
281 AliVZEROCalibData* AliVZERODigitizer::GetCalibData() const
284 AliCDBManager *man = AliCDBManager::Instance();
286 AliCDBEntry *entry=0;
288 entry = man->Get("VZERO/Calib/Data");
291 AliWarning("Load of calibration data from default storage failed!");
292 AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
293 Int_t runNumber = man->GetRun();
294 entry = man->GetStorage("local://$ALICE_ROOT")
295 ->Get("VZERO/Calib/Data",runNumber);
299 // Retrieval of data in directory VZERO/Calib/Data:
302 AliVZEROCalibData *calibdata = 0;
304 if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
305 if (!calibdata) AliError("No calibration data from calibration database !");