ATLAS Offline Software
CSCSDOVariables.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 namespace MuonPRDTest {
9  CscSDOVariables::CscSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
10  PrdTesterModule(tree, "CSC_SDO", false, 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;
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.) ){
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 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonPRDTest::CscSDOVariables::m_csc_sdo_charge
VectorBranch< double > & m_csc_sdo_charge
Definition: CSCSDOVariables.h:28
MuonPRDTest::CscSDOVariables::m_csc_sdo_localPosX
VectorBranch< float > & m_csc_sdo_localPosX
Definition: CSCSDOVariables.h:31
MuonPRDTest::CscSDOVariables::fill
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...
Definition: CSCSDOVariables.cxx:14
MuonPRDTest::CscSDOVariables::m_csc_sdo_localPosY
VectorBranch< float > & m_csc_sdo_localPosY
Definition: CSCSDOVariables.h:32
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonVal::CscIdentifierBranch::push_back
void push_back(const Identifier &id) override final
Definition: IdentifierBranch.cxx:52
CscSimDataCollection.h
tree
TChain * tree
Definition: tile_monitor.h:30
MuonPRDTest::PrdTesterModule::getDetMgr
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
Definition: PrdTesterModule.cxx:15
CSCSDOVariables.h
MuonGM::CscReadoutElement
Definition: CscReadoutElement.h:56
MuonGM::MuonClusterReadoutElement::surface
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
Definition: MuonClusterReadoutElement.h:123
MuonPRDTest::CscSDOVariables::m_csc_sdo_barcode
VectorBranch< int > & m_csc_sdo_barcode
Definition: CSCSDOVariables.h:27
CscSimData::word
int word() const
Definition: CscSimData.h:63
MuonPRDTest::CscSDOVariables::m_csc_sdo_id
CscIdentifierBranch m_csc_sdo_id
Definition: CSCSDOVariables.h:25
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonVal::ThreeVectorBranch::push_back
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
Definition: ThreeVectorBranch.cxx:23
MuonPRDTest::CscSDOVariables::m_key
SG::ReadHandleKey< CscSimDataCollection > m_key
Definition: CSCSDOVariables.h:22
Trk::PlaneSurface::insideBounds
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const override
This method calls the inside() method of the Bounds.
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
CscSimData
Definition: CscSimData.h:44
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonPRDTest::PrdTesterModule
Definition: PrdTesterModule.h:15
CscReadoutElement.h
CscSimData::deposits
void deposits(std::vector< Deposit > &deposits) const
Definition: CscSimData.h:71
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonPRDTest::CscSDOVariables::m_CSC_dig_globalPos
ThreeVectorBranch m_CSC_dig_globalPos
Definition: CSCSDOVariables.h:30
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonPRDTest::CscSDOVariables::m_csc_sdo_word
VectorBranch< int > & m_csc_sdo_word
Definition: CSCSDOVariables.h:26
MuonPRDTest::CscSDOVariables::m_csc_nsdo
ScalarBranch< unsigned int > & m_csc_nsdo
Definition: CSCSDOVariables.h:24
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
MuonPRDTest
Definition: CSCDigitVariables.h:10
MuonPRDTest::PrdTesterModule::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: PrdTesterModule.cxx:14
MuonPRDTest::CscSDOVariables::CscSDOVariables
CscSDOVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
Definition: CSCSDOVariables.cxx:9
Trk::PlaneSurface::localToGlobal
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.
Definition: PlaneSurface.cxx:204
Trk::PlaneSurface::isOnSurface
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...
Definition: PlaneSurface.cxx:268
MuonPRDTest::CscSDOVariables::declare_keys
bool declare_keys() override final
Definition: CSCSDOVariables.cxx:12