committing on behalf of Silvia... new macros for HFE analysis on the train (Markus
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALWsuCosmicRaySetUp.cxx
CommitLineData
1963b290 1/**************************************************************************
388f0a7b 2 * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
1963b290 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// //
20// Wsu Cosmic Ray SetUp //
21// This class contains the description of the Wsu Cosmic Ray SetUp //
22// external volume //
23// //
24//Begin_Html
25/*
26<img src="picts/AliEMCALWsuCosmicRaySetUpClass.gif">
27</pre>
28<br clear=left>
29<font size=+2 color=red>
30<p>The responsible person for this module is
388f0a7b 31<a href="mailto:pavlinov@physics.wayne.edu">Alexei Pavlino, WSU</a>.
1963b290 32</font>
33<pre>
34*/
35//End_Html
36// //
37// //
38///////////////////////////////////////////////////////////////////////////////
39
40#include <TVirtualMC.h>
388f0a7b 41#include <TROOT.h>
42#include <TDatabasePDG.h>
43#include <TBrowser.h>
44#include <TLorentzVector.h>
45#include <TParticle.h>
46#include <TList.h>
47#include <TH1.h>
48#include <TH2.h>
49#include <TAxis.h>
1963b290 50
51#include "AliEMCALWsuCosmicRaySetUp.h"
52//#include "AliMagF.h"
388f0a7b 53#include "AliStack.h"
1963b290 54#include "AliRun.h"
388f0a7b 55#include "AliMC.h"
56
57#include "AliEMCALHistoUtilities.h"
58
59using namespace std;
60
61typedef AliEMCALHistoUtilities hist;
62
63TDatabasePDG *pdg = 0;
64
65Int_t gid=0;
1963b290 66
67ClassImp(AliEMCALWsuCosmicRaySetUp)
388f0a7b 68
69// TList *fLHists=0, *ll=0;
70
1963b290 71//_____________________________________________________________________________
388f0a7b 72 AliEMCALWsuCosmicRaySetUp::AliEMCALWsuCosmicRaySetUp(): AliModule()
73 //,fMasterVolume()
74 ,fLHists(0),fMasterVolume()
1963b290 75{
76 //
77 // Default constructor
78 //
79}
80
81//_____________________________________________________________________________
82AliEMCALWsuCosmicRaySetUp::AliEMCALWsuCosmicRaySetUp(const char *name, const char *title)
83 : AliModule(name,title)
388f0a7b 84 //,fMasterVolume()
85 ,fLHists(0),fMasterVolume()
1963b290 86{
87 //
88 // Standard constructor of the Wsu Cosmic Ray SetUp external volume
89 //
e939a978 90 //PH SetMarkerColor(7);
91 //PH SetMarkerStyle(2);
92 //PH SetMarkerSize(0.4);
1963b290 93}
94
95//_____________________________________________________________________________
96void AliEMCALWsuCosmicRaySetUp::CreateGeometry()
97{
98 //
99 // Create the geometry of the Alice external body
100 //
101 //Begin_Html
102 /*
103 <img src="picts/AliEMCALWsuCosmicRaySetUpTree.gif">
104 */
105 //End_Html
388f0a7b 106 pdg = TDatabasePDG::Instance();
1963b290 107
ce540969 108 // Master Volume
388f0a7b 109 fMasterVolume[0] = fMasterVolume[1] = 35.0;
110 fMasterVolume[2] = 450.;
ce540969 111
1963b290 112 Int_t *idtmed = fIdtmed->GetArray()+1;
ce540969 113 int idAir = idtmed[0];
114 gMC->Gsvolu(GetName(),"BOX",idAir, fMasterVolume,3); // Master volume
115 //
116 // Sc counters
1963b290 117 //
ce540969 118 Float_t sc[3]; // tube
119 sc[0] = 0.0;
388f0a7b 120 sc[1] = 10.0;
121 sc[2] = 1.0; // thicness of Sc is 2 cm
122 Float_t zsc[3] = {10.,330.6, 810.1};
ce540969 123 int idSC = idtmed[1];
124 gMC->Gsvolu("SCOU","TUBE",idSC, sc,3); // Master volume
388f0a7b 125 printf(" idtmed[0] %i idtmed[1] %i \n", idtmed[0] , idtmed[1]);
ce540969 126 Int_t idRot=0; // no rotation
127 for(Int_t i=0; i<3; i++) {
128 Float_t zpos = zsc[i] - fMasterVolume[2];
129 gMC->Gspos("SCOU", i+1, "WSUC", 0.0, 0.0, zpos, idRot, "ONLY");
130 }
388f0a7b 131 //
132 // Dead end : Dec 2,2010
133 //
134 Float_t zbox[3]={30., 30.0, 0.1};
135 gMC->Gsvolu("SEND","BOX",idAir, zbox,3); // Master volume
136 gMC->Gspos("SEND", 1, "WSUC", 0.0, 0.0, 448.0, idRot, "ONLY");
137 // Hists
138 fLHists = new TList;
139 fLHists->SetName("hists");
140 //
141 //AliMC *ALIMC = dynamic_cast<AliMC *>(gMC);
142 //AliGenBox* gB = dynamic_cast<AliGenBox *>(ALIMC->Generator());
143 //Double_t p = gB->
144 fLHists->Add(BookKineHists(1.,"primeKineHists"));
145 fLHists->Add(BookKineHists(1.,"endKineHists"));
146 fLHists->Add(BookKineHists(1.,"secondaryKineHists"));
147 //ll = BookKineHists(1.,"kineHists");
148 //gROOT->GetListOfBrowsables()->Add(ll);
1963b290 149}
150
151//_____________________________________________________________________________
152void AliEMCALWsuCosmicRaySetUp::CreateMaterials()
153{
154// Create materials and media
155 Int_t isxfld = 0;
ce540969 156 Float_t sxmgmx = 0., deemax = 0.1;
1963b290 157 // AIR
158 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
159 Float_t zAir[4]={6.,7.,8.,18.};
160 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
161 Float_t dAir = 1.20479E-3;
1963b290 162 AliMixture(1,"Air $",aAir,zAir,dAir,4,wAir);
ce540969 163
164 // --- The polysterene scintillator (CH) ---
165 Float_t aP[2] = {12.011, 1.00794} ;
166 Float_t zP[2] = {6.0, 1.0} ;
167 Float_t wP[2] = {1.0, 1.0} ;
168 Float_t dP = 1.032 ;
169 AliMixture(2, "Polystyrene$", aP, zP, dP, -2, wP) ;
170
1963b290 171 //
172 AliMedium(1,"Air $",1,0,isxfld,sxmgmx,10,-1,-0.1,0.1 ,-10);
ce540969 173 AliMedium(2, "Scintillator$", 2, 1,
174 isxfld, sxmgmx, 10.0, 0.001, deemax, 0.001, 0.001, 0, 0) ;
388f0a7b 175 // cuts
176 DefineCuts(1);
177 DefineCuts(2);
1963b290 178}
179
388f0a7b 180void AliEMCALWsuCosmicRaySetUp::DefineCuts(const Int_t idtmed)
1963b290 181{
388f0a7b 182 // Dec 2,2010 : it works
183 Float_t cutgam=10.e-5; // 100 kev;
184 Float_t cutele=10.e-5; // 100 kev;
185 gMC->Gstpar(idtmed,"CUTGAM", cutgam);
186 gMC->Gstpar(idtmed,"CUTELE", cutele); // 1MEV -> 0.1MEV; 15-aug-05
187 gMC->Gstpar(idtmed,"BCUTE", cutgam); // BCUTE and BCUTM start from GUTGUM
188 gMC->Gstpar(idtmed,"BCUTM", cutgam); // BCUTE and BCUTM start from GUTGUM
189 // --- Generate explicitly delta rays in Lead ---
190 gMC->Gstpar(idtmed, "LOSS", 3) ;
191 gMC->Gstpar(idtmed, "DRAY", 1) ;
192 gMC->Gstpar(idtmed, "DCUTE", cutele) ;
193 gMC->Gstpar(idtmed, "DCUTM", cutele) ;
194}
195
196void AliEMCALWsuCosmicRaySetUp::StepManager(void)
197{
198 // Dec 1,2010
199 static Int_t pri=1;
200 static TString curVolName="";
201 static TLorentzVector pos; // Lorentz vector of the track current position.
202 static TLorentzVector mom; // Lorentz vector of the track current momentum.
203
204 if(pri>=2) printf("<I> AliEMCALWsuCosmicRaySetUp::StepManager %s \n", gMC->CurrentVolName());
205 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
9480ad51 206 // Int_t parent=0;
388f0a7b 207 TParticle* part=0;
208 curVolName = gMC->CurrentVolName();
209 if(curVolName.Contains("SEND")) {
210 gMC->TrackMomentum(mom);
211 gMC->TrackPosition(pos);
212 if(pri>=2) printf(" %s tracknumber %i p %f \n", curVolName.Data(), tracknumber, mom.P());
213 if(pri>=2) printf(" x %f y %f z %f \n", pos[0], pos[1], pos[2]);
214 if(gMC->IsTrackEntering()) { // primary only TList *l = GetLhists(1);
215 TList *l = 0;
216 if(tracknumber==0){
217 l = GetLhists(1);
218 part=gAlice->GetMCApp()->Particle(0);
219 gid = pdg->ConvertPdgToGeant3(part->GetPdgCode());
220 hist::FillH1(l, 1, double(gid));
221 } else {
222 l = GetLhists(2);
223 part=gAlice->GetMCApp()->Particle(tracknumber);
224 gid = pdg->ConvertPdgToGeant3(part->GetPdgCode());
225 hist::FillH1(l, 1, double(gid));
226 }
227 Int_t ic = 2;
228 hist::FillH1(l, ic++, mom.P());
229 hist::FillH1(l, ic++, mom.Eta());
230 hist::FillH1(l, ic++, TVector2::Phi_0_2pi(mom.Phi())*TMath::RadToDeg() );
231 hist::FillH1(l, ic++, mom.Theta()*TMath::RadToDeg());
232 }
233 }
234}
235
236void AliEMCALWsuCosmicRaySetUp::FinishEvent()
237{
238 // Dec 2,2010
239 int ic=0;
240
241 TList *l = GetLhists(0);
242 // TList *l = ll;
243 AliStack* st = AliRunLoader::Instance()->Stack();
244 TParticle *p = st->Particle(0);
245 gid = pdg->ConvertPdgToGeant3(p->GetPdgCode());
246
247 ic=1;
248 hist::FillH1(l, ic++, double(gid));
249 hist::FillH1(l, ic++, p->P());
250 hist::FillH1(l, ic++, p->Eta());
251 hist::FillH1(l, ic++, TVector2::Phi_0_2pi(p->Phi())*TMath::RadToDeg() );
252 hist::FillH1(l, ic++, p->Theta()*TMath::RadToDeg());
253}
254
255TList* AliEMCALWsuCosmicRaySetUp::BookKineHists(const Double_t p , const Char_t *opt)
256{
257 // Dec 2,2010
258 gROOT->cd();
259 TH1::AddDirectory(1);
260
261 TH1 *h = 0, *hgid=0;
262 Int_t nphi=180;
263 Int_t phimin=0.0, phimax=360.;
264 Double_t pmax=110.;
265 if(p>0.1) pmax = 1.1*p;
266 h = new TH1F("00_hNPrim"," number of primary particles ", 10, 0.5, 10.5);
267 hgid = new TH1F("01_hGidprim","Geant Id of primary particles", 16, 0.5, 16.5);
268 new TH1F("02_hPmomPrim","p of primary particles", 200, 0.0, pmax);
269 new TH1F("03_hEtaPrim","#eta primary particles", 80, 0.0, 8.0);
270 new TH1F("04_hPhiPrim","#phi primary particles", nphi,phimin,phimax);
271 new TH1F("05_hThetaPrim","#theta primary particles", 90, 0.0, 90.);
1963b290 272 //
388f0a7b 273 TAxis *xax=hgid->GetXaxis();
274 xax->SetBinLabel(1,"#gamma");
275 xax->SetBinLabel(2,"e^{+}");
276 xax->SetBinLabel(3,"e^{-}");
277 xax->SetBinLabel(4,"#nu");
278 xax->SetBinLabel(5,"#mu^{+}");
279 xax->SetBinLabel(6,"#mu^{-}");
280 xax->SetBinLabel(7,"#pi^{0}");
281 xax->SetBinLabel(8,"#pi^{+}");
282 xax->SetBinLabel(9,"#pi^{-}");
283 xax->SetBinLabel(10,"K_{L}");
284 xax->SetBinLabel(11,"K^{+}");
285 xax->SetBinLabel(12,"K^{-}");
286 xax->SetBinLabel(13,"n");
287 xax->SetBinLabel(14,"p");
288 xax->SetBinLabel(15,"#bar{p}");
289 xax->SetBinLabel(16,"K_{s}");
290 // hgid->SetBinLabel(,"");
1963b290 291
388f0a7b 292 TList *l = 0;
293 l = hist::MoveHistsToList(opt, 1);
294 if(strlen(opt)) hist::AddToNameAndTitleToList(l, opt, opt);
1963b290 295
388f0a7b 296 TH1::AddDirectory(0);
297
298 return l;
1963b290 299}
1963b290 300
388f0a7b 301void AliEMCALWsuCosmicRaySetUp::Browse(TBrowser* b)
302{
303 if(fLHists) b->Add(fLHists);
304 TObject::Browse(b);
305}
306/*
307*/