ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::StripClusteringTool Class Reference

#include <StripClusteringTool.h>

Inheritance diagram for ActsTrk::StripClusteringTool:
Collaboration diagram for ActsTrk::StripClusteringTool:

Public Types

using StripRDORawData = SCT_RDORawData
using StripID = SCT_ID

Public Member Functions

 StripClusteringTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual StatusCode clusterize (const EventContext &ctx, const InDetRawDataCollection< StripRDORawData > &RDOs, const InDet::SiDetectorElementStatus &stripDetElStatus, const InDetDD::SiDetectorElement &element, Acts::Ccl::ClusteringData &data, std::vector< typename IStripClusteringTool::ClusterCollection > &collection) const override
virtual std::any makeVars (SG::AuxVectorData &) const override
virtual StatusCode makeClusters (const EventContext &ctx, typename IStripClusteringTool::ClusterCollection &cluster, const InDetDD::SiDetectorElement &element, size_t icluster, std::any &vars, typename ClusterContainer::iterator itrContainer) const override

Private Member Functions

std::optional< std::pair< typename IStripClusteringTool::CellCollection, bool > > unpackRDOs (const EventContext &ctx, const RawDataCollection &RDOs, const InDet::SiDetectorElementStatus &stripDetElStatus, const InDetDD::SiDetectorElement &element) const
bool passTiming (const std::bitset< 3 > &timePattern) const
StatusCode decodeTimeBins ()
bool isBadStrip (const EventContext &ctx, const InDet::SiDetectorElementStatus *sctDetElStatus, const StripID &idHelper, IdentifierHash waferHash, Identifier stripId) const
StatusCode makeCluster (StripClusteringTool::Cluster &cluster, double LorentzShift, Eigen::Matrix< float, 1, 1 > &localCov, const StripID &stripID, const InDetDD::SiDetectorElement &element, const InDetDD::SiDetectorDesign &design, xAOD::StripCluster &container) const

Private Attributes

StringProperty m_timeBinStr {this, "timeBins", ""}
ToolHandle< ISiLorentzAngleToolm_lorentzAngleTool
SG::ReadHandleKey< InDet::SiDetectorElementStatusm_stripDetElStatus
ToolHandle< IInDetConditionsToolm_conditionsTool
Gaudi::Property< bool > m_checkBadModules
Gaudi::Property< unsigned int > m_maxFiredStrips
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollectionm_stripDetEleCollKey
Gaudi::Property< bool > m_isITk
Gaudi::Property< unsigned int > m_errorStrategy {this, "errorStrategy", 0, "Use different error strategies for the strip clusters"}
int m_timeBinBits [3] {-1, -1, -1}
const StripIDm_stripID {nullptr}

Detailed Description

Definition at line 26 of file StripClusteringTool.h.

Member Typedef Documentation

◆ StripID

◆ StripRDORawData

Constructor & Destructor Documentation

◆ StripClusteringTool()

ActsTrk::StripClusteringTool::StripClusteringTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 49 of file StripClusteringTool.cxx.

51 : base_class(type,name,parent)
52{
53}

Member Function Documentation

◆ clusterize()

StatusCode ActsTrk::StripClusteringTool::clusterize ( const EventContext & ctx,
const InDetRawDataCollection< StripRDORawData > & RDOs,
const InDet::SiDetectorElementStatus & stripDetElStatus,
const InDetDD::SiDetectorElement & element,
Acts::Ccl::ClusteringData & data,
std::vector< typename IStripClusteringTool::ClusterCollection > & collection ) const
overridevirtual

Definition at line 99 of file StripClusteringTool.cxx.

