ATLAS Offline Software
Loading...
Searching...
No Matches
MDTHitsTestTool Class Reference

#include <MDTHitsTestTool.h>

Inheritance diagram for MDTHitsTestTool:
Collaboration diagram for MDTHitsTestTool:

Public Member Functions

 MDTHitsTestTool (const std::string &type, const std::string &name, const IInterface *parent)
StatusCode initialize ()
StatusCode processEvent ()

Protected Member Functions

Identifier getIdentifier (HitID cschit)
StatusCode checkIdentifier (Identifier offid)
StatusCode executeCheckEventInfo ()
StatusCode executeFillHistos (const Amg::Vector3D &)
StatusCode executeFillHistosSectors_Wedge1 (const Amg::Vector3D &, std::string)
StatusCode executeFillHistosSectors_Wedge2 (const Amg::Vector3D &, std::string)
StatusCode executeFillHistos_sTGc (const Amg::Vector3D &, std::string)

Protected Attributes

std::string m_detname
const MuonGM::MuonDetectorManagerm_pMuonMgr
SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey {this, "EventInfo", "EventInfo", "EventInfo name"}
 SG key for Event Info.
double m_BarrelEtaCut
 MDT barrel eta cut, applicable to the MDT 2D cross section plot.
TH1 * m_muonevnt
TH1 * m_muonrun
TH1 * m_muoneta
TH1 * m_muontheta
TH1 * m_muonphi
TH1 * m_muonzResid
TH1 * m_muonphiResid
TH2 * m_muondetBarrel
TH2 * m_muonlongView
TH1 * m_eta
TH1 * m_theta
TH1 * m_phi
TH1 * m_zResid
TH1 * m_phiResid
TH2 * m_detBarrel
TH2 * m_longView
Amg::Vector3D m_direction
std::string m_path {"/truth/"}
ServiceHandle< ITHistSvc > m_histSvc {"THistSvc", "SimTestHisto"}

Private Attributes

bool m_DoMDTTest
const MdtIdHelperm_pMdtIdHelper

structors and AlgTool implementation

HepMC::ConstGenParticlePtr getPrimary ()
std::string m_key
 The MC truth key.

Detailed Description

Definition at line 15 of file MDTHitsTestTool.h.

Constructor & Destructor Documentation

◆ MDTHitsTestTool()

MDTHitsTestTool::MDTHitsTestTool ( const std::string & type,
const std::string & name,
const IInterface * parent )
inline

Definition at line 20 of file MDTHitsTestTool.h.

21 : MuonHitTestToolBase(type, name, parent),
23 {
24 declareProperty("DoMDTTest", m_DoMDTTest=true);
26 }
const MdtIdHelper * m_pMdtIdHelper
double m_BarrelEtaCut
MDT barrel eta cut, applicable to the MDT 2D cross section plot.
MuonHitTestToolBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ checkIdentifier()

StatusCode MDTHitsTestTool::checkIdentifier ( Identifier offid)
protected

Definition at line 60 of file MDTHitsTestTool.cxx.

60 {
61 const MuonGM::MdtReadoutElement* descriptor = m_pMuonMgr->getMdtReadoutElement(offid);
62 if (descriptor == NULL) {
63 ATH_MSG_FATAL("MDT readout element not found for Id = " << m_pMdtIdHelper->show_to_string(offid));
64 return StatusCode::FAILURE;
65 }
66
67 // Testing Sim to Offline ID conversion
68 Amg::Vector3D mdt_gPos = descriptor->tubePos(offid);
69 // double mdt_tube_pos = sqrt(mdt_gPos.perp()*mdt_gPos.perp()+mdt_gPos.z()*mdt_gPos.z());
70 double mdt_tube_phi = mdt_gPos.phi();
71 if (mdt_tube_phi < 0.) mdt_tube_phi += 2.*M_PI;
72 // double mdt_tube_perp = mdt_gPos.perp();
73 // double mdt_tube_z = mdt_gPos.z();
74 // double mdt_tube_cot = 1./tan(mdt_gPos.theta());
75 //Amg::Transform3D xf = descriptor->getMaterialGeom()->getAbsoluteTransform(); //FIXME in the future??
76 //*AS* Amg::Vector3D xU = xf*Amg::Vector3D((*i_hit).localPosition().x(),-(*i_hit).localPosition().z(), (*i_hit).localPosition().y());
77 //*AS*Amg::Vector3D gx = mdt_gPos + xU;
78
79 return StatusCode::SUCCESS;
80}
#define M_PI
#define ATH_MSG_FATAL(x)
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
const MuonGM::MuonDetectorManager * m_pMuonMgr
Eigen::Matrix< double, 3, 1 > Vector3D

◆ executeCheckEventInfo()

StatusCode MuonHitTestToolBase::executeCheckEventInfo ( )
protectedinherited

Definition at line 35 of file MuonHitTestToolBase.cxx.

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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
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.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG key for Event Info.
std::string m_key
The MC truth key.
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...
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ executeFillHistos()

StatusCode MuonHitTestToolBase::executeFillHistos ( const Amg::Vector3D & u)
protectedinherited

