]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCAL.cxx
12051e07abc88bc5944808c49bf60660a468c81d
[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
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) 
23 //
24 //*-- Additional Contributions: Sahal Yacoob (LBNL/UCT)
25 //
26 //////////////////////////////////////////////////////////////////////////////
27
28 // --- ROOT system ---
29 class TFile;
30 #include <TFolder.h> 
31 #include <TROOT.h>
32 #include <TTree.h>
33 #include <TVirtualMC.h> 
34
35 // --- Standard library ---
36 #include <Rstrstream.h>
37
38 // --- AliRoot header files ---
39 #include "AliMagF.h"
40 #include "AliEMCAL.h"
41 #include "AliEMCALGeometry.h"
42 #include "AliEMCALLoader.h"
43 //#include "AliEMCALQAChecker.h" 
44 #include "AliRun.h"
45
46 ClassImp(AliEMCAL)
47 //____________________________________________________________________________
48 AliEMCAL::AliEMCAL():AliDetector()
49 {
50   // Default ctor 
51   fName="EMCAL";
52   //fQATask = 0;
53   fTreeQA = 0;
54   fGeom = 0 ; 
55 }
56
57 //____________________________________________________________________________
58 AliEMCAL::AliEMCAL(const char* name, const char* title): AliDetector(name,title)
59 {
60   //   ctor : title is used to identify the layout
61   
62   //fQATask = 0;
63   fTreeQA = 0;
64   fGeom = 0;
65 }
66
67 //____________________________________________________________________________
68 AliEMCAL::~AliEMCAL()
69 {
70
71 }
72
73 //____________________________________________________________________________
74 void AliEMCAL::CreateMaterials()
75 {
76   // Definitions of materials to build EMCAL and associated tracking media.
77   // media number in idtmed are 1599 to 1698.
78
79   // --- Air ---
80   AliMaterial(0, "Air$", 14.61, 7.3, 0.001205, 30420., 67500., 0, 0) ;
81
82
83   // --- Lead ---                                                                     
84   AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
85
86
87   // --- The polysterene scintillator (CH) ---
88   Float_t aP[2] = {12.011, 1.00794} ;
89   Float_t zP[2] = {6.0, 1.0} ;
90   Float_t wP[2] = {1.0, 1.0} ;
91   Float_t dP = 1.032 ;
92
93   AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
94
95   // --- Aluminium ---
96   AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
97   // ---         Absorption length is ignored ^
98
99   // --- Copper ---
100   AliMaterial(4, "Cu$", 63.546, 29, 8.96, 1.43, 14.8, 0, 0) ; 
101   // ---         Absorption length is ignored ^
102
103
104   // DEFINITION OF THE TRACKING MEDIA
105
106   // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100]
107   Int_t * idtmed = fIdtmed->GetArray() - 1599 ; 
108   Int_t   isxfld = gAlice->Field()->Integ() ;
109   Float_t sxmgmx = gAlice->Field()->Max() ;
110  
111
112
113    // Air                                                                           -> idtmed[1599] 
114   AliMedium(0, "Air          $", 0, 0,
115              isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
116
117   // The Lead                                                                      -> idtmed[1600]
118  
119   AliMedium(1, "Lead      $", 1, 0,
120              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
121
122  
123  // The scintillator of the CPV made of Polystyrene scintillator                   -> idtmed[1601]
124   AliMedium(2, "CPV scint.   $", 2, 1,
125             isxfld, sxmgmx, 10.0, 0.001, 0.1, 0.001, 0.001, 0, 0) ;
126
127   // Various Aluminium parts made of Al                                            -> idtmed[1602]
128   AliMedium(3, "Al parts     $", 3, 0,
129              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
130
131   // Copper for HCal (post shower)                                                 -> idtmed[1603]
132   AliMedium(4, "Copper       $", 4, 0,
133              isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
134
135
136
137 // --- Set decent energy thresholds for gamma and electron tracking
138
139   // Tracking threshold for photons and electrons in Lead 
140   gMC->Gstpar(idtmed[1600],"CUTGAM",0.00008) ;
141   gMC->Gstpar(idtmed[1600],"CUTELE",0.001) ;
142   gMC->Gstpar(idtmed[1600],"BCUTE",0.0001) ;
143
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",0.00001) ;
148   gMC->Gstpar(idtmed[1600], "DCUTM",0.00001) ;
149
150 // --- in aluminium parts ---
151   gMC->Gstpar(idtmed[1602], "LOSS",3.) ;
152   gMC->Gstpar(idtmed[1602], "DRAY",1.) ;
153   gMC->Gstpar(idtmed[1602], "DCUTE",0.00001) ;
154   gMC->Gstpar(idtmed[1602], "DCUTM",0.00001) ;
155
156 // --- in copper parts ---
157   gMC->Gstpar(idtmed[1603], "LOSS",3.) ;
158   gMC->Gstpar(idtmed[1603], "DRAY",1.) ;
159   gMC->Gstpar(idtmed[1603], "DCUTE",0.00001) ;
160   gMC->Gstpar(idtmed[1603], "DCUTM",0.00001) ;
161
162
163
164 // --- and finally thresholds for photons and electrons in the scintillator ---
165   gMC->Gstpar(idtmed[1601],"CUTGAM",0.00008) ;
166   gMC->Gstpar(idtmed[1601],"CUTELE",0.001) ;
167   gMC->Gstpar(idtmed[1601],"BCUTE",0.0001) ;
168
169
170 }
171
172 //____________________________________________________________________________
173 AliEMCALGeometry * AliEMCAL::GetGeometry() const 
174 {  
175   // gets the pointer to the AliEMCALGeometry unique instance 
176
177   if (fGeom) 
178     return fGeom ; 
179   else 
180     return AliEMCALGeometry::GetInstance(GetTitle(),"") ;  
181 }
182
183 //____________________________________________________________________________
184 void AliEMCAL::SetTreeAddress()
185
186
187   TBranch *branch;
188   char branchname[20];
189   sprintf(branchname,"%s",GetName());
190   
191   // Branch address for hit tree
192   TTree *treeH = TreeH();
193   if (treeH) {
194     branch = treeH->GetBranch(branchname);
195     if (branch) 
196       { 
197         if (fHits == 0x0) fHits= new TClonesArray("AliEMCALHit",1000);
198         //Info("SetTreeAddress","<%s> Setting Hits Address",GetName());
199         branch->SetAddress(&fHits);
200       }
201     else
202       {
203         Warning("SetTreeAddress","<%s> Failed",GetName());
204       }
205   }
206 }
207 //____________________________________________________________________________
208 void AliEMCAL::WriteQA()
209 {
210   
211   // Make TreeQA in the output file. 
212   
213   if(fTreeQA == 0)
214     fTreeQA = new TTree("TreeQA", "QA Alarms") ;    
215   // Create Alarms branches
216   Int_t bufferSize = 32000 ;    
217   Int_t splitlevel = 0 ; 
218   
219   TFolder* topfold = GetLoader()->GetTopFolder(); //get top aliroot folder; skowron
220   TString emcalqafn(AliConfig::Instance()->GetQAFolderName()+"/"); //get name of QAaut folder relative to top event; skowron
221   emcalqafn+=GetName(); //hard wired string!!! add the detector name to the pathname; skowron 
222   TFolder * alarmsF = (TFolder*)topfold->FindObjectAny(emcalqafn); //get the folder
223   
224   if (alarmsF == 0x0)
225     {
226       Error("WriteQA","Can not find folder with qa alarms");
227       return;
228     }
229   TString branchName(alarmsF->GetName());
230   TBranch * alarmsBranch = fTreeQA->Branch(branchName,"TFolder", &alarmsF, bufferSize, splitlevel);
231   TString branchTitle = branchName + " QA alarms" ; 
232   alarmsBranch->SetTitle(branchTitle);
233   alarmsBranch->Fill() ; 
234   
235   //fTreeQA
236 }
237
238 //____________________________________________________________________________
239 AliLoader* AliEMCAL::MakeLoader(const char* topfoldername)
240 {
241 //different behaviour than standard (singleton getter)
242 // --> to be discussed and made eventually coherent
243  fLoader = new AliEMCALLoader(GetName(),topfoldername);
244  return fLoader;
245 }