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