for MDTs that have barrel + endcap section, take only the barrel when plotting the xy-2d plot of the detector

Definition at line 70 of file MuonHitTestToolBase.cxx.

70 {
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}
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ executeFillHistos_sTGc()

StatusCode MuonHitTestToolBase::executeFillHistos_sTGc ( const Amg::Vector3D & ,
std::string  )
protectedinherited

◆ executeFillHistosSectors_Wedge1()

StatusCode MuonHitTestToolBase::executeFillHistosSectors_Wedge1 ( const Amg::Vector3D & ,
std::string  )
protectedinherited

◆ executeFillHistosSectors_Wedge2()

StatusCode MuonHitTestToolBase::executeFillHistosSectors_Wedge2 ( const Amg::Vector3D & ,
std::string  )
protectedinherited

◆ getIdentifier()

Identifier MDTHitsTestTool::getIdentifier ( HitID cschit)
protected

Definition at line 38 of file MDTHitsTestTool.cxx.

39{
40 const MdtHitIdHelper* mdthelper = MdtHitIdHelper::GetHelper(m_pMdtIdHelper->tubeMax());
41 std::string mdt_stname = mdthelper->GetStationName(mdthit);
42 int mdt_steta = mdthelper->GetZSector(mdthit);
43 int mdt_stphi = mdthelper->GetPhiSector(mdthit);
44 int mdt_ml = mdthelper->GetMultiLayer(mdthit);
45 int mdt_tl = mdthelper->GetLayer(mdthit);
46 int mdt_tube = mdthelper->GetTube(mdthit);
47
48 // Create the offline identifiers, fill them with hit info. Ready to be
49 // accessed and retrieve info. Currently not used in this code except
50 // for some checks.
51 Identifier offid = m_pMdtIdHelper->channelID(mdt_stname, mdt_steta, mdt_stphi,mdt_ml,mdt_tl,mdt_tube);
52 if (offid == 0){
53 ATH_MSG_FATAL("MDT: Cannot build a valid Identifier; skip ");
54 }
55
56 ATH_MSG_VERBOSE(" MDT: Offline Id "<<m_pMdtIdHelper->show_to_string(offid));
57 return offid;
58}
static const MdtHitIdHelper * GetHelper(unsigned int nTubes=78)
int GetPhiSector(const int &hid) const
int GetMultiLayer(const int &hid) const
std::string GetStationName(const int &hid) const
int GetZSector(const int &hid) const
int GetLayer(const int &hid) const
int GetTube(const int &hid) const

◆ getPrimary()

HepMC::ConstGenParticlePtr SimTestToolBase::getPrimary ( )
protectedinherited

Definition at line 20 of file SimTestToolBase.cxx.

21{
22 const McEventCollection* mcCollection;
23 if (evtStore()->retrieve(mcCollection,m_key).isSuccess()) {
25 for (e=mcCollection->begin();e!=mcCollection->end(); ++e) {
26 for (auto p : (**e)) {
28 return p;
29 }
30 }
31 }
32 }
33 return 0;
34}

◆ initialize()

StatusCode MDTHitsTestTool::initialize ( )
virtual

Reimplemented from MuonHitTestToolBase.

Definition at line 129 of file MDTHitsTestTool.cxx.

129 {
131 // CHECK(detStore()->retrieve(m_pMuonMgr));
132 m_pMdtIdHelper = m_pMuonMgr->mdtIdHelper();
133 return StatusCode::SUCCESS;
134}
virtual StatusCode initialize() override

◆ processEvent()

StatusCode MDTHitsTestTool::processEvent ( )

Definition at line 82 of file MDTHitsTestTool.cxx.

82 {
84
85 // MuonSpectrometer
86 // Get the generic MuonSpectrometer (MDT,RPC,CSC,TGC) histograms
87 // Short description:
88 // MuonSpectrometer cross section
89 // MuonSpectrometer longitudinal
90 // Number of events processed from truth
91 // Event specific run number
92 // Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MuonSpectrometer
93
94 // MDT
95 // Get the MDT histograms
96 // Short description:
97 // MuonSpectrometer MDT cross section (affected by m_BarrelEtaCut)
98 // MuonSpectrometer MDT longitudinal
99 // Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MDTs
100
101
102 if (m_DoMDTTest) {
103 const MDTSimHitCollection* p_collection = nullptr;
104 if (evtStore()->retrieve(p_collection,"MDT_Hits") == StatusCode::SUCCESS) {
105 for (const MDTSimHit& hit : *p_collection) {
106 // Check the Hits identifiers, access the functions that give:
107 // Station name, station eta, station phi, multilayer ID, layer ID, tube ID.
108 HitID mdthit= (hit).MDTid();
109 Identifier offid= getIdentifier(mdthit);
110 CHECK(checkIdentifier(offid));
111
112
113
114 // Check Hits
115 // For every hit within the event, get the global position Amg::Vector3D u and then retrieve all releveant info
116 // either from the Amg::Vector3D or from the MC vector (direction)
117 GeoMDTHit ghit(hit);
118 if (!ghit) continue;
119 Amg::Vector3D u = ghit.getGlobalPosition();
121 }
122 }
123 }
124
125 return StatusCode::SUCCESS;
126}
int HitID
AtlasHitsVector< MDTSimHit > MDTSimHitCollection
StatusCode checkIdentifier(Identifier offid)
Identifier getIdentifier(HitID cschit)
StatusCode executeFillHistos(const Amg::Vector3D &)

