]>
Commit | Line | Data |
---|---|---|
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" |
20a489c2 | 56 | #include "AliRawReader.h" |
57 | #include "AliVZERORawStream.h" | |
47890cd3 | 58 | |
59 | ClassImp(AliVZERO) | |
0b2bea8b | 60 | //__________________________________________________________________ |
61 | AliVZERO::AliVZERO(): AliDetector(), | |
62 | fIdSens1(0), | |
63 | fThickness(0.), | |
64 | fThickness1(0.), | |
65 | fMaxStepQua(0.), | |
66 | fMaxStepAlu(0.), | |
67 | fMaxDestepQua(0.), | |
68 | fMaxDestepAlu(0.) | |
69 | { | |
70 | /// Default Constructor | |
71 | ||
72 | AliDebug(1,Form("default (empty) ctor this=%p",this)); | |
73 | fIshunt = 0; | |
74 | } | |
47890cd3 | 75 | //_____________________________________________________________________________ |
76 | AliVZERO::AliVZERO(const char *name, const char *title) | |
0b2bea8b | 77 | : AliDetector(name,title), |
78 | fIdSens1(0), | |
79 | fThickness(4.4), | |
80 | fThickness1(2.0), | |
81 | fMaxStepQua(0.05), | |
82 | fMaxStepAlu(0.01), | |
83 | fMaxDestepQua(-1.0), | |
84 | fMaxDestepAlu(-1.0) | |
47890cd3 | 85 | { |
0b2bea8b | 86 | |
47890cd3 | 87 | // Standard constructor for VZERO Detector |
0b2bea8b | 88 | |
89 | AliDebug(1,Form("ctor this=%p",this)); | |
47890cd3 | 90 | |
b0d2c2d3 | 91 | // fIshunt = 1; // All hits are associated with primary particles |
47890cd3 | 92 | |
61874e87 | 93 | fHits = new TClonesArray("AliVZEROhit", 400); |
94 | fDigits = new TClonesArray("AliVZEROdigit",400); | |
95 | ||
5d12ce38 | 96 | gAlice->GetMCApp()->AddHitList(fHits); |
61874e87 | 97 | |
0b2bea8b | 98 | // fThickness = 4.4; // total thickness of the V0R box in cm |
99 | // fThickness1 = 2.0; // thickness of scintillating cells in cm | |
100 | // | |
101 | // fMaxStepQua = 0.05; | |
102 | // fMaxStepAlu = 0.01; | |
103 | // | |
104 | // fMaxDestepQua = -1.0; | |
105 | // fMaxDestepAlu = -1.0; | |
47890cd3 | 106 | |
47890cd3 | 107 | |
61874e87 | 108 | } |
109 | ||
110 | //_____________________________________________________________________________ | |
111 | AliVZERO::~AliVZERO() | |
112 | { | |
b2501ea3 | 113 | // |
114 | // Default destructor for VZERO Detector | |
115 | // | |
116 | ||
61874e87 | 117 | if (fHits) { |
118 | fHits->Delete(); | |
119 | delete fHits; | |
b0d2c2d3 | 120 | fHits=0; } |
b2501ea3 | 121 | |
122 | if (fDigits) { | |
123 | fDigits->Delete(); | |
124 | delete fDigits; | |
b0d2c2d3 | 125 | fDigits=0; } |
61874e87 | 126 | } |
47890cd3 | 127 | |
128 | //_____________________________________________________________________________ | |
129 | void AliVZERO::BuildGeometry() | |
130 | { | |
131 | // | |
b2501ea3 | 132 | // Builds simple ROOT TNode geometry for event display |
47890cd3 | 133 | // |
134 | } | |
135 | ||
136 | //_____________________________________________________________________________ | |
137 | void AliVZERO::CreateGeometry() | |
138 | { | |
139 | // | |
b2501ea3 | 140 | // Builds simple Geant3 geometry |
47890cd3 | 141 | // |
142 | } | |
143 | //_____________________________________________________________________________ | |
144 | void AliVZERO::CreateMaterials() | |
145 | { | |
146 | // | |
b2501ea3 | 147 | // Creates materials used for Geant3 geometry |
47890cd3 | 148 | // |
149 | } | |
61874e87 | 150 | |
47890cd3 | 151 | //_____________________________________________________________________________ |
652e94c3 | 152 | Int_t AliVZERO::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/) |
47890cd3 | 153 | { |
154 | // | |
b2501ea3 | 155 | // Calculates the distance from the mouse to the VZERO on the screen |
47890cd3 | 156 | // Dummy routine |
157 | // | |
158 | ||
159 | return 9999; | |
160 | } | |
161 | ||
b2501ea3 | 162 | //_____________________________________________________________________________ |
47890cd3 | 163 | void AliVZERO::Init() |
164 | { | |
165 | // | |
b2501ea3 | 166 | // Initialises the VZERO class after it has been built |
47890cd3 | 167 | // |
168 | } | |
169 | ||
61874e87 | 170 | |
b2501ea3 | 171 | //_____________________________________________________________________________ |
47890cd3 | 172 | void AliVZERO::SetMaxStepQua(Float_t p1) |
173 | { | |
b2501ea3 | 174 | // |
175 | // Possible parametrisation of steps in active materials | |
176 | // | |
47890cd3 | 177 | fMaxStepQua = p1; |
178 | } | |
179 | ||
b2501ea3 | 180 | //_____________________________________________________________________________ |
47890cd3 | 181 | void AliVZERO::SetMaxStepAlu(Float_t p1) |
182 | { | |
b2501ea3 | 183 | // |
184 | // Possible parametrisation of steps in Aluminum foils (not used in | |
185 | // version v2) | |
186 | // | |
47890cd3 | 187 | fMaxStepAlu = p1; |
188 | } | |
189 | ||
b2501ea3 | 190 | //_____________________________________________________________________________ |
47890cd3 | 191 | void AliVZERO::SetMaxDestepQua(Float_t p1) |
192 | { | |
b2501ea3 | 193 | // |
194 | // Possible parametrisation of steps in active materials (quartz) | |
195 | // | |
47890cd3 | 196 | fMaxDestepQua = p1; |
197 | } | |
198 | ||
b2501ea3 | 199 | //_____________________________________________________________________________ |
47890cd3 | 200 | void AliVZERO::SetMaxDestepAlu(Float_t p1) |
201 | { | |
b2501ea3 | 202 | // |
203 | // Possible parametrisation of steps in Aluminum (not used in | |
204 | // version v2) | |
205 | // | |
47890cd3 | 206 | fMaxDestepAlu = p1; |
207 | } | |
4dbb3fd3 | 208 | |
b2501ea3 | 209 | //_____________________________________________________________________________ |
4dbb3fd3 | 210 | AliLoader* AliVZERO::MakeLoader(const char* topfoldername) |
211 | { | |
b2501ea3 | 212 | // |
213 | // Builds VZEROgetter (AliLoader type) | |
4dbb3fd3 | 214 | // if detector wants to use customized getter, it must overload this method |
b2501ea3 | 215 | // |
3e87825e | 216 | // Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername); |
217 | ||
218 | AliDebug(1,Form("Creating AliVZEROLoader, Top folder is %s ",topfoldername)); | |
4dbb3fd3 | 219 | fLoader = new AliVZEROLoader(GetName(),topfoldername); |
220 | return fLoader; | |
221 | } | |
222 | ||
b2501ea3 | 223 | //_____________________________________________________________________________ |
224 | void AliVZERO::SetTreeAddress() | |
225 | { | |
b0d2c2d3 | 226 | // |
0e305a84 | 227 | // Sets tree address for hits. |
b2501ea3 | 228 | // |
0e305a84 | 229 | if (fLoader->TreeH() && (fHits == 0x0)) |
230 | fHits = new TClonesArray("AliVZEROhit", 400); | |
231 | ||
232 | AliDetector::SetTreeAddress(); | |
233 | } | |
4dbb3fd3 | 234 | |
b0d2c2d3 | 235 | //_____________________________________________________________________________ |
236 | AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const | |
237 | { | |
238 | // | |
239 | // Creates a digitizer for VZERO | |
240 | // | |
241 | return new AliVZERODigitizer(manager); | |
242 | } | |
243 | ||
244 | //_____________________________________________________________________________ | |
245 | void AliVZERO::Hits2Digits(){ | |
246 | // | |
247 | // Converts hits to digits of the current event | |
248 | // | |
249 | // Inputs file name | |
d3d4a92f | 250 | const char *alifile = "galice.root"; |
b0d2c2d3 | 251 | |
252 | // Create the run digitizer | |
253 | AliRunDigitizer* manager = new AliRunDigitizer(1, 1); | |
254 | manager->SetInputStream(0, alifile); | |
255 | manager->SetOutputFile("H2Dfile"); | |
256 | ||
257 | // Creates the VZERO digitizer | |
258 | AliVZERODigitizer* dig = new AliVZERODigitizer(manager); | |
259 | ||
260 | // Creates the digits | |
261 | dig->Exec(""); | |
262 | ||
263 | } | |
264 | //_____________________________________________________________________________ | |
265 | void AliVZERO::Digits2Raw() | |
266 | { | |
c4f89fd4 | 267 | // |
268 | // Converts digits of the current event to raw data | |
269 | // | |
b0d2c2d3 | 270 | |
c4f89fd4 | 271 | AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO"); |
272 | fLoader->LoadDigits(); | |
273 | TTree* digits = fLoader->TreeD(); | |
274 | if (!digits) { | |
275 | Error("Digits2Raw", "no digits tree"); | |
276 | return; | |
277 | } | |
278 | TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000); | |
279 | fVZERO->SetTreeAddress(); | |
280 | digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits); | |
b0d2c2d3 | 281 | |
c4f89fd4 | 282 | const char *fileName = AliDAQ::DdlFileName("VZERO",0); |
283 | AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName); | |
b0d2c2d3 | 284 | |
c4f89fd4 | 285 | // Verbose level |
286 | // 0: Silent | |
287 | // 1: cout messages | |
288 | // 2: txt files with digits | |
289 | // BE CAREFUL, verbose level 2 MUST be used only for debugging and | |
290 | // it is highly suggested to use this mode only for debugging digits files | |
291 | // reasonably small, because otherwise the size of the txt files can reach | |
292 | // quickly several MB wasting time and disk space. | |
293 | ||
294 | ofstream ftxt; | |
295 | buffer->SetVerbose(0); | |
296 | Int_t verbose = buffer->GetVerbose(); | |
297 | ||
298 | // Get Trigger information first | |
299 | // Read trigger inputs from trigger-detector object | |
300 | AliDataLoader * dataLoader = fLoader->GetDigitsDataLoader(); | |
301 | if( !dataLoader->IsFileOpen() ) | |
302 | dataLoader->OpenFile( "READ" ); | |
303 | AliTriggerDetector* trgdet = (AliTriggerDetector*)dataLoader->GetDirectory()->Get( "Trigger" ); | |
304 | UInt_t triggerInfo = 0; | |
305 | if(trgdet) { | |
306 | triggerInfo = trgdet->GetMask() & 0xffff; | |
307 | } | |
308 | else { | |
309 | AliError(Form("There is no trigger object for %s",fLoader->GetName())); | |
310 | } | |
b0d2c2d3 | 311 | |
c4f89fd4 | 312 | buffer->WriteTriggerInfo((UInt_t)triggerInfo); |
313 | buffer->WriteTriggerScalers(); | |
314 | buffer->WriteBunchNumbers(); | |
315 | ||
316 | // Now retrieve the channel information: charge+time and | |
317 | // dump it into ADC and Time arrays | |
318 | // We assume here an ordered (by PMNumber) array of | |
319 | // digits!! | |
726d762c | 320 | |
c4f89fd4 | 321 | Int_t nEntries = Int_t(digits->GetEntries()); |
322 | UInt_t ADC[64]; | |
323 | Int_t PMNumber[64]; | |
324 | UInt_t Time[64]; | |
b0d2c2d3 | 325 | |
c4f89fd4 | 326 | for (Int_t i = 0; i < nEntries; i++) { |
327 | fVZERO->ResetDigits(); | |
328 | digits->GetEvent(i); | |
329 | Int_t ndig = VZEROdigits->GetEntriesFast(); | |
b0d2c2d3 | 330 | |
c4f89fd4 | 331 | if(ndig == 0) continue; |
332 | if(verbose == 2) {ftxt.open("VZEROdigits.txt",ios::app);} | |
333 | for(Int_t k=0; k<ndig; k++){ | |
334 | AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k); | |
335 | ADC[k] = (UInt_t) fVZERODigit->ADC(); | |
336 | PMNumber[k] = fVZERODigit->PMNumber(); | |
337 | Time[k] = (UInt_t) fVZERODigit->Time(); | |
338 | if(verbose == 1) { cout <<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: " | |
339 | <<PMNumber[k]<<"\tADC: "<< ADC[k] << "\tTime: "<< Time[k] << endl;} | |
340 | if(verbose == 2) { | |
341 | ftxt<<"DDL: "<<fileName<< "\tdigit number: "<< k<<"\tPM number: " | |
342 | <<PMNumber[k]<<"\tADC: "<< ADC[k] << "\tTime: "<< Time[k] << endl;} | |
343 | // printf("DDL: %s, channel: %d, PM: %d, ADC: %d, Time: %d \n", | |
344 | // fileName,k,PMNumber[k],ADC[k],Time[k]); | |
345 | } | |
346 | if(verbose==2) ftxt.close(); | |
347 | } | |
b0d2c2d3 | 348 | |
c4f89fd4 | 349 | // Now fill raw data |
350 | ||
351 | for (Int_t iCIU = 0; iCIU < 8; iCIU++) { | |
352 | ||
353 | // decoding of one Channel Interface Unit numbered iCIU - there are 8 channels per CIU (and 8 CIUs) : | |
354 | ||
355 | for(Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) { | |
356 | for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) { | |
357 | buffer->WriteChannel(iChannel, ADC[iChannel], Time[iChannel]); | |
358 | } | |
359 | buffer->WriteBeamFlags(); | |
360 | buffer->WriteMBInfo(); | |
361 | buffer->WriteMBFlags(); | |
362 | buffer->WriteBeamScalers(); | |
363 | } | |
364 | for(Int_t kChannel = kChannel=0; kChannel < 8; kChannel++) { | |
365 | buffer->WriteTiming(kChannel, ADC[kChannel], Time[kChannel]); | |
366 | } | |
726d762c | 367 | |
c4f89fd4 | 368 | // End of decoding of one CIU card |
369 | ||
370 | } // end of decoding the eight CIUs | |
371 | ||
b0d2c2d3 | 372 | delete buffer; |
c4f89fd4 | 373 | fLoader->UnloadDigits(); |
b0d2c2d3 | 374 | } |
375 | ||
20a489c2 | 376 | //_____________________________________________________________________________ |
377 | Bool_t AliVZERO::Raw2SDigits(AliRawReader* rawReader){ | |
378 | // Converts the VZERO raw data into digits | |
379 | // The method is used for merging simulated and | |
380 | // real data events | |
381 | TStopwatch timer; | |
382 | timer.Start(); | |
383 | ||
384 | if(!fLoader) { | |
385 | AliError("no VZERO loader found"); | |
386 | return kFALSE; } | |
387 | ||
388 | TTree* treeD = fLoader->TreeD(); | |
389 | if(!treeD) { | |
390 | fLoader->MakeTree("D"); | |
391 | treeD = fLoader->TreeD(); } | |
392 | ||
393 | AliVZEROdigit digit; | |
394 | AliVZEROdigit* pdigit = &digit; | |
395 | const Int_t kBufferSize = 4000; | |
396 | ||
397 | treeD->Branch("VZERO", "AliVZEROdigit", &pdigit, kBufferSize); | |
398 | ||
399 | rawReader->Reset(); | |
400 | AliVZERORawStream* rawStream = new AliVZERORawStream(rawReader); | |
401 | ||
402 | if (!rawStream->Next()) return kFALSE; // No VZERO data found | |
403 | ||
404 | for(Int_t i=0; i<64; i++) { | |
405 | new(pdigit) AliVZEROdigit(i, (Int_t)rawStream->GetADC(i), (Int_t)rawStream->GetTime(i)); | |
406 | treeD->Fill(); | |
407 | } | |
408 | ||
409 | // Checks if everything is OK by printing results | |
410 | ||
411 | // for(int i=0;i<64;i++) { | |
412 | // printf("Channel %d : %d %d \n",i,rawStream->GetADC(i),rawStream->GetTime(i)); } | |
413 | // treeD->Print(); printf(" \n"); | |
414 | ||
415 | fLoader->WriteDigits("OVERWRITE"); | |
416 | fLoader->UnloadDigits(); | |
417 | ||
418 | delete rawStream; | |
419 | ||
420 | timer.Stop(); | |
421 | timer.Print(); | |
422 | } | |
423 | ||
4dbb3fd3 | 424 |