10 #include "oneapi/tbb/parallel_for.h" 26 for (
int ilay =
layers.begin(); ilay <
layers.end(); ++ilay) {
58 std::vector<Track> &simtracks =
event->simTracks_;
60 for (
int itrack = 0; itrack < (
int)simtracks.size(); ++itrack) {
68 dprint(
"MX - simtrack with nHits=" <<
track.nFoundHits() <<
" chi2=" <<
track.chi2() <<
" pT=" <<
track.pT()
69 <<
" phi=" <<
track.momPhi() <<
" eta=" <<
track.momEta());
72 for (
int itrack = 0; itrack < (
int)simtracks.size(); ++itrack) {
73 for (
int ihit = 0; ihit < simtracks[itrack].nFoundHits(); ++ihit) {
74 dprint(
"track #" << itrack <<
" hit #" << ihit
75 <<
" hit pos=" << simtracks[itrack].hitsVector(
event->layerHits_)[ihit].position()
76 <<
" phi=" << simtracks[itrack].hitsVector(
event->layerHits_)[ihit].phi());
82 printf(
"%s with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d\nState:\n",
93 for (
int ih = 0; ih <
t.nTotalHits(); ++ih) {
94 int lyr =
t.getHitLyr(ih);
95 int idx =
t.getHitIdx(ih);
97 const Hit &
hit =
event->layerHits_[lyr][
idx];
98 printf(
" hit %2d lyr=%2d idx=%4d pos r=%7.3f z=% 8.3f mc_hit=%4d mc_trk=%4d\n",
105 hit.mcTrackID(
event->simHitsInfo_));
107 printf(
" hit %2d idx=%i\n", ih,
t.getHitIdx(ih));
118 std::map<int, int> cmsswLabelToPos;
120 for (
size_t itrack = 0; itrack <
event->cmsswTracks_.size(); itrack++) {
121 cmsswLabelToPos[
event->cmsswTracks_[itrack].label()] = itrack;
125 for (
size_t itrack = 0; itrack <
event->candidateTracks_.size(); itrack++) {
146 const auto &
seed =
event->seedTracks_[itrack];
156 const float pT = tkcand.
pT();
157 float pTmc = 0.f, etamc = 0.f, phimc = 0.f;
161 if (mctrk < 0 || static_cast<size_t>(mctrk) >=
event->simTracks_.size()) {
163 dprintf(
"XX bad track idx %d, orig label was %d\n", mctrk,
label);
165 auto &simtrack =
event->simTracks_[mctrk];
166 pTmc = simtrack.pT();
167 etamc = simtrack.momEta();
168 phimc = simtrack.momPhi();
171 nfoundmc = simtrack.nUniqueLayers();
174 if (pTr > 0.9 && pTr < 1.1)
176 if (pTr > 0.8 && pTr < 1.2)
181 if (pTr > 0.9 && pTr < 1.1)
183 if (pTr > 0.8 && pTr < 1.2)
192 float pTcmssw = 0.f, etacmssw = 0.f, phicmssw = 0.f;
193 int nfoundcmssw = -1;
195 if (cmsswLabelToPos.count(
label)) {
196 auto &cmsswtrack =
event->cmsswTracks_[cmsswLabelToPos[
label]];
197 pTcmssw = cmsswtrack.pT();
198 etacmssw = cmsswtrack.momEta();
199 phicmssw = cmsswtrack.swimPhiToR(tkcand.
x(), tkcand.
y());
200 nfoundcmssw = cmsswtrack.nUniqueLayers();
207 "MX - found track with chi2= %6.3f nFoundHits= %2d pT= %7.4f eta= %7.4f phi= %7.4f nfoundmc= %2d pTmc= " 208 "%7.4f etamc= %7.4f phimc= %7.4f nfoundcmssw= %2d pTcmssw= %7.4f etacmssw= %7.4f phicmssw= %7.4f lab= %d\n",
230 <<
" no_mc_assoc=" <<
m_cnt_nomc << std::endl;
240 std::lock_guard<std::mutex> q_lock(q_mutex);
257 event->relabel_bad_seedtracks();
258 event->relabel_cmsswtracks_from_seeds();
265 event->candidateTracks_ =
event->cmsswTracks_;
266 event->fitTracks_ =
event->candidateTracks_;
285 event->fitTracks_ =
event->candidateTracks_;
319 std::map<int, int> labelNHitsMap;
320 std::map<int, int> labelAlgoMap;
321 std::map<int, std::vector<int>> labelSeedHitsMap;
322 for (
const auto &seedtrack :
event->seedTracks_) {
323 for (
int ihit = 0; ihit < seedtrack.nTotalHits(); ihit++) {
324 const auto lyr = seedtrack.getHitLyr(ihit);
325 const auto idx = seedtrack.getHitIdx(ihit);
327 if (lyr < 0 ||
idx < 0)
329 seedHitIDMap[lyr][
idx].push_back(seedtrack.label());
330 labelSeedHitsMap[seedtrack.label()].push_back(lyr);
332 labelNHitsMap[seedtrack.label()] = seedtrack.nTotalHits();
333 labelAlgoMap[seedtrack.label()] = seedtrack.algoint();
337 unsigned int count = 0;
338 for (
auto &simtrack :
event->simTracks_) {
339 if (simtrack.isNotFindable())
342 for (
int ihit = 0; ihit < simtrack.nTotalHits(); ihit++) {
343 const auto lyr = simtrack.getHitLyr(ihit);
344 const auto idx = simtrack.getHitIdx(ihit);
346 if (lyr < 0 ||
idx < 0)
349 if (!seedHitIDMap.count(lyr))
351 if (!seedHitIDMap.at(lyr).count(
idx))
354 for (
const auto label : seedHitIDMap.at(lyr).at(
idx)) {
355 const auto &seedLayers = labelSeedHitsMap[
label];
356 if (
std::find(seedLayers.begin(), seedLayers.end(), lyr) != seedLayers.end())
357 seedIDMap[
label].emplace(lyr);
362 bool isSimSeed =
false;
363 for (
const auto &seedIDpair : seedIDMap) {
364 if ((
int)seedIDpair.second.size() == labelNHitsMap[seedIDpair.first]) {
367 simtrack.setAlgoint(labelAlgoMap[seedIDpair.first]);
369 event->simTracksExtra_[
count].addAlgo(labelAlgoMap[seedIDpair.first]);
377 simtrack.setNotFindable();
379 simtrack.setNotFindable();
383 simtrack.setNotFindable();
396 const int nlyr =
track.nUniqueLayers();
398 track.setNotFindable();
403 for (
size_t i = 0;
i <
tracks.size();
i++) {
407 event->validation_.alignTracks(
tracks, extras,
false);
float getScoreCand(const track_score_func &score_func, const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
void prep_reftracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
std::vector< TrackExtra > TrackExtraVec
std::map< int, std::unordered_set< int > > TrkIDLaySetMap
void root_val(Event *event)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void quality_process(Event *event, Track &tkcand, const int itrack, std::map< int, int > &cmsswLabelToPos)
void prep_simtracks(Event *event)
void prep_tracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
void loadHitsAndBeamSpot(Event &ev, EventOfHits &eoh)
void track_print(Event *event, const Track &t, const char *pref)
void score_tracks(TrackVec &tracks)
void prep_recotracks(Event *event)
void setBeamSpot(const BeamSpot &bs)
Abs< T >::type abs(const T &t)
static Quality s_quality_sum
static std::mutex printmutex
static void add_to_quality_sum(const Quality &q)
std::vector< Track > TrackVec
static track_score_func get_track_scorer(const std::string &name)
void print(std::string_view label, const MeasurementState &s)
void suckInHits(int layer, const HitVec &hitv)
void dump_simtracks(Event *event)
void root_val_dumb_cmssw(Event *event)
void quality_val(Event *event)
void handle_duplicates(Event *)
std::map< int, std::map< int, std::vector< int > > > LayIdxIDVecMapMap
void prep_cmsswtracks(Event *event)