1212// ***********************************************************
1313PFAnalyzer::PFAnalyzer (const edm::ParameterSet& pSet) {
1414 m_directory = " ParticleFlow" ;
15- m_isMiniAOD= true ;
15+ m_isMiniAOD = true ;
1616 parameters_ = pSet.getParameter <edm::ParameterSet>(" pfAnalysis" );
1717
1818 // patPfCandidateCollection_ = consumes<pat::PFParticleCollection>(pSet.getParameter<edm::InputTag>("pfCandidates"));
19- patPfCandidateCollection_ = consumes<pat::PackedCandidateCollection>(pSet.getParameter <edm::InputTag>(" pfCandidates" ));
19+ patPfCandidateCollection_ =
20+ consumes<pat::PackedCandidateCollection>(pSet.getParameter <edm::InputTag>(" pfCandidates" ));
2021 patJetsToken_ = consumes<pat::JetCollection>(pSet.getParameter <edm::InputTag>(" pfJetCollection" ));
2122
2223 thePfCandidateCollection_ = consumes<reco::PFCandidateCollection>(pSet.getParameter <edm::InputTag>(" pfCandidates" ));
@@ -69,7 +70,6 @@ PFAnalyzer::PFAnalyzer(const edm::ParameterSet& pSet) {
6970 m_funcMap[" HCalE_depth6" ] = getHcalEnergy_depth6;
7071 m_funcMap[" HCalE_depth7" ] = getHcalEnergy_depth7;
7172
72-
7373 m_funcMap[" PS1_E" ] = getPS1Energy;
7474 m_funcMap[" PS2_E" ] = getPS2Energy;
7575 m_funcMap[" PS_E" ] = getPSEnergy;
@@ -123,14 +123,13 @@ PFAnalyzer::PFAnalyzer(const edm::ParameterSet& pSet) {
123123 m_jetFuncMap[" pt" ] = getJetPt;
124124 m_jetFuncMap[" chargeFrac" ] = getJetChargeFrac;
125125
126-
127- m_particleTypeName[reco::PFCandidate::ParticleType::h] = " chargedHadPFC" ;
128- m_particleTypeName[reco::PFCandidate::ParticleType::h0] = " neutralHadPFC" ;
129- m_particleTypeName[reco::PFCandidate::ParticleType::e] = " electronPFC" ;
130- m_particleTypeName[reco::PFCandidate::ParticleType::mu] = " muonPFC" ;
131- m_particleTypeName[reco::PFCandidate::ParticleType::gamma] = " gammaPFC" ;
132- m_particleTypeName[reco::PFCandidate::ParticleType::h_HF] = " hadHFPFC" ;
133- m_particleTypeName[reco::PFCandidate::ParticleType::egamma_HF] = " emHFPFC" ;
126+ m_particleTypeName[reco::PFCandidate::ParticleType::h] = " chargedHadPFC" ;
127+ m_particleTypeName[reco::PFCandidate::ParticleType::h0] = " neutralHadPFC" ;
128+ m_particleTypeName[reco::PFCandidate::ParticleType::e] = " electronPFC" ;
129+ m_particleTypeName[reco::PFCandidate::ParticleType::mu] = " muonPFC" ;
130+ m_particleTypeName[reco::PFCandidate::ParticleType::gamma] = " gammaPFC" ;
131+ m_particleTypeName[reco::PFCandidate::ParticleType::h_HF] = " hadHFPFC" ;
132+ m_particleTypeName[reco::PFCandidate::ParticleType::egamma_HF] = " emHFPFC" ;
134133
135134 // Convert the cutList strings into real cuts that can be applied
136135 // The format should be three comma separated values
@@ -159,11 +158,10 @@ PFAnalyzer::PFAnalyzer(const edm::ParameterSet& pSet) {
159158 }
160159 }
161160
162-
163161 for (unsigned int i = 0 ; i < m_cutList2D.size (); i++) {
164162 m_fullCutList2D.push_back (std::vector<std::string>());
165- while (m_cutList2D[i].find (" ] " ) != std::string::npos) {
166- size_t pos = m_cutList2D[i].find (" ] " );
163+ while (m_cutList2D[i].find (' ] ' ) != std::string::npos) {
164+ size_t pos = m_cutList2D[i].find (' ] ' );
167165 m_fullCutList2D[i].push_back (m_cutList2D[i].substr (1 , pos));
168166 m_cutList2D[i].erase (0 , pos + 1 );
169167 }
@@ -172,7 +170,7 @@ PFAnalyzer::PFAnalyzer(const edm::ParameterSet& pSet) {
172170 for (unsigned int i = 0 ; i < m_fullCutList2D.size (); i++) {
173171 m_binList2D.push_back (std::vector<std::vector<double >>());
174172 for (unsigned int j = 0 ; j < m_fullCutList2D[i].size (); j++) {
175- size_t pos = m_fullCutList2D[i][j].find (" ; " );
173+ size_t pos = m_fullCutList2D[i][j].find (' ; ' );
176174 std::string observableName = m_fullCutList2D[i][j].substr (0 , pos);
177175 m_fullCutList2D[i][j].erase (0 , pos + 1 );
178176
@@ -230,15 +228,22 @@ void PFAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun
230228 // the keys in m_funcMap), the second being the number of bins,
231229 // and the last two being the min and max value for the histogram respectively.
232230
233- for (unsigned int i= 0 ; i< m_fullCutList2D.size (); i++){
231+ for (unsigned int i = 0 ; i < m_fullCutList2D.size (); i++) {
234232 // Loop over all of the different types of PF candidates
235233 for (unsigned int m = 0 ; m < m_pfNames.size (); m++) {
236234 // For each observable, we make a couple histograms based on a few generic categorizations.
237235 // In all cases, the PFCs that go into these histograms must pass the PFC selection from m_cutList.
238- std::string histName = Form (" %s_%s_%s" ,
239- m_pfNames[m].c_str (), m_fullCutList2D[i][0 ].c_str (), m_fullCutList2D[i][1 ].c_str ());
240- MonitorElement* mHist = ibooker.book2D (
241- histName, Form (" ;%s;%s" , m_fullCutList2D[i][0 ].c_str (), m_fullCutList2D[i][1 ].c_str ()), m_binList2D[i][0 ].size (), m_binList2D[i][0 ][0 ], m_binList2D[i][0 ][m_binList2D[i][0 ].size ()-1 ], m_binList2D[i][1 ].size (), m_binList2D[i][1 ][0 ], m_binList2D[i][1 ][m_binList2D[i][0 ].size ()-1 ]);
236+ std::string histName =
237+ Form (" %s_%s_%s" , m_pfNames[m].c_str (), m_fullCutList2D[i][0 ].c_str (), m_fullCutList2D[i][1 ].c_str ());
238+ MonitorElement* mHist =
239+ ibooker.book2D (histName,
240+ Form (" ;%s;%s" , m_fullCutList2D[i][0 ].c_str (), m_fullCutList2D[i][1 ].c_str ()),
241+ m_binList2D[i][0 ].size (),
242+ m_binList2D[i][0 ][0 ],
243+ m_binList2D[i][0 ][m_binList2D[i][0 ].size () - 1 ],
244+ m_binList2D[i][1 ].size (),
245+ m_binList2D[i][1 ][0 ],
246+ m_binList2D[i][1 ][m_binList2D[i][0 ].size () - 1 ]);
242247 map_of_MEs.insert (std::pair<std::string, MonitorElement*>(m_directory + " /" + histName, mHist ));
243248 }
244249 }
@@ -445,7 +450,6 @@ void PFAnalyzer::bookMESetSelection(std::string DirName, DQMStore::IBooker& iboo
445450// ***********************************************************
446451void PFAnalyzer::dqmBeginRun (const edm::Run& iRun, const edm::EventSetup& iSetup) {}
447452
448-
449453// How many significant digits do we need to save for the values to be distinct?
450454std::string PFAnalyzer::stringWithDecimals (int bin, std::vector<double > bins) {
451455 double diff = bins[bin + 1 ] - bins[bin];
@@ -470,8 +474,8 @@ std::string PFAnalyzer::stringWithDecimals(int bin, std::vector<double> bins) {
470474 if (bins[bin + 1 ] < 0 )
471475 signStringHigh = " m" ;
472476
473- int higherDigitsLow = (bins[bin]> 0 )? floor (bins[bin]): ceil (bins[bin]);
474- int higherDigitsHigh = (bins[bin+ 1 ]> 0 )? floor (bins[bin+ 1 ]): ceil (bins[bin+ 1 ]);
477+ int higherDigitsLow = (bins[bin] > 0 ) ? floor (bins[bin]) : ceil (bins[bin]);
478+ int higherDigitsHigh = (bins[bin + 1 ] > 0 ) ? floor (bins[bin + 1 ]) : ceil (bins[bin + 1 ]);
475479
476480 return Form (" %s%dp%.0f_%s%dp%.0f" ,
477481 signStringLow.c_str (),
@@ -506,7 +510,6 @@ std::vector<double> PFAnalyzer::getBinList(std::string binString) {
506510 return binList;
507511}
508512
509-
510513std::vector<std::string> PFAnalyzer::getAllSuffixes (std::vector<std::string> observables,
511514 std::vector<std::vector<double >> binnings) {
512515 int nTotalBins = 1 ;
@@ -531,7 +534,7 @@ std::vector<std::string> PFAnalyzer::getAllSuffixes(std::vector<std::string> obs
531534 for (int k = 0 ; k < factor; k++) {
532535 for (int j = 0 ; j < nBins[i]; j++) {
533536 for (int m = 0 ; m < otherFactor; m++) {
534- int binNumber = k* nBins[i] + j * otherFactor + m;
537+ int binNumber = k * nBins[i] + j * otherFactor + m;
535538 binList[binNumber].push_back (j);
536539 }
537540 }
@@ -596,7 +599,11 @@ int PFAnalyzer::getBinNumbers(std::vector<double> binVal, std::vector<std::vecto
596599 return bin;
597600}
598601
599- int PFAnalyzer::getPFBin (const reco::PFCandidate pfCand, const pat::PackedCandidate packedCand, const reco::CandidatePtr cand, int partType, int i) {
602+ int PFAnalyzer::getPFBin (const reco::PFCandidate pfCand,
603+ const pat::PackedCandidate packedCand,
604+ const reco::CandidatePtr cand,
605+ int partType,
606+ int i) {
600607 std::vector<double > binVals;
601608 for (unsigned int j = 0 ; j < m_fullCutList[i].size (); j++) {
602609 binVals.push_back (m_funcMap[m_fullCutList[i][j]](pfCand, packedCand, cand, partType));
@@ -652,55 +659,51 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
652659 // **** Get the TriggerResults container
653660 edm::Handle<edm::TriggerResults> triggerResults;
654661 iEvent.getByToken (triggerResultsToken_, triggerResults);
655- if (!triggerResults.isValid ()){
656- edm::LogError (" PFAnalyzer" ) << " invalid trigger result \n " ;
657- return ;
662+ if (!triggerResults.isValid ()) {
663+ edm::LogError (" PFAnalyzer" ) << " invalid trigger result \n " ;
664+ return ;
658665 }
659666 const edm::TriggerNames& triggerNames = iEvent.triggerNames (*triggerResults);
660667
661-
662668 edm::Handle<reco::PFCandidateCollection> recoPfCollection;
663669 edm::Handle<pat::PackedCandidateCollection> patPfCollection;
664670 std::vector<reco::PFCandidate> pfCollection;
665671
666-
667672 edm::Handle<pat::JetCollection> patJets;
668673 edm::Handle<reco::PFJetCollection> pfJets;
669674 std::vector<reco::Jet> jets;
670675
671676 unsigned int numJets = 0 ;
672677 unsigned int numPFCands = 0 ;
673- m_isMiniAOD= true ;
674- if (!m_isMiniAOD){
678+ m_isMiniAOD = true ;
679+ if (!m_isMiniAOD) {
675680 iEvent.getByToken (thePfCandidateCollection_, recoPfCollection);
676681 if (!recoPfCollection.isValid ()) {
677682 edm::LogError (" PFAnalyzer" ) << " invalid collection: PF candidate \n " ;
678683 return ;
679684 }
680- for (unsigned int i= 0 ; i< recoPfCollection->size (); i++){
685+ for (unsigned int i = 0 ; i < recoPfCollection->size (); i++) {
681686 pfCollection.push_back (recoPfCollection->at (i));
682687 }
683688 numPFCands = recoPfCollection->size ();
684689
685-
686690 iEvent.getByToken (pfJetsToken_, pfJets);
687691 if (!pfJets.isValid ()) {
688692 edm::LogError (" PFAnalyzer" ) << " invalid collection: PF jets \n " ;
689693 return ;
690694 }
691695 numJets = pfJets->size ();
692- for (unsigned int i= 0 ; i< numJets; i++){
696+ for (unsigned int i = 0 ; i < numJets; i++) {
693697 jets.push_back (pfJets->at (i));
694698 }
695- }
696- else {
699+ } else {
697700 iEvent.getByToken (patJetsToken_, patJets);
698701 if (!patJets.isValid ()) {
699702 edm::LogError (" PFAnalyzer" ) << " invalid collection: PF jets \n " ;
700703 return ;
701704 }
702705 numJets = patJets->size ();
703- for (unsigned int i= 0 ; i< numJets; i++){
706+ for (unsigned int i = 0 ; i < numJets; i++) {
704707 jets.push_back (patJets->at (i));
705708 }
706709
@@ -717,24 +720,24 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
717720 // edm::LogError("PFAnalyzer") << "invalid collection: Puppi weights \n";
718721 // }
719722
720- if (!passesTriggerSelection (jets, triggerResults, triggerNames, m_triggerOptions)){
723+ if (!passesTriggerSelection (jets, triggerResults, triggerNames, m_triggerOptions)) {
721724 return ;
722725 }
723726
724- if (!m_eventSelectionMap[m_selection](jets)){
727+ if (!m_eventSelectionMap[m_selection](jets)) {
725728 return ;
726729 }
727730
728- for (unsigned int i_pfcand= 0 ; i_pfcand < numPFCands; i_pfcand++){
731+ for (unsigned int i_pfcand = 0 ; i_pfcand < numPFCands; i_pfcand++) {
729732 reco::PFCandidate recoPF;
730733 pat::PackedCandidate packedCand;
731734 reco::CandidatePtr cand;
732735 int partType = 0 ;
733- if (m_isMiniAOD){
734- packedCand = patPfCollection->at (i_pfcand);
735- partType = 1 ;
736- } else {
737- recoPF = pfCollection[i_pfcand];
736+ if (m_isMiniAOD) {
737+ packedCand = patPfCollection->at (i_pfcand);
738+ partType = 1 ;
739+ } else {
740+ recoPF = pfCollection[i_pfcand];
738741 }
739742
740743 for (unsigned int j = 0 ; j < m_fullCutList.size (); j++) {
@@ -747,18 +750,18 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
747750 }
748751 std::string binString = m_allSuffixes[j][binNumber];
749752
750- for (unsigned int i= 0 ; i< m_fullCutList2D.size (); i++){
753+ for (unsigned int i = 0 ; i < m_fullCutList2D.size (); i++) {
751754 // For each observable, we make a couple histograms based on a few generic categorizations.
752755 // In all cases, the PFCs that go into these histograms must pass the PFC selection from m_cutList.
753756 std::string histName = Form (" %s_%s" , m_fullCutList2D[i][0 ].c_str (), m_fullCutList2D[i][1 ].c_str ());
754757 double valX = m_funcMap[m_fullCutList2D[i][0 ]](recoPF, packedCand, cand, partType);
755758 double valY = m_funcMap[m_fullCutList2D[i][1 ]](recoPF, packedCand, cand, partType);
756759
757760 map_of_MEs[m_directory + " /allPFC_" + histName]->Fill (valX, valY, eventWeight);
758- if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()){
759- map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _" + histName]->Fill (valX, valY, eventWeight);
761+ if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()) {
762+ map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _" + histName]->Fill (
763+ valX, valY, eventWeight);
760764 }
761-
762765 }
763766
764767 // Eventually, we might want the hist name to include the cuts that we are applying,
@@ -769,8 +772,9 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
769772 double val = m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType);
770773 map_of_MEs[m_directory + " /allPFC_" + histName]->Fill (val, eventWeight);
771774
772- if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()){
773- map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _" + histName]->Fill (val, eventWeight);
775+ if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()) {
776+ map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _" + histName]->Fill (val,
777+ eventWeight);
774778 }
775779 }
776780 }
@@ -781,39 +785,38 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
781785 map_of_MEs[m_directory + " /allPFC_" + histName]->Fill (
782786 m_eventFuncMap[m_eventObservableNames[i]](pfCollection, reco::PFCandidate::ParticleType::X), eventWeight);
783787
784- for (const auto & mypair : m_particleTypeName){
788+ for (const auto & mypair : m_particleTypeName) {
785789 map_of_MEs[m_directory + " /" + mypair.second + " _" + histName]->Fill (
786790 m_eventFuncMap[m_eventObservableNames[i]](pfCollection, mypair.first ), eventWeight);
787791 }
788792 }
789793
790794 // Plots for generic debugging
791795 map_of_MEs[m_directory + " /NPV" ]->Fill (numPV, eventWeight);
792- reco::Jet leadJet;
793- if (m_isMiniAOD){
796+ reco::Jet leadJet;
797+ if (m_isMiniAOD) {
794798 leadJet = *patJets->begin ();
795- } else {
799+ } else {
796800 leadJet = *pfJets->begin ();
797801 }
798802 map_of_MEs[m_directory + Form (" /jetPtLead_%s" , npvString.c_str ())]->Fill (leadJet.pt (), eventWeight);
799803 map_of_MEs[m_directory + Form (" /jetEtaLead_%s" , npvString.c_str ())]->Fill (leadJet.eta (), eventWeight);
800804
801-
802805 // Make plots of all observables, this time for PF candidates within jets
803- for (unsigned int index= 0 ; index < numJets; index++) {
806+ for (unsigned int index = 0 ; index < numJets; index++) {
804807 reco::Jet cjet;
805- if (m_isMiniAOD){
808+ if (m_isMiniAOD) {
806809 cjet = patJets->at (index);
807- } else {
810+ } else {
808811 cjet = pfJets->at (index);
809812 }
810813 std::vector<reco::PFCandidatePtr> pfConstits;
811814 std::vector<reco::CandidatePtr> patConstits;
812815 unsigned int nConstit = 0 ;
813- if (m_isMiniAOD){
816+ if (m_isMiniAOD) {
814817 patConstits = patJets->at (index).daughterPtrVector ();
815818 nConstit = patConstits.size ();
816- } else {
819+ } else {
817820 pfConstits = pfJets->at (index).getPFConstituents ();
818821 nConstit = pfConstits.size ();
819822 }
@@ -831,12 +834,12 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
831834 continue ;
832835 std::string jetBinString = m_allJetSuffixes[k][jetBinNumber];
833836
834- for (unsigned int iConstit= 0 ; iConstit < nConstit; iConstit++) {
837+ for (unsigned int iConstit = 0 ; iConstit < nConstit; iConstit++) {
835838 int partType = 0 ;
836- if (m_isMiniAOD) {
839+ if (m_isMiniAOD) {
837840 cand = patConstits[iConstit];
838841 partType = 2 ;
839- } else {
842+ } else {
840843 recoPFPtr = pfConstits[iConstit];
841844 recoPF = *recoPFPtr;
842845 }
@@ -855,11 +858,11 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
855858 binString.c_str (),
856859 jetBinString.c_str (),
857860 npvString.c_str ());
858- map_of_MEs[m_directory + " /allPFC_jetMatched_" + histName]->Fill (m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType),
859- eventWeight);
860- if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()){
861- map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _jetMatched_" + histName]->Fill (m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType),
862- eventWeight);
861+ map_of_MEs[m_directory + " /allPFC_jetMatched_" + histName]->Fill (
862+ m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType), eventWeight);
863+ if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()) {
864+ map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _jetMatched_" + histName]->Fill (
865+ m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType), eventWeight);
863866 }
864867 }
865868
@@ -872,9 +875,9 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
872875 map_of_MEs[m_directory + " /allPFC_jetMatched_" + histName]->Fill (
873876 m_pfInJetFuncMap[m_pfInJetObservableNames[i]](recoPF, cjet), eventWeight);
874877
875- if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()){
878+ if (partType == 0 && m_particleTypeName.find (recoPF.particleId ()) != m_particleTypeName.end ()) {
876879 map_of_MEs[m_directory + " /" + m_particleTypeName[recoPF.particleId ()] + " _jetMatched_" + histName]->Fill (
877- m_pfInJetFuncMap[m_pfInJetObservableNames[i]](recoPF, cjet), eventWeight);
880+ m_pfInJetFuncMap[m_pfInJetObservableNames[i]](recoPF, cjet), eventWeight);
878881 }
879882 }
880883 }
@@ -883,8 +886,9 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
883886 std::string histName =
884887 Form (" %s_jetCuts%s_%s" , m_eventObservableNames[i].c_str (), jetBinString.c_str (), npvString.c_str ());
885888 map_of_MEs[m_directory + " /allPFC_jetMatched_" + histName]->Fill (
886- m_jetWideFuncMap[m_eventObservableNames[i]](pfConstits, reco::PFCandidate::ParticleType::X, cjet), eventWeight);
887- for (const auto &mypair : m_particleTypeName){
889+ m_jetWideFuncMap[m_eventObservableNames[i]](pfConstits, reco::PFCandidate::ParticleType::X, cjet),
890+ eventWeight);
891+ for (const auto & mypair : m_particleTypeName) {
888892 map_of_MEs[m_directory + " /" + mypair.second + " _jetMatched_" + histName]->Fill (
889893 m_jetWideFuncMap[m_eventObservableNames[i]](pfConstits, mypair.first , cjet), eventWeight);
890894 }
@@ -893,4 +897,3 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
893897 }
894898 }
895899}
896-
0 commit comments