ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ActsTrk::StripClusteringTool Class Reference

#include <StripClusteringTool.h>

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

Classes

struct  Cell
 
struct  Cluster
 

Public Types

using StripRDORawData = SCT_RDORawData
 
using StripID = SCT_ID
 
using CellCollection = std::vector< Cell >
 
using ClusterCollection = std::vector< Cluster >
 

Public Member Functions

 StripClusteringTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual StatusCode initialize () override
 
virtual StatusCode clusterize (const InDetRawDataCollection< StripRDORawData > &RDOs, const StripID &stripID, const EventContext &ctx, xAOD::StripClusterContainer &container) const override
 

Private Member Functions

bool passTiming (const std::bitset< 3 > &timePattern) const
 
StatusCode decodeTimeBins ()
 
std::optional< std::pair< std::vector< Cell >, bool > > unpackRDOs (const InDetRawDataCollection< StripRDORawData > &RDOs, const StripID &idHelper, const InDet::SiDetectorElementStatus *sctDetElStatus, const EventContext &ctx) const
 
bool isBadStrip (const EventContext &ctx, const InDet::SiDetectorElementStatus *sctDetElStatus, const StripID &idHelper, IdentifierHash waferHash, Identifier stripId) const
 
StatusCode makeCluster (const StripClusteringTool::Cluster &cluster, double LorentzShift, const StripID &stripID, const InDetDD::SiDetectorElement *element, 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
 
int m_timeBinBits [3] {-1, -1, -1}
 

Detailed Description

Definition at line 26 of file StripClusteringTool.h.

Member Typedef Documentation

◆ CellCollection

Definition at line 47 of file StripClusteringTool.h.

◆ ClusterCollection

Definition at line 48 of file StripClusteringTool.h.

◆ StripID

Definition at line 30 of file StripClusteringTool.h.

◆ StripRDORawData

Definition at line 29 of file StripClusteringTool.h.

Constructor & Destructor Documentation

◆ StripClusteringTool()

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

Definition at line 43 of file StripClusteringTool.cxx.

45  : base_class(type,name,parent)
46 {
47 }

Member Function Documentation

◆ clusterize()

StatusCode ActsTrk::StripClusteringTool::clusterize ( const InDetRawDataCollection< StripRDORawData > &  RDOs,
const StripID stripID,
const EventContext &  ctx,
xAOD::StripClusterContainer container 
) const
overridevirtual

Definition at line 83 of file StripClusteringTool.cxx.

87 {
88  IdentifierHash idHash = RDOs.identifyHash();
89 
91  if (!m_stripDetElStatus.empty()) {
93  if (!status.isValid()) {
94  ATH_MSG_FATAL("Invalid SiDetectorelementStatus");
95  return StatusCode::FAILURE;
96  }
97  }
98 
99  bool goodModule = true;
100  if (m_checkBadModules.value()) {
101  if (!m_stripDetElStatus.empty()) {
102  goodModule = status->isGood(idHash);
103  } else {
104  goodModule = m_conditionsTool->isGood(idHash, ctx);
105  }
106  }
109  status->isGood(idHash), m_conditionsTool->isGood(idHash));
110 
111  if (!goodModule) {
112  ATH_MSG_DEBUG("Strip module failed status check");
113  return StatusCode::SUCCESS;
114  }
115 
116  // If more than a certain number of RDOs set module to bad
117  // in this case we skip clusterization
118  if (m_maxFiredStrips != 0u) {
119  unsigned int nFiredStrips = 0u;
120  for (const SCT_RDORawData* rdo : RDOs) {
121  nFiredStrips += rdo->getGroupSize();
122  }
123  if (nFiredStrips > m_maxFiredStrips)
124  return StatusCode::SUCCESS;
125  }
126 
128  m_stripDetEleCollKey, ctx);
129  ATH_CHECK( stripDetEleHandle.isValid() );
130  const InDetDD::SiDetectorElementCollection* stripDetEle(*stripDetEleHandle);
131  if (stripDetEle == nullptr) {
132  ATH_MSG_FATAL("Invalid SiDetectorElementCollection");
133  return StatusCode::FAILURE;
134  }
135 
136  const InDetDD::SiDetectorElement* element =
137  stripDetEle->getDetectorElement(idHash);
138 
139  const InDet::SiDetectorElementStatus *stripDetElStatus =
140  m_stripDetElStatus.empty() ? nullptr : status.cptr();
141 
142  std::optional<std::pair<CellCollection,bool>> unpckd
143  = unpackRDOs(RDOs, stripID, stripDetElStatus, ctx);
144  if (not unpckd.has_value()) {
145  ATH_MSG_FATAL("Error encountered while unpacking strip RDOs!");
146  return StatusCode::FAILURE;
147  }
148 
149  auto& [cells, badStripOnModule] = *unpckd;
150 
152  Acts::Ccl::createClusters<CellCollection, ClusterCollection, 1>(cells);
153 
154  std::size_t previousSizeContainer = container.size();
155  // Fast insertion trick
156  std::vector<xAOD::StripCluster*> toAddCollection;
157  toAddCollection.reserve(clusters.size());
158  for (std::size_t i(0); i<clusters.size(); ++i)
159  toAddCollection.push_back(new xAOD::StripCluster());
160  container.insert(container.end(), toAddCollection.begin(), toAddCollection.end());
161 
162  double lorentzShift
163  = m_lorentzAngleTool->getLorentzShift(element->identifyHash(), ctx);
164 
165  for (std::size_t i(0); i<clusters.size(); ++i) {
166  Cluster& cl = clusters[i];
167  // Bad strips on a module invalidates the hitsInThirdTimeBin word.
168  // Therefore set it to 0 if that's the case.
169  if (badStripOnModule) {
170  cl.hitsInThirdTimeBin = 0;
171  }
172  try {
173  ATH_CHECK(makeCluster(cl, lorentzShift, stripID, element, *container[previousSizeContainer+i]));
174  } catch (const std::exception& e) {
175  ATH_MSG_FATAL("Exception thrown while creating xAOD::StripCluster:"
176  << e.what());
177  ATH_MSG_FATAL("Detector Element identifier: " << element->identify());
178  ATH_MSG_FATAL("Strip Identifiers in cluster:");
179  for (const Identifier& id : cl.ids)
180  ATH_MSG_FATAL(" " << id);
181  return StatusCode::FAILURE;
182  }
183  }
184 
185  return StatusCode::SUCCESS;
186 }