Member Data Documentation

◆ m_BarrelEtaCut

double MuonHitTestToolBase::m_BarrelEtaCut
protectedinherited

MDT barrel eta cut, applicable to the MDT 2D cross section plot.

Definition at line 44 of file MuonHitTestToolBase.h.

◆ m_detBarrel

TH2* MuonHitTestToolBase::m_detBarrel
protectedinherited

Definition at line 54 of file MuonHitTestToolBase.h.

◆ m_detname

std::string MuonHitTestToolBase::m_detname
protectedinherited

Definition at line 37 of file MuonHitTestToolBase.h.

◆ m_direction

Amg::Vector3D MuonHitTestToolBase::m_direction
protectedinherited

Definition at line 58 of file MuonHitTestToolBase.h.

◆ m_DoMDTTest

bool MDTHitsTestTool::m_DoMDTTest
private

Definition at line 37 of file MDTHitsTestTool.h.

◆ m_eta

TH1* MuonHitTestToolBase::m_eta
protectedinherited

Definition at line 52 of file MuonHitTestToolBase.h.

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> MuonHitTestToolBase::m_eventInfoKey {this, "EventInfo", "EventInfo", "EventInfo name"}
protectedinherited

SG key for Event Info.

Definition at line 41 of file MuonHitTestToolBase.h.

41{this, "EventInfo", "EventInfo", "EventInfo name"};

◆ m_histSvc

ServiceHandle<ITHistSvc> SimTestHisto::m_histSvc {"THistSvc", "SimTestHisto"}
protectedinherited

Definition at line 35 of file SimTestHisto.h.

35{"THistSvc", "SimTestHisto"};

◆ m_key

std::string SimTestToolBase::m_key
protectedinherited

The MC truth key.

Definition at line 34 of file SimTestToolBase.h.

◆ m_longView

TH2 * MuonHitTestToolBase::m_longView
protectedinherited

Definition at line 54 of file MuonHitTestToolBase.h.

◆ m_muondetBarrel

TH2* MuonHitTestToolBase::m_muondetBarrel
protectedinherited

Definition at line 50 of file MuonHitTestToolBase.h.

◆ m_muoneta

TH1* MuonHitTestToolBase::m_muoneta
protectedinherited

Definition at line 48 of file MuonHitTestToolBase.h.

◆ m_muonevnt

TH1* MuonHitTestToolBase::m_muonevnt
protectedinherited

Definition at line 47 of file MuonHitTestToolBase.h.

◆ m_muonlongView

TH2 * MuonHitTestToolBase::m_muonlongView
protectedinherited

Definition at line 50 of file MuonHitTestToolBase.h.

◆ m_muonphi

TH1 * MuonHitTestToolBase::m_muonphi
protectedinherited

Definition at line 48 of file MuonHitTestToolBase.h.

◆ m_muonphiResid

TH1 * MuonHitTestToolBase::m_muonphiResid
protectedinherited

Definition at line 49 of file MuonHitTestToolBase.h.

◆ m_muonrun

TH1 * MuonHitTestToolBase::m_muonrun
protectedinherited

Definition at line 47 of file MuonHitTestToolBase.h.

◆ m_muontheta

TH1 * MuonHitTestToolBase::m_muontheta
protectedinherited

Definition at line 48 of file MuonHitTestToolBase.h.

◆ m_muonzResid

TH1* MuonHitTestToolBase::m_muonzResid
protectedinherited

Definition at line 49 of file MuonHitTestToolBase.h.

◆ m_path

std::string SimTestHisto::m_path {"/truth/"}
protectedinherited

Definition at line 34 of file SimTestHisto.h.

34{"/truth/"};

◆ m_phi

TH1 * MuonHitTestToolBase::m_phi
protectedinherited

Definition at line 52 of file MuonHitTestToolBase.h.

◆ m_phiResid

TH1 * MuonHitTestToolBase::m_phiResid
protectedinherited

Definition at line 53 of file MuonHitTestToolBase.h.

◆ m_pMdtIdHelper

const MdtIdHelper* MDTHitsTestTool::m_pMdtIdHelper
private

Definition at line 39 of file MDTHitsTestTool.h.

◆ m_pMuonMgr

const MuonGM::MuonDetectorManager* MuonHitTestToolBase::m_pMuonMgr
protectedinherited

Definition at line 38 of file MuonHitTestToolBase.h.

◆ m_theta

TH1 * MuonHitTestToolBase::m_theta
protectedinherited

Definition at line 52 of file MuonHitTestToolBase.h.

◆ m_zResid

TH1* MuonHitTestToolBase::m_zResid
protectedinherited

Definition at line 53 of file MuonHitTestToolBase.h.


The documentation for this class was generated from the following files: