613 const auto recotosim = *recotosimCollection;
621 for (std::vector<reco::GenParticle>::const_iterator it_p = genParticlesHandle->begin();
622 it_p != genParticlesHandle->end();
634 std::vector<int> daughters(it_p->daughterRefVector().size(), 0);
635 for (
unsigned j = 0;
j < it_p->daughterRefVector().size(); ++
j) {
636 daughters[
j] =
static_cast<int>(it_p->daughterRefVector().at(
j).key());
643 std::vector<reco::PFCandidate>
pfCandidates = *pfCandidatesHandle;
647 std::vector<reco::PFBlock> pfBlocks = *pfBlocksHandle;
650 const auto& all_elements_distances =
processBlocks(pfBlocks);
651 const auto& all_elements = all_elements_distances.first;
652 const auto& all_distances = all_elements_distances.second;
653 assert(!all_elements.empty());
655 for (
const auto&
d : all_distances) {
664 const auto vec_idx_in_all_elements =
find_element_ref(all_elements, trackref);
667 if (vec_idx_in_all_elements.empty()) {
671 if (recotosim.find(trackref) != recotosim.end()) {
672 const auto& tps = recotosim[trackref];
673 for (
const auto&
tp : tps) {
675 for (
auto idx_in_all_elements : vec_idx_in_all_elements) {
684 int idx_simcluster = 0;
686 for (
unsigned long ncaloparticle = 0; ncaloparticle < caloParticles.
size(); ncaloparticle++) {
687 const auto&
cp = caloParticles.
at(ncaloparticle);
691 for (
const auto& simcluster :
cp.simClusters()) {
693 map<uint64_t, double> detid_energy;
708 for (
const auto& hf : simcluster->hits_and_fractions()) {
715 const float x = pos.x();
716 const float y = pos.y();
717 const float z = pos.z();
718 const float eta = pos.eta();
719 const float phi = pos.phi();
731 detid_energy[
id.rawId()] += hf.second;
735 int simcluster_to_trackingparticle = -1;
736 for (
const auto& simtrack : simcluster->g4Tracks()) {
737 simtrack_x_.push_back(simtrack.trackerSurfacePosition().x());
738 simtrack_y_.push_back(simtrack.trackerSurfacePosition().y());
739 simtrack_z_.push_back(simtrack.trackerSurfacePosition().z());
743 for (
unsigned int itp = 0; itp < trackingParticles.
size(); itp++) {
744 const auto& simtrack2 = trackingParticles.
at(itp).g4Tracks().at(0);
746 if (simtrack.eventId() == simtrack2.eventId() && simtrack.trackId() == simtrack2.trackId()) {
747 simcluster_to_trackingparticle = itp;
764 for (
unsigned int ielem = 0; ielem < all_elements.size(); ielem++) {
765 const auto& elem = all_elements.at(ielem);
766 const auto& orig = elem.orig;
771 float sigmadeltap = 0.0;
778 float corr_energy = 0.0;
779 float trajpoint = 0.0;
780 float eta_ecal = 0.0;
781 float phi_ecal = 0.0;
782 float eta_hcal = 0.0;
783 float phi_hcal = 0.0;
787 float muon_dt_hits = 0.0;
788 float muon_csc_hits = 0.0;
789 float muon_type = 0.0;
790 float cluster_flags = 0.0;
791 float gsf_electronseed_trkorecal = 0.0;
792 float num_hits = 0.0;
795 const auto& matched_pftrack = orig.trackRefPF();
796 if (matched_pftrack.isNonnull()) {
799 if (atHCAL.isValid()) {
800 eta_hcal = atHCAL.positionREP().eta();
801 phi_hcal = atHCAL.positionREP().phi();
803 if (atECAL.isValid()) {
804 eta_ecal = atECAL.positionREP().eta();
805 phi_ecal = atECAL.positionREP().phi();
816 charge = ref->charge();
817 num_hits = ref->recHitsSize();
823 muon_dt_hits = standAloneMu->hitPattern().numberOfValidMuonDTHits();
824 muon_csc_hits = standAloneMu->hitPattern().numberOfValidMuonCSCHits();
826 muon_type = muonRef->type();
831 const auto& ref = orig2->GsftrackRef();
832 trajpoint = orig2->indTrajPoint();
833 if (ref.isNonnull()) {
834 deltap = orig2->DeltaP();
835 sigmadeltap = orig2->SigmaDeltaP();
843 charge = ref->charge();
846 const auto& gsfextraref = ref->extra();
847 if (gsfextraref.isAvailable() && gsfextraref->seedRef().isAvailable()) {
850 if (seedref->isEcalDriven()) {
851 gsf_electronseed_trkorecal = 1.0;
852 }
else if (seedref->isTrackerDriven()) {
853 gsf_electronseed_trkorecal = 2.0;
861 const auto& vec = orig2->Pin();
868 energy = vec.energy();
870 const auto&
vec2 = orig2->Pout();
871 eta_ecal =
vec2.eta();
872 phi_ecal =
vec2.phi();
874 if (!orig2->GsftrackRefPF().isNull()) {
875 charge = orig2->GsftrackRefPF()->charge();
876 num_hits = orig2->GsftrackRefPF()->PFRecBrem().size();
879 const auto& ref = orig2->GsftrackRef();
881 const auto& gsfextraref = ref->extra();
882 if (gsfextraref.isAvailable() && gsfextraref->seedRef().isAvailable()) {
885 if (seedref->isEcalDriven()) {
886 gsf_electronseed_trkorecal = 1.0;
887 }
else if (seedref->isTrackerDriven()) {
888 gsf_electronseed_trkorecal = 2.0;
898 if (ref.isNonnull()) {
899 cluster_flags = ref->flags();
903 px = ref->position().x();
904 py = ref->position().y();
905 pz = ref->position().z();
906 energy = ref->energy();
907 corr_energy = ref->correctedEnergy();
908 layer = ref->layer();
909 depth = ref->depth();
910 num_hits = ref->recHitFractions().size();
914 if (clref.isNonnull()) {
915 cluster_flags = clref->flags();
918 px = clref->position().x();
919 py = clref->position().y();
920 pz = clref->position().z();
921 energy = clref->energy();
922 num_hits = clref->clustersSize();
927 if (
t.second == (
int)ielem) {
928 tps.push_back(
t.first);
933 if (
t.second == (
int)ielem) {
934 scs.push_back(
t.first);
967 for (
const auto& cand : pfCandidates) {
977 for (
const auto& el : cand.elementsInBlocks()) {
978 const auto idx_block = el.first.index();
979 unsigned idx_element_in_block = el.second;
982 for (
const auto& elem_with_index : all_elements) {
984 if (elem_with_index.idx_block == idx_block && elem_with_index.idx_elem == idx_element_in_block) {
vector< int > element_charge_
vector< float > pfcandidate_pz_
EventNumber_t event() const
vector< float > pfcandidate_px_
vector< int > simtrack_pid_
bool isNonnull() const
Checks for non-null.
vector< int > element_distance_j_
vector< float > element_pz_
vector< int > simcluster_ev_
vector< float > element_phi_
vector< float > gen_energy_
uint16_t *__restrict__ id
vector< float > element_corr_energy_
vector< int > simcluster_bx_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
vector< float > simhit_phi_
vector< float > element_trajpoint_
vector< float > simcluster_px_
vector< float > element_gsf_electronseed_trkorecal_
vector< float > simcluster_eta_
vector< float > element_py_
vector< float > element_eta_
vector< int > gen_charge_
auto const & tracks
cannot be loose
key_type key() const
Accessor for product key.
vector< int > simhit_idx_simcluster_
vector< int > simtrack_idx_simcluster_
vector< int > element_layer_
LuminosityBlockNumber_t luminosityBlock() const
vector< float > element_sigmadeltap_
vector< float > simcluster_py_
constexpr std::array< uint8_t, layerIndexSize > layer
bool getData(T &iHolder) const
vector< float > element_pt_
vector< float > element_eta_ecal_
vector< float > simhit_z_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticles_
vector< float > simtrack_x_
vector< float > simhit_y_
vector< float > element_depth_
vector< float > simcluster_energy_
vector< int > find_element_ref(const vector< ElementWithIndex > &vec, const edm::RefToBase< reco::Track > &r)
vector< float > pfcandidate_phi_
edm::EDGetTokenT< edm::View< reco::Track > > tracks_
edm::EDGetTokenT< std::vector< reco::PFBlock > > pfBlocks_
vector< vector< int > > gen_daughters_
vector< pair< int, int > > element_to_candidate
vector< float > pfcandidate_eta_
vector< float > simcluster_phi_
vector< float > pfcandidate_pt_
vector< float > pfcandidate_py_
GlobalPoint getHitPosition(const DetId &id)
vector< int > element_distance_i_
vector< float > element_muon_csc_hits_
vector< float > element_muon_type_
vector< float > simhit_x_
edm::EDGetTokenT< std::vector< reco::PFCandidate > > pfCandidates_
vector< int > simcluster_pid_
vector< int > simhit_det_
vector< int > simhit_subdet_
vector< float > element_energy_
edm::EventNumber_t ev_event_
edm::LuminosityBlockNumber_t ev_lumi_
vector< float > element_px_
vector< float > element_deltap_
void processTrackingParticles(const edm::View< TrackingParticle > &trackingParticles, edm::Handle< edm::View< TrackingParticle >> &trackingParticlesHandle)
edm::EDGetTokenT< edm::View< TrackingParticle > > trackingParticles_
vector< int > gen_status_
vector< float > element_cluster_flags_
edm::EDGetTokenT< edm::View< CaloParticle > > caloParticles_
vector< float > element_phi_hcal_
vector< int > element_type_
vector< std::map< uint64_t, double > > simcluster_detids_
vector< float > simhit_frac_
const_reference at(size_type pos) const
vector< pair< int, int > > simcluster_to_element
vector< float > simcluster_pt_
vector< float > simcluster_pz_
vector< float > simtrack_y_
vector< int > pfcandidate_pdgid_
vector< float > pfcandidate_energy_
edm::EDGetTokenT< reco::RecoToSimCollection > tracks_recotosim_
vector< float > simhit_eta_
vector< float > element_muon_dt_hits_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topologyToken_
vector< pair< int, int > > trackingparticle_to_element
vector< float > element_phi_ecal_
pair< vector< ElementWithIndex >, vector< tuple< int, int, float > > > processBlocks(const std::vector< reco::PFBlock > &pfBlocks)
vector< float > simtrack_z_
vector< float > element_num_hits_
vector< int > simcluster_idx_trackingparticle_
vector< int > simcluster_nhits_
void associateClusterToSimCluster(const vector< ElementWithIndex > &all_elements)
vector< float > element_eta_hcal_
vector< uint64_t > simhit_detid_
vector< float > element_distance_d_