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