10 #include "oneapi/tbb/parallel_for.h" 25 tbb::parallel_for(tbb::blocked_range<int>(0,
ev.layerHits_.size()), [&](
const tbb::blocked_range<int> &
layers) {
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++) {
145 const auto &
seed =
event->seedTracks_[itrack];
155 const float pT = tkcand.
pT();
156 float pTmc = 0.f, etamc = 0.f, phimc = 0.f;
160 if (mctrk < 0 || static_cast<size_t>(mctrk) >=
event->simTracks_.size()) {
162 dprintf(
"XX bad track idx %d, orig label was %d\n", mctrk,
label);
164 auto &simtrack =
event->simTracks_[mctrk];
165 pTmc = simtrack.pT();
166 etamc = simtrack.momEta();
167 phimc = simtrack.momPhi();
170 nfoundmc = simtrack.nUniqueLayers();
173 if (pTr > 0.9 && pTr < 1.1)
175 if (pTr > 0.8 && pTr < 1.2)
180 if (pTr > 0.9 && pTr < 1.1)
182 if (pTr > 0.8 && pTr < 1.2)
191 float pTcmssw = 0.f, etacmssw = 0.f, phicmssw = 0.f;
192 int nfoundcmssw = -1;
194 if (cmsswLabelToPos.count(
label)) {
195 auto &cmsswtrack =
event->cmsswTracks_[cmsswLabelToPos[
label]];
196 pTcmssw = cmsswtrack.pT();
197 etacmssw = cmsswtrack.momEta();
198 phicmssw = cmsswtrack.swimPhiToR(tkcand.
x(), tkcand.
y());
199 nfoundcmssw = cmsswtrack.nUniqueLayers();
206 "MX - found track with chi2= %6.3f nFoundHits= %2d pT= %7.4f eta= %7.4f phi= %7.4f nfoundmc= %2d pTmc= " 207 "%7.4f etamc= %7.4f phimc= %7.4f nfoundcmssw= %2d pTcmssw= %7.4f etacmssw= %7.4f phicmssw= %7.4f lab= %d\n",
229 <<
" no_mc_assoc=" <<
m_cnt_nomc << std::endl;
241 event->relabel_bad_seedtracks();
242 event->relabel_cmsswtracks_from_seeds();
249 event->candidateTracks_ =
event->cmsswTracks_;
250 event->fitTracks_ =
event->candidateTracks_;
269 event->fitTracks_ =
event->candidateTracks_;
303 std::map<int, int> labelNHitsMap;
304 std::map<int, int> labelAlgoMap;
305 std::map<int, std::vector<int>> labelSeedHitsMap;
306 for (
const auto &seedtrack :
event->seedTracks_) {
307 for (
int ihit = 0; ihit < seedtrack.nTotalHits(); ihit++) {
308 const auto lyr = seedtrack.getHitLyr(ihit);
309 const auto idx = seedtrack.getHitIdx(ihit);
311 if (lyr < 0 ||
idx < 0)
313 seedHitIDMap[lyr][
idx].push_back(seedtrack.label());
314 labelSeedHitsMap[seedtrack.label()].push_back(lyr);
316 labelNHitsMap[seedtrack.label()] = seedtrack.nTotalHits();
317 labelAlgoMap[seedtrack.label()] = seedtrack.algoint();
321 unsigned int count = 0;
322 for (
auto &simtrack :
event->simTracks_) {
323 if (simtrack.isNotFindable())
326 for (
int ihit = 0; ihit < simtrack.nTotalHits(); ihit++) {
327 const auto lyr = simtrack.getHitLyr(ihit);
328 const auto idx = simtrack.getHitIdx(ihit);
330 if (lyr < 0 ||
idx < 0)
333 if (!seedHitIDMap.count(lyr))
335 if (!seedHitIDMap.at(lyr).count(
idx))
338 for (
const auto label : seedHitIDMap.at(lyr).at(
idx)) {
339 const auto &seedLayers = labelSeedHitsMap[
label];
340 if (
std::find(seedLayers.begin(), seedLayers.end(), lyr) != seedLayers.end())
341 seedIDMap[
label].emplace(lyr);
346 bool isSimSeed =
false;
347 for (
const auto &seedIDpair : seedIDMap) {
348 if ((
int)seedIDpair.second.size() == labelNHitsMap[seedIDpair.first]) {
351 simtrack.setAlgoint(labelAlgoMap[seedIDpair.first]);
353 event->simTracksExtra_[
count].addAlgo(labelAlgoMap[seedIDpair.first]);
361 simtrack.setNotFindable();
363 simtrack.setNotFindable();
367 simtrack.setNotFindable();
380 const int nlyr =
track.nUniqueLayers();
382 track.setNotFindable();
387 for (
size_t i = 0;
i <
tracks.size();
i++) {
391 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 std::mutex printmutex
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)