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