Skip to content

Commit

Permalink
bug fix for production
Browse files Browse the repository at this point in the history
  • Loading branch information
jshlee committed Sep 23, 2015
1 parent ab05d2a commit 268c658
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
70 changes: 34 additions & 36 deletions CatAnalyzer/plugins/h2muAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class h2muAnalyzer : public edm::EDAnalyzer {
edm::EDGetTokenT<pat::TriggerObjectStandAloneCollection> triggerObjects_;

TTree * ttree_;
TTree * t2;

int b_njet, b_step, b_channel;
float b_MET;
Expand Down Expand Up @@ -87,7 +86,7 @@ h2muAnalyzer::h2muAnalyzer(const edm::ParameterSet& iConfig)

edm::Service<TFileService> fs;
ttree_ = fs->make<TTree>("tree", "tree");
t2 = fs->make<TTree>("tree2","tree2");
ttree_ = fs->make<TTree>("tree2","tree2");
ttree_->Branch("njet", &b_njet, "njet/I");
ttree_->Branch("MET", &b_MET, "MET/F");
ttree_->Branch("channel", &b_channel, "channel/I");
Expand Down Expand Up @@ -118,16 +117,16 @@ h2muAnalyzer::h2muAnalyzer(const edm::ParameterSet& iConfig)
ttree_->Branch("jetcat_GC", &b_jetcat_GC, "jetcat_GC/I");

//tree2. we should use this for efficiency of recomuon per genmuon.
t2 ->Branch("gen_lep_pt", &b_gen_lep_pt, "gen_lep_pt/F");
t2 ->Branch("gen_lep_eta", &b_gen_lep_eta, "gen_lep_eta/F");
t2 ->Branch("gen_lep_phi", &b_gen_lep_phi, "gen_lep_phi/F");
t2 ->Branch("reco_lep_pt", &b_reco_lep_pt, "reco_lep_pt/F");
t2 ->Branch("reco_lep_eta", &b_reco_lep_eta, "reco_lep_eta/F");
t2 ->Branch("reco_lep_phi", &b_reco_lep_phi, "reco_lep_phi/F");
t2 ->Branch("resolution", &b_resolution, "resolution/F");
t2 ->Branch("lep_isLoose", &b_lep_isLoose, "lep_isLoose/B");
t2 ->Branch("lep_isMedium", &b_lep_isMedium, "lep_isMedium/B");
t2 ->Branch("lep_isTight", &b_lep_isTight, "lep_isTight/B");
ttree_->Branch("gen_lep_pt", &b_gen_lep_pt, "gen_lep_pt/F");
ttree_->Branch("gen_lep_eta", &b_gen_lep_eta, "gen_lep_eta/F");
ttree_->Branch("gen_lep_phi", &b_gen_lep_phi, "gen_lep_phi/F");
ttree_->Branch("reco_lep_pt", &b_reco_lep_pt, "reco_lep_pt/F");
ttree_->Branch("reco_lep_eta", &b_reco_lep_eta, "reco_lep_eta/F");
ttree_->Branch("reco_lep_phi", &b_reco_lep_phi, "reco_lep_phi/F");
ttree_->Branch("resolution", &b_resolution, "resolution/F");
ttree_->Branch("lep_isLoose", &b_lep_isLoose, "lep_isLoose/B");
ttree_->Branch("lep_isMedium", &b_lep_isMedium, "lep_isMedium/B");
ttree_->Branch("lep_isTight", &b_lep_isTight, "lep_isTight/B");

}
h2muAnalyzer::~h2muAnalyzer(){}
Expand Down Expand Up @@ -186,7 +185,6 @@ void h2muAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
b_lep_isLoose = 0; b_lep_isMedium = 0; b_lep_isTight = 0;

if (!isfromZboson) {
t2->Fill();
continue;
}
b_gen_lep_pt = g.pt();
Expand All @@ -206,7 +204,6 @@ void h2muAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
break;
}
}
t2->Fill();
}
}

Expand Down Expand Up @@ -234,39 +231,40 @@ void h2muAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet
b_ll_phi = tlv_ll.Phi();
b_ll_m = tlv_ll.M();

TLorentzVector met = mets->front().tlv();
b_MET = met.Pt();

vector<TLorentzVector> recolep;
vector<cat::Jet> selectedJets = selectJets( jets.product(), recolep );

b_njet = selectedJets.size();

b_step = 1;
int ll_charge = selectedMuons[0].charge()*selectedMuons[1].charge();

if (ll_charge < 0)
b_step = 2;

if (ll_charge > 0){
ttree_->Fill();
return;
}
b_step = 2;

edm::Handle<edm::TriggerResults> triggerBits;
edm::Handle<pat::TriggerObjectStandAloneCollection> triggerObjects;
iEvent.getByToken(triggerBits_, triggerBits);
iEvent.getByToken(triggerObjects_, triggerObjects);
const edm::TriggerNames &triggerNames = iEvent.triggerNames(*triggerBits);
AnalysisHelper trigHelper = AnalysisHelper(triggerNames, triggerBits, triggerObjects);

// if (triggerFired(triggerNames, triggerBits, "HLT_IsoMu24_eta2p1_v") ){
if (trigHelper.triggerFired("HLT_IsoMu24_eta2p1_v") ){
b_step = 3;
cout << "trigger fired"<<endl;
if (!trigHelper.triggerFired("HLT_IsoMu24_eta2p1_v")){
}
// if ( triggerMatched(triggerNames, triggerObjects, "HLT_IsoMu24_eta2p1_v", selectedMuons[0] )
// || triggerMatched(triggerNames, triggerObjects, "HLT_IsoMu24_eta2p1_v", selectedMuons[1] ))
if ( trigHelper.triggerMatched("HLT_IsoMu24_eta2p1_v", selectedMuons[0] )
|| trigHelper.triggerMatched("HLT_IsoMu24_eta2p1_v", selectedMuons[1] ))
b_step = 4;

TLorentzVector met = mets->front().tlv();
b_MET = met.Pt();

vector<TLorentzVector> recolep;
//for (auto lep : selectedMuons){ recolep.push_back(lep.tlv()); }
//vector<cat::Electron> selectedElectrons = selectElecs( electrons.product() );
vector<cat::Jet> selectedJets = selectJets( jets.product(), recolep );

b_njet = selectedJets.size();
b_step = 3;

if ( !trigHelper.triggerMatched("HLT_IsoMu24_eta2p1_v", selectedMuons[0] )
&& !trigHelper.triggerMatched("HLT_IsoMu24_eta2p1_v", selectedMuons[1] )){
ttree_->Fill();
return;
}
b_step = 4;

// float step = passingSteps( channel, met.Pt(), (recolep[0]+recolep[1]).M(), ll_charge, selectedJets.size() );

Expand Down
15 changes: 8 additions & 7 deletions CatAnalyzer/test/run_h2muAnalyzer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
process.load("FWCore.MessageService.MessageLogger_cfi")
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

datadir = '/xrootd/store/group/CAT/SingleMuon/v7-3-6_Run2015B-PromptReco-v1/150820_215216/0000/'
datadir = '/xrootd/store/user/jlee/SingleMuon/v7-4-1_Run2015C-PromptReco-v1/150913_173449/0000/'
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring('file:/afs/cern.ch/user/j/jlee/work/cat74/src/CATTools/CatProducer/prod/catTuple.root')
#fileNames = cms.untracked.vstring()
#fileNames = cms.untracked.vstring('file:/xrootd/store/user/jlee/SingleMuon/v7-4-1_Run2015C-PromptReco-v1/150913_173449/0000/catTuple_125.root')
fileNames = cms.untracked.vstring()
)

#for f in os.listdir(datadir):
# process.source.fileNames.append("file:"+datadir+f)
for f in os.listdir(datadir):
process.source.fileNames.append("file:"+datadir+f)

print process.source.fileNames
runOnMC=True
### for run data
lumiFile = 'Cert_246908-255031_13TeV_PromptReco_Collisions15_50ns_JSON.txt'
lumiFile = 'Cert_246908-255031_13TeV_PromptReco_Collisions15_25ns_JSON_v2.txt'
for i in process.source.fileNames:
if 'Run2015' in i:
runOnMC=False
Expand All @@ -35,7 +35,8 @@
mets = cms.InputTag("catMETs"),
mcLabel = cms.InputTag("prunedGenParticles"),
triggerBits = cms.InputTag("TriggerResults","","HLT"),
triggerObjects = cms.InputTag("catTrigger"),
#triggerObjects = cms.InputTag("catTrigger"),
triggerObjects = cms.InputTag("selectedPatTrigger"),
)

process.TFileService = cms.Service("TFileService",
Expand Down
3 changes: 2 additions & 1 deletion CatProducer/prod/PAT2CAT_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
if useMiniAOD:
process.source.fileNames = ['/store/relval/CMSSW_7_4_6_patch6/RelValTTbar_13/MINIAODSIM/MCRUN2_74_V9-v1/00000/2403409D-1225-E511-B64E-0025905A6132.root']
## Hack to run on relval sample
process.genMetExtractor.metSource = "slimmedMETs::RECO"
# this makes production to fail... need another solution for this
# process.genMetExtractor.metSource = "slimmedMETs::RECO"
else:
process.source.fileNames = ['/store/relval/CMSSW_7_4_6_patch6/RelValTTbar_13/GEN-SIM-RECO/MCRUN2_74_V9-v1/00000/54F6E09C-1225-E511-842B-0025905A612E.root']

Expand Down

0 comments on commit 268c658

Please sign in to comment.