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

Adding chsMET and trackMET to miniAOD #20655

Merged
merged 14 commits into from
Oct 17, 2017
Merged
Prev Previous commit
Next Next commit
new approach of adding the variables as a slimmedMETs variation
  • Loading branch information
zdemirag committed Sep 29, 2017
commit b226afbf0174c5605e9d356d6b5a6bb6160353ae
34 changes: 2 additions & 32 deletions DataFormats/PatCandidates/interface/MET.h
Original file line number Diff line number Diff line change
@@ -76,26 +76,6 @@ namespace pat {
// get the MET significance
double metSignificance() const;

// ----- CHS MET functions ----
// set CHS MET
void setCHSMETpt(const double& chsMETpt);
void setCHSMETphi(const double& chsMETphi);
void setCHSMETsumEt(const double& chsMETsumEt);
// get CHS MET
double CHSMETpt() const;
double CHSMETphi() const;
double CHSMETsumEt() const;

// ----- Track MET functions ----
// set Track MET
void setTrkMETpt(const double& trkMETpt);
void setTrkMETphi(const double& trkMETphi);
void setTrkMETsumEt(const double& trkMETsumEt);
// get Track MET
double TrkMETpt() const;
double TrkMETphi() const;
double TrkMETsumEt() const;

// ---- methods for uncorrected MET ----
// Methods not yet defined
//float uncorrectedPt() const;
@@ -178,12 +158,12 @@ namespace pat {
enum METCorrectionLevel {
Raw=0, Type1=1, Type01=2, TypeXY=3, Type1XY=4, Type01XY=5,
Type1Smear=6, Type01Smear=7, Type1SmearXY=8,
Type01SmearXY=9, RawCalo=10, METCorrectionLevelSize=11
Type01SmearXY=9, RawCalo=10, RawChs=11, RawTrk=12, METCorrectionLevelSize=13
Copy link
Contributor

Choose a reason for hiding this comment

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

Please indent as for the other lines

};
enum METCorrectionType {
None=0, T1=1, T0=2, TXY=3, TXYForRaw=4,
TXYForT01=5, TXYForT1Smear=6, TXYForT01Smear=7,
Smear=8, Calo=9, METCorrectionTypeSize=10
Smear=8, Calo=9, Chs=10, Trk=11, METCorrectionTypeSize=12
Copy link
Contributor

Choose a reason for hiding this comment

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

Please indent as for the other lines

};

struct Vector2 {
@@ -271,16 +251,6 @@ namespace pat {
// MET significance
double metSig_;

// MET CHS
double chsMETpt_;
double chsMETphi_;
double chsMETsumEt_;

// MET Track
double trkMETpt_;
double trkMETphi_;
double trkMETsumEt_;

const PackedMETUncertainty findMETTotalShift(MET::METCorrectionLevel cor, MET::METUncertainty shift) const;

std::map<MET::METCorrectionLevel, std::vector<MET::METCorrectionType> > corMap_;
101 changes: 10 additions & 91 deletions DataFormats/PatCandidates/src/MET.cc
Original file line number Diff line number Diff line change
@@ -23,12 +23,6 @@ MET::MET(const reco::MET & aMET) : PATObject<reco::MET>(aMET) {
if (pm != nullptr) this->operator=(*pm);

metSig_ =0.;
chsMETpt_ =0.;
chsMETphi_ =0.;
chsMETsumEt_ =0.;
trkMETpt_ =0.;
trkMETphi_ =0.;
trkMETsumEt_ =0.;
initCorMap();
}

@@ -43,12 +37,6 @@ MET::MET(const edm::RefToBase<reco::MET> & aMETRef) : PATObject<reco::MET>(aMETR
if (pm != nullptr) this->operator=(*pm);

metSig_ =0.;
chsMETpt_ =0.;
chsMETphi_ =0.;
chsMETsumEt_ =0.;
trkMETpt_ =0.;
trkMETphi_ =0.;
trkMETsumEt_ =0.;
initCorMap();
}

@@ -62,12 +50,6 @@ MET::MET(const edm::Ptr<reco::MET> & aMETRef) : PATObject<reco::MET>(aMETRef) {
if (pm != nullptr) this->operator=(*pm);

metSig_ =0.;
chsMETpt_ = 0.;
chsMETphi_ =0.;
chsMETsumEt_ =0.;
trkMETpt_ =0.;
trkMETphi_ =0.;
trkMETsumEt_ =0.;
initCorMap();
}

@@ -78,12 +60,6 @@ genMET_(iOther.genMET_),
caloMET_(iOther.caloMET_),
pfMET_(iOther.pfMET_),
metSig_(iOther.metSig_),
chsMETpt_(iOther.chsMETpt_),
chsMETphi_(iOther.chsMETphi_),
chsMETsumEt_(iOther.chsMETsumEt_),
trkMETpt_(iOther.trkMETpt_),
trkMETphi_(iOther.trkMETphi_),
trkMETsumEt_(iOther.trkMETsumEt_),
uncertaintiesRaw_(iOther.uncertaintiesRaw_), //74X reading compatibility
uncertaintiesType1_(iOther.uncertaintiesType1_), //74X compatibility
uncertaintiesType1p2_(iOther.uncertaintiesType1p2_), //74X compatibility
@@ -102,12 +78,6 @@ genMET_(srcMET.genMET_),
caloMET_(srcMET.caloMET_),
pfMET_(srcMET.pfMET_),
metSig_(srcMET.metSig_),
chsMETpt_(srcMET.chsMETpt_),
chsMETphi_(srcMET.chsMETphi_),
chsMETsumEt_(srcMET.chsMETsumEt_),
trkMETpt_(srcMET.trkMETpt_),
trkMETphi_(srcMET.trkMETphi_),
trkMETsumEt_(srcMET.trkMETsumEt_),
caloPackedMet_(srcMET.caloPackedMet_) {

setSignificanceMatrix(srcMET.getSignificanceMatrix());
@@ -131,12 +101,6 @@ MET& MET::operator=(MET const& iOther) {
uncertainties_ = iOther.uncertainties_;
corrections_ = iOther.corrections_;
metSig_ = iOther.metSig_;
chsMETpt_ = iOther.chsMETpt_;
chsMETphi_ = iOther.chsMETphi_;
chsMETsumEt_ = iOther.chsMETsumEt_;
trkMETpt_ = iOther.trkMETpt_;
trkMETphi_ = iOther.trkMETphi_;
trkMETsumEt_ = iOther.trkMETsumEt_;
caloPackedMet_ = iOther.caloPackedMet_;

return *this;
@@ -163,61 +127,6 @@ double MET::metSignificance() const {
return metSig_;
}

//Method to set the CHS MET
void MET::setCHSMETpt(const double& chsMETpt) {
chsMETpt_ = chsMETpt;
}

double MET::CHSMETpt() const {
return chsMETpt_;
}

//Method to set the CHS MET
void MET::setCHSMETphi(const double& chsMETphi) {
chsMETphi_ = chsMETphi;
}

double MET::CHSMETphi() const {
return chsMETphi_;
}

//Method to set the CHS MET
void MET::setCHSMETsumEt(const double& chsMETsumEt) {
chsMETsumEt_ = chsMETsumEt;
}

double MET::CHSMETsumEt() const {
return chsMETsumEt_;
}

//Method to set the Track MET
void MET::setTrkMETpt(const double& trkMETpt) {
trkMETpt_ = trkMETpt;
}

double MET::TrkMETpt() const {
return trkMETpt_;
}

//Method to set the CHS MET
void MET::setTrkMETphi(const double& trkMETphi) {
trkMETphi_ = trkMETphi;
}

double MET::TrkMETphi() const {
return trkMETphi_;
}

//Method to set the CHS MET
void MET::setTrkMETsumEt(const double& trkMETsumEt) {
trkMETsumEt_ = trkMETsumEt;
}

double MET::TrkMETsumEt() const {
return trkMETsumEt_;
}


void
MET::initCorMap() {

@@ -274,6 +183,16 @@ MET::initCorMap() {
std::vector<MET::METCorrectionType> tmpRawCalo;
tmpRawCalo.push_back(MET::Calo);
corMap_[MET::RawCalo] = tmpRawCalo;

//specific chs case
std::vector<MET::METCorrectionType> tmpRawChs;
tmpRawChs.push_back(MET::Chs);
corMap_[MET::RawChs] = tmpRawChs;

//specific chs case
Copy link
Contributor

Choose a reason for hiding this comment

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

//specific trk case

std::vector<MET::METCorrectionType> tmpRawTrk;
tmpRawTrk.push_back(MET::Trk);
corMap_[MET::RawTrk] = tmpRawTrk;
}

const MET::PackedMETUncertainty
3 changes: 2 additions & 1 deletion DataFormats/PatCandidates/src/classes_def_objects.xml
Original file line number Diff line number Diff line change
@@ -243,7 +243,8 @@
<ioread sourceClass = "pat::Jet" version="[1-11]" targetClass="pat::Jet" source="int partonFlavour_" target="jetFlavourInfo_">
<![CDATA[jetFlavourInfo_ = reco::JetFlavourInfo(0,onfile.partonFlavour_);]]>
</ioread>
<class name="pat::MET" ClassVersion="17">
<class name="pat::MET" ClassVersion="18">
<version ClassVersion="18" checksum="428901429"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

What are ClassVersion 16 and 17 for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as we were changing the code, there were a couple of times we edited the pat MET class, and to get to compile we had to increment it. please let us know if need to fix it some other way

Copy link
Contributor

Choose a reason for hiding this comment

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

Please cancel the intermediate ones and put classversion 16 in the most recent one

<version ClassVersion="17" checksum="2630287804"/>
<version ClassVersion="16" checksum="4025491907"/>
<version ClassVersion="15" checksum="428901429"/>
22 changes: 0 additions & 22 deletions PhysicsTools/PatAlgos/plugins/PATMETProducer.cc
Original file line number Diff line number Diff line change
@@ -21,10 +21,6 @@ PATMETProducer::PATMETProducer(const edm::ParameterSet & iConfig):
// initialize the configurables
metSrc_ = iConfig.getParameter<edm::InputTag>("metSource");
metToken_ = consumes<edm::View<reco::MET> >(metSrc_);
chsmetSrc_ = iConfig.getParameter<edm::InputTag>("chsmetSource");
chsmetToken_ = consumes<edm::View<reco::MET> >(chsmetSrc_);
trkmetSrc_ = iConfig.getParameter<edm::InputTag>("trkmetSource");
trkmetToken_ = consumes<edm::View<reco::MET> >(trkmetSrc_);
addGenMET_ = iConfig.getParameter<bool> ("addGenMET");
genMETToken_ = mayConsume<edm::View<reco::GenMET> >(iConfig.getParameter<edm::InputTag>("genMETSource"));
addResolutions_ = iConfig.getParameter<bool> ("addResolutions");
@@ -88,12 +84,6 @@ void PATMETProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
iEvent.getByToken(genMETToken_, genMETs);
}

edm::Handle<edm::View<reco::MET> > chsMETs;
iEvent.getByToken(chsmetToken_, chsMETs);

edm::Handle<edm::View<reco::MET> > trkMETs;
iEvent.getByToken(trkmetToken_, trkMETs);

// loop over mets
std::vector<MET> * patMETs = new std::vector<MET>();
for (edm::View<reco::MET>::const_iterator itMET = mets->begin(); itMET != mets->end(); itMET++) {
@@ -106,17 +96,6 @@ void PATMETProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
if (addGenMET_) amet.setGenMET((*genMETs)[idx]);


if (chsMETs.isValid()){
amet.setCHSMETpt((*chsMETs)[idx].pt());
amet.setCHSMETphi((*chsMETs)[idx].phi());
amet.setCHSMETsumEt((*chsMETs)[idx].sumEt());
}
if (trkMETs.isValid()){
amet.setTrkMETpt((*trkMETs)[idx].pt());
amet.setTrkMETphi((*trkMETs)[idx].phi());
amet.setTrkMETsumEt((*trkMETs)[idx].sumEt());
}

//add the MET significance
if(calculateMETSignificance_) {
const reco::METCovMatrix& sigcov = getMETCovMatrix(iEvent, iSetup);
@@ -138,7 +117,6 @@ void PATMETProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup
userDataHelper_.add( amet, iEvent, iSetup );
}


// correct for muons if demanded... never more: it's now done by JetMETCorrections
// add the MET to the vector of METs
patMETs->push_back(amet);
4 changes: 0 additions & 4 deletions PhysicsTools/PatAlgos/plugins/PATMETProducer.h
Original file line number Diff line number Diff line change
@@ -51,10 +51,6 @@ namespace pat {
// configurables
edm::InputTag metSrc_;
edm::EDGetTokenT<edm::View<reco::MET> > metToken_;
edm::InputTag chsmetSrc_;
edm::EDGetTokenT<edm::View<reco::MET> > chsmetToken_;
edm::InputTag trkmetSrc_;
edm::EDGetTokenT<edm::View<reco::MET> > trkmetToken_;
bool addGenMET_;
edm::EDGetTokenT<edm::View<reco::GenMET> > genMETToken_;
bool addResolutions_;
2 changes: 2 additions & 0 deletions PhysicsTools/PatAlgos/plugins/PATMETSlimmer.cc
Original file line number Diff line number Diff line change
@@ -65,6 +65,8 @@ pat::PATMETSlimmer::PATMETSlimmer(const edm::ParameterSet & iConfig) :
maybeReadShifts( iConfig, "tXYUncForT1Smear", pat::MET::TXYForT1Smear );
maybeReadShifts( iConfig, "tXYUncForT01Smear", pat::MET::TXYForT01Smear );
maybeReadShifts( iConfig, "caloMET", pat::MET::Calo );
maybeReadShifts( iConfig, "chsMET", pat::MET::Chs );
maybeReadShifts( iConfig, "trkMET", pat::MET::Trk );

produces<std::vector<pat::MET> >();
}
Original file line number Diff line number Diff line change
@@ -7,10 +7,6 @@
# input
metSource = cms.InputTag("pfMetT1"),

# additional sources
chsmetSource = cms.InputTag(''),
trkmetSource = cms.InputTag(''),

# add user data
userData = cms.PSet(
# add custom classes here
15 changes: 12 additions & 3 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
@@ -185,10 +185,14 @@ def miniAOD_customizeCommon(process):
globalThreshold = cms.double(0.0),
calculateSignificance = cms.bool(False),
)

task.add(process.pfMetCHS)

process.patMETs.chsmetSource = cms.InputTag("pfMetCHS")
addMETCollection(process,
labelName = "patChsMet",
metSource = "pfMetCHS"
)

process.patChsMet.computeMETSignificance = cms.bool(False)
Copy link
Contributor

Choose a reason for hiding this comment

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

hi @zdemirag - please follow a convention here. Eg

CHS or Chs (seems CHS is the established one)
ChsMet or MetChs

(and similarly for TrkMet)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The differences between patXXXMet and MetXXX is the pat vs reco modules. therefore the notation is self consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its not XXXMet vs MetXXX - rather its "XXX" being consistent that I'm requesting.It looks like CHS is currently universal in CMSSW python:

[dlange@lxplus098 CMSSW_9_4_0_pre2]$ cmsglimpse CHS | grep python | wc
Your query may search about 72% of the total space! Continue? (y/n)y
1251 5252 168118
[dlange@lxplus098 CMSSW_9_4_0_pre2]$ cmsglimpse Chs | grep python | wc
Your query may search about 72% of the total space! Continue? (y/n)y
0 0 0


# ================== CHSMET

@@ -208,7 +212,12 @@ def miniAOD_customizeCommon(process):

task.add(process.pfMetTrk)

process.patMETs.trkmetSource = cms.InputTag("pfMetTrk")
addMETCollection(process,
labelName = "patTrkMet",
metSource = "pfMetTrk"
)

process.patTrkMet.computeMETSignificance = cms.bool(False)

# ================== TrkMET

4 changes: 4 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimmedMETs_cfi.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,10 @@
#caloMET, will be used for the beginning of ata takin by the JetMET people
caloMET = cms.InputTag("patCaloMet"),

#adding CHS and Track MET for the Jet/MET studies
chsMET = cms.InputTag("patChsMet"),
trkMET = cms.InputTag("patTrkMet"),

#switch to read the type0 correction from the existing slimmedMET
#when running on top of miniAOD (type0 cannot be redone at the miniAOD level
runningOnMiniAOD = cms.bool(False)
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@
process.out.outputCommands = MINIAODSIMEventContent.outputCommands
process.out.outputCommands.append("keep *_slimmedMETs_*_*")
process.out.outputCommands.append("keep *_patPFMet_*_*")
process.out.outputCommands.append("keep *_patChsMet_*_*")
process.out.outputCommands.append("keep *_patTrkMet_*_*")
process.out.outputCommands.append("keep *_patPFMetT1_*_*")
process.out.outputCommands.append("keep *_patPFMetT1JetResDown_*_*")
process.out.outputCommands.append("keep *_patPFMetT1JetResUp_*_*")
Loading