@@ -597,10 +597,10 @@ int PFAnalyzer::getBinNumbers(std::vector<double> binVal, std::vector<std::vecto
597597 return bin;
598598}
599599
600- int PFAnalyzer::getPFBin (const reco::PFCandidate pfCand, const pat::PackedCandidate packedCand, bool isMini , int i) {
600+ int PFAnalyzer::getPFBin (const reco::PFCandidate pfCand, const pat::PackedCandidate packedCand, const reco::CandidatePtr cand, int partType , int i) {
601601 std::vector<double > binVals;
602602 for (unsigned int j = 0 ; j < m_fullCutList[i].size (); j++) {
603- binVals.push_back (m_funcMap[m_fullCutList[i][j]](pfCand, packedCand, isMini ));
603+ binVals.push_back (m_funcMap[m_fullCutList[i][j]](pfCand, packedCand, cand, partType ));
604604 }
605605
606606 return getBinNumbers (binVals, m_binList[i]);
@@ -695,7 +695,6 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
695695 }
696696 }
697697 else {
698-
699698 iEvent.getByToken (patJetsToken_, patJets);
700699 if (!patJets.isValid ()) {
701700 edm::LogError (" PFAnalyzer" ) << " invalid collection: PF jets \n " ;
@@ -733,14 +732,17 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
733732 for (unsigned int i_pfcand=0 ; i_pfcand < numPFCands; i_pfcand++){
734733 reco::PFCandidate recoPF;
735734 pat::PackedCandidate packedCand;
735+ reco::CandidatePtr cand;
736+ int partType = 0 ;
736737 if (m_isMiniAOD){
737738 packedCand = patPfCollection->at (i_pfcand);
739+ partType = 1 ;
738740 } else {
739741 recoPF = pfCollection[i_pfcand];
740742 }
741743
742744 for (unsigned int j = 0 ; j < m_fullCutList.size (); j++) {
743- int binNumber = getPFBin (recoPF, packedCand, m_isMiniAOD, j);
745+ int binNumber = getPFBin (recoPF, packedCand, cand, m_isMiniAOD, j);
744746
745747 if (binNumber < 0 )
746748 continue ;
@@ -753,8 +755,8 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
753755 // For each observable, we make a couple histograms based on a few generic categorizations.
754756 // In all cases, the PFCs that go into these histograms must pass the PFC selection from m_cutList.
755757 std::string histName = Form (" %s_%s" , m_fullCutList2D[i][0 ].c_str (), m_fullCutList2D[i][1 ].c_str ());
756- double valX = m_funcMap[m_fullCutList2D[i][0 ]](recoPF, packedCand, m_isMiniAOD );
757- double valY = m_funcMap[m_fullCutList2D[i][1 ]](recoPF, packedCand, m_isMiniAOD );
758+ double valX = m_funcMap[m_fullCutList2D[i][0 ]](recoPF, packedCand, cand, partType );
759+ double valY = m_funcMap[m_fullCutList2D[i][1 ]](recoPF, packedCand, cand, partType );
758760
759761 map_of_MEs[m_directory + " /allPFC_" + histName]->Fill (valX, valY, eventWeight);
760762 if (m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()){
@@ -768,7 +770,7 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
768770 // Make plots of all observables
769771 for (unsigned int i = 0 ; i < m_observables.size (); i++) {
770772 std::string histName = Form (" %s%s_%s" , m_observableNames[i].c_str (), binString.c_str (), npvString.c_str ());
771- double val = m_funcMap[m_observableNames[i]](recoPF, packedCand, m_isMiniAOD );
773+ double val = m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType );
772774 map_of_MEs[m_directory + " /allPFC_" + histName]->Fill (val, eventWeight);
773775
774776 if (m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()){
@@ -779,7 +781,6 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
779781 }
780782 }
781783
782- /*
783784 for (unsigned int i = 0 ; i < m_eventObservableNames.size (); i++) {
784785 std::string histName = Form (" %s_%s" , m_eventObservableNames[i].c_str (), npvString.c_str ());
785786 map_of_MEs[m_directory + " /allPFC_" + histName]->Fill (
@@ -811,29 +812,58 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
811812 } else {
812813 cjet = pfJets->at (index);
813814 }
814- std::vector<reco::PFCandidatePtr> pfConstits;;
815- std::vector<pat::PackedCandidateRef> patConstits;;
815+ std::vector<reco::PFCandidatePtr> pfConstits;
816+ // std::vector<pat::PackedCandidateRef> patConstits;
817+ // reco::CompositePtrCandidate::daughters patConstits;
818+ std::vector<reco::CandidatePtr> patConstits;
819+ unsigned int nConstit = 0 ;
816820 if (m_isMiniAOD){
817821 // patConstits = patJets->at(index).getPFConstituents();
818- pfConstits = pfJets->at(index).getPFConstituents();
822+ patConstits = patJets->at (index).daughterPtrVector ();
823+ nConstit = patConstits.size ();
824+
825+ // if(patConstits.size() ) std::cout << patConstits[0]->pt() << std::endl;
826+
827+ // for(unsigned int i=0; i<patConstits.size(); i++){
828+ // reco::CandidatePtr* tmpCand = &(patConstits[i]);
829+ // reco::PFCandidatePtr* myptr = static_cast<reco::PFCandidatePtr*>(tmpCand);
830+ // pfConstits.push_back(dynamic_cast<reco::PFCandidatePtr*>(patConstits[i]));
831+ // }
832+ // pfConstits = patJets->at(index).getPFConstituents();
833+ // pfConstits = pfJets->at(index).getPFConstituents();
819834 } else {
820835 pfConstits = pfJets->at (index).getPFConstituents ();
836+ nConstit = pfConstits.size ();
837+
838+ // for(unsigned int i=0; i<pfConstits.size(); i++){
839+ // patConstits.push_back(pfConstits[i]);
840+ // }
821841 }
822842
823843 map_of_MEs[m_directory + Form (" /jetPt_%s" , npvString.c_str ())]->Fill (cjet.pt (), eventWeight);
824844 map_of_MEs[m_directory + Form (" /jetEta_%s" , npvString.c_str ())]->Fill (cjet.eta (), eventWeight);
825845
826846 for (unsigned int k = 0 ; k < m_fullJetCutList.size (); k++) {
827847 pat::PackedCandidate packedCand;
848+ reco::CandidatePtr cand;
849+ reco::PFCandidatePtr recoPF;
828850 int jetBinNumber = getJetBin (cjet, pfConstits, k);
829851 if (jetBinNumber < 0 )
830852 continue ;
831853 std::string jetBinString = m_allJetSuffixes[k][jetBinNumber];
832854
833855
834- for (const auto& recoPF : pfConstits) {
856+ // for (auto recoPF : pfConstits) {
857+ for (unsigned int iConstit=0 ; iConstit < nConstit; iConstit++) {
858+ int partType = 0 ;
859+ if (m_isMiniAOD) {
860+ cand = patConstits[iConstit];
861+ partType = 2 ;
862+ } else {
863+ recoPF = pfConstits[iConstit];
864+ }
835865 for (unsigned int j = 0 ; j < m_fullCutList.size (); j++) {
836- int binNumber = getPFBin(*recoPF, packedCand, false, j);
866+ int binNumber = getPFBin (*recoPF, packedCand, cand, false , j);
837867 if (binNumber < 0 )
838868 continue ;
839869 if (binNumber >= int (m_allSuffixes[j].size ())) {
@@ -847,10 +877,10 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
847877 binString.c_str (),
848878 jetBinString.c_str (),
849879 npvString.c_str ());
850- map_of_MEs[m_directory + "/allPFC_jetMatched_" + histName]->Fill(m_funcMap[m_observableNames[i]](*recoPF, packedCand, false ),
880+ map_of_MEs[m_directory + " /allPFC_jetMatched_" + histName]->Fill (m_funcMap[m_observableNames[i]](*recoPF, packedCand, cand, partType ),
851881 eventWeight);
852882 if (m_particleTypeName.find (recoPF->particleId ()) != m_particleTypeName.end ()){
853- map_of_MEs[m_directory + "/" + m_particleTypeName[recoPF->particleId()] + "_jetMatched_" + histName]->Fill(m_funcMap[m_observableNames[i]](*recoPF, packedCand, false ),
883+ map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF->particleId ()] + " _jetMatched_" + histName]->Fill (m_funcMap[m_observableNames[i]](*recoPF, packedCand, cand, partType ),
854884 eventWeight);
855885 }
856886 }
@@ -885,6 +915,5 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
885915 }
886916 }
887917 }
888- */
889918}
890919
0 commit comments