Code for simulation, sdigitization and digitization moved from macros to compiled...
[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$ */
17
18//_________________________________________________________________________
19// Base Class for EMCAL description:
ffa6d63b 20// This class contains material definitions
21// for the EMCAL - It does not place the detector in Alice
2012850d 22//*-- Author: Yves Schutz (SUBATECH)
b13bbe81 23//
24//*-- Additional Contributions: Sahal Yacoob (LBNL/UCT)
25//
2012850d 26//////////////////////////////////////////////////////////////////////////////
27
2012850d 28// --- ROOT system ---
b13bbe81 29class TFile;
88cb7938 30#include <TFolder.h>
88cb7938 31#include <TTree.h>
32#include <TVirtualMC.h>
2012850d 33
05a92d59 34// --- Standard library ---
2012850d 35
05a92d59 36// --- AliRoot header files ---
2012850d 37#include "AliMagF.h"
88cb7938 38#include "AliEMCAL.h"
05a92d59 39#include "AliEMCALGeometry.h"
88cb7938 40#include "AliEMCALLoader.h"
85a5290f 41#include "AliRun.h"
42#include "AliEMCALSDigitizer.h"
43#include "AliEMCALDigitizer.h"
2012850d 44
45ClassImp(AliEMCAL)
2012850d 46//____________________________________________________________________________
47AliEMCAL::AliEMCAL():AliDetector()
48{
05a92d59 49 // Default ctor
50 fName="EMCAL";
51 //fQATask = 0;
52 fTreeQA = 0;
1d7b3dd6 53 fGeom = 0 ;
2012850d 54}
05a92d59 55
2012850d 56//____________________________________________________________________________
05a92d59 57AliEMCAL::AliEMCAL(const char* name, const char* title): AliDetector(name,title)
58{
59 // ctor : title is used to identify the layout
60
61 //fQATask = 0;
62 fTreeQA = 0;
1fe0f889 63 fGeom = 0;
2012850d 64}
05a92d59 65
2012850d 66//____________________________________________________________________________
05a92d59 67AliEMCAL::~AliEMCAL()
68{
69
2012850d 70}
71
72//____________________________________________________________________________
05a92d59 73void AliEMCAL::CreateMaterials()
74{
2012850d 75 // Definitions of materials to build EMCAL and associated tracking media.
76 // media number in idtmed are 1599 to 1698.
77
78 // --- Air ---
79 AliMaterial(0, "Air$", 14.61, 7.3, 0.001205, 30420., 67500., 0, 0) ;
80
b13bbe81 81
2012850d 82 // --- Lead ---
83 AliMaterial(1, "Pb$", 207.2, 82, 11.35, 0.56, 0., 0, 0) ;
84
b13bbe81 85
86 // --- The polysterene scintillator (CH) ---
87 Float_t aP[2] = {12.011, 1.00794} ;
88 Float_t zP[2] = {6.0, 1.0} ;
89 Float_t wP[2] = {1.0, 1.0} ;
90 Float_t dP = 1.032 ;
91
92 AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
93
94 // --- Aluminium ---
95 AliMaterial(3, "Al$", 26.98, 13., 2.7, 8.9, 999., 0, 0) ;
96 // --- Absorption length is ignored ^
97
a63e0d5e 98 // --- Copper ---
99 AliMaterial(4, "Cu$", 63.546, 29, 8.96, 1.43, 14.8, 0, 0) ;
100 // --- Absorption length is ignored ^
b13bbe81 101
2012850d 102
103 // DEFINITION OF THE TRACKING MEDIA
104
105 // for EMCAL: idtmed[1599->1698] equivalent to fIdtmed[0->100]
106 Int_t * idtmed = fIdtmed->GetArray() - 1599 ;
107 Int_t isxfld = gAlice->Field()->Integ() ;
108 Float_t sxmgmx = gAlice->Field()->Max() ;
b13bbe81 109
110
2012850d 111
112 // Air -> idtmed[1599]
113 AliMedium(0, "Air $", 0, 0,
114 isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
115
a63e0d5e 116 // The Lead -> idtmed[1600]
2012850d 117
118 AliMedium(1, "Lead $", 1, 0,
119 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
120
b13bbe81 121
122 // The scintillator of the CPV made of Polystyrene scintillator -> idtmed[1601]
123 AliMedium(2, "CPV scint. $", 2, 1,
61e0abb5 124 isxfld, sxmgmx, 10.0, 0.001, 0.1, 0.001, 0.001, 0, 0) ;
b13bbe81 125
a63e0d5e 126 // Various Aluminium parts made of Al -> idtmed[1602]
b13bbe81 127 AliMedium(3, "Al parts $", 3, 0,
128 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
129
a63e0d5e 130 // Copper for HCal (post shower) -> idtmed[1603]
131 AliMedium(4, "Copper $", 4, 0,
132 isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.001, 0.001, 0, 0) ;
b13bbe81 133
2012850d 134
2012850d 135
b13bbe81 136// --- Set decent energy thresholds for gamma and electron tracking
2012850d 137
138 // Tracking threshold for photons and electrons in Lead
ffa6d63b 139 gMC->Gstpar(idtmed[1600],"CUTGAM",0.00008) ;
140 gMC->Gstpar(idtmed[1600],"CUTELE",0.001) ;
141 gMC->Gstpar(idtmed[1600],"BCUTE",0.0001) ;
2012850d 142
143 // --- Generate explicitly delta rays in Lead ---
144 gMC->Gstpar(idtmed[1600], "LOSS",3.) ;
145 gMC->Gstpar(idtmed[1600], "DRAY",1.) ;
05a92d59 146 gMC->Gstpar(idtmed[1600], "DCUTE",0.00001) ;
147 gMC->Gstpar(idtmed[1600], "DCUTM",0.00001) ;
148
a63e0d5e 149// --- in aluminium parts ---
b13bbe81 150 gMC->Gstpar(idtmed[1602], "LOSS",3.) ;
151 gMC->Gstpar(idtmed[1602], "DRAY",1.) ;
05a92d59 152 gMC->Gstpar(idtmed[1602], "DCUTE",0.00001) ;
153 gMC->Gstpar(idtmed[1602], "DCUTM",0.00001) ;
b13bbe81 154
a63e0d5e 155// --- in copper parts ---
156 gMC->Gstpar(idtmed[1603], "LOSS",3.) ;
157 gMC->Gstpar(idtmed[1603], "DRAY",1.) ;
158 gMC->Gstpar(idtmed[1603], "DCUTE",0.00001) ;
159 gMC->Gstpar(idtmed[1603], "DCUTM",0.00001) ;
160
161
61e0abb5 162
ffa6d63b 163// --- and finally thresholds for photons and electrons in the scintillator ---
61e0abb5 164 gMC->Gstpar(idtmed[1601],"CUTGAM",0.00008) ;
165 gMC->Gstpar(idtmed[1601],"CUTELE",0.001) ;
166 gMC->Gstpar(idtmed[1601],"BCUTE",0.0001) ;
167
168
2012850d 169}
05a92d59 170
171//____________________________________________________________________________
172AliEMCALGeometry * AliEMCAL::GetGeometry() const
173{
174 // gets the pointer to the AliEMCALGeometry unique instance
05a92d59 175
1d7b3dd6 176 if (fGeom)
177 return fGeom ;
178 else
179 return AliEMCALGeometry::GetInstance(GetTitle(),"") ;
05a92d59 180}
181
2012850d 182//____________________________________________________________________________
183void AliEMCAL::SetTreeAddress()
184{
d64c959b 185 // Linking Hits in Tree to Hits array
2012850d 186 TBranch *branch;
187 char branchname[20];
188 sprintf(branchname,"%s",GetName());
189
190 // Branch address for hit tree
88cb7938 191 TTree *treeH = TreeH();
192 if (treeH) {
2012850d 193 branch = treeH->GetBranch(branchname);
88cb7938 194 if (branch)
195 {
d64c959b 196 if (fHits == 0x0)
197 fHits= new TClonesArray("AliEMCALHit",1000);
88cb7938 198 //Info("SetTreeAddress","<%s> Setting Hits Address",GetName());
199 branch->SetAddress(&fHits);
200 }
201 else
202 {
203 Warning("SetTreeAddress","<%s> Failed",GetName());
204 }
2012850d 205 }
2012850d 206}
05a92d59 207//____________________________________________________________________________
208void AliEMCAL::WriteQA()
209{
88cb7938 210
05a92d59 211 // Make TreeQA in the output file.
88cb7938 212
05a92d59 213 if(fTreeQA == 0)
214 fTreeQA = new TTree("TreeQA", "QA Alarms") ;
215 // Create Alarms branches
88cb7938 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
05a92d59 236}
2012850d 237
88cb7938 238//____________________________________________________________________________
239AliLoader* 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}
85a5290f 246
247//____________________________________________________________________________
248void AliEMCAL::Hits2SDigits()
249{
250// create summable digits
251
252 AliEMCALSDigitizer* emcalDigitizer =
253 new AliEMCALSDigitizer(fLoader->GetRunLoader()->GetFileName().Data());
254 emcalDigitizer->ExecuteTask();
255}
256
257//____________________________________________________________________________
258AliDigitizer* AliEMCAL::CreateDigitizer(AliRunDigitizer* manager)
259{
260 return new AliEMCALDigitizer(manager);
261}