]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZERO.cxx
Small optimizations
[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"
362c9d61 55#include "AliDAQ.h"
47890cd3 56
57ClassImp(AliVZERO)
0b2bea8b 58 //__________________________________________________________________
59AliVZERO::AliVZERO(): AliDetector(),
60 fIdSens1(0),
61 fThickness(0.),
62 fThickness1(0.),
63 fMaxStepQua(0.),
64 fMaxStepAlu(0.),
65 fMaxDestepQua(0.),
66 fMaxDestepAlu(0.)
67{
68/// Default Constructor
69
70 AliDebug(1,Form("default (empty) ctor this=%p",this));
71 fIshunt = 0;
72}
47890cd3 73//_____________________________________________________________________________
74AliVZERO::AliVZERO(const char *name, const char *title)
0b2bea8b 75 : AliDetector(name,title),
76 fIdSens1(0),
77 fThickness(4.4),
78 fThickness1(2.0),
79 fMaxStepQua(0.05),
80 fMaxStepAlu(0.01),
81 fMaxDestepQua(-1.0),
82 fMaxDestepAlu(-1.0)
47890cd3 83{
0b2bea8b 84
47890cd3 85 // Standard constructor for VZERO Detector
0b2bea8b 86
87 AliDebug(1,Form("ctor this=%p",this));
47890cd3 88
b0d2c2d3 89 // fIshunt = 1; // All hits are associated with primary particles
47890cd3 90
61874e87 91 fHits = new TClonesArray("AliVZEROhit", 400);
92 fDigits = new TClonesArray("AliVZEROdigit",400);
93
5d12ce38 94 gAlice->GetMCApp()->AddHitList(fHits);
61874e87 95
0b2bea8b 96// fThickness = 4.4; // total thickness of the V0R box in cm
97// fThickness1 = 2.0; // thickness of scintillating cells in cm
98//
99// fMaxStepQua = 0.05;
100// fMaxStepAlu = 0.01;
101//
102// fMaxDestepQua = -1.0;
103// fMaxDestepAlu = -1.0;
47890cd3 104
47890cd3 105
61874e87 106}
107
108//_____________________________________________________________________________
109AliVZERO::~AliVZERO()
110{
b2501ea3 111 //
112 // Default destructor for VZERO Detector
113 //
114
61874e87 115 if (fHits) {
116 fHits->Delete();
117 delete fHits;
b0d2c2d3 118 fHits=0; }
b2501ea3 119
120 if (fDigits) {
121 fDigits->Delete();
122 delete fDigits;
b0d2c2d3 123 fDigits=0; }
61874e87 124}
47890cd3 125
126//_____________________________________________________________________________
127void AliVZERO::BuildGeometry()
128{
129 //
b2501ea3 130 // Builds simple ROOT TNode geometry for event display
47890cd3 131 //
132}
133
134//_____________________________________________________________________________
135void AliVZERO::CreateGeometry()
136{
137 //
b2501ea3 138 // Builds simple Geant3 geometry
47890cd3 139 //
140}
141//_____________________________________________________________________________
142void AliVZERO::CreateMaterials()
143{
144 //
b2501ea3 145 // Creates materials used for Geant3 geometry
47890cd3 146 //
147}
61874e87 148
47890cd3 149//_____________________________________________________________________________
652e94c3 150Int_t AliVZERO::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
47890cd3 151{
152 //
b2501ea3 153 // Calculates the distance from the mouse to the VZERO on the screen
47890cd3 154 // Dummy routine
155 //
156
157 return 9999;
158}
159
b2501ea3 160//_____________________________________________________________________________
47890cd3 161void AliVZERO::Init()
162{
163 //
b2501ea3 164 // Initialises the VZERO class after it has been built
47890cd3 165 //
166}
167
61874e87 168
b2501ea3 169//_____________________________________________________________________________
47890cd3 170void AliVZERO::SetMaxStepQua(Float_t p1)
171{
b2501ea3 172 //
173 // Possible parametrisation of steps in active materials
174 //
47890cd3 175 fMaxStepQua = p1;
176}
177
b2501ea3 178//_____________________________________________________________________________
47890cd3 179void AliVZERO::SetMaxStepAlu(Float_t p1)
180{
b2501ea3 181 //
182 // Possible parametrisation of steps in Aluminum foils (not used in
183 // version v2)
184 //
47890cd3 185 fMaxStepAlu = p1;
186}
187
b2501ea3 188//_____________________________________________________________________________
47890cd3 189void AliVZERO::SetMaxDestepQua(Float_t p1)
190{
b2501ea3 191 //
192 // Possible parametrisation of steps in active materials (quartz)
193 //
47890cd3 194 fMaxDestepQua = p1;
195}
196
b2501ea3 197//_____________________________________________________________________________
47890cd3 198void AliVZERO::SetMaxDestepAlu(Float_t p1)
199{
b2501ea3 200 //
201 // Possible parametrisation of steps in Aluminum (not used in
202 // version v2)
203 //
47890cd3 204 fMaxDestepAlu = p1;
205}
4dbb3fd3 206
b2501ea3 207//_____________________________________________________________________________
4dbb3fd3 208AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
209{
b2501ea3 210 //
211 // Builds VZEROgetter (AliLoader type)
4dbb3fd3 212 // if detector wants to use customized getter, it must overload this method
b2501ea3 213 //
3e87825e 214// Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername);
215
216 AliDebug(1,Form("Creating AliVZEROLoader, Top folder is %s ",topfoldername));
4dbb3fd3 217 fLoader = new AliVZEROLoader(GetName(),topfoldername);
218 return fLoader;
219}
220
b2501ea3 221//_____________________________________________________________________________
222void AliVZERO::SetTreeAddress()
223{
b0d2c2d3 224 //
0e305a84 225 // Sets tree address for hits.
b2501ea3 226 //
0e305a84 227 if (fLoader->TreeH() && (fHits == 0x0))
228 fHits = new TClonesArray("AliVZEROhit", 400);
229
230 AliDetector::SetTreeAddress();
231}
4dbb3fd3 232
b0d2c2d3 233//_____________________________________________________________________________
234AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
235{
236 //
237 // Creates a digitizer for VZERO
238 //
239 return new AliVZERODigitizer(manager);
240}
241
242//_____________________________________________________________________________
243void AliVZERO::Hits2Digits(){
244 //
245 // Converts hits to digits of the current event
246 //
247 // Inputs file name
d3d4a92f 248 const char *alifile = "galice.root";
b0d2c2d3 249
250 // Create the run digitizer
251 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
252 manager->SetInputStream(0, alifile);
253 manager->SetOutputFile("H2Dfile");
254
255 // Creates the VZERO digitizer
256 AliVZERODigitizer* dig = new AliVZERODigitizer(manager);
257
258 // Creates the digits
259 dig->Exec("");
260
261}
262//_____________________________________________________________________________
263void AliVZERO::Digits2Raw()
264{
265 //
266 // Converts digits of the current event to raw data
267 //
268 AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
269 fLoader->LoadDigits();
270 TTree* digits = fLoader->TreeD();
271 if (!digits) {
272 Error("Digits2Raw", "no digits tree");
273 return;
274 }
275 TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
276 fVZERO->SetTreeAddress();
277 digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits);
278
362c9d61 279 const char *fileName = AliDAQ::DdlFileName("VZERO",0);
b0d2c2d3 280 AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName);
281
282 // Verbose level
283 // 0: Silent
284 // 1: cout messages
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.
290
291 ofstream ftxt;
292 buffer->SetVerbose(0);
726d762c 293 Int_t verbose = buffer->GetVerbose();
b0d2c2d3 294
726d762c 295 // Get Trigger information first
296 // Read trigger inputs from trigger-detector object
297 AliDataLoader * dataLoader = fLoader->GetDigitsDataLoader();
298 if( !dataLoader->IsFileOpen() )
299 dataLoader->OpenFile( "READ" );
300 AliTriggerDetector* trgdet = (AliTriggerDetector*)dataLoader->GetDirectory()->Get( "Trigger" );
301 UInt_t triggerInfo = 0;
302 if(trgdet) {
303 triggerInfo = trgdet->GetMask() & 0xffff;
304 }
305 else {
306 AliError(Form("There is no trigger object for %s",fLoader->GetName()));
307 }
308 buffer->WriteTriggerInfo((UInt_t)triggerInfo);
309
310 // Now write the channel information: charge+time
311 // We assume here an ordered (by PMNumber) array of
312 // digits!!
b0d2c2d3 313 Int_t nEntries = Int_t(digits->GetEntries());
b0d2c2d3 314 for (Int_t i = 0; i < nEntries; i++) {
315
316 fVZERO->ResetDigits();
317 digits->GetEvent(i);
318 Int_t ndig = VZEROdigits->GetEntriesFast();
319
320 if(ndig == 0) continue;
726d762c 321 if(verbose == 2) {ftxt.open("VZEROdigits.txt",ios::app);}
b0d2c2d3 322 for(Int_t k=0; k<ndig; k++){
323 AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k);
20277079 324 Int_t ADC = fVZERODigit->ADC();
325 Int_t PMNumber = fVZERODigit->PMNumber();
326 Int_t Time = fVZERODigit->Time();
726d762c 327 if(verbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
20277079 328 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;}
726d762c 329 if(verbose == 2) {
20277079 330 ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: "
331 <<PMNumber<<"\tADC: "<< ADC << "\tTime: "<< Time << endl;
b0d2c2d3 332 }
726d762c 333 buffer->WriteChannel(PMNumber, ADC, Time);
b0d2c2d3 334 }
726d762c 335 if(verbose==2) ftxt.close();
b0d2c2d3 336 }
337
726d762c 338 buffer->WriteScalers();
339 buffer->WriteMBInfo();
340
b0d2c2d3 341 delete buffer;
342 fLoader->UnloadDigits();
343}
344
4dbb3fd3 345