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 //_________________________________________________________________________
19 // Base Class for EMCAL description:
20 // This class contains material definitions
21 // for the EMCAL - It does not place the detector in Alice
22 //*-- Author: Yves Schutz (SUBATECH)
24 //*-- Additional Contributions: Sahal Yacoob (LBNL/UCT)
26 //////////////////////////////////////////////////////////////////////////////
28 // --- ROOT system ---
32 #include <TVirtualMC.h>
34 // --- Standard library ---
36 // --- AliRoot header files ---
39 #include "AliEMCALGetter.h"
41 #include "AliEMCALSDigitizer.h"
42 #include "AliEMCALDigitizer.h"
43 #include "AliAltroBuffer.h"
46 //____________________________________________________________________________
47 AliEMCAL::AliEMCAL():AliDetector()
52 fRan = new TRandom(123456) ;
55 //____________________________________________________________________________
56 AliEMCAL::AliEMCAL(const char* name, const char* title): AliDetector(name,title)
58 // ctor : title is used to identify the layout
60 fRan = new TRandom(123456) ;
63 //____________________________________________________________________________
69 //____________________________________________________________________________
70 void AliEMCAL::Copy(AliEMCAL & emcal)
72 TObject::Copy(emcal) ;
75 //____________________________________________________________________________
76 AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager) const
78 return new AliEMCALDigitizer(manager);
81 //____________________________________________________________________________
82 void AliEMCAL::CreateMaterials()
84 // Definitions of materials to build EMCAL and associated tracking media.
85 // media number in idtmed are 1599 to 1698.
88 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
89 Float_t zAir[4]={6.,7.,8.,18.};
90 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
91 Float_t dAir = 1.20479E-3;
92 AliMixture(0, "Air$", aAir, zAir, dAir, 4, wAir) ;
95 AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
98 // --- The polysterene scintillator (CH) ---
99 Float_t aP[2] = {12.011, 1.00794} ;
100 Float_t zP[2] = {6.0, 1.0} ;
101 Float_t wP[2] = {1.0, 1.0} ;
104 AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
107 AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
108 // --- Absorption length is ignored ^
110 // DEFINITION OF THE TRACKING MEDIA
112 // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100]
113 Int_t * idtmed = fIdtmed->GetArray() - 1599 ;
114 Int_t isxfld = gAlice->Field()->Integ() ;
115 Float_t sxmgmx = gAlice->Field()->Max() ;
117 // Air -> idtmed[1599]
118 AliMedium(0, "Air $", 0, 0,
119 isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
121 // The Lead -> idtmed[1600]
123 AliMedium(1, "Lead $", 1, 0,
124 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
126 // The scintillator of the CPV made of Polystyrene scintillator -> idtmed[1601]
127 AliMedium(2, "CPV scint. $", 2, 1,
128 isxfld, sxmgmx, 10.0, 0.001, 0.1, 0.001, 0.001, 0, 0) ;
130 // Various Aluminium parts made of Al -> idtmed[1602]
131 AliMedium(3, "Al parts $", 3, 0,
132 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
135 // --- Set decent energy thresholds for gamma and electron tracking
137 // Tracking threshold for photons and electrons in Lead
138 gMC->Gstpar(idtmed[1600],"CUTGAM",0.00008) ;
139 gMC->Gstpar(idtmed[1600],"CUTELE",0.001) ;
140 gMC->Gstpar(idtmed[1600],"BCUTE",0.0001) ;
142 // --- Generate explicitly delta rays in Lead ---
143 gMC->Gstpar(idtmed[1600], "LOSS",3.) ;
144 gMC->Gstpar(idtmed[1600], "DRAY",1.) ;
145 gMC->Gstpar(idtmed[1600], "DCUTE",0.00001) ;
146 gMC->Gstpar(idtmed[1600], "DCUTM",0.00001) ;
148 // --- in aluminium parts ---
149 gMC->Gstpar(idtmed[1602], "LOSS",3.) ;
150 gMC->Gstpar(idtmed[1602], "DRAY",1.) ;
151 gMC->Gstpar(idtmed[1602], "DCUTE",0.00001) ;
152 gMC->Gstpar(idtmed[1602], "DCUTM",0.00001) ;
154 // --- and finally thresholds for photons and electrons in the scintillator ---
155 gMC->Gstpar(idtmed[1601],"CUTGAM",0.00008) ;
156 gMC->Gstpar(idtmed[1601],"CUTELE",0.001) ;
157 gMC->Gstpar(idtmed[1601],"BCUTE",0.0001) ;
159 //set constants for Birk's Law implentation
162 fBirkC2 = 9.6e-6/(dP * dP);
167 //____________________________________________________________________________
168 void AliEMCAL::Digits2Raw()
170 // convert digits of the current event to raw data
173 AliEMCALGetter * gime = AliEMCALGetter::Instance(AliRunLoader::GetGAliceName()) ;
175 Error("Digits2Raw", "EMCAL Getter not instantiated") ;
178 gime->Event(gime->EventNumber(), "D") ;
179 TClonesArray* digits = gime->Digits() ;
182 Error("Digits2Raw", "no digits found !");
187 AliEMCALGeometry* geom = gime->EMCALGeometry();
189 Error("Digits2Raw", "no geometry found !");
193 // some digitization constants
194 const Int_t kDDLOffset = 0x800;
195 const Double_t kTimeMax = 1.28E-5;
196 const Int_t kTimeBins = 256;
197 const Double_t kTimePeak = 2.0E-6;
198 const Double_t kTimeRes = 1.5E-6;
199 const Int_t kThreshold = 3;
200 const Int_t kHighGainFactor = 40;
201 const Int_t kHighGainOffset = 0x200;
202 // PHOS has 4 DDL per module; I assume therefore that kChannelsperDDL=896+1 EMCAL channel go to one DDL
203 const Int_t kChannelsperDDL = 897 ;
205 AliAltroBuffer* buffer = NULL;
207 Int_t adcValuesLow[kTimeBins];
208 Int_t adcValuesHigh[kTimeBins];
210 // loop over digits (assume ordered digits)
211 for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
212 AliEMCALDigit* digit = gime->Digit(iDigit);
213 if (digit->GetAmp() < kThreshold)
215 Int_t iDDL = digit->GetId() / kChannelsperDDL ;
216 // for each DDL id is numbered from 1 to kChannelsperDDL -1
217 Int_t idDDL = digit->GetId() - iDDL * ( kChannelsperDDL - 1 ) ;
219 if (iDDL != prevDDL) {
220 // write real header and close previous file
223 buffer->WriteDataHeader(kFALSE, kFALSE);
227 // open new file and write dummy header
228 TString fileName("EMCAL_") ;
229 fileName += (iDDL + kDDLOffset) ;
231 buffer = new AliAltroBuffer(fileName.Data(), 1);
232 buffer->WriteDataHeader(kTRUE, kFALSE); //Dummy;
237 // out of time range signal (?)
238 if (digit->GetTime() > kTimeMax) {
239 buffer->FillBuffer(digit->GetAmp());
240 buffer->FillBuffer(kTimeBins); // time bin
241 buffer->FillBuffer(3); // bunch length
242 buffer->WriteTrailer(3, idDDL, 0, 0); // trailer
244 // simulate linear rise and gaussian decay of signal
246 Bool_t highGain = kFALSE;
248 // fill time bin values :
249 // 1. the signal starts at the time given by the digit
250 // 2. the rise is linear and the maximum is reached kTimePeak after start
251 // 3. the decay is gaussian with a sigma of kTimeRes
252 // 4. the signal is binned into kTimeBins bins
253 for (Int_t iTime = 0; iTime < kTimeBins; iTime++) {
254 Double_t time = iTime * kTimeMax/kTimeBins;
256 if (time < digit->GetTime() + kTimePeak) { // signal is rising
257 signal = static_cast<Int_t>((fRan->Rndm() + digit->GetAmp()) *
258 (time - digit->GetTime() / kTimePeak) + 0.5);
259 } else { // signal is decaying
260 signal = static_cast<Int_t>((fRan->Rndm() + digit->GetAmp()) *
261 TMath::Gaus(time, digit->GetTime() + kTimePeak, kTimeRes) + 0.5);
265 adcValuesLow[iTime] = signal;
266 if (signal > 0x3FF) // larger than 10 bits
267 adcValuesLow[iTime] = 0x3FF;
268 adcValuesHigh[iTime] = static_cast<Int_t>(0.5 + (signal / kHighGainFactor));
269 if (adcValuesHigh[iTime] > 0)
273 // write low and eventually high gain channel
274 buffer->WriteChannel(idDDL, 0, 0,
275 kTimeBins, adcValuesLow, kThreshold);
277 buffer->WriteChannel(idDDL, 0, kHighGainOffset,
278 kTimeBins, adcValuesHigh, 1);
283 // write real header and close last file
286 buffer->WriteDataHeader(kFALSE, kFALSE);
290 gime->EmcalLoader()->UnloadDigits();
293 //____________________________________________________________________________
294 void AliEMCAL::Hits2SDigits()
296 // create summable digits
298 AliEMCALSDigitizer* emcalDigitizer =
299 new AliEMCALSDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ;
300 emcalDigitizer->SetEventRange(0, -1) ; // do all the events
301 emcalDigitizer->ExecuteTask() ;
304 //____________________________________________________________________________
305 AliLoader* AliEMCAL::MakeLoader(const char* topfoldername)
307 //different behaviour than standard (singleton getter)
308 // --> to be discussed and made eventually coherent
309 fLoader = new AliEMCALLoader(GetName(),topfoldername);
313 //____________________________________________________________________________
314 void AliEMCAL::SetTreeAddress()
316 // Linking Hits in Tree to Hits array
319 sprintf(branchname,"%s",GetName());
321 // Branch address for hit tree
322 TTree *treeH = TreeH();
324 branch = treeH->GetBranch(branchname);
328 fHits= new TClonesArray("AliEMCALHit",1000);
329 branch->SetAddress(&fHits);
333 Warning("SetTreeAddress","<%s> Failed",GetName());