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))));
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);
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);
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;
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
318 if (collection.
empty()) {
324 std::vector<const SCT_RDORawData*> collectionCopy(collection.
begin(), collection.
end());
325 if (collection.
size() not_eq 1) std::sort(collectionCopy.begin(), collectionCopy.end(),
strip_less_than());
334 unsigned int previousStrip(0);
338 const Identifier firstStripId(pRawData->identify());
339 const unsigned int nStrips(pRawData->getGroupSize());
340 const int thisStrip(idHelper.
strip(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) {
442 clusterCollection->setIdentifier(elementID);
443 clusterCollection->reserve(cache.
idGroups.size());
455 const bool badStripInClusterOnThisModuleSide = (cache.
idGroups.size() != cache.
tbinGroups.size());
458 const int nStrips(stripGroup.size());
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());
517 if (collectionCopy.size() > 1) std::sort(collectionCopy.begin(), collectionCopy.end(),
strip_less_than());
523 unsigned int previousStrip = 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) {
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;
640 clusterCollection->setIdentifier(elementID);
641 clusterCollection->reserve(cache.
idGroups.size());
646 int clusterNumber = 0;
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) {
673 double dnStrips =
static_cast<double>(
nStrips);
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;
786 const double stripPitch = design->
stripPitch();