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_
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)
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_