ATLAS Offline Software
Loading...
Searching...
No Matches
MDTHitAnalysis.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MDTHitAnalysis.h"
6
7// Section of includes for MDT of the Muon Spectrometer tests
9
12#include "CLHEP/Vector/LorentzVector.h"
13
14#include "TH1.h"
15
16#include <algorithm>
17#include <math.h>
18#include <functional>
19#include <iostream>
20#include <stdio.h>
21
22
24 ATH_MSG_DEBUG( "Initializing MDTHitAnalysis" );
25 ATH_CHECK(m_readKey.initialize());
26
27
29 m_h_hits_x = new TH1D("h_hits_mdt_x","hits_x", 100,-25000, 25000);
30 m_h_hits_x->StatOverflows();
31 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_x->GetName(), m_h_hits_x));
32
33 m_h_hits_y = new TH1D("h_hits_mdt_y", "hits_y", 100,-25000,25000);
34 m_h_hits_y->StatOverflows();
35 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_y->GetName(), m_h_hits_y));
36
37 m_h_hits_z = new TH1D("h_hits_mdt_z", "hits_z", 100,-45000,45000);
38 m_h_hits_z->StatOverflows();
39 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_z->GetName(), m_h_hits_z));
40
41 m_h_hits_r = new TH1D("h_hits_mdt_r", "hits_r", 100,4000,26000);
42 m_h_hits_r->StatOverflows();
43 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_r->GetName(), m_h_hits_r));
44
45 m_h_xy = new TH2D("h_mdt_xy", "xy", 100,-25000.,25000.,100, -25000., 25000.);
46 m_h_xy->StatOverflows();
47 ATH_CHECK(histSvc()->regHist( m_path+m_h_xy->GetName(), m_h_xy));
48
49 m_h_zr = new TH2D("h_mdt_zr", "zr", 100,-45000.,45000.,100, 4000., 26000.);
50 m_h_zr->StatOverflows();
51 ATH_CHECK(histSvc()->regHist( m_path+m_h_zr->GetName(), m_h_zr));
52
53 m_h_hits_eta = new TH1D("h_hits_mdt_eta", "hits_eta", 100,-3.0,3.0);
54 m_h_hits_eta->StatOverflows();
55 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_eta->GetName(), m_h_hits_eta));
56
57 m_h_hits_phi = new TH1D("h_hits_mdt_phi", "hits_phi", 100,-3.2,3.2);
58 m_h_hits_phi->StatOverflows();
59 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_phi->GetName(), m_h_hits_phi));
60
61 m_h_hits_lx = new TH1D("h_hits_mdt_lx","hits_lx", 100,-20, 20);
62 m_h_hits_lx->StatOverflows();
63 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_lx->GetName(), m_h_hits_lx));
64
65 m_h_hits_ly = new TH1D("h_hits_mdt_ly", "hits_ly", 100,-20,20);
66 m_h_hits_ly->StatOverflows();
67 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_ly->GetName(), m_h_hits_ly));
68
69 m_h_hits_lz = new TH1D("h_hits_mdt_lz", "hits_lz", 100,-2000,2000);
70 m_h_hits_lz->StatOverflows();
71 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_lz->GetName(), m_h_hits_lz));
72
73 m_h_hits_driftR = new TH1D("h_hits_mdt_driftR", "hits_driftR", 100,0,15);
74 m_h_hits_driftR->StatOverflows();
75 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_driftR->GetName(), m_h_hits_driftR));
76
77 m_h_hits_time = new TH1D("h_hits_mdt_time","hits_time", 100,0, 150);
78 m_h_hits_time->StatOverflows();
79 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_time->GetName(), m_h_hits_time));
80
81 m_h_hits_edep = new TH1D("h_hits_mdt_edep", "hits_edep", 100,0,0.2);
82 m_h_hits_edep->StatOverflows();
83 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_edep->GetName(), m_h_hits_edep));
84
85 m_h_hits_kine = new TH1D("h_hits_mdt_kine", "hits_kine", 100,0,20000);
86 m_h_hits_kine->StatOverflows();
87 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_kine->GetName(), m_h_hits_kine));
88
89 m_h_hits_step = new TH1D("h_hits_mdt_step", "hits_step", 100,0,100);
90 m_h_hits_step->StatOverflows();
91 ATH_CHECK(histSvc()->regHist(m_path + m_h_hits_step->GetName(), m_h_hits_step));
92
93
94 return StatusCode::SUCCESS;
95}
96
97
99 ATH_MSG_DEBUG( "In MDTHitAnalysis::execute()" );
100
101 const EventContext& ctx{Gaudi::Hive::currentContext()};
102 const MDTSimHitCollection* mdt_container{nullptr};
103 ATH_CHECK(SG::get(mdt_container, m_readKey, ctx));
104 for (MDTSimHitCollection::const_iterator i_hit = mdt_container->begin(); i_hit != mdt_container->end(); ++i_hit) {
105 //MDTSimHitCollection::const_iterator i_hit;
106 //for(auto i_hit : *mdt_container){
107 GeoMDTHit ghit(*i_hit);
108 if (!ghit) continue;
109
111 m_h_hits_x->Fill(p.x());
112 m_h_hits_y->Fill(p.y());
113 m_h_hits_z->Fill(p.z());
114 m_h_hits_r->Fill(p.perp());
115 m_h_xy->Fill(p.x(), p.y());
116 m_h_zr->Fill(p.z(),p.perp());
117 m_h_hits_eta->Fill(p.eta());
118 m_h_hits_phi->Fill(p.phi());
119 m_h_hits_driftR->Fill((*i_hit).driftRadius());
120 m_h_hits_lx->Fill( (*i_hit).localPosition().x());
121 m_h_hits_ly->Fill( (*i_hit).localPosition().y());
122 m_h_hits_lz->Fill( (*i_hit).localPosition().z());
123 m_h_hits_edep->Fill((*i_hit).energyDeposit());
124 m_h_hits_time->Fill((*i_hit).globalTime());
125 m_h_hits_step->Fill((*i_hit).stepLength());
126 m_h_hits_kine->Fill((*i_hit).kineticEnergy());
127
128 }
129
130 return StatusCode::SUCCESS;
131}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
AtlasHitsVector< MDTSimHit > MDTSimHitCollection
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
CONT::const_iterator const_iterator
const_iterator begin() const
const_iterator end() const
Amg::Vector3D getGlobalPosition() const
Gaudi::Property< std::string > m_path
virtual StatusCode execute() override final
virtual StatusCode initialize() override final
TH1 * m_h_hits_x
Some variables.
SG::ReadHandleKey< MDTSimHitCollection > m_readKey
Eigen::Matrix< double, 3, 1 > Vector3D
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.