9 #include "oneapi/tbb/parallel_for.h" 24 tbb::parallel_for(tbb::blocked_range<int>(0,
ev.layerHits_.size()), [&](
const tbb::blocked_range<int> &
layers) {
25 for (
int ilay =
layers.begin(); ilay <
layers.end(); ++ilay) {
34 if (Config::removeDuplicates) {
55 std::vector<Track> &simtracks =
event->simTracks_;
57 for (
int itrack = 0; itrack < (
int)simtracks.size(); ++itrack) {
65 dprint(
"MX - simtrack with nHits=" <<
track.nFoundHits() <<
" chi2=" <<
track.chi2() <<
" pT=" <<
track.pT()
66 <<
" phi=" <<
track.momPhi() <<
" eta=" <<
track.momEta());
69 for (
int itrack = 0; itrack < (
int)simtracks.size(); ++itrack) {
70 for (
int ihit = 0; ihit < simtracks[itrack].nFoundHits(); ++ihit) {
71 dprint(
"track #" << itrack <<
" hit #" << ihit
72 <<
" hit pos=" << simtracks[itrack].hitsVector(
event->layerHits_)[ihit].position()
73 <<
" phi=" << simtracks[itrack].hitsVector(
event->layerHits_)[ihit].phi());
79 printf(
"%s with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d\nState:\n",
90 for (
int ih = 0; ih <
t.nTotalHits(); ++ih) {
91 int lyr =
t.getHitLyr(ih);
92 int idx =
t.getHitIdx(ih);
94 const Hit &
hit =
event->layerHits_[lyr][
idx];
95 printf(
" hit %2d lyr=%2d idx=%4d pos r=%7.3f z=% 8.3f mc_hit=%4d mc_trk=%4d\n",
102 hit.mcTrackID(
event->simHitsInfo_));
104 printf(
" hit %2d idx=%i\n", ih,
t.getHitIdx(ih));
115 std::map<int, int> cmsswLabelToPos;
117 for (
size_t itrack = 0; itrack <
event->cmsswTracks_.size(); itrack++) {
118 cmsswLabelToPos[
event->cmsswTracks_[itrack].label()] = itrack;
122 for (
size_t itrack = 0; itrack <
event->candidateTracks_.size(); itrack++) {
142 const auto &
seed =
event->seedTracks_[itrack];
152 const float pT = tkcand.
pT();
153 float pTmc = 0.f, etamc = 0.f, phimc = 0.f;
157 if (mctrk < 0 || static_cast<size_t>(mctrk) >=
event->simTracks_.size()) {
159 dprint(
"XX bad track idx " << mctrk <<
", orig label was " <<
label);
161 auto &simtrack =
event->simTracks_[mctrk];
162 pTmc = simtrack.pT();
163 etamc = simtrack.momEta();
164 phimc = simtrack.momPhi();
167 nfoundmc = simtrack.nUniqueLayers();
170 if (pTr > 0.9 && pTr < 1.1)
172 if (pTr > 0.8 && pTr < 1.2)
177 if (pTr > 0.9 && pTr < 1.1)
179 if (pTr > 0.8 && pTr < 1.2)
188 #ifdef SELECT_SEED_LABEL 189 if (
label == SELECT_SEED_LABEL)
190 track_print(tkcand,
"MkBuilder::quality_process SELECT_SEED_LABEL:");
193 float pTcmssw = 0.f, etacmssw = 0.f, phicmssw = 0.f;
194 int nfoundcmssw = -1;
196 if (cmsswLabelToPos.count(
label)) {
197 auto &cmsswtrack =
event->cmsswTracks_[cmsswLabelToPos[
label]];
198 pTcmssw = cmsswtrack.pT();
199 etacmssw = cmsswtrack.momEta();
200 phicmssw = cmsswtrack.swimPhiToR(tkcand.
x(), tkcand.
y());
201 nfoundcmssw = cmsswtrack.nUniqueLayers();
208 "MX - found track with chi2= %6.3f nFoundHits= %2d pT= %7.4f eta= %7.4f phi= %7.4f nfoundmc= %2d pTmc= " 209 "%7.4f etamc= %7.4f phimc= %7.4f nfoundcmssw= %2d pTcmssw= %7.4f etacmssw= %7.4f phicmssw= %7.4f lab= %d\n",
231 <<
" no_mc_assoc=" <<
m_cnt_nomc << std::endl;
243 event->relabel_bad_seedtracks();
244 event->relabel_cmsswtracks_from_seeds();
251 event->candidateTracks_ =
event->cmsswTracks_;
252 event->fitTracks_ =
event->candidateTracks_;
271 event->fitTracks_ =
event->candidateTracks_;
305 std::map<int, int> labelNHitsMap;
306 std::map<int, int> labelAlgoMap;
307 std::map<int, std::vector<int>> labelSeedHitsMap;
308 for (
const auto &seedtrack :
event->seedTracks_) {
309 for (
int ihit = 0; ihit < seedtrack.nTotalHits(); ihit++) {
310 const auto lyr = seedtrack.getHitLyr(ihit);
311 const auto idx = seedtrack.getHitIdx(ihit);
313 if (lyr < 0 ||
idx < 0)
315 seedHitIDMap[lyr][
idx].push_back(seedtrack.label());
316 labelSeedHitsMap[seedtrack.label()].push_back(lyr);
318 labelNHitsMap[seedtrack.label()] = seedtrack.nTotalHits();
319 labelAlgoMap[seedtrack.label()] = seedtrack.algoint();
323 unsigned int count = 0;
324 for (
auto &simtrack :
event->simTracks_) {
325 if (simtrack.isNotFindable())
328 for (
int ihit = 0; ihit < simtrack.nTotalHits(); ihit++) {
329 const auto lyr = simtrack.getHitLyr(ihit);
330 const auto idx = simtrack.getHitIdx(ihit);
332 if (lyr < 0 ||
idx < 0)
335 if (!seedHitIDMap.count(lyr))
337 if (!seedHitIDMap.at(lyr).count(
idx))
340 for (
const auto label : seedHitIDMap.at(lyr).at(
idx)) {
341 const auto &seedLayers = labelSeedHitsMap[
label];
342 if (
std::find(seedLayers.begin(), seedLayers.end(), lyr) != seedLayers.end())
343 seedIDMap[
label].emplace(lyr);
348 bool isSimSeed =
false;
349 for (
const auto &seedIDpair : seedIDMap) {
350 if ((
int)seedIDpair.second.size() == labelNHitsMap[seedIDpair.first]) {
353 simtrack.setAlgoint(labelAlgoMap[seedIDpair.first]);
355 event->simTracksExtra_[
count].addAlgo(labelAlgoMap[seedIDpair.first]);
363 simtrack.setNotFindable();
365 simtrack.setNotFindable();
369 simtrack.setNotFindable();
382 const int nlyr =
track.nUniqueLayers();
384 track.setNotFindable();
389 for (
size_t i = 0;
i <
tracks.size();
i++) {
393 event->validation_.alignTracks(
tracks, extras,
false);
void prep_reftracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
std::vector< TrackExtra > TrackExtraVec
void find_duplicates(TrackVec &tracks)
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)
float getScoreCand(const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
void score_tracks(TrackVec &tracks)
void prep_recotracks(Event *event)
void setBeamSpot(const BeamSpot &bs)
Abs< T >::type abs(const T &t)
static std::mutex printmutex
std::vector< Track > TrackVec
auto const & tracks
cannot be loose
void print(std::string_view label, const MeasurementState &s)
void suckInHits(int layer, const HitVec &hitv)
void dump_simtracks(Event *event)
void handle_duplicates(Event *event)
void root_val_dumb_cmssw(Event *event)
void quality_val(Event *event)
std::map< int, std::map< int, std::vector< int > > > LayIdxIDVecMapMap
void prep_cmsswtracks(Event *event)