ATLAS Offline Software
Loading...
Searching...
No Matches
MuonHitTestToolBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10
11#include "TH1D.h"
12#include "TH2D.h"
13#include <math.h>
14
16
17MuonHitTestToolBase::MuonHitTestToolBase(const std::string& type, const std::string& name, const IInterface* parent)
18 : SimTestToolBase(type, name, parent),
19 m_detname("MDT"),
20 m_pMuonMgr(0),
25 m_eta(0), m_theta(0), m_phi(0),
26 m_zResid(0),m_phiResid(0),
28
29{
30 declareProperty("BarrelEtaCut", m_BarrelEtaCut=99.);
31 declareProperty("DetectorName", m_detname="MDT");
32
33}
34
36{
37 SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey,Gaudi::Hive::currentContext());
38 ATH_CHECK(eventInfo.isValid());
39 uint64_t evt = eventInfo->eventNumber();
40 int numrun = eventInfo->runNumber();
41 ATH_MSG_VERBOSE("Processing EventInfo event #"<< evt<< " run: " << numrun);
42 m_muonevnt->Fill(evt);
43 m_muonrun->Fill(numrun);
44 const McEventCollection* mcEvent;
45 CHECK(evtStore()->retrieve(mcEvent,m_key));
46
47 // *AS* Why only if mcEvent ==1? when would there be more than one event?
48 if (mcEvent->size()!=1) {
49 m_direction=Amg::Vector3D(0.,0.,0.);
50 return StatusCode::SUCCESS;
51 }
52
53 // *AS* Why this (double) loop, if only the last entry is preserved?
54 // changed it to take the gen particle
56 for (e=mcEvent->begin();e!=mcEvent->end(); ++e) {
57 for (auto p: (**e)) {
59 Amg::Vector3D temp_momentum(p->momentum().px(),
60 p->momentum().py(),
61 p->momentum().pz());
62 m_direction = temp_momentum.unit();
63 break;
64 }
65 }
66 }
67 return StatusCode::SUCCESS;
68}
69
72
73 if (m_direction.perp() > 0 && fabs(m_direction.eta())<m_BarrelEtaCut){
74 //mdtdet->Fill(u.x(),u.y());
75 m_muondetBarrel->Fill(u.x(),u.y());
76 m_detBarrel->Fill(u.x(),u.y());
77 }
78
79 double rad=sqrt(u.x()*u.x()+u.y()*u.y());
80 m_muonlongView->Fill(u.z(),rad);
81 m_longView->Fill(u.z(),rad);
82
83 // //m_direction vector is filled with truth above, so here it is wrong (no eta, theta, phi of the hit!!!)
84 // *AS* why not use "u"?
85 // theta->Fill(m_direction.theta());
86 // theta->Fill(m_direction.theta());
87 // eta->Fill(m_direction.eta());
88 // eta->Fill(m_direction.eta());
89 // phi->Fill(m_direction.phi());
90 // phi->Fill(m_direction.phi());
91
92 if (m_direction.perp() > 0) {
93 m_muonzResid->Fill(u.cross(m_direction).dot(m_direction.cross(Amg::Vector3D(0,0,1)).unit()));
94 m_muonphiResid->Fill(u.cross(m_direction).z());
95
96 m_zResid->Fill(u.cross(m_direction).dot(m_direction.cross(Amg::Vector3D(0,0,1)).unit()));
97 m_phiResid->Fill(u.cross(m_direction).z());
98 }
99 else {
100 m_muonzResid->Fill(0);
101 m_muonphiResid->Fill(0);
102 m_zResid->Fill(0);
103 m_phiResid->Fill(0);
104 }
105
106 return StatusCode::SUCCESS;
107}
108
109
110
112
113 CHECK(detStore()->retrieve(m_pMuonMgr));
114 ATH_CHECK (m_eventInfoKey.initialize());
115
116 //MuonSpectrometer
121
122 m_path+="Muon/";
123 // will only create new if not already registered (uses m_path)
124 _TH1D(m_muonevnt,"event_num",100,0.,1000.);
125 _TH1D(m_muonrun,"run_num",100,-300.,300.);
126
127 /*
128 TH1D *etamuon=new TH1D("muonhitpos_eta","muonhitpos_eta",50,-5.,5.);
129 registerHistogram("/truth/muonhitpos_eta",etamuon);
130
131 TH1D *theta=new TH1D("muonhitpos_theta","muonhitpos_theta",50,-10.,10.);
132 registerHistogram("/truth/muonhitpos_theta",theta);
133
134 TH1D *phimuon=new TH1D("muonhitpos_phi","muonhitpos_phi",50,-5.,5.);
135 registerHistogram("/truth/muonhitpos_phi",phimuon);
136 */
137
138 _TH1D(m_muonzResid,"muonhitpos_zResid",50,-300.,300.);
139 _TH1D(m_muonphiResid,"muonhitpos_phiResid",50,-300.,300.);
140
141 _TH2D(m_muondetBarrel,"muondet_barrel",200,-11000.,11000.,200,-11000.,11000.);
142 _TH2D(m_muonlongView,"muonlong_view",200,-24000.,24000.,200,0.,13000.);
143 // ================================================================================
144
145 m_path+=m_detname+"/";
146 // book Histograms
150 /*
151 TH1D *eta=new TH1D("hitpos_eta","hitpos_eta",50,-5.,5.);
152 registerHistogram("/truth/hitpos_eta",eta);
153
154 TH1D *theta=new TH1D("hitpos_theta","hitpos_theta",50,-10.,10.);
155 registerHistogram("/truth/hitpos_theta",theta);
156
157 TH1D *phi=new TH1D("hitpos_phi","hitpos_phi",50,-5.,5.);
158 registerHistogram("/truth/hitpos_phi",phi);
159 */
160 _TH1D(m_zResid,(m_detname+"_hitpos_zResid").c_str(),50,-300.,300.);
161 _TH1D(m_phiResid,(m_detname+"_hitpos_phiResid").c_str(),50,-300.,300.);
162
163 _TH2D(m_detBarrel,(m_detname+"_det_barrel").c_str(),200,-11000.,11000.,200,-11000.,11000.);
164 _TH2D(m_longView,(m_detname+"_long_view").c_str(),200,-24000.,24000.,200,0.,14000.);
165
166 return StatusCode::SUCCESS;
167
168}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
#define _TH2D(var, name, nbinx, xmin, xmax, nbiny, ymin, ymax)
#define _TH1D(var, name, nbin, xmin, xmax)
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
StatusCode executeFillHistos(const Amg::Vector3D &)
const MuonGM::MuonDetectorManager * m_pMuonMgr
double m_BarrelEtaCut
MDT barrel eta cut, applicable to the MDT 2D cross section plot.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG key for Event Info.
MuonHitTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::string m_path
std::string m_key
The MC truth key.
SimTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Eigen::Matrix< double, 3, 1 > Vector3D
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...