◆ decodeTimeBins()

StatusCode ActsTrk::StripClusteringTool::decodeTimeBins ( )
private

Definition at line 63 of file StripClusteringTool.cxx.

64 {
65  for (size_t i = 0; i < m_timeBinStr.size(); i++) {
66  if (i >= 3) {
67  ATH_MSG_WARNING("Time bin string has excess characters");
68  break;
69  }
70  switch (std::toupper(m_timeBinStr[i])) {
71  case 'X': m_timeBinBits[i] = -1; break;
72  case '0': m_timeBinBits[i] = 0; break;
73  case '1': m_timeBinBits[i] = 1; break;
74  default:
75  ATH_MSG_FATAL("Invalid time bin string: " << m_timeBinStr);
76  return StatusCode::FAILURE;
77  }
78  }
79  return StatusCode::SUCCESS;
80 }

◆ initialize()

StatusCode ActsTrk::StripClusteringTool::initialize ( )
overridevirtual

Definition at line 49 of file StripClusteringTool.cxx.

50 {
51  ATH_MSG_DEBUG("Initializing " << name() << "...");
52 
53  ATH_CHECK(m_conditionsTool.retrieve());
54  ATH_CHECK(m_lorentzAngleTool.retrieve());
56 
59 
60  return StatusCode::SUCCESS;
61 }

◆ isBadStrip()

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

Definition at line 268 of file StripClusteringTool.cxx.

273 {
274  if (stripDetElStatus) {
275  const int strip_i{stripID.strip(stripId)};
277  stripDetElStatus,
278  stripDetElStatus->isCellGood(waferHash.value(), strip_i),
279  m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP));
280  return not stripDetElStatus->isCellGood(waferHash.value(), strip_i) ;
281  }
282  return not m_conditionsTool->isGood(stripId, InDetConditions::SCT_STRIP, ctx);
283 }

◆ makeCluster()

