Skip to content

Commit 96fe249

Browse files
committed
Merging mini and calib changes
1 parent 204b3f6 commit 96fe249

File tree

5 files changed

+167
-84
lines changed

5 files changed

+167
-84
lines changed

DQMOffline/ParticleFlow/plugins/PFAnalyzer.cc

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ PFAnalyzer::PFAnalyzer(const edm::ParameterSet& pSet) {
4747
// List of jet cuts that we apply for the case of plotting PFCs in jets
4848
m_jetCutList = parameters_.getParameter<vstring>("jetCutList");
4949

50-
m_eventSelectionMap["none"] = &passesEventSelection;
5150
m_eventSelectionMap["dijet"] = &passesDijetSelection;
5251
m_eventSelectionMap["nocut"] = &passesNoCutSelection;
5352
m_eventSelectionMap["anomalous"] = &passesAnomalousSelection;
@@ -710,9 +709,6 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
710709
edm::LogError("PFAnalyzer") << "invalid collection: PF candidate \n";
711710
return;
712711
}
713-
//for(unsigned int i=0; i<patPfCollection->size(); i++){
714-
// pfCollection.push_back(patPfCollection->at(i));
715-
//}
716712
numPFCands = patPfCollection->size();
717713
}
718714

@@ -736,14 +732,13 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
736732
int partType = 0;
737733
if(m_isMiniAOD){
738734
packedCand = patPfCollection->at(i_pfcand);
739-
740735
partType = 1;
741736
} else{
742737
recoPF = pfCollection[i_pfcand];
743738
}
744739

745740
for (unsigned int j = 0; j < m_fullCutList.size(); j++) {
746-
int binNumber = getPFBin(recoPF, packedCand, cand, m_isMiniAOD, j);
741+
int binNumber = getPFBin(recoPF, packedCand, cand, partType, j);
747742

748743
if (binNumber < 0)
749744
continue;
@@ -760,7 +755,7 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
760755
double valY = m_funcMap[m_fullCutList2D[i][1]](recoPF, packedCand, cand, partType);
761756

762757
map_of_MEs[m_directory + "/allPFC_" + histName]->Fill(valX, valY, eventWeight);
763-
if(m_particleTypeName.find(recoPF.particleId()) != m_particleTypeName.end()){
758+
if(partType == 0 && m_particleTypeName.find(recoPF.particleId()) != m_particleTypeName.end()){
764759
map_of_MEs[m_directory + "/" + m_particleTypeName[recoPF.particleId()] + "_" + histName]->Fill(valX, valY, eventWeight);
765760
}
766761

@@ -774,10 +769,9 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
774769
double val = m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType);
775770
map_of_MEs[m_directory + "/allPFC_" + histName]->Fill(val, eventWeight);
776771

777-
if(m_particleTypeName.find(recoPF.particleId()) != m_particleTypeName.end()){
772+
if(partType == 0 && m_particleTypeName.find(recoPF.particleId()) != m_particleTypeName.end()){
778773
map_of_MEs[m_directory + "/" + m_particleTypeName[recoPF.particleId()] + "_" + histName]->Fill(val, eventWeight);
779774
}
780-
781775
}
782776
}
783777
}
@@ -814,31 +808,14 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
814808
cjet = pfJets->at(index);
815809
}
816810
std::vector<reco::PFCandidatePtr> pfConstits;
817-
//std::vector<pat::PackedCandidateRef> patConstits;
818-
//reco::CompositePtrCandidate::daughters patConstits;
819811
std::vector<reco::CandidatePtr> patConstits;
820812
unsigned int nConstit = 0;
821813
if(m_isMiniAOD){
822-
//patConstits = patJets->at(index).getPFConstituents();
823814
patConstits = patJets->at(index).daughterPtrVector();
824815
nConstit = patConstits.size();
825-
826-
//if(patConstits.size() ) std::cout << patConstits[0]->pt() << std::endl;
827-
828-
//for(unsigned int i=0; i<patConstits.size(); i++){
829-
//reco::CandidatePtr* tmpCand = &(patConstits[i]);
830-
//reco::PFCandidatePtr* myptr = static_cast<reco::PFCandidatePtr*>(tmpCand);
831-
//pfConstits.push_back(dynamic_cast<reco::PFCandidatePtr*>(patConstits[i]));
832-
//}
833-
//pfConstits = patJets->at(index).getPFConstituents();
834-
//pfConstits = pfJets->at(index).getPFConstituents();
835816
} else{
836817
pfConstits = pfJets->at(index).getPFConstituents();
837818
nConstit = pfConstits.size();
838-
839-
//for(unsigned int i=0; i<pfConstits.size(); i++){
840-
// patConstits.push_back(pfConstits[i]);
841-
//}
842819
}
843820

844821
map_of_MEs[m_directory + Form("/jetPt_%s", npvString.c_str())]->Fill(cjet.pt(), eventWeight);
@@ -847,24 +824,24 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
847824
for (unsigned int k = 0; k < m_fullJetCutList.size(); k++) {
848825
pat::PackedCandidate packedCand;
849826
reco::CandidatePtr cand;
850-
reco::PFCandidatePtr recoPF;
827+
reco::PFCandidatePtr recoPFPtr;
828+
reco::PFCandidate recoPF;
851829
int jetBinNumber = getJetBin(cjet, pfConstits, k);
852830
if (jetBinNumber < 0)
853831
continue;
854832
std::string jetBinString = m_allJetSuffixes[k][jetBinNumber];
855833

856-
857-
//for (auto recoPF : pfConstits) {
858834
for (unsigned int iConstit=0; iConstit < nConstit; iConstit++) {
859835
int partType = 0;
860836
if(m_isMiniAOD) {
861837
cand = patConstits[iConstit];
862838
partType = 2;
863839
} else{
864-
recoPF = pfConstits[iConstit];
840+
recoPFPtr = pfConstits[iConstit];
841+
recoPF = *recoPFPtr;
865842
}
866843
for (unsigned int j = 0; j < m_fullCutList.size(); j++) {
867-
int binNumber = getPFBin(*recoPF, packedCand, cand, false, j);
844+
int binNumber = getPFBin(recoPF, packedCand, cand, partType, j);
868845
if (binNumber < 0)
869846
continue;
870847
if (binNumber >= int(m_allSuffixes[j].size())) {
@@ -878,10 +855,10 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
878855
binString.c_str(),
879856
jetBinString.c_str(),
880857
npvString.c_str());
881-
map_of_MEs[m_directory + "/allPFC_jetMatched_" + histName]->Fill(m_funcMap[m_observableNames[i]](*recoPF, packedCand, cand, partType),
858+
map_of_MEs[m_directory + "/allPFC_jetMatched_" + histName]->Fill(m_funcMap[m_observableNames[i]](recoPF, packedCand, cand, partType),
882859
eventWeight);
883-
if(m_particleTypeName.find(recoPF->particleId()) != m_particleTypeName.end()){
884-
map_of_MEs[m_directory + "/" + m_particleTypeName[recoPF->particleId()] + "_jetMatched_" + histName]->Fill(m_funcMap[m_observableNames[i]](*recoPF, packedCand, cand, partType),
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),
885862
eventWeight);
886863
}
887864
}
@@ -893,13 +870,12 @@ void PFAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup
893870
jetBinString.c_str(),
894871
npvString.c_str());
895872
map_of_MEs[m_directory + "/allPFC_jetMatched_" + histName]->Fill(
896-
m_pfInJetFuncMap[m_pfInJetObservableNames[i]](*recoPF, cjet), eventWeight);
873+
m_pfInJetFuncMap[m_pfInJetObservableNames[i]](recoPF, cjet), eventWeight);
897874

898-
if(m_particleTypeName.find(recoPF->particleId()) != m_particleTypeName.end()){
899-
map_of_MEs[m_directory + "/" + m_particleTypeName[recoPF->particleId()] + "_jetMatched_" + histName]->Fill(
900-
m_pfInJetFuncMap[m_pfInJetObservableNames[i]](*recoPF, cjet), eventWeight);
875+
if(partType == 0 && m_particleTypeName.find(recoPF.particleId()) != m_particleTypeName.end()){
876+
map_of_MEs[m_directory + "/" + m_particleTypeName[recoPF.particleId()] + "_jetMatched_" + histName]->Fill(
877+
m_pfInJetFuncMap[m_pfInJetObservableNames[i]](recoPF, cjet), eventWeight);
901878
}
902-
903879
}
904880
}
905881

DQMOffline/ParticleFlow/plugins/PFAnalyzer.h

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class PFAnalyzer : public DQMEDAnalyzer {
7878
// A map between an observable name and a function that obtains that observable from a PFCandidate.
7979
// This allows us to construct more complicated observables easily, and have it more configurable
8080
// in the config file.
81-
std::map<std::string, std::function<double(const reco::PFCandidate, const pat::PackedCandidate, const reco::CandidatePtr, bool)>> m_funcMap;
81+
std::map<std::string, std::function<double(const reco::PFCandidate, const pat::PackedCandidate, const reco::CandidatePtr, int)>> m_funcMap;
8282
//std::map<std::string, std::function<double(const reco::PFCandidateCollection, reco::PFCandidate::ParticleType pfType)>>
8383
std::map<std::string, std::function<double(const std::vector<reco::PFCandidate>, reco::PFCandidate::ParticleType pfType)>>
8484
m_eventFuncMap;
@@ -120,7 +120,6 @@ class PFAnalyzer : public DQMEDAnalyzer {
120120
return pfCand.pt() / jet.pt();
121121
}
122122

123-
//static double getNPFC(const reco::PFCandidateCollection pfCands, reco::PFCandidate::ParticleType pfType) {
124123
static double getNPFC(const std::vector<reco::PFCandidate> pfCands, reco::PFCandidate::ParticleType pfType) {
125124
int nPF = 0;
126125
for (auto pfCand : pfCands) {
@@ -144,7 +143,6 @@ class PFAnalyzer : public DQMEDAnalyzer {
144143
return nPF;
145144
}
146145

147-
//static double getMaxPt(const reco::PFCandidateCollection pfCands, reco::PFCandidate::ParticleType pfType) {
148146
static double getMaxPt(const std::vector<reco::PFCandidate> pfCands, reco::PFCandidate::ParticleType pfType) {
149147
double maxPt = 0;
150148
for (auto pfCand : pfCands) {
@@ -170,20 +168,36 @@ class PFAnalyzer : public DQMEDAnalyzer {
170168

171169

172170
// Various functions designed to get information from a PF canddidate
173-
static double getPt(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType) {return packedPart.pt();} return pfCand.pt(); }
174-
static double getEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType) {return packedPart.energy();} return pfCand.energy(); }
175-
static double getEta(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType) {return packedPart.eta();}return pfCand.eta(); }
176-
static double getAbsEta(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType) {return std::abs(packedPart.eta());}return std::abs(pfCand.eta()); }
177-
static double getPhi(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType) {return packedPart.phi();}return pfCand.phi(); }
171+
static double getPt(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) {
172+
if(partType==1) {return packedPart.pt();}
173+
if(partType==2) {return cand->pt(); }
174+
return pfCand.pt();
175+
}
176+
static double getEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1) {return packedPart.energy();} return pfCand.energy(); }
177+
static double getEta(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) {
178+
if(partType==1) { return packedPart.eta();}
179+
if(partType==2) { return cand->eta(); }
180+
return pfCand.eta();
181+
}
182+
static double getAbsEta(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) {
183+
if(partType==1) {return std::abs(packedPart.eta());}
184+
if(partType==2) { return std::abs(cand->eta()); }
185+
return std::abs(pfCand.eta());
186+
}
187+
static double getPhi(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) {
188+
if(partType==1) {return packedPart.phi();}
189+
if(partType==2) { return cand->phi(); }
190+
return pfCand.phi();
191+
}
178192

179193
static double getHadCalibration(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) {
180194
if (pfCand.rawHcalEnergy() == 0)
181195
return -1;
182196
return pfCand.hcalEnergy() / pfCand.rawHcalEnergy();
183197
}
184-
static double getPuppiWeight(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){return packedPart.puppiWeight();} return 1; }
198+
static double getPuppiWeight(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1){return packedPart.puppiWeight();} return 1; }
185199

186-
static double getTime(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){return packedPart.time();} return pfCand.time(); }
200+
static double getTime(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1){return packedPart.time();} return pfCand.time(); }
187201

188202
static double getHcalEnergy_depth1(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { return pfCand.hcalDepthEnergyFraction(1); }
189203
static double getHcalEnergy_depth2(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { return pfCand.hcalDepthEnergyFraction(2); }
@@ -193,10 +207,10 @@ class PFAnalyzer : public DQMEDAnalyzer {
193207
static double getHcalEnergy_depth6(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { return pfCand.hcalDepthEnergyFraction(6); }
194208
static double getHcalEnergy_depth7(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { return pfCand.hcalDepthEnergyFraction(7); }
195209

196-
static double getEcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){ return (1.0-packedPart.hcalFraction())*packedPart.energy();} return pfCand.ecalEnergy(); }
197-
static double getRawEcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){ return (1.0-packedPart.rawHcalFraction())*packedPart.energy();}return pfCand.rawEcalEnergy(); }
198-
static double getHcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){return packedPart.hcalFraction()*packedPart.energy();}return pfCand.hcalEnergy(); }
199-
static double getRawHcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){ return packedPart.rawHcalFraction()*packedPart.energy();}return pfCand.rawHcalEnergy(); }
210+
static double getEcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1){ return (1.0-packedPart.hcalFraction())*packedPart.energy();} return pfCand.ecalEnergy(); }
211+
static double getRawEcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1){ return (1.0-packedPart.rawHcalFraction())*packedPart.energy();}return pfCand.rawEcalEnergy(); }
212+
static double getHcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1){return packedPart.hcalFraction()*packedPart.energy();}return pfCand.hcalEnergy(); }
213+
static double getRawHcalEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType==1){ return packedPart.rawHcalFraction()*packedPart.energy();}return pfCand.rawHcalEnergy(); }
200214
static double getHOEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){return 0;} return pfCand.hoEnergy(); }
201215
static double getRawHOEnergy(const reco::PFCandidate pfCand, const pat::PackedCandidate packedPart, const reco::CandidatePtr cand, int partType) { if(partType){return 0;} return pfCand.rawHoEnergy(); }
202216

@@ -244,8 +258,6 @@ class PFAnalyzer : public DQMEDAnalyzer {
244258
}
245259
}
246260
}
247-
248-
std::cout << energy << "\t" << pfCand.pS1Energy() << std::endl;
249261
}
250262
return pfCand.pS1Energy()+pfCand.pS2Energy();}
251263

@@ -364,7 +376,6 @@ class PFAnalyzer : public DQMEDAnalyzer {
364376
// Get cluster and hits
365377
reco::PFClusterRef clusterref = elements[iEle].clusterRef();
366378
reco::PFCluster cluster = *clusterref;
367-
//std::vector<std::pair<DetId, float>> hitsAndFracs = cluster.hitsAndFractions();
368379
energy += cluster.energy();
369380
}
370381
}
@@ -454,17 +465,6 @@ class PFAnalyzer : public DQMEDAnalyzer {
454465
}
455466

456467

457-
static bool passesEventSelection(const std::vector<reco::Jet>& pfJets) {
458-
if (pfJets.size() < 2)
459-
return false;
460-
if (pfJets[0].pt() < 450)
461-
return false;
462-
if (pfJets[0].pt() / pfJets[1].pt() > 2)
463-
return false;
464-
465-
return true;
466-
}
467-
468468
static bool passesNoCutSelection(const std::vector<reco::Jet>& pfJets) {
469469
return true;
470470
}
@@ -494,7 +494,6 @@ class PFAnalyzer : public DQMEDAnalyzer {
494494
bool m_isMiniAOD;
495495

496496
edm::EDGetTokenT<reco::PFCandidateCollection> thePfCandidateCollection_;
497-
//edm::EDGetTokenT<pat::PFParticleCollection> patPfCandidateCollection_;
498497
edm::EDGetTokenT<pat::PackedCandidateCollection> patPfCandidateCollection_;
499498

500499
edm::EDGetTokenT<reco::PFJetCollection> pfJetsToken_;

DQMOffline/ParticleFlow/python/runBasic_cfi.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,15 @@
22
from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
33

44
PFAnalyzer = DQMEDAnalyzer("PFAnalyzer",
5-
#pfCandidates = cms.InputTag("particleFlow"),
6-
#pfJetCollection = cms.InputTag("ak4PFJetsPuppiCorrected"),
7-
8-
# For Mini
9-
pfCandidates = cms.InputTag("packedPFCandidates"),
10-
pfJetCollection = cms.InputTag("slimmedJets"),
11-
5+
pfCandidates = cms.InputTag("particleFlow"),
6+
pfJetCollection = cms.InputTag("ak4PFJetsPuppiCorrected"),
127
PVCollection = cms.InputTag("offlinePrimaryVertices"),
138

149
TriggerResultsLabel = cms.InputTag("TriggerResults::HLT"),
15-
#TriggerNames = cms.vstring("HLT_PFJet450"),
16-
TriggerNames = cms.vstring(""),
10+
TriggerNames = cms.vstring("HLT_PFJet450"),
1711
#puppiWeight = cms.InputTag("packedPuppiweight"),
12+
eventSelection = cms.string("dijet"),
1813
#eventSelection = cms.string("nocut"),
19-
#eventSelection = cms.string("dijet"),
20-
eventSelection = cms.string("nocut"),
21-
22-
2314

2415
pfAnalysis = cms.PSet(
2516
# Bins of NPV for plots
@@ -101,9 +92,9 @@
10192
cutList = cms.vstring(
10293
'[pt;1;0;10000]',
10394
#'[pt;0;1;2;4;6;10;20;40;60;100][abseta;0;1.5;2.0;2.5;2.8;2.85;2.9;2.95;3]',
104-
'[pt;0;2;5;10;20;50;100;1000]',
95+
#'[pt;0;2;5;10;20;50;100;1000]',
10596
#'[pt;1;0;10000][abseta;0;1;2;2.5;2.6;2.7;2.8;2.9;3;3.5;4.0;4.5]',
106-
'[pt;1;0;10000][abseta;0;1;1.5;2;2.5;3;3.5;4.0]',
97+
#'[pt;1;0;10000][abseta;0;1;1.5;2;2.5;3;3.5;4.0]',
10798
),
10899

109100
# This is a list of multidimensional cuts on the jets that are applied for the plots.

DQMOffline/ParticleFlow/python/runMini_cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
process.load("DQMServices.Components.DQMEnvironment_cfi")
1717

1818
# my analyzer
19-
process.load('DQMOffline.ParticleFlow.runBasic_cfi')
19+
process.load('DQMOffline.ParticleFlow.runMini_cfi')
2020

2121

2222
with open('fileList.log') as f:

0 commit comments

Comments
 (0)