ATLAS Offline Software
CscClusterUtilTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CscClusterUtilTool.h"
6 
16 
17 using Muon::CscPrepData;
21 
22 //**********************************************************************
23 
24 CscClusterUtilTool::CscClusterUtilTool(const std::string& type, const std::string& aname, const IInterface* parent) :
25  AthAlgTool(type, aname, parent), m_phelper(nullptr), m_cscStripLocation("CSC_Measurements") {
26  declareInterface<ICscClusterUtilTool>(this);
27  declareProperty("CscStripPrepDataLocation", m_cscStripLocation);
28 }
29 
30 //**********************************************************************
31 
33  ATH_MSG_DEBUG("Initializing " << name());
34  ATH_MSG_DEBUG(" Strip fitter is " << m_stripFitter.typeAndName());
35  ATH_CHECK(m_cscStripLocation.initialize());
36  ATH_MSG_DEBUG(" CscStripPrepDataLocation is " << m_cscStripLocation.key());
37 
38  // Retrieve the strip fitting tool.
39  ATH_CHECK(m_stripFitter.retrieve());
40  ATH_MSG_DEBUG("Retrieved strip fitting tool " << m_stripFitter);
41 
42  // Retrieve the precision cluster fitting tool.
43  ATH_CHECK(m_precClusterFitter.retrieve());
44  ATH_MSG_DEBUG("Retrieved CSC precision cluster fitting tool");
45 
46  const MuonGM::MuonDetectorManager* muDetMgr = nullptr;
48  ATH_MSG_DEBUG("Retrieved geometry.");
49  m_phelper = muDetMgr->cscIdHelper();
50 
51  return StatusCode::SUCCESS;
52 }
53 
54 //**********************************************************************
56  if (!rot) {
57  ATH_MSG_WARNING(" Trk::RIO_OnTrack* rot is empty !");
58  return;
59  }
60  const Muon::CscClusterOnTrack* pclu = dynamic_cast<const Muon::CscClusterOnTrack*>(rot);
61  if (!pclu) {
62  ATH_MSG_WARNING(" Muon::CscClusterOnTrack* pclu is empty !");
63  return;
64  }
65  getStripFits(pclu, sfits);
66 }
67 
69  if (!pclu) {
70  ATH_MSG_WARNING(" Muon::CscClusterOnTrack* pclu is empty !");
71  return;
72  }
73  const Muon::CscPrepData* pprd = pclu->prepRawData();
74  if (!pprd) {
75  ATH_MSG_WARNING(" Muon::CscPrepData* pprd is empty !");
76  return;
77  }
78 
79  getStripFits(pprd, sfits);
80 }
83  if (!MClus) {
84  ATH_MSG_WARNING(" Muon::CscPrepData* pprd is empty !");
85  return;
86  }
87 
88  sfits.clear();
89 
90  std::vector<const CscStripPrepData*> strPrepDatas = getStrips(MClus);
91  for (unsigned int i = 0; i < strPrepDatas.size(); ++i) {
93  sfit = m_stripFitter->fit(*strPrepDatas[i]);
94  ATH_MSG_VERBOSE(" in loop charge " << sfit.charge);
95  // if (sfit.charge == 0.) // It's the case of narrow strips...in QratStripFitter
96  // sfit.charge = 40.; // 0 charge is set to minimal non zero to do fit e.g. dead channel case
97  sfits.push_back(sfit);
98  }
99  }
103  if (!MClus) {
104  ATH_MSG_WARNING(" Muon::CscPrepData* pprd is empty !");
105  return results;
106  }
107 
109  sfits.clear();
110 
111  getStripFits(MClus, sfits);
112  results = m_precClusterFitter->fit(sfits, tantheta);
113 
114  return results;
115 }
117 
118 std::vector<const CscStripPrepData*> CscClusterUtilTool::getStrips(const CscPrepData* MClus) const {
119  std::vector<const CscStripPrepData*> strips;
120  if (!MClus) {
121  ATH_MSG_WARNING(" Muon::CscPrepData* pprd is empty !");
122  return strips;
123  }
124 
125  const std::vector<Identifier> &prd_digit_ids = MClus->rdoList();
126 
128 
129  if (!pdigcont.isValid()) {
130  ATH_MSG_WARNING("Strip container " << m_cscStripLocation.key() << " not found in StoreGate!");
131  return strips;
132  }
133  ATH_MSG_DEBUG("Retrieved " << m_cscStripLocation.key() << " successfully. ");
134 
135  IdentifierHash elhash = MClus->collectionHash();
136  const auto *it = pdigcont->indexFindPtr(elhash);
137 
138  ATH_MSG_VERBOSE("Hash " << elhash << " converted to iterator of container successfully");
139 
140  if (it != nullptr) {
141  ATH_MSG_VERBOSE(" it == pdigcont.end() passed");
142  for (unsigned int istrip = 0; istrip < prd_digit_ids.size(); ++istrip) {
144  // Loop over digits and fill these arrays.
145  for (CscStripPrepDataCollection::const_iterator idig = col.begin(); idig != col.end(); ++idig) {
146  const CscStripPrepData& dig = **idig;
147  Identifier stid = dig.identify();
148  if (stid != prd_digit_ids[istrip]) continue;
149  const CscStripPrepData* pstrip = &dig;
150  ATH_MSG_VERBOSE("strip " << pstrip->timeOfFirstSample());
151 
152  strips.push_back(pstrip);
153  break;
154  }
155  }
156  }
157  return strips;
158 }
CscIdHelper.h
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CscStripPrepDataContainer.h
ICscClusterFitter::Results
std::vector< Result > Results
Definition: ICscClusterFitter.h:101
Muon::CscStripPrepDataCollection
MuonPrepDataCollection< CscStripPrepData > CscStripPrepDataCollection
Definition: MuonPrepDataCollection.h:111
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
skel.it
it
Definition: skel.GENtoEVGEN.py:423
ICscStripFitter::Result::charge
double charge
Definition: ICscStripFitter.h:31
Muon::MuonCluster::collectionHash
virtual IdentifierHash collectionHash() const
Returns the IdentifierHash corresponding to the PRD collection in the PRD container.
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonCluster.h:104
CscStripPrepDataCollection.h
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
ATH_CHECK_RECOVERABLE
#define ATH_CHECK_RECOVERABLE
Evaluate an expression and check for errors.
Definition: AthCheckMacros.h:48
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CscClusterUtilTool::CscClusterUtilTool
CscClusterUtilTool(const std::string &, const std::string &, const IInterface *)
Definition: CscClusterUtilTool.cxx:24
CscClusterUtilTool::m_stripFitter
ToolHandle< ICscStripFitter > m_stripFitter
Definition: CscClusterUtilTool.h:52
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
python.Dumpers.aname
string aname
Definition: Dumpers.py:5541
Muon::CscStripPrepData
Class representing the raw data of one CSC strip (for clusters look at Muon::CscPrepData).
Definition: CscStripPrepData.h:40
ICscClusterFitter.h
CscClusterUtilTool::getRefitCluster
ICscClusterFitter::Results getRefitCluster(const Muon::CscPrepData *MClus, double tantheta) const
Definition: CscClusterUtilTool.cxx:101
CscPrepData.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
Muon::CscPrepData
Class representing clusters from the CSC.
Definition: CscPrepData.h:39
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CscClusterOnTrack.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CscClusterUtilTool::initialize
StatusCode initialize()
Definition: CscClusterUtilTool.cxx:32
Muon::CscStripPrepDataContainer
MuonPrepDataContainerT< CscStripPrepData > CscStripPrepDataContainer
Definition: MuonPrepDataContainer.h:99
ICscStripFitter::Result
Definition: ICscStripFitter.h:25
CscClusterUtilTool::m_cscStripLocation
SG::ReadHandleKey< Muon::CscStripPrepDataContainer > m_cscStripLocation
Definition: CscClusterUtilTool.h:63
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CscClusterUtilTool::m_precClusterFitter
ToolHandle< ICscClusterFitter > m_precClusterFitter
Definition: CscClusterUtilTool.h:57
CscClusterUtilTool::getStripFits
void getStripFits(const Trk::RIO_OnTrack *rot, ICscClusterFitter::StripFitList &sfits) const
Definition: CscClusterUtilTool.cxx:55
CscClusterUtilTool::m_phelper
const CscIdHelper * m_phelper
Definition: CscClusterUtilTool.h:49
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
RIO_OnTrack.h
python.ami.results
def results
Definition: ami.py:386
query_example.col
col
Definition: query_example.py:7
MuonDetectorManager.h
Muon::CscClusterOnTrack::prepRawData
virtual const CscPrepData * prepRawData() const override final
Returns the CscPrepData - is a CscPrepData in this scope.
Definition: CscClusterOnTrack.h:154
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:292
CscClusterUtilTool::getStrips
std::vector< const Muon::CscStripPrepData * > getStrips(const Muon::CscPrepData *MClus) const
Definition: CscClusterUtilTool.cxx:118
Muon::CscClusterOnTrack
Class to represent the calibrated clusters created from CSC strips.
Definition: CscClusterOnTrack.h:47
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ICscStripFitter.h
CscClusterUtilTool.h
MuonGM::MuonDetectorManager::cscIdHelper
const CscIdHelper * cscIdHelper() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:224
ICscClusterFitter::StripFitList
std::vector< StripFit > StripFitList
Definition: ICscClusterFitter.h:40
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
Definition: IdentifierHash.h:38
Muon::CscStripPrepData::timeOfFirstSample
double timeOfFirstSample() const
return the time of the first sample
Definition: CscStripPrepData.h:168