ATLAS Offline Software
Loading...
Searching...
No Matches
LayerTestTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "LayerTestTool.h"
6
7#include "GaudiKernel/ITHistSvc.h"
10
11#include <TH1.h>
12#include <TH2.h>
13
14LayerTestTool::LayerTestTool(const std::string& type, const std::string& name, const IInterface* parent)
15 : SimTestToolBase(type, name, parent), m_collection("CaloEntry"), m_n_energy(0),m_n_energy_e(0),m_n_energy_ep(0),
17 m_n_pos(0),m_n_px(0),m_n_py(0),m_n_pz(0),m_n_rho(0),m_n_eta(0),m_n_phi(0),
19{
20 declareProperty("CollectionName", m_collection="CaloEntry");
21}
22
23
25{
26 m_path+="Layer/";
28
29 _TH1D(m_n_energy,(m_collection+"_energy").c_str(),31,0.,2000000.);
30 _SET_TITLE(m_n_energy,"energy","E MeV","n");
31
32 _TH1D(m_n_energy_e,(m_collection+"_energy_e").c_str(),31,0.,20000.);
33 _SET_TITLE(m_n_energy_e,"energy","E MeV","n");
34
35 _TH1D(m_n_energy_ep,(m_collection+"_energy_ep").c_str(),31,0.,20000.);
36 _SET_TITLE(m_n_energy_ep,"energy","E MeV","n");
37
38 _TH1D(m_n_energy_gamma,(m_collection+"_energy_gamma").c_str(),31,0.,20000.);
39 _SET_TITLE(m_n_energy_gamma,"energy","E MeV","n");
40
41 _TH1D(m_n_energy_neutron,(m_collection+"_energy_neutron").c_str(),31,0.,20000.);
42 _SET_TITLE(m_n_energy_neutron,"energy","E MeV","n");
43
44 _TH1D(m_n_energy_muon,(m_collection+"_energy_muon").c_str(),31,0.,2000000.);
45 _SET_TITLE(m_n_energy_muon,"energy","E MeV","n");
46
47 _TH1D(m_n_energy_muonp,(m_collection+"_energy_muonp").c_str(),31,0.,2000000.);
48 _SET_TITLE(m_n_energy_muonp,"energy","E MeV","n");
49
50 _TH1D(m_n_px,(m_collection+"_px").c_str(),31,-500000.,500000.);
51 _SET_TITLE(m_n_px,"px distribution","px MeV","n");
52 _TH1D(m_n_py,(m_collection+"_py").c_str(),31,-500000.,500000.);
53 _SET_TITLE(m_n_py,"py distribution","py MeV","n");
54 _TH1D(m_n_pz,(m_collection+"_pz").c_str(),31,-500000.,500000.);
55 _SET_TITLE(m_n_pz,"pz distribution","pz MeV","n");
56
57 _TH1D(m_n_rho,(m_collection+"_rho").c_str(),31,0,50000.);
58 _SET_TITLE(m_n_rho,"rho distribution","rho","n");
59 _TH1D(m_n_eta,(m_collection+"_eta").c_str(),31,-5.,5.);
60 _SET_TITLE(m_n_eta,"eta distribution","eta","n");
61 _TH1D(m_n_phi,(m_collection+"_phi").c_str(),31,-5.,5.);
62 _SET_TITLE(m_n_phi,"phi distribution","phi","n");
63
64 _TH2D(m_n_pos,(m_collection+"_pos").c_str(),31,-7500.,7500.,31,0.,4500.);
65 _SET_TITLE(m_n_pos,"pos","z","r");
66 return StatusCode::SUCCESS;
67}
68
69
71{
72 //std::cout<<"LayerTestTool::processEvent()"<<std::endl;
73 const TrackRecordCollection * trCollection = 0;
74 m_key=m_collection+"Layer";
75
76 if (evtStore()->retrieve(trCollection,m_key).isSuccess()) {
77
78 for(const auto& e : *trCollection){
79
80 m_energy = e.GetEnergy();
81 m_n_energy->Fill(m_energy);
82
83 if(e.GetPDGCode() == 11){
85 }
86
87 if(e.GetPDGCode() == -11){
89 }
90
91 if(e.GetPDGCode() == 22){
93 }
94
95 if(e.GetPDGCode() == 2112){
97 }
98
99 if(e.GetPDGCode() == 13){
101 }
102
103 if(e.GetPDGCode() == -13){
105 }
106
107 m_pos_x = e.GetPosition().x();
108 m_pos_y = e.GetPosition().y();
109 m_pos_z = e.GetPosition().z();
111 m_n_pos->Fill(m_pos_z,m_pos_r);
112
113 m_p_x=e.GetMomentum().x();
114 m_p_y=e.GetMomentum().y();
115 m_p_z=e.GetMomentum().z();
116 // std::cout<<"px="<<m_p_x<<";py="<<m_p_y<<";pz="<<m_p_z<<std::endl;
117 m_n_px->Fill(m_p_x);
118 m_n_py->Fill(m_p_y);
119 m_n_pz->Fill(m_p_z);
120
121 m_p_rho=e.GetMomentum().rho();
122 m_p_phi=e.GetMomentum().phi();
123 m_p_eta=e.GetMomentum().eta();
124 // std::cout<<"rho="<<m_p_rho<<";phi="<<m_p_phi<<";eta="<<m_p_eta<<std::endl;
125 m_n_rho->Fill(m_p_rho);
126 m_n_eta->Fill(m_p_eta);
127 m_n_phi->Fill(m_p_phi);
128 }
129
130 }
131
132 return StatusCode::SUCCESS;
133}
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
#define _TH1D(var, name, nbin, xmin, xmax)
#define _SET_TITLE(var, title, xaxis, yaxis)
AtlasHitsVector< TrackRecord > TrackRecordCollection
StatusCode processEvent()
TH1 * m_n_energy_gamma
LayerTestTool(const std::string &type, const std::string &name, const IInterface *parent)
TH1 * m_n_energy_muonp
StatusCode initialize()
TH1 * m_n_energy_neutron
TH1 * m_n_energy_muon
std::string m_collection
std::string m_path
std::string m_key
The MC truth key.
SimTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)