Skip to content

Commit

Permalink
Merge CMSSW_9_4_X into CMSSW_9_4_AN_X.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed May 15, 2018
2 parents 8e3520e + 928b9bc commit 7767a72
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 8 additions & 2 deletions PhysicsTools/JetMCAlgos/plugins/ttHFGenFilter.cc
Expand Up @@ -67,6 +67,7 @@ class ttHFGenFilter : public edm::stream::EDFilter<> {
const edm::EDGetTokenT<std::vector<std::vector<int> > > genBHadPlusMothersIndicesToken_;
const edm::EDGetTokenT<std::vector<int> > genBHadIndexToken_;
bool OnlyHardProcessBHadrons_;
bool taggingMode_;


// ----------member data ---------------------------
Expand All @@ -93,6 +94,9 @@ genBHadIndexToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTa
{
//now do what ever initialization is needed
OnlyHardProcessBHadrons_ = iConfig.getParameter<bool> ( "OnlyHardProcessBHadrons" );
taggingMode_ = iConfig.getParameter<bool>("taggingMode");

produces<bool>();
}


Expand Down Expand Up @@ -142,9 +146,11 @@ ttHFGenFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)

std::vector<const reco::Candidate*> AllTopMothers;
std::vector<const reco::Candidate*> Tops = GetTops(*genParticles,AllTopMothers);
// std::cout << "Size of AllTopMothers = " << AllTopMothers.size() << std::endl;
return HasAdditionalBHadron(*genBHadIndex,*genBHadFlavour,*genBHadPlusMothers,AllTopMothers);
bool pass = HasAdditionalBHadron(*genBHadIndex,*genBHadFlavour,*genBHadPlusMothers,AllTopMothers);

iEvent.put(std::make_unique<bool>(pass));

return taggingMode_ || pass;
}

bool ttHFGenFilter::HasAdditionalBHadron(const std::vector<int>& genBHadIndex, const std::vector<int>& genBHadFlavour,const std::vector<reco::GenParticle>& genBHadPlusMothers,std::vector<const reco::Candidate*>& AllTopMothers){
Expand Down
3 changes: 2 additions & 1 deletion PhysicsTools/JetMCAlgos/python/ttHFGenFilter_cfi.py
Expand Up @@ -9,6 +9,7 @@
genBHadPlusMothersIndices = cms.InputTag("matchGenBHadron", "genBHadPlusMothersIndices"),
genBHadIndex = cms.InputTag("matchGenBHadron", "genBHadIndex"),

OnlyHardProcessBHadrons = cms.bool(False)
OnlyHardProcessBHadrons = cms.bool(False),
taggingMode = cms.bool(False)

)
10 changes: 7 additions & 3 deletions PhysicsTools/JetMCAlgos/test/testttHFGenFilter.py
Expand Up @@ -13,7 +13,7 @@
)
## Set up command line options
options = VarParsing ('analysis')
options.register('runOnGenOrAODsim', True, VarParsing.multiplicity.singleton, VarParsing.varType.bool, "GEN SIM")
options.register('runOnGenOrAODsim', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool, "GEN SIM")
options.register( "skipEvents", 0, VarParsing.multiplicity.singleton, VarParsing.varType.int, "Number of events to skip" )
options.parseArguments()

Expand All @@ -28,7 +28,7 @@
if options.runOnGenOrAODsim:
options.inputFiles=['/store/mc/RunIISummer15GS/TTToSemiLeptonic_TuneCUETP8M1_alphaS01273_13TeV-powheg-scaledown-pythia8/GEN-SIM/MCRUN2_71_V1-v2/40000/DE7952A2-6E2F-E611-A803-001E673D1B21.root']
else:
options.inputFiles=['/store/mc/RunIISpring15MiniAODv2/ttbb_4FS_ckm_amcatnlo_madspin_pythia8/MINIAODSIM/74X_mcRun2_asymptotic_v2-v1/40000/06D46D97-C66D-E511-9ABF-00266CFAE20C.root']
options.inputFiles=['/store/mc/RunIIFall17MiniAOD/TTToSemiLeptonic_TuneCP5_PSweights_13TeV-powheg-pythia8/MINIAODSIM/94X_mc2017_realistic_v10-v1/50000/DC5D3109-F2E1-E711-A26E-A0369FC5FC9C.root']

## Define maximum number of events to loop over
if options.maxEvents is -1: # maxEvents is set in VarParsing class by default to -1
Expand Down Expand Up @@ -108,9 +108,13 @@
process.load("PhysicsTools/JetMCAlgos/ttHFGenFilter_cfi")
from PhysicsTools.JetMCAlgos.ttHFGenFilter_cfi import ttHFGenFilter
process.ttHFGenFilter = ttHFGenFilter.clone(
genParticles = genParticleCollection
genParticles = genParticleCollection,
taggingMode = cms.bool(True),
)

print "If taggingMode is set to true, the filter will write a branch into the tree instead of filtering the events"
print "taggingMode is set to ", process.ttHFGenFilter.taggingMode


## configuring the testing analyzer that produces output tree
#process.matchGenHFHadrons = cms.EDAnalyzer("matchGenHFHadrons",
Expand Down

0 comments on commit 7767a72

Please sign in to comment.