105{
106 IdentifierHash idHash = RDOs.identifyHash();
107 // At least an empty cluster collection needs to be always added because the
108 // assumption is that there is one element per element RawDataCollection.
109 collection.emplace_back();
110 bool goodModule = true;
111 if (m_checkBadModules.value()) {
112 goodModule = stripDetElStatus.isGood(idHash);
113 }
114
116 m_checkBadModules.value() && !m_stripDetElStatus.empty(),
117 stripDetElStatus.isGood(idHash), m_conditionsTool->isGood(idHash));
118
119 if (!goodModule) {
120 ATH_MSG_DEBUG("Strip module failed status check");
121 return StatusCode::SUCCESS;
122 }
123
124 // If more than a certain number of RDOs set module to bad
125 // in this case we skip clusterization
126 if (m_maxFiredStrips != 0u) {
127 unsigned int nFiredStrips = 0u;
128 for (const SCT_RDORawData* rdo : RDOs) {
129 nFiredStrips += rdo->getGroupSize();
130 }
131 if (nFiredStrips > m_maxFiredStrips)
132 return StatusCode::SUCCESS;
133 }
134
135 std::optional<std::pair<typename IStripClusteringTool::CellCollection,bool>> unpckd
136 = unpackRDOs(ctx, RDOs, stripDetElStatus, element);
137
138 if (not unpckd.has_value()) {
139 ATH_MSG_FATAL("Error encountered while unpacking strip RDOs!");
140 return StatusCode::FAILURE;
141 }
142
143 auto& [cells, badStripOnModule] = *unpckd;
144 // Bad strips on a module invalidates the hitsInThirdTimeBin word.
145 // Therefore set it to 0 if that's the case.
146 // We are currently not using this, but keeping it here should we need it in the future
147
148 Acts::Ccl::createClusters<CellCollection, typename IStripClusteringTool::ClusterCollection, 1>(data, cells, collection.back());
149
150 return StatusCode::SUCCESS;
151}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define VALIDATE_STATUS_ARRAY(use_info, info_val, summary_val)
ToolHandle< IInDetConditionsTool > m_conditionsTool
Gaudi::Property< unsigned int > m_maxFiredStrips
Gaudi::Property< bool > m_checkBadModules
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_stripDetElStatus
std::optional< std::pair< typename IStripClusteringTool::CellCollection, bool > > unpackRDOs(const EventContext &ctx, const RawDataCollection &RDOs, const InDet::SiDetectorElementStatus &stripDetElStatus, const InDetDD::SiDetectorElement &element) const
virtual IdentifierHash identifyHash() const override final
bool isGood(IdentifierHash hash) const
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ decodeTimeBins()

StatusCode ActsTrk::StripClusteringTool::decodeTimeBins ( )
private

Definition at line 79 of file StripClusteringTool.cxx.

80{
81 for (size_t i = 0; i < m_timeBinStr.size(); i++) {
82 if (i >= 3) {
83 ATH_MSG_WARNING("Time bin string has excess characters");
84 break;
85 }
86 switch (std::toupper(m_timeBinStr[i])) {
87 case 'X': m_timeBinBits[i] = -1; break;
88 case '0': m_timeBinBits[i] = 0; break;
89 case '1': m_timeBinBits[i] = 1; break;
90 default:
91 ATH_MSG_FATAL("Invalid time bin string: " << m_timeBinStr);
92 return StatusCode::FAILURE;
93 }
94 }
95 return StatusCode::SUCCESS;
96}
#define ATH_MSG_WARNING(x)

◆ initialize()

StatusCode ActsTrk::StripClusteringTool::initialize ( )
overridevirtual

Definition at line 55 of file StripClusteringTool.cxx.

56{
57 ATH_MSG_DEBUG("Initializing " << name() << "...");
58
65
66
67 ATH_CHECK(m_conditionsTool.retrieve(DisableTool{!m_stripDetElStatus.empty()} ));
68 ATH_CHECK(m_lorentzAngleTool.retrieve());
70
71 ATH_CHECK(m_stripDetElStatus.initialize(not m_stripDetElStatus.empty()));
72 ATH_CHECK(m_stripDetEleCollKey.initialize());
73
74 ATH_CHECK( detStore()->retrieve(m_stripID, "SCT_ID") );
75
76 return StatusCode::SUCCESS;
77}
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Property< bool > m_isITk
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_stripDetEleCollKey
Gaudi::Property< unsigned int > m_errorStrategy

◆ isBadStrip()

bool ActsTrk::StripClusteringTool::isBadStrip ( const EventContext & ctx,
const InDet::SiDetectorElementStatus * sctDetElStatus,
const StripID & idHelper,
IdentifierHash waferHash,
Identifier stripId ) const
private

Definition at line 365 of file StripClusteringTool.cxx.

370{
371 if (stripDetElStatus) {
372 const int strip_i{stripID.strip(stripId)};
374 stripDetElStatus,
375 stripDetElStatus->isCellGood(waferHash.value(), strip_i),
377 return not stripDetElStatus->isCellGood(waferHash.value(), strip_i) ;
378 }
379 return not m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP, ctx);
380}
constexpr value_type value() const

◆ makeCluster()

StatusCode ActsTrk::StripClusteringTool::makeCluster ( StripClusteringTool::Cluster & cluster,
double LorentzShift,
Eigen::Matrix< float, 1, 1 > & localCov,
const StripID & stripID,
const InDetDD::SiDetectorElement & element,
const InDetDD::SiDetectorDesign & design,
xAOD::StripCluster & container ) const
private

