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 **************************************************************************/
16 /* $Id: AliAD.cxx $ */
18 ///////////////////////////////////////////////////////////////////////////
20 // AD (ALICE Diffractive) Detector //
22 // This class contains the base procedures for the AD detector //
23 // All comments should be sent to : //
26 ///////////////////////////////////////////////////////////////////////////
29 // --- Standard libraries ---
30 #include <Riostream.h>
33 // --- ROOT libraries ---
41 #include "TClonesArray.h"
42 #include "TGeoGlobalMagField.h"
44 #include "TStopwatch.h"
45 #include "TParameter.h"
48 // --- AliRoot header files ---
53 #include "AliADLoader.h"
54 #include "AliADDigitizer.h"
55 #include "AliADBuffer.h"
56 #include "AliADConst.h"
57 #include "AliDigitizationInput.h"
58 #include "AliADdigit.h"
59 #include "AliADSDigit.h"
60 #include "AliADCalibData.h"
62 #include "AliRawReader.h"
63 #include "AliCDBManager.h"
64 #include "AliCDBEntry.h"
65 #include "AliADReconstructor.h"
68 //__________________________________________________________________
71 fSetADAToInstalled(0),
74 /// Default Constructor
79 //_____________________________________________________________________________
80 AliAD::AliAD(const char *name, const char *title)
81 : AliDetector(name,title),
82 fSetADAToInstalled(kTRUE),
83 fSetADCToInstalled(kTRUE)
87 // Standard constructor for AD Detector
92 //_____________________________________________________________________________
96 // Default destructor for AD Detector
101 //_____________________________________________________________________________
102 void AliAD::CreateMaterials()
105 // MATERIALS FOR ADC AND ADA
108 // Parameters for simulation scope for ADA and ADC (stolen from AliVZEROv7::CreateMaterials )
109 Int_t fieldType = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); // Field type
110 Double_t maxField = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max(); // Field max.
111 Double_t maxBending = 10; // Max Angle
112 Double_t maxStepSize = 0.01; // Max step size
113 Double_t maxEnergyLoss = 1; // Max Delta E
114 Double_t precision = 0.003; // Precision
115 Double_t minStepSize = 0.003; // Minimum step size
116 Float_t density, as[11], zs[11], ws[11];
117 Double_t radLength, absLength, a_ad, z_ad;
121 // Parameters for AD scintillator: NE-102 (BC400)
123 // NE-102, has the following properties : (from internet, need better reference)
124 // Density : ca. 1.03 g/cm3
125 // Electrons/cm3: 3.39 x 10^23
126 // H atoms/cm3: 5.28 x 10^22
127 // C atoms/cm3: 4.78 x 10^22
128 // Ratio of H to C : 1.104 .
129 // wavelength of emission : ~4.23 nm.
130 // Decay time : ~2.4 ns.
131 // Luminescent efficiency : typically 18% of NaI(Tl)
132 // Photons/MeV: 2.5 x 10^4
135 as[0] = 1.00794; as[1] = 12.011;
136 zs[0] = 1.; zs[1] = 6.;
137 ws[0] = 5.23; ws[1] = 4.74;
140 AliMixture( id, "NE102", as, zs, density, -2, ws );
141 AliMedium( id, "NE102", id, 1, fieldType, maxField, maxBending, maxStepSize,
142 maxEnergyLoss, precision, minStepSize );
145 // Parameters for lightGuide:
146 // TODO check material
147 // Should be Poly(methyl methacrylate) (PMMA) acrylic
149 // Density 1.18 g/cm3
150 // Mixture PMMA Aeff=12.3994 Zeff=6.23653 rho=1.18 radlen=34.0677 intlen=63.3073
151 // Element #0 : C Z= 6.00 A= 12.01 w= 0.600 natoms=5
152 // Element #1 : H Z= 1.00 A= 1.01 w= 0.081 natoms=8
153 // Element #2 : O Z= 8.00 A= 16.00 w= 0.320 natoms=2
155 // Carbon Hydrogen Oxygen
156 as[0] = 12.0107; as[1] = 1.00794; as[2] = 15.9994;
157 zs[0] = 6.; zs[1] = 1.; zs[2] = 8.;
158 ws[0] = 0.60; ws[1] = 0.081; ws[2] = 0.32;
161 AliMixture( id, "PMMA", as, zs, density, 3, ws );
162 AliMedium( id,"PMMA", id, 1, fieldType, maxField, maxBending, maxStepSize,
163 maxEnergyLoss, precision, minStepSize );
167 // Niquel Iron Molybdenum Manganese
168 as[0] = 58.6934; as[1] = 55.845; as[2] = 95.94; as[3] = 54.9380;
169 zs[0] = 28.; zs[1] = 26.; zs[2] = 42.; zs[3] = 25.;
170 ws[0] = 0.802; ws[1] = 0.14079; ws[2] = 0.0485; ws[3] = 0.005;
171 // Silicon Chromium Cobalt Aluminium
172 as[4] = 28.0855; as[5] = 51.9961; as[6] = 58.9332; as[7] = 26.981539;
173 zs[4] = 14.; zs[5] = 24.; zs[6] = 27.; zs[7] = 13.;
174 ws[4] = 0.003; ws[5] = 0.0002; ws[6] = 0.0002; ws[7] = 0.0001;
175 // Carbon Phosphorus Sulfur
176 as[8] = 12.0107; as[9] = 30.97376; as[10] = 32.066;
177 zs[8] = 6.; zs[9] = 15.; zs[10] = 16.;
178 ws[8] = 0.00015; ws[9] = 0.00005; ws[10] = 0.00001;
181 AliMixture( id, "MuMetal", as, zs, density, 11, ws );
182 AliMedium( id,"MuMetal", id, 1, fieldType, maxField, maxBending, maxStepSize,
183 maxEnergyLoss, precision, minStepSize );
185 // Parameters for ADCPMA: Aluminium
192 AliMaterial (id, "Alum", a_ad, z_ad, density, radLength, absLength, 0, 0 );
193 AliMedium( id, "Alum", id, 1, fieldType, maxField, maxBending, maxStepSize,
194 maxEnergyLoss, precision, minStepSize );
196 // Parameters for ADCPMG: Glass for the simulation Aluminium
204 AliMaterial( id, "Glass", a_ad, z_ad, density, radLength, absLength, 0, 0 );
205 AliMedium( id, "Glass", id, 1, fieldType, maxField, maxBending, maxStepSize,
206 maxEnergyLoss, precision, minStepSize );
210 //_____________________________________________________________________________
211 void AliAD::SetTreeAddress()
214 // Sets tree address for hits.
219 snprintf(branchname,19,"%s",GetName());
220 // Branch address for hit tree
221 TTree *treeH = fLoader->TreeH();
224 branch = treeH->GetBranch(branchname);
225 if (branch) branch->SetAddress(&fHits);
230 //_____________________________________________________________________________
231 void AliAD::MakeBranch(Option_t* opt)
233 const char* oH = strstr(opt,"H");
234 if (fLoader->TreeH() && oH && (fHits==0x0))
236 fHits = new TClonesArray("AliADhit",1000);
239 AliDetector::MakeBranch(opt);
241 //_____________________________________________________________________________
242 AliLoader* AliAD::MakeLoader(const char* topfoldername)
245 AliDebug(1,Form("Creating AliADLoader, Top folder is %s ",topfoldername));
246 fLoader = new AliADLoader(GetName(),topfoldername);
250 //_____________________________________________________________________________
251 AliDigitizer* AliAD::CreateDigitizer(AliDigitizationInput* digInput) const
254 // Creates a digitizer for AD
256 return new AliADDigitizer(digInput);
259 //_____________________________________________________________________________
260 void AliAD::Hits2Digits(){
262 // Converts hits to digits
264 // Creates the AD digitizer
265 AliADDigitizer* dig = new AliADDigitizer(this,AliADDigitizer::kHits2Digits);
267 // Creates the digits
270 // deletes the digitizer
274 //_____________________________________________________________________________
275 void AliAD::Hits2SDigits(){
277 // Converts hits to summable digits
279 // Creates the AD digitizer
280 AliADDigitizer* dig = new AliADDigitizer(this,AliADDigitizer::kHits2SDigits);
282 // Creates the sdigits
285 // deletes the digitizer
290 //_____________________________________________________________________________
291 void AliAD::Digits2Raw()
294 // Converts digits of the current event to raw data
296 AliAD *fAD = (AliAD*)gAlice->GetDetector("AD");
297 fLoader->LoadDigits();
298 TTree* digits = fLoader->TreeD();
300 Error("Digits2Raw", "no digits tree");
303 TClonesArray * ADdigits = new TClonesArray("AliADdigit",1000);
304 fAD->SetTreeAddress();
305 digits->GetBranch("ADDigit")->SetAddress(&ADdigits);
307 const char *fileName = AliDAQ::DdlFileName("AD",0);
308 AliADBuffer* buffer = new AliADBuffer(fileName);
309 //AliADBuffer* buffer = new AliADBuffer("AD_0.ddl");
311 // Get Trigger information first
312 // Read trigger inputs from trigger-detector object
313 AliDataLoader * dataLoader = fLoader->GetDigitsDataLoader();
314 if( !dataLoader->IsFileOpen() )
315 dataLoader->OpenFile( "READ" );
316 AliTriggerDetector* trgdet = (AliTriggerDetector*)dataLoader->GetDirectory()->Get( "Trigger" );
317 UInt_t triggerInfo = 0;
319 triggerInfo = trgdet->GetMask() & 0xffff;
322 AliError(Form("There is no trigger object for %s",fLoader->GetName()));
325 buffer->WriteTriggerInfo((UInt_t)triggerInfo);
326 buffer->WriteTriggerScalers();
327 buffer->WriteBunchNumbers();
329 // Now retrieve the channel information: charge smaples + time and
330 // dump it into ADC and Time arrays
331 Int_t nEntries = Int_t(digits->GetEntries());
332 Short_t aADC[16][kNClocks];
335 Bool_t aIntegrator[16];
337 for (Int_t i = 0; i < nEntries; i++) {
340 Int_t ndig = ADdigits->GetEntriesFast();
342 if(ndig == 0) continue;
343 for(Int_t k=0; k<ndig; k++){
344 AliADdigit* fADDigit = (AliADdigit*) ADdigits->At(k);
346 Int_t iChannel = fADDigit->PMNumber();
348 for(Int_t iClock = 0; iClock < kNClocks; ++iClock) aADC[iChannel][iClock] = fADDigit->ChargeADC(iClock);
349 aTime[iChannel] = fADDigit->Time(); //divide by resolution
350 aWidth[iChannel] = fADDigit->Width(); //divide by resolution
351 aIntegrator[iChannel]= fADDigit->Integrator();
353 //AliDebug(1,Form("DDL: %s\tdigit number: %d\tPM number: %d\tADC: %d\tTime: %f",
354 //fileName,k,fADDigit->PMNumber(),aADC[iChannel][AliADdigit::kNClocks/2],aTime[iChannel]));
359 for (Int_t iCIU = 0; iCIU < kNCIUBoards; iCIU++) {
360 // decoding of one Channel Interface Unit numbered iCIU - there are 8 channels per CIU (and 2 CIUs) :
361 for(Int_t iChannel_Offset = iCIU*8; iChannel_Offset < (iCIU*8)+8; iChannel_Offset=iChannel_Offset+4) {
362 for(Int_t iChannel = iChannel_Offset; iChannel < iChannel_Offset+4; iChannel++) {
363 buffer->WriteChannel(iChannel, aADC[iChannel], aIntegrator[iChannel]);
365 buffer->WriteBeamFlags();
366 buffer->WriteMBInfo();
367 buffer->WriteMBFlags();
368 buffer->WriteBeamScalers();
371 for(Int_t iChannel = iCIU*8 + 7; iChannel >= iCIU*8; iChannel--) {
372 buffer->WriteTiming(aTime[iChannel], aWidth[iChannel]);
373 } // End of decoding of one CIU card
374 } // end of decoding the eight CIUs
378 fLoader->UnloadDigits();
382 //_____________________________________________________________________________
383 Bool_t AliAD::Raw2SDigits(AliRawReader* /*rawReader*/)
385 // reads raw data to produce digits
386 // for AD not implemented yet (needs detailed hardware info)