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) {
57 std::vector<Track> &simtracks =
event->simTracks_;
59 for (
int itrack = 0; itrack < (
int)simtracks.size(); ++itrack) {
67 dprint(
"MX - simtrack with nHits=" <<
track.nFoundHits() <<
" chi2=" <<
track.chi2() <<
" pT=" <<
track.pT()
68 <<
" phi=" <<
track.momPhi() <<
" eta=" <<
track.momEta());
71 for (
int itrack = 0; itrack < (
int)simtracks.size(); ++itrack) {
72 for (
int ihit = 0; ihit < simtracks[itrack].nFoundHits(); ++ihit) {
73 dprint(
"track #" << itrack <<
" hit #" << ihit
74 <<
" hit pos=" << simtracks[itrack].hitsVector(
event->layerHits_)[ihit].position()
75 <<
" phi=" << simtracks[itrack].hitsVector(
event->layerHits_)[ihit].phi());
81 printf(
"%s with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d\nState:\n",
92 for (
int ih = 0; ih <
t.nTotalHits(); ++ih) {
93 int lyr =
t.getHitLyr(ih);
94 int idx =
t.getHitIdx(ih);
96 const Hit &
hit =
event->layerHits_[lyr][
idx];
97 printf(
" hit %2d lyr=%2d idx=%4d pos r=%7.3f z=% 8.3f mc_hit=%4d mc_trk=%4d\n",
104 hit.mcTrackID(
event->simHitsInfo_));
106 printf(
" hit %2d idx=%i\n", ih,
t.getHitIdx(ih));
117 std::map<int, int> cmsswLabelToPos;
119 for (
size_t itrack = 0; itrack <
event->cmsswTracks_.size(); itrack++) {
120 cmsswLabelToPos[
event->cmsswTracks_[itrack].label()] = itrack;
124 for (
size_t itrack = 0; itrack <
event->candidateTracks_.size(); itrack++) {
144 const auto &
seed =
event->seedTracks_[itrack];
154 const float pT = tkcand.
pT();
155 float pTmc = 0.f, etamc = 0.f, phimc = 0.f;
159 if (mctrk < 0 || static_cast<size_t>(mctrk) >=
event->simTracks_.size()) {
161 dprint(
"XX bad track idx " << mctrk <<
", orig label was " <<
label);
163 auto &simtrack =
event->simTracks_[mctrk];
164 pTmc = simtrack.pT();
165 etamc = simtrack.momEta();
166 phimc = simtrack.momPhi();
169 nfoundmc = simtrack.nUniqueLayers();
172 if (pTr > 0.9 && pTr < 1.1)
174 if (pTr > 0.8 && pTr < 1.2)
179 if (pTr > 0.9 && pTr < 1.1)
181 if (pTr > 0.8 && pTr < 1.2)
190 #ifdef SELECT_SEED_LABEL 191 if (
label == SELECT_SEED_LABEL)
192 track_print(tkcand,
"MkBuilder::quality_process SELECT_SEED_LABEL:");
195 float pTcmssw = 0.f, etacmssw = 0.f, phicmssw = 0.f;
196 int nfoundcmssw = -1;
198 if (cmsswLabelToPos.count(
label)) {
199 auto &cmsswtrack =
event->cmsswTracks_[cmsswLabelToPos[
label]];
200 pTcmssw = cmsswtrack.pT();
201 etacmssw = cmsswtrack.momEta();
202 phicmssw = cmsswtrack.swimPhiToR(tkcand.
x(), tkcand.
y());
203 nfoundcmssw = cmsswtrack.nUniqueLayers();
210 "MX - found track with chi2= %6.3f nFoundHits= %2d pT= %7.4f eta= %7.4f phi= %7.4f nfoundmc= %2d pTmc= " 211 "%7.4f etamc= %7.4f phimc= %7.4f nfoundcmssw= %2d pTcmssw= %7.4f etacmssw= %7.4f phicmssw= %7.4f lab= %d\n",
233 <<
" no_mc_assoc=" <<
m_cnt_nomc << std::endl;
245 event->relabel_bad_seedtracks();
246 event->relabel_cmsswtracks_from_seeds();
253 event->candidateTracks_ =
event->cmsswTracks_;
254 event->fitTracks_ =
event->candidateTracks_;
273 event->fitTracks_ =
event->candidateTracks_;
307 std::map<int, int> labelNHitsMap;
308 std::map<int, int> labelAlgoMap;
309 std::map<int, std::vector<int>> labelSeedHitsMap;
310 for (
const auto &seedtrack :
event->seedTracks_) {
311 for (
int ihit = 0; ihit < seedtrack.nTotalHits(); ihit++) {
312 const auto lyr = seedtrack.getHitLyr(ihit);
313 const auto idx = seedtrack.getHitIdx(ihit);
315 if (lyr < 0 ||
idx < 0)
317 seedHitIDMap[lyr][
idx].push_back(seedtrack.label());
318 labelSeedHitsMap[seedtrack.label()].push_back(lyr);
320 labelNHitsMap[seedtrack.label()] = seedtrack.nTotalHits();
321 labelAlgoMap[seedtrack.label()] = seedtrack.algoint();
325 unsigned int count = 0;
326 for (
auto &simtrack :
event->simTracks_) {
327 if (simtrack.isNotFindable())
330 for (
int ihit = 0; ihit < simtrack.nTotalHits(); ihit++) {
331 const auto lyr = simtrack.getHitLyr(ihit);
332 const auto idx = simtrack.getHitIdx(ihit);
334 if (lyr < 0 ||
idx < 0)
337 if (!seedHitIDMap.count(lyr))
339 if (!seedHitIDMap.at(lyr).count(
idx))
342 for (
const auto label : seedHitIDMap.at(lyr).at(
idx)) {
343 const auto &seedLayers = labelSeedHitsMap[
label];
344 if (
std::find(seedLayers.begin(), seedLayers.end(), lyr) != seedLayers.end())
345 seedIDMap[
label].emplace(lyr);
350 bool isSimSeed =
false;
351 for (
const auto &seedIDpair : seedIDMap) {
352 if ((
int)seedIDpair.second.size() == labelNHitsMap[seedIDpair.first]) {
355 simtrack.setAlgoint(labelAlgoMap[seedIDpair.first]);
357 event->simTracksExtra_[
count].addAlgo(labelAlgoMap[seedIDpair.first]);
365 simtrack.setNotFindable();
367 simtrack.setNotFindable();
371 simtrack.setNotFindable();
384 const int nlyr =
track.nUniqueLayers();
386 track.setNotFindable();
391 for (
size_t i = 0;
i <
tracks.size();
i++) {
395 event->validation_.alignTracks(
tracks, extras,
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)
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 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)