ATLAS Offline Software
CSCHitsTestTool.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 "CSCHitsTestTool.h"
6 
8 #include "CLHEP/Vector/LorentzVector.h"
9 
14 #include "MuonSimEvent/CSCSimHit.h"
17 
18 #include <TH1D.h>
19 #include <TH2D.h>
20 
21 
23  const CscHitIdHelper* cschelper = CscHitIdHelper::GetHelper();
24 
25  const std::string & csc_stname = cschelper->GetStationName(cschit);
26  int csc_steta = cschelper->GetZSector(cschit);
27  int csc_stphi = cschelper->GetPhiSector(cschit);
28  int csc_cl = cschelper->GetChamberLayer(cschit);
29  int csc_wl = cschelper->GetWireLayer(cschit);
30  int csc_measphi = 1;
31  int csc_strip = 1;
32 
33  // Create the offline identifiers, fill them with hit info. Ready to be
34  // accessed and retrieve info. Currently not used in this code except for
35  // some checks.
36  // ======================================================================
37  Identifier offid = m_pCscIdHelper->channelID(csc_stname, csc_steta,
38  csc_stphi, csc_cl, csc_wl,
39  csc_measphi, csc_strip);
40  if (offid == 0) {
41  ATH_MSG_FATAL("CSC: Cannot build a valid Identifier; skip ");
42  }
43  // *AS* really info level? perhaps debug or verbose?
44  ATH_MSG_VERBOSE(" CSC: Offline Id "<<m_pCscIdHelper->show_to_string(offid));
45  return offid;
46 }
47 
49  const MuonGM::CscReadoutElement* descriptor = m_pMuonMgr->getCscReadoutElement(offid);
50  if (!descriptor) {
51  ATH_MSG_FATAL("CSC readout element not found for Id = " << m_pCscIdHelper->show_to_string(offid));
52  return StatusCode::FAILURE;
53  }
54 
55  // Testing Sim to Offline ID conversion
56  Amg::Vector3D csc_gPos = descriptor->stripPos(offid);
57  double csc_strip_phi = csc_gPos.phi();
58  if (csc_strip_phi < 0.) csc_strip_phi += 2.*M_PI;
59  double csc_strip_perp __attribute ((unused)) = csc_gPos.perp();
60  double csc_strip_z __attribute ((unused)) = csc_gPos.z();
61  double csc_strip_cot __attribute ((unused)) = 1./tan(csc_gPos.theta());
62 
63  return StatusCode::SUCCESS;
64 }
65 
68 
69  // *AS* which direction is selected in the end?
70  // should match with truth particle using barcode (particleID)
71 
72  // MuonSpectrometer
73  // Get the generic MuonSpectrometer (MDT,RPC,CSC,TGC) histograms
74  // Short description:
75  // MuonSpectrometer cross section
76  // MuonSpectrometer longitudinal
77  // Number of events processed from truth
78  // Event specific run number
79  // Eta, Theta, Phi, z residual (...), phi residual (...) of hits in MuonSpectrometer
80 
81  // CSC
82  // Get the CSC histograms
83  // Short description:
84  // MuonSpectrometer RPC cross section
85  // MuonSpectrometer RPC longitudinal
86  // Eta, Theta, Phi, z residual (...), phi residual (...) of hits in CSCs
87 
88  if (m_DoCSCTest) {
89  // -- loop over CSC hit collection --
90  const CSCSimHitCollection* p_collection = nullptr;
91  if (evtStore()->retrieve(p_collection,"CSC_Hits") == StatusCode::SUCCESS) {
92  for (const CSCSimHit& hit : *p_collection) {
93 
94  // Check the Hits identifiers, access the functions that give:
95  // Station name, station eta, station phi, chamber layer, wire layer.
96  HitID cschit= hit.CSCid();
97  Identifier offid= getIdentifier(cschit);
98  CHECK(checkIdentifier(offid));
99 
100  // Check Hits. For every hit within the event, get the global position
101  // Amg::Vector3D u and then retrieve all releveant info either from the
102  // Amg::Vector3D or from the MC vector (direction)
103  GeoCSCHit ghit(hit);
104  if (!ghit) continue;
107  }
108  }
109  }
110 
111  return StatusCode::SUCCESS;
112 }
113 
115  // initialise general histograms
117 
119 
120  return StatusCode::SUCCESS;
121 }
CscIdHelper.h
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
GeoCSCHit
Definition: GeoMuonHits.h:129
MuonHitTestToolBase::executeCheckEventInfo
StatusCode executeCheckEventInfo()
Definition: MuonHitTestToolBase.cxx:35
CSCHitsTestTool::getIdentifier
Identifier getIdentifier(HitID)
Definition: CSCHitsTestTool.cxx:22
CSCSimHitCollection.h
CSCHitsTestTool::checkIdentifier
StatusCode checkIdentifier(Identifier)
Definition: CSCHitsTestTool.cxx:48
AtlasHitsVector
Definition: AtlasHitsVector.h:33
M_PI
#define M_PI
Definition: ActiveFraction.h:11
GeoMuonHits.h
MuonGM::CscReadoutElement
Definition: CscReadoutElement.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CscHitIdHelper::GetChamberLayer
int GetChamberLayer(const int &hid) const
Definition: CscHitIdHelper.cxx:78
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
CscHitIdHelper::GetPhiSector
int GetPhiSector(const int &hid) const
Definition: CscHitIdHelper.cxx:67
CscHitIdHelper::GetHelper
static const CscHitIdHelper * GetHelper()
Definition: CscHitIdHelper.cxx:23
CSCSimHit
Definition: CSCSimHit.h:18
McEventCollection.h
MuonGM::MuonDetectorManager::getCscReadoutElement
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:225
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CscHitIdHelper
Definition: CscHitIdHelper.h:13
CscReadoutElement.h
CscHitIdHelper::GetWireLayer
int GetWireLayer(const int &hid) const
Definition: CscHitIdHelper.cxx:83
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
CSCHitsTestTool::processEvent
StatusCode processEvent()
Definition: CSCHitsTestTool.cxx:66
CSCHitsTestTool::m_pCscIdHelper
const CscIdHelper * m_pCscIdHelper
Definition: CSCHitsTestTool.h:36
CscHitIdHelper.h
CSCHitsTestTool::m_DoCSCTest
bool m_DoCSCTest
Definition: CSCHitsTestTool.h:34
CSCSimHit.h
CscIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer, int measuresPhi, int strip) const
Definition: CscIdHelper.cxx:706
CSCHitsTestTool::initialize
StatusCode initialize()
Definition: CSCHitsTestTool.cxx:114
GeoCSCHit::getGlobalPosition
Amg::Vector3D getGlobalPosition() const
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonHitTestToolBase::executeFillHistos
StatusCode executeFillHistos(const Amg::Vector3D &)
Definition: MuonHitTestToolBase.cxx:70
MuonDetectorManager.h
CscHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: CscHitIdHelper.cxx:56
CscHitIdHelper::GetZSector
int GetZSector(const int &hid) const
Definition: CscHitIdHelper.cxx:72
unused
void unused(Args &&...)
Definition: VP1ExpertSettings.cxx:39
CSCHitsTestTool.h
MuonHitTestToolBase::initialize
virtual StatusCode initialize() override
Definition: MuonHitTestToolBase.cxx:111
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
MuonHitTestToolBase::m_pMuonMgr
const MuonGM::MuonDetectorManager * m_pMuonMgr
Definition: MuonHitTestToolBase.h:38
MuonGM::CscReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
takes into account internal alignment parameters, hence gives accurate answer
Definition: CscReadoutElement.cxx:227
MuonGM::MuonDetectorManager::cscIdHelper
const CscIdHelper * cscIdHelper() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:224
HitID
int HitID
Definition: GenericMuonSimHit.h:13