29 static inline std::string
to_string(
const std::vector<T>&
v)
31 std::ostringstream oss;
35 std::copy(
v.begin(),
v.end() - 1, std::ostream_iterator<T>(oss,
", "));
45 os <<
"lyr: " << hit.
layer <<
" ";
46 os <<
"(" << hit.
hitptr->getR() <<
", " << hit.
hitptr->getGPhi() <<
", " << hit.
hitptr->getZ() <<
") ";
58 declareInterface<IFPGATrackSimRoadFinderTool>(
this);
65 const std::vector<Gaudi::Details::PropertyBase*> props = this->getProperties();
66 for( Gaudi::Details::PropertyBase* prop : props ) {
67 if (prop->ownerTypeName()==this->type()) {
68 ATH_MSG_DEBUG(
"Property:\t" << prop->name() <<
"\t : \t" << prop->toString());
107 return StatusCode::FAILURE;
124 return StatusCode::FAILURE;
146 return StatusCode::SUCCESS;
162 if (((lyrhit >> hit.
layer) & 0
x1) == 0x0)
164 lyrhit |= (0x1 << hit.
layer);
173 std::vector<std::shared_ptr<const FPGATrackSimRoad>> &roads)
195 std::vector<HitPairSet> pairsets;
212 if (pairsets.size() >1) {
216 s +=
"(" + std::to_string(hit->
hitptr->getLayer()) +
"," + std::to_string(hit->
hitptr->getR()) +
"), ";
237 return StatusCode::SUCCESS;
246 for (
const std::shared_ptr<const FPGATrackSimHit>& hit :
hits)
261 if (!slicebin.data())
continue;
279 if (!scanbin.data())
continue;
285 std::pair<unsigned, unsigned> rowRange =
m_binning->idxsetToRowParBinRange(
idx, hit.get());
288 for (
unsigned rowbin = rowRange.first; rowbin < rowRange.second; rowbin++)
299 s_hit.
layer = hit->getLayer();
312 return StatusCode::SUCCESS;
318 std::vector<HitPairSet> &output_pairsets)
323 std::vector<std::vector<const StoredHit *>> hitsByLayer(
m_nLayers);
343 if (passedPairFilter)
346 std::vector<HitPairSet> pairsets;
356 output_pairsets.push_back(pairset);
365 output_pairsets.push_back(
pairs);
370 output_pairsets.push_back(filteredpairs);
373 return StatusCode::SUCCESS;
381 const std::vector<const StoredHit *>& newhits)
385 std::vector<bool> pairset_used(inputstate.
pairsets.size(),
false);
387 for (
auto &newhit : newhits) {
390 std::set<const StoredHit *> vetoList;
393 for (
auto &pairset : inputstate.
pairsets) {
398 outputstate.
pairsets.push_back(newset);
400 for (
auto vetohit : pairset.hitlist) {
401 vetoList.insert(vetohit);
408 if (vetoList.count(prevhit) == 0) {
413 outputstate.
pairsets.push_back(newset);
420 if (lyridx <= allowed_missed_hits) {
429 for (
auto &pairset : inputstate.
pairsets) {
430 if (lyridx < (pairset.hitlist.size() + allowed_missed_hits)) {
431 outputstate.
pairsets.push_back(pairset);
447 if (lyridx > allowed_missed_hits) {
461 std::vector<HitPairSet> &output_pairsets)
466 std::vector<std::vector<const StoredHit *>> hitsByLayer(
m_nLayers);
474 for (
unsigned lyridx = 0; lyridx <
m_nLayers; lyridx++) {
484 return StatusCode::SUCCESS;
490 std::vector<std::vector<const StoredHit *>>& hitsByLayer)
496 hitsByLayer[hit.
hitptr->getLayer()].push_back(&hit);
499 return StatusCode::SUCCESS;
512 std::vector<const FPGATrackSimGenScanTool::StoredHit *>
const * lastlyr = 0;
513 std::vector<const FPGATrackSimGenScanTool::StoredHit *>
const * lastlastlyr = 0;
531 lastlastlyr = lastlyr;
532 lastlyr = &hitsByLayer[lyr];
536 return StatusCode::SUCCESS;
544 int lyr =
std::min(pair.first->hitptr->getLayer(),pair.second->hitptr->getLayer());
562 return StatusCode::SUCCESS;
568 std::vector<HitPairSet> &pairsets,
578 if ((std::abs(pair.second->layer - pair.first->layer) > 1)
579 && (pairset.hasLayer(
std::min(pair.first->layer,pair.second->layer) + 1)))
593 int size = pairset.addPair(pair);
595 ATH_MSG_VERBOSE(
"addPair " << pairsets.size() <<
" " << pairset.pairList.size() <<
" " <<
size);
606 pairsets.push_back(newpairset);
610 return StatusCode::SUCCESS;
625 cutvar(std::string
name,
double val,
double cut, std::vector<TH1D *>& histset) :
626 m_name(std::move(
name)), m_val(
val), m_cut(
cut), m_histset(histset) {}
627 bool passed() {
return std::abs(m_val) < m_cut; }
628 void fill(
unsigned cat) { m_histset[cat]->Fill(m_val); }
632 std::vector<TH1D *> &m_histset;
636 std::vector<cutvar> allcuts;
637 allcuts.push_back(cutvar(
"MatchPhi", pairset.
MatchPhi(pair),
640 allcuts.push_back(cutvar(
"MatchEta", pairset.
MatchEta(pair),
643 allcuts.push_back(cutvar(
"DeltaDeltaPhi", pairset.
DeltaDeltaPhi(pair),
646 allcuts.push_back(cutvar(
"DeltaDeltaEta", pairset.
DeltaDeltaEta(pair),
649 allcuts.push_back(cutvar(
"PhiCurvature", pairset.
PhiCurvature(pair),
652 allcuts.push_back(cutvar(
"EtaCurvature", pairset.
EtaCurvature(pair),
656 allcuts.push_back(cutvar(
659 allcuts.push_back(cutvar(
663 allcuts.push_back(cutvar(
666 allcuts.push_back(cutvar(
671 unsigned passedCuts = std::count_if(allcuts.begin(), allcuts.end(),
672 [](cutvar&
cut) { return cut.passed(); });
673 bool passedAll = (passedCuts == allcuts.size());
676 bool passedAllButOne = (passedCuts == allcuts.size() - 1);
677 for (cutvar&
cut: allcuts) {
681 (passedAll || (passedAllButOne && !
cut.passed())));
687 for (cutvar &
cut : allcuts)
689 s +=
cut.m_name +
" : (" +
cut.passed() +
", " +
cut.m_val +
"), ";
693 << *pairset.
lastpair().second <<
"\n "
694 << *pair.first <<
"\n "
705 std::vector<std::shared_ptr<const FPGATrackSimHit>> outhits;
708 hitLayers |= 1 << hit->hitptr->getLayer();
709 outhits.push_back(hit->hitptr);
712 std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> sorted_hits =
::sortByLayer(outhits);
720 r.setHits(std::move(sorted_hits));
726 r.setHitLayers(hitLayers);
745 if (pairList.size() > 0)
748 LastPhiCurvature = PhiCurvature(pair);
749 LastEtaCurvature = EtaCurvature(pair);
752 pairList.push_back(pair);
754 hitLayers |= (0x1 << pair.first->hitptr->getLayer());
755 hitLayers |= (0x1 << pair.second->hitptr->getLayer());
756 if (!hasHit(pair.first))
757 hitlist.push_back(pair.first);
758 if (!hasHit(pair.second))
759 hitlist.push_back(pair.second);
760 return this->pairList.size();
766 if ((lastpair().
first->hitptr==pair.first->hitptr)||
767 (lastpair().
first->hitptr==pair.second->hitptr)||
768 (lastpair().
second->hitptr==pair.first->hitptr)||
769 (lastpair().
second->hitptr==pair.second->hitptr))
772 double dr = (lastpair().second->hitptr->getR() - pair.first->hitptr->getR()) / 2.0;
773 double lastpairextrap = lastpair().second->phiShift - lastpair().dPhi() / lastpair().dR() *
dr;
774 double newpairextrap = pair.first->phiShift + pair.
dPhi() / pair.
dR() *
dr;
775 return lastpairextrap - newpairextrap;
780 if ((lastpair().
first->hitptr==pair.first->hitptr)||
781 (lastpair().
first->hitptr==pair.second->hitptr)||
782 (lastpair().
second->hitptr==pair.first->hitptr)||
783 (lastpair().
second->hitptr==pair.second->hitptr))
786 double dr = (lastpair().second->hitptr->getR() - pair.first->hitptr->getR()) / 2.0;
787 double lastpairextrap = lastpair().second->etaShift - lastpair().dEta() / lastpair().dR() *
dr;
788 double newpairextrap = pair.first->etaShift + pair.
dEta() / pair.
dR() *
dr;
789 return lastpairextrap - newpairextrap;
794 return (pair.
dPhi() * lastpair().dR() - lastpair().
dPhi() * pair.
dR()) / (lastpair().dR() * pair.
dR());
799 return (pair.
dEta() * lastpair().dR() - lastpair().
dEta() * pair.
dR()) / (lastpair().dR() * pair.
dR());
804 return 2 * DeltaDeltaPhi(pair) / (lastpair().dR() + pair.
dR());
808 return 2 * DeltaDeltaEta(pair) / (lastpair().dR() + pair.
dR());
812 return PhiCurvature(pair) - LastPhiCurvature;
816 return EtaCurvature(pair) - LastEtaCurvature;
821 return lastpair().PhiInExtrap(r_in) + 0.5 * PhiCurvature(pair) * (r_in -
r) * (r_in -
r);
826 return pair.
PhiOutExtrap(r_out) + 0.5 * PhiCurvature(pair) * (r_out -
r) * (r_out -
r);
854 min_padded[
par] *= 1000;
855 max_padded[
par] *= 1000;
858 <<
" min=" << min_padded[
par] <<
" max=" << max_padded[
par]);
865 std::vector<FPGATrackSimGenScanBinningBase::ParSet> parsets =
m_binning->makeVariationSet(std::vector<unsigned>({0,1,2,3,4}),
bin.idx());
889 if (
bin.data() ==
false)
892 <<
" minvals: " << minvals <<
" maxvals: " << maxvals );
907 <<
" valid slices: " << validSlices
908 <<
" valid scans: " << validScans);