StatusCode ActsTrk::StripClusteringTool::makeCluster ( const StripClusteringTool::Cluster cluster,
double  LorentzShift,
const StripID stripID,
const InDetDD::SiDetectorElement element,
xAOD::StripCluster container 
) const
private

Definition at line 232 of file StripClusteringTool.cxx.

237 {
238 
239  IdentifierHash idHash = element->identifyHash();
240  auto [pos, localPos, localCov, globalPos]
241  = computePosition(cluster, lorentzShift, stripID, element);
242 
243  // For Strip Clusters the identifier is taken from the front rod list object
244  // This is the same strategy used in Athena:
245  // Since clusterId is arbitary (it only needs to be unique) just use ID of first strip
246  // For strip Cluster it has been found that "identifierOfPosition" does not produces unique values
247  cl.setMeasurement<1>(idHash, localPos, localCov);
248  cl.setIdentifier( cluster.ids.front().get_compact() );
249  cl.globalPosition() = globalPos;
250  cl.setRDOlist(cluster.ids);
251  cl.setChannelsInPhi(cluster.ids.size());
252 
253  return StatusCode::SUCCESS;
254 }

◆ passTiming()

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

Definition at line 257 of file StripClusteringTool.cxx.

257  {
258  // Convert the given timebin to a bit set and test each bit
259  // if bit is -1 (i.e. X) it always passes, other wise require exact match of 0/1
260  // N.B bitset has opposite order to the bit pattern we define
261  if (m_timeBinBits[0] != -1 and timePattern.test(2) != static_cast<bool>(m_timeBinBits[0])) return false;
262  if (m_timeBinBits[1] != -1 and timePattern.test(1) != static_cast<bool>(m_timeBinBits[1])) return false;
263  if (m_timeBinBits[2] != -1 and timePattern.test(0) != static_cast<bool>(m_timeBinBits[2])) return false;
264  return true;
265 }

◆ unpackRDOs()

std::optional< std::pair< StripClusteringTool::CellCollection, bool > > ActsTrk::StripClusteringTool::unpackRDOs ( const InDetRawDataCollection< StripRDORawData > &  RDOs,
const StripID idHelper,
const InDet::SiDetectorElementStatus sctDetElStatus,
const EventContext &  ctx 
) const
private

Definition at line 287 of file StripClusteringTool.cxx.

291 {
293  bool badStripOnModule{false};
294 
295  for (const StripRDORawData * raw : RDOs) {
296  const SCT3_RawData* raw3 = dynamic_cast<const SCT3_RawData*>(raw);
297  if (!raw3) {
298  ATH_MSG_ERROR("Casting into SCT3_RawData failed");
299  return {};
300  }
301 
302  std::bitset<3> timePattern(raw3->getTimeBin());
303  if (!passTiming(timePattern)) {
304  ATH_MSG_DEBUG("Strip failed timing check");
305  continue;
306  }
307 
308  Identifier firstStripId = raw->identify();
309  Identifier waferId = stripID.wafer_id(firstStripId);
310  IdentifierHash waferHash = stripID.wafer_hash(waferId);
311  size_t iFirstStrip = static_cast<size_t>(stripID.strip(firstStripId));
312  size_t iMaxStrip = std::min(
313  iFirstStrip + raw->getGroupSize(),
314  static_cast<size_t>(stripID.strip_max(waferId)) + 1
315  );
316 
317  for (size_t i = iFirstStrip; i < iMaxStrip; i++) {
318  Identifier stripIdent = stripID.strip_id(waferId, i);
319  if (isBadStrip(ctx, stripDetElStatus, stripID, waferHash, stripIdent)) {
320  // Bad strip, throw it out to minimize useless work.
321  ATH_MSG_DEBUG("Bad strip encountered:" << stripIdent
322  << ", wafer is: " << waferId);
323  badStripOnModule = true;
324  } else {
325  // Good strip!
326  cells.emplace_back(i, stripIdent, std::move(timePattern));
327  }
328  }
329  }
330  return std::make_pair(cells, badStripOnModule);
331 }

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 100 of file StripClusteringTool.h.

◆ m_conditionsTool

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

Definition at line 97 of file StripClusteringTool.h.

◆ 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 89 of file StripClusteringTool.h.

