Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions JetAnalyzers/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<use name="DataFormats/HepMCCandidate"/>
<use name="DataFormats/ParticleFlowCandidate"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/PatCandidates"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="SimDataFormats/JetMatching"/>
<use name="PhysicsTools/Utilities"/>
Expand Down
759 changes: 759 additions & 0 deletions JetAnalyzers/XrdClFileSystem_v2.hh

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion JetAnalyzers/interface/JetResponseAnalyzer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"

#include "JetMETCorrections/Objects/interface/JetCorrector.h"

Expand Down Expand Up @@ -104,7 +105,8 @@ private:
//edm::EDGetTokenT<vector<reco::PFCandidate> > srcPFCandidates_;
edm::EDGetTokenT<PFCandidateView> srcPFCandidates_;
edm::EDGetTokenT<std::vector<edm::FwdPtr<reco::PFCandidate> > > srcPFCandidatesAsFwdPtr_;
edm::EDGetTokenT<vector<reco::GenParticle> > srcGenParticles_;
// edm::EDGetTokenT<vector<reco::GenParticle> > srcGenParticles_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove code, specifically commented code, which is no longer needed. If you need to switch back an forth you should consider using an `edm::View``` and then casting to the correct base type.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I removed the code that is no longer needed.

edm::EDGetTokenT<vector<pat::PackedGenParticle> > srcGenParticles_;

std::string jecLabel_;

