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