ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Muon::ClusterTimeProjectionMMClusterBuilderTool Class Reference

#include <ClusterTimeProjectionMMClusterBuilderTool.h>

Inheritance diagram for Muon::ClusterTimeProjectionMMClusterBuilderTool:
Collaboration diagram for Muon::ClusterTimeProjectionMMClusterBuilderTool:

Public Types

using RIO_Author = MMClusterOnTrack::Author
 Refinement of the cluster position after the cluster calibration loop is ran with a complete external constraint (e.g. More...
 

Public Member Functions

 ClusterTimeProjectionMMClusterBuilderTool (const std::string &, const std::string &, const IInterface *)
 
virtual ~ClusterTimeProjectionMMClusterBuilderTool ()=default
 
StatusCode initialize () override
 
StatusCode getClusters (const EventContext &ctx, std::vector< Muon::MMPrepData > &&stripsVect, std::vector< std::unique_ptr< Muon::MMPrepData >> &clustersVect) const override
 Standard Interface to produce Micromega clusters from raw Input hits without external contstaint. More...
 
virtual RIO_Author getCalibratedClusterPosition (const EventContext &ctx, const std::vector< NSWCalib::CalibratedStrip > &calibratedStrips, const Amg::Vector3D &directionEstimate, Amg::Vector2D &clusterLocalPosition, Amg::MatrixX &covMatrix) const override
 
 DeclareInterfaceID (Muon::IMMClusterBuilderTool, 1, 0)
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

Private Types

using LaySortedPrds = std::array< std::vector< Muon::MMPrepData >, 8 >
 
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

LaySortedPrds sortHitsToLayer (std::vector< Muon::MMPrepData > &&MMprds) const
 
std::vector< std::vector< uint > > clusterLayer (const std::vector< Muon::MMPrepData > &MMPrdsPerLayer) const
 
std::pair< double, double > getClusterPositionPRD (const NswErrorCalibData &errorCalibDB, uint8_t author, const std::vector< NSWCalib::CalibratedStrip > &features, const Amg::Vector3D &thetaEstimate) const
 
StatusCode writeClusterPrd (const EventContext &ctx, const std::vector< Muon::MMPrepData > &constituents, const double clustersPosition, const double clustersPositionErrorSq, std::vector< std::unique_ptr< Muon::MMPrepData >> &mergedClust) const
 
uint channel (const Identifier &id) const
 
uint channel (const MMPrepData &strip) const
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 Muon Detector Descriptor. More...
 
SG::ReadCondHandleKey< NswErrorCalibDatam_uncertCalibKey
 
Gaudi::Property< bool > m_writeStripProperties {this, "writeStripProperties" , true}
 
Gaudi::Property< uintm_maxHoleSize {this, "maxHoleSize", 1}
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 17 of file ClusterTimeProjectionMMClusterBuilderTool.h.

Member Typedef Documentation

◆ LaySortedPrds

Definition at line 35 of file ClusterTimeProjectionMMClusterBuilderTool.h.

◆ RIO_Author

Refinement of the cluster position after the cluster calibration loop is ran with a complete external constraint (e.g.

from the track fit). The cluster local position and the associated covariance are updated during this procedure Returns the Author of the ClusterBuilderTool, in case that the calibrated strip passes all internal constraints of the ClusterBuilder, otherwise Unknown author is returned. In the latter case, the Cluster should not be transformed into a calibrated RIO object.

Parameters
ctxEventContext used for StoreGate access
calibratedStripsCluster constitutents after the calibration stage
directionEstimateEstimate of the direction given in the local frame
clusterLocalPositionVector to which the final cluster position is saved to
covMatrixUncertainty associated with the local position

Definition at line 48 of file IMMClusterBuilderTool.h.

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ClusterTimeProjectionMMClusterBuilderTool()

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

Definition at line 23 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

25  :
26  AthAlgTool(t, n, p) {
27  declareInterface<IMMClusterBuilderTool>(this);
28 }

◆ ~ClusterTimeProjectionMMClusterBuilderTool()

virtual Muon::ClusterTimeProjectionMMClusterBuilderTool::~ClusterTimeProjectionMMClusterBuilderTool ( )
virtualdefault

Member Function Documentation

◆ channel() [1/2]

uint Muon::ClusterTimeProjectionMMClusterBuilderTool::channel ( const Identifier id) const
inlineprivate

Definition at line 61 of file ClusterTimeProjectionMMClusterBuilderTool.h.

61 { return m_idHelperSvc->mmIdHelper().channel(id); }

◆ channel() [2/2]

uint Muon::ClusterTimeProjectionMMClusterBuilderTool::channel ( const MMPrepData strip) const
inlineprivate

Definition at line 62 of file ClusterTimeProjectionMMClusterBuilderTool.h.

62 { return channel(strip.identify()); }

◆ clusterLayer()

std::vector< std::vector< uint > > Muon::ClusterTimeProjectionMMClusterBuilderTool::clusterLayer ( const std::vector< Muon::MMPrepData > &  MMPrdsPerLayer) const
private

Definition at line 113 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

113  {
114 
115  const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
116  // get gas gap for later correction of the sign of the slope
117  int gasGap = idHelper.gasGap(MMPrdsPerLayer.at(0).identify());
118 
119  ATH_MSG_DEBUG("Scanning gas gap " << gasGap);
120  if (msgLvl(MSG::VERBOSE)) {
121  for (const auto& prd : MMPrdsPerLayer) {
122  ATH_MSG_DEBUG("Hit channel " << " " << m_idHelperSvc->toStringDetEl(prd.identify())
123  << " local positionX " << prd.localPosition().x() << " time " << prd.time()
124  << " corrected time " << prd.time() << " angle to IP "<< prd.globalPosition().theta() << " "
125  << prd.globalPosition().theta() / Gaudi::Units::degree);
126  }
127  }
128  std::vector<std::vector<uint>> idxClusters{};
129  // simple grouping of strips using the fact that the strips where ordered by channel
130  idxClusters.push_back(std::vector<uint>{0}); // assumes that mmPrdsPerLayer always has at least one strip
131  for (uint i_strip = 1; i_strip < MMPrdsPerLayer.size(); i_strip++) {
132  if (channel(MMPrdsPerLayer.at(i_strip)) - channel(MMPrdsPerLayer.at(i_strip - 1)) <= m_maxHoleSize + 1) {
133  idxClusters.back().push_back(i_strip);
134  } else {
135  idxClusters.push_back(std::vector<uint>{i_strip});
136  }
137  }
138  if (msgLvl(MSG::VERBOSE)) {
139  ATH_MSG_DEBUG("Found " << idxClusters.size() << " clusters");
140  for (const auto& idxCluster : idxClusters) { ATH_MSG_DEBUG("cluster: " << idxCluster); }
141  }
142  return idxClusters;
143 } // end of cluster layer

◆ declareGaudiProperty() [1/4]

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

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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

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

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

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

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ DeclareInterfaceID()

Muon::IMMClusterBuilderTool::DeclareInterfaceID ( Muon::IMMClusterBuilderTool  ,
,
 
)
inherited

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

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

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ 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.

95 { return m_detStore; }

◆ evtStore() [1/2]

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.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ 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

◆ getCalibratedClusterPosition()

RIO_Author Muon::ClusterTimeProjectionMMClusterBuilderTool::getCalibratedClusterPosition ( const EventContext &  ctx,
const std::vector< NSWCalib::CalibratedStrip > &  calibratedStrips,
const Amg::Vector3D directionEstimate,
Amg::Vector2D clusterLocalPosition,
Amg::MatrixX covMatrix 
) const
overridevirtual

Implements Muon::IMMClusterBuilderTool.

Definition at line 259 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

263  {
264 
266  if (!errorCalibDB.isValid()) {
267  ATH_MSG_FATAL("Failed to retrieve the parameterized errors "<<m_uncertCalibKey.fullKey());
268  return RIO_Author::unKnownAuthor;
269  }
270 
271  constexpr uint8_t toolAuthor = static_cast<uint8_t>(RIO_Author::ClusterTimeProjectionClusterBuilder);
272  std::pair<double, double> posAndErrorSq = getClusterPositionPRD(*errorCalibDB.cptr(), toolAuthor, calibratedStrips, directionEstimate);
273 
274  clusterLocalPosition[Trk::locX] = posAndErrorSq.first;
275  Amg::MatrixX covN(1, 1);
276  covN.coeffRef(0, 0) = posAndErrorSq.second;
277  covMatrix = covN;
278 
279  return RIO_Author::ClusterTimeProjectionClusterBuilder;
280 }

◆ getClusterPositionPRD()

std::pair< double, double > Muon::ClusterTimeProjectionMMClusterBuilderTool::getClusterPositionPRD ( const NswErrorCalibData errorCalibDB,
uint8_t  author,
const std::vector< NSWCalib::CalibratedStrip > &  features,
const Amg::Vector3D thetaEstimate 
) const
private

divide by 1000 to avoid overflow of variables

Definition at line 146 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

149  {
150 
151 
152  double clusterPosition{0}, clusterPositionErrorSq{0.};
153 
154  double qtot{0}, meanDriftDist{0.}, meanDriftDistError{0.};
155  double meanPosX{0.}, meanPosXError{0.};
156 
157  for (const NSWCalib::CalibratedStrip& clustFeat : constituents) {
158  const double driftDist = clustFeat.distDrift;
160  const double charge = clustFeat.charge * Gaudi::Units::perThousand;
161  const double chargeSq = std::pow(charge, 2);
162  qtot += charge;
163  meanPosX += clustFeat.locPos.x() * charge;
164  meanPosXError += clustFeat.resLongDistDrift * chargeSq;
165  meanDriftDist += driftDist * charge;
166  meanDriftDistError += clustFeat.resTransDistDrift * chargeSq;
167  ATH_MSG_VERBOSE("Strip:"<<m_idHelperSvc->toString(clustFeat.identifier)
168  << " drift dist " << driftDist << " +- " << std::sqrt(clustFeat.resTransDistDrift)
169  << " xpos: "<< clustFeat.locPos.x() << " +- " << std::sqrt(clustFeat.resLongDistDrift)
170  << " xMeanPos " << meanPosX / qtot << " +- " << std::sqrt(meanPosXError) / qtot
171  << " meanPosXError " << meanPosXError << " meanDriftDist " << meanDriftDist / qtot
172  << " meanDriftDist Error " << std::sqrt(meanDriftDistError) / qtot
173  << " charge " << charge << " qtot " << qtot);
174  }
175  meanPosX /= qtot;
176  double meanPosXErrorSq = meanPosXError / (qtot * qtot);
177  meanDriftDist /= qtot;
178  double meanDriftDistErrorSq = meanDriftDistError / (qtot * qtot);
179 
180  const double tanTheta = std::tan(dirEstimate.theta());
181  double correction = tanTheta * (meanDriftDist - halfGapWidth);
182  if (m_idHelperSvc->mmIdHelper().gasGap(constituents[0].identifier) % 2 == 0) {
183  correction = -1. * correction; // take care of inverted drif direction for even gaps
184  }
185  double correctionErrorSq = tanTheta * tanTheta * meanDriftDistErrorSq;
186 
187  clusterPosition = meanPosX + correction;
188  clusterPositionErrorSq = correctionErrorSq + meanPosXErrorSq;
189 
190 
191  NswErrorCalibData::Input errorCalibIn{};
192  errorCalibIn.stripId = constituents[0].identifier;
193  errorCalibIn.clusterAuthor = author;
194  errorCalibIn.locPhi = dirEstimate.phi();
195  errorCalibIn.locTheta = dirEstimate.theta();
196  errorCalibIn.localPos = Amg::Vector2D{clusterPosition, 0.};
197  errorCalibIn.clusterSize = constituents.size();
198 
199  const double localUncertainty = errorCalibDB.clusterUncertainty(errorCalibIn);
200 
201  ATH_MSG_DEBUG("Cluster Properties"
202  << " meanX " << meanPosX << " +-" << std::sqrt(meanPosXErrorSq) << " mean drift dist " << meanDriftDist << " +- "
203  << std::sqrt(meanDriftDistErrorSq) << " correction " << correction << " +- " << std::sqrt(correctionErrorSq)
204  << " final position " << clusterPosition << " +- " << std::sqrt(clusterPositionErrorSq));
205  return std::make_pair(clusterPosition, localUncertainty*localUncertainty);
206 }

◆ getClusters()

StatusCode Muon::ClusterTimeProjectionMMClusterBuilderTool::getClusters ( const EventContext &  ctx,
std::vector< Muon::MMPrepData > &&  stripsVect,
std::vector< std::unique_ptr< Muon::MMPrepData >> &  clustersVect 
) const
overridevirtual

Standard Interface to produce Micromega clusters from raw Input hits without external contstaint.

Executes the clusterization algorithm & fills the results in the clusterVect Returns a failure in case of conditions or unexpected problems

Parameters
ctxEventContext used for StoreGate access
stripsVectVector of the single Micromega hits.
clusterVectOutput vector of the merged clusters

Implements Muon::IMMClusterBuilderTool.

Definition at line 36 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

38  {
39  LaySortedPrds prdsPerLayer = sortHitsToLayer(std::move(MMprds));
40 
41 
42  for (std::vector<MMPrepData>& prdsOfLayer : prdsPerLayer) {
43  if (prdsOfLayer.size() < 2) continue; // require at least two strips per layer
44 
45  std::vector<std::vector<uint>> idxClusters = clusterLayer(prdsOfLayer);
46 
47  for (std::vector<uint>& clustIds : idxClusters) {
48  DEFINE_VECTOR(MMPrepData, clustConstituents, clustIds.size());
49  DEFINE_VECTOR(NSWCalib::CalibratedStrip, stripFeatures, clustIds.size());
50 
52  for (unsigned idx : clustIds) {
53  MMPrepData& toMerge{prdsOfLayer[idx]};
54 
55  const Amg::Vector3D lDir{NswClustering::toLocal(toMerge)};
56  const double q = toMerge.charge();
57 
58  clustDir += q * lDir;
59  NSWCalib::CalibratedStrip clusFeat{};
60  clusFeat.identifier = toMerge.identify();
61  clusFeat.locPos = toMerge.localPosition();
62  clusFeat.distDrift = toMerge.driftDist();
63  clusFeat.resTransDistDrift = toMerge.localCovariance()(0, 0);
64  clusFeat.resLongDistDrift = toMerge.localCovariance()(1, 1);
65  clusFeat.charge = q;
66 
67  stripFeatures.emplace_back(std::move(clusFeat));
68  clustConstituents.emplace_back(std::move(toMerge));
69  }
70 
72  if (!errorCalibDB.isValid()) {
73  ATH_MSG_FATAL("Failed to retrieve the parameterized errors "<<m_uncertCalibKey.fullKey());
74  return StatusCode::FAILURE;
75  }
76 
77  constexpr uint8_t toolAuthor = static_cast<uint8_t>(MMPrepData::Author::ClusterTimeProjectionClusterBuilder);
78  std::pair<double, double> posAndErrorSq = getClusterPositionPRD(**errorCalibDB,
79  toolAuthor,
80  stripFeatures,
81  clustDir.unit());
82 
83  ATH_CHECK(writeClusterPrd(ctx, clustConstituents, posAndErrorSq.first, posAndErrorSq.second, clustersVec));
84 
85  }
86  }
87  return StatusCode::SUCCESS;
88 }

◆ initialize()

StatusCode Muon::ClusterTimeProjectionMMClusterBuilderTool::initialize ( )
override

Definition at line 30 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

30  {
31  ATH_CHECK(m_idHelperSvc.retrieve());
33  return StatusCode::SUCCESS;
34 }

◆ 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() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

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

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ 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();
383  PBASE::renounce (h);
384  }

