ATLAS Offline Software
sTGCPRDVariables.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 namespace MuonPRDTest {
10  sTGCPRDVariables::sTGCPRDVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
11  PrdTesterModule(tree, "PRD_sTGC", msglvl), m_key{container_name} {}
13 
14  bool sTGCPRDVariables::fill(const EventContext& ctx) {
15  m_externalPush = false;
16  ATH_MSG_DEBUG("do fillsTGCPRDVariables()");
17  const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
18  if (!MuonDetMgr) { return false; }
20  if (!stgcprdContainer.isValid()) {
21  ATH_MSG_FATAL("Failed to retrieve prd container " << m_key.fullKey());
22  return false;
23  }
24 
25  ATH_MSG_DEBUG("retrieved sTGC PRD Container with size " << stgcprdContainer->size());
26 
27  if (stgcprdContainer->size() == 0) ATH_MSG_DEBUG(" sTGC PRD Container empty ");
28  unsigned int n_PRD{0};
29  for(const Muon::sTgcPrepDataCollection* coll : *stgcprdContainer ) {
30  for (unsigned int item=0; item<coll->size(); item++) {
31  const Muon::sTgcPrepData* prd = coll->at(item);
32  Identifier Id = prd->identify();
33 
36 
38  if (!det) {
39  ATH_MSG_ERROR("The sTGC hit "<<idHelperSvc()->toString(Id)<<" does not have a detector element attached. That should actually never happen");
40  return false;
41  }
42 
44  Amg::Vector2D loc_pos(0., 0.);
45  det->surface(Id).globalToLocal(pos, Amg::Vector3D(0., 0., 0.), loc_pos);
46 
47  double err_x = prd->localCovariance()(0,0);
48  double err_y = ( prd->localCovariance().rows()==2)? prd->localCovariance()(1,1) : 0.;
49 
50  ATH_MSG_DEBUG( "sTgc PRD local pos.: x=" << std::setw(6) << std::setprecision(2) << loc_pos[0]
51  << ", ex=" << std::setw(6) << std::setprecision(2) << err_x
52  << ", y=" << std::setw(6) << std::setprecision(2) << loc_pos[1]
53  << ", ey=" << std::setw(6) << std::setprecision(2) << err_y );
54 
56 
61 
62  if(m_applyFilter && !m_filteredChamb.count(coll->identify())){
63  ATH_MSG_VERBOSE("Do not dump measurements from " << idHelperSvc()->toStringChamber(coll->identify()));
64  continue;
65  }
66  for(const Muon::sTgcPrepData* prd: *coll){
67  dump(*prd);
68  ++n_PRD;
69  }
70  }
71  }
72  m_NSWsTGC_nPRD = n_PRD;
73  ATH_MSG_DEBUG("finished fillsTGCPRDVariables()");
74  m_filteredPRDs.clear();
75  m_filteredChamb.clear();
76  return true;
77  }
78 
80  m_externalPush=true;
81  return dump(prd);
82  }
83 
85  m_applyFilter = true;
86  }
87 
89  m_applyFilter=true;
90  m_filteredChamb.insert(idHelperSvc()->chamberId(detEle.identify()));
91  }
92 
93  unsigned int sTGCPRDVariables::dump(const Muon::sTgcPrepData& prd){
94  const Identifier Id = prd.identify();
95 
96 
97  if (m_filteredPRDs.count(Id)) {
98  ATH_MSG_VERBOSE("The hit has already been added "<<idHelperSvc()->toString(Id));
99  return m_filteredPRDs.at(Id);
100  }
101 
104 
106 
109  det->surface(Id).globalToLocal(pos, Amg::Vector3D::Zero(), loc_pos);
110 
111  double err_x = prd.localCovariance()(0,0);
112  double err_y = prd.localCovariance().rows()==2 ? prd.localCovariance()(1,1) : 0.;
113 
114  ATH_MSG_DEBUG( "sTgc PRD local pos.: x=" << std::setw(6) << std::setprecision(2) << loc_pos[0]
115  << ", ex=" << std::setw(6) << std::setprecision(2) << err_x
116  << ", y=" << std::setw(6) << std::setprecision(2) << loc_pos[1]
117  << ", ey=" << std::setw(6) << std::setprecision(2) << err_y );
118 
120 
123 
124 
126 
127  // determine the time of the strip with the highest charge
128  short int prdTime = prd.time();
129  if(idHelperSvc()->stgcIdHelper().channelType(Id) == sTgcIdHelper::sTgcChannelTypes::Strip) {
130  int maxCharge{-SHRT_MAX};
131  std::vector<int> stripCharges = prd.stripCharges();
132  for (int i = 0; i < static_cast<int>(stripCharges.size()); ++i) {
133  if (stripCharges.at(i) > maxCharge) {
134  maxCharge = stripCharges.at(i);
135  prdTime = prd.stripTimes().at(i);
136  }
137  }
138  }
139  m_NSWsTGC_PRD_time.push_back(prdTime);
141 
145 
146  m_stgcAuthor.push_back(static_cast<uint8_t>(prd.author()));
147  m_stgcQuality.push_back(static_cast<uint8_t>(prd.quality()));
148 
149 
150  unsigned idx = m_filteredPRDs.size();
151  if (m_externalPush) {
152  m_filteredPRDs.insert(std::make_pair(Id, idx));
153  }
154 
155  return idx;
156  }
157 }
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_covMatrix_1_1
VectorBranch< double > & m_NSWsTGC_PRD_covMatrix_1_1
Definition: sTGCPRDVariables.h:50
MuonPRDTest::sTGCPRDVariables::declare_keys
bool declare_keys() override final
Definition: sTGCPRDVariables.cxx:12
MuonPRDTest::sTGCPRDVariables::dumpAllHitsInChamber
void dumpAllHitsInChamber(const MuonGM::sTgcReadoutElement &detEle)
Adds all hits in this particular chamber to the output n-tuple.
Definition: sTGCPRDVariables.cxx:88
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_stripCharge
MatrixBranch< int > & m_NSWsTGC_PRD_stripCharge
Definition: sTGCPRDVariables.h:58
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
sTgcReadoutElement.h
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonPRDTest::sTGCPRDVariables::m_filteredPRDs
std::unordered_map< Identifier, unsigned int > m_filteredPRDs
Set of particular chambers to be dumped.
Definition: sTGCPRDVariables.h:69
tree
TChain * tree
Definition: tile_monitor.h:30
MuonPRDTest::sTGCPRDVariables::m_externalPush
bool m_externalPush
Flag telling whether an external prd has been pushed.
Definition: sTGCPRDVariables.h:73
Trk::PrepRawData::localCovariance
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
MuonPRDTest::PrdTesterModule::getDetMgr
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
Definition: PrdTesterModule.cxx:16
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_covMatrix_2_2
VectorBranch< double > & m_NSWsTGC_PRD_covMatrix_2_2
Definition: sTGCPRDVariables.h:51
MuonVal::sTgcIdentifierBranch::push_back
void push_back(const Identifier &id) override final
Definition: IdentifierBranch.cxx:79
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_localPosY
VectorBranch< double > & m_NSWsTGC_PRD_localPosY
Definition: sTGCPRDVariables.h:48
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_charge
VectorBranch< int > & m_NSWsTGC_PRD_charge
Definition: sTGCPRDVariables.h:54
Muon::sTgcPrepData::author
Author author() const
Definition: sTgcPrepData.h:115
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonPRDTest::sTGCPRDVariables::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: sTGCPRDVariables.cxx:14
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_localPosX
VectorBranch< double > & m_NSWsTGC_PRD_localPosX
Definition: sTGCPRDVariables.h:47
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_stripChannel
MatrixBranch< uint16_t > & m_NSWsTGC_PRD_stripChannel
Definition: sTGCPRDVariables.h:60
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
Muon::sTgcPrepData::stripNumbers
const std::vector< uint16_t > & stripNumbers() const
returns the list of strip numbers
Definition: sTgcPrepData.h:158
Muon::sTgcPrepData::stripCharges
const std::vector< int > & stripCharges() const
returns the list of charges
Definition: sTgcPrepData.h:160
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_time
VectorBranch< short > & m_NSWsTGC_PRD_time
Definition: sTGCPRDVariables.h:55
MuonVal::MatrixBranch::push_back
void push_back(size_t i, const T &value)
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
lumiFormat.i
int i
Definition: lumiFormat.py:85
Muon::sTgcPrepData::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
Definition: sTgcPrepData.h:143
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGM::sTgcReadoutElement
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:30
MuonPRDTest::PrdTesterModule
Definition: PrdTesterModule.h:15
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_nStrips
VectorBranch< int > & m_NSWsTGC_PRD_nStrips
Definition: sTGCPRDVariables.h:56
MuonPRDTest::sTGCPRDVariables::m_applyFilter
bool m_applyFilter
Apply a filter to dump the prds.
Definition: sTGCPRDVariables.h:71
Muon::sTgcPrepData::time
short int time() const
Definition: sTgcPrepData.h:156
Muon::MuonPrepDataCollection
Template to hold collections of MuonPrepRawData objects.
Definition: MuonPrepDataCollection.h:46
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
MuonPRDTest::sTGCPRDVariables::push_back
unsigned int push_back(const Muon::sTgcPrepData &prd)
Adds a prd to the output tree.
Definition: sTGCPRDVariables.cxx:79
item
Definition: ItemListSvc.h:43
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Muon::sTgcPrepData::detectorElement
virtual const MuonGM::sTgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Definition: sTgcPrepData.h:139
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
MuonPRDTest::sTGCPRDVariables::m_filteredChamb
std::unordered_set< Identifier > m_filteredChamb
Set of chambers to be dumped.
Definition: sTGCPRDVariables.h:67
MuonGM::MuonReadoutElement::identify
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:184
MuonPRDTest
Definition: CSCDigitVariables.h:10
MuonPRDTest::PrdTesterModule::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: PrdTesterModule.cxx:15
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_stripTime
MatrixBranch< short > & m_NSWsTGC_PRD_stripTime
Definition: sTGCPRDVariables.h:59
MuonPRDTest::sTGCPRDVariables::dump
unsigned int dump(const Muon::sTgcPrepData &prd)
Definition: sTGCPRDVariables.cxx:93
MuonPRDTest::sTGCPRDVariables::m_stgcQuality
VectorBranch< uint8_t > & m_stgcQuality
Definition: sTGCPRDVariables.h:63
MuonPRDTest::sTGCPRDVariables::sTGCPRDVariables
sTGCPRDVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
Standard constructor taking the MuonTesterTree as parent The container name under which the MicroMega...
Definition: sTGCPRDVariables.cxx:10
sTGCPRDVariables.h
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_id
sTgcIdentifierBranch m_NSWsTGC_PRD_id
Definition: sTGCPRDVariables.h:52
MuonPRDTest::sTGCPRDVariables::m_key
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_key
Definition: sTGCPRDVariables.h:45
Muon::sTgcPrepData
Class to represent sTgc measurements.
Definition: sTgcPrepData.h:20
Muon::sTgcPrepData::quality
Quality quality() const
Definition: sTgcPrepData.h:112
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_PRD_globalPos
ThreeVectorBranch m_NSWsTGC_PRD_globalPos
Definition: sTGCPRDVariables.h:49
Muon::sTgcPrepData::charge
int charge() const
Returns the bcBitMap of this PRD bit2 for Previous BC, bit1 for Current BC, bit0 for Next BC.
Definition: sTgcPrepData.h:154
MuonPRDTest::sTGCPRDVariables::m_NSWsTGC_nPRD
ScalarBranch< unsigned int > & m_NSWsTGC_nPRD
Definition: sTGCPRDVariables.h:46
Muon::sTgcPrepData::stripTimes
const std::vector< short int > & stripTimes() const
returns the list of times
Definition: sTgcPrepData.h:159
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
MuonPRDTest::sTGCPRDVariables::m_stgcAuthor
VectorBranch< uint8_t > & m_stgcAuthor
Definition: sTGCPRDVariables.h:62
MuonPRDTest::sTGCPRDVariables::enableSeededDump
void enableSeededDump()
Dumps only hits which are marked by the dumpAllHitsInChamber method.
Definition: sTGCPRDVariables.cxx:84
Identifier
Definition: IdentifierFieldParser.cxx:14