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

Boosted Tau Production Changes for Ultra Legacy #87

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
156 changes: 156 additions & 0 deletions Production/plugins/BoostedTauProductionFilter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// system include files
kandrosov marked this conversation as resolved.
Show resolved Hide resolved
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDFilter.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "DataFormats/PatCandidates/interface/Tau.h"

//
// class declaration
//

class BoostedTauProductionFilter : public edm::stream::EDFilter<> {
public:
explicit BoostedTauProductionFilter(const edm::ParameterSet&);
~BoostedTauProductionFilter();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
virtual void beginStream(edm::StreamID) override;
virtual bool filter(edm::Event&, const edm::EventSetup&) override;
virtual void endStream() override;

//virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
//virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
//virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;

// ----------member data ---------------------------
edm::EDGetTokenT< std::vector<pat::Tau> > boostedTauCollection;
bool verboseDebug;
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
BoostedTauProductionFilter::BoostedTauProductionFilter(const edm::ParameterSet& iConfig):
boostedTauCollection(consumes< std::vector<pat::Tau> >(iConfig.getParameter< edm::InputTag >("boostedTauCollection") ) )
{
//now do what ever initialization is needed
verboseDebug = iConfig.exists("verboseDebug") ? iConfig.getParameter<bool>("verboseDebug"): false;
if (verboseDebug) std::cout<<"Constructing boosted tau filter..."<<std::endl;
}


BoostedTauProductionFilter::~BoostedTauProductionFilter()
{

// do anything here that needs to be done at destruction time
// (e.g. close files, deallocate resources etc.)

}


//
// member functions
//

// ------------ method called on each new Event ------------
bool
BoostedTauProductionFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;
/*
#ifdef THIS_IS_AN_EVENT_EXAMPLE
Handle<ExampleData> pIn;
iEvent.getByLabel("example",pIn);
#endif

#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
ESHandle<SetupData> pSetup;
iSetup.get<SetupRecord>().get(pSetup);
#endif
return true;
*/

edm::Handle< std::vector<pat::Tau> > boostedTauHandle;
iEvent.getByToken(boostedTauCollection, boostedTauHandle);

//Our filter really only asks one very simple question. Is there a boosted tau in the event?
if (verboseDebug) std::cout<<"boosted taus empty? "<<boostedTauHandle->empty()<<std::endl;
if (boostedTauHandle->empty()) return false;
return true;


}

// ------------ method called once each stream before processing any runs, lumis or events ------------
void
BoostedTauProductionFilter::beginStream(edm::StreamID)
{
}

// ------------ method called once each stream after processing all runs, lumis and events ------------
void
BoostedTauProductionFilter::endStream() {
}

// ------------ method called when starting to processes a run ------------
/*
void
BoostedTauProductionFilter::beginRun(edm::Run const&, edm::EventSetup const&)
{
}
*/

// ------------ method called when ending the processing of a run ------------
/*
void
BoostedTauProductionFilter::endRun(edm::Run const&, edm::EventSetup const&)
{
}
*/

// ------------ method called when starting to processes a luminosity block ------------
/*
void
BoostedTauProductionFilter::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
*/

// ------------ method called when ending the processing of a luminosity block ------------
/*
void
BoostedTauProductionFilter::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
{
}
*/

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
BoostedTauProductionFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}
//define this as a plug-in
DEFINE_FWK_MODULE(BoostedTauProductionFilter);
8 changes: 8 additions & 0 deletions Production/python/Production.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
" If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is built to seed taus (as at RECO), otherwise standard slimmedJets are used")
options.register('rerunTauReco', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
"If true, tau reconstruction is re-run on MINIAOD with a larger signal cone and no DM finding filter")
options.register('useBoostedTauFilter', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool,
"Implement boosted tau filter in the process to only consider events with some boosted tau content")
options.parseArguments()

sampleConfig = importlib.import_module('TauMLTools.Production.sampleConfig')
Expand Down Expand Up @@ -236,6 +238,12 @@
if isRun2PreUL:
process.p.insert(2, process.boostedSequence)

if options.useBoostedTauFilter:
process.theBoostedTauFilter = cms.EDFilter('BoostedTauProductionFilter',
boostedTauCollection = cms.InputTag("slimmedTausBoosted"),
verboseDebug = cms.bool(False))
process.p.insert(0, process.theBoostedTauFilter)

process.load('FWCore.MessageLogger.MessageLogger_cfi')
x = process.maxEvents.input.value()
x = x if x >= 0 else 10000
Expand Down
12 changes: 10 additions & 2 deletions Production/python/sampleConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import FWCore.ParameterSet.Config as cms
import os

mcSampleTypes = Set([ 'MC_16', 'MC_17', 'MC_18', 'MC_UL18', 'Emb_16', 'Emb_17', 'Emb_18ABC', 'Emb_18D', 'MC_Phase2_111X', 'MC_Phase2_110X'])
mcSampleTypes = Set([ 'MC_16', 'MC_17', 'MC_18', 'MC_UL18', 'Emb_16', 'Emb_17', 'Emb_18ABC', 'Emb_18D', 'MC_Phase2_111X', 'MC_Phase2_110X', 'UL18', 'UL17','UL16','UL16APV'])
dataSampleTypes = Set([ 'Run2016' , 'Run2017', 'Run2018ABC', 'Run2018D', 'RunUL2018' ])

periodDict = { 'MC_16' : 'Run2016',
Expand All @@ -23,6 +23,10 @@
'Emb_18D' : 'Run2018',
'MC_Phase2_110X' : 'Phase2',
'MC_Phase2_111X' : 'Phase2',
'UL18': 'Run2018',
'UL17': 'Run2017',
'UL16': 'Run2016',
'UL16APV': 'Run2016',
}

globalTagMap = { 'MC_16' : '102X_mcRun2_asymptotic_v7',
Expand All @@ -41,6 +45,10 @@
'Emb_18D' : '102X_dataRun2_Prompt_v15',
'MC_Phase2_110X' : '110X_mcRun4_realistic_v3',
'MC_Phase2_111X' : 'auto:phase2_realistic_T15',
'UL18': '106X_upgrade2018_realistic_v15_L1v1',
'UL17': '106X_mc2017_realistic_v8',
'UL16': '106X_mcRun2_asymptotic_v17',
'UL16APV': '106X_mcRun2_asymptotic_preVFP_v11'
kandrosov marked this conversation as resolved.
Show resolved Hide resolved
}

def IsEmbedded(sampleType):
Expand Down Expand Up @@ -73,7 +81,7 @@ def isRun2UL(sampleType):
if sampleType not in periodDict:
print "ERROR: unknown sample type = '{}'".format(sampleType)
sys.exit(1)
return sampleType in ['MC_UL18', 'RunUL2018']
return sampleType in ['MC_UL18', 'RunUL2018', 'UL16', 'UL16APV', 'UL17', 'UL18']

def isPhase2(sampleType):
if sampleType not in periodDict:
Expand Down