CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
mkfit::Event Class Reference

#include <Event.h>

Classes

struct  SimLabelFromHits
 

Public Member Functions

int clean_cms_seedtracks (TrackVec *seed_ptr=nullptr)
 
int clean_cms_seedtracks_badlabel ()
 
int clean_cms_simtracks ()
 
const TrackcurrentSeed (int i) const
 
 Event (int evtID, int nLayers)
 
 Event (Validation &v, int evtID, int nLayers)
 
int evtID () const
 
void fill_hitmask_bool_vectors (int track_algo, std::vector< std::vector< bool >> &layer_masks)
 
void fill_hitmask_bool_vectors (std::vector< int > &track_algo_vec, std::vector< std::vector< bool >> &layer_masks)
 
void kludge_cms_hit_errors ()
 
void print_tracks (const TrackVec &tracks, bool print_hits) const
 
void printStats (const TrackVec &, TrackExtraVec &)
 
void read_in (DataFile &data_file, FILE *in_fp=0)
 
int read_tracks (FILE *fp, TrackVec &tracks, bool skip_reading=false)
 
void relabel_bad_seedtracks ()
 
void relabel_cmsswtracks_from_seeds ()
 
void reset (int evtID)
 
void resetCurrentSeedTracks ()
 
void resetLayerHitMap (bool resetSimHits)
 
int select_tracks_iter (unsigned int n=0)
 
void setCurrentSeedTracks (const TrackVec &seeds)
 
void setInputFromCMSSW (std::vector< HitVec > hits, TrackVec seeds)
 
SimLabelFromHits simLabelForCurrentSeed (int i) const
 
int use_seeds_from_cmsswtracks ()
 
void validate ()
 
void write_out (DataFile &data_file)
 
int write_tracks (FILE *fp, const TrackVec &tracks)
 

Public Attributes

BeamSpot beamSpot_
 
TrackVec candidateTracks_
 
TrackExtraVec candidateTracksExtra_
 
TrackVec cmsswTracks_
 
TrackExtraVec cmsswTracksExtra_
 
TrackVec fitTracks_
 
TrackExtraVec fitTracksExtra_
 
std::vector< std::vector< uint64_t > > layerHitMasks_
 
std::vector< HitVeclayerHits_
 
TrackVec seedTracks_
 
TrackExtraVec seedTracksExtra_
 
MCHitInfoVec simHitsInfo_
 
TrackVec simTracks_
 
TrackExtraVec simTracksExtra_
 
TSVec simTrackStates_
 
Validationvalidation_
 

Static Public Attributes

static std::mutex printmutex
 

Private Attributes

std::vector< SimLabelFromHitscurrentSeedSimFromHits_
 
const TrackVeccurrentSeedTracks_ = nullptr
 
int evtID_
 

Detailed Description

Definition at line 14 of file Event.h.

Constructor & Destructor Documentation

◆ Event() [1/2]

Event::Event ( int  evtID,
int  nLayers 
)
explicit

Definition at line 22 of file Event.cc.

References layerHitMasks_, layerHits_, and MuonTCMETValueMapProducer_cff::nLayers.

22  : validation_(*dummyValidation), evtID_(evtID) {
23  layerHits_.resize(nLayers);
24  layerHitMasks_.resize(nLayers);
25  }
Validation & validation_
Definition: Event.h:50
int evtID() const
Definition: Event.h:23
std::vector< HitVec > layerHits_
Definition: Event.h:70
int evtID_
Definition: Event.h:64
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

◆ Event() [2/2]

Event::Event ( Validation v,
int  evtID,
int  nLayers 
)

Definition at line 27 of file Event.cc.

References layerHitMasks_, layerHits_, MuonTCMETValueMapProducer_cff::nLayers, mkfit::Validation::resetValidationMaps(), and validation_.

27  : validation_(v), evtID_(evtID) {
28  layerHits_.resize(nLayers);
29  layerHitMasks_.resize(nLayers);
30  validation_.resetValidationMaps(); // need to reset maps for every event.
31  }
Validation & validation_
Definition: Event.h:50
virtual void resetValidationMaps()
Definition: Validation.h:50
int evtID() const
Definition: Event.h:23
std::vector< HitVec > layerHits_
Definition: Event.h:70
int evtID_
Definition: Event.h:64
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

Member Function Documentation

◆ clean_cms_seedtracks()

int Event::clean_cms_seedtracks ( TrackVec seed_ptr = nullptr)

Definition at line 595 of file Event.cc.

References funct::abs(), mkfit::Config::c_dpt_common, mkfit::Config::c_drmax_brl, mkfit::Config::c_drmax_els, mkfit::Config::c_drmax_hpt, mkfit::Config::c_dzmax_brl, mkfit::Config::c_dzmax_els, mkfit::Config::c_dzmax_hpt, mkfit::Config::c_etamax_brl, mkfit::Config::c_ptmin_hpt, mkfit::cdist(), ALCARECOTkAlJpsiMuMu_cff::charge, mkfit::TrackBase::charge(), PVValHelper::eta, calostep_cfi::Eta1, f, mkfit::TrackBase::invpT(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, mkfit::TrackBase::momEta(), mkfit::TrackBase::momPhi(), mkfit::Track::nFoundHits(), nHits, funct::pow(), DiDispStaMuonMonitor_cfi::pt, mkfit::TrackBase::pT(), HLT_2024v14_cff::seeds, seedTracks_, mathSSE::sqrt(), contentValuesCheck::ss, funct::tan(), mkfit::TrackBase::theta(), mkfit::Config::track1GeVradius, x, mkfit::TrackBase::x(), mkfit::TrackBase::y(), and mkfit::TrackBase::z().

595  {
596  const float etamax_brl = Config::c_etamax_brl;
597  const float dpt_common = Config::c_dpt_common;
598  const float dzmax_brl = Config::c_dzmax_brl;
599  const float drmax_brl = Config::c_drmax_brl;
600  const float ptmin_hpt = Config::c_ptmin_hpt;
601  const float dzmax_hpt = Config::c_dzmax_hpt;
602  const float drmax_hpt = Config::c_drmax_hpt;
603  const float dzmax_els = Config::c_dzmax_els;
604  const float drmax_els = Config::c_drmax_els;
605 
606  const float dzmax2_inv_brl = 1.f / (dzmax_brl * dzmax_brl);
607  const float drmax2_inv_brl = 1.f / (drmax_brl * drmax_brl);
608  const float dzmax2_inv_hpt = 1.f / (dzmax_hpt * dzmax_hpt);
609  const float drmax2_inv_hpt = 1.f / (drmax_hpt * drmax_hpt);
610  const float dzmax2_inv_els = 1.f / (dzmax_els * dzmax_els);
611  const float drmax2_inv_els = 1.f / (drmax_els * drmax_els);
612 
613  TrackVec &seeds = (seed_ptr != nullptr) ? *seed_ptr : seedTracks_;
614  const int ns = seeds.size();
615 
616  TrackVec cleanSeedTracks;
617  cleanSeedTracks.reserve(ns);
618  std::vector<bool> writetrack(ns, true);
619 
620  const float invR1GeV = 1.f / Config::track1GeVradius;
621 
622  std::vector<int> nHits(ns);
623  std::vector<int> charge(ns);
624  std::vector<float> oldPhi(ns);
625  std::vector<float> pos2(ns);
626  std::vector<float> eta(ns);
627  std::vector<float> ctheta(ns);
628  std::vector<float> invptq(ns);
629  std::vector<float> pt(ns);
630  std::vector<float> x(ns);
631  std::vector<float> y(ns);
632  std::vector<float> z(ns);
633 
634  for (int ts = 0; ts < ns; ts++) {
635  const Track &tk = seeds[ts];
636  nHits[ts] = tk.nFoundHits();
637  charge[ts] = tk.charge();
638  oldPhi[ts] = tk.momPhi();
639  pos2[ts] = std::pow(tk.x(), 2) + std::pow(tk.y(), 2);
640  eta[ts] = tk.momEta();
641  ctheta[ts] = 1.f / std::tan(tk.theta());
642  invptq[ts] = tk.charge() * tk.invpT();
643  pt[ts] = tk.pT();
644  x[ts] = tk.x();
645  y[ts] = tk.y();
646  z[ts] = tk.z();
647  }
648 
649  for (int ts = 0; ts < ns; ts++) {
650  if (not writetrack[ts])
651  continue; //FIXME: this speed up prevents transitive masking; check build cost!
652 
653  const float oldPhi1 = oldPhi[ts];
654  const float pos2_first = pos2[ts];
655  const float Eta1 = eta[ts];
656  const float Pt1 = pt[ts];
657  const float invptq_first = invptq[ts];
658 
659  //#pragma simd /* Vectorization via simd had issues with icc */
660  for (int tss = ts + 1; tss < ns; tss++) {
661  const float Pt2 = pt[tss];
662 
664  if (charge[tss] != charge[ts])
665  continue;
666 
667  const float thisDPt = std::abs(Pt2 - Pt1);
669  if (thisDPt > dpt_common * (Pt1))
670  continue;
671 
672  const float Eta2 = eta[tss];
673  const float deta2 = std::pow(Eta1 - Eta2, 2);
674 
675  const float oldPhi2 = oldPhi[tss];
676 
677  const float pos2_second = pos2[tss];
678  const float thisDXYSign05 = pos2_second > pos2_first ? -0.5f : 0.5f;
679 
680  const float thisDXY = thisDXYSign05 * sqrt(std::pow(x[ts] - x[tss], 2) + std::pow(y[ts] - y[tss], 2));
681 
682  const float invptq_second = invptq[tss];
683 
684  const float newPhi1 = oldPhi1 - thisDXY * invR1GeV * invptq_first;
685  const float newPhi2 = oldPhi2 + thisDXY * invR1GeV * invptq_second;
686 
687  const float dphi = cdist(std::abs(newPhi1 - newPhi2));
688 
689  const float dr2 = deta2 + dphi * dphi;
690 
691  const float thisDZ = z[ts] - z[tss] - thisDXY * (ctheta[ts] + ctheta[tss]);
692  const float dz2 = thisDZ * thisDZ;
693 
696  if (std::abs(Eta1) < etamax_brl) {
697  if (dz2 * dzmax2_inv_brl + dr2 * drmax2_inv_brl < 1.0f)
698  writetrack[tss] = false;
699  } else if (Pt1 > ptmin_hpt) {
700  if (dz2 * dzmax2_inv_hpt + dr2 * drmax2_inv_hpt < 1.0f)
701  writetrack[tss] = false;
702  } else {
703  if (dz2 * dzmax2_inv_els + dr2 * drmax2_inv_els < 1.0f)
704  writetrack[tss] = false;
705  }
706  }
707 
708  if (writetrack[ts])
709  cleanSeedTracks.emplace_back(seeds[ts]);
710  }
711 
712  seeds.swap(cleanSeedTracks);
713 
714 #ifdef DEBUG
715  {
716  const int ns2 = seeds.size();
717  printf("Number of CMS seeds before %d --> after %d cleaning\n", ns, ns2);
718 
719  for (int it = 0; it < ns2; it++) {
720  const Track &ss = seeds[it];
721  printf(" %3i q=%+i pT=%7.3f eta=% 7.3f nHits=%i label=% i\n",
722  it,
723  ss.charge(),
724  ss.pT(),
725  ss.momEta(),
726  ss.nFoundHits(),
727  ss.label());
728  }
729  }
730 #endif
731 
732  return seeds.size();
733  }
constexpr float c_drmax_els
Definition: Config.h:102
constexpr float c_dpt_common
Definition: Config.h:95
TrackVec seedTracks_
Definition: Event.h:74
float float float z
constexpr float c_dzmax_hpt
Definition: Config.h:99
constexpr float c_etamax_brl
Definition: Config.h:94
constexpr float c_ptmin_hpt
Definition: Config.h:98
T sqrt(T t)
Definition: SSEVec.h:23
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
float cdist(float a)
Definition: Config.h:32
std::vector< Track > TrackVec
constexpr float track1GeVradius
Definition: Config.h:93
constexpr float c_dzmax_els
Definition: Config.h:101
constexpr float c_dzmax_brl
Definition: Config.h:96
float x
constexpr float c_drmax_hpt
Definition: Config.h:100
constexpr float c_drmax_brl
Definition: Config.h:97
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ clean_cms_seedtracks_badlabel()

int Event::clean_cms_seedtracks_badlabel ( )

Definition at line 771 of file Event.cc.

References visDQMUpload::buf, seedTracks_, and submitPVValidationJobs::t.

771  {
772  printf("***\n*** REMOVING SEEDS WITH BAD LABEL. This is a development hack. ***\n***\n");
773  TrackVec buf;
774  seedTracks_.swap(buf);
775  std::copy_if(
776  buf.begin(), buf.end(), std::back_inserter(seedTracks_), [](const Track &t) { return t.label() >= 0; });
777  return seedTracks_.size();
778  }
TrackVec seedTracks_
Definition: Event.h:74
std::vector< Track > TrackVec

◆ clean_cms_simtracks()

int Event::clean_cms_simtracks ( )

Definition at line 514 of file Event.cc.

References mkfit::Config::cmsSelMinLayers, dprintf, mps_fire::i, simTracks_, and submitPVValidationJobs::t.

514  {
515  // Sim tracks from cmssw have the following issues:
516  // - hits are not sorted by layer;
517  // - there are tracks with too low number of hits, even 0;
518  // - even with enough hits, there can be too few layers (esp. in endcap);
519  // - tracks from secondaries can have extremely low pT.
520  // Possible further checks:
521  // - make sure enough hits exist in seeding layers.
522  //
523  // What is done:
524  // 1. Hits are sorted by layer;
525  // 2. Non-findable tracks are marked with Track::Status::not_findable flag.
526  //
527  // Returns number of passed simtracks.
528 
529  dprintf("Event::clean_cms_simtracks processing %lu simtracks.\n", simTracks_.size());
530 
531  int n_acc = 0;
532  int i = -1; //wrap in ifdef DEBUG?
533  for (Track &t : simTracks_) {
534  i++;
535 
536  t.sortHitsByLayer();
537 
538  const int lyr_cnt = t.nUniqueLayers();
539 
540  //const int lasthit = t.getLastFoundHitPos();
541  //const float eta = layerHits_[t.getHitLyr(lasthit)][t.getHitIdx(lasthit)].eta();
542 
543  if (lyr_cnt < Config::cmsSelMinLayers) // || Config::TrkInfo.is_transition(eta))
544  {
545  dprintf("Rejecting simtrack %d, n_hits=%d, n_layers=%d, pT=%f\n", i, t.nFoundHits(), lyr_cnt, t.pT());
546  t.setNotFindable();
547  } else {
548  dprintf("Accepting simtrack %d, n_hits=%d, n_layers=%d, pT=%f\n", i, t.nFoundHits(), lyr_cnt, t.pT());
549  ++n_acc;
550  }
551  }
552 
553  return n_acc;
554  }
TrackVec simTracks_
Definition: Event.h:74
#define dprintf(...)
Definition: Debug.h:98

◆ currentSeed()

const Track & Event::currentSeed ( int  i) const

Definition at line 873 of file Event.cc.

References currentSeedTracks_, and mps_fire::i.

Referenced by mkfit::MkFinder::selectHitIndices(), and simLabelForCurrentSeed().

873 { return (*currentSeedTracks_)[i]; }
const TrackVec * currentSeedTracks_
Definition: Event.h:65

◆ evtID()

int mkfit::Event::evtID ( ) const
inline

◆ fill_hitmask_bool_vectors() [1/2]

void Event::fill_hitmask_bool_vectors ( int  track_algo,
std::vector< std::vector< bool >> &  layer_masks 
)

Definition at line 822 of file Event.cc.

References mps_fire::i, createfilelist::int, MainPageGenerator::l, layerHitMasks_, and layerHits_.

Referenced by mkfit::Shell::ProcessEvent().

822  {
823  // Convert from per-hit uint64_t to per layer bool-vectors for given
824  // iteration.
825 
826  uint64_t iter_mask = 1 << track_algo;
827 
828  const int n_lay = (int)layerHits_.size();
829  layer_masks.resize(n_lay);
830 
831  for (int l = 0; l < n_lay; ++l) {
832  const int n_hit = (int)layerHits_[l].size();
833  layer_masks[l].resize(n_hit);
834 
835  for (int i = 0; i < n_hit; ++i) {
836  layer_masks[l][i] = layerHitMasks_[l][i] & iter_mask;
837  }
838  }
839  }
size
Write out results.
std::vector< HitVec > layerHits_
Definition: Event.h:70
unsigned long long uint64_t
Definition: Time.h:13
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

◆ fill_hitmask_bool_vectors() [2/2]

void Event::fill_hitmask_bool_vectors ( std::vector< int > &  track_algo_vec,
std::vector< std::vector< bool >> &  layer_masks 
)

Definition at line 841 of file Event.cc.

References mps_fire::i, createfilelist::int, MainPageGenerator::l, layerHitMasks_, and layerHits_.

841  {
842  // Convert from per-hit uint64_t to per layer bool-vectors for a list of
843  // iterations.
844  // A hit mask is set if it is set for _all_ listed iterations.
845 
846  uint64_t iter_mask = 0;
847  for (auto ta : track_algo_vec)
848  iter_mask |= 1 << ta;
849 
850  const int n_lay = (int)layerHits_.size();
851  layer_masks.resize(n_lay);
852 
853  for (int l = 0; l < n_lay; ++l) {
854  const int n_hit = (int)layerHits_[l].size();
855  layer_masks[l].resize(n_hit);
856 
857  for (int i = 0; i < n_hit; ++i) {
858  uint64_t hitmasks = layerHitMasks_[l][i];
859  layer_masks[l][i] = ((iter_mask ^ hitmasks) & iter_mask) == 0;
860  }
861  }
862  }
size
Write out results.
std::vector< HitVec > layerHits_
Definition: Event.h:70
unsigned long long uint64_t
Definition: Time.h:13
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

◆ kludge_cms_hit_errors()

void Event::kludge_cms_hit_errors ( )

Definition at line 479 of file Event.cc.

References DummyCfis::c, MillePedeFileConverter_cfg::e, relativeConstraints::empty, h, and layerHits_.

Referenced by read_in().

479  {
480  // Enforce Vxy on all layers, Vz on pixb only.
481 
482  const float Exy = 15 * 1e-4, Vxy = Exy * Exy;
483  const float Ez = 30 * 1e-4, Vz = Ez * Ez;
484 
485  int nl = layerHits_.size();
486 
487  int cnt = 0;
488 
489  for (int il = 0; il < nl; il++) {
490  if (layerHits_[il].empty())
491  continue;
492 
493  for (Hit &h : layerHits_[il]) {
494  SVector6 &c = h.error_nc();
495 
496  float vxy = c[0] + c[2];
497  if (vxy < Vxy) {
498  c[0] *= Vxy / vxy;
499  c[2] *= Vxy / vxy;
500  ++cnt;
501  }
502  if (il < 4 && c[5] < Vz) {
503  c[5] = Vz;
504  ++cnt;
505  }
506  }
507  }
508 
509  printf("Event::kludge_cms_hit_errors processed %d layers, kludged %d entries.\n", nl, cnt);
510  }
std::vector< HitVec > layerHits_
Definition: Event.h:70
ROOT::Math::SVector< float, 6 > SVector6
Definition: MatrixSTypes.h:10
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ print_tracks()

void Event::print_tracks ( const TrackVec tracks,
bool  print_hits 
) const

Definition at line 556 of file Event.cc.

References mkfit::IterationConfig::get_track_scorer(), mkfit::getScoreCand(), heavyIonCSV_trainingSettings::idx, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, layerHits_, nt, simHitsInfo_, submitPVValidationJobs::t, and DiMuonV_cfg::tracks.

556  {
557  const int nt = tracks.size();
558  auto score_func = IterationConfig::get_track_scorer("default");
559  //WARNING: Printouts for hits will not make any sense if mkFit is not run with a validation flag such as --quality-val
560  printf("Event::print_tracks printing %d tracks %s hits:\n", nt, (print_hits ? "with" : "without"));
561  for (int it = 0; it < nt; it++) {
562  const Track &t = tracks[it];
563  printf(" %i with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d findable=%d score=%7.3f chi2=%7.3f\n",
564  it,
565  t.charge(),
566  t.pT(),
567  t.momEta(),
568  t.nFoundHits(),
569  t.label(),
570  t.isFindable(),
571  getScoreCand(score_func, t),
572  t.chi2());
573 
574  if (print_hits) {
575  for (int ih = 0; ih < t.nTotalHits(); ++ih) {
576  int lyr = t.getHitLyr(ih);
577  int idx = t.getHitIdx(ih);
578  if (idx >= 0) {
579  const Hit &hit = layerHits_[lyr][idx];
580  printf(" hit %2d lyr=%2d idx=%3d pos r=%7.3f z=% 8.3f mc_hit=%3d mc_trk=%3d\n",
581  ih,
582  lyr,
583  idx,
584  layerHits_[lyr][idx].r(),
585  layerHits_[lyr][idx].z(),
586  hit.mcHitID(),
587  hit.mcTrackID(simHitsInfo_));
588  } else
589  printf(" hit %2d lyr=%2d idx=%3d\n", ih, t.getHitLyr(ih), t.getHitIdx(ih));
590  }
591  }
592  }
593  }
float getScoreCand(const track_score_func &score_func, const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:601
float float float z
MCHitInfoVec simHitsInfo_
Definition: Event.h:72
int nt
Definition: AMPTWrapper.h:42
std::vector< HitVec > layerHits_
Definition: Event.h:70
static track_score_func get_track_scorer(const std::string &name)

◆ printStats()

void Event::printStats ( const TrackVec trks,
TrackExtraVec trkextras 
)

Definition at line 91 of file Event.cc.

References gather_cfg::cout, newFWLiteAna::found, layerHits_, simHitsInfo_, simTracks_, and hltEgammaHLTExtra_cfi::trks.

91  {
92  int miss(0), found(0), fp_10(0), fp_20(0), hit8(0), h8_10(0), h8_20(0);
93 
94  for (auto &&trk : trks) {
95  auto &&extra = trkextras[trk.label()];
96  extra.setMCTrackIDInfo(trk, layerHits_, simHitsInfo_, simTracks_, false, true);
97  if (extra.mcTrackID() < 0) {
98  ++miss;
99  } else {
100  auto &&mctrk = simTracks_[extra.mcTrackID()];
101  auto pr = trk.pT() / mctrk.pT();
102  found++;
103  bool h8 = trk.nFoundHits() >= 8;
104  bool pt10 = pr > 0.9 && pr < 1.1;
105  bool pt20 = pr > 0.8 && pr < 1.2;
106  fp_10 += pt10;
107  fp_20 += pt20;
108  hit8 += h8;
109  h8_10 += h8 && pt10;
110  h8_20 += h8 && pt20;
111  }
112  }
113  std::cout << "found tracks=" << found << " in pT 10%=" << fp_10 << " in pT 20%=" << fp_20
114  << " no_mc_assoc=" << miss << std::endl
115  << " nH >= 8 =" << hit8 << " in pT 10%=" << h8_10 << " in pT 20%=" << h8_20 << std::endl;
116  }
MCHitInfoVec simHitsInfo_
Definition: Event.h:72
std::vector< HitVec > layerHits_
Definition: Event.h:70
TrackVec simTracks_
Definition: Event.h:74

◆ read_in()

void Event::read_in ( DataFile data_file,
FILE *  in_fp = 0 
)

Definition at line 207 of file Event.cc.

References mkfit::DataFile::advancePosToNextEvent(), beamSpot_, mkfit::cmsswSeeds, cmsswTracks_, dumpMFGeometry_cfg::delta, relativeConstraints::empty, mkfit::DataFile::f_fp, personalPlayback::fp, mkfit::ModuleInfo::half_length, mkfit::DataFile::hasBeamSpot(), mkfit::DataFile::hasCmsswTracks(), mkfit::DataFile::hasHitIterMasks(), mkfit::DataFile::hasSeeds(), mkfit::DataFile::hasSimTrackStates(), heavyIonCSV_trainingSettings::idx, createfilelist::int, mkfit::LayerInfo::is_barrel(), mkfit::LayerInfo::is_pixel(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, kludge_cms_hit_errors(), mkfit::Config::kludgeCmsHitErrors, layerHitMasks_, layerHits_, SiStripPI::max, SiStripPI::min, mkfit::LayerInfo::module_info(), cms::cuda::nh, nt, mkfit::Config::nTracks, read_tracks(), mkfit::Config::readCmsswTracks, mkfit::Config::seedInput, seedTracks_, mkfit::Config::silent, simHitsInfo_, simTracks_, simTrackStates_, mathSSE::sqrt(), contentValuesCheck::ss, submitPVValidationJobs::t, mkfit::Config::TrkInfo, funct::void, x, hit::x, hit::y, and hit::z.

Referenced by mkfit::Shell::GoToEvent().

207  {
208  FILE *fp = in_fp ? in_fp : data_file.f_fp;
209 
210  data_file.advancePosToNextEvent(fp);
211 
212  int nt = read_tracks(fp, simTracks_);
214 
215  if (data_file.hasSimTrackStates()) {
216  int nts;
217  fread(&nts, sizeof(int), 1, fp);
218  simTrackStates_.resize(nts);
219  fread(&simTrackStates_[0], sizeof(TrackState), nts, fp);
220  }
221 
222  int nl;
223  fread(&nl, sizeof(int), 1, fp);
224  layerHits_.resize(nl);
225  layerHitMasks_.resize(nl);
226  for (int il = 0; il < nl; ++il) {
227  int nh;
228  fread(&nh, sizeof(int), 1, fp);
229  layerHits_[il].resize(nh);
230  layerHitMasks_[il].resize(nh, 0); //init to 0 by default
231  fread(&layerHits_[il][0], sizeof(Hit), nh, fp);
232  }
233 
234  if (data_file.hasHitIterMasks()) {
235  for (int il = 0; il < nl; ++il) {
236  int nh = layerHits_[il].size();
237  fread(&layerHitMasks_[il][0], sizeof(uint64_t), nh, fp);
238  }
239  }
240 
241  int nm;
242  fread(&nm, sizeof(int), 1, fp);
243  simHitsInfo_.resize(nm);
244  fread(&simHitsInfo_[0], sizeof(MCHitInfo), nm, fp);
245 
246  if (data_file.hasSeeds()) {
248  (void)ns;
249 
250 #ifdef DUMP_SEEDS
251  printf("Read %i seedtracks (neg value means actual reading was skipped)\n", ns);
252  for (int it = 0; it < ns; it++) {
253  const Track &ss = seedTracks_[it];
254  printf(" %-3i q=%+i pT=%7.3f eta=% 7.3f nHits=%i label=%4i algo=%2i\n",
255  it,
256  ss.charge(),
257  ss.pT(),
258  ss.momEta(),
259  ss.nFoundHits(),
260  ss.label(),
261  (int)ss.algorithm());
262 #ifdef DUMP_SEED_HITS
263  for (int ih = 0; ih < seedTracks_[it].nTotalHits(); ++ih) {
264  int lyr = seedTracks_[it].getHitLyr(ih);
265  int idx = seedTracks_[it].getHitIdx(ih);
266  if (idx >= 0) {
267  const Hit &hit = layerHits_[lyr][idx];
268  printf(" hit %2d lyr=%3d idx=%4d pos r=%7.3f z=% 8.3f mc_hit=%3d mc_trk=%3d\n",
269  ih,
270  lyr,
271  idx,
272  layerHits_[lyr][idx].r(),
273  layerHits_[lyr][idx].z(),
274  hit.mcHitID(),
275  hit.mcTrackID(simHitsInfo_));
276  } else
277  printf(" hit %2d idx=%i\n", ih, seedTracks_[it].getHitIdx(ih));
278  }
279 #endif
280  }
281 #endif
282  }
283 
284  int nert = -99999;
285  if (data_file.hasCmsswTracks()) {
287  (void)nert;
288  }
289 
290  /*
291  // HACK TO ONLY SELECT ONE PROBLEMATIC TRACK.
292  // Note that MC matching gets screwed.
293  // Works for MC seeding.
294  //
295  printf("************** SIM SELECTION HACK IN FORCE ********************\n");
296  TrackVec x;
297  x.push_back(simTracks_[3]);
298  simTracks_.swap(x);
299  nt = 1;
300  */
301 
302 #ifdef DUMP_TRACKS
303  printf("Read %i simtracks\n", nt);
304  for (int it = 0; it < nt; it++) {
305  const Track &t = simTracks_[it];
306  printf(" %-3i q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d\n",
307  it,
308  t.charge(),
309  t.pT(),
310  t.momEta(),
311  t.nFoundHits(),
312  t.label());
313 #ifdef DUMP_TRACK_HITS
314  for (int ih = 0; ih < t.nTotalHits(); ++ih) {
315  int lyr = t.getHitLyr(ih);
316  int idx = t.getHitIdx(ih);
317  if (idx >= 0) {
318  const Hit &hit = layerHits_[lyr][idx];
319  printf(" hit %2d lyr=%2d idx=%3d pos r=%7.3f x=% 8.3f y=% 8.3f z=% 8.3f mc_hit=%3d mc_trk=%3d\n",
320  ih,
321  lyr,
322  idx,
323  layerHits_[lyr][idx].r(),
324  layerHits_[lyr][idx].x(),
325  layerHits_[lyr][idx].y(),
326  layerHits_[lyr][idx].z(),
327  hit.mcHitID(),
328  hit.mcTrackID(simHitsInfo_));
329  } else
330  printf(" hit %2d idx=%i\n", ih, t.getHitIdx(ih));
331  }
332 #endif
333  }
334 #endif
335 #ifdef DUMP_LAYER_HITS
336  // clang-format off
337  printf("Read %i layers\n", nl);
338  int total_hits = 0;
339  float min_delta = 100, max_delta = -100;
340  for (int il = 0; il < nl; il++) {
341  if (layerHits_[il].empty())
342  continue;
343 
344  const LayerInfo &linfo = Config::TrkInfo[il];
345  printf("Read %i hits in layer %i, is_brl=%d is_pix=%d\n",
346  (int)layerHits_[il].size(), il, linfo.is_barrel(), linfo.is_pixel());
347  total_hits += layerHits_[il].size();
348  for (int ih = 0; ih < (int)layerHits_[il].size(); ih++) {
349  const Hit &hit = layerHits_[il][ih];
350  unsigned int mid = hit.detIDinLayer();
351  const ModuleInfo &mi = linfo.module_info(mid);
352 
353  if ( ! linfo.is_pixel() && ! linfo.is_barrel()) {
354  float delta = mi.half_length - std::sqrt(3)*std::sqrt(hit.exx() + hit.eyy());
355  min_delta = std::min(min_delta, delta);
356  max_delta = std::max(max_delta, delta);
357  }
358  // continue;
359 
360  printf(" mcHitID=%-5d r=%7g x=%8g y=%8g z=%8g"
361  " sx=%10.4g sy=%10.4e sz=%10.4e sxy=%10.4e, mhl=%10.4e, delta=%10.4e"
362  " chg_pcm=%u (%u - %u)\n",
363  hit.mcHitID(), hit.r(), hit.x(), hit.y(), hit.z(),
364  std::sqrt(hit.exx()), std::sqrt(hit.eyy()), std::sqrt(hit.ezz()),
365  std::sqrt(hit.exx() + hit.eyy()),
366  mi.half_length,
367  mi.half_length - std::sqrt(3)*std::sqrt(hit.exx() + hit.eyy()),
368  hit.chargePerCM(), hit.minChargePerCM(), hit.maxChargePerCM());
369  }
370  }
371  printf("Total hits in all layers = %d; endcap strips: min_delta=%.5f max_delta=%.5f\n",
372  total_hits, min_delta, max_delta);
373  // clang-format on
374 #endif
375 #ifdef DUMP_REC_TRACKS
376  printf("Read %i rectracks\n", nert);
377  for (int it = 0; it < nert; it++) {
378  const Track &t = cmsswTracks_[it];
379  printf(" %-3i with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d algo=%2d\n",
380  it,
381  t.charge(),
382  t.pT(),
383  t.momEta(),
384  t.nFoundHits(),
385  t.label(),
386  (int)t.algorithm());
387 #ifdef DUMP_REC_TRACK_HITS
388  for (int ih = 0; ih < t.nTotalHits(); ++ih) {
389  int lyr = t.getHitLyr(ih);
390  int idx = t.getHitIdx(ih);
391  if (idx >= 0) {
392  const Hit &hit = layerHits_[lyr][idx];
393  printf(" hit %2d lyr=%2d idx=%3d pos r=%7.3f z=% 8.3f mc_hit=%3d mc_trk=%3d\n",
394  ih,
395  lyr,
396  idx,
397  hit.r(),
398  hit.z(),
399  hit.mcHitID(),
400  hit.mcTrackID(simHitsInfo_));
401  } else
402  printf(" hit %2d idx=%i\n", ih, t.getHitIdx(ih));
403  }
404 #endif
405  }
406 #endif
407 
408  if (data_file.hasBeamSpot()) {
409  fread(&beamSpot_, sizeof(BeamSpot), 1, fp);
410  }
411 
414  }
415 
416  if (!Config::silent)
417  printf("Read complete, %d simtracks on file.\n", nt);
418  }
size
Write out results.
void kludge_cms_hit_errors()
Definition: Event.cc:479
TrackVec cmsswTracks_
Definition: Event.h:75
TrackVec seedTracks_
Definition: Event.h:74
float float float z
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
BeamSpot beamSpot_
Definition: Event.h:69
T sqrt(T t)
Definition: SSEVec.h:23
TrackerInfo TrkInfo
uint32_t nh
MCHitInfoVec simHitsInfo_
Definition: Event.h:72
int nt
Definition: AMPTWrapper.h:42
std::vector< HitVec > layerHits_
Definition: Event.h:70
TrackVec simTracks_
Definition: Event.h:74
TSVec simTrackStates_
Definition: Event.h:80
unsigned long long uint64_t
Definition: Time.h:13
float x
int read_tracks(FILE *fp, TrackVec &tracks, bool skip_reading=false)
Definition: Event.cc:446
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

◆ read_tracks()

int Event::read_tracks ( FILE *  fp,
TrackVec tracks,
bool  skip_reading = false 
)

Definition at line 446 of file Event.cc.

References personalPlayback::fp, mps_fire::i, and DiMuonV_cfg::tracks.

Referenced by read_in().

446  {
447  // Returns number of read tracks (negative if actual reading was skipped).
448 
449  int n_tracks, data_size;
450  fread(&n_tracks, sizeof(int), 1, fp);
451  fread(&data_size, sizeof(int), 1, fp);
452 
453  if (skip_reading) {
454  fseek(fp, data_size - 2 * sizeof(int), SEEK_CUR); // -2 because data_size counts itself and n_tracks too
455  n_tracks = -n_tracks;
456  } else {
457  tracks.resize(n_tracks);
458 
459  fread(tracks.data(), sizeof(Track), n_tracks, fp);
460 
461  for (int i = 0; i < n_tracks; ++i) {
462  tracks[i].resizeHitsForInput();
463  fread(tracks[i].beginHitsOnTrack_nc(), sizeof(HitOnTrack), tracks[i].nTotalHits(), fp);
464  }
465  }
466 
467  return n_tracks;
468  }

◆ relabel_bad_seedtracks()

void Event::relabel_bad_seedtracks ( )

Definition at line 795 of file Event.cc.

References seedTracks_, and HLT_2024v14_cff::track.

795  {
796  int newlabel = 0;
797  for (auto &&track : seedTracks_) {
798  if (track.label() < 0)
799  track.setLabel(--newlabel);
800  }
801  }
TrackVec seedTracks_
Definition: Event.h:74

◆ relabel_cmsswtracks_from_seeds()

void Event::relabel_cmsswtracks_from_seeds ( )

Definition at line 803 of file Event.cc.

References cmsswTracks_, iseed, label, and seedTracks_.

803  {
804  std::map<int, int> cmsswLabelMap;
805  for (size_t iseed = 0; iseed < seedTracks_.size(); iseed++) {
806  for (size_t icmssw = 0; icmssw < cmsswTracks_.size(); icmssw++) {
807  if (cmsswTracks_[icmssw].label() == static_cast<int>(iseed)) {
808  cmsswLabelMap[icmssw] = seedTracks_[iseed].label();
809  break;
810  }
811  }
812  }
813  for (size_t icmssw = 0; icmssw < cmsswTracks_.size(); icmssw++) {
814  cmsswTracks_[icmssw].setLabel(cmsswLabelMap[icmssw]);
815  }
816  }
TrackVec cmsswTracks_
Definition: Event.h:75
TrackVec seedTracks_
Definition: Event.h:74
char const * label
int iseed
Definition: AMPTWrapper.h:134

◆ reset()

void Event::reset ( int  evtID)

Definition at line 33 of file Event.cc.

References beamSpot_, candidateTracks_, candidateTracksExtra_, cmsswTracks_, cmsswTracksExtra_, evtID(), evtID_, fitTracks_, fitTracksExtra_, MainPageGenerator::l, layerHitMasks_, layerHits_, mkfit::Validation::resetValidationMaps(), seedTracks_, seedTracksExtra_, simHitsInfo_, simTracks_, simTracksExtra_, simTrackStates_, and validation_.

Referenced by mkfit::Shell::GoToEvent().

33  {
34  evtID_ = evtID;
35 
36  for (auto &&l : layerHits_) {
37  l.clear();
38  }
39  for (auto &&l : layerHitMasks_) {
40  l.clear();
41  }
42 
43  simHitsInfo_.clear();
44  simTrackStates_.clear();
45  simTracks_.clear();
46  simTracksExtra_.clear();
47  seedTracks_.clear();
48  seedTracksExtra_.clear();
49  candidateTracks_.clear();
50  candidateTracksExtra_.clear();
51  fitTracks_.clear();
52  fitTracksExtra_.clear();
53  cmsswTracks_.clear();
54  cmsswTracksExtra_.clear();
55  beamSpot_ = {};
56 
57  validation_.resetValidationMaps(); // need to reset maps for every event.
58  }
Validation & validation_
Definition: Event.h:50
virtual void resetValidationMaps()
Definition: Validation.h:50
TrackVec cmsswTracks_
Definition: Event.h:75
TrackExtraVec candidateTracksExtra_
Definition: Event.h:77
TrackVec seedTracks_
Definition: Event.h:74
int evtID() const
Definition: Event.h:23
BeamSpot beamSpot_
Definition: Event.h:69
TrackExtraVec cmsswTracksExtra_
Definition: Event.h:78
TrackExtraVec simTracksExtra_
Definition: Event.h:77
MCHitInfoVec simHitsInfo_
Definition: Event.h:72
std::vector< HitVec > layerHits_
Definition: Event.h:70
TrackVec simTracks_
Definition: Event.h:74
TSVec simTrackStates_
Definition: Event.h:80
int evtID_
Definition: Event.h:64
TrackExtraVec fitTracksExtra_
Definition: Event.h:77
TrackExtraVec seedTracksExtra_
Definition: Event.h:77
TrackVec fitTracks_
Definition: Event.h:74
TrackVec candidateTracks_
Definition: Event.h:74
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

◆ resetCurrentSeedTracks()

void Event::resetCurrentSeedTracks ( )

Definition at line 917 of file Event.cc.

References currentSeedSimFromHits_, and currentSeedTracks_.

Referenced by mkfit::Shell::GoToEvent().

917  {
918  currentSeedTracks_ = nullptr;
919  currentSeedSimFromHits_.clear();
920  }
const TrackVec * currentSeedTracks_
Definition: Event.h:65
std::vector< SimLabelFromHits > currentSeedSimFromHits_
Definition: Event.h:66

◆ resetLayerHitMap()

void mkfit::Event::resetLayerHitMap ( bool  resetSimHits)

◆ select_tracks_iter()

int Event::select_tracks_iter ( unsigned int  n = 0)

Definition at line 735 of file Event.cc.

References mkfit::TrackBase::algorithm(), analysisFilters_cff::algorithms, cmsswTracks_, spr::find(), createfilelist::int, dqmiodumpmetadata::n, nt, and seedTracks_.

735  {
736  if (n == 0)
737  return 1;
738 
739  unsigned int algorithms[] = {4, 22, 23, 5, 24, 7, 8, 9, 10, 6}; //to be stored somewhere common
740 
741  //saving seeds by algorithm
742  const int ns = seedTracks_.size();
743 
744  TrackVec cleanSeedTracks;
745  cleanSeedTracks.reserve(ns);
746 
747  for (int ts = 0; ts < ns; ts++) {
748  const Track &tk = seedTracks_[ts];
749  unsigned int algo = (unsigned int)tk.algorithm();
751  cleanSeedTracks.emplace_back(seedTracks_[ts]);
752  }
753  seedTracks_.swap(cleanSeedTracks);
754 
755  //saving tracks by algorithm
756  const int nt = cmsswTracks_.size();
757 
758  TrackVec cleanTracks;
759  cleanTracks.reserve(nt);
760 
761  for (int ts = 0; ts < nt; ts++) {
762  const Track &tk = cmsswTracks_[ts];
763  unsigned int algo = (unsigned int)tk.algorithm();
765  cleanTracks.emplace_back(cmsswTracks_[ts]);
766  }
767  cmsswTracks_.swap(cleanTracks);
768  return cmsswTracks_.size() + seedTracks_.size();
769  }
TrackVec cmsswTracks_
Definition: Event.h:75
TrackVec seedTracks_
Definition: Event.h:74
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int nt
Definition: AMPTWrapper.h:42
std::vector< Track > TrackVec

◆ setCurrentSeedTracks()

void Event::setCurrentSeedTracks ( const TrackVec seeds)

Definition at line 868 of file Event.cc.

References currentSeedSimFromHits_, currentSeedTracks_, and HLT_2024v14_cff::seeds.

Referenced by mkfit::Shell::ProcessEvent().

868  {
870  currentSeedSimFromHits_.clear();
871  }
const TrackVec * currentSeedTracks_
Definition: Event.h:65
std::vector< SimLabelFromHits > currentSeedSimFromHits_
Definition: Event.h:66

◆ setInputFromCMSSW()

void Event::setInputFromCMSSW ( std::vector< HitVec hits,
TrackVec  seeds 
)

Definition at line 472 of file Event.cc.

References hfClusterShapes_cfi::hits, layerHits_, eostools::move(), HLT_2024v14_cff::seeds, and seedTracks_.

472  {
475  }
TrackVec seedTracks_
Definition: Event.h:74
std::vector< HitVec > layerHits_
Definition: Event.h:70
def move(src, dest)
Definition: eostools.py:511

◆ simLabelForCurrentSeed()

Event::SimLabelFromHits Event::simLabelForCurrentSeed ( int  i) const

Definition at line 875 of file Event.cc.

References cms::cuda::assert(), currentSeed(), currentSeedSimFromHits_, currentSeedTracks_, h, mps_fire::i, createfilelist::int, layerHits_, alignCSCRings::s, simHitsInfo_, and x.

Referenced by mkfit::MkFinder::selectHitIndices(), and mkfit::MkFinder::selectHitIndicesV2().

875  {
876  assert(currentSeedTracks_ != nullptr);
877 
878  if (currentSeedSimFromHits_.empty()) {
880 
881  for (int si = 0; si < (int)currentSeedTracks_->size(); ++si) {
882  const Track &s = currentSeed(si);
883  // printf("%3d (%d): [", si, s.label());
884  std::map<int, int> lab_cnt;
885  for (int hi = 0; hi < s.nTotalHits(); ++hi) {
886  auto hot = s.getHitOnTrack(hi);
887  // printf(" %d", hot.index);
888  if (hot.index < 0)
889  continue;
890  const Hit &h = layerHits_[hot.layer][hot.index];
891  int hl = simHitsInfo_[h.mcHitID()].mcTrackID_;
892  // printf(" (%d)", hl);
893  if (hl >= 0)
894  ++lab_cnt[hl];
895  }
896  int max_c = -1, max_l = -1;
897  for (auto &x : lab_cnt) {
898  if (x.second > max_c) {
899  max_l = x.first;
900  max_c = x.second;
901  } else if (x.second == max_c) {
902  max_l = -1;
903  }
904  }
905  if (max_c < 0) {
906  max_c = 0;
907  max_l = -1;
908  }
909  // printf(" ] -> %d %d => %d\n", s.nTotalHits(), max_c, max_l);
910  currentSeedSimFromHits_[si] = {s.nTotalHits(), max_c, max_l};
911  }
912  }
913 
914  return currentSeedSimFromHits_[i];
915  }
const TrackVec * currentSeedTracks_
Definition: Event.h:65
assert(be >=bs)
Definition: EPCuts.h:4
MCHitInfoVec simHitsInfo_
Definition: Event.h:72
std::vector< HitVec > layerHits_
Definition: Event.h:70
const Track & currentSeed(int i) const
Definition: Event.cc:873
float x
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< SimLabelFromHits > currentSeedSimFromHits_
Definition: Event.h:66

◆ use_seeds_from_cmsswtracks()

int Event::use_seeds_from_cmsswtracks ( )

Definition at line 780 of file Event.cc.

References cmsswTracks_, and seedTracks_.

780  {
781  int ns = seedTracks_.size();
782 
783  TrackVec cleanSeedTracks;
784  cleanSeedTracks.reserve(ns);
785 
786  for (auto &&cmsswtrack : cmsswTracks_) {
787  cleanSeedTracks.emplace_back(seedTracks_[cmsswtrack.label()]);
788  }
789 
790  seedTracks_.swap(cleanSeedTracks);
791 
792  return seedTracks_.size();
793  }
TrackVec cmsswTracks_
Definition: Event.h:75
TrackVec seedTracks_
Definition: Event.h:74
std::vector< Track > TrackVec

◆ validate()

void Event::validate ( )

Definition at line 60 of file Event.cc.

References mkfit::Config::cmssw_val, mkfit::Validation::fillCMSSWEfficiencyTree(), mkfit::Validation::fillCMSSWFakeRateTree(), mkfit::Validation::fillEfficiencyTree(), mkfit::Validation::fillFakeRateTree(), mkfit::Validation::fillFitTree(), mkfit::Config::fit_val, mkfit::Validation::makeCMSSWTkToRecoTksMaps(), mkfit::Validation::makeCMSSWTkToSeedTkMap(), mkfit::Validation::makeRecoTkToRecoTkMaps(), mkfit::Validation::makeRecoTkToSeedTkMapsDumbCMSSW(), mkfit::Validation::makeSeedTkToRecoTkMaps(), mkfit::Validation::makeSimTkToRecoTksMaps(), mkfit::Validation::setTrackExtras(), mkfit::Validation::setTrackScoresDumbCMSSW(), mkfit::Config::sim_val, mkfit::Config::sim_val_for_cmssw, and validation_.

60  {
61  // special map needed for sim_val_for_cmssw + set the track scores
65  }
66 
67  // standard eff/fr/dr validation
74  }
75 
76  // special cmssw to mkfit validation
77  if (Config::cmssw_val) {
84  }
85 
86  if (Config::fit_val) { // fit val for z-phi tuning
87  validation_.fillFitTree(*this);
88  }
89  }
Validation & validation_
Definition: Event.h:50
virtual void fillEfficiencyTree(const Event &)
Definition: Validation.h:66
virtual void setTrackScoresDumbCMSSW(Event &)
Definition: Validation.h:64
virtual void makeSimTkToRecoTksMaps(Event &)
Definition: Validation.h:56
virtual void setTrackExtras(Event &ev)
Definition: Validation.h:55
virtual void fillCMSSWFakeRateTree(const Event &)
Definition: Validation.h:70
virtual void makeCMSSWTkToRecoTksMaps(Event &)
Definition: Validation.h:59
virtual void makeSeedTkToRecoTkMaps(Event &)
Definition: Validation.h:57
virtual void makeRecoTkToSeedTkMapsDumbCMSSW(Event &)
Definition: Validation.h:62
virtual void makeCMSSWTkToSeedTkMap(Event &)
Definition: Validation.h:61
virtual void makeRecoTkToRecoTkMaps(Event &)
Definition: Validation.h:58
virtual void fillFakeRateTree(const Event &)
Definition: Validation.h:67
virtual void fillCMSSWEfficiencyTree(const Event &)
Definition: Validation.h:69
virtual void fillFitTree(const Event &)
Definition: Validation.h:71

◆ write_out()

void Event::write_out ( DataFile data_file)

Definition at line 118 of file Event.cc.

References cms::cuda::assert(), align::BeamSpot, beamSpot_, cmsswTracks_, mkfit::DataFile::f_fp, personalPlayback::fp, mkfit::DataFile::hasBeamSpot(), mkfit::DataFile::hasCmsswTracks(), mkfit::DataFile::hasHitIterMasks(), mkfit::DataFile::hasSeeds(), mkfit::DataFile::hasSimTrackStates(), createfilelist::int, layerHitMasks_, layerHits_, mutex, cms::cuda::nh, seedTracks_, simHitsInfo_, simTracks_, simTrackStates_, and write_tracks().

118  {
119  FILE *fp = data_file.f_fp;
120 
121  static std::mutex writemutex;
122  std::lock_guard<std::mutex> writelock(writemutex);
123 
124  auto start = ftell(fp);
125  int evsize = sizeof(int);
126  fwrite(&evsize, sizeof(int), 1, fp); // this will be overwritten at the end
127 
128  evsize += write_tracks(fp, simTracks_);
129 
130  if (data_file.hasSimTrackStates()) {
131  int nts = simTrackStates_.size();
132  fwrite(&nts, sizeof(int), 1, fp);
133  fwrite(&simTrackStates_[0], sizeof(TrackState), nts, fp);
134  evsize += sizeof(int) + nts * sizeof(TrackState);
135  }
136 
137  int nl = layerHits_.size();
138  fwrite(&nl, sizeof(int), 1, fp);
139  evsize += sizeof(int);
140  for (int il = 0; il < nl; ++il) {
141  int nh = layerHits_[il].size();
142  fwrite(&nh, sizeof(int), 1, fp);
143  fwrite(&layerHits_[il][0], sizeof(Hit), nh, fp);
144  evsize += sizeof(int) + nh * sizeof(Hit);
145  }
146 
147  if (data_file.hasHitIterMasks()) {
148  //sizes are the same as in layerHits_
149  for (int il = 0; il < nl; ++il) {
150  int nh = layerHitMasks_[il].size();
151  assert(nh == (int)layerHits_[il].size());
152  fwrite(&layerHitMasks_[il][0], sizeof(uint64_t), nh, fp);
153  evsize += nh * sizeof(uint64_t);
154  }
155  }
156 
157  int nm = simHitsInfo_.size();
158  fwrite(&nm, sizeof(int), 1, fp);
159  fwrite(&simHitsInfo_[0], sizeof(MCHitInfo), nm, fp);
160  evsize += sizeof(int) + nm * sizeof(MCHitInfo);
161 
162  if (data_file.hasSeeds()) {
163  evsize += write_tracks(fp, seedTracks_);
164  }
165 
166  if (data_file.hasCmsswTracks()) {
167  evsize += write_tracks(fp, cmsswTracks_);
168  }
169 
170  if (data_file.hasBeamSpot()) {
171  fwrite(&beamSpot_, sizeof(BeamSpot), 1, fp);
172  evsize += sizeof(BeamSpot);
173  }
174 
175  fseek(fp, start, SEEK_SET);
176  fwrite(&evsize, sizeof(int), 1, fp);
177  fseek(fp, 0, SEEK_END);
178 
179  //layerHitMap_ is recreated afterwards
180 
181  /*
182  printf("write %i tracks\n",nt);
183  for (int it = 0; it<nt; it++) {
184  printf("track with pT=%5.3f\n",simTracks_[it].pT());
185  for (int ih=0; ih<simTracks_[it].nTotalHits(); ++ih) {
186  printf("hit lyr:%2d idx=%i\n", simTracks_[it].getHitLyr(ih), simTracks_[it].getHitIdx(ih));
187  }
188  }
189  printf("write %i layers\n",nl);
190  for (int il = 0; il<nl; il++) {
191  printf("write %i hits in layer %i\n",layerHits_[il].size(),il);
192  for (int ih = 0; ih<layerHits_[il].size(); ih++) {
193  printf("hit with r=%5.3f x=%5.3f y=%5.3f z=%5.3f\n",layerHits_[il][ih].r(),layerHits_[il][ih].x(),layerHits_[il][ih].y(),layerHits_[il][ih].z());
194  }
195  }
196  */
197  }
size
Write out results.
Definition: start.py:1
TrackVec cmsswTracks_
Definition: Event.h:75
static std::mutex mutex
Definition: Proxy.cc:8
TrackVec seedTracks_
Definition: Event.h:74
assert(be >=bs)
BeamSpot beamSpot_
Definition: Event.h:69
uint32_t nh
MCHitInfoVec simHitsInfo_
Definition: Event.h:72
std::vector< HitVec > layerHits_
Definition: Event.h:70
TrackVec simTracks_
Definition: Event.h:74
TSVec simTrackStates_
Definition: Event.h:80
unsigned long long uint64_t
Definition: Time.h:13
int write_tracks(FILE *fp, const TrackVec &tracks)
Definition: Event.cc:422
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:71

◆ write_tracks()

int Event::write_tracks ( FILE *  fp,
const TrackVec tracks 
)

Definition at line 422 of file Event.cc.

References personalPlayback::fp, mps_fire::i, createfilelist::int, and DiMuonV_cfg::tracks.

Referenced by write_out().

422  {
423  // Returns total number of bytes written.
424 
425  int n_tracks = tracks.size();
426  fwrite(&n_tracks, sizeof(int), 1, fp);
427 
428  auto start = ftell(fp);
429  int data_size = 2 * sizeof(int) + n_tracks * sizeof(Track);
430  fwrite(&data_size, sizeof(int), 1, fp);
431 
432  fwrite(tracks.data(), sizeof(Track), n_tracks, fp);
433 
434  for (int i = 0; i < n_tracks; ++i) {
435  fwrite(tracks[i].beginHitsOnTrack(), sizeof(HitOnTrack), tracks[i].nTotalHits(), fp);
436  data_size += tracks[i].nTotalHits() * sizeof(HitOnTrack);
437  }
438 
439  fseek(fp, start, SEEK_SET);
440  fwrite(&data_size, sizeof(int), 1, fp);
441  fseek(fp, 0, SEEK_END);
442 
443  return data_size;
444  }
Definition: start.py:1

Member Data Documentation

◆ beamSpot_

BeamSpot mkfit::Event::beamSpot_

Definition at line 69 of file Event.h.

Referenced by read_in(), reset(), and write_out().

◆ candidateTracks_

TrackVec mkfit::Event::candidateTracks_

Definition at line 74 of file Event.h.

Referenced by reset().

◆ candidateTracksExtra_

TrackExtraVec mkfit::Event::candidateTracksExtra_
mutable

Definition at line 77 of file Event.h.

Referenced by reset().

◆ cmsswTracks_

TrackVec mkfit::Event::cmsswTracks_

◆ cmsswTracksExtra_

TrackExtraVec mkfit::Event::cmsswTracksExtra_
mutable

Definition at line 78 of file Event.h.

Referenced by reset().

◆ currentSeedSimFromHits_

std::vector<SimLabelFromHits> mkfit::Event::currentSeedSimFromHits_
mutableprivate

Definition at line 66 of file Event.h.

Referenced by resetCurrentSeedTracks(), setCurrentSeedTracks(), and simLabelForCurrentSeed().

◆ currentSeedTracks_

const TrackVec* mkfit::Event::currentSeedTracks_ = nullptr
private

◆ evtID_

int mkfit::Event::evtID_
private

Definition at line 64 of file Event.h.

Referenced by evtID(), and reset().

◆ fitTracks_

TrackVec mkfit::Event::fitTracks_

Definition at line 74 of file Event.h.

Referenced by reset().

◆ fitTracksExtra_

TrackExtraVec mkfit::Event::fitTracksExtra_
mutable

Definition at line 77 of file Event.h.

Referenced by reset().

◆ layerHitMasks_

std::vector<std::vector<uint64_t> > mkfit::Event::layerHitMasks_

Definition at line 71 of file Event.h.

Referenced by Event(), fill_hitmask_bool_vectors(), read_in(), reset(), and write_out().

◆ layerHits_

std::vector<HitVec> mkfit::Event::layerHits_

◆ printmutex

std::mutex Event::printmutex
static

◆ seedTracks_

TrackVec mkfit::Event::seedTracks_

◆ seedTracksExtra_

TrackExtraVec mkfit::Event::seedTracksExtra_
mutable

Definition at line 77 of file Event.h.

Referenced by reset().

◆ simHitsInfo_

MCHitInfoVec mkfit::Event::simHitsInfo_

◆ simTracks_

TrackVec mkfit::Event::simTracks_

◆ simTracksExtra_

TrackExtraVec mkfit::Event::simTracksExtra_
mutable

Definition at line 77 of file Event.h.

Referenced by reset().

◆ simTrackStates_

TSVec mkfit::Event::simTrackStates_

Definition at line 80 of file Event.h.

Referenced by read_in(), reset(), and write_out().

◆ validation_

Validation& mkfit::Event::validation_

Definition at line 50 of file Event.h.

Referenced by Event(), reset(), and validate().