Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NanoAOD update 10XY version (master version of #23445) #23446

Merged
merged 59 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a9ba3f6
fix dqm
arizzi Apr 9, 2018
465c4fa
BadGlobalMuonTagger -> add a boolean flagging the event as good or bad
Apr 18, 2018
a8c054a
NanoAOD file to run the bad muon / bad charged hadron modules + a tab…
Apr 18, 2018
4c8e9db
Add the extra flags producers and table to 80X for nanoaod (flags pre…
Apr 18, 2018
9f7accb
Use the correct bad charged hadron module for the full 2016 dataset
Apr 18, 2018
073088d
Rename bad charged hadron flag for consistency with 94X flags
Apr 18, 2018
078366b
Add a flag for the BadPFMuonFilter module in 80X nanoAOD
Apr 18, 2018
bc6eca0
Added my own version of triggerObjects_cff.py witn modified e and mu …
rdewanje Apr 10, 2018
b9c697c
Updated e, mu and tau sections triggerObjects_cff.py for better reada…
rdewanje Apr 10, 2018
672287c
Fix syntax errors in HLT filter expressions
ktht Apr 13, 2018
1eafd4e
Added the new HLT filter logic for e/mu/tau
rdewanje Apr 20, 2018
6c0029c
Added the latest changes to the HLT bit masks for e, mu and tau objects
rdewanje Apr 25, 2018
7906f35
Corrected the qualityBitsDoc line FOR Electron setting bits: 2 = 1e (…
rdewanje Apr 25, 2018
a65ae20
Minor modifications in qualityBits for Electron to make them have the…
rdewanje Apr 25, 2018
84ba040
Added b-tag SF EDProducer to get event weights, configs in nano_cff, …
Mar 15, 2018
b36518f
Modified BTagSFProducer and config to produce one weight table for mu…
Mar 18, 2018
dcccc9e
Added era switches, added default output of 1.0 for the eras where SF…
Mar 19, 2018
be182a2
Minor change
Mar 19, 2018
e04ce58
Edited BTagSFProducer to not produce any branch for b-taggers marked …
Mar 19, 2018
22027f8
Saving Discriminator Reshaping weights; added latest SF .csv files
arizzi Jun 3, 2018
443d6f5
Using jet.hadronFlavour() instead of jet.partonFlavour()
Apr 30, 2018
53666c5
Adapting GenWeightsTableProducer to work with new header file format …
adewit May 15, 2018
3f695e4
Assigning bools with explicit true/false instead of 0/1
adewit May 16, 2018
e84506a
Reducing code duplication in GenWeightsTableProducer
adewit May 16, 2018
89736f7
Perform all bracket replacements in initial loop
adewit May 17, 2018
591920b
Removing redundant if statement
adewit May 17, 2018
db498d8
bug fix, wrong input tag used
arizzi May 17, 2018
ee6fdf6
Add PS weights to GenWeightsTableProducer
adewit May 22, 2018
7697afa
first version of tensorflow support for MVA value map producer
arizzi Apr 6, 2018
f7779bc
adding regression variables
leonardogiannini Mar 14, 2018
af349bd
adding jet energy rings needed for b-jet regression
nadya-chernyavskaya Mar 23, 2018
a755df8
£target
leonardogiannini Mar 24, 2018
2df1fb8
target
leonardogiannini Mar 24, 2018
98fabdb
ptRel simple def
leonardogiannini Apr 6, 2018
39b0ead
first version of bjet NN tensorflow regression
arizzi Apr 6, 2018
52019f4
nadya's regression
arizzi Apr 10, 2018
bf213de
do not add unexpected vars, silence printout
arizzi Apr 10, 2018
98622f9
NN regression for b-jets, modified inputs
nadya-chernyavskaya Apr 11, 2018
f0bfbb0
Update jets_cff.py
Apr 11, 2018
4a39178
enable only working version
arizzi May 7, 2018
46dc6f1
remove variables needed for training from nano
arizzi May 7, 2018
2115d6d
better naming and remove second version
arizzi May 7, 2018
748df7c
readd deep flav
arizzi May 7, 2018
692914b
code checks and 80Xlegacy fix
arizzi May 8, 2018
1dfd71f
reduce precision of resolution, remove old reg, add dqm
arizzi May 8, 2018
6cb7642
add DeepCSV to 80X samples
arizzi May 9, 2018
f5ee560
add qgtagger for 80X
arizzi May 9, 2018
0150b51
updated rms and mean for new training
arizzi May 9, 2018
8e7db2a
restore cut at 15 GeV
arizzi May 9, 2018
4fbd56a
enable re-btag only for 80X
arizzi May 23, 2018
1a9886e
remove nPV normalization
arizzi May 23, 2018
82d3ed1
fix b-regression target
arizzi May 24, 2018
6adba45
remove legacy regression, fix dqm
arizzi Jun 3, 2018
7a4a65f
fix code-checks
arizzi Jun 4, 2018
7cc8509
use FileInPath
arizzi Jun 4, 2018
a26d44a
fix conflict
arizzi Jun 6, 2018
41e6b51
style cleanup
arizzi Jun 6, 2018
dd1e24d
Remove include
gpetruc Jul 5, 2018
355f35c
Merge pull request #37 from gpetruc/nanoAODrebasedMasterWithoutData10XY
arizzi Jul 5, 2018
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
123 changes: 77 additions & 46 deletions PhysicsTools/NanoAOD/plugins/BJetEnergyRegressionMVA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class BJetEnergyRegressionMVA : public BaseMVAValueMapProducer<pat::Jet> {
explicit BJetEnergyRegressionMVA(const edm::ParameterSet &iConfig):
BaseMVAValueMapProducer<pat::Jet>(iConfig),
pvsrc_(edm::stream::EDProducer<>::consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("pvsrc"))),
svsrc_(edm::stream::EDProducer<>::consumes<edm::View<reco::VertexCompositePtrCandidate>> (iConfig.getParameter<edm::InputTag>("svsrc")))
svsrc_(edm::stream::EDProducer<>::consumes<edm::View<reco::VertexCompositePtrCandidate>> (iConfig.getParameter<edm::InputTag>("svsrc"))),
rhosrc_(edm::stream::EDProducer<>::consumes<double> (iConfig.getParameter<edm::InputTag>("rhosrc")))

{

Expand All @@ -42,65 +43,95 @@ class BJetEnergyRegressionMVA : public BaseMVAValueMapProducer<pat::Jet> {
void readAdditionalCollections(edm::Event&iEvent, const edm::EventSetup&) override {
iEvent.getByToken(pvsrc_, pvs_);
iEvent.getByToken(svsrc_, svs_);
}

void fillAdditionalVariables(const pat::Jet&j) override {
this->setValue("nPVs",pvs_->size());
BaseMVAValueMapProducer<pat::Jet>::setValue("Jet_leptonPtRel",0);

if(!j.overlaps("muons").empty()) {
const auto *lep=dynamic_cast<const pat::Muon *>(&*j.overlaps("muons")[0]);
if(lep!=nullptr) {BaseMVAValueMapProducer<pat::Jet>::setValue("Jet_leptonPtRel",lep->userFloat("ptRel"));}
}
else if(!j.overlaps("electrons").empty()) {
const auto *lep=dynamic_cast<const pat::Electron *>(&*j.overlaps("electrons")[0]);
if(lep!=nullptr) {BaseMVAValueMapProducer<pat::Jet>::setValue("Jet_leptonPtRel",lep->userFloat("ptRel"));}
}

float ptMax=0;
for(const auto & d : j.daughterPtrVector()){if(d->pt()>ptMax) ptMax=d->pt();}
BaseMVAValueMapProducer<pat::Jet>::setValue("Jet_leadTrackPt",ptMax);

//Fill vertex properties
VertexDistance3D vdist;
float maxFoundSignificance=0;
const auto & pv = (*pvs_)[0];
this->setValue("Jet_vtxPt",0);
this->setValue("Jet_vtxMass",0);
this->setValue("Jet_vtx3dL",0);
this->setValue("Jet_vtx3deL",0);
this->setValue("Jet_vtxNtrk",0);

for(const auto &sv: *svs_){
GlobalVector flightDir(sv.vertex().x() - pv.x(), sv.vertex().y() - pv.y(),sv.vertex().z() - pv.z());
GlobalVector jetDir(j.px(),j.py(),j.pz());
if( Geom::deltaR2( flightDir, jetDir ) < 0.09 ){
Measurement1D dl= vdist.distance(pv,VertexState(RecoVertex::convertPos(sv.position()),RecoVertex::convertError(sv.error())));
if(dl.significance() > maxFoundSignificance){
maxFoundSignificance=dl.significance();
this->setValue("Jet_vtxPt",sv.pt());
this->setValue("Jet_vtxMass",sv.p4().M());
this->setValue("Jet_vtx3dL",dl.value());
this->setValue("Jet_vtx3deL",dl.error());
this->setValue("Jet_vtxNtrk",sv.numberOfSourceCandidatePtrs());
}
}
}
iEvent.getByToken(rhosrc_,rho_);

}

void fillAdditionalVariables(const pat::Jet&j) override {

this->setValue("nPVs",pvs_->size());
this->setValue("rho",*(rho_.product()));


float cone_boundaries[] = { 0.05, 0.1, 0.2, 0.3,0.4 };
size_t ncone_boundaries = sizeof(cone_boundaries)/sizeof(float);
Copy link
Contributor

Choose a reason for hiding this comment

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

use std::array<float>

std::vector<float> emFractionEnergyRings(ncone_boundaries+1);
std::vector<float> chFractionEnergyRings(ncone_boundaries+1);
std::vector<float> neFractionEnergyRings(ncone_boundaries+1);
std::vector<float> muFractionEnergyRings(ncone_boundaries+1);
float jetRawEnergy=j.p4().E()*j.jecFactor("Uncorrected");
int numDaughtersPt03=0;
for (unsigned int ijcone = 0; ijcone<ncone_boundaries; ijcone++){
emFractionEnergyRings[ijcone] = 0;
muFractionEnergyRings[ijcone] = 0;
chFractionEnergyRings[ijcone] = 0;
neFractionEnergyRings[ijcone] = 0;
}
for(const auto & d : j.daughterPtrVector()){
float candDr = Geom::deltaR(d->p4(),j.p4());
Copy link
Contributor

Choose a reason for hiding this comment

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

reco::deltaR

size_t icone = std::lower_bound(&cone_boundaries[0],&cone_boundaries[ncone_boundaries],candDr) - &cone_boundaries[0];
float candEnergy = d->energy()/jetRawEnergy;
int pdgid = abs(d->pdgId()) ;
if( pdgid == 22 || pdgid == 11 ) {
emFractionEnergyRings[icone] += candEnergy;
} else if ( pdgid == 13 ) {
muFractionEnergyRings[icone] += candEnergy;
} else if ( d->charge() != 0 ) {
chFractionEnergyRings[icone] += candEnergy;
} else {
neFractionEnergyRings[icone] += candEnergy;
}
if(d->pt()>0.3) numDaughtersPt03+=1;
} // end of jet daughters loop

this->setValue("Jet_energyRing_dR0_em_Jet_rawEnergy", emFractionEnergyRings[0]);
this->setValue("Jet_energyRing_dR1_em_Jet_rawEnergy", emFractionEnergyRings[1]);
this->setValue("Jet_energyRing_dR2_em_Jet_rawEnergy", emFractionEnergyRings[2]);
this->setValue("Jet_energyRing_dR3_em_Jet_rawEnergy", emFractionEnergyRings[3]);
this->setValue("Jet_energyRing_dR4_em_Jet_rawEnergy", emFractionEnergyRings[4]);
// this->setValue("Jet_energyRing_dR5_em_Jet_rawEnergy", emFractionEnergyRings[5]);

this->setValue("Jet_energyRing_dR0_ch_Jet_rawEnergy", chFractionEnergyRings[0]);
this->setValue("Jet_energyRing_dR1_ch_Jet_rawEnergy", chFractionEnergyRings[1]);
this->setValue("Jet_energyRing_dR2_ch_Jet_rawEnergy", chFractionEnergyRings[2]);
this->setValue("Jet_energyRing_dR3_ch_Jet_rawEnergy", chFractionEnergyRings[3]);
this->setValue("Jet_energyRing_dR4_ch_Jet_rawEnergy", chFractionEnergyRings[4]);
// this->setValue("Jet_energyRing_dR5_ch_Jet_rawEnergy", chFractionEnergyRings[5]);

this->setValue("Jet_energyRing_dR0_mu_Jet_rawEnergy", muFractionEnergyRings[0]);
this->setValue("Jet_energyRing_dR1_mu_Jet_rawEnergy", muFractionEnergyRings[1]);
this->setValue("Jet_energyRing_dR2_mu_Jet_rawEnergy", muFractionEnergyRings[2]);
this->setValue("Jet_energyRing_dR3_mu_Jet_rawEnergy", muFractionEnergyRings[3]);
this->setValue("Jet_energyRing_dR4_mu_Jet_rawEnergy", muFractionEnergyRings[4]);
// this->setValue("Jet_energyRing_dR5_mu_Jet_rawEnergy", muFractionEnergyRings[5]);

this->setValue("Jet_energyRing_dR0_neut_Jet_rawEnergy", neFractionEnergyRings[0]);
this->setValue("Jet_energyRing_dR1_neut_Jet_rawEnergy", neFractionEnergyRings[1]);
this->setValue("Jet_energyRing_dR2_neut_Jet_rawEnergy", neFractionEnergyRings[2]);
this->setValue("Jet_energyRing_dR3_neut_Jet_rawEnergy", neFractionEnergyRings[3]);
this->setValue("Jet_energyRing_dR4_neut_Jet_rawEnergy", neFractionEnergyRings[4]);
// this->setValue("Jet_energyRing_dR5_neut_Jet_rawEnergy", neFractionEnergyRings[5]);

this->setValue("Jet_numDaughters_pt03",numDaughtersPt03);

}

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc = BaseMVAValueMapProducer<pat::Jet>::getDescription();
desc.add<edm::InputTag>("pvsrc")->setComment("primary vertices input collection");
desc.add<edm::InputTag>("svsrc")->setComment("secondary vertices input collection");
desc.add<edm::InputTag>("rhosrc")->setComment("rho input collection");
descriptions.add("BJetEnergyRegressionMVA",desc);
}

private:
const edm::EDGetTokenT<std::vector<reco::Vertex>> pvsrc_;
edm::Handle<std::vector<reco::Vertex>> pvs_;
const edm::EDGetTokenT<edm::View<reco::VertexCompositePtrCandidate> > svsrc_;
const edm::EDGetTokenT<edm::View<reco::VertexCompositePtrCandidate> > svsrc_;
edm::Handle<edm::View<reco::VertexCompositePtrCandidate>> svs_;
edm::EDGetTokenT<double> rhosrc_;
edm::Handle<double> rho_;


};

Expand Down
Loading