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"
59 //_____________________________________________________________________________
60 AliVZERO::AliVZERO(const char *name, const char *title)
61 : AliDetector(name,title)
64 // Standard constructor for VZERO Detector
67 // fIshunt = 1; // All hits are associated with primary particles
69 fHits = new TClonesArray("AliVZEROhit", 400);
70 fDigits = new TClonesArray("AliVZEROdigit",400);
72 gAlice->GetMCApp()->AddHitList(fHits);
74 fThickness = 4.4; // total thickness of the V0R box in cm
75 fThickness1 = 2.0; // thickness of scintillating cells in cm
86 //_____________________________________________________________________________
90 // Default destructor for VZERO Detector
104 //_____________________________________________________________________________
105 void AliVZERO::BuildGeometry()
108 // Builds simple ROOT TNode geometry for event display
112 //_____________________________________________________________________________
113 void AliVZERO::CreateGeometry()
116 // Builds simple Geant3 geometry
119 //_____________________________________________________________________________
120 void AliVZERO::CreateMaterials()
123 // Creates materials used for Geant3 geometry
127 //_____________________________________________________________________________
128 Int_t AliVZERO::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
131 // Calculates the distance from the mouse to the VZERO on the screen
138 //_____________________________________________________________________________
139 void AliVZERO::Init()
142 // Initialises the VZERO class after it has been built
147 //_____________________________________________________________________________
148 void AliVZERO::SetMaxStepQua(Float_t p1)
151 // Possible parametrisation of steps in active materials
156 //_____________________________________________________________________________
157 void AliVZERO::SetMaxStepAlu(Float_t p1)
160 // Possible parametrisation of steps in Aluminum foils (not used in
166 //_____________________________________________________________________________
167 void AliVZERO::SetMaxDestepQua(Float_t p1)
170 // Possible parametrisation of steps in active materials (quartz)
175 //_____________________________________________________________________________
176 void AliVZERO::SetMaxDestepAlu(Float_t p1)
179 // Possible parametrisation of steps in Aluminum (not used in
185 //_____________________________________________________________________________
186 AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
189 // Builds VZEROgetter (AliLoader type)
190 // if detector wants to use customized getter, it must overload this method
192 // Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername);
194 AliDebug(1,Form("Creating AliVZEROLoader, Top folder is %s ",topfoldername));
195 fLoader = new AliVZEROLoader(GetName(),topfoldername);
199 //_____________________________________________________________________________
200 void AliVZERO::SetTreeAddress()
203 // Sets tree address for hits.
205 if (fLoader->TreeH() && (fHits == 0x0))
206 fHits = new TClonesArray("AliVZEROhit", 400);
208 AliDetector::SetTreeAddress();
211 //_____________________________________________________________________________
212 AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
215 // Creates a digitizer for VZERO
217 return new AliVZERODigitizer(manager);
220 //_____________________________________________________________________________
221 void AliVZERO::Hits2Digits(){
223 // Converts hits to digits of the current event
226 const char *alifile = "galice.root";
228 // Create the run digitizer
229 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
230 manager->SetInputStream(0, alifile);
231 manager->SetOutputFile("H2Dfile");
233 // Creates the VZERO digitizer
234 AliVZERODigitizer* dig = new AliVZERODigitizer(manager);
236 // Creates the digits
240 //_____________________________________________________________________________
241 void AliVZERO::Digits2Raw()
244 // Converts digits of the current event to raw data
246 AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
247 fLoader->LoadDigits();
248 TTree* digits = fLoader->TreeD();
250 Error("Digits2Raw", "no digits tree");
253 TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
254 fVZERO->SetTreeAddress();
255 digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits);
257 const char *fileName = AliDAQ::DdlFileName("VZERO",0);
258 AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName);
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.
270 buffer->SetVerbose(0);
271 Int_t fVerbose = buffer->GetVerbose();
273 Int_t nEntries = Int_t(digits->GetEntries());
275 for (Int_t i = 0; i < nEntries; i++) {
277 fVZERO->ResetDigits();
279 Int_t ndig = VZEROdigits->GetEntriesFast();
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);
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;}
291 ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
292 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;
294 buffer->WriteBinary(PMNumber, ADC, Time);
296 if(fVerbose==2) ftxt.close();
300 fLoader->UnloadDigits();