Expand Down
8 changes: 4 additions & 4 deletions JetAnalyzers/python/Defaults_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
JetResponseParameters = cms.PSet(
# record flavor information, consider both RefPt and JetPt
doComposition = cms.bool(True),
doFlavor = cms.bool(True),
doFlavor = cms.bool(False),
doRefPt = cms.bool(True),
doJetPt = cms.bool(True),
saveCandidates = cms.bool(False),
# MATCHING MODE: deltaR(ref,jet)
deltaRMax = cms.double(0.25),
deltaRMax = cms.double(0.4),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been out of the loop for a while, so feel free to tell me I don't know the latest developments. That said, 0.4 seems awfully permissive for the deltaR matching. That's the entire cone radius for an R=0.4 jet. The default here should be the most often used value and should not change much. Is that why you changed this to 0.4.

Copy link

@magdadiamant magdadiamant Nov 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the confusion, this was actually a test version and we will fix it and upload the correct one with the values that were before. (However, this does not affect the results because we require dr max value of 0.2 in the MC Truth JECs derivation.)

# deltaR(ref,parton) IF doFlavor is True
deltaRPartonMax = cms.double(0.25),
deltaRPartonMax = cms.double(0.4),
# consider all matched references
nRefMax = cms.uint32(0),
# is the sample an HLT sample
Expand Down Expand Up @@ -76,7 +76,7 @@
dobalance = cms.bool(False),
doflavor = cms.bool(False),
noabsflavors = cms.bool(False),
drmax = cms.double(0.3),
drmax = cms.double(0.4),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would imagine this should match the value in the JetResponseParameters, so keep that in mind when answering my previous comment.

dphimin = cms.double(2.7),
dojetpt = cms.bool(False),
dorefpt = cms.bool(True),
Expand Down
4 changes: 3 additions & 1 deletion JetAnalyzers/python/JetReconstruction_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
#!
#! PF JETS CHS
#!
ak1PFCHSJets = ak1PFJets.clone( src = 'pfNoPileUpJME' )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these newlines to keep the style the same among the various sections of the code. You should strive to keep the formatting consistent throughout the code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!


ak1PFCHSJets = ak1PFJets.clone( src = 'pfCHS' )
ak2PFCHSJets = ak1PFCHSJets.clone( rParam=0.2 )
ak3PFCHSJets = ak1PFCHSJets.clone( rParam=0.3 )
ak4PFCHSJets = ak1PFCHSJets.clone( rParam=0.4 )
Expand Down
60 changes: 42 additions & 18 deletions JetAnalyzers/python/addAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
################################################################################

partons = cms.EDProducer('PartonSelector',
src = cms.InputTag('genParticles'),
src = cms.InputTag('packedGenParticles'),
withLeptons = cms.bool(False),
skipFirstN = cms.uint32(0)
)
Expand All @@ -20,6 +20,11 @@
from JetMETAnalysis.JetAnalyzers.JetCorrection_cff import *
from RecoTauTag.TauTagTools.tauDecayModes_cfi import *
from CommonTools.PileupAlgos.Puppi_cff import *
from JetMETAnalysis.JetAnalyzers.customizePuppiTune_cff import *


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this to 1 newline to maintain the style.


genParticlesForJetsNoNu.src = cms.InputTag("packedGenParticles")

stdClusteringAlgorithms = ['ak'] #Options: {ak,kt}
stdJetTypes = ['calo','pf','pfchs','puppi'] #Options: {'calo','pf','pfchs','puppi'}
Expand Down Expand Up @@ -102,6 +107,7 @@
stdRecJetsDict['ak5tauHPSall'] = 'hpsPFTauProducer'
recJetsDict['ak5tauHPSall'] = ('hpsPFTauProducer', hpsPFTauProducer)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

tauDiscriminatorDict = {
"ak5tauHPSlooseCombDBcorr" : "hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits",
"ak5tauHPSmediumCombDBcorr" : "hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits",
Expand Down Expand Up @@ -382,8 +388,26 @@ def addAlgorithm(process, alg_size_type_corr, Defaults, reco, doProducer):
sequence = cms.Sequence(recJets * sequence)
if type == 'PUPPI':
process.load('CommonTools.PileupAlgos.Puppi_cff')
process.load('JetMETAnalysis.JetAnalyzers.customizePuppiTune_cff')
#puppi.candName = cms.InputTag("particleFlow")
#80x change
puppiCentral[0].applyLowPUCorr = cms.bool(False)
puppiForward[0].applyLowPUCorr = cms.bool(False)
puppi.vertexName = "offlineSlimmedPrimaryVertices"

#UpdatePuppiTuneV14(process)



#puppi.UseFromPVLooseTight = cms.bool(False)
#puppi.UseDeltaZCut = cms.bool(False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused code. A history will be maintained in Git so nothing will be lost forever.

#puppi.PtMaxCharged = cms.double(20.)
#puppi.EtaMaxCharged = cms.double(2.5)
#puppi.PtMaxNeutralsStartSlope = cms.double(20.)

sequence = cms.Sequence(puppi * sequence)

#sequence = cms.Sequence(process.puppiMETSequence * process.fullPatMetSequencePuppi * process.patPuppiJetSpecificProducer * process.slimmedJetsPuppi * sequence)
if type == 'Track':
process.load('JetMETAnalysis.JetAnalyzers.TrackJetReconstruction_cff')
sequence = cms.Sequence(trackJetSequence * sequence)
Expand Down Expand Up @@ -505,10 +529,10 @@ def addAlgorithm(process, alg_size_type_corr, Defaults, reco, doProducer):
srcRhos = cms.InputTag(''),
srcRho = cms.InputTag(''),
srcRhoHLT = cms.InputTag(''),
srcVtx = cms.InputTag('offlinePrimaryVertices'),
srcVtx = cms.InputTag('offlineSlimmedPrimaryVertices'),
srcJetToUncorJetMap = cms.InputTag(jetToUncorJet.label(), 'rec2gen'),
srcPFCandidates = cms.InputTag(''),
srcGenParticles = cms.InputTag('genParticles')
srcGenParticles = cms.InputTag('packedGenParticles')
)
if doProducer:
jraAnalyzer = 'JetResponseAnalyzerProducer'
Expand All @@ -519,10 +543,10 @@ def addAlgorithm(process, alg_size_type_corr, Defaults, reco, doProducer):
jecLabel = cms.string(''),
srcRho = cms.InputTag(''),
srcRhoHLT = cms.InputTag(''),
srcVtx = cms.InputTag('offlinePrimaryVertices'),
srcVtx = cms.InputTag('offlineSlimmedPrimaryVertices'),
srcJetToUncorJetMap = cms.InputTag(jetToUncorJet.label(), 'rec2gen'),
srcPFCandidates = cms.InputTag(''),
srcGenParticles = cms.InputTag('genParticles')
srcGenParticles = cms.InputTag('packedGenParticles')
)

