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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
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 //
28 ///////////////////////////////////////////////////////////////////////////
31 // --- Standard libraries ---
32 #include <Riostream.h>
35 // --- ROOT libraries ---
43 #include "TClonesArray.h"
44 #include "TStopwatch.h"
46 // --- AliRoot header files ---
50 #include "AliVZEROLoader.h"
51 #include "AliVZERODigitizer.h"
52 #include "AliVZEROBuffer.h"
53 #include "AliRunDigitizer.h"
54 #include "AliVZEROdigit.h"
58 //__________________________________________________________________
59 AliVZERO::AliVZERO(): AliDetector(),
68 /// Default Constructor
70 AliDebug(1,Form("default (empty) ctor this=%p",this));
73 //_____________________________________________________________________________
74 AliVZERO::AliVZERO(const char *name, const char *title)
75 : AliDetector(name,title),
85 // Standard constructor for VZERO Detector
87 AliDebug(1,Form("ctor this=%p",this));
89 // fIshunt = 1; // All hits are associated with primary particles
91 fHits = new TClonesArray("AliVZEROhit", 400);
92 fDigits = new TClonesArray("AliVZEROdigit",400);
94 gAlice->GetMCApp()->AddHitList(fHits);
96 // fThickness = 4.4; // total thickness of the V0R box in cm
97 // fThickness1 = 2.0; // thickness of scintillating cells in cm
99 // fMaxStepQua = 0.05;
100 // fMaxStepAlu = 0.01;
102 // fMaxDestepQua = -1.0;
103 // fMaxDestepAlu = -1.0;
108 //_____________________________________________________________________________
109 AliVZERO::~AliVZERO()
112 // Default destructor for VZERO Detector
126 //_____________________________________________________________________________
127 void AliVZERO::BuildGeometry()
130 // Builds simple ROOT TNode geometry for event display
134 //_____________________________________________________________________________
135 void AliVZERO::CreateGeometry()
138 // Builds simple Geant3 geometry
141 //_____________________________________________________________________________
142 void AliVZERO::CreateMaterials()
145 // Creates materials used for Geant3 geometry
149 //_____________________________________________________________________________
150 Int_t AliVZERO::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
153 // Calculates the distance from the mouse to the VZERO on the screen
160 //_____________________________________________________________________________
161 void AliVZERO::Init()
164 // Initialises the VZERO class after it has been built
169 //_____________________________________________________________________________
170 void AliVZERO::SetMaxStepQua(Float_t p1)
173 // Possible parametrisation of steps in active materials
178 //_____________________________________________________________________________
179 void AliVZERO::SetMaxStepAlu(Float_t p1)
182 // Possible parametrisation of steps in Aluminum foils (not used in
188 //_____________________________________________________________________________
189 void AliVZERO::SetMaxDestepQua(Float_t p1)
192 // Possible parametrisation of steps in active materials (quartz)
197 //_____________________________________________________________________________
198 void AliVZERO::SetMaxDestepAlu(Float_t p1)
201 // Possible parametrisation of steps in Aluminum (not used in
207 //_____________________________________________________________________________
208 AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
211 // Builds VZEROgetter (AliLoader type)
212 // if detector wants to use customized getter, it must overload this method
214 // Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername);
216 AliDebug(1,Form("Creating AliVZEROLoader, Top folder is %s ",topfoldername));
217 fLoader = new AliVZEROLoader(GetName(),topfoldername);
221 //_____________________________________________________________________________
222 void AliVZERO::SetTreeAddress()
225 // Sets tree address for hits.
227 if (fLoader->TreeH() && (fHits == 0x0))
228 fHits = new TClonesArray("AliVZEROhit", 400);
230 AliDetector::SetTreeAddress();
233 //_____________________________________________________________________________
234 AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
237 // Creates a digitizer for VZERO
239 return new AliVZERODigitizer(manager);
242 //_____________________________________________________________________________
243 void AliVZERO::Hits2Digits(){
245 // Converts hits to digits of the current event
248 const char *alifile = "galice.root";
250 // Create the run digitizer
251 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
252 manager->SetInputStream(0, alifile);
253 manager->SetOutputFile("H2Dfile");
255 // Creates the VZERO digitizer
256 AliVZERODigitizer* dig = new AliVZERODigitizer(manager);
258 // Creates the digits
262 //_____________________________________________________________________________
263 void AliVZERO::Digits2Raw()
266 // Converts digits of the current event to raw data
268 AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
269 fLoader->LoadDigits();
270 TTree* digits = fLoader->TreeD();
272 Error("Digits2Raw", "no digits tree");
275 TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
276 fVZERO->SetTreeAddress();
277 digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits);
279 const char *fileName = AliDAQ::DdlFileName("VZERO",0);
280 AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName);
285 // 2: txt files with digits
286 // BE CAREFUL, verbose level 2 MUST be used only for debugging and
287 // it is highly suggested to use this mode only for debugging digits files
288 // reasonably small, because otherwise the size of the txt files can reach
289 // quickly several MB wasting time and disk space.
292 buffer->SetVerbose(0);
293 Int_t fVerbose = buffer->GetVerbose();
295 Int_t nEntries = Int_t(digits->GetEntries());
297 for (Int_t i = 0; i < nEntries; i++) {
299 fVZERO->ResetDigits();
301 Int_t ndig = VZEROdigits->GetEntriesFast();
303 if(ndig == 0) continue;
304 if(fVerbose == 2) {ftxt.open("VZEROdigits.txt",ios::app);}
305 for(Int_t k=0; k<ndig; k++){
306 AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k);
307 Int_t ADC = fVZERODigit->ADC();
308 Int_t PMNumber = fVZERODigit->PMNumber();
309 Int_t Time = fVZERODigit->Time();
310 if(fVerbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
311 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;}
313 ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
314 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;
316 buffer->WriteBinary(PMNumber, ADC, Time);
318 if(fVerbose==2) ftxt.close();
322 fLoader->UnloadDigits();