18 simTICLCandidatesToken_(simTICLCandidatesToken),
19 recoTracksToken_(recoTracksToken),
20 trackstersToken_(trackstersToken),
21 associatorMapRtSToken_(associatorMapRtSToken),
22 associatorMapStRToken_(associatorMapStRToken),
23 associatorMapRtSPUToken_(associatorMapRtSPUToken),
33 ibook.
book1D(
"N of tracksters in candidate",
"N of tracksters in candidate", 100, 0, 99);
35 ibook.
book1D(
"Candidates raw energy",
"Candidates raw energy;E (GeV)", 250, 0, 250);
37 ibook.
book1D(
"Candidates regressed energy",
"Candidates regressed energy;E (GeV)", 250, 0, 250);
38 histograms.h_candidate_pT = ibook.
book1D(
"Candidates pT",
"Candidates pT;p_{T}", 250, 0, 250);
39 histograms.h_candidate_charge = ibook.
book1D(
"Candidates charge",
"Candidates charge;Charge", 3, -1.5, 1.5);
40 histograms.h_candidate_pdgId = ibook.
book1D(
"Candidates PDG Id",
"Candidates PDG ID", 100, -220, 220);
41 histograms.h_candidate_partType = ibook.
book1D(
"Candidates type",
"Candidates type", 9, -0.5, 8.5);
44 const std::vector<std::string>
neutrals{
"photons",
"neutral_pions",
"neutral_hadrons"};
45 for (
long unsigned int i = 0;
i <
neutrals.size();
i++) {
49 "N of tracksters in candidate for " +
neutrals[
i],
54 neutrals[
i] +
"candidates regressed energy",
neutrals[
i] +
" candidates regressed energy;E (GeV)", 250, 0, 250));
59 histograms.h_neut_candidate_partType.push_back(
62 histograms.h_den_fake_neut_energy_candidate.push_back(
65 "num_fake_pid_cand_vs_energy_" +
neutrals[
i],
neutrals[
i] +
" PID fake vs energy;E (GeV)", 50, 0, 250));
66 histograms.h_num_fake_neut_energy_candidate_energy.push_back(
68 neutrals[
i] +
" PID and energy fake vs energy;E (GeV)",
72 histograms.h_den_fake_neut_pt_candidate.push_back(
75 "num_fake_pid_cand_vs_pt_" +
neutrals[
i],
neutrals[
i] +
" PID fake vs pT;p_{T} (GeV)", 50, 0, 250));
76 histograms.h_num_fake_neut_pt_candidate_energy.push_back(
78 neutrals[
i] +
" PID and energy fake vs pT;p_{T} (GeV)",
82 histograms.h_den_fake_neut_eta_candidate.push_back(
85 "num_fake_pid_cand_vs_eta_" +
neutrals[
i],
neutrals[
i] +
" PID fake vs eta;#eta (GeV)", 50, -3, 3));
86 histograms.h_num_fake_neut_eta_candidate_energy.push_back(
88 neutrals[
i] +
" PID and energy fake vs eta;#eta (GeV)",
93 "den_fake_cand_vs_phi_" +
neutrals[
i],
neutrals[
i] +
" candidates phi;#phi (GeV)", 50, -3.14159, 3.14159));
95 "num_fake_pid_cand_vs_phi_" +
neutrals[
i],
neutrals[
i] +
" PID fake vs phi;#phi (GeV)", 50, -3.14159, 3.14159));
96 histograms.h_num_fake_neut_phi_candidate_energy.push_back(
98 neutrals[
i] +
" PID and energy fake vs phi;#phi (GeV)",
103 histograms.h_den_neut_energy_candidate.push_back(
105 histograms.h_num_neut_energy_candidate_pdgId.push_back(
107 neutrals[
i] +
" track and PID efficiency vs energy;E (GeV)",
111 histograms.h_num_neut_energy_candidate_energy.push_back(
113 neutrals[
i] +
" track, PID and energy efficiency vs energy;E (GeV)",
120 "num_pid_cand_vs_pt_" +
neutrals[
i],
neutrals[
i] +
" track and PID efficiency vs pT;p_{T} (GeV)", 50, 0, 250));
121 histograms.h_num_neut_pt_candidate_energy.push_back(
123 neutrals[
i] +
" track, PID and energy efficiency vs pT;p_{T} (GeV)",
127 histograms.h_den_neut_eta_candidate.push_back(
130 "num_pid_cand_vs_eta_" +
neutrals[
i],
neutrals[
i] +
" track and PID efficiency vs eta;#eta (GeV)", 50, -3, 3));
131 histograms.h_num_neut_eta_candidate_energy.push_back(
133 neutrals[
i] +
" track, PID and energy efficiency vs eta;#eta (GeV)",
138 "den_cand_vs_phi_" +
neutrals[
i],
neutrals[
i] +
" simCandidates phi;#phi (GeV)", 50, -3.14159, 3.14159));
139 histograms.h_num_neut_phi_candidate_pdgId.push_back(
141 neutrals[
i] +
" track and PID efficiency vs phi;#phi (GeV)",
145 histograms.h_num_neut_phi_candidate_energy.push_back(
147 neutrals[
i] +
" track, PID and energy efficiency vs phi;#phi (GeV)",
153 const std::vector<std::string>
charged{
"electrons",
"muons",
"charged_hadrons"};
154 for (
long unsigned int i = 0;
i <
charged.size();
i++) {
158 "N of tracksters in candidate for " +
charged[
i],
"N of tracksters in candidate for " +
charged[
i], 100, 0, 99));
160 charged[
i] +
"candidates regressed energy",
charged[
i] +
" candidates regressed energy;E (GeV)", 250, 0, 250));
165 histograms.h_chg_candidate_partType.push_back(
168 histograms.h_den_fake_chg_energy_candidate.push_back(
169 ibook.
book1D(
"den_fake_cand_vs_energy_" +
charged[
i],
charged[
i] +
" candidates energy;E (GeV)", 50, 0, 250));
171 "num_fake_track_cand_vs_energy_" +
charged[
i],
charged[
i] +
" track fake vs energy;E (GeV)", 50, 0, 250));
173 "num_fake_pid_cand_vs_energy_" +
charged[
i],
charged[
i] +
" track and PID fake vs energy;E (GeV)", 50, 0, 250));
174 histograms.h_num_fake_chg_energy_candidate_energy.push_back(
176 charged[
i] +
" track, PID and energy fake vs energy;E (GeV)",
180 histograms.h_den_fake_chg_pt_candidate.push_back(
181 ibook.
book1D(
"den_fake_cand_vs_pt_" +
charged[
i],
charged[
i] +
" candidates pT;p_{T} (GeV)", 50, 0, 250));
183 "num_fake_track_cand_vs_pt_" +
charged[
i],
charged[
i] +
" track fake vs pT;p_{T} (GeV)", 50, 0, 250));
185 "num_fake_pid_cand_vs_pt_" +
charged[
i],
charged[
i] +
" track and PID fake vs pT;p_{T} (GeV)", 50, 0, 250));
186 histograms.h_num_fake_chg_pt_candidate_energy.push_back(
188 charged[
i] +
" track, PID and energy fake vs pT;p_{T} (GeV)",
192 histograms.h_den_fake_chg_eta_candidate.push_back(
193 ibook.
book1D(
"den_fake_cand_vs_eta_" +
charged[
i],
charged[
i] +
" candidates eta;#eta (GeV)", 50, -3, 3));
195 "num_fake_track_cand_vs_eta_" +
charged[
i],
charged[
i] +
" track fake vs eta;#eta (GeV)", 50, -3, 3));
197 "num_fake_pid_cand_vs_eta_" +
charged[
i],
charged[
i] +
" track and PID fake vs eta;#eta (GeV)", 50, -3, 3));
198 histograms.h_num_fake_chg_eta_candidate_energy.push_back(
200 charged[
i] +
" track, PID and energy fake vs eta;#eta (GeV)",
205 "den_fake_cand_vs_phi_" +
charged[
i],
charged[
i] +
" candidates phi;#phi (GeV)", 50, -3.14159, 3.14159));
207 charged[
i] +
" track fake vs phi;#phi (GeV)",
211 histograms.h_num_fake_chg_phi_candidate_pdgId.push_back(
213 charged[
i] +
" track and PID fake vs phi;#phi (GeV)",
217 histograms.h_num_fake_chg_phi_candidate_energy.push_back(
219 charged[
i] +
" track, PID and energy fake vs phi;#phi (GeV)",
224 histograms.h_den_chg_energy_candidate.push_back(
225 ibook.
book1D(
"den_cand_vs_energy_" +
charged[
i],
charged[
i] +
" simCandidates energy;E (GeV)", 50, 0, 250));
227 "num_track_cand_vs_energy_" +
charged[
i],
charged[
i] +
" track efficiency vs energy;E (GeV)", 50, 0, 250));
229 "num_pid_cand_vs_energy_" +
charged[
i],
charged[
i] +
" track and PID efficiency vs energy;E (GeV)", 50, 0, 250));
230 histograms.h_num_chg_energy_candidate_energy.push_back(
232 charged[
i] +
" track, PID and energy efficiency vs energy;E (GeV)",
239 "num_track_cand_vs_pt_" +
charged[
i],
charged[
i] +
" track efficiency vs pT;p_{T} (GeV)", 50, 0, 250));
241 "num_pid_cand_vs_pt_" +
charged[
i],
charged[
i] +
" track and PID efficiency vs pT;p_{T} (GeV)", 50, 0, 250));
242 histograms.h_num_chg_pt_candidate_energy.push_back(
244 charged[
i] +
" track, PID and energy efficiency vs pT;p_{T} (GeV)",
251 "num_track_cand_vs_eta_" +
charged[
i],
charged[
i] +
" track efficiency vs eta;#eta (GeV)", 50, -3, 3));
253 "num_pid_cand_vs_eta_" +
charged[
i],
charged[
i] +
" track and PID efficiency vs eta;#eta (GeV)", 50, -3, 3));
254 histograms.h_num_chg_eta_candidate_energy.push_back(
256 charged[
i] +
" track, PID and energy efficiency vs eta;#eta (GeV)",
261 "den_cand_vs_phi_" +
charged[
i],
charged[
i] +
" simCandidates phi;#phi (GeV)", 50, -3.14159, 3.14159));
263 charged[
i] +
" track efficiency vs phi;#phi (GeV)",
267 histograms.h_num_chg_phi_candidate_pdgId.push_back(
269 charged[
i] +
" track and PID efficiency vs phi;#phi (GeV)",
273 histograms.h_num_chg_phi_candidate_energy.push_back(
275 charged[
i] +
" track, PID and energy efficiency vs phi;#phi (GeV)",
289 auto simTICLCandidates = *simTICLCandidates_h;
297 auto trackstersMerged = *Tracksters_h;
301 auto const& mergeTsRecoToSimMap = *mergeTsRecoToSim_h;
305 auto const& mergeTsSimToRecoMap = *mergeTsSimToReco_h;
309 auto const& mergeTsRecoToSimPUMap = *mergeTsRecoToSimPU_h;
312 for (
const auto&
cand : TICLCandidates) {
313 histograms.h_tracksters_in_candidate->Fill(
cand.tracksters().size());
319 const auto& arr =
cand.idProbabilities();
320 histograms.h_candidate_partType->Fill(std::max_element(arr.begin(), arr.end()) - arr.begin());
323 std::vector<int> chargedCandidates;
324 std::vector<int> neutralCandidates;
325 chargedCandidates.reserve(simTICLCandidates.size());
326 neutralCandidates.reserve(simTICLCandidates.size());
328 for (
size_t i = 0;
i < simTICLCandidates.size(); ++
i) {
329 const auto& simCand = simTICLCandidates[
i];
334 chargedCandidates.emplace_back(
i);
338 neutralCandidates.emplace_back(
i);
342 chargedCandidates.shrink_to_fit();
343 neutralCandidates.shrink_to_fit();
345 for (
const auto i : chargedCandidates) {
346 const auto& simCand = simTICLCandidates[
i];
352 int32_t simCandTrackIdx = -1;
353 if (simCand.trackPtr().get() !=
nullptr)
359 if (simCand.trackPtr().get()->pt() < 1
or simCand.trackPtr().get()->missingOuterHits() > 5
or 364 histograms.h_den_chg_energy_candidate[
index]->Fill(simCand.rawEnergy());
369 int32_t cand_idx = -1;
371 const auto ts_iter = mergeTsSimToRecoMap.find(stsRef);
372 float shared_energy = 0.;
374 if (ts_iter != mergeTsSimToRecoMap.end()) {
375 const auto& tsAssoc = (ts_iter->val);
376 std::vector<uint32_t> MergeTracksters_simToReco;
377 std::vector<float> MergeTracksters_simToReco_score;
378 std::vector<float> MergeTracksters_simToReco_sharedE;
379 MergeTracksters_simToReco.reserve(tsAssoc.size());
380 MergeTracksters_simToReco_score.reserve(tsAssoc.size());
381 MergeTracksters_simToReco_sharedE.reserve(tsAssoc.size());
382 for (
auto& ts : tsAssoc) {
384 MergeTracksters_simToReco.push_back(ts_id);
385 MergeTracksters_simToReco_score.push_back(ts.second.second);
386 MergeTracksters_simToReco_sharedE.push_back(ts.second.first);
388 auto min_idx = std::min_element(MergeTracksters_simToReco_score.begin(), MergeTracksters_simToReco_score.end());
390 cand_idx = MergeTracksters_simToReco[min_idx - MergeTracksters_simToReco_score.begin()];
391 shared_energy = MergeTracksters_simToReco_sharedE[min_idx - MergeTracksters_simToReco_score.begin()];
399 auto& recoCand = TICLCandidates[cand_idx];
403 auto cand_it = std::find_if(TICLCandidates.begin(), TICLCandidates.end(), [tsPtr](
TICLCandidate const&
cand) {
404 if (!
cand.tracksters().empty())
405 return cand.tracksters()[0] == tsPtr;
409 if (cand_it != TICLCandidates.end())
415 if (recoCand.trackPtr().get() !=
nullptr) {
417 if (simCandTrackIdx == candTrackIdx) {
419 histograms.h_num_chg_energy_candidate_track[
index]->Fill(simCand.rawEnergy());
431 if (simCand.pdgId() == recoCand.pdgId()) {
433 histograms.h_num_chg_energy_candidate_pdgId[
index]->Fill(simCand.rawEnergy());
439 if (shared_energy / simCand.rawEnergy() > 0.5) {
441 histograms.h_num_chg_energy_candidate_energy[
index]->Fill(simCand.rawEnergy());
449 for (
const auto i : neutralCandidates) {
450 const auto& simCand = simTICLCandidates[
i];
456 histograms.h_den_neut_energy_candidate[
index]->Fill(simCand.rawEnergy());
461 int32_t cand_idx = -1;
463 const auto ts_iter = mergeTsSimToRecoMap.find(stsRef);
464 float shared_energy = 0.;
466 if (ts_iter != mergeTsSimToRecoMap.end()) {
467 const auto& tsAssoc = (ts_iter->val);
468 std::vector<uint32_t> MergeTracksters_simToReco;
469 std::vector<float> MergeTracksters_simToReco_score;
470 std::vector<float> MergeTracksters_simToReco_sharedE;
471 MergeTracksters_simToReco.reserve(tsAssoc.size());
472 MergeTracksters_simToReco_score.reserve(tsAssoc.size());
473 MergeTracksters_simToReco_sharedE.reserve(tsAssoc.size());
474 for (
auto& ts : tsAssoc) {
476 MergeTracksters_simToReco.push_back(ts_id);
477 MergeTracksters_simToReco_score.push_back(ts.second.second);
478 MergeTracksters_simToReco_sharedE.push_back(ts.second.first);
480 auto min_idx = std::min_element(MergeTracksters_simToReco_score.begin(), MergeTracksters_simToReco_score.end());
482 cand_idx = MergeTracksters_simToReco[min_idx - MergeTracksters_simToReco_score.begin()];
483 shared_energy = MergeTracksters_simToReco_sharedE[min_idx - MergeTracksters_simToReco_score.begin()];
491 auto& recoCand = TICLCandidates[cand_idx];
495 auto cand_it = std::find_if(TICLCandidates.begin(), TICLCandidates.end(), [tsPtr](
TICLCandidate const&
cand) {
496 if (!
cand.tracksters().empty())
497 return cand.tracksters()[0] == tsPtr;
501 if (cand_it != TICLCandidates.end())
507 if (recoCand.trackPtr().get() !=
nullptr)
511 if (simCand.pdgId() == recoCand.pdgId()) {
513 histograms.h_num_neut_energy_candidate_pdgId[
index]->Fill(simCand.rawEnergy());
519 if (shared_energy / simCand.rawEnergy() > 0.5) {
521 histograms.h_num_neut_energy_candidate_energy[
index]->Fill(simCand.rawEnergy());
523 histograms.h_num_neut_eta_candidate_energy[
index]->Fill(simCand.eta());
524 histograms.h_num_neut_phi_candidate_energy[
index]->Fill(simCand.phi());
530 chargedCandidates.clear();
531 neutralCandidates.clear();
532 chargedCandidates.reserve(TICLCandidates.size());
533 neutralCandidates.reserve(TICLCandidates.size());
535 auto isCharged = [](
int pdgId) {
540 for (
size_t i = 0;
i < TICLCandidates.size(); ++
i) {
541 const auto&
cand = TICLCandidates[
i];
544 chargedCandidates.emplace_back(
i);
546 neutralCandidates.emplace_back(
i);
551 chargedCandidates.shrink_to_fit();
552 neutralCandidates.shrink_to_fit();
555 for (
const auto i : chargedCandidates) {
556 const auto&
cand = TICLCandidates[
i];
562 int32_t candTrackIdx = -1;
565 if (
cand.tracksters().empty())
575 auto const sts_iterPU = mergeTsRecoToSimPUMap.find(tsRef);
576 if (sts_iterPU != mergeTsRecoToSimPUMap.end()) {
577 const auto& stsPUAssociated = sts_iterPU->val;
578 if (stsPUAssociated[0].
second.first / (*Tracksters_h)[mergeTs_id].raw_energy() > 0.95)
592 const auto& arr =
cand.idProbabilities();
593 histograms.h_chg_candidate_partType[
index]->Fill(std::max_element(arr.begin(), arr.end()) - arr.begin());
595 int32_t simCand_idx = -1;
596 const auto sts_iter = mergeTsRecoToSimMap.find(tsRef);
597 float shared_energy = 0.;
599 if (sts_iter != mergeTsRecoToSimMap.end()) {
600 const auto& stsAssoc = (sts_iter->val);
601 std::vector<uint32_t> MergeTracksters_recoToSim;
602 std::vector<float> MergeTracksters_recoToSim_score;
603 std::vector<float> MergeTracksters_recoToSim_sharedE;
604 MergeTracksters_recoToSim.reserve(stsAssoc.size());
605 MergeTracksters_recoToSim_score.reserve(stsAssoc.size());
606 MergeTracksters_recoToSim_sharedE.reserve(stsAssoc.size());
607 for (
auto& sts : stsAssoc) {
609 MergeTracksters_recoToSim.push_back(sts_id);
610 MergeTracksters_recoToSim_score.push_back(sts.second.second);
611 MergeTracksters_recoToSim_sharedE.push_back(sts.second.first);
613 auto min_idx = std::min_element(MergeTracksters_recoToSim_score.begin(), MergeTracksters_recoToSim_score.end());
615 simCand_idx = MergeTracksters_recoToSim[min_idx - MergeTracksters_recoToSim_score.begin()];
616 shared_energy = MergeTracksters_recoToSim_sharedE[min_idx - MergeTracksters_recoToSim_score.begin()];
620 if (simCand_idx == -1)
623 const auto& simCand = simTICLCandidates[simCand_idx];
624 if (simCand.trackPtr().get() !=
nullptr) {
625 const auto simCandTrackIdx = simCand.trackPtr().get() -
edm::Ptr<reco::Track>(recoTracks_h, 0).
get();
626 if (simCandTrackIdx != candTrackIdx) {
644 if (simCand.pdgId() !=
cand.pdgId()) {
654 if (shared_energy / simCand.rawEnergy() < 0.5) {
663 for (
const auto i : neutralCandidates) {
664 const auto&
cand = TICLCandidates[
i];
671 if (
cand.tracksters().empty())
681 auto const sts_iterPU = mergeTsRecoToSimPUMap.find(tsRef);
682 if (sts_iterPU != mergeTsRecoToSimPUMap.end()) {
683 const auto& stsPUAssociated = sts_iterPU->val;
684 if (stsPUAssociated[0].
second.first / (*Tracksters_h)[mergeTs_id].raw_energy() > 0.95)
698 const auto& arr =
cand.idProbabilities();
699 histograms.h_neut_candidate_partType[
index]->Fill(std::max_element(arr.begin(), arr.end()) - arr.begin());
701 int32_t simCand_idx = -1;
702 const auto sts_iter = mergeTsRecoToSimMap.find(tsRef);
703 float shared_energy = 0.;
705 if (sts_iter != mergeTsRecoToSimMap.end()) {
706 const auto& stsAssoc = (sts_iter->val);
707 std::vector<uint32_t> MergeTracksters_recoToSim;
708 std::vector<float> MergeTracksters_recoToSim_score;
709 std::vector<float> MergeTracksters_recoToSim_sharedE;
710 MergeTracksters_recoToSim.reserve(stsAssoc.size());
711 MergeTracksters_recoToSim_score.reserve(stsAssoc.size());
712 MergeTracksters_recoToSim_sharedE.reserve(stsAssoc.size());
713 for (
auto& sts : stsAssoc) {
715 MergeTracksters_recoToSim.push_back(sts_id);
716 MergeTracksters_recoToSim_score.push_back(sts.second.second);
717 MergeTracksters_recoToSim_sharedE.push_back(sts.second.first);
719 auto min_idx = std::min_element(MergeTracksters_recoToSim_score.begin(), MergeTracksters_recoToSim_score.end());
721 simCand_idx = MergeTracksters_recoToSim[min_idx - MergeTracksters_recoToSim_score.begin()];
722 shared_energy = MergeTracksters_recoToSim_sharedE[min_idx - MergeTracksters_recoToSim_score.begin()];
726 if (simCand_idx == -1)
729 const auto& simCand = simTICLCandidates[simCand_idx];
732 if (simCand.pdgId() !=
cand.pdgId()) {
742 if (shared_energy / simCand.rawEnergy() < 0.5) {
edm::EDGetTokenT< std::vector< TICLCandidate > > simTICLCandidatesToken_
virtual void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< std::vector< reco::Track > > recoTracksToken_
edm::EDGetTokenT< std::vector< TICLCandidate > > TICLCandidatesToken_
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< ticl::RecoToSimCollectionSimTracksters > associatorMapRtSPUToken_
edm::EDGetTokenT< ticl::RecoToSimCollectionSimTracksters > associatorMapRtSToken_
Trackster::ParticleType tracksterParticleTypeFromPdgId(int pdgId, int charge)
~TICLCandidateValidator()
edm::EDGetTokenT< ticl::SimToRecoCollectionSimTracksters > associatorMapStRToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Abs< T >::type abs(const T &t)
T const * get() const
Returns C++ pointer to the item.
edm::EDGetTokenT< std::vector< ticl::Trackster > > trackstersToken_
void bookCandidatesHistos(DQMStore::IBooker &ibook, Histograms &histograms, std::string baseDir) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void fillCandidateHistos(const edm::Event &event, const Histograms &histograms, edm::Handle< ticl::TracksterCollection > simTrackstersCP_h) const