ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::CaruanaSTgcClusterBuilderTool Class Reference

#include <CaruanaSTgcClusterBuilderTool.h>

Inheritance diagram for Muon::CaruanaSTgcClusterBuilderTool:
Collaboration diagram for Muon::CaruanaSTgcClusterBuilderTool:

Public Member Functions

 CaruanaSTgcClusterBuilderTool (const std::string &, const std::string &, const IInterface *)
 Default constructor.
virtual ~CaruanaSTgcClusterBuilderTool ()=default
 Default destructor.
virtual StatusCode initialize ()
 standard initialize method
StatusCode getClusters (const EventContext &ctx, std::vector< Muon::sTgcPrepData > &&stripsVect, std::vector< std::unique_ptr< Muon::sTgcPrepData > > &clustersVect) const
 DeclareInterfaceID (Muon::ISTgcClusterBuilderTool, 1, 0)
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void dumpStrips (std::vector< Muon::sTgcPrepData > &stripsVect, std::vector< Muon::sTgcPrepData * > &clustersVect) const
 private functions
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< double > m_chargeCut {this, "ChargeCut", 0.}
Gaudi::Property< unsigned int > m_maxHoleSize {this, "maxHoleSize", 0}
Gaudi::Property< double > m_positionStripResolution {this,"positionStripResolution", 0.0949}
Gaudi::Property< double > m_angularStripResolution {this, "angularStripResolution", 0.305}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_DetectorManagerKey {this, "DetectorManagerKey", "MuonDetectorManager", "Key of input MuonDetectorManager condition data"}
SG::ReadCondHandleKey< NswErrorCalibDatam_uncertCalibKey
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 29 of file CaruanaSTgcClusterBuilderTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CaruanaSTgcClusterBuilderTool()

Muon::CaruanaSTgcClusterBuilderTool::CaruanaSTgcClusterBuilderTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Default constructor.

Definition at line 14 of file CaruanaSTgcClusterBuilderTool.cxx.

14 :
15 AthAlgTool(t,n,p)
16{
17}
AthAlgTool()
Default constructor:

◆ ~CaruanaSTgcClusterBuilderTool()

virtual Muon::CaruanaSTgcClusterBuilderTool::~CaruanaSTgcClusterBuilderTool ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ DeclareInterfaceID()

Muon::ISTgcClusterBuilderTool::DeclareInterfaceID ( Muon::ISTgcClusterBuilderTool ,
1 ,
0  )
inherited

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ dumpStrips()

void CaruanaSTgcClusterBuilderTool::dumpStrips ( std::vector< Muon::sTgcPrepData > & stripsVect,
std::vector< Muon::sTgcPrepData * > & clustersVect ) const
private

private functions

Dump cluster information.

Definition at line 166 of file CaruanaSTgcClusterBuilderTool.cxx.

168{
169
170 ATH_MSG_INFO("====> Dumping all strips: ");
171 for ( const auto& it : stripsVect ) {
172 Identifier stripId = it.identify();
173 ATH_MSG_INFO("Strip identifier: " << m_idHelperSvc->stgcIdHelper().show_to_string(stripId) );
174 }
175
176 ATH_MSG_INFO("Dumping all clusters: ");
177 for ( auto *it : clustersVect ) {
178 Identifier clusterId = it->identify();
179 ATH_MSG_INFO("***> New cluster identifier: " << m_idHelperSvc->stgcIdHelper().show_to_string(clusterId) );
180 ATH_MSG_INFO("Cluster size: " << it->rdoList().size() );
181 ATH_MSG_INFO("List of associated RDO's: ");
182
183 }
184
185 }
#define ATH_MSG_INFO(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getClusters()

StatusCode Muon::CaruanaSTgcClusterBuilderTool::getClusters ( const EventContext & ctx,
std::vector< Muon::sTgcPrepData > && stripsVect,
std::vector< std::unique_ptr< Muon::sTgcPrepData > > & clustersVect ) const
virtual

Implements Muon::ISTgcClusterBuilderTool.

Definition at line 30 of file CaruanaSTgcClusterBuilderTool.cxx.

