ATLAS Offline Software
Loading...
Searching...
No Matches
CSCSDOVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
8namespace MuonPRDTest {
9 CscSDOVariables::CscSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
10 PrdTesterModule(tree, "CSC_SDO", msglvl), m_key{container_name} {}
11
13
14 bool CscSDOVariables::fill(const EventContext& ctx) {
15 ATH_MSG_DEBUG("do fill CscSDOVariable()");
16 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
17 if (!MuonDetMgr) { return false; }
18 SG::ReadHandle<CscSimDataCollection> cscSdoContainer{m_key, ctx};
19 if (!cscSdoContainer.isValid()) {
20 ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
21 return false;
22 }
23 unsigned int n_sdo{0};
24 for (const auto& coll : *cscSdoContainer) {
25 const Identifier& id = coll.first;
26 const CscSimData& csc_sdo = coll.second;
27 m_csc_sdo_id.push_back(id);
28
29 ATH_MSG_DEBUG("CSC SDO: " << idHelperSvc()->toString(id));
30
31 ATH_MSG_DEBUG( "Get the truth deposits from the SDO." );
32 std::vector<CscSimData::Deposit> deposits;
33 csc_sdo.deposits(deposits);
34
35 int truth_barcode = deposits[0].first.barcode();
36 double truth_localPosX = deposits[0].second.zpos();
37 double truth_localPosY = deposits[0].second.ypos();
38 double truth_charge = deposits[0].second.charge();
39
40 m_csc_sdo_word.push_back( csc_sdo.word() );
41
42 const MuonGM::CscReadoutElement* rdoEl = MuonDetMgr->getCscReadoutElement(id);
43 if (!rdoEl) {
44 ATH_MSG_ERROR("CSCSDOVariables::fillVariables() - Failed to retrieve CscReadoutElement for " << idHelperSvc()->toString(id));
45 return false;
46 }
47
48 Amg::Vector2D hit_on_surface(truth_localPosX, truth_localPosY);
49 Amg::Vector3D hit_gpos(0., 0., 0.);
50 rdoEl->surface(id).localToGlobal(hit_on_surface, Amg::Vector3D(0., 0., 0.), hit_gpos);
51
52 if ( rdoEl->surface(id).insideBounds(hit_on_surface,0.,0.) ){
53 m_csc_sdo_localPosX.push_back(truth_localPosX);
54 m_csc_sdo_localPosY.push_back(truth_localPosY);
55 }
56
57 if ( rdoEl->surface(id).isOnSurface(hit_gpos,true,0.,0.) ){
58 m_CSC_dig_globalPos.push_back(hit_gpos);
59 }
60
61 ATH_MSG_DEBUG("CSC SDO barcode=" << truth_barcode);
62 ATH_MSG_DEBUG("CSC SDO localPosX=" << std::setw(9) << std::setprecision(2) << truth_localPosX
63 << ", localPosY=" << std::setw(9) << std::setprecision(2) << truth_localPosY
64 << ", truth charge=" << std::setw(8) << std::setprecision(5) << truth_charge);
65
66 m_csc_sdo_barcode.push_back(truth_barcode);
67 m_csc_sdo_charge.push_back( truth_charge );
68
69 ++n_sdo;
70 }
71 m_csc_nsdo = n_sdo;
72
73 ATH_MSG_DEBUG("Processed " << n_sdo << " CSC SDOs");
74 return true;
75 }
76}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
int word() const
Definition CscSimData.h:63
void deposits(std::vector< Deposit > &deposits) const
Definition CscSimData.h:71
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
CscIdentifierBranch m_csc_sdo_id
ScalarBranch< unsigned int > & m_csc_nsdo
VectorBranch< int > & m_csc_sdo_word
VectorBranch< float > & m_csc_sdo_localPosY
CscSDOVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
ThreeVectorBranch m_CSC_dig_globalPos
bool declare_keys() override final
VectorBranch< int > & m_csc_sdo_barcode
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
VectorBranch< double > & m_csc_sdo_charge
VectorBranch< float > & m_csc_sdo_localPosX
SG::ReadHandleKey< CscSimDataCollection > m_key
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
const Muon::IMuonIdHelperSvc * idHelperSvc() const
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const override
This method calls the inside() method of the Bounds.
virtual bool isOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const override final
This method returns true if the GlobalPosition is on the Surface for both, within or without check of...
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D