ATLAS Offline Software
Loading...
Searching...
No Matches
MDTHitsTestTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MDTHitsTestTool.h"
6
7#include "Identifier/Identifier.h"
8
10
13
16
19
21#include "CLHEP/Vector/LorentzVector.h"
22
23#include "GaudiKernel/NTuple.h"
24#include "GaudiKernel/SmartDataPtr.h"
25#include "GaudiKernel/IDataProviderSvc.h"
26#include "GaudiKernel/ITHistSvc.h"
27#include "GaudiKernel/INTupleSvc.h"
28
29#include "TH2D.h"
30#include "TTree.h"
31#include "TROOT.h"
32#include "TFile.h"
33#include "TF1.h"
34#include "TH1F.h"
35
36using namespace MuonGM;
37
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}
59
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}
81
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();
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;
121 }
122 }
123 }
124
125 return StatusCode::SUCCESS;
126}
127
128
131 // CHECK(detStore()->retrieve(m_pMuonMgr));
132 m_pMdtIdHelper = m_pMuonMgr->mdtIdHelper();
133 return StatusCode::SUCCESS;
134}
#define M_PI
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
int HitID
AtlasHitsVector< MDTSimHit > MDTSimHitCollection
Amg::Vector3D getGlobalPosition() const
StatusCode initialize()
StatusCode checkIdentifier(Identifier offid)
Identifier getIdentifier(HitID cschit)
const MdtIdHelper * m_pMdtIdHelper
StatusCode processEvent()
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
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
StatusCode executeFillHistos(const Amg::Vector3D &)
const MuonGM::MuonDetectorManager * m_pMuonMgr
virtual StatusCode initialize() override
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
Definition GeoMuonHits.h:27