◆ 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  {
365  handlesArray.renounce();
366  }

◆ sortHitsToLayer()

ClusterTimeProjectionMMClusterBuilderTool::LaySortedPrds Muon::ClusterTimeProjectionMMClusterBuilderTool::sortHitsToLayer ( std::vector< Muon::MMPrepData > &&  MMprds) const
private

Definition at line 91 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

91  {
92 
93  LaySortedPrds prdsPerLayer{};
94  const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
95  // sorting hits by gas gap
96  for (MMPrepData& prd : MMprds) {
97  const Identifier id = prd.identify();
98  int layer = 4 * (idHelper.multilayer(id) - 1) + (idHelper.gasGap(id) - 1);
99  prdsPerLayer.at(layer).push_back(std::move(prd));
100  }
101  ATH_MSG_DEBUG("sorted hist");
102  // sort MMPrds by channel
103  for (std::vector<MMPrepData>& prdsInLay : prdsPerLayer) {
104  std::sort(prdsInLay.begin(), prdsInLay.end(), [&idHelper](const MMPrepData& a, const MMPrepData& b) {
105  return idHelper.channel(a.identify()) <
106  idHelper.channel(b.identify());
107  });
108  }
109  return prdsPerLayer;
110 }

◆ 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 DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ 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) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

◆ writeClusterPrd()

