switch on effC++ compilation flags by default (--enable-strict option)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCAL.cxx
CommitLineData
2012850d 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
16/* $Id$ */
4884333f 17/* History of cvs commits:
18 *
19 * $Log$
3294dade 20 * Revision 1.53.10.1 2007/12/06 10:29:59 hristov
21 * Bug fix: using the mapping from CDB
22 *
23 * Revision 1.53 2007/03/17 19:56:38 mvl
24 * Moved signal shape routines from AliEMCAL to separate class AliEMCALRawUtils to streamline raw data reconstruction code.
25 *
ee299369 26 * Revision 1.52 2007/03/10 22:19:01 pavlinov
27 * move one varibels from AliEMCALv2 to AliEMCAL
28 *
23ef18ac 29 * Revision 1.51 2007/02/24 20:42:35 pavlinov
30 * fixed error of Geant3 parameters initialisation
31 *
91e5f344 32 * Revision 1.50 2007/02/05 10:43:25 hristov
33 * Changes for correct initialization of Geant4 (Mihaela)
34 *
7235aed2 35 * Revision 1.49 2007/01/22 17:29:12 pavlinov
36 * EMCAL geometry can be created independently form anything now
37 *
89557f6d 38 * Revision 1.48 2006/12/19 02:34:13 pavlinov
39 * clean up the EMCAL name scheme : super module -> module -> tower (or cell)
40 *
2bb3725c 41 * Revision 1.47 2006/12/05 17:12:03 gustavo
42 * Updated AliEMCAL::Digits2Raw, reads first provisional RCU mapping files to make Raw data with new AliCaloAltroMapping and AliCaloRawStream
43 *
4884333f 44 *
45 */
2012850d 46//_________________________________________________________________________
47// Base Class for EMCAL description:
ffa6d63b 48// This class contains material definitions
49// for the EMCAL - It does not place the detector in Alice
2012850d 50//*-- Author: Yves Schutz (SUBATECH)
b13bbe81 51//
52//*-- Additional Contributions: Sahal Yacoob (LBNL/UCT)
53//
2012850d 54//////////////////////////////////////////////////////////////////////////////
55
2012850d 56// --- ROOT system ---
b13bbe81 57class TFile;
88cb7938 58#include <TFolder.h>
88cb7938 59#include <TTree.h>
60#include <TVirtualMC.h>
046ae904 61#include <TH1F.h>
046ae904 62#include <TRandom.h>
2d5d9e60 63#include <TGraph.h>
2012850d 64
05a92d59 65// --- Standard library ---
2012850d 66
05a92d59 67// --- AliRoot header files ---
2012850d 68#include "AliMagF.h"
88cb7938 69#include "AliEMCAL.h"
85a5290f 70#include "AliRun.h"
5dee926e 71#include "AliEMCALLoader.h"
85a5290f 72#include "AliEMCALSDigitizer.h"
73#include "AliEMCALDigitizer.h"
5dee926e 74#include "AliEMCALDigit.h"
ee299369 75#include "AliEMCALRawUtils.h"
3294dade 76#include "AliCDBManager.h"
77#include "AliCDBEntry.h"
78
2012850d 79
80ClassImp(AliEMCAL)
4884333f 81
2012850d 82//____________________________________________________________________________
18a21c7c 83AliEMCAL::AliEMCAL()
84 : AliDetector(),
85 fBirkC0(0),
86 fBirkC1(0.),
87 fBirkC2(0.),
23ef18ac 88 fGeometry(0)
2012850d 89{
05a92d59 90 // Default ctor
046ae904 91 fName = "EMCAL" ;
7235aed2 92 InitConstants();
23ef18ac 93 // Should call AliEMCALGeometry::GetInstance(EMCAL->GetTitle(),"") for getting EMCAL geometry
2012850d 94}
05a92d59 95
2012850d 96//____________________________________________________________________________
18a21c7c 97AliEMCAL::AliEMCAL(const char* name, const char* title)
98 : AliDetector(name,title),
99 fBirkC0(0),
100 fBirkC1(0.),
101 fBirkC2(0.),
23ef18ac 102 fGeometry(0)
05a92d59 103{
104 // ctor : title is used to identify the layout
7235aed2 105 InitConstants();
0a4cb131 106}
107
108//____________________________________________________________________________
05a92d59 109AliEMCAL::~AliEMCAL()
110{
14ce0a6e 111 //dtor
2012850d 112}
113
114//____________________________________________________________________________
7235aed2 115void AliEMCAL::InitConstants()
0a4cb131 116{
117 //initialize EMCAL values
118 fBirkC0 = 1;
119 fBirkC1 = 0.013/1.032;
120 fBirkC2 = 9.6e-6/(1.032 * 1.032);
ee299369 121 }
0a4cb131 122
123//____________________________________________________________________________
91e5f344 124void AliEMCAL::DefineMediumParameters()
05a92d59 125{
91e5f344 126 //
127 // EMCAL cuts (Geant3)
128 //
2012850d 129 Int_t * idtmed = fIdtmed->GetArray() - 1599 ;
b13bbe81 130// --- Set decent energy thresholds for gamma and electron tracking
2012850d 131
132 // Tracking threshold for photons and electrons in Lead
905263da 133 Float_t cutgam=10.e-5; // 100 kev;
134 Float_t cutele=10.e-5; // 100 kev;
135 TString ntmp(GetTitle());
136 ntmp.ToUpper();
137 if(ntmp.Contains("10KEV")) {
138 cutele = cutgam = 1.e-5;
139 } else if(ntmp.Contains("50KEV")) {
140 cutele = cutgam = 5.e-5;
141 } else if(ntmp.Contains("100KEV")) {
142 cutele = cutgam = 1.e-4;
143 } else if(ntmp.Contains("200KEV")) {
144 cutele = cutgam = 2.e-4;
145 } else if(ntmp.Contains("500KEV")) {
146 cutele = cutgam = 5.e-4;
147 }
2012850d 148
905263da 149 gMC->Gstpar(idtmed[1600],"CUTGAM", cutgam);
150 gMC->Gstpar(idtmed[1600],"CUTELE", cutele); // 1MEV -> 0.1MEV; 15-aug-05
151 gMC->Gstpar(idtmed[1600],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
152 gMC->Gstpar(idtmed[1600],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
2012850d 153 // --- Generate explicitly delta rays in Lead ---
89557f6d 154 gMC->Gstpar(idtmed[1600], "LOSS", 3) ;
155 gMC->Gstpar(idtmed[1600], "DRAY", 1) ;
905263da 156 gMC->Gstpar(idtmed[1600], "DCUTE", cutele) ;
157 gMC->Gstpar(idtmed[1600], "DCUTM", cutele) ;
05a92d59 158
a63e0d5e 159// --- in aluminium parts ---
905263da 160 gMC->Gstpar(idtmed[1602],"CUTGAM", cutgam) ;
161 gMC->Gstpar(idtmed[1602],"CUTELE", cutele) ;
162 gMC->Gstpar(idtmed[1602],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
163 gMC->Gstpar(idtmed[1602],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
b13bbe81 164 gMC->Gstpar(idtmed[1602], "LOSS",3.) ;
165 gMC->Gstpar(idtmed[1602], "DRAY",1.) ;
905263da 166 gMC->Gstpar(idtmed[1602], "DCUTE", cutele) ;
167 gMC->Gstpar(idtmed[1602], "DCUTM", cutele) ;
b13bbe81 168
ffa6d63b 169// --- and finally thresholds for photons and electrons in the scintillator ---
905263da 170 gMC->Gstpar(idtmed[1601],"CUTGAM", cutgam) ;
171 gMC->Gstpar(idtmed[1601],"CUTELE", cutele) ;// 1MEV -> 0.1MEV; 15-aug-05
172 gMC->Gstpar(idtmed[1601],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
173 gMC->Gstpar(idtmed[1601],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
89557f6d 174 gMC->Gstpar(idtmed[1601], "LOSS",3) ; // generate delta rays
175 gMC->Gstpar(idtmed[1601], "DRAY",1) ;
905263da 176 gMC->Gstpar(idtmed[1601], "DCUTE", cutele) ;
177 gMC->Gstpar(idtmed[1601], "DCUTM", cutele) ;
178
179 // S steel -
180 gMC->Gstpar(idtmed[1603],"CUTGAM", cutgam);
181 gMC->Gstpar(idtmed[1603],"CUTELE", cutele);
182 gMC->Gstpar(idtmed[1603],"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
183 gMC->Gstpar(idtmed[1603],"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
184 // --- Generate explicitly delta rays
89557f6d 185 gMC->Gstpar(idtmed[1603], "LOSS",3);
186 gMC->Gstpar(idtmed[1603], "DRAY",1);
905263da 187 gMC->Gstpar(idtmed[1603], "DCUTE", cutele) ;
188 gMC->Gstpar(idtmed[1603], "DCUTM", cutele) ;
1963b290 189
7235aed2 190 AliEMCALGeometry* geom = GetGeometry();
89557f6d 191 if(geom->GetILOSS()>=0) {
192 for(int i=1600; i<=1603; i++) gMC->Gstpar(idtmed[i], "LOSS", geom->GetILOSS()) ;
193 }
194 if(geom->GetIHADR()>=0) {
195 for(int i=1600; i<=1603; i++) gMC->Gstpar(idtmed[i], "HADR", geom->GetIHADR()) ;
196 }
7235aed2 197}
198
199//____________________________________________________________________________
200AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager) const
201{
202 //create and return the digitizer
203 return new AliEMCALDigitizer(manager);
204}
205
206//____________________________________________________________________________
207void AliEMCAL::CreateMaterials()
208{
209 // Definitions of materials to build EMCAL and associated tracking media.
210 // media number in idtmed are 1599 to 1698.
211 // --- Air ---
212 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
213 Float_t zAir[4]={6.,7.,8.,18.};
214 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
215 Float_t dAir = 1.20479E-3;
216 AliMixture(0, "Air$", aAir, zAir, dAir, 4, wAir) ;
217
218 // --- Lead ---
219 AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
220
221
222 // --- The polysterene scintillator (CH) ---
223 Float_t aP[2] = {12.011, 1.00794} ;
224 Float_t zP[2] = {6.0, 1.0} ;
225 Float_t wP[2] = {1.0, 1.0} ;
226 Float_t dP = 1.032 ;
227
228 AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
229
230 // --- Aluminium ---
231 AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
232 // --- Absorption length is ignored ^
233
234 // 25-aug-04 by PAI - see PMD/AliPMDv0.cxx for STEEL definition
235 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
236 Float_t zsteel[4] = { 26.,24.,28.,14. };
237 Float_t wsteel[4] = { .715,.18,.1,.005 };
238 AliMixture(4, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
239
240 // DEFINITION OF THE TRACKING MEDIA
241
242 // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100]
243 Int_t isxfld = gAlice->Field()->Integ() ;
244 Float_t sxmgmx = gAlice->Field()->Max() ;
245
246 // Air -> idtmed[1599]
247 AliMedium(0, "Air$", 0, 0,
248 isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
249
250 // The Lead -> idtmed[1600]
251
252 AliMedium(1, "Lead$", 1, 0,
253 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
254
255 // The scintillator of the CPV made of Polystyrene scintillator -> idtmed[1601]
ee299369 256 float deemax = 0.1; // maximum fractional energy loss in one step (0 < DEEMAX < deemax )
7235aed2 257 AliMedium(2, "Scintillator$", 2, 1,
258 isxfld, sxmgmx, 10.0, 0.001, deemax, 0.001, 0.001, 0, 0) ;
259
260 // Various Aluminium parts made of Al -> idtmed[1602]
261 AliMedium(3, "Al$", 3, 0,
262 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
263
264 // 25-aug-04 by PAI : see PMD/AliPMDv0.cxx for STEEL definition -> idtmed[1603]
265 AliMedium(4, "S steel$", 4, 0,
266 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
267
89557f6d 268
ab37d09c 269 //set constants for Birk's Law implentation
270 fBirkC0 = 1;
271 fBirkC1 = 0.013/dP;
272 fBirkC2 = 9.6e-6/(dP * dP);
273
91e5f344 274 // Call just in case of Geant3; What to do in case of Geant4 ?
275 if(gMC->InheritsFrom("TGeant3")) DefineMediumParameters(); // Feb 20, 2007
2012850d 276}
f51151a0 277//____________________________________________________________________________
ee299369 278void AliEMCAL::Digits2Raw() {
279 static AliEMCALRawUtils rawUtil;
3294dade 280 //Get Mapping RCU files from the AliEMCALRecParam
281 AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/Mapping");
282 const TObjArray* maps = 0x0;
283 if(entry)
284 maps = (TObjArray*)entry->GetObject();
285
286 if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
287
288 AliAltroMapping * mapping[2] ; // For the moment only 2
289 for(Int_t i = 0; i < 2; i++) {
290 mapping[i] = (AliAltroMapping*)maps->At(i);
291 }
292 rawUtil.Digits2Raw(mapping);
2d5d9e60 293}
2d5d9e60 294//____________________________________________________________________________
8367ce9a 295void AliEMCAL::Hits2SDigits()
296{
297// create summable digits
298
ddca522a 299 GetGeometry();
4d33c797 300 AliEMCALSDigitizer emcalDigitizer(fLoader->GetRunLoader()->GetFileName().Data()) ;
301 emcalDigitizer.SetEventRange(0, -1) ; // do all the events
302 emcalDigitizer.ExecuteTask() ;
da480a28 303}
304
305//____________________________________________________________________________
5dee926e 306
8367ce9a 307AliLoader* AliEMCAL::MakeLoader(const char* topfoldername)
308{
309//different behaviour than standard (singleton getter)
310// --> to be discussed and made eventually coherent
311 fLoader = new AliEMCALLoader(GetName(),topfoldername);
312 return fLoader;
313}