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>
37 // --- Standard library ---
39 // --- AliRoot header files ---
42 #include "AliEMCALGetter.h"
44 #include "AliEMCALSDigitizer.h"
45 #include "AliEMCALDigitizer.h"
46 #include "AliAltroBuffer.h"
49 //____________________________________________________________________________
50 AliEMCAL::AliEMCAL():AliDetector()
56 //____________________________________________________________________________
57 AliEMCAL::AliEMCAL(const char* name, const char* title): AliDetector(name,title)
59 // ctor : title is used to identify the layout
65 fHighGainOffset = 0x200 ;
68 //____________________________________________________________________________
74 //____________________________________________________________________________
75 void AliEMCAL::Copy(AliEMCAL & emcal)
77 TObject::Copy(emcal) ;
80 //____________________________________________________________________________
81 AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager) const
83 return new AliEMCALDigitizer(manager);
86 //____________________________________________________________________________
87 void AliEMCAL::CreateMaterials()
89 // Definitions of materials to build EMCAL and associated tracking media.
90 // media number in idtmed are 1599 to 1698.
93 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
94 Float_t zAir[4]={6.,7.,8.,18.};
95 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
96 Float_t dAir = 1.20479E-3;
97 AliMixture(0, "Air$", aAir, zAir, dAir, 4, wAir) ;
100 AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
103 // --- The polysterene scintillator (CH) ---
104 Float_t aP[2] = {12.011, 1.00794} ;
105 Float_t zP[2] = {6.0, 1.0} ;
106 Float_t wP[2] = {1.0, 1.0} ;
109 AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
112 AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
113 // --- Absorption length is ignored ^
115 // DEFINITION OF THE TRACKING MEDIA
117 // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100]
118 Int_t * idtmed = fIdtmed->GetArray() - 1599 ;
119 Int_t isxfld = gAlice->Field()->Integ() ;
120 Float_t sxmgmx = gAlice->Field()->Max() ;
122 // Air -> idtmed[1599]
123 AliMedium(0, "Air $", 0, 0,
124 isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
126 // The Lead -> idtmed[1600]
128 AliMedium(1, "Lead $", 1, 0,
129 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
131 // The scintillator of the CPV made of Polystyrene scintillator -> idtmed[1601]
132 AliMedium(2, "CPV scint. $", 2, 1,
133 isxfld, sxmgmx, 10.0, 0.001, 0.1, 0.001, 0.001, 0, 0) ;
135 // Various Aluminium parts made of Al -> idtmed[1602]
136 AliMedium(3, "Al parts $", 3, 0,
137 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
140 // --- Set decent energy thresholds for gamma and electron tracking
142 // Tracking threshold for photons and electrons in Lead
143 gMC->Gstpar(idtmed[1600],"CUTGAM",0.00008) ;
144 gMC->Gstpar(idtmed[1600],"CUTELE",0.001) ;
145 gMC->Gstpar(idtmed[1600],"BCUTE",0.0001) ;
147 // --- Generate explicitly delta rays in Lead ---
148 gMC->Gstpar(idtmed[1600], "LOSS",3.) ;
149 gMC->Gstpar(idtmed[1600], "DRAY",1.) ;
150 gMC->Gstpar(idtmed[1600], "DCUTE",0.00001) ;
151 gMC->Gstpar(idtmed[1600], "DCUTM",0.00001) ;
153 // --- in aluminium parts ---
154 gMC->Gstpar(idtmed[1602], "LOSS",3.) ;
155 gMC->Gstpar(idtmed[1602], "DRAY",1.) ;
156 gMC->Gstpar(idtmed[1602], "DCUTE",0.00001) ;
157 gMC->Gstpar(idtmed[1602], "DCUTM",0.00001) ;
159 // --- and finally thresholds for photons and electrons in the scintillator ---
160 gMC->Gstpar(idtmed[1601],"CUTGAM",0.00008) ;
161 gMC->Gstpar(idtmed[1601],"CUTELE",0.001) ;
162 gMC->Gstpar(idtmed[1601],"BCUTE",0.0001) ;
164 //set constants for Birk's Law implentation
167 fBirkC2 = 9.6e-6/(dP * dP);
172 //____________________________________________________________________________
173 void AliEMCAL::Digits2Raw()
175 // convert digits of the current event to raw data
178 AliEMCALGetter * gime = AliEMCALGetter::Instance(AliRunLoader::GetGAliceName()) ;
180 Error("Digits2Raw", "EMCAL Getter not instantiated") ;
183 gime->Event(gime->EventNumber(), "D") ;
184 TClonesArray* digits = gime->Digits() ;
187 Error("Digits2Raw", "no digits found !");
192 AliEMCALGeometry* geom = gime->EMCALGeometry();
194 Error("Digits2Raw", "no geometry found !");
198 // some digitization constants
199 const Int_t kDDLOffset = 0x800;
200 const Int_t kThreshold = 3;
201 const Int_t kChannelsperDDL = 897 ;
203 AliAltroBuffer* buffer = NULL;
205 Int_t adcValuesLow[fkTimeBins];
206 Int_t adcValuesHigh[fkTimeBins];
208 // loop over digits (assume ordered digits)
209 for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
210 AliEMCALDigit* digit = gime->Digit(iDigit);
211 if (digit->GetAmp() < kThreshold)
213 Int_t iDDL = digit->GetId() / kChannelsperDDL ;
214 // for each DDL id is numbered from 1 to kChannelsperDDL -1
215 Int_t idDDL = digit->GetId() - iDDL * ( kChannelsperDDL - 1 ) ;
217 if (iDDL != prevDDL) {
218 // write real header and close previous file
221 buffer->WriteDataHeader(kFALSE, kFALSE);
225 // open new file and write dummy header
226 TString fileName("EMCAL_") ;
227 fileName += (iDDL + kDDLOffset) ;
229 buffer = new AliAltroBuffer(fileName.Data(), 1);
230 buffer->WriteDataHeader(kTRUE, kFALSE); //Dummy;
235 // out of time range signal (?)
236 if (digit->GetTimeR() > fTimeMax) {
237 buffer->FillBuffer(digit->GetAmp());
238 buffer->FillBuffer(fkTimeBins); // time bin
239 buffer->FillBuffer(3); // bunch length
240 buffer->WriteTrailer(3, idDDL, 0, 0); // trailer
242 // simulate linear rise and gaussian decay of signal
244 Bool_t highGain = kFALSE;
246 // write low and eventually high gain channel
247 buffer->WriteChannel(iDDL, 0, 0,
248 fkTimeBins, adcValuesLow, kThreshold);
250 buffer->WriteChannel(iDDL, 0, fHighGainOffset,
251 fkTimeBins, adcValuesHigh, 1);
255 // write real header and close last file
258 buffer->WriteDataHeader(kFALSE, kFALSE);
261 gime->EmcalLoader()->UnloadDigits();
264 //____________________________________________________________________________
265 void AliEMCAL::Hits2SDigits()
267 // create summable digits
269 AliEMCALSDigitizer* emcalDigitizer =
270 new AliEMCALSDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ;
271 emcalDigitizer->SetEventRange(0, -1) ; // do all the events
272 emcalDigitizer->ExecuteTask() ;
275 //____________________________________________________________________________
276 AliLoader* AliEMCAL::MakeLoader(const char* topfoldername)
278 //different behaviour than standard (singleton getter)
279 // --> to be discussed and made eventually coherent
280 fLoader = new AliEMCALLoader(GetName(),topfoldername);
284 //__________________________________________________________________
285 Double_t AliEMCAL::RawResponseFunction(Double_t *x, Double_t *par)
287 // Shape of the electronics raw reponse:
288 // 1. the signal rises linearly from par[4] to par[1] to reach the maximu par[3]
289 // 2. the signal decays with a gaussian shape for par[4]+par[1] with a sigma of par[2]
293 Double_t signal = 0. ;
295 if (xx < par[4] + par[1]) // signal is rising
296 signal = (gRandom->Rndm() + par[3]) * (xx - par[4]) / (par[1] - par[4]) ;
297 else // signal is decaying
298 signal = (gRandom->Rndm() + par[3]) * TMath::Gaus(xx, par[4] + par[1], par[2]) ;
300 return signal < 0. ? 0. : signal ;
303 //__________________________________________________________________
304 Bool_t AliEMCAL::RawSampledResponse(const Float_t dtime, const Int_t damp, Int_t * adcH, Int_t * adcL) const
306 // for a start time dtime and an amplitude damp given by digit,
307 // calculates the raw sampled response
309 const Int_t kRawSignalOverflow = 0x3FF ;
310 Bool_t highGain = kFALSE ;
312 TF1 f1("signal", RawResponseFunction, 0, fkTimeBins, 5);
314 f1.SetParNames("Time Max", "Peaking time", "Decay width", "Amp max", "Start time") ;
315 f1.SetParameter(0, fTimeMax) ;
316 f1.SetParameter(1, fTimePeak) ;
317 f1.SetParameter(2, fTimeRes) ;
318 f1.SetParameter(3, damp) ;
319 f1.SetParameter(4, dtime) ;
321 for (Int_t iTime = 0; iTime < fkTimeBins; iTime++) {
322 Double_t time = iTime * fTimeMax/fkTimeBins;
323 Double_t signal = f1.Eval(time) ;
324 adcL[iTime] = static_cast<Int_t>(signal + 0.5) ;
325 if ( adcL[iTime] > kRawSignalOverflow) // larger than 10 bits
326 adcL[iTime] = kRawSignalOverflow ;
327 adcH[iTime] = static_cast<Int_t>(0.5 + (signal / fHighGainFactor)) ;
334 //____________________________________________________________________________
335 void AliEMCAL::SetTreeAddress()
337 // Linking Hits in Tree to Hits array
340 sprintf(branchname,"%s",GetName());
342 // Branch address for hit tree
343 TTree *treeH = TreeH();
345 branch = treeH->GetBranch(branchname);
349 fHits= new TClonesArray("AliEMCALHit",1000);
350 branch->SetAddress(&fHits);
354 Warning("SetTreeAddress","<%s> Failed",GetName());