StatusCode Muon::ClusterTimeProjectionMMClusterBuilderTool::writeClusterPrd ( const EventContext &  ctx,
const std::vector< Muon::MMPrepData > &  constituents,
const double  clustersPosition,
const double  clustersPositionErrorSq,
std::vector< std::unique_ptr< Muon::MMPrepData >> &  mergedClust 
) const
private

Definition at line 208 of file ClusterTimeProjectionMMClusterBuilderTool.cxx.

212  {
213 
214  DEFINE_VECTOR(Identifier, rdoList, constituents.size());
215  DEFINE_VECTOR(int, stripCharges, constituents.size());
216  DEFINE_VECTOR(short int, stripTimes, constituents.size());
217  DEFINE_VECTOR(uint16_t, stripNumbers, constituents.size());
218  DEFINE_VECTOR(float, stripDriftDists, constituents.size());
219  DEFINE_VECTOR(AmgVector(2), stripDriftDistErrors, constituents.size());
220 
221  int totalCharge{0};
222  for (const Muon::MMPrepData& clustFeat : constituents) {
223  rdoList.push_back(clustFeat.identify());
224  stripNumbers.push_back(channel(clustFeat));
225  stripTimes.push_back(clustFeat.time());
226  stripCharges.push_back(clustFeat.charge());
227  stripDriftDists.push_back(clustFeat.driftDist());
228  const Amg::MatrixX cov{clustFeat.localCovariance()};
229  stripDriftDistErrors.emplace_back(cov(0,0), cov(1,1));
230  totalCharge += clustFeat.charge();
231  }
232  if (!m_writeStripProperties) { stripNumbers.clear(); }
233 
234  auto covN = Amg::MatrixX(1, 1);
235  covN.coeffRef(0, 0) = clusterPositionErrorSq;
236  Amg::Vector2D localClusterPositionV(clusterPosition, constituents[0].localPosition().y());
237  Identifier idStrip0 = constituents[0].identify();
238 
239  std::unique_ptr<MMPrepData> prdN = std::make_unique<MMPrepData>(idStrip0,
240  constituents[0].collectionHash(),
241  std::move(localClusterPositionV),
242  std::move(rdoList),
243  std::move(covN),
244  constituents[0].detectorElement(),
245  0, // drift dist
246  totalCharge,
247  0.0 /*drift dist*/,
248  std::move(stripNumbers),
249  std::move(stripTimes),
250  std::move(stripCharges));
251 
252  prdN->setDriftDist(std::move(stripDriftDists), std::move(stripDriftDistErrors));
254 
255  mergedClust.push_back(std::move(prdN));
256  return StatusCode::SUCCESS;
257 }

