]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZERODigitizer.cxx
Store in ESD mip Q as pTrk->SetRICHnclusters(100000*Q+nphots)
[u/mrichter/AliRoot.git] / VZERO / AliVZERODigitizer.cxx
CommitLineData
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"
9e04c3b6 35#include "AliVZEROdigit.h"
b0d2c2d3 36#include "AliVZERODigitizer.h"
9e04c3b6 37
38ClassImp(AliVZERODigitizer)
39
40 AliVZERODigitizer::AliVZERODigitizer()
41{
b0d2c2d3 42 // default constructor
43
9e04c3b6 44 fNdigits = 0;
b0d2c2d3 45 fDigits = 0 ;
9e04c3b6 46
47 fPhotoCathodeEfficiency = 0.18;
48 fPMVoltage = 768.0;
49 fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
50}
51
52//____________________________________________________________________________
53 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
54 :AliDigitizer(manager)
55
56{
57 // constructor
58
9e04c3b6 59 fNdigits = 0;
841137ce 60 fDigits = 0;
9e04c3b6 61
62 fPhotoCathodeEfficiency = 0.18;
63 fPMVoltage = 768.0;
64 fPMGain = TMath::Power( (fPMVoltage / 112.5) ,7.04277 );
65}
66
67//____________________________________________________________________________
68 AliVZERODigitizer::~AliVZERODigitizer()
69{
70 // destructor
71
72 if (fDigits) {
73 fDigits->Delete();
74 delete fDigits;
b0d2c2d3 75 fDigits=0;
76 }
9e04c3b6 77}
78
b0d2c2d3 79//_____________________________________________________________________________
80Bool_t AliVZERODigitizer::Init()
9e04c3b6 81{
b0d2c2d3 82 // Initialises the digitizer
9e04c3b6 83
b0d2c2d3 84 // Initialises the Digit array
9e04c3b6 85 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
86
b0d2c2d3 87 return kTRUE;
9e04c3b6 88}
89
90//____________________________________________________________________________
b0d2c2d3 91void AliVZERODigitizer::Exec(Option_t* /*option*/)
92{
93 //
94 // Creates digits from hits
95 //
96
841137ce 97 Int_t adc[96];
98 Float_t time[96];
99 fNdigits = 0;
100 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
2d7933c7 101
b0d2c2d3 102 AliRunLoader* outRunLoader =
103 AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
104 if (!outRunLoader) {
105 Error("Exec", "Can not get output Run Loader");
106 return;
107 }
108 AliLoader* outLoader = outRunLoader->GetLoader("VZEROLoader");
109 if (!outLoader) {
110 Error("Exec", "Can not get output VZERO Loader");
111 return;
112 }
113
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);
120
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");
125 if (!loader) {
126 Error("Exec", "Can not get VZERO Loader for input %d", iInput);
127 continue;
128 }
129 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
130
131 AliVZERO* vzero = (AliVZERO*) runLoader->GetAliRun()->GetDetector("VZERO");
132 if (!vzero) {
133 Error("Exec", "No VZERO detector for input %d", iInput);
134 continue;
135 }
9e04c3b6 136
b0d2c2d3 137 loader->LoadHits();
138 TTree* treeH = loader->TreeH();
139 if (!treeH) {
140 Error("Exec", "Cannot get TreeH for input %d", iInput);
141 continue;
142 }
841137ce 143
144 Float_t timeV0 = 1e12;
145 for(Int_t i=0; i<96; i++) { adc[i] = 0; time[i] = 0.0; }
146
b0d2c2d3 147 TClonesArray* hits = vzero->Hits();
9e04c3b6 148
b0d2c2d3 149// Now makes Digits from hits
9e04c3b6 150
b0d2c2d3 151 Int_t nTracks = (Int_t) treeH->GetEntries();
152 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
153 vzero->ResetHits();
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();
841137ce 160 adc[cell] += nPhot;
c313ff94 161 Float_t dt_scintillator = gRandom->Gaus(0,0.3);
841137ce 162 time[cell] = dt_scintillator + 1e9*hit->Tof();
163 if(time[cell] < timeV0) timeV0 = time[cell];
b0d2c2d3 164 } // hit loop
165 } // track loop
166
167 loader->UnloadHits();
168
169 } // input loop
841137ce 170
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))
b0d2c2d3 175 + noise*1e-3;
841137ce 176 adc[i] = Int_t( pmResponse * 50.0);
177 if(adc[i] > 0) {
178// printf(" Event, cell, adc, tof = %d %d %d %f\n",
179// outRunLoader->GetEventNumber(),i, adc[i], time[i]*100.0);
5c1828c2 180// multiply by 10 to have 100 ps per channel :
181 AddDigit(i, adc[i], Int_t(time[i]*10.0) );
b0d2c2d3 182 }
841137ce 183
b0d2c2d3 184 }
185
186 treeD->Fill();
187 outLoader->WriteDigits("OVERWRITE");
188 outLoader->UnloadDigits();
189 ResetDigit();
9e04c3b6 190}
191
192//____________________________________________________________________________
7caec66b 193void AliVZERODigitizer::AddDigit(Int_t cellnumber, Int_t adc, Int_t time)
9e04c3b6 194 {
195
196// Adds Digit
197
198 TClonesArray &ldigits = *fDigits;
7caec66b 199 new(ldigits[fNdigits++]) AliVZEROdigit(cellnumber,adc,time);
9e04c3b6 200}
201//____________________________________________________________________________
202void AliVZERODigitizer::ResetDigit()
203{
b0d2c2d3 204//
9e04c3b6 205// Clears Digits
b0d2c2d3 206//
9e04c3b6 207 fNdigits = 0;
b0d2c2d3 208 if (fDigits) fDigits->Delete();
9e04c3b6 209}