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 constructs Digits out of Hits
21 // --- Standard library ---
22 #include <Riostream.h>
25 // --- ROOT system ---
31 #include <TVirtualMC.h>
33 // --- AliRoot header files ---
34 #include "AliVZEROConst.h"
37 #include "AliVZEROhit.h"
39 #include "AliDetector.h"
40 #include "AliRunLoader.h"
41 #include "AliLoader.h"
42 #include "AliConfig.h"
43 #include "AliRunDigitizer.h"
44 #include "AliDigitizer.h"
45 #include "AliHeader.h"
47 #include "AliVZERODigitizer.h"
48 #include "AliVZEROdigit.h"
51 ClassImp(AliVZERODigitizer)
53 AliVZERODigitizer::AliVZERODigitizer()
55 if (!fDigits) fDigits = new TClonesArray("AliVZEROdigit", 1000);
63 fPhotoCathodeEfficiency = 0.18;
65 fPMGain = TMath::Power((fPMVoltage / 112.5) ,7.04277);
68 //____________________________________________________________________________
69 AliVZERODigitizer::AliVZERODigitizer(AliRunDigitizer* manager)
70 :AliDigitizer(manager)
81 fPhotoCathodeEfficiency = 0.18;
83 fPMGain = TMath::Power( (fPMVoltage / 112.5) ,7.04277 );
86 //____________________________________________________________________________
87 AliVZERODigitizer::~AliVZERODigitizer()
97 //____________________________________________________________________________
98 void AliVZERODigitizer::OpengAliceFile(const char *file)
100 // Loads galice.root file and corresponding header, kinematics
103 fRunLoader = AliRunLoader::Open(file,AliConfig::fgkDefaultEventFolderName,
108 Error("Open","Can not open session for file %s.",file);
111 fRunLoader->LoadgAlice();
112 fRunLoader->LoadHeader();
113 fRunLoader->LoadKinematics();
115 gAlice = fRunLoader->GetAliRun();
118 { printf("<AliVZEROdigitizer::Open> ");
119 printf("AliRun object found on file.\n");}
121 { printf("<AliVZEROdigitizer::Open> ");
122 printf("Could not find AliRun object.\n");}
124 // Initialise Hit and Digit arrays
125 fHits = new TClonesArray ("AliVZEROhit", 1000);
126 fDigits = new TClonesArray ("AliVZEROdigit", 1000);
128 fVZERO = (AliVZERO*) gAlice->GetDetector("VZERO");
129 fVZEROLoader = fRunLoader->GetLoader("VZEROLoader");
131 if (fVZEROLoader == 0x0){
132 cerr<<"Hits2Digits : Can not find VZERO or VZEROLoader\n";}
134 Int_t retval = fVZEROLoader->LoadHits("read");
136 Error("Open","Error occured while loading hits... Exiting.");
139 fVZEROLoader->LoadDigits("recreate");
142 //____________________________________________________________________________
143 void AliVZERODigitizer::Exec()
151 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
153 for(Int_t i=0; i<96; i++) map[i] = 0;
155 fNevents = (Int_t) fRunLoader->TreeE()->GetEntries ();
156 printf(" Number of events in file = %d \n", fNevents);
158 for (Int_t ievent = 0; ievent < fNevents; ievent++){
160 for(Int_t i=0; i<96; i++) map[i] = 0;
162 fRunLoader->GetEvent(ievent);
164 fTreeH = fVZEROLoader->TreeH();
166 { Error("Exec","Cannot get TreeH");
169 fTreeD = fVZEROLoader->TreeD();
171 { fVZEROLoader->MakeTree("D");
172 fVZEROLoader->MakeDigitsContainer();
173 fTreeD = fVZEROLoader->TreeD(); }
175 Int_t bufsize = 16000;
176 fTreeD->Branch("VZERODigit", &fDigits, bufsize);
178 // Now make Digits from hits
182 fHits = fVZERO->Hits();
184 Int_t ntracks = (Int_t) fTreeH->GetEntries ();
185 // printf(" Number of Tracks in the TreeH = %d \n", ntracks);
186 for (Int_t track = 0; track < ntracks; track++)
188 gAlice->ResetHits ();
189 nbytes += fTreeH->GetEvent(track);
190 fParticle = fRunLoader->Stack()->Particle(track);
191 Int_t nhits = fHits->GetEntriesFast();
192 for (Int_t hit = 0; hit < nhits; hit++)
194 fVZEROHit = (AliVZEROhit *)fHits->UncheckedAt(hit);
195 N = fVZEROHit->Nphot();
196 cell = fVZEROHit->Cell();
197 map[cell] = map[cell] + N;
203 for(Int_t i=0; i<96; i++) {
204 Float_t q1 = Float_t ( map[i] )* cPM * kQe;
205 Float_t noise = gRandom->Gaus(10.5,3.22);
206 Float_t PMresponse = q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau))
208 map[i] = Int_t( PMresponse * 200.0);
211 // printf(" Event, cell, adc = %d %d %d\n", ievent, i, map[i]);
212 AddDigit(ievent, i, map[i]);}
218 fVZEROLoader->WriteDigits("OVERWRITE");
219 fVZEROLoader->UnloadDigits();
224 //____________________________________________________________________________
225 void AliVZERODigitizer::AddDigit(Int_t eventnumber, Int_t cellnumber, Int_t adc)
230 TClonesArray &ldigits = *fDigits;
231 new(ldigits[fNdigits++]) AliVZEROdigit(eventnumber,cellnumber,adc);
233 //____________________________________________________________________________
234 void AliVZERODigitizer::ResetDigit()
238 if (fDigits) fDigits->Clear();