ATLAS Offline Software
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 
14 LayerTestTool::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),
16  m_n_energy_gamma(0),m_n_energy_neutron(0),m_n_energy_muon(0),m_n_energy_muonp(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),
18  m_energy(0),m_pos_x(0),m_pos_y(0),m_pos_z(0),m_pos_r(0),m_p_x(0),m_p_y(0),m_p_z(0),m_p_rho(0),m_p_phi(0),m_p_eta(0)
19 {
20  declareProperty("CollectionName", m_collection="CaloEntry");
21 }
22 
23 
25 {
26  m_path+="Layer/";
27  m_path+=m_collection+"/";
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();
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();
110  m_pos_r= std::sqrt(m_pos_x*m_pos_x+m_pos_y*m_pos_y);
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TH2::Fill
int Fill(double, double)
Definition: rootspy.cxx:382
LayerTestTool::initialize
StatusCode initialize()
Definition: LayerTestTool.cxx:24
LayerTestTool::m_n_eta
TH1 * m_n_eta
Definition: LayerTestTool.h:37
LayerTestTool::m_n_pz
TH1 * m_n_pz
Definition: LayerTestTool.h:34
AtlasHitsVector
Definition: AtlasHitsVector.h:33
LayerTestTool::m_n_phi
TH1 * m_n_phi
Definition: LayerTestTool.h:38
LayerTestTool::m_pos_y
double m_pos_y
Definition: LayerTestTool.h:42
LayerTestTool::processEvent
StatusCode processEvent()
Definition: LayerTestTool.cxx:70
_SET_TITLE
#define _SET_TITLE(var, title, xaxis, yaxis)
Definition: SimTestHisto.h:93
LayerTestTool::m_p_x
double m_p_x
Definition: LayerTestTool.h:45
LayerTestTool::m_n_energy_muonp
TH1 * m_n_energy_muonp
Definition: LayerTestTool.h:28
LayerTestTool::m_p_rho
double m_p_rho
Definition: LayerTestTool.h:48
_TH1D
#define _TH1D(var, name, nbin, xmin, xmax)
Definition: SimTestHisto.h:47
LayerTestTool::m_pos_z
double m_pos_z
Definition: LayerTestTool.h:43
LayerTestTool::m_n_energy_e
TH1 * m_n_energy_e
Definition: LayerTestTool.h:23
LayerTestTool::m_n_rho
TH1 * m_n_rho
Definition: LayerTestTool.h:36
SimTestToolBase
Definition: SimTestToolBase.h:20
LayerTestTool::m_n_py
TH1 * m_n_py
Definition: LayerTestTool.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LayerTestTool::m_p_phi
double m_p_phi
Definition: LayerTestTool.h:49
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LayerTestTool::m_n_energy
TH1 * m_n_energy
Definition: LayerTestTool.h:22
LayerTestTool::m_p_z
double m_p_z
Definition: LayerTestTool.h:47
LayerTestTool::m_p_eta
double m_p_eta
Definition: LayerTestTool.h:50
_TH2D
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
Definition: SimTestHisto.h:81
LayerTestTool::m_p_y
double m_p_y
Definition: LayerTestTool.h:46
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
LayerTestTool::m_n_energy_muon
TH1 * m_n_energy_muon
Definition: LayerTestTool.h:27
TrackRecord.h
LayerTestTool::m_pos_r
double m_pos_r
Definition: LayerTestTool.h:44
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrackRecordCollection.h
LayerTestTool::m_collection
std::string m_collection
Definition: LayerTestTool.h:20
LayerTestTool::LayerTestTool
LayerTestTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: LayerTestTool.cxx:14
LayerTestTool::m_n_px
TH1 * m_n_px
Definition: LayerTestTool.h:32
LayerTestTool::m_n_energy_gamma
TH1 * m_n_energy_gamma
Definition: LayerTestTool.h:25
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
LayerTestTool::m_energy
double m_energy
Definition: LayerTestTool.h:40
LayerTestTool::m_n_energy_neutron
TH1 * m_n_energy_neutron
Definition: LayerTestTool.h:26
SimTestHisto::m_path
std::string m_path
Definition: SimTestHisto.h:34
LayerTestTool::m_n_pos
TH2 * m_n_pos
Definition: LayerTestTool.h:30
SimTestToolBase::m_key
std::string m_key
The MC truth key.
Definition: SimTestToolBase.h:34
LayerTestTool::m_pos_x
double m_pos_x
Definition: LayerTestTool.h:41
LayerTestTool.h
LayerTestTool::m_n_energy_ep
TH1 * m_n_energy_ep
Definition: LayerTestTool.h:24