33{
34
35 ATH_MSG_DEBUG("Size of the input vector: " << stripsVect.size());
36
37 if (stripsVect.empty()) {
38 ATH_MSG_DEBUG("Size of the channel vectors is zero");
39 return StatusCode::SUCCESS;
40 }
41
42 SG::ReadCondHandle<NswErrorCalibData> errorCalibDB{m_uncertCalibKey, ctx};
43 if (!errorCalibDB.isValid()) {
44 ATH_MSG_FATAL("Failed to retrieve the parameterized errors "<<m_uncertCalibKey.fullKey());
45 return StatusCode::FAILURE;
46 }
47
48 Muon::STgcClusterBuilderCommon stgcClusterCommon(m_idHelperSvc->stgcIdHelper(), **errorCalibDB);
49
50 // define the identifier hash
51 Identifier chanId = stripsVect.at(0).identify();
52 IdentifierHash hash = m_idHelperSvc->moduleHash(chanId);
53
54 int channelType = m_idHelperSvc->stgcIdHelper().channelType(stripsVect.at(0).identify());
55 double resolution = Amg::error(stripsVect.at(0).localCovariance(), Trk::locX);
56 ATH_MSG_DEBUG("ChannelType: " << channelType << " Single channel resolution: " << resolution);
57
58 // Separate hits by layer (using index = 0 to 7) and sort them
59 std::array<std::vector<Muon::sTgcPrepData>, 8> stgcPrdsPerLayer = stgcClusterCommon.sortSTGCPrdPerLayer(std::move(stripsVect));
60
61 SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_DetectorManagerKey, ctx};
62 if(!detManager.isValid()){
63 ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object");
64 return StatusCode::FAILURE;
65 }
66
67 // Loop over the 8 layers, from 0 to 7
68 for (std::vector<sTgcPrepData>& unmerged : stgcPrdsPerLayer) {
69 // Get the strip clusters of the layer.
70 std::vector<std::vector<Muon::sTgcPrepData>> layerClusters = stgcClusterCommon.findStripCluster(std::move(unmerged),
72
73 // Loop over the clusters of that gap
74 for (std::vector<Muon::sTgcPrepData>& cluster: layerClusters) {
76 std::vector<Identifier> rdoList;
77 //vectors to hold the properties of the elements of a cluster
78 std::vector<int> elementsCharge;
79 std::vector<short int> elementsTime;
80 std::vector<uint16_t> elementsChannel;
81 std::vector<double> elementsLocalPositions;
82 std::vector<Identifier> elementsIdentifier;
83 double posY = (cluster.at(0)).localPosition().y();
84
85 // loop on the strips and set the cluster weighted position and charge
86 for (const sTgcPrepData& it : cluster ){
87 rdoList.push_back(it.identify());
88 elementsCharge.push_back(it.charge());
89 elementsChannel.push_back(m_idHelperSvc->stgcIdHelper().channel(it.identify()));
90 elementsTime.push_back(it.time());
91 elementsLocalPositions.push_back(it.localPosition().x());
92 elementsIdentifier.push_back(it.identify());
93 }
94
95 // Use the Caruana method to reconstruct clusters, determining the cluster mean position and error.
96 // If the Caruana method fails at some point, the reconstruction reverts to the weighted average method.
97 Identifier clusterId;
98 double reconstructedPosX{0};
99 double sigmaSq{0};
100 std::optional<Muon::STgcClusterPosition> optStripCluster = stgcClusterCommon.caruanaGaussianFitting(cluster,
103 detManager.cptr());
104 if (optStripCluster.has_value()) {
105 clusterId = (*optStripCluster).getClusterId();
106 reconstructedPosX = (*optStripCluster).getMeanPosition();
107 sigmaSq = (*optStripCluster).getErrorSquared();
109 } else {
110 ATH_MSG_DEBUG("sTGC cluster reconstruction using the Caruana method failed, reversing to the weighted average");
111
112 // Fallback to the weighted average when the Caruana method fails
113 bool isStrip = (channelType == sTgcIdHelper::sTgcChannelTypes::Strip);
114 // Calculate the cluster position and error using the weighted average
115 std::optional<Muon::STgcClusterPosition> optClusterWA = stgcClusterCommon.weightedAverage(cluster, resolution, isStrip);
116 // Skip the cluster if the weighted average also fails
117 if (!optClusterWA) {
118 if (msgLvl(MSG::VERBOSE)) {
119 std::stringstream sstr{};
120 for (const Muon::sTgcPrepData& prd : cluster) {
121 sstr << m_idHelperSvc->stgcIdHelper().print_to_string(prd.identify())
122 << ", local pos: ("<< prd.localPosition().x() << "," << prd.localPosition().y()
123 << "), charge: " << prd.charge() << ", time: " << static_cast<int>(prd.time())
124 << std::endl;
125 }
126 ATH_MSG_VERBOSE("Reject invalid cluster..." << std::endl << std::endl << sstr.str());
127 }
128 continue;
129 }
131
132 clusterId = (*optClusterWA).getClusterId();
133 reconstructedPosX = (*optClusterWA).getMeanPosition();
134 sigmaSq = (*optClusterWA).getErrorSquared();
135 }
136
137 Amg::Vector2D localPosition(reconstructedPosX,posY);
138 auto covN = Amg::MatrixX(1,1);
139 covN(0,0) = sigmaSq;
140 ATH_MSG_DEBUG("Reconstructed a cluster at mean local position: "<< Amg::toString(localPosition,2)
141 << " with error on cluster: " << std::sqrt((covN)(0,0)));
142
143 std::unique_ptr<sTgcPrepData> prdN = std::make_unique<sTgcPrepData>(clusterId,
144 hash,
145 std::move(localPosition),
146 std::move(rdoList),
147 std::move(covN),
148 cluster.at(0).detectorElement(),
149 std::accumulate(elementsCharge.begin(), elementsCharge.end(), 0),
150 (short int)0,
151 std::move(elementsChannel),
152 std::move(elementsTime),
153 std::move(elementsCharge));
154 prdN->setAuthor(author);
155 clustersVect.push_back(std::move(prdN));
156 }
157 }
158
159 ATH_MSG_DEBUG("Size of the output cluster vector: " << clustersVect.size());
160
161 return StatusCode::SUCCESS;
162}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
SG::ReadCondHandleKey< NswErrorCalibData > m_uncertCalibKey
Gaudi::Property< unsigned int > m_maxHoleSize
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
const_pointer_type cptr()
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 2, 1 > Vector2D
double resolution[nGasTypes][nParametersResolution]
@ locX
Definition ParamDefs.h:37

