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::GetDefaultEventFolderName(),
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()
150 Float_t cPM = fPhotoCathodeEfficiency * fPMGain;
152 for(Int_t i=0; i<96; i++) map[i] = 0;
154 fNevents = (Int_t) fRunLoader->TreeE()->GetEntries ();
155 printf(" Number of events in file = %d \n", fNevents);
157 for (Int_t ievent = 0; ievent < fNevents; ievent++){
159 for(Int_t i=0; i<96; i++) map[i] = 0;
161 fRunLoader->GetEvent(ievent);
163 fTreeH = fVZEROLoader->TreeH();
165 { Error("Exec","Cannot get TreeH");
168 fTreeD = fVZEROLoader->TreeD();
170 { fVZEROLoader->MakeTree("D");
171 fVZEROLoader->MakeDigitsContainer();
172 fTreeD = fVZEROLoader->TreeD(); }
174 Int_t bufsize = 16000;
175 fTreeD->Branch("VZERODigit", &fDigits, bufsize);
177 // Now make Digits from hits
181 fHits = fVZERO->Hits();
183 Int_t ntracks = (Int_t) fTreeH->GetEntries ();
184 // printf(" Number of Tracks in the TreeH = %d \n", ntracks);
185 for (Int_t track = 0; track < ntracks; track++)
187 gAlice->ResetHits ();
188 fTreeH->GetEvent(track);
189 fParticle = fRunLoader->Stack()->Particle(track);
190 Int_t nhits = fHits->GetEntriesFast();
191 for (Int_t hit = 0; hit < nhits; hit++)
193 fVZEROHit = (AliVZEROhit *)fHits->UncheckedAt(hit);
194 N = fVZEROHit->Nphot();
195 cell = fVZEROHit->Cell();
196 map[cell] = map[cell] + N;
202 for(Int_t i=0; i<96; i++) {
203 Float_t q1 = Float_t ( map[i] )* cPM * kQe;
204 Float_t noise = gRandom->Gaus(10.5,3.22);
205 Float_t PMresponse = q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau))
207 map[i] = Int_t( PMresponse * 200.0);
210 // printf(" Event, cell, adc = %d %d %d\n", ievent, i, map[i]);
211 AddDigit(ievent, i, map[i]);}
217 fVZEROLoader->WriteDigits("OVERWRITE");
218 fVZEROLoader->UnloadDigits();
223 //____________________________________________________________________________
224 void AliVZERODigitizer::AddDigit(Int_t eventnumber, Int_t cellnumber, Int_t adc)
229 TClonesArray &ldigits = *fDigits;
230 new(ldigits[fNdigits++]) AliVZEROdigit(eventnumber,cellnumber,adc);
232 //____________________________________________________________________________
233 void AliVZERODigitizer::ResetDigit()
237 if (fDigits) fDigits->Clear();