Definition at line 300 of file StripClusteringTool.cxx.

307{
308 std::size_t size = cluster.ids.size();
309
310 auto [localPos, globalPos]
311 = computePosition(cluster, size, lorentzShift, stripID, element, design, m_isITk);
312
313 // For Strip Clusters the identifier is taken from the front rod list object
314 // This is the same strategy used in Athena:
315 // Since clusterId is arbitary (it only needs to be unique) just use ID of first strip
316 // For strip Cluster it has been found that "identifierOfPosition" does not produces unique values
317
318
319 // If requiring broad errors, use the cluster size as error -
320 // TODO use SiWidth to get the right cluster size as I'm assuming equal strip pitch
321
322 if (m_errorStrategy == 1) {// use width
323
324 localCov *= size*size;
325
326 } else if (m_errorStrategy == 2) { //use tuned error as function of size
327
328 if (size == 1)
329 localCov *= oneStripSF;
330 else if (size == 2)
331 localCov *= twoStripSF*size*size;
332 else
333 localCov *= size*size;
334
335 }
336
337 if (not m_isITk) {
338 localCov(0,0) = computeRotatedLocalCov(localCov(0,0), element, design, cluster, size, stripID, localPos(0,0));
339 }
340
341 cl.setMeasurement<1>(element.identifyHash(), localPos, localCov);
342 cl.setIdentifier( cluster.ids.front() );
343
344 // Do I really need the global position in fast tracking?
345 cl.globalPosition() = globalPos;
346
347 cl.setChannelsInPhi(size);
348 cl.setRDOlist(std::move(cluster.ids));
349
350 return StatusCode::SUCCESS;
351}
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
constexpr float oneStripSF
static std::pair< Eigen::Matrix< float, 1, 1 >, Eigen::Matrix< float, 3, 1 > > computePosition(const StripClusteringTool::Cluster &cluster, std::size_t size, double lorentzShift, const IStripClusteringTool::IDHelper &stripID, const InDetDD::SiDetectorElement &element, const InDetDD::SiDetectorDesign &design, bool isITk)
constexpr float twoStripSF
static float computeRotatedLocalCov(float localCov, const InDetDD::SiDetectorElement &element, const InDetDD::SiDetectorDesign &design, const StripClusteringTool::Cluster &cluster, std::size_t size, const IStripClusteringTool::IDHelper &stripID, float localPos)
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

◆ makeClusters()

StatusCode ActsTrk::StripClusteringTool::makeClusters ( const EventContext & ctx,
typename IStripClusteringTool::ClusterCollection & cluster,
const InDetDD::SiDetectorElement & element,
size_t icluster,
std::any & vars,
typename ClusterContainer::iterator itrContainer ) const
overridevirtual

Definition at line 155 of file StripClusteringTool.cxx.

161{
162 const IdentifierHash idHash = element.identifyHash();
163 double lorentzShift = m_lorentzAngleTool->getLorentzShift(idHash, ctx);
164
165 const InDetDD::SiDetectorDesign& design = element.design();
166 // get the pitch, this will be the local covariance for the cluster
167
168 assert((not m_isITk) || element.isBarrel() || dynamic_cast<const InDetDD::StripStereoAnnulusDesign*>(&element.design()) !=nullptr);
169 float pitch = (element.isBarrel() or (not m_isITk))
170 ? design.phiPitch()
171 : static_cast<const InDetDD::StripStereoAnnulusDesign&>(element.design()).phiPitchPhi();
172 Eigen::Matrix<float,1,1> localCov(pitch * pitch * ONE_TWELFTH);
173
174 for (typename IStripClusteringTool::Cluster& cl : clusters) {
175 try {
176 xAOD::StripCluster *xaodCluster = *itrContainer;
178 lorentzShift,
179 localCov,
180 *m_stripID,
181 element,
182 design,
183 *xaodCluster));
184 ++itrContainer;
185 } catch (const std::exception& e) {
186 ATH_MSG_FATAL("Exception thrown while creating xAOD::StripCluster:"
187 << e.what());
188 ATH_MSG_FATAL("Detector Element identifier: " << element.identify());
189 ATH_MSG_FATAL("Strip Identifiers in cluster:");
190 for (const auto& id : cl.ids)
191 ATH_MSG_FATAL(" " << id);
192 return StatusCode::FAILURE;
193 }
194 }
195
196 return StatusCode::SUCCESS;
197}
StatusCode makeCluster(StripClusteringTool::Cluster &cluster, double LorentzShift, Eigen::Matrix< float, 1, 1 > &localCov, const StripID &stripID, const InDetDD::SiDetectorElement &element, const InDetDD::SiDetectorDesign &design, xAOD::StripCluster &container) const
virtual double phiPitch() const =0
Pitch in phi direction.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
virtual Identifier identify() const override final
identifier of this detector element (inline)
constexpr double ONE_TWELFTH
StripCluster_v1 StripCluster
Define the version of the strip cluster class.