Member Data Documentation

◆ 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::ClusterTimeProjectionMMClusterBuilderTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Muon Detector Descriptor.

Definition at line 37 of file ClusterTimeProjectionMMClusterBuilderTool.h.

◆ m_maxHoleSize

Gaudi::Property<uint> Muon::ClusterTimeProjectionMMClusterBuilderTool::m_maxHoleSize {this, "maxHoleSize", 1}
private

Definition at line 44 of file ClusterTimeProjectionMMClusterBuilderTool.h.

◆ m_uncertCalibKey

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

Definition at line 40 of file ClusterTimeProjectionMMClusterBuilderTool.h.

◆ 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.

◆ m_writeStripProperties

Gaudi::Property<bool> Muon::ClusterTimeProjectionMMClusterBuilderTool::m_writeStripProperties {this, "writeStripProperties" , true}
private

Definition at line 43 of file ClusterTimeProjectionMMClusterBuilderTool.h.


The documentation for this class was generated from the following files:
dumpTgcDigiDeadChambers.gasGap
list gasGap
Definition: dumpTgcDigiDeadChambers.py:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Muon::MMPrepData
Class to represent MM measurements.
Definition: MMPrepData.h:22
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
Trk::PrepRawDataType::MMPrepData
@ MMPrepData
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Trk::locX
@ locX
Definition: ParamDefs.h:37
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DEFINE_VECTOR
#define DEFINE_VECTOR(dType, varName, nEles)
Definition: ClusterTimeProjectionMMClusterBuilderTool.cxx:13
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
keylayer_zslicemap.strip
strip
Definition: keylayer_zslicemap.py:151
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
Muon::ClusterTimeProjectionMMClusterBuilderTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Muon Detector Descriptor.
Definition: ClusterTimeProjectionMMClusterBuilderTool.h:37
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
Muon::ClusterTimeProjectionMMClusterBuilderTool::m_maxHoleSize
Gaudi::Property< uint > m_maxHoleSize
Definition: ClusterTimeProjectionMMClusterBuilderTool.h:44
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::covMatrix
covMatrix
Definition: TrackMeasurement_v1.cxx:19
AmgVector
AmgVector(4) T2BSTrackFilterTool
Definition: T2BSTrackFilterTool.cxx:114
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
python.SystemOfUnits.perThousand
float perThousand
Definition: SystemOfUnits.py:278
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
NswErrorCalibData::clusterUncertainty
double clusterUncertainty(const Input &clustInfo) const
Definition: NswErrorCalibData.cxx:96
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
NSWCalib::CalibratedStrip
Definition: INSWCalibTool.h:20
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
NswErrorCalibData::Input::stripId
Identifier stripId
Identifier of the strip.
Definition: NswErrorCalibData.h:27
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Muon::ClusterTimeProjectionMMClusterBuilderTool::channel
uint channel(const Identifier &id) const
Definition: ClusterTimeProjectionMMClusterBuilderTool.h:61
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Muon::ClusterTimeProjectionMMClusterBuilderTool::sortHitsToLayer
LaySortedPrds sortHitsToLayer(std::vector< Muon::MMPrepData > &&MMprds) const
Definition: ClusterTimeProjectionMMClusterBuilderTool.cxx:91
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Muon::MMPrepData::Author::ClusterTimeProjectionClusterBuilder
@ ClusterTimeProjectionClusterBuilder
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
Muon::ClusterTimeProjectionMMClusterBuilderTool::getClusterPositionPRD
std::pair< double, double > getClusterPositionPRD(const NswErrorCalibData &errorCalibDB, uint8_t author, const std::vector< NSWCalib::CalibratedStrip > &features, const Amg::Vector3D &thetaEstimate) const
Definition: ClusterTimeProjectionMMClusterBuilderTool.cxx:146
MmIdHelper
Definition: MmIdHelper.h:54
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
Muon::ClusterTimeProjectionMMClusterBuilderTool::clusterLayer
std::vector< std::vector< uint > > clusterLayer(const std::vector< Muon::MMPrepData > &MMPrdsPerLayer) const
Definition: ClusterTimeProjectionMMClusterBuilderTool.cxx:113
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
Muon::ClusterTimeProjectionMMClusterBuilderTool::m_uncertCalibKey
SG::ReadCondHandleKey< NswErrorCalibData > m_uncertCalibKey
Definition: ClusterTimeProjectionMMClusterBuilderTool.h:40
Muon::NswClustering::toLocal
Amg::Vector3D toLocal(const Trk::Surface &surf, const Amg::Vector3D &dir)
Rotates a direction vector into a local frame: x-axis : Parallell to the radial direction of the dete...
Definition: NswClusteringUtils.h:21
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
extractSporadic.q
list q
Definition: extractSporadic.py:98
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
NswErrorCalibData::Input
Helper struct to be parsed to the object to derive the specific error of the cluster.
Definition: NswErrorCalibData.h:25
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
Muon::ClusterTimeProjectionMMClusterBuilderTool::m_writeStripProperties
Gaudi::Property< bool > m_writeStripProperties
Definition: ClusterTimeProjectionMMClusterBuilderTool.h:43
Muon::ClusterTimeProjectionMMClusterBuilderTool::writeClusterPrd
StatusCode writeClusterPrd(const EventContext &ctx, const std::vector< Muon::MMPrepData > &constituents, const double clustersPosition, const double clustersPositionErrorSq, std::vector< std::unique_ptr< Muon::MMPrepData >> &mergedClust) const
Definition: ClusterTimeProjectionMMClusterBuilderTool.cxx:208
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
Muon::ClusterTimeProjectionMMClusterBuilderTool::LaySortedPrds
std::array< std::vector< Muon::MMPrepData >, 8 > LaySortedPrds
Definition: ClusterTimeProjectionMMClusterBuilderTool.h:35
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
fitman.k
k
Definition: fitman.py:528
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
NSWCalib::CalibratedStrip::identifier
Identifier identifier
Definition: INSWCalibTool.h:29
Identifier
Definition: IdentifierFieldParser.cxx:14