◆ 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 103 of file StripClusteringTool.h.

◆ m_stripDetEleCollKey

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

Definition at line 106 of file StripClusteringTool.h.

◆ m_stripDetElStatus

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

Definition at line 94 of file StripClusteringTool.h.

◆ m_timeBinBits

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

Definition at line 109 of file StripClusteringTool.h.

◆ m_timeBinStr

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

Definition at line 87 of file StripClusteringTool.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ActsTrk::StripClusteringTool::isBadStrip
bool isBadStrip(const EventContext &ctx, const InDet::SiDetectorElementStatus *sctDetElStatus, const StripID &idHelper, IdentifierHash waferHash, Identifier stripId) const
Definition: StripClusteringTool.cxx:268
ActsTrk::StripClusteringTool::m_lorentzAngleTool
ToolHandle< ISiLorentzAngleTool > m_lorentzAngleTool
Definition: StripClusteringTool.h:89
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
IdentifierHash::value
unsigned int value() const
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
ActsTrk::StripClusteringTool::CellCollection
std::vector< Cell > CellCollection
Definition: StripClusteringTool.h:47
ActsTrk::StripClusteringTool::ClusterCollection
std::vector< Cluster > ClusterCollection
Definition: StripClusteringTool.h:48
SCT_RDORawData
Definition: SCT_RDORawData.h:24
ActsTrk::StripClusteringTool::unpackRDOs
std::optional< std::pair< std::vector< Cell >, bool > > unpackRDOs(const InDetRawDataCollection< StripRDORawData > &RDOs, const StripID &idHelper, const InDet::SiDetectorElementStatus *sctDetElStatus, const EventContext &ctx) const
Definition: StripClusteringTool.cxx:287
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
ActsTrk::StripClusteringTool::m_checkBadModules
Gaudi::Property< bool > m_checkBadModules
Definition: StripClusteringTool.h:100
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
InDetRawDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ActsTrk::StripClusteringTool::m_timeBinBits
int m_timeBinBits[3]
Definition: StripClusteringTool.h:109
ActsTrk::StripClusteringTool::StripRDORawData
SCT_RDORawData StripRDORawData
Definition: StripClusteringTool.h:29
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
VALIDATE_STATUS_ARRAY
#define VALIDATE_STATUS_ARRAY(use_info, info_val, summary_val)
Definition: SiDetectorElementStatus.h:51
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
SCT3_RawData
Definition: SCT3_RawData.h:24
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
calibdata.exception
exception
Definition: calibdata.py:496
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector::insert
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
SCT3_RawData::getTimeBin
int getTimeBin() const
Definition: SCT3_RawData.h:92
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
ActsTrk::StripClusteringTool::m_maxFiredStrips
Gaudi::Property< unsigned int > m_maxFiredStrips
Definition: StripClusteringTool.h:103
ActsTrk::StripClusteringTool::decodeTimeBins
StatusCode decodeTimeBins()
Definition: StripClusteringTool.cxx:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::StripClusteringTool::m_timeBinStr
StringProperty m_timeBinStr
Definition: StripClusteringTool.h:87
ActsTrk::StripClusteringTool::m_stripDetElStatus
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_stripDetElStatus
Definition: StripClusteringTool.h:94
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ActsTrk::StripClusteringTool::makeCluster
StatusCode makeCluster(const StripClusteringTool::Cluster &cluster, double LorentzShift, const StripID &stripID, const InDetDD::SiDetectorElement *element, xAOD::StripCluster &container) const
Definition: StripClusteringTool.cxx:232
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ActsTrk::StripClusteringTool::passTiming
bool passTiming(const std::bitset< 3 > &timePattern) const
Definition: StripClusteringTool.cxx:257
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ActsTrk::StripClusteringTool::m_stripDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_stripDetEleCollKey
Definition: StripClusteringTool.h:106
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
merge.status
status
Definition: merge.py:17
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetConditions::SCT_STRIP
@ SCT_STRIP
Definition: InDetHierarchy.h:14
ActsTrk::StripClusteringTool::m_conditionsTool
ToolHandle< IInDetConditionsTool > m_conditionsTool
Definition: StripClusteringTool.h:97
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
Identifier
Definition: IdentifierFieldParser.cxx:14