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