Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
540 changes: 540 additions & 0 deletions plugins/MiniEffiTree.cc

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion plugins/RateTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class RateTree : public edm::EDAnalyzer {
std::vector<Float_t>* puEM_;
std::vector<Float_t>* puUICEM_;
std::vector<Float_t>* effArea_;
std::vector<Float_t>* eneighbor_;
std::vector<bool>* taus_;
std::vector<bool>* tausneighbor_;
std::vector<bool>* mips_;

};
Expand All @@ -89,7 +91,9 @@ RateTree::RateTree(const edm::ParameterSet& pset) {
pts_ = new std::vector<Float_t>();
etas_ = new std::vector<Float_t>();
phis_ = new std::vector<Float_t>();
eneighbor_ = new std::vector<Float_t>();
taus_ = new std::vector<bool>();
tausneighbor_ = new std::vector<bool>();
mips_ = new std::vector<bool>();


Expand Down Expand Up @@ -162,7 +166,9 @@ RateTree::RateTree(const edm::ParameterSet& pset) {
tree->Branch("puEM", "std::vector<float>", &puEM_);
tree->Branch("puUICEM", "std::vector<float>", &puUICEM_);
tree->Branch("effArea", "std::vector<float>", &effArea_);
tree->Branch("associated4x4Et", "std::vector<float>",&eneighbor_);
tree->Branch("tauVeto", "std::vector<bool>", &taus_);
tree->Branch("associated4x4Tau","std::vector<bool>",&tausneighbor_);
tree->Branch("mipBit", "std::vector<bool>", &mips_);

// Now add nice aliases so the same draw commands work for rate/eff
Expand All @@ -183,6 +189,7 @@ RateTree::RateTree(const edm::ParameterSet& pset) {

tree->SetAlias("l1gEllIso", "ellIso");
tree->SetAlias("l1gTauVeto", "tauVeto");
tree->SetAlias("l1gTauVetoNeighbor","associated4x4Tau");
tree->SetAlias("l1gMIP", "mipBit");

tree->SetAlias("l1gPU", "pu");
Expand Down Expand Up @@ -228,7 +235,9 @@ RateTree::~RateTree() {
delete puUICEM_;
delete effArea_;
delete mips_;
delete eneighbor_;
delete taus_;
delete tausneighbor_;
}


Expand Down Expand Up @@ -303,7 +312,9 @@ void RateTree::analyze(const edm::Event& evt, const edm::EventSetup& es) {
puEM_->clear();
puUICEM_->clear();
effArea_->clear();
eneighbor_->clear();
taus_->clear();
tausneighbor_->clear();
mips_->clear();

// Setup meta info
Expand Down Expand Up @@ -359,7 +370,10 @@ void RateTree::analyze(const edm::Event& evt, const edm::EventSetup& es) {
puUICEM_->push_back(uct->getFloat("puLevelUICEM", -4));
effArea_->push_back(uct->getFloat("effArea", -4));
mips_->push_back(uct->getInt("mipBit", -4));
eneighbor_->push_back(uct->getFloat("associated4x4Et",-4));
taus_->push_back(uct->getInt("tauVeto", -4));
//std::cout << "tauVeto Rate Tree:" << uct->getFloat("tauVeto",-4) << std::endl;
tausneighbor_->push_back(uct->getInt("associated4x4Tau",-4));
// UCT doesn't have a type
type_->push_back(-1);
} else {
Expand Down Expand Up @@ -409,7 +423,8 @@ void RateTree::analyze(const edm::Event& evt, const edm::EventSetup& es) {
puUICEM_->push_back(-5);
effArea_->push_back(-5);
mips_->push_back(-5);
taus_->push_back(-5);
//taus_->push_back(-5);
//tausneighbor_->push_back(-5);
type_->push_back(-5);

tree->Fill();
Expand Down
167 changes: 167 additions & 0 deletions plugins/RateTreeEmul.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "DataFormats/Candidate/interface/Candidate.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"

#include "DataFormats/L1Trigger/interface/L1EmParticle.h"
#include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
#include "DataFormats/L1Trigger/interface/L1JetParticle.h"
#include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
#include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
#include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"

#include "DataFormats/Scalers/interface/LumiScalers.h"

#include "L1Trigger/L1TCalorimeter/interface/Stage1Layer2TauAlgorithmImp.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/L1Candidate.h"

#include "TTree.h"

typedef std::vector<edm::InputTag> VInputTag;

class RateTreeEmul : public edm::EDAnalyzer {
public:
RateTreeEmul(const edm::ParameterSet& pset);
virtual ~RateTreeEmul();
void analyze(const edm::Event& evt, const edm::EventSetup& es);
private:
VInputTag src_;
TTree* tree;
std::vector<Float_t>* pts_;
std::vector<Float_t>* etas_;
std::vector<Float_t>* phis_;
std::vector<Int_t>* isoFlags_;
UInt_t run_;
UInt_t lumi_;
ULong64_t event_;
Int_t nPU_;
};

RateTreeEmul::RateTreeEmul(const edm::ParameterSet& pset) {
// Initialize the ntuple builder
edm::Service<TFileService> fs;
tree = fs->make<TTree>("Ntuple", "Ntuple");
pts_ = new std::vector<Float_t>();
etas_ = new std::vector<Float_t>();
phis_ = new std::vector<Float_t>();
isoFlags_ = new std::vector<Int_t>();

tree->Branch("pt", "std::vector<float>", &pts_);
tree->Branch("eta", "std::vector<float>", &etas_);
tree->Branch("phi", "std::vector<float>", &phis_);
tree->Branch("run", &run_, "run/i");
//tree->Branch("isoFlags", "std::vector<int>", &isoFlags_);
tree->Branch("lumi", &lumi_, "lumi/i");
tree->Branch("evt", &event_, "evt/l");
tree->Branch("nPU", &nPU_, "nPU/i");

src_ = pset.getParameter<VInputTag>("src");
}

RateTreeEmul::~RateTreeEmul() {
delete pts_;
delete etas_;
delete phis_;
delete isoFlags_;
}


namespace {

// Predicate to sort candidates by descending pt
class CandPtSorter {
public:
bool operator()(const reco::Candidate* candA, const reco::Candidate* candB)
const {
return candA->pt() > candB->pt();
}
};

// Turn a set of InputTags into a colleciton of candidate pointers.
std::vector<const reco::Candidate*> getCollections(
const edm::Event& evt, const VInputTag& collections) {
std::vector<const reco::Candidate*> output;
// Loop over collections
for (size_t i = 0; i < collections.size(); ++i) {
edm::Handle<edm::View<reco::Candidate> > handle;
evt.getByLabel(collections[i], handle);
// Loop over objects in current collection
for (size_t j = 0; j < handle->size(); ++j) {
const reco::Candidate& object = handle->at(j);
output.push_back(&object);
}
}
return output;
}

}

void RateTreeEmul::analyze(const edm::Event& evt, const edm::EventSetup& es) {
//std::cout << "getting objects" << std::endl;
// Get the objects.
std::vector<const reco::Candidate*> objects = getCollections(
evt, src_);
//std::cout << "sorting objects" << std::endl;
std::sort(objects.begin(), objects.end(), CandPtSorter());

//std::cout << "clearing objects" << std::endl;
// Clear previous event's objects
pts_->clear();
etas_->clear();
phis_->clear();
isoFlags_->clear();


//std::cout << "setting up meta info" <<std::endl;
// Setup meta info
//
run_ = evt.id().run();
lumi_ = evt.id().luminosityBlock();
event_ = evt.id().event();

//std::cout << "event: " << event_ << std::endl;

//std::cout << "getting pileup summary" << std::endl;
edm::Handle<std::vector<PileupSummaryInfo> > PupInfo;
evt.getByLabel("addPileupInfo", PupInfo);

nPU_=-1;
for(std::vector<PileupSummaryInfo>::const_iterator i = PupInfo->begin(); i!=PupInfo->end();++i) {
int BX = i->getBunchCrossing();
if(BX==0) {
nPU_ =i->getTrueNumInteractions();
}
else {
nPU_=i->getPU_NumInteractions();
}
}



//std::cout << "pushing back" << std::endl;
for (size_t i = 0; i < objects.size(); ++i) {
pts_->push_back(objects[i]->pt());
etas_->push_back(objects[i]->eta());
phis_->push_back(objects[i]->phi());
//std::cout <<"about to make dynamic cast"<<std::endl;
//const l1t::Tau* tau = dynamic_cast <const l1t::Tau*>(objects[i]);
//std::cout << "about to push back hwIso" <<std::endl;
//std::cout << tau[i].hwIso() << std::endl;
//isoFlags_->push_back(tau[i].hwIso());
}


tree->Fill();
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(RateTreeEmul);
40 changes: 21 additions & 19 deletions python/recoObjects_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
src = cms.InputTag( "gsfElectrons" ),
cut = cms.string(
" (et>20.0)"
" && (gsfTrack.trackerExpectedHitsInner.numberOfHits==0 && !(-0.02<convDist<0.02 && -0.02<convDcot<0.02))"
" && (!(-0.02<convDist<0.02 && -0.02<convDcot<0.02))"
" && ( (isEB"
" && abs(sigmaIetaIeta)<0.01 && abs(deltaPhiSuperClusterTrackAtVtx)<0.03 && abs(deltaEtaSuperClusterTrackAtVtx)<0.004 )"
" || (isEE"
Expand All @@ -54,18 +54,18 @@
)

# Apply jet energy corrections - disabled until we can fix the global tag issue.
calibratedAK5PFJets = cms.EDProducer(
'PFJetCorrectionProducer',
src = cms.InputTag('ak5PFJets'),
correctors = cms.vstring("ak5PFL1FastL2L3Residual")
)
#calibratedAK5PFJets = cms.EDProducer(
# 'PFJetCorrectionProducer',
# src = cms.InputTag('ak5PFJets'),
# correctors = cms.vstring("ak5PFL1FastL2L3Residual")
#)

##########################################################################
##-------- Remove electrons and muons from jet collection ----------------------
ak5PFJetsNOMuons = cms.EDProducer(
"PFJetCleaner",
srcJets = cms.InputTag("calibratedAK5PFJets"),
#srcJets = cms.InputTag("ak5PFJets"),
#srcJets = cms.InputTag("calibratedAK5PFJets"),
srcJets = cms.InputTag("ak5PFJets"),
module_label = cms.string(""),
idLevel = cms.int32(0), # No Jet Id Required
etaMin = cms.double(0.0),
Expand All @@ -91,7 +91,7 @@
tightMuons*
recoElecs*
isoElecs*
calibratedAK5PFJets*
#calibratedAK5PFJets*
ak5PFJetsNOMuons*
recoJets
)
Expand All @@ -100,6 +100,7 @@
from Configuration.StandardSequences.GeometryIdeal_cff import *
from Configuration.StandardSequences.MagneticField_cff import *
from RecoTauTag.Configuration.RecoPFTauTag_cff import *
from PhysicsTools.PatAlgos.tools.tauTools import *
from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import *

# Select good taus
Expand All @@ -126,7 +127,8 @@
selectionCut=cms.double(0.5)
),
cms.PSet(
discriminator=cms.InputTag("hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr"),
#discriminator=cms.InputTag("hpsPFTauDiscriminationByLooseIsolationDBSumPtCorr"),
discriminator=cms.InputTag("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr"),
selectionCut=cms.double(0.5)
),
),
Expand Down Expand Up @@ -161,7 +163,7 @@

recoObjects = cms.Sequence(
cleanJets *
PFTau *
# PFTau *
dmTaus *
isoTaus*
recoTaus
Expand All @@ -182,11 +184,11 @@
matching = cms.InputTag("recoTauTruthMatcher")
)

recoObjects_truthMatched = cms.Sequence(
recoObjects *
genParticles *
tauGenJets *
trueHadronicTaus *
recoTauTruthMatcher *
trueTaus
)
#recoObjects_truthMatched = cms.Sequence(
# recoObjects *
# genParticles *
# tauGenJets *
# trueHadronicTaus *
# recoTauTruthMatcher *
# trueTaus
#)
Loading