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 ---
27 // --- AliRoot header files ---
28 #include "AliVZEROConst.h"
31 #include "AliVZEROhit.h"
32 #include "AliRunLoader.h"
33 #include "AliLoader.h"
34 #include "AliRunDigitizer.h"
35 #include "AliVZEROdigit.h"
36 #include "AliVZERODigitizer.h"
38 ClassImp(AliVZERODigitizer)
40 AliVZERODigitizer::AliVZERODigitizer()
42 // default constructor
47 fPhotoCathodeEfficiency = 0.18;
49 fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
52 //____________________________________________________________________________
53 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
54 :AliDigitizer(manager)
62 fPhotoCathodeEfficiency = 0.18;
64 fPMGain = TMath::Power( (fPMVoltage / 112.5) ,7.04277 );
67 //____________________________________________________________________________
68 AliVZERODigitizer::~AliVZERODigitizer()
79 //_____________________________________________________________________________
80 Bool_t AliVZERODigitizer::Init()
82 // Initialises the digitizer
84 // Initialises the Digit array
85 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
90 //____________________________________________________________________________
91 void AliVZERODigitizer::Exec(Option_t* /*option*/)
94 // Creates digits from hits
100 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
102 AliRunLoader* outRunLoader =
103 AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
105 Error("Exec", "Can not get output Run Loader");
108 AliLoader* outLoader = outRunLoader->GetLoader("VZEROLoader");
110 Error("Exec", "Can not get output VZERO Loader");
114 outLoader->LoadDigits("update");
115 if (!outLoader->TreeD()) outLoader->MakeTree("D");
116 outLoader->MakeDigitsContainer();
117 TTree* treeD = outLoader->TreeD();
118 Int_t bufsize = 16000;
119 treeD->Branch("VZERODigit", &fDigits, bufsize);
121 for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) {
122 AliRunLoader* runLoader =
123 AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
124 AliLoader* loader = runLoader->GetLoader("VZEROLoader");
126 Error("Exec", "Can not get VZERO Loader for input %d", iInput);
129 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
131 AliVZERO* vzero = (AliVZERO*) runLoader->GetAliRun()->GetDetector("VZERO");
133 Error("Exec", "No VZERO detector for input %d", iInput);
138 TTree* treeH = loader->TreeH();
140 Error("Exec", "Cannot get TreeH for input %d", iInput);
144 Float_t timeV0 = 1e12;
145 for(Int_t i=0; i<96; i++) { adc[i] = 0; time[i] = 0.0; }
147 TClonesArray* hits = vzero->Hits();
149 // Now makes Digits from hits
151 Int_t nTracks = (Int_t) treeH->GetEntries();
152 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
154 treeH->GetEvent(iTrack);
155 Int_t nHits = hits->GetEntriesFast();
156 for (Int_t iHit = 0; iHit < nHits; iHit++) {
157 AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit);
158 Int_t nPhot = hit->Nphot();
159 Int_t cell = hit->Cell();
161 Float_t dt_scintillator = gRandom->Gaus(0,1);
162 time[cell] = dt_scintillator + 1e9*hit->Tof();
163 if(time[cell] < timeV0) timeV0 = time[cell];
167 loader->UnloadHits();
171 for (Int_t i=0; i<96; i++) {
172 Float_t q1 = Float_t ( adc[i] )* cPM * kQe;
173 Float_t noise = gRandom->Gaus(10.5,3.22);
174 Float_t pmResponse = q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau))
176 adc[i] = Int_t( pmResponse * 50.0);
178 // printf(" Event, cell, adc, tof = %d %d %d %f\n",
179 // outRunLoader->GetEventNumber(),i, adc[i], time[i]*100.0);
180 AddDigit(i, adc[i], int(time[i]*100.0) );
186 outLoader->WriteDigits("OVERWRITE");
187 outLoader->UnloadDigits();
191 //____________________________________________________________________________
192 void AliVZERODigitizer::AddDigit(Int_t cellnumber, Int_t adc, Int_t time)
197 TClonesArray &ldigits = *fDigits;
198 new(ldigits[fNdigits++]) AliVZEROdigit(cellnumber,adc,time);
200 //____________________________________________________________________________
201 void AliVZERODigitizer::ResetDigit()
207 if (fDigits) fDigits->Delete();