45 bool adjacent(
unsigned int strip1,
unsigned int strip2) {
46 return ((1 == (strip2-strip1)) or (1 == (strip1-strip2)));
50 bool adjacent(
const unsigned int strip1,
const int row1,
const unsigned int strip2,
const int row2){
51 return ((row1==row2) and ((1 == (strip2-strip1)) or (1 == (strip1-strip2))));
56 base_class(
type, name, parent)
69 return StatusCode::FAILURE;
79 return StatusCode::SUCCESS;
84 if (timeBin ==
'X') {bit = -1;
return StatusCode::SUCCESS;}
85 if (timeBin ==
'0') {bit = 0;
return StatusCode::SUCCESS;}
86 if (timeBin ==
'1') {bit = 1;
return StatusCode::SUCCESS;}
89 return StatusCode::FAILURE;
97 const std::bitset<3> timePattern(
static_cast<unsigned long>(timeBin));
107 const std::bitset<3> timePattern(
static_cast<unsigned long>(timeBin));
108 if (timePattern.test(2)) pass=
false;
109 if (!timePattern.test(1)) pass=
false;
119 const std::bitset<3> timePattern(
static_cast<unsigned long>(timeBin));
120 if (!timePattern.test(1)) pass=
false;
128 ATH_MSG_DEBUG(
"Clustering has been asked to look at bad channel info");
145 int countTrueSettings(0);
149 if (countTrueSettings!=1) {
153 if (countTrueSettings==0) {
154 ATH_MSG_DEBUG(
"Timing requirement is not used for clustering");
156 ATH_MSG_FATAL(
"One and only one of m_majority01X, m_innermostBarrelX1X and m_innertwoBarrelX1X should be set to True!");
157 return StatusCode::FAILURE;
165 " is true and used for clustering");
171 return StatusCode::SUCCESS;
175 std::vector<Identifier>& clusterVector,
const SCT_ID& idHelper) {
176 const unsigned int firstStripNumber(idHelper.
strip(firstStripId));
177 const unsigned int endStripNumber(firstStripNumber + nStrips);
179 clusterVector.reserve(clusterVector.size() + nStrips);
181 for (
unsigned int stripNumber(firstStripNumber); stripNumber not_eq endStripNumber; ++stripNumber) {
183 clusterVector.push_back(stripId);
193 unsigned int nStrips,
194 std::vector<Identifier>& clusterVector,
195 std::vector<std::vector<Identifier> >& idGroups,
198 const EventContext& ctx)
const{
200 const unsigned int firstStripNumber(idHelper.
strip(firstStripId));
201 const unsigned int endStripNumber(firstStripNumber + nStrips);
205 clusterVector.reserve(clusterVector.size() + nStrips);
208 unsigned int nBadStrips(0);
209 for (
unsigned int stripNumber(firstStripNumber); stripNumber not_eq endStripNumber; ++stripNumber) {
211 if (
isBad(det_el_status, idHelper, waferHash, stripId, ctx)) {
215 clusterVector.push_back(stripId);
219 if (clusterVector.size() == nBadStrips) {
220 clusterVector.clear();
226 if (nBadStrips != 0) {
228 clusterVector=
recluster(clusterVector, idGroups);
234 unsigned int nStrips,
235 std::vector<Identifier>& clusterVector,
236 std::vector<std::vector<Identifier> >& idGroups,
239 const EventContext& ctx)
const{
241 const unsigned int firstStripNumber(idHelper.
strip(firstStripId));
242 const unsigned int firstRowNumber(idHelper.
row(firstStripId));
243 const unsigned int endStripNumber(firstStripNumber + nStrips);
247 clusterVector.reserve(clusterVector.size() + nStrips);
249 unsigned int nBadStrips(0);
250 for (
unsigned int stripNumber(firstStripNumber); stripNumber not_eq endStripNumber; ++stripNumber) {
252 if (
isBad(det_el_status, idHelper, waferHash, stripId, ctx)) {
256 clusterVector.push_back(stripId);
260 if (clusterVector.size() == nBadStrips) {
261 clusterVector.clear();
267 if (nBadStrips != 0) {
268 clusterVector=
recluster(clusterVector, idGroups);
280 std::vector<SCT_ClusteringTool::IdVec_t>& idGroups)
const {
284 const unsigned int numberOfBadStrips(std::count(clusterVector.begin(), clusterVector.end(),
invalidId));
287 if (numberOfBadStrips==0 or clusterVector.empty())
return clusterVector;
289 if (clusterVector.size() == numberOfBadStrips) {
290 clusterVector.clear();
291 return clusterVector;
295 SCT_ClusteringTool::IdVec_t::iterator pBadId(std::find(clusterVector.begin(), clusterVector.end(),
invalidId));
299 if (pBadId != clusterVector.end()) clusterVector.erase(clusterVector.begin(), ++pBadId);
300 if (not subCluster.empty()) idGroups.push_back(subCluster);
301 return recluster(clusterVector, idGroups);
311 const EventContext& ctx)
const
317 SCT_ClusterCollection* nullResult(
nullptr);
318 if (collection.
empty()) {
324 std::vector<const SCT_RDORawData*> collectionCopy(collection.
begin(), collection.
end());
334 unsigned int previousStrip(0);
335 uint16_t hitsInThirdTimeBin(0);
338 const Identifier firstStripId(pRawData->identify());
339 const unsigned int nStrips(pRawData->getGroupSize());
340 const int thisStrip(idHelper.
strip(firstStripId));
341 const int BEC(idHelper.
barrel_ec(firstStripId));
342 const int layer(idHelper.
layer_disk(firstStripId));
357 cache.
tbinGroups.push_back(hitsInThirdTimeBin);
358 hitsInThirdTimeBin =0;
363 bool passTiming(
true);
368 ATH_MSG_ERROR(
"Casting into SCT3_RawData failed. This is probably caused by use of an old RDO file.");
372 std::bitset<3> timePattern(
static_cast<unsigned long>(timeBin));
378 if (passX1X and (not pass01X)) n11X++;
380 if ((BEC==0) and (layer==0) and passX1X) passTiming=
true;
381 else passTiming = pass01X;
383 if ((BEC==0) and (layer==0 or layer==1) and passX1X) passTiming=
true;
384 else passTiming = pass01X;
397 for (
unsigned int iStrip=0; iStrip<nStrips; iStrip++) {
398 if (stripCount < 16) hitsInThirdTimeBin |= (timePattern.test(0) << stripCount);
412 cache.
tbinGroups.push_back(hitsInThirdTimeBin);
413 hitsInThirdTimeBin=0;
423 if (not sctDetEleHandle.
isValid() or sctDetEle==
nullptr) {
441 SCT_ClusterCollection* clusterCollection =
new SCT_ClusterCollection(idHash);
442 clusterCollection->setIdentifier(elementID);
443 clusterCollection->reserve(cache.
idGroups.size());
450 std::vector<uint16_t>::iterator tbinIter(cache.
tbinGroups.begin());
455 const bool badStripInClusterOnThisModuleSide = (cache.
idGroups.size() != cache.
tbinGroups.size());
458 const int nStrips(stripGroup.size());
459 if (nStrips == 0)
continue;
468 const Identifier clusterId(stripGroup.front());
472 const std::pair<InDetDD::SiLocalPosition, InDetDD::SiLocalPosition> ends(design->
endsOfStrip(clusterDim.
centre));
473 const double stripLength(std::abs(ends.first.xEta()-ends.second.xEta()));
487 ? (
m_clusterMaker->sctCluster(clusterId, localPos, std::move(stripGroup),
489 : (
SCT_Cluster(clusterId, localPos, std::move(stripGroup), siWidth, element,
493 clusterCollection->size());
500 clusterCollection->push_back(cluster);
503 return clusterCollection;
511 const EventContext& ctx)
const
513 if (collection.
empty())
return nullptr;
515 std::vector<const SCT_RDORawData*> collectionCopy(collection.
begin(), collection.
end());
523 unsigned int previousStrip = 0;
524 uint16_t hitsInThirdTimeBin = 0;
526 int previousRow = -1;
532 Identifier firstStripId = pRawData->identify();
535 unsigned int nStrips = pRawData->getGroupSize();
536 int thisStrip = idHelper.
strip(firstStripId);
551 cache.
tbinGroups.push_back(hitsInThirdTimeBin);
552 hitsInThirdTimeBin = 0;
561 ATH_MSG_ERROR(
"Casting into SCT3_RawData failed. This is probably caused by use of an old RDO file.");
566 std::bitset<3> timePattern(
static_cast<unsigned long>(timeBin));
568 bool passTiming =
true;
576 unsigned int nBadStrips(0);
577 unsigned int max_strip = std::min(
static_cast<unsigned int>(thisStrip+nStrips),
static_cast<unsigned int>(idHelper.
strip_max(waferId)+1) );
579 if (thisStrip+nStrips > max_strip) {
580 ATH_MSG_DEBUG(
"SCT strip range exceeds bounds: strip range " << thisStrip <<
" .. + " << nStrips <<
" = " << (thisStrip+nStrips)
581 <<
" !<= " << max_strip );
583 for (
unsigned int sn=thisStrip; sn < max_strip; ++sn) {
585 if (!
isBad(sctDetElStatus, idHelper, waferHash, stripId, ctx)) {
591 if (stripCount < 16) {
592 hitsInThirdTimeBin = hitsInThirdTimeBin | (timePattern.test(0) << stripCount);
599 }
else if (nBadStrips) {
616 cache.
tbinGroups.push_back(hitsInThirdTimeBin);
617 hitsInThirdTimeBin=0;
625 if (not sctDetEleHandle.
isValid() or sctDetEle==
nullptr) {
636 if(design==
nullptr)
return nullptr;
638 SCT_ClusterCollection* clusterCollection =
new SCT_ClusterCollection(idHash);
640 clusterCollection->setIdentifier(elementID);
641 clusterCollection->reserve(cache.
idGroups.size());
646 int clusterNumber = 0;
650 std::vector<IdVec_t>::iterator pGroup = cache.
idGroups.begin();
651 std::vector<IdVec_t>::iterator lastGroup = cache.
idGroups.end();
652 std::vector<uint16_t>::iterator tbinIter = cache.
tbinGroups.begin();
658 double iphipitch = 1./element->
phiPitch();
661 bool badStripInClusterOnThisModuleSide = (cache.
idGroups.size() != cache.
tbinGroups.size());
668 COV11 = stripL*stripL*(1./12.);
671 for (; pGroup!=lastGroup; ++pGroup) {
672 int nStrips = pGroup->size();
673 double dnStrips =
static_cast<double>(nStrips);
676 int firstStrip = idHelper.
strip(clusterId);
677 double width = stripPitch;
680 int row = idHelper.
row(clusterId);
684 centre = (centre+lastStripPos)*.5;
689 centre = clusterDim.
centre;
712 double V[4] = {
x*
x*(1./12.), 0., 0., COV11};
717 std::pair<InDetDD::SiLocalPosition, InDetDD::SiLocalPosition> ends(design->
endsOfStrip(centre));
718 stripL = std::abs(ends.first.xEta()-ends.second.xEta());
720 double w = element->
phiPitch(localPos)*iphipitch;
724 double v0 = V[0]*w*w;
725 double v1 = stripL*stripL*(1./12.);
726 V[0] = cs2*v0+sn2*v1;
727 V[1] = V[2] = sn*sqrt(cs2)*(v0-v1);
728 V[3] = sn2*v0+cs2*v1;
732 errorMatrix<<V[0],V[1],V[2],V[3];
739 (*cluster) =
SCT_Cluster{clusterId, locpos, std::move(*pGroup),
740 siWidth, element, std::move(errorMatrix)};
743 cluster =
new SCT_Cluster{clusterId, locpos, std::move(*pGroup),
744 siWidth, element, std::move(errorMatrix)};
758 clusterCollection->push_back(cluster);
761 return clusterCollection;
768 const int nStrips(lastStrip - firstStrip + 1);
775 const double width((
static_cast<double>(nStrips)/
static_cast<double>(nStrips+1))*( lastStripPos.
xPhi()-firstStripPos.
xPhi()));
783 const int nStrips(lastStrip - firstStrip + 1);
784 const int firstStrip1D = design->
strip1Dim(firstStrip, row);
785 const int lastStrip1D = design->
strip1Dim(lastStrip, row);
786 const double stripPitch = design->
stripPitch();
791 const double width(nStrips*stripPitch);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Header containing the InDetHierarchy enum, to avoid pulling in a class every time it is needed and na...
header file for SCT_ReClustering class
void rotate(double angler, GeoTrf::Vector2D &vector)
a typed memory pool that saves time spent allocation small object.
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
virtual DetectorShape shape() const
Shape of element.
virtual double etaPitch() const =0
Barrel module design description for the SCT.
Design descriptor for forward modules in the SCT, carries the bounds, and readout information.
Base class for the SCT module side design, extended by the Forward and Barrel module design.
virtual double stripPitch(const SiLocalPosition &chargePos) const =0
give the strip pitch (dependence on position needed for forward)
virtual int strip1Dim(int strip, int row) const override
only relevant for SCT.
virtual std::pair< SiLocalPosition, SiLocalPosition > endsOfStrip(const SiLocalPosition &position) const override=0
give the ends of strips
Identifier for the strip or pixel cell.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
double phiPitch() const
Pitch (inline methods)
double sinStereoLocal(const Amg::Vector2D &localPos) const
Angle of strip in local frame with respect to the etaAxis.
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
Amg::Vector2D rawLocalPositionOfCell(const SiCellId &cellId) const
Returns position (center) of cell.
virtual Identifier identify() const override final
virtual IdentifierHash identifyHash() const override final
virtual Identifier identify() const override final
void setHitsInThirdTimeBin(uint16_t hitsInThirdTimeBin)
Setter method of timing.
bool operator()(const SCT_RDORawData *rdo1, const SCT_RDORawData *rdo2)
Trk::PrepRawDataCollection< SCT_Cluster > SCT_ClusterCollection
This is an Identifier helper class for the SCT subdetector.
int layer_disk(const Identifier &id) const
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
int strip_max(const Identifier &id) const
int row(const Identifier &id) const
int strip(const Identifier &id) const
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Identifier strip_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side, int strip) const
For an individual strip.
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be sct id, otherwise answer is not accurate. Use SiliconID for gen...
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
bool adjacent(unsigned int strip1, unsigned int strip2)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
std::vector< IdVec_t > idGroups
std::vector< uint16_t > tbinGroups