if type == 'CaloHLT':
Expand All @@ -531,35 +555,38 @@ def addAlgorithm(process, alg_size_type_corr, Defaults, reco, doProducer):
elif type == 'Calo':
jra.srcRho = cms.InputTag("fixedGridRhoFastjetAllCalo")
elif type == 'PFchs':
process.kt6PFchsJetsRhos = kt6PFJets.clone(src = 'pfNoPileUpJME',
process.pfCHS = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("fromPV"))
process.kt6PFchsJetsRhos = kt6PFJets.clone(src = 'pfCHS',
doFastJetNonUniform = cms.bool(True),
puCenters = cms.vdouble(-5,-4,-3,-2,-1,0,1,2,3,4,5),
puWidth = cms.double(.8),
nExclude = cms.uint32(2))
sequence = cms.Sequence(process.kt6PFchsJetsRhos * sequence)
sequence = cms.Sequence(process.pfCHS * process.kt6PFchsJetsRhos * sequence)
jra.srcRhos = cms.InputTag("kt6PFchsJetsRhos", "rhos")
jra.srcRho = cms.InputTag("fixedGridRhoFastjetAll")
jra.srcPFCandidates = cms.InputTag('pfNoPileUpJME')
jra.srcPFCandidates = cms.InputTag('pfCHS')
elif type == 'PFHLT':
jra.srcRho = ak4PFL1Fastjet.srcRho #added 02/15/2012
jra.srcRho = ak4PFL1Fastjet.srcRho
jra.srcRhoHLT = ak5PFHLTL1Fastjet.srcRho
elif type == 'PFchsHLT':
jra.srcRho = ak4PFchsL1Fastjet.srcRho #added 02/15/2012
jra.srcRho = ak4PFchsL1Fastjet.srcRho
jra.srcRhoHLT = ak5PFchsHLTL1Fastjet.srcRho
elif type == 'PF':
process.particleFlow = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string(""))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you recreating the particleFlow collection without any cuts? Why not just use the packedPFCandidates directly as inputs on line 583? Same comment for lines 585-589.

process.kt6PFJetsRhos = kt6PFJets.clone(doFastJetNonUniform = cms.bool(True),
puCenters = cms.vdouble(-5,-4,-3,-2,-1,0,1,2,3,4,5),
puWidth = cms.double(.8),
nExclude = cms.uint32(2))
sequence = cms.Sequence(process.kt6PFJetsRhos * sequence)
sequence = cms.Sequence(process.particleFlow * process.kt6PFJetsRhos * sequence)
jra.srcRhos = cms.InputTag("kt6PFJetsRhos", "rhos")
jra.srcRho = cms.InputTag("fixedGridRhoFastjetAll")
jra.srcPFCandidates = cms.InputTag('particleFlow')
jra.srcPFCandidates = cms.InputTag('packedPFCandidates')
elif type == 'PUPPI':
process.particleFlow = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string(""))
process.kt6PFJetsRhos = kt6PFJets.clone(doFastJetNonUniform = cms.bool(True),
puCenters = cms.vdouble(-5,-4,-3,-2,-1,0,1,2,3,4,5),
puWidth = cms.double(.8), nExclude = cms.uint32(2))
sequence = cms.Sequence(process.kt6PFJetsRhos * sequence)
sequence = cms.Sequence(process.particleFlow * process.kt6PFJetsRhos * sequence)
jra.srcRhos = cms.InputTag("kt6PFJetsRhos", "rhos")
jra.srcRho = cms.InputTag("fixedGridRhoFastjetAll")
jra.srcPFCandidates = cms.InputTag('puppi')
Expand All @@ -575,13 +602,10 @@ def addAlgorithm(process, alg_size_type_corr, Defaults, reco, doProducer):
setattr(process,alg_size_type_corr,jra)
sequence = cms.Sequence(sequence * jra)

## add chs to path is needed
if type == 'PFchs':
sequence = cms.Sequence(process.pfNoPileUpJMESequence * sequence)

## create the path and put in the sequence

sequence = cms.Sequence(sequence)
setattr(process, alg_size_type_corr + 'Sequence', sequence)
path = cms.Path( sequence )
setattr(process, alg_size_type_corr + 'Path', path)