◆ initialize()

StatusCode Muon::CaruanaSTgcClusterBuilderTool::initialize ( )
virtual

standard initialize method

Definition at line 19 of file CaruanaSTgcClusterBuilderTool.cxx.

20{
21 ATH_CHECK( m_idHelperSvc.retrieve() );
22 ATH_CHECK(m_DetectorManagerKey.initialize());
23 ATH_CHECK(m_uncertCalibKey.initialize());
24 return StatusCode::SUCCESS;
25}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_angularStripResolution

Gaudi::Property<double> Muon::CaruanaSTgcClusterBuilderTool::m_angularStripResolution {this, "angularStripResolution", 0.305}
private

Definition at line 53 of file CaruanaSTgcClusterBuilderTool.h.

53{this, "angularStripResolution", 0.305};

◆ m_chargeCut

Gaudi::Property<double> Muon::CaruanaSTgcClusterBuilderTool::m_chargeCut {this, "ChargeCut", 0.}
private

Definition at line 48 of file CaruanaSTgcClusterBuilderTool.h.

48{this, "ChargeCut", 0.};

◆ m_DetectorManagerKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> Muon::CaruanaSTgcClusterBuilderTool::m_DetectorManagerKey {this, "DetectorManagerKey", "MuonDetectorManager", "Key of input MuonDetectorManager condition data"}
private

Definition at line 56 of file CaruanaSTgcClusterBuilderTool.h.

56{this, "DetectorManagerKey", "MuonDetectorManager", "Key of input MuonDetectorManager condition data"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::CaruanaSTgcClusterBuilderTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 55 of file CaruanaSTgcClusterBuilderTool.h.

55{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_maxHoleSize

Gaudi::Property<unsigned int> Muon::CaruanaSTgcClusterBuilderTool::m_maxHoleSize {this, "maxHoleSize", 0}
private

Definition at line 49 of file CaruanaSTgcClusterBuilderTool.h.

49{this, "maxHoleSize", 0};

◆ m_positionStripResolution

Gaudi::Property<double> Muon::CaruanaSTgcClusterBuilderTool::m_positionStripResolution {this,"positionStripResolution", 0.0949}
private

Definition at line 52 of file CaruanaSTgcClusterBuilderTool.h.

52{this,"positionStripResolution", 0.0949};

◆ m_uncertCalibKey

SG::ReadCondHandleKey<NswErrorCalibData> Muon::CaruanaSTgcClusterBuilderTool::m_uncertCalibKey
private
Initial value:
{this, "ErrorCalibKey", "NswUncertData",
"Key of the parametrized NSW uncertainties"}

Definition at line 58 of file CaruanaSTgcClusterBuilderTool.h.

58 {this, "ErrorCalibKey", "NswUncertData",
59 "Key of the parametrized NSW uncertainties"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: