CMS 3D CMS Logo

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

#include <Event.h>

Public Member Functions

int clean_cms_seedtracks (TrackVec *seed_ptr=nullptr)
 
int clean_cms_seedtracks_badlabel ()
 
int clean_cms_simtracks ()
 
 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 resetLayerHitMap (bool resetSimHits)
 
int select_tracks_iter (unsigned int n=0)
 
void setInputFromCMSSW (std::vector< HitVec > hits, TrackVec seeds)
 
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

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:57
int evtID_
Definition: Event.h:53
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

◆ 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:57
int evtID_
Definition: Event.h:53
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

Member Function Documentation

◆ clean_cms_seedtracks()

int Event::clean_cms_seedtracks ( TrackVec seed_ptr = nullptr)

Definition at line 579 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(), mkfit::TrackBase::momEta(), mkfit::TrackBase::momPhi(), mkfit::Track::nFoundHits(), nHits, funct::pow(), DiDispStaMuonMonitor_cfi::pt, mkfit::TrackBase::pT(), DetachedQuadStep_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().

579  {
580  const float etamax_brl = Config::c_etamax_brl;
581  const float dpt_common = Config::c_dpt_common;
582  const float dzmax_brl = Config::c_dzmax_brl;
583  const float drmax_brl = Config::c_drmax_brl;
584  const float ptmin_hpt = Config::c_ptmin_hpt;
585  const float dzmax_hpt = Config::c_dzmax_hpt;
586  const float drmax_hpt = Config::c_drmax_hpt;
587  const float dzmax_els = Config::c_dzmax_els;
588  const float drmax_els = Config::c_drmax_els;
589 
590  const float dzmax2_inv_brl = 1.f / (dzmax_brl * dzmax_brl);
591  const float drmax2_inv_brl = 1.f / (drmax_brl * drmax_brl);
592  const float dzmax2_inv_hpt = 1.f / (dzmax_hpt * dzmax_hpt);
593  const float drmax2_inv_hpt = 1.f / (drmax_hpt * drmax_hpt);
594  const float dzmax2_inv_els = 1.f / (dzmax_els * dzmax_els);
595  const float drmax2_inv_els = 1.f / (drmax_els * drmax_els);
596 
597  TrackVec &seeds = (seed_ptr != nullptr) ? *seed_ptr : seedTracks_;
598  const int ns = seeds.size();
599 
600  TrackVec cleanSeedTracks;
601  cleanSeedTracks.reserve(ns);
602  std::vector<bool> writetrack(ns, true);
603 
604  const float invR1GeV = 1.f / Config::track1GeVradius;
605 
606  std::vector<int> nHits(ns);
607  std::vector<int> charge(ns);
608  std::vector<float> oldPhi(ns);
609  std::vector<float> pos2(ns);
610  std::vector<float> eta(ns);
611  std::vector<float> ctheta(ns);
612  std::vector<float> invptq(ns);
613  std::vector<float> pt(ns);
614  std::vector<float> x(ns);
615  std::vector<float> y(ns);
616  std::vector<float> z(ns);
617 
618  for (int ts = 0; ts < ns; ts++) {
619  const Track &tk = seeds[ts];
620  nHits[ts] = tk.nFoundHits();
621  charge[ts] = tk.charge();
622  oldPhi[ts] = tk.momPhi();
623  pos2[ts] = std::pow(tk.x(), 2) + std::pow(tk.y(), 2);
624  eta[ts] = tk.momEta();
625  ctheta[ts] = 1.f / std::tan(tk.theta());
626  invptq[ts] = tk.charge() * tk.invpT();
627  pt[ts] = tk.pT();
628  x[ts] = tk.x();
629  y[ts] = tk.y();
630  z[ts] = tk.z();
631  }
632 
633  for (int ts = 0; ts < ns; ts++) {
634  if (not writetrack[ts])
635  continue; //FIXME: this speed up prevents transitive masking; check build cost!
636 
637  const float oldPhi1 = oldPhi[ts];
638  const float pos2_first = pos2[ts];
639  const float Eta1 = eta[ts];
640  const float Pt1 = pt[ts];
641  const float invptq_first = invptq[ts];
642 
643  //#pragma simd /* Vectorization via simd had issues with icc */
644  for (int tss = ts + 1; tss < ns; tss++) {
645  const float Pt2 = pt[tss];
646 
648  if (charge[tss] != charge[ts])
649  continue;
650 
651  const float thisDPt = std::abs(Pt2 - Pt1);
653  if (thisDPt > dpt_common * (Pt1))
654  continue;
655 
656  const float Eta2 = eta[tss];
657  const float deta2 = std::pow(Eta1 - Eta2, 2);
658 
659  const float oldPhi2 = oldPhi[tss];
660 
661  const float pos2_second = pos2[tss];
662  const float thisDXYSign05 = pos2_second > pos2_first ? -0.5f : 0.5f;
663 
664  const float thisDXY = thisDXYSign05 * sqrt(std::pow(x[ts] - x[tss], 2) + std::pow(y[ts] - y[tss], 2));
665 
666  const float invptq_second = invptq[tss];
667 
668  const float newPhi1 = oldPhi1 - thisDXY * invR1GeV * invptq_first;
669  const float newPhi2 = oldPhi2 + thisDXY * invR1GeV * invptq_second;
670 
671  const float dphi = cdist(std::abs(newPhi1 - newPhi2));
672 
673  const float dr2 = deta2 + dphi * dphi;
674 
675  const float thisDZ = z[ts] - z[tss] - thisDXY * (ctheta[ts] + ctheta[tss]);
676  const float dz2 = thisDZ * thisDZ;
677 
680  if (std::abs(Eta1) < etamax_brl) {
681  if (dz2 * dzmax2_inv_brl + dr2 * drmax2_inv_brl < 1.0f)
682  writetrack[tss] = false;
683  } else if (Pt1 > ptmin_hpt) {
684  if (dz2 * dzmax2_inv_hpt + dr2 * drmax2_inv_hpt < 1.0f)
685  writetrack[tss] = false;
686  } else {
687  if (dz2 * dzmax2_inv_els + dr2 * drmax2_inv_els < 1.0f)
688  writetrack[tss] = false;
689  }
690  }
691 
692  if (writetrack[ts])
693  cleanSeedTracks.emplace_back(seeds[ts]);
694  }
695 
696  seeds.swap(cleanSeedTracks);
697 
698 #ifdef DEBUG
699  {
700  const int ns2 = seeds.size();
701  printf("Number of CMS seeds before %d --> after %d cleaning\n", ns, ns2);
702 
703  for (int it = 0; it < ns2; it++) {
704  const Track &ss = seeds[it];
705  printf(" %3i q=%+i pT=%7.3f eta=% 7.3f nHits=%i label=% i\n",
706  it,
707  ss.charge(),
708  ss.pT(),
709  ss.momEta(),
710  ss.nFoundHits(),
711  ss.label());
712  }
713  }
714 #endif
715 
716  return seeds.size();
717  }
constexpr float c_drmax_els
Definition: Config.h:143
constexpr float c_dpt_common
Definition: Config.h:136
TrackVec seedTracks_
Definition: Event.h:61
float float float z
constexpr float c_dzmax_hpt
Definition: Config.h:140
constexpr float c_etamax_brl
Definition: Config.h:135
constexpr float c_ptmin_hpt
Definition: Config.h:139
T sqrt(T t)
Definition: SSEVec.h:19
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:75
std::vector< Track > TrackVec
constexpr float track1GeVradius
Definition: Config.h:134
constexpr float c_dzmax_els
Definition: Config.h:142
constexpr float c_dzmax_brl
Definition: Config.h:137
float x
constexpr float c_drmax_hpt
Definition: Config.h:141
constexpr float c_drmax_brl
Definition: Config.h:138
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 755 of file Event.cc.

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

755  {
756  printf("***\n*** REMOVING SEEDS WITH BAD LABEL. This is a development hack. ***\n***\n");
757  TrackVec buf;
758  seedTracks_.swap(buf);
759  std::copy_if(
760  buf.begin(), buf.end(), std::back_inserter(seedTracks_), [](const Track &t) { return t.label() >= 0; });
761  return seedTracks_.size();
762  }
TrackVec seedTracks_
Definition: Event.h:61
std::vector< Track > TrackVec

◆ clean_cms_simtracks()

int Event::clean_cms_simtracks ( )

Definition at line 498 of file Event.cc.

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

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

◆ evtID()

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

Definition at line 23 of file Event.h.

References evtID_.

Referenced by mkfit::MkBuilder::fit_cands_BH(), mkfit::Shell::GoToEvent(), mkfit::Shell::NextEvent(), reset(), and mkfit::Shell::Status().

23 { return evtID_; }
int evtID_
Definition: Event.h:53

◆ 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 806 of file Event.cc.

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

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

806  {
807  // Convert from per-hit uint64_t to per layer bool-vectors for given
808  // iteration.
809 
810  uint64_t iter_mask = 1 << track_algo;
811 
812  const int n_lay = (int)layerHits_.size();
813  layer_masks.resize(n_lay);
814 
815  for (int l = 0; l < n_lay; ++l) {
816  const int n_hit = (int)layerHits_[l].size();
817  layer_masks[l].resize(n_hit);
818 
819  for (int i = 0; i < n_hit; ++i) {
820  layer_masks[l][i] = layerHitMasks_[l][i] & iter_mask;
821  }
822  }
823  }
size
Write out results.
std::vector< HitVec > layerHits_
Definition: Event.h:57
unsigned long long uint64_t
Definition: Time.h:13
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

◆ 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 825 of file Event.cc.

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

825  {
826  // Convert from per-hit uint64_t to per layer bool-vectors for a list of
827  // iterations.
828  // A hit mask is set if it is set for _all_ listed iterations.
829 
830  uint64_t iter_mask = 0;
831  for (auto ta : track_algo_vec)
832  iter_mask |= 1 << ta;
833 
834  const int n_lay = (int)layerHits_.size();
835  layer_masks.resize(n_lay);
836 
837  for (int l = 0; l < n_lay; ++l) {
838  const int n_hit = (int)layerHits_[l].size();
839  layer_masks[l].resize(n_hit);
840 
841  for (int i = 0; i < n_hit; ++i) {
842  uint64_t hitmasks = layerHitMasks_[l][i];
843  layer_masks[l][i] = ((iter_mask ^ hitmasks) & iter_mask) == 0;
844  }
845  }
846  }
size
Write out results.
std::vector< HitVec > layerHits_
Definition: Event.h:57
unsigned long long uint64_t
Definition: Time.h:13
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

◆ kludge_cms_hit_errors()

void Event::kludge_cms_hit_errors ( )

Definition at line 463 of file Event.cc.

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

Referenced by read_in().

463  {
464  // Enforce Vxy on all layers, Vz on pixb only.
465 
466  const float Exy = 15 * 1e-4, Vxy = Exy * Exy;
467  const float Ez = 30 * 1e-4, Vz = Ez * Ez;
468 
469  int nl = layerHits_.size();
470 
471  int cnt = 0;
472 
473  for (int il = 0; il < nl; il++) {
474  if (layerHits_[il].empty())
475  continue;
476 
477  for (Hit &h : layerHits_[il]) {
478  SVector6 &c = h.error_nc();
479 
480  float vxy = c[0] + c[2];
481  if (vxy < Vxy) {
482  c[0] *= Vxy / vxy;
483  c[2] *= Vxy / vxy;
484  ++cnt;
485  }
486  if (il < 4 && c[5] < Vz) {
487  c[5] = Vz;
488  ++cnt;
489  }
490  }
491  }
492 
493  printf("Event::kludge_cms_hit_errors processed %d layers, kludged %d entries.\n", nl, cnt);
494  }
std::vector< HitVec > layerHits_
Definition: Event.h:57
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 540 of file Event.cc.

References mkfit::IterationConfig::get_track_scorer(), mkfit::getScoreCand(), heavyIonCSV_trainingSettings::idx, layerHits_, nt, simHitsInfo_, submitPVValidationJobs::t, and pwdgSkimBPark_cfi::tracks.

540  {
541  const int nt = tracks.size();
542  auto score_func = IterationConfig::get_track_scorer("default");
543  //WARNING: Printouts for hits will not make any sense if mkFit is not run with a validation flag such as --quality-val
544  printf("Event::print_tracks printing %d tracks %s hits:\n", nt, (print_hits ? "with" : "without"));
545  for (int it = 0; it < nt; it++) {
546  const Track &t = tracks[it];
547  printf(" %i with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d findable=%d score=%7.3f chi2=%7.3f\n",
548  it,
549  t.charge(),
550  t.pT(),
551  t.momEta(),
552  t.nFoundHits(),
553  t.label(),
554  t.isFindable(),
555  getScoreCand(score_func, t),
556  t.chi2());
557 
558  if (print_hits) {
559  for (int ih = 0; ih < t.nTotalHits(); ++ih) {
560  int lyr = t.getHitLyr(ih);
561  int idx = t.getHitIdx(ih);
562  if (idx >= 0) {
563  const Hit &hit = layerHits_[lyr][idx];
564  printf(" hit %2d lyr=%2d idx=%3d pos r=%7.3f z=% 8.3f mc_hit=%3d mc_trk=%3d\n",
565  ih,
566  lyr,
567  idx,
568  layerHits_[lyr][idx].r(),
569  layerHits_[lyr][idx].z(),
570  hit.mcHitID(),
571  hit.mcTrackID(simHitsInfo_));
572  } else
573  printf(" hit %2d lyr=%2d idx=%3d\n", ih, t.getHitLyr(ih), t.getHitIdx(ih));
574  }
575  }
576  }
577  }
float getScoreCand(const track_score_func &score_func, const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:608
float float float z
MCHitInfoVec simHitsInfo_
Definition: Event.h:59
int nt
Definition: AMPTWrapper.h:42
std::vector< HitVec > layerHits_
Definition: Event.h:57
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:59
std::vector< HitVec > layerHits_
Definition: Event.h:57
TrackVec simTracks_
Definition: Event.h:61

◆ 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_, relativeConstraints::empty, mkfit::DataFile::f_fp, personalPlayback::fp, mkfit::DataFile::hasBeamSpot(), mkfit::DataFile::hasCmsswTracks(), mkfit::DataFile::hasHitIterMasks(), mkfit::DataFile::hasSeeds(), mkfit::DataFile::hasSimTrackStates(), heavyIonCSV_trainingSettings::idx, createfilelist::int, kludge_cms_hit_errors(), mkfit::Config::kludgeCmsHitErrors, layerHitMasks_, layerHits_, cms::cuda::nh, nt, mkfit::Config::nTracks, read_tracks(), mkfit::Config::readCmsswTracks, mkfit::Config::seedInput, seedTracks_, mkfit::Config::silent, simHitsInfo_, simTracks_, simTrackStates_, findQualityFiles::size, mathSSE::sqrt(), contentValuesCheck::ss, submitPVValidationJobs::t, 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  printf("Read %i layers\n", nl);
337  int total_hits = 0;
338  for (int il = 0; il < nl; il++) {
339  if (layerHits_[il].empty())
340  continue;
341 
342  printf("Read %i hits in layer %i\n", (int)layerHits_[il].size(), il);
343  total_hits += layerHits_[il].size();
344  for (int ih = 0; ih < (int)layerHits_[il].size(); ih++) {
345  const Hit &hit = layerHits_[il][ih];
346  printf(" mcHitID=%5d r=%10g x=%10g y=%10g z=%10g sx=%10.4g sy=%10.4e sz=%10.4e\n",
347  hit.mcHitID(),
348  hit.r(),
349  hit.x(),
350  hit.y(),
351  hit.z(),
352  std::sqrt(hit.exx()),
353  std::sqrt(hit.eyy()),
354  std::sqrt(hit.ezz()));
355  }
356  }
357  printf("Total hits in all layers = %d\n", total_hits);
358 #endif
359 #ifdef DUMP_REC_TRACKS
360  printf("Read %i rectracks\n", nert);
361  for (int it = 0; it < nert; it++) {
362  const Track &t = cmsswTracks_[it];
363  printf(" %-3i with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d algo=%2d\n",
364  it,
365  t.charge(),
366  t.pT(),
367  t.momEta(),
368  t.nFoundHits(),
369  t.label(),
370  (int)t.algorithm());
371 #ifdef DUMP_REC_TRACK_HITS
372  for (int ih = 0; ih < t.nTotalHits(); ++ih) {
373  int lyr = t.getHitLyr(ih);
374  int idx = t.getHitIdx(ih);
375  if (idx >= 0) {
376  const Hit &hit = layerHits_[lyr][idx];
377  printf(" hit %2d lyr=%2d idx=%3d pos r=%7.3f z=% 8.3f mc_hit=%3d mc_trk=%3d\n",
378  ih,
379  lyr,
380  idx,
381  hit.r(),
382  hit.z(),
383  hit.mcHitID(),
384  hit.mcTrackID(simHitsInfo_));
385  } else
386  printf(" hit %2d idx=%i\n", ih, t.getHitIdx(ih));
387  }
388 #endif
389  }
390 #endif
391 
392  if (data_file.hasBeamSpot()) {
393  fread(&beamSpot_, sizeof(BeamSpot), 1, fp);
394  }
395 
398  }
399 
400  if (!Config::silent)
401  printf("Read complete, %d simtracks on file.\n", nt);
402  }
size
Write out results.
void kludge_cms_hit_errors()
Definition: Event.cc:463
TrackVec cmsswTracks_
Definition: Event.h:62
TrackVec seedTracks_
Definition: Event.h:61
float float float z
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
BeamSpot beamSpot_
Definition: Event.h:56
T sqrt(T t)
Definition: SSEVec.h:19
uint32_t nh
MCHitInfoVec simHitsInfo_
Definition: Event.h:59
int nt
Definition: AMPTWrapper.h:42
std::vector< HitVec > layerHits_
Definition: Event.h:57
TrackVec simTracks_
Definition: Event.h:61
TSVec simTrackStates_
Definition: Event.h:67
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:430
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

◆ read_tracks()

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

Definition at line 430 of file Event.cc.

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

Referenced by read_in().

430  {
431  // Returns number of read tracks (negative if actual reading was skipped).
432 
433  int n_tracks, data_size;
434  fread(&n_tracks, sizeof(int), 1, fp);
435  fread(&data_size, sizeof(int), 1, fp);
436 
437  if (skip_reading) {
438  fseek(fp, data_size - 2 * sizeof(int), SEEK_CUR); // -2 because data_size counts itself and n_tracks too
439  n_tracks = -n_tracks;
440  } else {
441  tracks.resize(n_tracks);
442 
443  fread(tracks.data(), sizeof(Track), n_tracks, fp);
444 
445  for (int i = 0; i < n_tracks; ++i) {
446  tracks[i].resizeHitsForInput();
447  fread(tracks[i].beginHitsOnTrack_nc(), sizeof(HitOnTrack), tracks[i].nTotalHits(), fp);
448  }
449  }
450 
451  return n_tracks;
452  }

◆ relabel_bad_seedtracks()

void Event::relabel_bad_seedtracks ( )

Definition at line 779 of file Event.cc.

References seedTracks_, and HLT_2023v11_cff::track.

779  {
780  int newlabel = 0;
781  for (auto &&track : seedTracks_) {
782  if (track.label() < 0)
783  track.setLabel(--newlabel);
784  }
785  }
TrackVec seedTracks_
Definition: Event.h:61

◆ relabel_cmsswtracks_from_seeds()

void Event::relabel_cmsswtracks_from_seeds ( )

Definition at line 787 of file Event.cc.

References cmsswTracks_, iseed, label, and seedTracks_.

787  {
788  std::map<int, int> cmsswLabelMap;
789  for (size_t iseed = 0; iseed < seedTracks_.size(); iseed++) {
790  for (size_t icmssw = 0; icmssw < cmsswTracks_.size(); icmssw++) {
791  if (cmsswTracks_[icmssw].label() == static_cast<int>(iseed)) {
792  cmsswLabelMap[icmssw] = seedTracks_[iseed].label();
793  break;
794  }
795  }
796  }
797  for (size_t icmssw = 0; icmssw < cmsswTracks_.size(); icmssw++) {
798  cmsswTracks_[icmssw].setLabel(cmsswLabelMap[icmssw]);
799  }
800  }
TrackVec cmsswTracks_
Definition: Event.h:62
TrackVec seedTracks_
Definition: Event.h:61
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:62
TrackExtraVec candidateTracksExtra_
Definition: Event.h:64
TrackVec seedTracks_
Definition: Event.h:61
int evtID() const
Definition: Event.h:23
BeamSpot beamSpot_
Definition: Event.h:56
TrackExtraVec cmsswTracksExtra_
Definition: Event.h:65
TrackExtraVec simTracksExtra_
Definition: Event.h:64
MCHitInfoVec simHitsInfo_
Definition: Event.h:59
std::vector< HitVec > layerHits_
Definition: Event.h:57
TrackVec simTracks_
Definition: Event.h:61
TSVec simTrackStates_
Definition: Event.h:67
int evtID_
Definition: Event.h:53
TrackExtraVec fitTracksExtra_
Definition: Event.h:64
TrackExtraVec seedTracksExtra_
Definition: Event.h:64
TrackVec fitTracks_
Definition: Event.h:61
TrackVec candidateTracks_
Definition: Event.h:61
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

◆ resetLayerHitMap()

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

◆ select_tracks_iter()

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

Definition at line 719 of file Event.cc.

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

719  {
720  if (n == 0)
721  return 1;
722 
723  unsigned int algorithms[] = {4, 22, 23, 5, 24, 7, 8, 9, 10, 6}; //to be stored somewhere common
724 
725  //saving seeds by algorithm
726  const int ns = seedTracks_.size();
727 
728  TrackVec cleanSeedTracks;
729  cleanSeedTracks.reserve(ns);
730 
731  for (int ts = 0; ts < ns; ts++) {
732  const Track &tk = seedTracks_[ts];
733  unsigned int algo = (unsigned int)tk.algorithm();
735  cleanSeedTracks.emplace_back(seedTracks_[ts]);
736  }
737  seedTracks_.swap(cleanSeedTracks);
738 
739  //saving tracks by algorithm
740  const int nt = cmsswTracks_.size();
741 
742  TrackVec cleanTracks;
743  cleanTracks.reserve(nt);
744 
745  for (int ts = 0; ts < nt; ts++) {
746  const Track &tk = cmsswTracks_[ts];
747  unsigned int algo = (unsigned int)tk.algorithm();
749  cleanTracks.emplace_back(cmsswTracks_[ts]);
750  }
751  cmsswTracks_.swap(cleanTracks);
752  return cmsswTracks_.size() + seedTracks_.size();
753  }
TrackVec cmsswTracks_
Definition: Event.h:62
TrackVec seedTracks_
Definition: Event.h:61
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

◆ setInputFromCMSSW()

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

Definition at line 456 of file Event.cc.

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

456  {
459  }
TrackVec seedTracks_
Definition: Event.h:61
std::vector< HitVec > layerHits_
Definition: Event.h:57
def move(src, dest)
Definition: eostools.py:511

◆ use_seeds_from_cmsswtracks()

int Event::use_seeds_from_cmsswtracks ( )

Definition at line 764 of file Event.cc.

References cmsswTracks_, and seedTracks_.

764  {
765  int ns = seedTracks_.size();
766 
767  TrackVec cleanSeedTracks;
768  cleanSeedTracks.reserve(ns);
769 
770  for (auto &&cmsswtrack : cmsswTracks_) {
771  cleanSeedTracks.emplace_back(seedTracks_[cmsswtrack.label()]);
772  }
773 
774  seedTracks_.swap(cleanSeedTracks);
775 
776  return seedTracks_.size();
777  }
TrackVec cmsswTracks_
Definition: Event.h:62
TrackVec seedTracks_
Definition: Event.h:61
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_, findQualityFiles::size, 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:62
static std::mutex mutex
Definition: Proxy.cc:8
TrackVec seedTracks_
Definition: Event.h:61
assert(be >=bs)
BeamSpot beamSpot_
Definition: Event.h:56
uint32_t nh
MCHitInfoVec simHitsInfo_
Definition: Event.h:59
std::vector< HitVec > layerHits_
Definition: Event.h:57
TrackVec simTracks_
Definition: Event.h:61
TSVec simTrackStates_
Definition: Event.h:67
unsigned long long uint64_t
Definition: Time.h:13
int write_tracks(FILE *fp, const TrackVec &tracks)
Definition: Event.cc:406
std::vector< std::vector< uint64_t > > layerHitMasks_
Definition: Event.h:58

◆ write_tracks()

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

Definition at line 406 of file Event.cc.

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

Referenced by write_out().

406  {
407  // Returns total number of bytes written.
408 
409  int n_tracks = tracks.size();
410  fwrite(&n_tracks, sizeof(int), 1, fp);
411 
412  auto start = ftell(fp);
413  int data_size = 2 * sizeof(int) + n_tracks * sizeof(Track);
414  fwrite(&data_size, sizeof(int), 1, fp);
415 
416  fwrite(tracks.data(), sizeof(Track), n_tracks, fp);
417 
418  for (int i = 0; i < n_tracks; ++i) {
419  fwrite(tracks[i].beginHitsOnTrack(), sizeof(HitOnTrack), tracks[i].nTotalHits(), fp);
420  data_size += tracks[i].nTotalHits() * sizeof(HitOnTrack);
421  }
422 
423  fseek(fp, start, SEEK_SET);
424  fwrite(&data_size, sizeof(int), 1, fp);
425  fseek(fp, 0, SEEK_END);
426 
427  return data_size;
428  }
Definition: start.py:1

Member Data Documentation

◆ beamSpot_

BeamSpot mkfit::Event::beamSpot_

Definition at line 56 of file Event.h.

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

◆ candidateTracks_

TrackVec mkfit::Event::candidateTracks_

Definition at line 61 of file Event.h.

Referenced by reset().

◆ candidateTracksExtra_

TrackExtraVec mkfit::Event::candidateTracksExtra_
mutable

Definition at line 64 of file Event.h.

Referenced by reset().

◆ cmsswTracks_

TrackVec mkfit::Event::cmsswTracks_

◆ cmsswTracksExtra_

TrackExtraVec mkfit::Event::cmsswTracksExtra_
mutable

Definition at line 65 of file Event.h.

Referenced by reset().

◆ evtID_

int mkfit::Event::evtID_
private

Definition at line 53 of file Event.h.

Referenced by evtID(), and reset().

◆ fitTracks_

TrackVec mkfit::Event::fitTracks_

Definition at line 61 of file Event.h.

Referenced by reset().

◆ fitTracksExtra_

TrackExtraVec mkfit::Event::fitTracksExtra_
mutable

Definition at line 64 of file Event.h.

Referenced by reset().

◆ layerHitMasks_

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

Definition at line 58 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 64 of file Event.h.

Referenced by reset().

◆ simHitsInfo_

MCHitInfoVec mkfit::Event::simHitsInfo_

Definition at line 59 of file Event.h.

Referenced by mkfit::Shell::LabelFromHits(), print_tracks(), printStats(), read_in(), reset(), and write_out().

◆ simTracks_

TrackVec mkfit::Event::simTracks_

Definition at line 61 of file Event.h.

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

◆ simTracksExtra_

TrackExtraVec mkfit::Event::simTracksExtra_
mutable

Definition at line 64 of file Event.h.

Referenced by reset().

◆ simTrackStates_

TSVec mkfit::Event::simTrackStates_

Definition at line 67 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().