◆ makeVars()

virtual std::any ActsTrk::StripClusteringTool::makeVars ( SG::AuxVectorData & ) const
inlineoverridevirtual

Definition at line 45 of file StripClusteringTool.h.

46 { return std::any(); }

◆ passTiming()

bool ActsTrk::StripClusteringTool::passTiming ( const std::bitset< 3 > & timePattern) const
private

Definition at line 354 of file StripClusteringTool.cxx.

354 {
355 // Convert the given timebin to a bit set and test each bit
356 // if bit is -1 (i.e. X) it always passes, other wise require exact match of 0/1
357 // N.B bitset has opposite order to the bit pattern we define
358 if (m_timeBinBits[0] != -1 and timePattern.test(2) != static_cast<bool>(m_timeBinBits[0])) return false;
359 if (m_timeBinBits[1] != -1 and timePattern.test(1) != static_cast<bool>(m_timeBinBits[1])) return false;
360 if (m_timeBinBits[2] != -1 and timePattern.test(0) != static_cast<bool>(m_timeBinBits[2])) return false;
361 return true;
362}

◆ unpackRDOs()

std::optional< std::pair< typename IStripClusteringTool::CellCollection, bool > > ActsTrk::StripClusteringTool::unpackRDOs ( const EventContext & ctx,
const RawDataCollection & RDOs,
const InDet::SiDetectorElementStatus & stripDetElStatus,
const InDetDD::SiDetectorElement & element ) const
private

Definition at line 384 of file StripClusteringTool.cxx.

388{
389 const InDetDD::SiDetectorDesign& design = element.design();
390
391 CellCollection cells;
392 // reserve memory. number evaluated on ttbar pu200
393 cells.reserve(60);
394 bool badStripOnModule{false};
395 //Check type in debug build otherwise assume it is correct
396 assert(dynamic_cast<const InDetDD::SCT_ModuleSideDesign*>(&design)!=nullptr);
397 std::size_t ncells = static_cast<size_t>(static_cast<const InDetDD::SCT_ModuleSideDesign&>(design).cells());
398
399 // Simple single-entry cache
400 Identifier::value_type waferId_compact_cache = 0;
401 IdentifierHash waferHash_cache(0);
402 bool cache_valid = false;
403
404 for (const StripRDORawData * raw : RDOs) {
405
406 //Check type in debug build otherwise assume it is correct
407 assert(static_cast<const SCT3_RawData*>(raw)!=nullptr);
408 const SCT3_RawData* raw3 = static_cast<const SCT3_RawData*>(raw);
409
410 std::bitset<3> timePattern(raw3->getTimeBin());
411 if (!passTiming(timePattern)) {
412 ATH_MSG_DEBUG("Strip failed timing check");
413 continue;
414 }
415
416 Identifier firstStripId = raw->identify();
417 Identifier waferId = m_stripID->wafer_id(firstStripId);
418
419 Identifier::value_type waferId_compact = waferId.get_compact();
420
421
422 // Check cache - will be invalid when switching wafer groups
423 if (!cache_valid || waferId_compact != waferId_compact_cache) {
424 waferId_compact_cache = waferId_compact;
425 waferHash_cache = m_stripID->wafer_hash(waferId);
426 cache_valid = true;
427 }
428
429 std::size_t iFirstStrip = static_cast<size_t>(m_stripID->strip(firstStripId));
430
431 std::size_t iMaxStrip = std::min(
432 iFirstStrip + raw->getGroupSize(),
433 ncells
434 );
435
436 for (size_t i = iFirstStrip; i < iMaxStrip; i++) {
437 Identifier stripIdent = m_stripID->strip_id(waferId, i);
438 if (isBadStrip(ctx, &stripDetElStatus, *m_stripID, waferHash_cache, stripIdent)) {
439 // Bad strip, throw it out to minimize useless work.
440 ATH_MSG_DEBUG("Bad strip encountered:" << stripIdent
441 << ", wafer is: " << waferId);
442 badStripOnModule = true;
443 } else {
444 // Good strip!
445 cells.emplace_back(i, stripIdent, std::move(timePattern));
446 }
447 }
448 }
449
450 return std::make_pair(std::move(cells), badStripOnModule);
451}
bool passTiming(const std::bitset< 3 > &timePattern) const
bool isBadStrip(const EventContext &ctx, const InDet::SiDetectorElementStatus *sctDetElStatus, const StripID &idHelper, IdentifierHash waferHash, Identifier stripId) const
value_type get_compact() const
Get the compact id.
int getTimeBin() const

