- from Nov 1st on, libSTEER needs ROOT libTreePlayer: added to configure script
[u/mrichter/AliRoot.git] / VZERO / AliVZERO.cxx
CommitLineData
47890cd3 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
88cb7938 16/* $Id$ */
47890cd3 17
18///////////////////////////////////////////////////////////////////////////
19// //
20// V-Zero Detector //
21// This class contains the base procedures for the VZERO detector //
b0d2c2d3 22// Default geometry of November 2003 : V0R box is 4.4 cm thick //
23// scintillators are 2 cm thick //
47890cd3 24// All comments should be sent to Brigitte CHEYNIS : //
61874e87 25// b.cheynis@ipnl.in2p3.fr //
26// //
47890cd3 27// //
28///////////////////////////////////////////////////////////////////////////
29
88cb7938 30
b2501ea3 31// --- Standard libraries ---
3af027ba 32#include <Riostream.h>
b0d2c2d3 33#include <stdlib.h>
47890cd3 34
b2501ea3 35// --- ROOT libraries ---
36#include <TNamed.h>
b0d2c2d3 37#include "TROOT.h"
38#include "TFile.h"
39#include "TNetFile.h"
40#include "TRandom.h"
41#include "TTree.h"
42#include "TBranch.h"
43#include "TClonesArray.h"
44#include "TStopwatch.h"
b2501ea3 45
46// --- AliRoot header files ---
47#include "AliRun.h"
48#include "AliMC.h"
47890cd3 49#include "AliVZERO.h"
b2501ea3 50#include "AliVZEROLoader.h"
b0d2c2d3 51#include "AliVZERODigitizer.h"
52#include "AliVZEROBuffer.h"
53#include "AliRunDigitizer.h"
54#include "AliVZEROdigit.h"
362c9d61 55#include "AliDAQ.h"
47890cd3 56
57ClassImp(AliVZERO)
58
47890cd3 59//_____________________________________________________________________________
60AliVZERO::AliVZERO(const char *name, const char *title)
61 : AliDetector(name,title)
62{
63 //
64 // Standard constructor for VZERO Detector
65 //
66
b0d2c2d3 67 // fIshunt = 1; // All hits are associated with primary particles
47890cd3 68
61874e87 69 fHits = new TClonesArray("AliVZEROhit", 400);
70 fDigits = new TClonesArray("AliVZEROdigit",400);
71
5d12ce38 72 gAlice->GetMCApp()->AddHitList(fHits);
61874e87 73
2f77b146 74 fThickness = 4.4; // total thickness of the V0R box in cm
75 fThickness1 = 2.0; // thickness of scintillating cells in cm
47890cd3 76
77 fMaxStepQua = 0.05;
78 fMaxStepAlu = 0.01;
79
80 fMaxDestepQua = -1.0;
81 fMaxDestepAlu = -1.0;
82
e939a978 83 //PH SetMarkerColor(kRed);
61874e87 84}
85
86//_____________________________________________________________________________
87AliVZERO::~AliVZERO()
88{
b2501ea3 89 //
90 // Default destructor for VZERO Detector
91 //
92
61874e87 93 if (fHits) {
94 fHits->Delete();
95 delete fHits;
b0d2c2d3 96 fHits=0; }
b2501ea3 97
98 if (fDigits) {
99 fDigits->Delete();
100 delete fDigits;
b0d2c2d3 101 fDigits=0; }
61874e87 102}
47890cd3 103
104//_____________________________________________________________________________
105void AliVZERO::BuildGeometry()
106{
107 //
b2501ea3 108 // Builds simple ROOT TNode geometry for event display
47890cd3 109 //
110}
111
112//_____________________________________________________________________________
113void AliVZERO::CreateGeometry()
114{
115 //
b2501ea3 116 // Builds simple Geant3 geometry
47890cd3 117 //
118}
119//_____________________________________________________________________________
120void AliVZERO::CreateMaterials()
121{
122 //
b2501ea3 123 // Creates materials used for Geant3 geometry
47890cd3 124 //
125}
61874e87 126
47890cd3 127//_____________________________________________________________________________
652e94c3 128Int_t AliVZERO::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
47890cd3 129{
130 //
b2501ea3 131 // Calculates the distance from the mouse to the VZERO on the screen
47890cd3 132 // Dummy routine
133 //
134
135 return 9999;
136}
137
b2501ea3 138//_____________________________________________________________________________
47890cd3 139void AliVZERO::Init()
140{
141 //
b2501ea3 142 // Initialises the VZERO class after it has been built
47890cd3 143 //
144}
145
61874e87 146
b2501ea3 147//_____________________________________________________________________________
47890cd3 148void AliVZERO::SetMaxStepQua(Float_t p1)
149{
b2501ea3 150 //
151 // Possible parametrisation of steps in active materials
152 //
47890cd3 153 fMaxStepQua = p1;
154}
155
b2501ea3 156//_____________________________________________________________________________
47890cd3 157void AliVZERO::SetMaxStepAlu(Float_t p1)
158{
b2501ea3 159 //
160 // Possible parametrisation of steps in Aluminum foils (not used in
161 // version v2)
162 //
47890cd3 163 fMaxStepAlu = p1;
164}
165
b2501ea3 166//_____________________________________________________________________________
47890cd3 167void AliVZERO::SetMaxDestepQua(Float_t p1)
168{
b2501ea3 169 //
170 // Possible parametrisation of steps in active materials (quartz)
171 //
47890cd3 172 fMaxDestepQua = p1;
173}
174
b2501ea3 175//_____________________________________________________________________________
47890cd3 176void AliVZERO::SetMaxDestepAlu(Float_t p1)
177{
b2501ea3 178 //
179 // Possible parametrisation of steps in Aluminum (not used in
180 // version v2)
181 //
47890cd3 182 fMaxDestepAlu = p1;
183}
4dbb3fd3 184
b2501ea3 185//_____________________________________________________________________________
4dbb3fd3 186AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
187{
b2501ea3 188 //
189 // Builds VZEROgetter (AliLoader type)
4dbb3fd3 190 // if detector wants to use customized getter, it must overload this method
b2501ea3 191 //
3e87825e 192// Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername);
193
194 AliDebug(1,Form("Creating AliVZEROLoader, Top folder is %s ",topfoldername));
4dbb3fd3 195 fLoader = new AliVZEROLoader(GetName(),topfoldername);
196 return fLoader;
197}
198
b2501ea3 199//_____________________________________________________________________________
200void AliVZERO::SetTreeAddress()
201{
b0d2c2d3 202 //
0e305a84 203 // Sets tree address for hits.
b2501ea3 204 //
0e305a84 205 if (fLoader->TreeH() && (fHits == 0x0))
206 fHits = new TClonesArray("AliVZEROhit", 400);
207
208 AliDetector::SetTreeAddress();
209}
4dbb3fd3 210
b0d2c2d3 211//_____________________________________________________________________________
212AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
213{
214 //
215 // Creates a digitizer for VZERO
216 //
217 return new AliVZERODigitizer(manager);
218}
219
220//_____________________________________________________________________________
221void AliVZERO::Hits2Digits(){
222 //
223 // Converts hits to digits of the current event
224 //
225 // Inputs file name
d3d4a92f 226 const char *alifile = "galice.root";
b0d2c2d3 227
228 // Create the run digitizer
229 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
230 manager->SetInputStream(0, alifile);
231 manager->SetOutputFile("H2Dfile");
232
233 // Creates the VZERO digitizer
234 AliVZERODigitizer* dig = new AliVZERODigitizer(manager);
235
236 // Creates the digits
237 dig->Exec("");
238
239}
240//_____________________________________________________________________________
241void AliVZERO::Digits2Raw()
242{
243 //
244 // Converts digits of the current event to raw data
245 //
246 AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
247 fLoader->LoadDigits();
248 TTree* digits = fLoader->TreeD();
249 if (!digits) {
250 Error("Digits2Raw", "no digits tree");
251 return;
252 }
253 TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
254 fVZERO->SetTreeAddress();
255 digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits);
256
362c9d61 257 const char *fileName = AliDAQ::DdlFileName("VZERO",0);
b0d2c2d3 258 AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName);
259
260 // Verbose level
261 // 0: Silent
262 // 1: cout messages
263 // 2: txt files with digits
264 // BE CAREFUL, verbose level 2 MUST be used only for debugging and
265 // it is highly suggested to use this mode only for debugging digits files
266 // reasonably small, because otherwise the size of the txt files can reach
267 // quickly several MB wasting time and disk space.
268
269 ofstream ftxt;
270 buffer->SetVerbose(0);
271 Int_t fVerbose = buffer->GetVerbose();
272
273 Int_t nEntries = Int_t(digits->GetEntries());
274
275 for (Int_t i = 0; i < nEntries; i++) {
276
277 fVZERO->ResetDigits();
278 digits->GetEvent(i);
279 Int_t ndig = VZEROdigits->GetEntriesFast();
280
281 if(ndig == 0) continue;
282 if(fVerbose == 2) {ftxt.open("VZEROdigits.txt",ios::app);}
283 for(Int_t k=0; k<ndig; k++){
284 AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k);
20277079 285 Int_t ADC = fVZERODigit->ADC();
286 Int_t PMNumber = fVZERODigit->PMNumber();
287 Int_t Time = fVZERODigit->Time();
288 if(fVerbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
289 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;}
b0d2c2d3 290 if(fVerbose == 2) {
20277079 291 ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
292 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;
b0d2c2d3 293 }
20277079 294 buffer->WriteBinary(PMNumber, ADC, Time);
b0d2c2d3 295 }
296 if(fVerbose==2) ftxt.close();
297 }
298
299 delete buffer;
300 fLoader->UnloadDigits();
301}
302
4dbb3fd3 303