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(const char *name, const char *title)
60 : AliDetector(name,title)
63 // Standard constructor for VZERO Detector
66 // fIshunt = 1; // All hits are associated with primary particles
68 fHits = new TClonesArray("AliVZEROhit", 400);
69 fDigits = new TClonesArray("AliVZEROdigit",400);
71 gAlice->GetMCApp()->AddHitList(fHits);
73 fThickness = 4.4; // total thickness of the V0R box in cm
74 fThickness1 = 2.0; // thickness of scintillating cells in cm
85 //_____________________________________________________________________________
89 // Default destructor for VZERO Detector
103 //_____________________________________________________________________________
104 void AliVZERO::BuildGeometry()
107 // Builds simple ROOT TNode geometry for event display
111 //_____________________________________________________________________________
112 void AliVZERO::CreateGeometry()
115 // Builds simple Geant3 geometry
118 //_____________________________________________________________________________
119 void AliVZERO::CreateMaterials()
122 // Creates materials used for Geant3 geometry
126 //_____________________________________________________________________________
127 Int_t AliVZERO::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
130 // Calculates the distance from the mouse to the VZERO on the screen
137 //_____________________________________________________________________________
138 void AliVZERO::Init()
141 // Initialises the VZERO class after it has been built
146 //_____________________________________________________________________________
147 void AliVZERO::SetMaxStepQua(Float_t p1)
150 // Possible parametrisation of steps in active materials
155 //_____________________________________________________________________________
156 void AliVZERO::SetMaxStepAlu(Float_t p1)
159 // Possible parametrisation of steps in Aluminum foils (not used in
165 //_____________________________________________________________________________
166 void AliVZERO::SetMaxDestepQua(Float_t p1)
169 // Possible parametrisation of steps in active materials (quartz)
174 //_____________________________________________________________________________
175 void AliVZERO::SetMaxDestepAlu(Float_t p1)
178 // Possible parametrisation of steps in Aluminum (not used in
184 //_____________________________________________________________________________
185 AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
188 // Builds VZEROgetter (AliLoader type)
189 // if detector wants to use customized getter, it must overload this method
192 Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername);
193 fLoader = new AliVZEROLoader(GetName(),topfoldername);
197 //_____________________________________________________________________________
198 void AliVZERO::SetTreeAddress()
201 // Sets tree address for hits.
203 if (fLoader->TreeH() && (fHits == 0x0))
204 fHits = new TClonesArray("AliVZEROhit", 400);
206 AliDetector::SetTreeAddress();
209 //_____________________________________________________________________________
210 AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
213 // Creates a digitizer for VZERO
215 return new AliVZERODigitizer(manager);
218 //_____________________________________________________________________________
219 void AliVZERO::Hits2Digits(){
221 // Converts hits to digits of the current event
224 Char_t *alifile = "galice.root";
226 // Create the run digitizer
227 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
228 manager->SetInputStream(0, alifile);
229 manager->SetOutputFile("H2Dfile");
231 // Creates the VZERO digitizer
232 AliVZERODigitizer* dig = new AliVZERODigitizer(manager);
234 // Creates the digits
238 //_____________________________________________________________________________
239 void AliVZERO::Digits2Raw()
242 // Converts digits of the current event to raw data
244 AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
245 fLoader->LoadDigits();
246 TTree* digits = fLoader->TreeD();
248 Error("Digits2Raw", "no digits tree");
251 TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
252 fVZERO->SetTreeAddress();
253 digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits);
255 const char *fileName = "VZERO_3584.ddl";
256 AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName);
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.
268 buffer->SetVerbose(0);
269 Int_t fVerbose = buffer->GetVerbose();
271 Int_t nEntries = Int_t(digits->GetEntries());
273 for (Int_t i = 0; i < nEntries; i++) {
275 fVZERO->ResetDigits();
277 Int_t ndig = VZEROdigits->GetEntriesFast();
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);
283 Int_t ADC = fVZERODigit->ADC();
284 Int_t cell = fVZERODigit->CellNumber();
285 if(fVerbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tcell: "
286 <<cell<<"\tADC: "<< ADC << endl;}
288 ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tcell: "
289 <<cell<<"\tADC: "<< ADC << endl;
291 buffer->WriteBinary(cell, ADC);
293 if(fVerbose==2) ftxt.close();
297 fLoader->UnloadDigits();