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"
45 #include "TParameter.h"
47 // --- AliRoot header files ---
51 #include "AliVZEROLoader.h"
52 #include "AliVZERODigitizer.h"
53 #include "AliVZEROBuffer.h"
54 #include "AliRunDigitizer.h"
55 #include "AliVZEROdigit.h"
57 #include "AliRawReader.h"
58 #include "AliVZERORawStream.h"
59 #include "AliVZEROCalibData.h"
62 //__________________________________________________________________
63 AliVZERO::AliVZERO(): AliDetector(),
72 /// Default Constructor
74 AliDebug(1,Form("default (empty) ctor this=%p",this));
77 //_____________________________________________________________________________
78 AliVZERO::AliVZERO(const char *name, const char *title)
79 : AliDetector(name,title),
89 // Standard constructor for VZERO Detector
91 AliDebug(1,Form("ctor this=%p",this));
93 // fIshunt = 1; // All hits are associated with primary particles
95 fHits = new TClonesArray("AliVZEROhit", 400);
96 fDigits = new TClonesArray("AliVZEROdigit",400);
98 gAlice->GetMCApp()->AddHitList(fHits);
100 // fThickness = 4.4; // total thickness of the V0R box in cm
101 // fThickness1 = 2.0; // thickness of scintillating cells in cm
103 // fMaxStepQua = 0.05;
104 // fMaxStepAlu = 0.01;
106 // fMaxDestepQua = -1.0;
107 // fMaxDestepAlu = -1.0;
112 //_____________________________________________________________________________
113 AliVZERO::~AliVZERO()
116 // Default destructor for VZERO Detector
130 //_____________________________________________________________________________
131 void AliVZERO::CreateGeometry()
134 // Builds simple Geant3 geometry
137 //_____________________________________________________________________________
138 void AliVZERO::CreateMaterials()
141 // Creates materials used for Geant3 geometry
145 //_____________________________________________________________________________
146 void AliVZERO::Init()
149 // Initialises the VZERO class after it has been built
154 //_____________________________________________________________________________
155 void AliVZERO::SetMaxStepQua(Float_t p1)
158 // Possible parametrisation of steps in active materials
163 //_____________________________________________________________________________
164 void AliVZERO::SetMaxStepAlu(Float_t p1)
167 // Possible parametrisation of steps in Aluminum foils (not used in
173 //_____________________________________________________________________________
174 void AliVZERO::SetMaxDestepQua(Float_t p1)
177 // Possible parametrisation of steps in active materials (quartz)
182 //_____________________________________________________________________________
183 void AliVZERO::SetMaxDestepAlu(Float_t p1)
186 // Possible parametrisation of steps in Aluminum (not used in
192 //_____________________________________________________________________________
193 AliLoader* AliVZERO::MakeLoader(const char* topfoldername)
196 // Builds VZEROgetter (AliLoader type)
197 // if detector wants to use customized getter, it must overload this method
199 // Info("MakeLoader","Creating AliVZEROLoader. Top folder is %s.",topfoldername);
201 AliDebug(1,Form("Creating AliVZEROLoader, Top folder is %s ",topfoldername));
202 fLoader = new AliVZEROLoader(GetName(),topfoldername);
206 //_____________________________________________________________________________
207 void AliVZERO::SetTreeAddress()
210 // Sets tree address for hits.
212 if (fLoader->TreeH() && (fHits == 0x0))
213 fHits = new TClonesArray("AliVZEROhit", 400);
215 AliDetector::SetTreeAddress();
218 //_____________________________________________________________________________
219 AliDigitizer* AliVZERO::CreateDigitizer(AliRunDigitizer* manager) const
222 // Creates a digitizer for VZERO
224 return new AliVZERODigitizer(manager);
227 //_____________________________________________________________________________
228 void AliVZERO::Hits2Digits(){
230 // Converts hits to digits
232 // Creates the VZERO digitizer
233 AliVZERODigitizer* dig = new AliVZERODigitizer(this,AliVZERODigitizer::kHits2Digits);
235 // Creates the digits
240 //_____________________________________________________________________________
241 void AliVZERO::Hits2SDigits(){
243 // Converts hits to summable digits
245 // Creates the VZERO digitizer
246 AliVZERODigitizer* dig = new AliVZERODigitizer(this,AliVZERODigitizer::kHits2SDigits);
248 // Creates the sdigits
253 //_____________________________________________________________________________
254 void AliVZERO::Digits2Raw()
257 // Converts digits of the current event to raw data
260 AliVZERO *fVZERO = (AliVZERO*)gAlice->GetDetector("VZERO");
261 fLoader->LoadDigits();
262 TTree* digits = fLoader->TreeD();
264 Error("Digits2Raw", "no digits tree");
267 TClonesArray * VZEROdigits = new TClonesArray("AliVZEROdigit",1000);
268 fVZERO->SetTreeAddress();
269 digits->GetBranch("VZERODigit")->SetAddress(&VZEROdigits);
271 const char *fileName = AliDAQ::DdlFileName("VZERO",0);
272 AliVZEROBuffer* buffer = new AliVZEROBuffer(fileName);
274 // Get Trigger information first
275 // Read trigger inputs from trigger-detector object
276 AliDataLoader * dataLoader = fLoader->GetDigitsDataLoader();
277 if( !dataLoader->IsFileOpen() )
278 dataLoader->OpenFile( "READ" );
279 AliTriggerDetector* trgdet = (AliTriggerDetector*)dataLoader->GetDirectory()->Get( "Trigger" );
280 UInt_t triggerInfo = 0;
282 triggerInfo = trgdet->GetMask() & 0xffff;
285 AliError(Form("There is no trigger object for %s",fLoader->GetName()));
288 buffer->WriteTriggerInfo((UInt_t)triggerInfo);
289 buffer->WriteTriggerScalers();
290 buffer->WriteBunchNumbers();
292 Int_t aBBflagsV0A = 0;
293 Int_t aBBflagsV0C = 0;
294 Int_t aBGflagsV0A = 0;
295 Int_t aBGflagsV0C = 0;
297 if (digits->GetUserInfo()->FindObject("BBflagsV0A")) {
298 aBBflagsV0A = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BBflagsV0A"))->GetVal();
301 AliWarning("V0A beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
303 if (digits->GetUserInfo()->FindObject("BBflagsV0C")) {
304 aBBflagsV0C = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BBflagsV0C"))->GetVal();
307 AliWarning("V0C beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
309 if (digits->GetUserInfo()->FindObject("BGflagsV0A")) {
310 aBGflagsV0A = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BGflagsV0A"))->GetVal();
313 AliWarning("V0A beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
315 if (digits->GetUserInfo()->FindObject("BGflagsV0C")) {
316 aBGflagsV0C = ((TParameter<int>*)digits->GetUserInfo()->FindObject("BGflagsV0C"))->GetVal();
319 AliWarning("V0C beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
321 // Now retrieve the channel information: charge smaples + time and
322 // dump it into ADC and Time arrays
323 Int_t nEntries = Int_t(digits->GetEntries());
324 Short_t aADC[64][AliVZEROdigit::kNClocks];
327 Bool_t aIntegrator[64];
331 for (Int_t i = 0; i < nEntries; i++) {
332 fVZERO->ResetDigits();
334 Int_t ndig = VZEROdigits->GetEntriesFast();
336 if(ndig == 0) continue;
337 for(Int_t k=0; k<ndig; k++){
338 AliVZEROdigit* fVZERODigit = (AliVZEROdigit*) VZEROdigits->At(k);
339 // Convert aliroot channel k into FEE channel iChannel before writing data
340 Int_t iChannel = AliVZEROCalibData::GetBoardNumber(fVZERODigit->PMNumber()) * 8 +
341 AliVZEROCalibData::GetFEEChannelNumber(fVZERODigit->PMNumber());
342 for(Int_t iClock = 0; iClock < AliVZEROdigit::kNClocks; ++iClock) aADC[iChannel][iClock] = fVZERODigit->ChargeADC(iClock);
343 aTime[iChannel] = fVZERODigit->Time();
344 aWidth[iChannel] = fVZERODigit->Width();
345 aIntegrator[iChannel]= fVZERODigit->Integrator();
346 if(fVZERODigit->PMNumber() < 32) {
347 aBBflag[iChannel] = (aBBflagsV0C >> fVZERODigit->PMNumber()) & 0x1;
348 aBGflag[iChannel] = (aBGflagsV0C >> fVZERODigit->PMNumber()) & 0x1;
351 aBBflag[iChannel] = (aBBflagsV0A >> (fVZERODigit->PMNumber()-32)) & 0x1;
352 aBGflag[iChannel] = (aBGflagsV0A >> (fVZERODigit->PMNumber()-32)) & 0x1;
354 AliDebug(1,Form("DDL: %s\tdigit number: %d\tPM number: %d\tADC: %f\tTime: %f",
355 fileName,k,fVZERODigit->PMNumber(),aADC[k],aTime[k]));
361 for (Int_t iCIU = 0; iCIU < 8; iCIU++) {
363 // decoding of one Channel Interface Unit numbered iCIU - there are 8 channels per CIU (and 8 CIUs) :
365 for(Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) {
366 for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
367 buffer->WriteChannel(iChannel, aADC[iChannel], aIntegrator[iChannel]);
369 buffer->WriteBeamFlags(&aBBflag[iChannel_Offset],&aBGflag[iChannel_Offset]);
370 buffer->WriteMBInfo();
371 buffer->WriteMBFlags();
372 buffer->WriteBeamScalers();
375 for(Int_t iChannel = iCIU*8 + 7; iChannel >= iCIU*8; iChannel--) {
376 buffer->WriteTiming(aTime[iChannel], aWidth[iChannel]);
379 // End of decoding of one CIU card
381 } // end of decoding the eight CIUs
384 fLoader->UnloadDigits();
387 //_____________________________________________________________________________
388 Bool_t AliVZERO::Raw2SDigits(AliRawReader* rawReader){
389 // Converts the VZERO raw data into digits
390 // The method is used for merging simulated and
396 AliError("no VZERO loader found");
399 TTree* treeD = fLoader->TreeD();
401 fLoader->MakeTree("D");
402 treeD = fLoader->TreeD(); }
405 AliVZEROdigit* pdigit = &digit;
406 const Int_t kBufferSize = 4000;
408 treeD->Branch("VZERO", "AliVZEROdigit", &pdigit, kBufferSize);
411 AliVZERORawStream* rawStream = new AliVZERORawStream(rawReader);
413 if (!rawStream->Next()) return kFALSE; // No VZERO data found
415 fLoader->WriteDigits("OVERWRITE");
416 fLoader->UnloadDigits();