print alg_size_type_corr
86 changes: 67 additions & 19 deletions JetAnalyzers/src/JetResponseAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ JetResponseAnalyzer::JetResponseAnalyzer(const edm::ParameterSet& iConfig)
, srcRhoHLT_ (consumes<double>(iConfig.getParameter<edm::InputTag> ("srcRhoHLT")))
, srcVtx_ (consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag> ("srcVtx")))
, srcGenInfo_ (consumes<GenEventInfoProduct>(edm::InputTag("generator")) )
, srcPileupInfo_ (consumes<vector<PileupSummaryInfo> >(edm::InputTag("addPileupInfo")) )
, srcPileupInfo_ (consumes<vector<PileupSummaryInfo> >(edm::InputTag("slimmedAddPileupInfo")) )
//, srcPFCandidates_ (consumes<vector<reco::PFCandidate> >(iConfig.getParameter<edm::InputTag>("srcPFCandidates")))
, srcPFCandidates_ (consumes<PFCandidateView>(iConfig.getParameter<edm::InputTag>("srcPFCandidates")))
, srcPFCandidatesAsFwdPtr_(consumes<std::vector<edm::FwdPtr<reco::PFCandidate> > >(iConfig.getParameter<edm::InputTag>("srcPFCandidates")))
, srcGenParticles_ (consumes<vector<reco::GenParticle> >(iConfig.getParameter<edm::InputTag>("srcGenParticles")))
, srcGenParticles_ (consumes<vector<pat::PackedGenParticle> >(iConfig.getParameter<edm::InputTag>("srcGenParticles")))
, jecLabel_ (iConfig.getParameter<std::string> ("jecLabel"))
, doComposition_ (iConfig.getParameter<bool> ("doComposition"))
, doFlavor_ (iConfig.getParameter<bool> ("doFlavor"))
Expand Down Expand Up @@ -115,6 +115,50 @@ void JetResponseAnalyzer::beginJob()
}



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to match the style for this entire section (the getMult function).




void getMult( vector<reco::CandidatePtr> const & particles, int* nMult, int* chMult ) {

vector<reco::CandidatePtr>::const_iterator itParticle;
for (itParticle=particles.begin();itParticle!=particles.end();++itParticle){
const reco::Candidate* pfCand = itParticle->get();

switch (std::abs(pfCand->pdgId())) {

case 211: //PFCandidate::h: // charged hadron
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use unnamed constants. Instead, you should define enums as in

enum Flavor{all=0, h, e, mu, gamma, h0, h_HF, egamma_HF, chs, numFlavors, X}; //X=undefined
and use those as your cases.

You also only really have two cases:

  1. You add one to the nMult variable
  2. You add one to the chMult variable
    You should combine these cases using and OR of the conditions inside if, else if, else statements. This will reduce the number of comparisons. You can use the std::any_of function to reduce the verbosity of the conditional (https://www.cplusplus.com/reference/algorithm/any_of/).

(*chMult)++;
break;

case 130: //PFCandidate::h0 : // neutral hadron
(*nMult)++;
break;

case 22: //PFCandidate::gamma: // photon
(*nMult)++;
break;

case 11: // PFCandidate::e: // electron
(*chMult)++;
break;

case 13: //PFCandidate::mu: // muon
(*chMult)++;
break;

case 1: // PFCandidate::h_HF : // hadron in HF
(*nMult)++;
break;

case 2: //PFCandidate::egamma_HF : // electromagnetic in HF
(*nMult)++;
break;
}
}
}

//_______________
//______________________________________________________________________________
void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
const edm::EventSetup& iSetup)
Expand All @@ -134,7 +178,7 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
edm::Handle<reco::VertexCollection> vtx;
edm::Handle<PFCandidateView> pfCandidates;
edm::Handle<std::vector<edm::FwdPtr<reco::PFCandidate> > > pfCandidatesAsFwdPtr;
edm::Handle<vector<reco::GenParticle> > genParticles;
edm::Handle<vector<pat::PackedGenParticle> > genParticles;

