ATLAS Offline Software
FPGATrackSimGenScanTool.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
21 
22 #include <sstream>
23 #include <cmath>
24 #include <algorithm>
25 #include <limits>
26 
27 
28 #include <nlohmann/json.hpp>
29 
30 #include "TH1.h"
31 
32 namespace {
33  bool
34  nearZero(const double & v){
35  return std::abs(v)<=std::numeric_limits<double>::min();
36  }
37 }
38 
39 
40 
42 // Debug Print Tools
43 template<class T>
44 static inline std::string to_string(const std::vector<T>& v)
45 {
46  std::ostringstream oss;
47  oss << "[";
48  if (!v.empty())
49  {
50  std::copy(v.begin(), v.end() - 1, std::ostream_iterator<T>(oss, ", "));
51  oss << v.back();
52  }
53  oss << "]";
54  return oss.str();
55 }
56 
57 
59 // AthAlgTool
60 
61 FPGATrackSimGenScanTool::FPGATrackSimGenScanTool(const std::string& algname, const std::string &name, const IInterface *ifc) :
62  base_class(algname, name, ifc)
63 {
64  declareInterface<IFPGATrackSimRoadFinderTool>(this);
65 }
66 
67 
69 {
70  // Dump the configuration to make sure it propagated through right
71  const std::vector<Gaudi::Details::PropertyBase*> props = this->getProperties();
72  for( Gaudi::Details::PropertyBase* prop : props ) {
73  if (prop->ownerTypeName()==this->type()) {
74  ATH_MSG_DEBUG("Property:\t" << prop->name() << "\t : \t" << prop->toString());
75  }
76  }
77 
78  // Retrieve info
79  ATH_CHECK(m_FPGATrackSimMapping.retrieve());
80  ATH_MSG_INFO("Map specifies :" << m_binnedhits->getNLayers());
81  ATH_CHECK(m_binnedhits.retrieve());
82  ATH_CHECK(m_monitoring.retrieve());
83  ATH_MSG_INFO("Monitoring Dir :" << m_monitoring->dir());
84 
85  // Setup layer configuration if not already set from layerMap
86  if (m_binnedhits->getNLayers()==0){
87  auto nLogicalLayers = m_FPGATrackSimMapping->PlaneMap_1st(getSubRegion())->getNLogiLayers();
88  if (nLogicalLayers == 0){
89  ATH_MSG_ERROR("Number of logical layers is zero in FPGATrackSimGenScanTool::initialize");
90  return StatusCode::FAILURE;
91  }
92  m_binnedhits->setNLayers(nLogicalLayers);
93  }
94  // This is the layers they get paired with previous layers
95  for (unsigned lyr = 0; lyr < m_binnedhits->getNLayers(); ++lyr) m_pairingLayers.push_back(lyr);
96  if (m_reversePairDir) {
98  }
99  ATH_MSG_INFO("Pairing Layers: " << m_pairingLayers);
100 
101  // Check inputs
102  bool ok = false;
103  if (std::ssize(m_pairFilterDeltaPhiCut) != static_cast<int>(m_binnedhits->getNLayers()) - 1)
104  ATH_MSG_FATAL("initialize() pairFilterDeltaPhiCut must have size nLayers-1=" << m_binnedhits->getNLayers() - 1 << " found " << m_pairFilterDeltaPhiCut.size());
105  else if (m_pairFilterDeltaEtaCut.size() != m_binnedhits->getNLayers() - 1)
106  ATH_MSG_FATAL("initialize() pairFilterDeltaEtaCut must have size nLayers-1=" << m_binnedhits->getNLayers() - 1 << " found " << m_pairFilterDeltaEtaCut.size());
107  else if (m_pairFilterPhiExtrapCut.size() != 2)
108  ATH_MSG_FATAL("initialize() pairFilterPhiExtrapCut must have size 2 found " << m_pairFilterPhiExtrapCut.size());
109  else if (m_pairFilterEtaExtrapCut.size() != 2)
110  ATH_MSG_FATAL("initialize() pairFilterEtaExtrapCut must have size 2 found " << m_pairFilterEtaExtrapCut.size());
111  else if (m_pairSetPhiExtrapCurvedCut.size() != 2)
112  ATH_MSG_FATAL("initialize() PairSetPhiExtrapCurvedCut must have size 2found " << m_pairSetPhiExtrapCurvedCut.size());
113  else if ((m_rin < 0.0) || (m_rout < 0.0))
114  ATH_MSG_FATAL("Radii not set");
115  else
116  ok = true;
117  if (!ok)
118  return StatusCode::FAILURE;
119 
120 
121  // register histograms
122  ATH_CHECK(m_monitoring->registerHistograms(m_binnedhits.get()));
123 
124  // write out the firmware LUTs
125  m_binnedhits->getBinTool().writeLUTs();
126 
127  return StatusCode::SUCCESS;
128 }
129 
131 // Main Algorithm
132 
133 StatusCode FPGATrackSimGenScanTool::getRoads(const std::vector<std::shared_ptr<const FPGATrackSimHit>> &hits,
134  std::vector<std::shared_ptr<const FPGATrackSimRoad>> &roads)
135 {
136  ATH_MSG_DEBUG("In getRoads, Processing Event# " << ++m_evtsProcessed << " hit size = " << hits.size());
137 
138 
139  roads.clear();
140  m_roads.clear();
141  m_monitoring->resetDataFlowCounters();
142 
143  // Currently assume that if less than 100 hits its a single track MC
144  m_monitoring->parseTruthInfo(getTruthTracks(),(hits.size() < 100));
145 
146  // do the binning...
147  ATH_CHECK(m_binnedhits->fill(hits));
148  m_monitoring->fillBinningSummary(hits);
149 
150  // scan over image building pairs for bins over threshold
151  for (FPGATrackSimBinArray<BinEntry>::ConstIterator &bin : m_binnedhits->lastStepBinnedHits())
152  {
153  // apply threshold
154  if (bin.data().lyrCnt() < m_threshold) continue;
155  ATH_MSG_DEBUG("Bin passes threshold " << bin.data().lyrCnt() << " "
156  << bin.idx());
157 
158  // Monitor contents of bins passing threshold
159  m_monitoring->fillBinLevelOutput(bin.idx(), bin.data());
160  if (m_binningOnly) continue;
161 
162  // pass hits for bin to filterRoad and get back pairs of hits grouped into pairsets
163  std::vector<HitPairSet> pairsets;
164  if (m_binFilter=="PairThenGroup") {
165  ATH_CHECK(pairThenGroupFilter(bin.data(), pairsets));
166  } else if (m_binFilter=="IncrementalBuild") {
167  ATH_CHECK(incrementalBuildFilter(bin.data(), pairsets));
168  } else {
169  ATH_MSG_FATAL("Unknown bin filter" << m_binFilter);
170  }
171  ATH_MSG_DEBUG("grouped PairSets " << pairsets.size());
172 
173  // convert the group pairsets to FPGATrackSimRoads
174  for (const FPGATrackSimGenScanTool::HitPairSet& pairset: pairsets)
175  {
176  addRoad(pairset.hitlist, bin.idx());
177  ATH_MSG_DEBUG("Output road size=" <<pairset.hitlist.size());
178 
179  // debug statement if more than one road found in bin
180  // not necessarily a problem
181  if (pairsets.size() >1) {
182  std::string s = "";
183  for (const FPGATrackSimBinUtil::StoredHit* const hit : pairset.hitlist)
184  {
185  s += "(" + std::to_string(hit->layer) + "," + std::to_string(hit->hitptr->getR()) + "), ";
186  }
187  ATH_MSG_DEBUG("Duplicate Group " << s);
188  }
189  }
190  }
191 
192  // copy roads to output vector
193  roads.reserve(m_roads.size());
194 
195  if (m_keepHitsStrategy > 0) {
196  for (std::unique_ptr<FPGATrackSimRoad>& r : m_roads) {
197  const std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>>& theseHits = r->getAllHits();
198  layer_bitmask_t hitmask = r->getHitLayers();
199  std::vector<unsigned> toUse = PickHitsToUse(hitmask);
200 
201  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> vec(5); // even if not all layers have hits, they need to be in the vector as empty vectors
202  for (size_t ihit = 0; ihit < toUse.size(); ++ihit) {
203  unsigned int layer = toUse[ihit];
204  if (layer >= theseHits.size() || theseHits[layer].empty()) {
205  ATH_MSG_ERROR("Hit index out of range in keepHitsStrategy: layer=" << layer << ", hits.size()=" << theseHits.size());
206  return StatusCode::FAILURE;
207  }
208  vec[ihit].push_back(theseHits[layer][0]);
209  }
210  r->setHits(std::move(vec));
211  }
212  }
213 
214 
215  for (auto & r : m_roads) roads.push_back(std::move(r));
216  ATH_MSG_DEBUG("Roads = " << roads.size());
217 
218  // clear previous event
219  // (reusing saves having to reallocate memory for each event)
220  m_binnedhits->resetBins();
221 
222  m_evtsProcessed++;
223  return StatusCode::SUCCESS;
224 }
225 
226 // Filter the bins above threshold into pairsets which output roads
228  std::vector<HitPairSet> &output_pairsets)
229 {
230  ATH_MSG_VERBOSE("In pairThenGroupFilter");
231 
232  // Organize Hits by Layer
233  std::vector<std::vector<const StoredHit *>> hitsByLayer(m_binnedhits->getNLayers());
234  ATH_CHECK(sortHitsByLayer(bindata, hitsByLayer));
235 
236  // This is monitoring for each bin over threshold
237  // It's here so it can get the hitsByLayer
238  m_monitoring->fillHitsByLayer(hitsByLayer);
239 
240  // Make Pairs
242  ATH_CHECK(makePairs(hitsByLayer, pairs));
243 
244  // Filter Pairs
245  HitPairSet filteredpairs;
246  ATH_CHECK(filterPairs(pairs, filteredpairs));
247 
248  // Require road is still over threshold
249  bool passedPairFilter = (filteredpairs.lyrCnt() >= m_threshold);
250  m_monitoring->pairFilterCheck(pairs, filteredpairs, passedPairFilter);
251 
252  // if passed Pair Filter proceed to group the filtered pairs into pairsets
253  if (passedPairFilter)
254  {
255  // Pair Set Grouping
256  std::vector<HitPairSet> pairsets;
257  ATH_CHECK(groupPairs(filteredpairs, pairsets, false));
258 
259  // loop over pairsets and find those that are over thresold
260  for (const FPGATrackSimGenScanTool::HitPairSet& pairset : pairsets)
261  {
262  // if over threshold add it to the output
263  if (pairset.lyrCnt() >= m_threshold)
264  {
265  if (m_applyPairSetFilter) {
266  output_pairsets.push_back(pairset);
267  }
268  }
269  }
270  }
271 
272  // set outputs if not all filters applied
273  if (!m_applyPairFilter) {
274  // output is just the filtered pairs
275  output_pairsets.push_back(std::move(pairs));
276  }
277  else if (passedPairFilter && !m_applyPairSetFilter)
278  {
279  // output is just the filtered pairs
280  output_pairsets.push_back(std::move(filteredpairs));
281  }
282 
283  return StatusCode::SUCCESS;
284 }
285 
286 
288  IntermediateState &outputstate,
289  unsigned lyridx,
290  const std::vector<const StoredHit *>& newhits)
291 {
292  unsigned int allowed_missed_hits = m_binnedhits->getNLayers() - m_threshold;
293 
294  std::vector<bool> pairset_used(inputstate.pairsets.size(),false);
295 
296  for (auto &newhit : newhits) {
297 
298  // don't make new pairs with hits that the new hit is already paired with in a group
299  std::set<const StoredHit *> vetoList;
300 
301  // try adding hit to existing pair sets
302  for (unsigned ps_idx = 0; ps_idx < inputstate.pairsets.size(); ++ps_idx) {
303  auto &pairset = inputstate.pairsets[ps_idx];
304  HitPair nextpair(pairset.lastpair().second, newhit, m_reversePairDir);
305  if (pairMatchesPairSet(pairset, nextpair, false) || (m_applyPairSetFilter==false)) {
306  HitPairSet newset(pairset);
307  newset.addPair(nextpair);
308  pairset_used[ps_idx]=true;
309  outputstate.pairsets.push_back(newset);
310  // put inpair hits in list of hits not to pair again with the new hits
311  for (auto vetohit : pairset.hitlist) {
312  vetoList.insert(vetohit);
313  }
314  }
315  }
316 
317  // make new pairsets with unpaired hits
318  for (auto prevhit : inputstate.unpairedHits) {
319  if (vetoList.count(prevhit) == 0) {
320  HitPair newpair(prevhit, newhit, m_reversePairDir);
321  if (pairPassesFilter(newpair) || (m_applyPairFilter == false)) {
322  HitPairSet newset;
323  newset.addPair(newpair);
324  outputstate.pairsets.push_back(std::move(newset));
325  }
326  }
327  }
328 
329  // if this can be the start of a the start of a track and still
330  // have enough hits to make a track, add it to the unpaired hits list
331  if (lyridx <= allowed_missed_hits) {
332  outputstate.unpairedHits.push_back(newhit);
333  }
334  }
335 
336  // Add groups to output without new hit if they have enough hits to skip
337  // this layer. Note expected hits at this point is lyridx+1, since we start
338  // counting lyridx from zero. Logic is then keep the pairset if
339  // expected hits <= hits in set + allows misses
340  for (unsigned ps_idx = 0; ps_idx < inputstate.pairsets.size(); ++ps_idx) {
341  auto &pairset = inputstate.pairsets[ps_idx];
342  if ((!pairset_used[ps_idx])&&(lyridx < (pairset.hitlist.size() + allowed_missed_hits))) {
343  outputstate.pairsets.push_back(pairset);
344  }
345  }
346 
347  // Add hits to unpaired list if hits are still allowed to start a track
348  // ---------------------------------------------------------------------
349  // If you start a new track with a pair whose second element is
350  // layer N (layer numbering starting from zero), then you'll have missed N-1
351  // layers Minus 1 because the first hit was one of the N layers already
352  // passed.
353  //
354  // The next pass will be layer N=lyridx+1 where lyridx is the current value
355  // at this point in the code. You will have then missed lyridx layers, so...
356  // E.g. if you allow one missed layer then this stops putting hits in the
357  // unpairedHits list if lyridx>1, so tracks must start with layer 0 or 1,
358  // which makes sense
359  if (lyridx > allowed_missed_hits) {
360  // make no new track starts
361  outputstate.unpairedHits.clear();
362  } else {
363  // copy in any previous unpairedHits as well
364  for (auto prevhit : inputstate.unpairedHits) {
365  outputstate.unpairedHits.push_back(prevhit);
366  }
367  }
368 }
369 
370 // Filter the bins above threshold into pairsets which output roads
372  std::vector<HitPairSet> &output_pairsets)
373 {
374  ATH_MSG_VERBOSE("In buildGroupsWithPairs");
375 
376  // Organize Hits by Layer
377  std::vector<std::vector<const StoredHit *>> hitsByLayer(m_binnedhits->getNLayers());
378  ATH_CHECK(sortHitsByLayer(bindata, hitsByLayer));
379 
380  // This is monitoring for each bin over threshold
381  // It's here so it can get the hitsByLayer
382  m_monitoring->fillHitsByLayer(hitsByLayer);
383 
384  std::vector<IntermediateState> states{m_binnedhits->getNLayers()+1};
385  for (unsigned lyridx = 0; lyridx < m_binnedhits->getNLayers(); lyridx++) {
386  unsigned lyr = m_pairingLayers[lyridx];
387  updateState(states[lyridx] , states[lyridx+1], lyridx, hitsByLayer[lyr]);
388  }
389 
390  // this is a little ugly because it requires copying the output pairsets right now
391  output_pairsets=states[m_binnedhits->getNLayers()].pairsets;
392 
393  m_monitoring->fillBuildGroupsWithPairs(states,m_binnedhits->getNLayers()-m_threshold);
394 
395  return StatusCode::SUCCESS;
396 }
397 
398 
399 // 1st step of filter: sort hits by layer
401  std::vector<std::vector<const StoredHit *>>& hitsByLayer)
402 {
403  ATH_MSG_DEBUG("In fillHitsByLayer");
404 
405  for (const FPGATrackSimBinUtil::StoredHit &hit : bindata.hits) {
406  hitsByLayer.at(hit.layer).push_back(&hit);
407  }
408 
409  return StatusCode::SUCCESS;
410 }
411 
412 
413 
414 
415 
416 // 2nd step of filter: make pairs of hits from adjacent and next-to-adjacent layers
417 StatusCode FPGATrackSimGenScanTool::makePairs(const std::vector<std::vector<const StoredHit *>>& hitsByLayer,
418  HitPairSet &pairs)
419 {
420  ATH_MSG_VERBOSE("In makePairs");
421 
422  std::vector<const StoredHit *> const * lastlyr = 0;
423  std::vector<const StoredHit *> const * lastlastlyr = 0;
424 
425  // order here is designed so lower radius hits come first
426  for (unsigned lyr : m_pairingLayers) {
427  for (const StoredHit *const &ptr1 :
428  hitsByLayer[lyr]) {
429  if (lastlyr) {
430  for (const StoredHit *const &ptr2 : *lastlyr) {
431  pairs.addPair(HitPair(ptr2, ptr1,m_reversePairDir));
432  }
433  // Add Pairs that skip one layer
434  if (lastlastlyr) {
435  for (const StoredHit *const &ptr2 : *lastlastlyr) {
436  pairs.addPair(HitPair(ptr2, ptr1,m_reversePairDir));
437  }
438  }
439  }
440  }
441  lastlastlyr = lastlyr;
442  lastlyr = &hitsByLayer[lyr];
443  m_monitoring->fillPairingHits(lastlyr,lastlastlyr);
444  }
445 
446  return StatusCode::SUCCESS;
447 }
448 
449 // 3rd step of filter: make cuts on the pairs to ensure that are consisten with
450 // the bin they are in
451 
453  m_monitoring->fillPairFilterCuts(pair,m_rin,m_rout);
454  int lyr = std::min(pair.first->layer,pair.second->layer);
455  return (std::abs(pair.dPhi()) < m_pairFilterDeltaPhiCut[lyr]) &&
456  (std::abs(pair.dEta()) < m_pairFilterDeltaEtaCut[lyr]) &&
457  (std::abs(pair.PhiInExtrap(m_rin)) < m_pairFilterPhiExtrapCut[0]) &&
458  (std::abs(pair.PhiOutExtrap(m_rout)) < m_pairFilterPhiExtrapCut[1]) &&
459  (std::abs(pair.EtaInExtrap(m_rin)) < m_pairFilterEtaExtrapCut[0]) &&
460  (std::abs(pair.EtaOutExtrap(m_rout)) < m_pairFilterEtaExtrapCut[1]);
461 }
462 
464 {
465  ATH_MSG_VERBOSE("In filterPairs");
466 
467  for (const FPGATrackSimGenScanTool::HitPair &pair : pairs.pairList) {
468  if (pairPassesFilter(pair)) {
469  filteredpairs.addPair(pair);
470  }
471  }
472  return StatusCode::SUCCESS;
473 }
474 
475 
476 // 4th step of filter: group pairs into sets where they are all consistent with being from the same track
478  std::vector<HitPairSet> &pairsets,
479  bool verbose)
480 {
481  ATH_MSG_VERBOSE("In groupPairs");
482  for (const FPGATrackSimGenScanTool::HitPair & pair : filteredpairs.pairList)
483  {
484  bool added = false;
485  for (FPGATrackSimGenScanTool::HitPairSet &pairset : pairsets)
486  {
487  // Only add skip pairs if skipped layer is not already hit
488  if ((std::abs(int(pair.second->layer) - int(pair.first->layer)) > 1) // gives if is a skip pair
489  && (pairset.hasLayer(std::min(pair.first->layer,pair.second->layer) + 1))) // gives true if skipped layer already in set
490  {
491  // if it matches mark as added so it doesn't start a new pairset
492  // false here is so it doesn't plot these either
493  if (pairMatchesPairSet(pairset, pair, verbose))
494  added = true;
495  if (!added) {
496  ATH_MSG_VERBOSE("Skip pair does not match non-skip pair");
497  }
498  }
499  else
500  {
501  if (pairMatchesPairSet(pairset, pair, verbose))
502  {
503  int size = pairset.addPair(pair);
504  if (verbose)
505  ATH_MSG_VERBOSE("addPair " << pairsets.size() << " " << pairset.pairList.size() << " " << size);
506  added = true;
507  }
508  }
509 
510  }
511 
512  if (!added)
513  {
514  HitPairSet newpairset;
515  newpairset.addPair(pair);
516  pairsets.push_back(std::move(newpairset));
517  }
518  }
519 
520  return StatusCode::SUCCESS;
521 
522 }
523 
524 // used to determine if a pair is consistend with a pairset
526  const HitPair &pair,
527  bool verbose) {
528  // In order to make it easy to have a long list of possible cuts,
529  // a vector of cutvar structs is used to represent each cut
530  // then apply the AND of all the cuts is done with a std::count_if function
531 
532  // define the struct (effectively mapping because variable, configured cut value,
533  // and histograms for plotting
534  struct cutvar {
535  cutvar(std::string name, double val, double cut, std::vector<TH1D *>& histset) :
536  m_name(std::move(name)), m_val(val), m_cut(cut), m_histset(histset) {}
537  bool passed() { return std::abs(m_val) < m_cut; }
538  void fill(unsigned cat) { m_histset[cat]->Fill(m_val); }
539  std::string m_name;
540  double m_val;
541  double m_cut;
542  std::vector<TH1D *> &m_histset;
543  };
544 
545  // add the cuts to the list of all cuts
546  std::vector<cutvar> allcuts;
547  allcuts.push_back(cutvar("MatchPhi", pairset.MatchPhi(pair),
549  m_monitoring->m_pairSetMatchPhi));
550  allcuts.push_back(cutvar("MatchEta", pairset.MatchEta(pair),
552  m_monitoring->m_pairSetMatchEta));
553  allcuts.push_back(cutvar("DeltaDeltaPhi", pairset.DeltaDeltaPhi(pair),
555  m_monitoring->m_deltaDeltaPhi));
556  allcuts.push_back(cutvar("DeltaDeltaEta", pairset.DeltaDeltaEta(pair),
558  m_monitoring->m_deltaDeltaEta));
559  allcuts.push_back(cutvar("PhiCurvature", pairset.PhiCurvature(pair),
561  m_monitoring->m_phiCurvature));
562  allcuts.push_back(cutvar("EtaCurvature", pairset.EtaCurvature(pair),
564  m_monitoring->m_etaCurvature));
565  if (pairset.pairList.size() > 1) {
566  allcuts.push_back(cutvar(
567  "DeltaPhiCurvature", pairset.DeltaPhiCurvature(pair),
568  m_pairSetDeltaPhiCurvatureCut, m_monitoring->m_deltaPhiCurvature));
569  allcuts.push_back(cutvar(
570  "DeltaEtaCurvature", pairset.DeltaEtaCurvature(pair),
571  m_pairSetDeltaEtaCurvatureCut, m_monitoring->m_deltaEtaCurvature));
572  }
573  allcuts.push_back(cutvar(
574  "PhiInExtrapCurved", pairset.PhiInExtrapCurved(pair, m_rin),
575  m_pairSetPhiExtrapCurvedCut[0], m_monitoring->m_phiInExtrapCurved));
576  allcuts.push_back(cutvar(
577  "PhiOutExtrapCurved", pairset.PhiOutExtrapCurved(pair, m_rout),
578  m_pairSetPhiExtrapCurvedCut[1], m_monitoring->m_phiOutExtrapCurved));
579 
580  // count number of cuts passed
581  unsigned passedCuts = std::count_if(allcuts.begin(), allcuts.end(),
582  [](cutvar& cut) { return cut.passed(); });
583  bool passedAll = (passedCuts == allcuts.size());
584 
585  // monitoring
586  bool passedAllButOne = (passedCuts == allcuts.size() - 1);
587  for (cutvar& cut: allcuts) {
588  // the last value computes if an n-1 histogram should be filled
589  m_monitoring->fillPairSetFilterCut(cut.m_histset, cut.m_val, pair,
590  pairset.lastpair(),
591  (passedAll || (passedAllButOne && !cut.passed())));
592  }
593 
594  if (verbose)
595  {
596  std::string s = "";
597  for (cutvar &cut : allcuts)
598  {
599  s += cut.m_name + " : (" + cut.passed() + ", " + cut.m_val + "), ";
600  }
601  ATH_MSG_DEBUG("PairSet test " << passedAll << " " << s);
602  ATH_MSG_DEBUG("Hits: \n " << *pairset.lastpair().first << "\n "
603  << *pairset.lastpair().second << "\n "
604  << *pair.first << "\n "
605  << *pair.second);
606  }
607 
608  return passedAll;
609 }
610 
611 // format final pairsets into expected output of getRoads
612 void FPGATrackSimGenScanTool::addRoad(std::vector<const StoredHit *> const &hits, const FPGATrackSimBinUtil::IdxSet &idx)
613 {
614  layer_bitmask_t hitLayers = 0;
615  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>>
616  sorted_hits(m_binnedhits->getNLayers(),std::vector<std::shared_ptr<const FPGATrackSimHit>>());
617  for (const FPGATrackSimBinUtil::StoredHit* hit : hits)
618  {
619  hitLayers |= 1 << hit->layer;
620  sorted_hits[hit->layer].push_back(hit->hitptr);
621  }
622 
623  // "Fit" the track.
624  FPGATrackSimTrackPars fittedpars;
625  double chi2;
626  bool inBin = fitRoad(hits, idx, fittedpars, chi2);
627  if (!inBin && m_inBinFiltering) return;
628 
629  m_roads.emplace_back(std::make_unique<FPGATrackSimRoad>());
630  FPGATrackSimRoad *r = m_roads.back().get();
631 
632  r->setRoadID(m_roads.size() - 1);
633  // r.setPID(y * m_imageSize_y + x);
634  r->setHits(std::move(sorted_hits));
635 
636  FPGATrackSimBinUtil::ParSet binCenterPars = m_binnedhits->getBinTool().lastStep()->binCenter(idx);
637  FPGATrackSimTrackPars trackpars = m_binnedhits->getBinTool().binDesc()->parSetToTrackPars(binCenterPars);
638  r->setX(trackpars[FPGATrackSimTrackPars::IPHI]);
639  r->setY(trackpars[FPGATrackSimTrackPars::IHIP]);
640  r->setXBin(idx[3]);
641  r->setYBin(idx[4]);
642  r->setHitLayers(hitLayers);
643  r->setSubRegion(0);
644 
645  // Store the fitted information on the track.
646  r->setFitParams(fittedpars);
647  r->setFitChi2(chi2);
648 }
649 
650 
652 // HitPair and HitPairSet Storage
653 
655 {for (const FPGATrackSimBinUtil::StoredHit* hit : hitlist)
656  {
657  if (hit == newhit)
658  return true;
659  }
660  return false;
661 }
662 
664 {
665  if (pairList.size() > 0)
666  {
667  // these need to be done before the pair is added
668  LastPhiCurvature = PhiCurvature(pair);
669  LastEtaCurvature = EtaCurvature(pair);
670  }
671 
672  pairList.push_back(pair);
673 
674  hitLayers |= (0x1 << pair.first->layer);
675  hitLayers |= (0x1 << pair.second->layer);
676  if (!hasHit(pair.first))
677  hitlist.push_back(pair.first);
678  if (!hasHit(pair.second))
679  hitlist.push_back(pair.second);
680  return this->pairList.size();
681 }
682 
683 
685 {
686  if ((lastpair().first->hitptr==pair.first->hitptr)||
687  (lastpair().first->hitptr==pair.second->hitptr)||
688  (lastpair().second->hitptr==pair.first->hitptr)||
689  (lastpair().second->hitptr==pair.second->hitptr))
690  return 0.0;
691 
692  double dr = (lastpair().second->hitptr->getR() - pair.first->hitptr->getR()) / 2.0;
693  double lastpairextrap = lastpair().second->phiShift - lastpair().dPhi() / lastpair().dR() * dr;
694  double newpairextrap = pair.first->phiShift + pair.dPhi() / pair.dR() * dr;
695  return lastpairextrap - newpairextrap;
696 }
697 
699 {
700  if ((lastpair().first->hitptr==pair.first->hitptr)||
701  (lastpair().first->hitptr==pair.second->hitptr)||
702  (lastpair().second->hitptr==pair.first->hitptr)||
703  (lastpair().second->hitptr==pair.second->hitptr))
704  return 0.0;
705 
706  double dr = (lastpair().second->hitptr->getR() - pair.first->hitptr->getR()) / 2.0;
707  double lastpairextrap = lastpair().second->etaShift - lastpair().dEta() / lastpair().dR() * dr;
708  double newpairextrap = pair.first->etaShift + pair.dEta() / pair.dR() * dr;
709  return lastpairextrap - newpairextrap;
710 }
711 
712 double
714  return (pair.dPhi() * lastpair().dR() - lastpair().dPhi() * pair.dR()) / (lastpair().dR() * pair.dR());
715 }
716 
718 {
719  return (pair.dEta() * lastpair().dR() - lastpair().dEta() * pair.dR()) / (lastpair().dR() * pair.dR());
720 }
721 
723 {
724  return 2 * DeltaDeltaPhi(pair) / (lastpair().dR() + pair.dR());
725 }
727 {
728  return 2 * DeltaDeltaEta(pair) / (lastpair().dR() + pair.dR());
729 }
731 {
732  return PhiCurvature(pair) - LastPhiCurvature;
733 }
735 {
736  return EtaCurvature(pair) - LastEtaCurvature;
737 }
739 {
740  double r = std::min(lastpair().first->hitptr->getR(),lastpair().second->hitptr->getR());
741  return lastpair().PhiInExtrap(r_in) + 0.5 * PhiCurvature(pair) * (r_in - r) * (r_in - r);
742 }
744 {
745  double r = std::max(lastpair().first->hitptr->getR(),lastpair().second->hitptr->getR());
746  return pair.PhiOutExtrap(r_out) + 0.5 * PhiCurvature(pair) * (r_out - r) * (r_out - r);
747 }
748 
749 
750 // format final pairsets into expected output of getRoads
751 bool FPGATrackSimGenScanTool::fitRoad(std::vector<const StoredHit *> const &hits, const FPGATrackSimBinUtil::IdxSet &idx, FPGATrackSimTrackPars& trackpars, double& chi2) const
752 {
753 
754  double N =hits.size();
755  double sum_Phi = 0;
756  double sum_Phi2 = 0;
757  double sum_PhiR = 0;
758  double sum_PhiR2 = 0;
759  double sum_Eta = 0;
760  double sum_Eta2 = 0;
761  double sum_EtaR = 0;
762  double sum_R = 0;
763  double sum_R2 = 0;
764  double sum_R3 = 0;
765  double sum_R4 = 0;
766 
767  for (const FPGATrackSimBinUtil::StoredHit* hit : hits)
768  {
769  // these are just relevant sums of variables (moments) needed for the chi2 calculation
770  // Calculate r^2, r^3, and r^4, we'll sum these up later below
771  double r = hit->hitptr->getR();
772  double r2 = r*r;
773  double r3 = r2*r;
774  double r4 = r3*r;
775  double dphi = hit->phiShift;
776  double dphi2 = dphi*dphi;
777  double deta = hit->etaShift;
778  double deta2 = deta*deta;
779 
780  sum_Phi += dphi;
781  sum_Phi2 += dphi2;
782  sum_PhiR += dphi*r;
783  sum_PhiR2 += dphi*r2;
784  sum_Eta += deta;
785  sum_Eta2 += deta2;
786  sum_EtaR += deta*r;
787  sum_R += r;
788  sum_R2 += r2;
789  sum_R3 += r3;
790  sum_R4 += r4;
791  }
792 
793  // phi var calculation
794  // phi(r) = phivars[0] + phivars[1]*r + phivars[2]*r^2
795  // math below is calculated by analytically minimizing the chi2
796  // and solving for the phivars.
797  // the terms below which recur in the phivar expression are just organized
798  // by the power of r (i.e. the dimension), but otherwise have no deep meaning
799  double r6_t0 = (-sum_R2 * sum_R4 + sum_R3*sum_R3);
800  double r5_t0 = (sum_R*sum_R4 - sum_R2*sum_R3);
801  double r4_t0 = (-sum_R * sum_R3 + sum_R2*sum_R2);
802  double r4_t1 = (-N*sum_R4 + sum_R2*sum_R2);
803  double r3_t0 = (N*sum_R3 - sum_R*sum_R2);
804  double r2_t0 = (-N*sum_R2 + sum_R*sum_R);
805 
806  // all three phi var expresions use the same demoninator
807  const double denom_phi = N * r6_t0 + sum_R * r5_t0 + sum_R2 * r4_t0;
808  if (nearZero(denom_phi)){
809  ATH_MSG_ERROR("Divide by zero (phi) trapped in FPGATrackSimGenScanTool::fitRoad");
810  return false;
811  }
812 
813  // phivar expresions from analytic chi2 minimization
814  std::vector<double> phivars(3);
815  phivars[0] = (sum_Phi*r6_t0 + sum_PhiR*r5_t0 + sum_PhiR2*r4_t0)/denom_phi;
816  phivars[1] = (sum_Phi*r5_t0 + sum_PhiR*r4_t1 + sum_PhiR2*r3_t0)/denom_phi;
817  phivars[2] = (sum_Phi*r4_t0 + sum_PhiR*r3_t0 + sum_PhiR2*r2_t0)/denom_phi;
818 
819  // eta vars
820  // same as phi but with not curvature (r^2) term
821  const double denom_eta = N*sum_R2 - sum_R*sum_R;
822  if (nearZero(denom_eta)){
823  ATH_MSG_ERROR("Divide by zero (eta) trapped in FPGATrackSimGenScanTool::fitRoad");
824  return false;
825  }
826 
827  std::vector<double> etavars(2);
828  etavars[0] = (-sum_R*sum_EtaR + sum_R2*sum_Eta)/denom_eta;
829  etavars[1] = (N*sum_EtaR - sum_R*sum_Eta)/denom_eta;
830 
831  // bin center
832  FPGATrackSimBinUtil::ParSet parset = m_binnedhits->getBinTool().lastStep()->binCenter(idx);
833  double parshift[FPGATrackSimTrackPars::NPARS];
834  parshift[0] = etavars[0] + etavars[1]*m_rin; // z at r in
835  parshift[1]= etavars[0] + etavars[1]*m_rout; // z at r out
836  parshift[2]= -(phivars[0]/m_rin + phivars[1] + phivars[2]*m_rin) ; // phi at r in
837  parshift[3]= -(phivars[0]/m_rout + phivars[1] + phivars[2]*m_rout) ; // phi at r out
838  double y = (m_rout-m_rin); // midpoint between rin and rout from rin
839  parshift[4]= -phivars[2]/4.0*y*y ; // xm
840 
841  bool inBin = true;
842  const auto& lastStep = m_binnedhits->getBinTool().lastStep();
843  for (int par = 0; par < FPGATrackSimTrackPars::NPARS; par++ ){
844  parset[par]+=parshift[par];
845  inBin = inBin && (std::abs(parshift[par]) < lastStep->binWidth(par)/2.0);
846  }
847 
848  double ec0 = etavars[0];
849  double ec1 = etavars[1];
850  double eta_chi2 = sum_Eta2 - 2*ec0*sum_Eta - 2*ec1*sum_EtaR + N*ec0*ec0 + 2*ec0*ec1*sum_R + ec1*ec1*sum_R2;
851 
852  double pc0 = phivars[0];
853  double pc1 = phivars[1];
854  double pc2 = phivars[2];
855 
856  double phi_chi2 = sum_Phi2 - 2*pc0*sum_Phi - 2*pc1*sum_PhiR - 2*pc2*sum_PhiR2 + N*pc0*pc0 + 2*pc0*pc1*sum_R + 2*pc0*pc2*sum_R2 + 2*pc1*pc2*sum_R3 + pc1*pc1*sum_R2 + pc2*pc2*sum_R4;
857 
858  for (const FPGATrackSimBinUtil::StoredHit* hit : hits)
859  {
860  double r = hit->hitptr->getR();
861  ATH_MSG_VERBOSE("Fitted r= " << r << " phishift " << hit->phiShift << " =?= " << pc0+pc1*r+pc2*r*r << " etashift " << hit->etaShift << " =?= " << ec0+ec1*r);
862  }
863 
864  ATH_MSG_DEBUG("Bin Info parset " << idx << " " << m_binnedhits->getBinTool().lastStep()->binCenter(idx));
865  ATH_MSG_DEBUG("Fitted parset inBin="<< inBin << " nhits=" << hits.size() << " " << parset << " chi2 " << eta_chi2 << "," << phi_chi2);
866 
867  // Return by reference the "fitted" track parameters. shift q/pt dimension (GeV/MeV)
868  trackpars = m_binnedhits->getBinTool().binDesc()->parSetToTrackPars(parset);
869  trackpars[FPGATrackSimTrackPars::IHIP] = trackpars[FPGATrackSimTrackPars::IHIP] / 1000;
870  ATH_MSG_VERBOSE("Fitted track pars" << trackpars);
871 
872  // and the summed chi2, which is assuming (right now) an even weighting between the two components.
873  chi2 = std::sqrt(m_etaWeight * eta_chi2 * eta_chi2 + m_phiWeight * phi_chi2 * phi_chi2);
874 
875  return inBin;
876 }
877 
878 std::vector<unsigned> FPGATrackSimGenScanTool::PickHitsToUse(layer_bitmask_t hitmask) const
879 {
880  std::vector<unsigned> toUse;
881  switch (m_keepHitsStrategy) {
882  case 1: // try and pick hits furthest apart, use only 3
883  {
884  if (hitmask == 0x1f) { // miss no hits
885  toUse = {0,2,4};
886  }
887  else if (hitmask == 0x1e) { // miss inner layer, ie layer 0
888  toUse = {1,3,4};
889  }
890  else if (hitmask == 0x1d) { // miss layer 1
891  toUse = {0,2,4};
892  }
893  else if (hitmask == 0x1b) { // miss layer 2
894  toUse = {0,3,4};
895  }
896  else if (hitmask == 0x17) { // miss layer 3
897  toUse = {0,2,4};
898  }
899  else if (hitmask == 0x0f) { // miss layer 4
900  toUse = {0,2,3};
901  }
902  }
903  break;
904  case 2: // pick inner hits, use only 3
905  {
906  if (hitmask == 0x1f) { // miss no hits
907  toUse = {0,1,2};
908  }
909  else if (hitmask == 0x1e) { // miss inner layer, ie layer 0
910  toUse = {1,2,3};
911  }
912  else if (hitmask == 0x1d) { // miss layer 1
913  toUse = {0,2,3};
914  }
915  else if (hitmask == 0x1b) { // miss layer 2
916  toUse = {0,1,3};
917  }
918  else if (hitmask == 0x17) { // miss layer 3
919  toUse = {0,1,2};
920  }
921  else if (hitmask == 0x0f) { // miss layer 4
922  toUse = {0,1,2};
923  }
924  }
925  break;
926  case 3: // pick outer hits, use only 3
927  {
928  if (hitmask == 0x1f) { // miss no hits
929  toUse = {2,3,4};
930  }
931  else if (hitmask == 0x1e) { // miss inner layer, ie layer 0
932  toUse = {2,3,4};
933  }
934  else if (hitmask == 0x1d) { // miss layer 1
935  toUse = {2,3,4};
936  }
937  else if (hitmask == 0x1b) { // miss layer 2
938  toUse = {1,3,4};
939  }
940  else if (hitmask == 0x17) { // miss layer 3
941  toUse = {1,2,4};
942  }
943  else if (hitmask == 0x0f) { // miss layer 4
944  toUse = {1,2,3};
945  }
946  }
947  break;
948  case 4: // keep 4 hits, choose middle one to drop if necessary
949  {
950  if (hitmask == 0x1f) { // miss no hits
951  toUse = {0,1,2,3};
952  }
953  else if (hitmask == 0x1e) { // miss inner layer, ie layer 0
954  toUse = {1,2,3,4};
955  }
956  else if (hitmask == 0x1d) { // miss layer 1
957  toUse = {0,2,3,4};
958  }
959  else if (hitmask == 0x1b) { // miss layer 2
960  toUse = {0,1,3,4};
961  }
962  else if (hitmask == 0x17) { // miss layer 3
963  toUse = {0,1,2,4};
964  }
965  else if (hitmask == 0x0f) { // miss layer 4
966  toUse = {0,1,2,3};
967  }
968  }
969  break;
970  }
971  return toUse;
972 }
FPGATrackSimGenScanTool::m_pairFilterEtaExtrapCut
Gaudi::Property< std::vector< double > > m_pairFilterEtaExtrapCut
Definition: FPGATrackSimGenScanTool.h:119
FPGATrackSimGenScanTool::IntermediateState::unpairedHits
std::vector< const StoredHit * > unpairedHits
Definition: FPGATrackSimGenScanTool.h:262
FPGATrackSimTrackPars::IHIP
@ IHIP
Definition: FPGATrackSimTrackPars.h:49
beamspotman.r
def r
Definition: beamspotman.py:672
FPGATrackSimGenScanTool::m_keepHitsStrategy
Gaudi::Property< int > m_keepHitsStrategy
Definition: FPGATrackSimGenScanTool.h:134
FPGATrackSimGenScanTool::pairMatchesPairSet
bool pairMatchesPairSet(const HitPairSet &pairset, const HitPair &pair, bool verbose)
Definition: FPGATrackSimGenScanTool.cxx:525
FPGATrackSimBinUtil::StoredHit::hitptr
std::shared_ptr< const FPGATrackSimHit > hitptr
Definition: FPGATrackSimBinUtil.h:103
FPGATrackSimGenScanTool::m_pairSetPhiCurvatureCut
Gaudi::Property< double > m_pairSetPhiCurvatureCut
Definition: FPGATrackSimGenScanTool.h:126
getMenu.algname
algname
Definition: getMenu.py:54
FPGATrackSimGenScanTool::HitPair::PhiInExtrap
double PhiInExtrap(double r_in) const
Definition: FPGATrackSimGenScanTool.h:200
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
FPGATrackSimGenScanTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimGenScanTool.cxx:68
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSimGenScanTool::filterPairs
StatusCode filterPairs(HitPairSet &pairs, HitPairSet &filteredpairs)
Definition: FPGATrackSimGenScanTool.cxx:463
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:118
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimGenScanTool::m_binFilter
Gaudi::Property< std::string > m_binFilter
Definition: FPGATrackSimGenScanTool.h:111
FPGATrackSimGenScanTool::updateState
void updateState(const IntermediateState &inputstate, IntermediateState &outputstate, unsigned lyridx, const std::vector< const StoredHit * > &newhits)
Definition: FPGATrackSimGenScanTool.cxx:287
FPGATrackSimGenScanTool.h
Implements a generalized 5d scan which filters pair of hits in bins linearized about nominal trajecto...
AthMsgStreamMacros.h
FPGATrackSimGenScanTool::m_rin
Gaudi::Property< double > m_rin
Definition: FPGATrackSimGenScanTool.h:105
FPGATrackSimPlaneMap.h
Maps physical layers to logical layers.
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
FPGATrackSimGenScanTool::m_phiWeight
Gaudi::Property< double > m_phiWeight
Definition: FPGATrackSimGenScanTool.h:131
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
IFPGATrackSimMappingSvc.h
FPGATrackSimBinUtil::StoredHit::layer
unsigned layer
Definition: FPGATrackSimBinUtil.h:106
FPGATrackSimGenScanTool::HitPairSet::PhiOutExtrapCurved
double PhiOutExtrapCurved(const HitPair &pair, double r_out) const
Definition: FPGATrackSimGenScanTool.cxx:743
FPGATrackSimGenScanMonitoring.h
This is the monitoring for the FPGATrackSimGenScanTool.
python.SystemOfUnits.second
float second
Definition: SystemOfUnits.py:135
FPGATrackSimGenScanTool::makePairs
StatusCode makePairs(const std::vector< std::vector< const StoredHit * >> &hitsByLayer, HitPairSet &pairs)
Definition: FPGATrackSimGenScanTool.cxx:417
bin
Definition: BinsDiffFromStripMedian.h:43
FPGATrackSimGenScanTool::HitPairSet::MatchEta
double MatchEta(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:698
FPGATrackSimGenScanTool::sortHitsByLayer
StatusCode sortHitsByLayer(const BinEntry &bindata, std::vector< std::vector< const StoredHit * >> &hitsByLayer)
Definition: FPGATrackSimGenScanTool.cxx:400
FPGATrackSimGenScanTool::HitPairSet::DeltaDeltaPhi
double DeltaDeltaPhi(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:713
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
FPGATrackSimGenScanTool::m_binnedhits
ToolHandle< FPGATrackSimBinnedHits > m_binnedhits
Definition: FPGATrackSimGenScanTool.h:101
FPGATrackSimGenScanTool::HitPair::EtaOutExtrap
double EtaOutExtrap(double r_out) const
Definition: FPGATrackSimGenScanTool.h:203
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:111
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
m_name
std::string m_name
Definition: ColumnarPhysliteTest.cxx:63
FPGATrackSimGenScanTool::m_evtsProcessed
int m_evtsProcessed
Definition: FPGATrackSimGenScanTool.h:268
FPGATrackSimGenScanTool::HitPairSet::hasHit
bool hasHit(const StoredHit *hit) const
Definition: FPGATrackSimGenScanTool.cxx:654
FPGATrackSimGenScanTool::IntermediateState
Definition: FPGATrackSimGenScanTool.h:261
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
python.CreateTierZeroArgdict.pairs
pairs
Definition: CreateTierZeroArgdict.py:201
FPGATrackSimGenScanTool::HitPair::dR
double dR() const
Definition: FPGATrackSimGenScanTool.h:188
FPGATrackSimRegionMap.h
Maps ITK module indices to FPGATrackSim regions.
FPGATrackSimGenScanTool::m_etaWeight
Gaudi::Property< double > m_etaWeight
Definition: FPGATrackSimGenScanTool.h:132
FPGATrackSimGenScanTool::m_pairFilterPhiExtrapCut
Gaudi::Property< std::vector< double > > m_pairFilterPhiExtrapCut
Definition: FPGATrackSimGenScanTool.h:118
FPGATrackSimGenScanTool::getSubRegion
virtual int getSubRegion() const override
Definition: FPGATrackSimGenScanTool.h:90
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
FPGATrackSimGenScanTool::IntermediateState::pairsets
std::vector< HitPairSet > pairsets
Definition: FPGATrackSimGenScanTool.h:263
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
FPGATrackSimGenScanTool::m_pairSetDeltaDeltaEtaCut
Gaudi::Property< double > m_pairSetDeltaDeltaEtaCut
Definition: FPGATrackSimGenScanTool.h:125
FPGATrackSimGenScanTool::m_pairSetDeltaEtaCurvatureCut
Gaudi::Property< double > m_pairSetDeltaEtaCurvatureCut
Definition: FPGATrackSimGenScanTool.h:129
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimGenScanTool::HitPairSet::PhiCurvature
double PhiCurvature(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:722
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FPGATrackSimBinUtil.h
Binning Utilities for GenScanTool.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FPGATrackSimGenScanTool::m_binningOnly
Gaudi::Property< bool > m_binningOnly
Definition: FPGATrackSimGenScanTool.h:113
urldecode::states
states
Definition: urldecode.h:39
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FPGATrackSimGenScanTool::m_threshold
Gaudi::Property< unsigned > m_threshold
Definition: FPGATrackSimGenScanTool.h:109
FPGATrackSimGenScanTool::PickHitsToUse
std::vector< unsigned > PickHitsToUse(layer_bitmask_t) const
Definition: FPGATrackSimGenScanTool.cxx:878
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, float &out)
Definition: TauGNNUtils.cxx:401
FPGATrackSimGenScanTool::FPGATrackSimGenScanTool
FPGATrackSimGenScanTool(const std::string &algname, const std::string &name, const IInterface *ifc)
Definition: FPGATrackSimGenScanTool.cxx:61
FPGATrackSimGenScanTool::HitPairSet
Definition: FPGATrackSimGenScanTool.h:216
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
FPGATrackSimGenScanTool::HitPairSet::DeltaDeltaEta
double DeltaDeltaEta(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:717
FPGATrackSimGenScanTool::m_pairSetDeltaPhiCurvatureCut
Gaudi::Property< double > m_pairSetDeltaPhiCurvatureCut
Definition: FPGATrackSimGenScanTool.h:128
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimGenScanTool::m_pairSetEtaCurvatureCut
Gaudi::Property< double > m_pairSetEtaCurvatureCut
Definition: FPGATrackSimGenScanTool.h:127
FPGATrackSimGenScanTool::HitPairSet::DeltaPhiCurvature
double DeltaPhiCurvature(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:730
FPGATrackSimGenScanTool::HitPairSet::addPair
int addPair(const HitPair &pair)
Definition: FPGATrackSimGenScanTool.cxx:663
FPGATrackSimBinUtil::ParSet
Definition: FPGATrackSimBinUtil.h:45
FPGATrackSimBinArray::ConstIterator
Definition: FPGATrackSimBinArray.h:127
FPGATrackSimGenScanTool::m_monitoring
ToolHandle< FPGATrackSimGenScanMonitoring > m_monitoring
Definition: FPGATrackSimGenScanTool.h:100
FPGATrackSimGenScanTool::m_pairSetDeltaDeltaPhiCut
Gaudi::Property< double > m_pairSetDeltaDeltaPhiCut
Definition: FPGATrackSimGenScanTool.h:124
FPGATrackSimGenScanTool::pairPassesFilter
bool pairPassesFilter(const HitPair &pair)
Definition: FPGATrackSimGenScanTool.cxx:452
FPGATrackSimGenScanTool::getRoads
virtual StatusCode getRoads(const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits, std::vector< std::shared_ptr< const FPGATrackSimRoad >> &road) override
Definition: FPGATrackSimGenScanTool.cxx:133
FPGATrackSimBinnedHits::BinEntry
Definition: FPGATrackSimBinnedHits.h:70
FPGATrackSimBinUtil::StoredHit
Definition: FPGATrackSimBinUtil.h:101
FPGATrackSimGenScanTool::groupPairs
StatusCode groupPairs(HitPairSet &filteredpairs, std::vector< HitPairSet > &clusters, bool verbose)
Definition: FPGATrackSimGenScanTool.cxx:477
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:28
FPGATrackSimGenScanTool::m_roads
std::vector< std::unique_ptr< FPGATrackSimRoad > > m_roads
Definition: FPGATrackSimGenScanTool.h:272
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
FPGATrackSimGenScanTool::m_pairSetMatchPhiCut
Gaudi::Property< double > m_pairSetMatchPhiCut
Definition: FPGATrackSimGenScanTool.h:122
FPGATrackSimGenScanTool::HitPair::dPhi
double dPhi() const
Definition: FPGATrackSimGenScanTool.h:186
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
FPGATrackSimGenScanTool::HitPairSet::DeltaEtaCurvature
double DeltaEtaCurvature(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:734
FPGATrackSimGenScanTool::m_pairFilterDeltaEtaCut
Gaudi::Property< std::vector< double > > m_pairFilterDeltaEtaCut
Definition: FPGATrackSimGenScanTool.h:117
FPGATrackSimTrackPars::IPHI
@ IPHI
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimGenScanTool::HitPairSet::pairList
std::vector< HitPair > pairList
Definition: FPGATrackSimGenScanTool.h:221
FPGATrackSimGenScanTool::m_applyPairSetFilter
Gaudi::Property< bool > m_applyPairSetFilter
Definition: FPGATrackSimGenScanTool.h:121
python.PyAthena.v
v
Definition: PyAthena.py:154
FPGATrackSimGenScanTool::HitPair::dEta
double dEta() const
Definition: FPGATrackSimGenScanTool.h:187
FPGATrackSimGenScanTool::HitPair
Definition: FPGATrackSimGenScanTool.h:183
y
#define y
IFPGATrackSimEventSelectionSvc.h
lumiFormat.fill
fill
Definition: lumiFormat.py:104
FPGATrackSimGenScanTool::HitPairSet::lastpair
const HitPair & lastpair() const
Definition: FPGATrackSimGenScanTool.h:236
FPGATrackSimGenScanTool::HitPairSet::EtaCurvature
double EtaCurvature(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:726
FPGATrackSimGenScanTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimGenScanTool.h:99
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
layer_bitmask_t
uint32_t layer_bitmask_t
Definition: FPGATrackSimTypes.h:22
FPGATrackSimGenScanTool::m_applyPairFilter
Gaudi::Property< bool > m_applyPairFilter
Definition: FPGATrackSimGenScanTool.h:114
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:296
DeMoScan.first
bool first
Definition: DeMoScan.py:534
FPGATrackSimGenScanTool::HitPairSet::lyrCnt
unsigned int lyrCnt() const
Definition: FPGATrackSimGenScanTool.h:241
FPGATrackSimTrackPars::NPARS
@ NPARS
Definition: FPGATrackSimTrackPars.h:49
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, float &out)
Definition: TauGNNUtils.cxx:412
FPGATrackSimGenScanTool::fitRoad
bool fitRoad(std::vector< const StoredHit * > const &hits, const FPGATrackSimBinUtil::IdxSet &idx, FPGATrackSimTrackPars &trackpars, double &chi2) const
Definition: FPGATrackSimGenScanTool.cxx:751
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
FPGATrackSimGenScanTool::HitPairSet::hitlist
std::vector< const StoredHit * > hitlist
Definition: FPGATrackSimGenScanTool.h:227
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
FPGATrackSimGenScanTool::m_rout
Gaudi::Property< double > m_rout
Definition: FPGATrackSimGenScanTool.h:106
FPGATrackSimGenScanTool::m_pairSetPhiExtrapCurvedCut
Gaudi::Property< std::vector< double > > m_pairSetPhiExtrapCurvedCut
Definition: FPGATrackSimGenScanTool.h:130
FPGATrackSimGenScanTool::HitPairSet::PhiInExtrapCurved
double PhiInExtrapCurved(const HitPair &pair, double r_in) const
Definition: FPGATrackSimGenScanTool.cxx:738
calibdata.copy
bool copy
Definition: calibdata.py:26
FPGATrackSimGenScanTool::HitPairSet::MatchPhi
double MatchPhi(const HitPair &pair) const
Definition: FPGATrackSimGenScanTool.cxx:684
FPGATrackSimBinUtil::IdxSet
Definition: FPGATrackSimBinUtil.h:50
FPGATrackSimGenScanTool::m_reversePairDir
Gaudi::Property< bool > m_reversePairDir
Definition: FPGATrackSimGenScanTool.h:115
FPGATrackSimGenScanTool::incrementalBuildFilter
StatusCode incrementalBuildFilter(const BinEntry &bindata, std::vector< HitPairSet > &output_pairset)
Definition: FPGATrackSimGenScanTool.cxx:371
FPGATrackSimGenScanTool::m_pairFilterDeltaPhiCut
Gaudi::Property< std::vector< double > > m_pairFilterDeltaPhiCut
Definition: FPGATrackSimGenScanTool.h:116
FPGATrackSimGenScanTool::m_pairSetMatchEtaCut
Gaudi::Property< double > m_pairSetMatchEtaCut
Definition: FPGATrackSimGenScanTool.h:123
FPGATrackSimTypes.h
FPGATrackSimGenScanTool::m_pairingLayers
std::vector< unsigned int > m_pairingLayers
Definition: FPGATrackSimGenScanTool.h:269
FPGATrackSimTrackPars.h
Structs that store the 5 track parameters.
FPGATrackSimBinnedHits::BinEntry::hits
std::vector< FPGATrackSimBinUtil::StoredHit > hits
Definition: FPGATrackSimBinnedHits.h:78
FPGATrackSimGenScanTool::pairThenGroupFilter
StatusCode pairThenGroupFilter(const BinEntry &bindata, std::vector< HitPairSet > &output_pairset)
Definition: FPGATrackSimGenScanTool.cxx:227
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:31
FPGATrackSimGenScanTool::HitPair::EtaInExtrap
double EtaInExtrap(double r_in) const
Definition: FPGATrackSimGenScanTool.h:206
FPGATrackSimGenScanTool::HitPair::PhiOutExtrap
double PhiOutExtrap(double r_out) const
Definition: FPGATrackSimGenScanTool.h:196
FPGATrackSimGenScanTool::m_inBinFiltering
Gaudi::Property< bool > m_inBinFiltering
Definition: FPGATrackSimGenScanTool.h:133
FPGATrackSimGenScanTool::addRoad
void addRoad(std::vector< const StoredHit * > const &hits, const FPGATrackSimBinUtil::IdxSet &idx)
Definition: FPGATrackSimGenScanTool.cxx:612