7#include "GaudiKernel/MsgStream.h"
14std::vector<FPGATrackSimTrack>::const_iterator
getBestChi2(std::vector<FPGATrackSimTrack>
const & tracks);
15bool hasGoodFit(std::vector<FPGATrackSimTrack>
const & track_cands,
float minchi2);
23 const std::vector<const FPGATrackSimFitConstantBank*>& droppedLayerbanks,
bool guessingHits) :
31 for (
auto bank : droppedLayerbanks)
56 std::vector<FPGATrackSimTrack> t;
59 else tracks.insert(tracks.end(), t.begin(), t.end());
107 getMissingInfo(road, nMissing, missPixel, missStrip, missing_mask, norecovery_mask);
116 temp.setSecondSectorID(road.
getSector());
120 temp.setPatternID(road.
getPID());
121 temp.setHitMap(missing_mask);
122 temp.setNMissing(nMissing);
130 temp.setHoughXBin(road.
getXBin());
131 temp.setHoughYBin(road.
getYBin());
136 std::vector<FPGATrackSimTrack> track_cands;
140 ATH_MSG_DEBUG(
"There are theoretically " << comboIndices.size() <<
" combinations to process for this road");
142 for (
size_t icomb = 0; icomb < comboIndices.size(); icomb++) {
159 ATH_MSG_DEBUG(
"Assigned chi2 = " << track_cand.
getChi2() <<
" and parameters from genscan tool");
165 tracks.push_back(track_cand);
176 for (
unsigned int ic = 0; ic <
m_pmap->getNCoords(); ic++) {
177 if (!( (missing_mask >> ic) & 0x1))
break;
189 for (
unsigned icoord = 0; icoord <
m_pmap->getNCoords(); icoord++) {
193 unsigned int bitmask = ( 1 <<
m_pmap->getNCoords() ) - 1;
194 bitmask &= ~(1 << icoord);
195 if (
m_pmap->getDim(icoord) == 2) {
196 bitmask &= ~(1 << (icoord+1));
202 if (
m_pmap->getDim(icoord) == 2) {
209 tracks.push_back(track_cand);
218 ATH_MSG_DEBUG(
"Processed " << tracks.size() <<
" actual/valid tracks for this road");
263 nMissing =
m_pmap->getNCoords();
269 for (
unsigned layer = 0; layer <
m_pmap->getNLogiLayers(); layer++)
276 int ix =
m_pmap->getCoordOffset(layer);
280 missing_mask |= 1 << ix;
285 missing_mask |= (1<<ix) | (1<<iy);
291 if (
m_pmap->isSCT(layer)) missStrip =
true;
292 else missPixel =
true;
295 else if (!((wclayers >> layer) & 1)) {
296 int ix =
m_pmap->getCoordOffset(layer);
300 missing_mask |= 1 << ix;
305 missing_mask |= (1<<ix) | (1<<iy);
311 norecovery_mask |= (1<<layer);
335 for (
unsigned layer = 0; layer <
m_pmap->getNLogiLayers(); layer++)
337 if (hit_indices[layer] < 0)
345 if (wcbits & (1 << layer ) ) {
354 const std::shared_ptr<const FPGATrackSimHit> hit = road.
getHitPtrs(layer)[hit_indices[layer]];
361 if (!inner_hit_ptr)
throw std::runtime_error(
"Null inner hit pointer in TrackFitter: inner layer should have a hit when comparing spacepoints");
363 if ((hit->getX() != inner_hit.
getX()) || (hit->getY() != inner_hit.
getY()) || (hit->getZ() != inner_hit.
getZ())) {
386 std::vector<FPGATrackSimTrack> recovered_tracks(
m_pmap->getNLogiLayers(),t);
388 float best_chi2ndof = t.getChi2ndof();
392 for (
unsigned layer = (
m_require_first ? 1 : 0); layer < recovered_tracks.size(); ++layer)
395 if (norecovery_mask & (1<<layer))
continue;
403 recovered_tracks[layer].setFPGATrackSimHit(layer, std::make_shared<FPGATrackSimHit>(newhit));
405 int ix =
m_pmap->getCoordOffset(layer);
407 unsigned int missing_mask = t.getHitMap();
408 missing_mask &= ~(1 << ix);
410 if (
m_pmap->isPixel(layer)) missing_mask &= ~(1 << (ix + 1));
412 recovered_tracks[layer].setHitMap(missing_mask);
413 recovered_tracks[layer].setNMissing(t.getNMissing() +
m_pmap->getDim(layer));
416 recovered_tracks[layer].setQOverPt(qoverpt);
426 if (recovered_tracks[layer].getChi2ndof() < best_chi2ndof)
428 best_chi2ndof = recovered_tracks[layer].getChi2ndof();
434 return recovered_tracks[best_i];
446 std::vector<FPGATrackSimMultiTruth> mtv;
448 for (
unsigned layer = 0; layer <
m_pmap->getNLogiLayers(); layer++)
450 if (t.getHitMap() & (1 <<
m_pmap->getCoordOffset(layer)))
continue;
452 if (layer < t.getFPGATrackSimHitPtrs().size()) {
453 auto hit_ptr = t.getFPGATrackSimHitPtrs().at(layer);
454 if (!hit_ptr)
throw std::runtime_error(
"Null hit pointer in TrackFitter::compute_truth: tracks should not have unassigned layers");
455 mtv.push_back(hit_ptr->getTruth());
459 if (!mtv.empty()) mtv.back().assign_equal_normalization();
467 const bool ok = mt.
best(tbarcode, tfrac);
470 t.setEventIndex(tbarcode.first);
471 t.setBarcode(tbarcode.second);
472 t.setBarcodeFrac(tfrac);
482bool hasGoodFit(std::vector<FPGATrackSimTrack>
const & track_cands,
float minchi2ndof)
486 if (t.getChi2ndof() > 0 && t.getChi2ndof() < minchi2ndof)
#define ATH_MSG_WARNING(x)
std::vector< std::vector< int > > getComboIndices(std::vector< size_t > const &sizes)
Given a vector of sizes (of arrays), generates a vector of all combinations of indices to index one e...
static const uint32_t nHits
std::vector< FPGATrackSimTrack >::const_iterator getBestChi2(std::vector< FPGATrackSimTrack > const &tracks)
bool hasGoodFit(std::vector< FPGATrackSimTrack > const &track_cands, float minchi2)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
void setLayer(unsigned v)
void setHitType(HitType type)
void setSection(unsigned v)
void setDetType(SiliconTech detType)
bool best(FPGATrackSimMultiTruth::Barcode &code, FPGATrackSimMultiTruth::Weight &weight) const
std::pair< unsigned long, unsigned long > Barcode
double getFitChi2() const
double getFitChi2Phi() const
sector_t getSector() const
const std::vector< unsigned > & getBinIdx() const
const std::vector< std::shared_ptr< const FPGATrackSimHit > > & getHitPtrs(size_t layer) const
layer_bitmask_t getWCLayers() const
double getFitChi2Eta() const
std::vector< size_t > getNHits_layer() const
const FPGATrackSimTrackPars & getFitParams() const
void setOrigChi2(float v)
const std::vector< std::shared_ptr< const FPGATrackSimHit > > & getFPGATrackSimHitPtrs() const
void setIdealRadii(const std::vector< double > &v)
void setFPGATrackSimHit(unsigned i, std::shared_ptr< const FPGATrackSimHit > hit)
void setPars(FPGATrackSimTrackPars const &pars)
void setNLayers(int)
set the number of layers in the track.
void setHitMap(unsigned int v)
void setValidCand(bool v)
void compute_truth(FPGATrackSimTrack &newtrk) const
FPGATrackSimRegionMap const * m_rmap
FPGATrackSimTrack makeTrackCandidate(const FPGATrackSimRoad &road, const FPGATrackSimTrack &temp, const std::vector< int > &hit_indices)
bool getDoMissingHitsCheck() const
float m_Chi2Dof_recovery_min
FPGATrackSimPlaneMap const * m_pmap
float m_Chi2Dof_recovery_max
TrackCorrType m_IdealCoordFitType
std::vector< const FPGATrackSimFitConstantBank * > m_droppedLayerBanks
FPGATrackSimTrack recoverTrack(FPGATrackSimTrack const &t, sector_t sector, layer_bitmask_t norecovery_mask, double qoverpt)
Given a N/N track that has a bad chi2, try to refit the track by taking away a single hit,...
void getMissingInfo(const FPGATrackSimRoad &road, int &nMissing, bool &missPixel, bool &missStrip, layer_bitmask_t &missing_mask, layer_bitmask_t &norecovery_mask)
const FPGATrackSimFitConstantBank * m_nominalBank
std::vector< FPGATrackSimTrack > m_tracks_missinghits_track
int fitTracks(const std::vector< FPGATrackSimRoad > &roads, std::vector< FPGATrackSimTrack > &tracks)
singleton-like access to IMessageSvc via open function and helper
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....