// Jet CORRECTOR
jetCorrector_ = (jecLabel_.empty()) ? 0 : JetCorrector::getJetCorrector(jecLabel_,iSetup);
Expand Down Expand Up @@ -189,8 +233,8 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
JRAEvt_->refpvz = -1000.0;
iEvent.getByToken(srcGenParticles_, genParticles);
for (size_t i = 0; i < genParticles->size(); ++i) {
const reco::GenParticle & genIt = (*genParticles)[i];
if ( genIt.isHardProcess() ) {
const pat::PackedGenParticle & genIt = (*genParticles)[i];
if ( genIt.fromHardProcessFinalState() ) {
JRAEvt_->refpvz = genIt.vz();
break;
}
Expand Down Expand Up @@ -257,18 +301,19 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
JRAEvt_->refdphijt->push_back(reco::deltaPhi(jet->phi(),ref->phi()));
else
JRAEvt_->refdrjt->push_back(reco::deltaR(jet->eta(),jet->phi(),ref->eta(),ref->phi()));

if ((!doBalancing_&&JRAEvt_->refdrjt->at(JRAEvt_->nref)>deltaRMax_)||
(doBalancing_&&std::abs(JRAEvt_->refdphijt->at(JRAEvt_->nref))<deltaPhiMin_)) {
if(doBalancing_) JRAEvt_->refdphijt->pop_back();
else JRAEvt_->refdrjt->pop_back();
continue;
}

JRAEvt_->refpdgid->push_back(0);
JRAEvt_->refpdgid_algorithmicDef->push_back(0);
JRAEvt_->refpdgid_physicsDef->push_back(0);

if (getFlavorFromMap_) {
JRAEvt_->refpdgid_algorithmicDef->push_back(0);
JRAEvt_->refpdgid_physicsDef->push_back(0);

reco::JetMatchedPartonsCollection::const_iterator itPartonMatch;
itPartonMatch=refToPartonMap->begin();
for (;itPartonMatch!=refToPartonMap->end();++itPartonMatch) {
Expand All @@ -277,7 +322,7 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
const reco::Candidate* cand = &(*jetRef);
if (cand==&(*ref)) break;
}

if (itPartonMatch!=refToPartonMap->end()&&
itPartonMatch->second.algoDefinitionParton().get()!=0&&
itPartonMatch->second.physicsDefinitionParton().get()!=0) {
Expand Down Expand Up @@ -315,10 +360,6 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
}
}
}
else {
JRAEvt_->refpdgid_algorithmicDef->at(JRAEvt_->nref)=0;
JRAEvt_->refpdgid_physicsDef->at(JRAEvt_->nref)=0;
}
JRAEvt_->refpdgid->at(JRAEvt_->nref)=ref->pdgId();

// Beta/Beta Star Calculation
Expand Down Expand Up @@ -439,12 +480,21 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
JRAEvt_->jtmuf ->push_back(pfJetRef->muonEnergyFraction() *JRAEvt_->jtjec->at(JRAEvt_->nref));
JRAEvt_->jthfhf->push_back(pfJetRef->HFHadronEnergyFraction() *JRAEvt_->jtjec->at(JRAEvt_->nref));
JRAEvt_->jthfef->push_back(pfJetRef->HFEMEnergyFraction() *JRAEvt_->jtjec->at(JRAEvt_->nref));
int chMult=0, nMult=0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing issue

getMult( ref.castTo<reco::GenJetRef>()->getJetConstituents(), &nMult, &chMult );
JRAEvt_->refnMult ->push_back( nMult );
JRAEvt_->refchMult->push_back( chMult );

//this method exists for pfjets (neutralMultiplicity()), but not for genjets
//original i thought since genjet didn't have it i should make this method
chMult=0; nMult=0;
getMult( jet.castTo<reco::PFJetRef>()->getJetConstituents(), &nMult, &chMult );
JRAEvt_->jtnMult ->push_back( nMult );
JRAEvt_->jtchMult->push_back( chMult );
}
}

JRAEvt_->nref++;
}

// PFCANDIDATE INFORMATION
//Dual handle idea from https://github.com/aperloff/cmssw/blob/CMSSW_7_6_X/RecoJets/JetProducers/plugins/VirtualJetProducer.cc
//Random-Cone algo from https://github.com/cihar29/OffsetAnalysis/blob/master/run_offset.py
Expand Down Expand Up @@ -483,10 +533,8 @@ void JetResponseAnalyzer::analyze(const edm::Event& iEvent,
}
}
}


tree_->Fill();

return;
}

Expand Down
Loading