Member Data Documentation

◆ m_checkBadModules

Gaudi::Property<bool> ActsTrk::StripClusteringTool::m_checkBadModules
private
Initial value:
{this, "checkBadModules", true,
"Check bad modules using the conditions summary tool"}

Definition at line 95 of file StripClusteringTool.h.

95 {this, "checkBadModules", true,
96 "Check bad modules using the conditions summary tool"};

◆ m_conditionsTool

ToolHandle<IInDetConditionsTool> ActsTrk::StripClusteringTool::m_conditionsTool
private
Initial value:
{this, "conditionsTool", "",
"Conditions summary tool"}

Definition at line 92 of file StripClusteringTool.h.

92 {this, "conditionsTool", "",
93 "Conditions summary tool"};

◆ m_errorStrategy

Gaudi::Property<unsigned int> ActsTrk::StripClusteringTool::m_errorStrategy {this, "errorStrategy", 0, "Use different error strategies for the strip clusters"}
private

Definition at line 107 of file StripClusteringTool.h.

107{this, "errorStrategy", 0, "Use different error strategies for the strip clusters"};

◆ m_isITk

Gaudi::Property<bool> ActsTrk::StripClusteringTool::m_isITk
private
Initial value:
{this, "isITk", true,
"True if running in ITk"}

Definition at line 104 of file StripClusteringTool.h.

104 {this, "isITk", true,
105 "True if running in ITk"};

◆ m_lorentzAngleTool

ToolHandle<ISiLorentzAngleTool> ActsTrk::StripClusteringTool::m_lorentzAngleTool
private
Initial value:
{this, "LorentzAngleTool", "",
"Tool to retreive Lorentz angle of Si detector module"
}

Definition at line 84 of file StripClusteringTool.h.

84 {this, "LorentzAngleTool", "",
85 "Tool to retreive Lorentz angle of Si detector module"
86 };

◆ m_maxFiredStrips

Gaudi::Property<unsigned int> ActsTrk::StripClusteringTool::m_maxFiredStrips
private
Initial value:
{this, "maxFiredStrips", 384u,
"Threshold of number of fired strips per wafer. 0 disables the per-wafer cut."}

Definition at line 98 of file StripClusteringTool.h.

98 {this, "maxFiredStrips", 384u,
99 "Threshold of number of fired strips per wafer. 0 disables the per-wafer cut."};

◆ m_stripDetEleCollKey

SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> ActsTrk::StripClusteringTool::m_stripDetEleCollKey
private
Initial value:
{this, "StripDetEleCollKey", "ITkStripDetectorElementCollection",
"SiDetectorElementCollection key for strip"}

Definition at line 101 of file StripClusteringTool.h.

101 {this, "StripDetEleCollKey", "ITkStripDetectorElementCollection",
102 "SiDetectorElementCollection key for strip"};

◆ m_stripDetElStatus

SG::ReadHandleKey<InDet::SiDetectorElementStatus> ActsTrk::StripClusteringTool::m_stripDetElStatus
private
Initial value:
{this, "StripDetElStatus", "",
"SiDetectorElementStatus for strip"}

Definition at line 89 of file StripClusteringTool.h.

89 {this, "StripDetElStatus", "",
90 "SiDetectorElementStatus for strip"};

◆ m_stripID

const StripID* ActsTrk::StripClusteringTool::m_stripID {nullptr}
private

Definition at line 112 of file StripClusteringTool.h.

112{nullptr};

◆ m_timeBinBits

int ActsTrk::StripClusteringTool::m_timeBinBits[3] {-1, -1, -1}
private

Definition at line 109 of file StripClusteringTool.h.

109{-1, -1, -1};

◆ m_timeBinStr

StringProperty ActsTrk::StripClusteringTool::m_timeBinStr {this, "timeBins", ""}
private

Definition at line 82 of file StripClusteringTool.h.

82{this, "timeBins", ""};

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