diff --git a/DataFormats/PatCandidates/interface/Electron.h b/DataFormats/PatCandidates/interface/Electron.h index 9731431b7d45f..eb7730d280b80 100644 --- a/DataFormats/PatCandidates/interface/Electron.h +++ b/DataFormats/PatCandidates/interface/Electron.h @@ -182,15 +182,15 @@ namespace pat { // ---- embed various impact parameters with errors ---- typedef enum IPTYPE { PV2D = 0, PV3D = 1, BS2D = 2, BS3D = 3, IpTypeSize = 4 } IpType; /// Impact parameter wrt primary vertex or beamspot - double dB(IpType type) const; + double dB(IPTYPE type) const; /// Uncertainty on the corresponding impact parameter - double edB(IpType type) const; + double edB(IPTYPE type) const; /// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) double dB() const { return std::abs(dB(PV2D)); } /// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) double edB() const { return std::abs(edB(PV2D)); } /// Set impact parameter of a certain type and its uncertainty - void setDB(double dB, double edB, IpType type); + void setDB(double dB, double edB, IPTYPE type); // ---- Momentum estimate specific methods ---- const LorentzVector & ecalDrivenMomentum() const {return ecalDrivenMomentum_;} diff --git a/DataFormats/PatCandidates/interface/Muon.h b/DataFormats/PatCandidates/interface/Muon.h index 21437240add3c..455e8bf93605a 100644 --- a/DataFormats/PatCandidates/interface/Muon.h +++ b/DataFormats/PatCandidates/interface/Muon.h @@ -208,15 +208,15 @@ namespace pat { PV2D = 0, PV3D = 1, BS2D = 2, BS3D = 3, IpTypeSize = 4 } IpType; void initImpactParameters(void); // init IP defaults in a constructor - double dB(IpType type) const; - double edB(IpType type) const; + double dB(IPTYPE type) const; + double edB(IPTYPE type) const; /// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) double dB() const { return std::abs(dB(PV2D)); } /// the version without arguments returns PD2D, but with an absolute value (for backwards compatibility) double edB() const { return std::abs(edB(PV2D)); } - void setDB ( double dB, double edB, IpType type = PV2D ) { + void setDB ( double dB, double edB, IPTYPE type = PV2D ) { ip_[type] = dB; eip_[type] = edB; cachedIP_ |= (1 << int(type)); } diff --git a/MuonAnalysis/MuonAssociators/plugins/TriggerObjectFilterByCollection.cc b/MuonAnalysis/MuonAssociators/plugins/TriggerObjectFilterByCollection.cc new file mode 100644 index 0000000000000..498aaeeae2d5d --- /dev/null +++ b/MuonAnalysis/MuonAssociators/plugins/TriggerObjectFilterByCollection.cc @@ -0,0 +1,77 @@ +// +// $Id: TriggerObjectFilterByCollection.cc,v 1.1 2012/08/02 14:34:28 gpetrucc Exp $ +// + +/** + \class TriggerObjectFilterByCollection.h "MuonAnalysis/TagAndProbe/plugins/TriggerObjectFilterByCollection.h" + \brief Creates a filtered list of TriggerObjectStandAlone objects selecting by collection label + Inputs are: + - a list of TriggerObjectStandAlone (param. "src") + - a list of collections (param. "collections") + Outputs are: + - a list of TriggerObjectStandAlone + + \author Giovanni Petrucciani + \version $Id: TriggerObjectFilterByCollection.cc,v 1.1 2012/08/02 14:34:28 gpetrucc Exp $ +*/ + +#include +#include +#include +#include + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h" + + +class TriggerObjectFilterByCollection : public edm::EDProducer { + public: + explicit TriggerObjectFilterByCollection(const edm::ParameterSet & iConfig); + virtual ~TriggerObjectFilterByCollection() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); + + private: + edm::InputTag src_; + std::vector collections_; +}; + +TriggerObjectFilterByCollection::TriggerObjectFilterByCollection(const edm::ParameterSet & iConfig) : + src_(iConfig.getParameter("src")), + collections_(iConfig.getParameter >("collections")) +{ + produces >(); + for (unsigned int i = 0, n = collections_.size(); i < n; ++i) { + std::string &c = collections_[i]; + int numsc = std::count(c.begin(), c.end(), ':'); + if (numsc == 1) c.push_back(':'); + else if (numsc == 2) c.append("::"); + } +} + +void +TriggerObjectFilterByCollection::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { + using namespace edm; + + Handle > src; + iEvent.getByLabel(src_, src); + + std::auto_ptr > out(new std::vector()); + out->reserve(src->size()); + for (std::vector::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) { + const std::string &coll = it->collection(); + bool found = false; + for (std::vector::const_iterator ic = collections_.begin(), ec = collections_.end(); ic != ec; ++ic) { + if (strncmp(coll.c_str(), ic->c_str(), ic->size()) == 0) { found = true; break; } + } + if (found) out->push_back(*it); + } + + iEvent.put(out); +} + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(TriggerObjectFilterByCollection); diff --git a/MuonAnalysis/MuonAssociators/python/patMuonsWithTrigger_cff.py b/MuonAnalysis/MuonAssociators/python/patMuonsWithTrigger_cff.py index 42201ad51e152..745acc41c276e 100644 --- a/MuonAnalysis/MuonAssociators/python/patMuonsWithTrigger_cff.py +++ b/MuonAnalysis/MuonAssociators/python/patMuonsWithTrigger_cff.py @@ -18,6 +18,7 @@ embedPFCandidate = False, embedCaloMETMuonCorrs = cms.bool(False), embedTcMETMuonCorrs = cms.bool(False), + embedPfEcalEnergy = cms.bool(False), # then switch off some features we don't need #addTeVRefits = False, ## <<--- this doesn't work. PAT bug ?? embedPickyMuon = False, @@ -68,10 +69,14 @@ def addL1UserData(patMuonProducer, l1ModuleLabel = "muonL1Info"): ### ==== Unpack trigger, and match ==== from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger as patTriggerFull patTriggerFull.onlyStandAlone = True -patTrigger = cms.EDFilter("PATTriggerObjectStandAloneSelector", +patTrigger = cms.EDProducer("TriggerObjectFilterByCollection", src = cms.InputTag("patTriggerFull"), - cut = cms.string('coll("hltL1extraParticles") || coll("hltL2MuonCandidates") || coll("hltL3MuonCandidates") || coll("hltGlbTrkMuonCands") || coll("hltMuTrackJpsiCtfTrackCands") || coll("hltMuTrackJpsiEffCtfTrackCands") || coll("hltMuTkMuJpsiTrackerMuonCands")'), + collections = cms.vstring("hltL1extraParticles", "hltL2MuonCandidates", "hltL3MuonCandidates", "hltGlbTrkMuonCands", "hltMuTrackJpsiCtfTrackCands", "hltMuTrackJpsiEffCtfTrackCands", "hltMuTkMuJpsiTrackerMuonCands"), ) +#patTrigger = cms.EDFilter("PATTriggerObjectStandAloneSelector", +# src = cms.InputTag("patTriggerFull"), +# cut = cms.string('coll("hltL1extraParticles") || coll("hltL2MuonCandidates") || coll("hltL3MuonCandidates") || coll("hltGlbTrkMuonCands") || coll("hltMuTrackJpsiCtfTrackCands") || coll("hltMuTrackJpsiEffCtfTrackCands") || coll("hltMuTkMuJpsiTrackerMuonCands")'), +#) ### ==== Then perform a match for all HLT triggers of interest muonTriggerMatchHLT = cms.EDProducer( "PATTriggerMatcherDRDPtLessByR", @@ -107,14 +112,14 @@ def addL1UserData(patMuonProducer, l1ModuleLabel = "muonL1Info"): muonMatchHLTTrackMu = muonTriggerMatchHLT.clone(matchedCuts = cms.string('coll("hltMuTkMuJpsiTrackerMuonCands")'), maxDeltaR = 0.1, maxDPtRel = 10.0) #maxDeltaR Changed accordingly to Zoltan tuning. patTriggerMatchers1Mu = cms.Sequence( - muonMatchHLTL1 + + #muonMatchHLTL1 + # keep off by default, since it is slow and usually not needed muonMatchHLTL2 + muonMatchHLTL3 + muonMatchHLTL3T ) patTriggerMatchers1MuInputTags = [ - cms.InputTag('muonMatchHLTL1','propagatedReco'), # fake, will match if and only if he muon did propagate to station 2 - cms.InputTag('muonMatchHLTL1'), + #cms.InputTag('muonMatchHLTL1','propagatedReco'), # fake, will match if and only if he muon did propagate to station 2 + #cms.InputTag('muonMatchHLTL1'), cms.InputTag('muonMatchHLTL2'), cms.InputTag('muonMatchHLTL3'), cms.InputTag('muonMatchHLTL3T'), @@ -201,6 +206,19 @@ def addMCinfo(process): def addDiMuonTriggers(process): print "[MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff] Di-muon triggers are already enabled by default" +def addHLTL1Passthrough(process, embedder="patMuonsWithTrigger"): + process.patMuonsWithTriggerSequence.replace(process.muonMatchHLTL3, process.muonMatchHLTL1 + process.muonMatchHLTL3) + getattr(process,embedder).matches += [ cms.InputTag('muonMatchHLTL1'), cms.InputTag('muonMatchHLTL1','propagatedReco') ] + +def useExtendedL1Match(process, patMuonProd="patMuonsWithoutTrigger", byWhat=["ByQ"]): + process.load("MuonAnalysis.MuonAssociators.muonL1MultiMatch_cfi") + process.globalReplace('muonL1Info', process.muonL1MultiMatch.clone(src = process.muonL1Info.src.value())) + pmp = getattr(process, patMuonProd) + for X in byWhat: + pmp.userData.userInts.src += [ cms.InputTag('muonL1Info', "quality"+X) ] + pmp.userData.userFloats.src += [ cms.InputTag('muonL1Info', "deltaR"+X) ] + pmp.userData.userCands.src += [ cms.InputTag('muonL1Info', X) ] + def useL1MatchingWindowForSinglets(process): "Change the L1 trigger matching window to be suitable also for CSC single triggers" if hasattr(process, 'muonL1Info'): diff --git a/PhysicsTools/TagAndProbe/interface/BaseTreeFiller.h b/PhysicsTools/TagAndProbe/interface/BaseTreeFiller.h index 5ae5ac8a5102a..e95f399e2da0b 100644 --- a/PhysicsTools/TagAndProbe/interface/BaseTreeFiller.h +++ b/PhysicsTools/TagAndProbe/interface/BaseTreeFiller.h @@ -158,6 +158,10 @@ class BaseTreeFiller : boost::noncopyable { /// Write a string dump of this PSet into the TTree header. /// see macro in test directory for how to retrieve it from the output root file void writeProvenance(const edm::ParameterSet &pset) const ; + + //get the pileup weight informations + bool storePUweight() const {return storePUweight_;}; + protected: std::vector vars_; @@ -167,6 +171,7 @@ class BaseTreeFiller : boost::noncopyable { enum WeightMode { None, Fixed, External }; WeightMode weightMode_; edm::EDGetTokenT weightSrcToken_; + edm::EDGetTokenT PUweightSrcToken_; edm::EDGetTokenT recVtxsToken_; edm::EDGetTokenT beamSpotToken_; edm::EDGetTokenT metToken_; @@ -179,6 +184,9 @@ class BaseTreeFiller : boost::noncopyable { /// Add branches with run and lumisection number bool addRunLumiInfo_; + /// Store Pileup weight when running over Monte Carlo + bool storePUweight_; + /// Add branches with event variables: met, sum ET, .. etc. bool addEventVariablesInfo_; @@ -187,6 +195,7 @@ class BaseTreeFiller : boost::noncopyable { //implementation notice: these two are 'mutable' because we will fill them from a 'const' method mutable TTree * tree_; mutable float weight_; + mutable float PUweight_; mutable uint32_t run_, lumi_, mNPV_; mutable uint64_t event_; diff --git a/PhysicsTools/TagAndProbe/interface/TPTreeFiller.h b/PhysicsTools/TagAndProbe/interface/TPTreeFiller.h index d7c9217b458a1..f62f77956098d 100644 --- a/PhysicsTools/TagAndProbe/interface/TPTreeFiller.h +++ b/PhysicsTools/TagAndProbe/interface/TPTreeFiller.h @@ -12,13 +12,15 @@ class TPTreeFiller : public BaseTreeFiller { // We declare 'const' the methods which don't change the configuration void init(const edm::Event &iEvent) const ; - void fill(const reco::CandidateBaseRef &probe, double mass, bool mcTrue=false) const ; - + void fill(const reco::CandidateBaseRef &probe, double mass, bool mcTrue=false, float mcMass=0.0) const ; + protected: /// extra branch for the mass mutable float mass_; /// extra branch for the mc truth mutable int32_t mcTrue_; + /// extra branch for the mc-truth mass + mutable float mcMass_; }; } diff --git a/PhysicsTools/TagAndProbe/interface/TagProbeFitter.h b/PhysicsTools/TagAndProbe/interface/TagProbeFitter.h index 9a1daa2c93862..2ec2b5982afb5 100644 --- a/PhysicsTools/TagAndProbe/interface/TagProbeFitter.h +++ b/PhysicsTools/TagAndProbe/interface/TagProbeFitter.h @@ -50,6 +50,9 @@ class TagProbeFitter { /// set number of bins to use when making the plots; 0 = automatic void setBinsForMassPlots(int bins) ; + //// turn on or off the saving of distribution plots) + void setSaveDistributionsPlot(bool saveDistributionsPlot_) { doSaveDistributionsPlot = saveDistributionsPlot_; } + /// set a variable to be used as weight for a dataset. empty string means no weights. void setWeightVar(const std::string &weight); @@ -69,6 +72,9 @@ class TagProbeFitter { ///number of CPUs to use for the fit int numCPU; + ///save distribution plots + bool doSaveDistributionsPlot; + ///the default option wether to save the workspace for each bin bool saveWorkspace; @@ -142,10 +148,10 @@ class TagProbeFitter { void saveEfficiencyPlots(RooDataSet& eff, const TString& effName, RooArgSet& binnedVariables, RooArgSet& mappedCategories); ///makes the 1D plot - void makeEfficiencyPlot1D(RooDataSet& eff, RooRealVar& v, const TString& plotName, const TString& plotTitle, const TString& effName); - + void makeEfficiencyPlot1D(RooDataSet& eff, RooRealVar& v, const TString& plotName, const TString& plotTitle, const TString& effName, const char *catName = 0, int catIndex = -1); + ///makes the 2D plot - void makeEfficiencyPlot2D(RooDataSet& eff, RooRealVar& v1, RooRealVar& v2, const TString& plotName, const TString& plotTitle, const TString& effName); + void makeEfficiencyPlot2D(RooDataSet& eff, RooRealVar& v1, RooRealVar& v2, const TString& plotName, const TString& plotTitle, const TString& effName, const char *catName = 0, int catIndex = -1); }; diff --git a/PhysicsTools/TagAndProbe/interface/TagProbePairMaker.h b/PhysicsTools/TagAndProbe/interface/TagProbePairMaker.h index 36c5553fa14c2..1545300623f8b 100644 --- a/PhysicsTools/TagAndProbe/interface/TagProbePairMaker.h +++ b/PhysicsTools/TagAndProbe/interface/TagProbePairMaker.h @@ -38,6 +38,10 @@ namespace tnp { double arbitrationMass_; void arbitrate(TagProbePairs &pairs) const ; TRandom2* randGen_; + + // SCZ + bool phiCutForTwoLeg_; + void phiCutByEventNumber(TagProbePairs &pairs, int eventNumber) const ; }; } diff --git a/PhysicsTools/TagAndProbe/interface/TriggerCandProducer.h b/PhysicsTools/TagAndProbe/interface/TriggerCandProducer.h index b3daff54c782b..58286a6f35fed 100644 --- a/PhysicsTools/TagAndProbe/interface/TriggerCandProducer.h +++ b/PhysicsTools/TagAndProbe/interface/TriggerCandProducer.h @@ -44,9 +44,14 @@ class TriggerCandProducer : public edm::EDProducer std::vector hltTags_; edm::InputTag theRightHLTTag_; double delRMatchingCut_; + double objEtMin_; + double objEtaMax_; std::string filterName_; bool storeRefCollection_; + bool antiSelect_; + bool isTriggerOR_; bool isFilter_; + bool noHltFiring_; bool printIndex_; bool changed_; HLTConfigProvider hltConfig_; diff --git a/PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.cc b/PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.cc new file mode 100644 index 0000000000000..21703296bdcdd --- /dev/null +++ b/PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.cc @@ -0,0 +1,95 @@ +#include "PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.h" +#include "DataFormats/Common/interface/AssociationVector.h" +#include "DataFormats/Common/interface/AssociationMap.h" +#include "DataFormats/Common/interface/OneToValue.h" +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" + +namespace pat { namespace helper { +class AnyNumberAssociationAdaptor { + public: + typedef float value_type; + typedef edm::View Collection; + template struct AssoVec { typedef typename edm::AssociationVector > type; }; + + AnyNumberAssociationAdaptor(const edm::InputTag &in, const edm::ParameterSet & iConfig, edm::ConsumesCollector && iC) : + type_(Uninitialized), in_(in), label_(in.label() + in.instance()), + tokenVMd_(iC.consumes >(in)), + tokenVMf_(iC.consumes >(in)), + tokenVMi_(iC.consumes >(in)), + tokenVMb_(iC.consumes >(in)), + tokenAVd_(iC.consumes::type >(in)), + tokenAVf_(iC.consumes::type >(in)), + tokenAVi_(iC.consumes::type >(in)), + tokenAVb_(iC.consumes::type >(in)) + { } + + const std::string & label() { return label_; } + + bool run(const edm::Event &iEvent, const Collection &coll, std::vector &ret) { + switch (type_) { + case Uninitialized: + if (run_ >(tokenVMd_, iEvent, coll, ret)) { type_ = ValueMapDouble; return true; } + if (run_ >(tokenVMf_, iEvent, coll, ret)) { type_ = ValueMapFloat; return true; } + if (run_ >(tokenVMi_, iEvent, coll, ret)) { type_ = ValueMapInt; return true; } + if (run_ >(tokenVMb_, iEvent, coll, ret)) { type_ = ValueMapBool; return true; } + if (run_::type >(tokenAVd_, iEvent, coll, ret)) { type_ = AssoVecDouble; return true; } + if (run_::type >(tokenAVf_, iEvent, coll, ret)) { type_ = AssoVecFloat; return true; } + if (run_::type >(tokenAVi_, iEvent, coll, ret)) { type_ = AssoVecInt; return true; } + if (run_::type >(tokenAVb_, iEvent, coll, ret)) { type_ = AssoVecBool; return true; } + type_ = Nothing; return false; + break; + case ValueMapDouble : return run_ >(tokenVMd_, iEvent, coll, ret); + case ValueMapFloat : return run_ >(tokenVMf_, iEvent, coll, ret); + case ValueMapInt : return run_ >(tokenVMi_, iEvent, coll, ret); + case ValueMapBool : return run_ >(tokenVMb_, iEvent, coll, ret); + case AssoVecDouble : return run_::type >(tokenAVd_, iEvent, coll, ret); + case AssoVecFloat : return run_::type >(tokenAVf_, iEvent, coll, ret); + case AssoVecInt : return run_::type >(tokenAVi_, iEvent, coll, ret); + case AssoVecBool : return run_::type >(tokenAVb_, iEvent, coll, ret); + case Nothing : return false; + } + return false; + } + private: + enum Type { Uninitialized = 0, + ValueMapDouble, ValueMapFloat, ValueMapInt, ValueMapBool, + AssoVecDouble , AssoVecFloat, AssoVecInt, AssoVecBool, + Nothing }; + template bool run_(const edm::EDGetTokenT & token, const edm::Event &iEvent, const Collection &coll, std::vector &ret) ; + Type type_; + edm::InputTag in_; + std::string label_; + edm::EDGetTokenT > tokenVMd_; + edm::EDGetTokenT > tokenVMf_; + edm::EDGetTokenT > tokenVMi_; + edm::EDGetTokenT > tokenVMb_; + edm::EDGetTokenT::type > tokenAVd_; + edm::EDGetTokenT::type > tokenAVf_; + edm::EDGetTokenT::type > tokenAVi_; + edm::EDGetTokenT::type > tokenAVb_; + +}; + +template +bool AnyNumberAssociationAdaptor::run_(const edm::EDGetTokenT & token, const edm::Event &iEvent, const Collection &coll, std::vector &ret) { + edm::Handle handle; + iEvent.getByToken(token, handle); + if (handle.failedToGet()) return false; + + for (size_t i = 0, n = coll.size(); i < n; ++i) { + reco::CandidateBaseRef ref = coll.refAt(i); + ret.push_back( (*handle)[ref] ); + } + return true; +} + +typedef ManyThingsToValueMaps AnyNumbersToValueMaps; + +}} // namespaces + + +#include "FWCore/Framework/interface/MakerMacros.h" +using namespace pat::helper; +DEFINE_FWK_MODULE(AnyNumbersToValueMaps); diff --git a/PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.h b/PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.h new file mode 100644 index 0000000000000..3614d63032d5e --- /dev/null +++ b/PhysicsTools/TagAndProbe/plugins/AnythingToValueMap.h @@ -0,0 +1,109 @@ +#ifndef PhysicsTools_TagAndProbe_interface_AnythingToValueMap_h +#define PhysicsTools_TagAndProbe_interface_AnythingToValueMap_h + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/Common/interface/View.h" +#include "DataFormats/Common/interface/RefToBase.h" +#include "DataFormats/Common/interface/ValueMap.h" + +namespace pat { namespace helper { + + template + class AnythingToValueMap : public edm::EDProducer { + public: + typedef typename edm::ValueMap Map; + typedef typename Map::Filler MapFiller; + explicit AnythingToValueMap(const edm::ParameterSet & iConfig) : + failSilently_(iConfig.getUntrackedParameter("failSilently", false)), + src_(consumes(iConfig.getParameter("src"))), + adaptor_(iConfig,consumesCollector()) { + produces< Map >(adaptor_.label()); + } + ~AnythingToValueMap() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) ; + + private: + bool failSilently_; + edm::EDGetTokenT src_; + Adaptor adaptor_; + }; + +template +void AnythingToValueMap::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { + edm::Handle handle; + iEvent.getByToken(src_, handle); + if (handle.failedToGet() && failSilently_) return; + + bool adaptorOk = adaptor_.init(iEvent); + if ((!adaptorOk) && failSilently_) return; + + std::vector ret; + ret.reserve(handle->size()); + + adaptor_.run(*handle, ret); + + std::auto_ptr map(new Map()); + MapFiller filler(*map); + filler.insert(handle, ret.begin(), ret.end()); + filler.fill(); + iEvent.put(map, adaptor_.label()); +} + + template + class ManyThingsToValueMaps : public edm::EDProducer { + public: + typedef typename edm::ValueMap Map; + typedef typename Map::Filler MapFiller; + explicit ManyThingsToValueMaps(const edm::ParameterSet & iConfig) : + failSilently_(iConfig.getUntrackedParameter("failSilently", false)), + src_(consumes(iConfig.getParameter("collection"))), + inputs_(iConfig.getParameter >("associations")) + { + for (std::vector::const_iterator it = inputs_.begin(), ed = inputs_.end(); it != ed; ++it) { + adaptors_.push_back(Adaptor(*it, iConfig, consumesCollector())); + produces< Map >(adaptors_.back().label()); + } + } + ~ManyThingsToValueMaps() { } + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup) ; + + private: + bool failSilently_; + edm::EDGetTokenT src_; + std::vector inputs_; + std::vector adaptors_; + }; + +template +void ManyThingsToValueMaps::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { + edm::Handle handle; + iEvent.getByToken(src_, handle); + if (handle.failedToGet() && failSilently_) return; + + std::vector ret; + ret.reserve(handle->size()); + + for (typename std::vector::iterator it = adaptors_.begin(), ed = adaptors_.end(); it != ed; ++it) { + ret.clear(); + if (it->run(iEvent, *handle, ret)) { + std::auto_ptr map(new Map()); + MapFiller filler(*map); + filler.insert(handle, ret.begin(), ret.end()); + filler.fill(); + iEvent.put(map, it->label()); + } else { + if (!failSilently_) throw cms::Exception("ManyThingsToValueMaps") << "Error in adapter " << it->label() << "\n"; + } + } +} + +} } // namespace; + + +#endif diff --git a/PhysicsTools/TagAndProbe/plugins/NearbyCandCountComputer.cc b/PhysicsTools/TagAndProbe/plugins/NearbyCandCountComputer.cc index 85156abbd3022..4c55bf6101379 100644 --- a/PhysicsTools/TagAndProbe/plugins/NearbyCandCountComputer.cc +++ b/PhysicsTools/TagAndProbe/plugins/NearbyCandCountComputer.cc @@ -75,7 +75,7 @@ NearbyCandCountComputer::produce(edm::Event & iEvent, const edm::EventSetup & iS for (probe = probes->begin(); probe != endprobes; ++probe) { float count = 0; for (object = beginobjects; object != endobjects; ++object) { - if ((deltaR2(*probe, *object) >= deltaR2_) && + if ((deltaR2(*probe, *object) < deltaR2_) && objCut_(*object) && pairCut_(pat::DiObjectProxy(*probe, *object))) { count++; diff --git a/PhysicsTools/TagAndProbe/plugins/ProbeMulteplicityProducer.cc b/PhysicsTools/TagAndProbe/plugins/ProbeMulteplicityProducer.cc new file mode 100644 index 0000000000000..f891643471d32 --- /dev/null +++ b/PhysicsTools/TagAndProbe/plugins/ProbeMulteplicityProducer.cc @@ -0,0 +1,91 @@ +// + +/** + \class ProbeMulteplicityProducer" + \brief Matcher of number of reconstructed objects in the event to probe + + \author Kalanand Mishra +*/ + + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/Common/interface/View.h" + +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "CommonTools/Utils/interface/StringCutObjectSelector.h" + + +class ProbeMulteplicityProducer : public edm::EDProducer { + public: + explicit ProbeMulteplicityProducer(const edm::ParameterSet & iConfig); + virtual ~ProbeMulteplicityProducer() ; + + virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup); + + private: + edm::EDGetTokenT pairs_; + StringCutObjectSelector pairCut_; // lazy parsing, to allow cutting on variables not in reco::Candidate class + StringCutObjectSelector probeCut_; // lazy parsing, to allow cutting on variables not in reco::Candidate class +}; + + +ProbeMulteplicityProducer::ProbeMulteplicityProducer(const edm::ParameterSet & iConfig) : + pairs_(consumes(iConfig.getParameter("pairs"))), + pairCut_(iConfig.existsAs("pairSelection") ? iConfig.getParameter("pairSelection") : "", true), + probeCut_(iConfig.existsAs("probeSelection") ? iConfig.getParameter("probeSelection") : "", true) +{ + produces >(); +} + + + +ProbeMulteplicityProducer::~ProbeMulteplicityProducer() +{ +} + + +void +ProbeMulteplicityProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetup) { + using namespace edm; + + // read input + Handle > pairs; + iEvent.getByToken(pairs_, pairs); + + // fill + unsigned int i = 0; + std::vector tagKeys; + std::vector values; + View::const_iterator pair, endpairs = pairs->end(); + for (pair = pairs->begin(); pair != endpairs; ++pair, ++i) { + reco::CandidateBaseRef probeRef = pair->daughter(1)->masterClone(); + unsigned int tagKey = pair->daughter(0)->masterClone().key(); + unsigned int copies = 1; + if (pairCut_(*pair) && probeCut_(*probeRef)) { + for (unsigned int j = 0; j < i; ++j) if (tagKeys[j] == tagKey) copies++; + for (unsigned int j = 0; j < i; ++j) if (tagKeys[j] == tagKey) values[j] = copies; + } else { + tagKey = std::numeric_limits::max(); + copies = 0; + } + tagKeys.push_back(tagKey); + values.push_back(copies); + } + + // convert into ValueMap and store + std::auto_ptr > valMap(new ValueMap()); + ValueMap::Filler filler(*valMap); + filler.insert(pairs, values.begin(), values.end()); + filler.fill(); + iEvent.put(valMap); +} + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(ProbeMulteplicityProducer); diff --git a/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeAnalyzer.cc b/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeAnalyzer.cc index 582c105f53adb..d008e1a3ce326 100644 --- a/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeAnalyzer.cc +++ b/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeAnalyzer.cc @@ -42,6 +42,9 @@ TagProbeFitTreeAnalyzer::TagProbeFitTreeAnalyzer(const edm::ParameterSet& pset): fitter.setBinsForMassPlots(pset.getParameter("binsForMassPlots")); } + if (pset.existsAs("saveDistributionsPlot")) { + fitter.setSaveDistributionsPlot(pset.getParameter("saveDistributionsPlot")); + } if (pset.existsAs("WeightVariable")) { fitter.setWeightVar(pset.getParameter("WeightVariable")); } diff --git a/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc b/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc index c9faa83dcef35..68cbf3d8e76df 100644 --- a/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc +++ b/PhysicsTools/TagAndProbe/plugins/TagProbeFitTreeProducer.cc @@ -148,13 +148,12 @@ TagProbeFitTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup using namespace edm; using namespace std; Handle src, allProbes; Handle > > tagMatches, probeMatches; - treeFiller_->init(iEvent); // read out info from the event if needed (external vars, list of passing probes, ...) if (oldTagFiller_.get()) oldTagFiller_->init(iEvent); if (tagFiller_.get()) tagFiller_->init(iEvent); if (pairFiller_.get()) pairFiller_->init(iEvent); if (mcFiller_.get()) mcFiller_->init(iEvent); - + // on mc we want to load also the MC match info if (isMC_) { iEvent.getByToken(tagMatchesToken_, tagMatches); @@ -167,16 +166,20 @@ TagProbeFitTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup for (tnp::TagProbePairs::const_iterator it = pairs.begin(), ed = pairs.end(); it != ed; ++it) { // on mc, fill mc info (on non-mc, let it to 'true', the treeFiller will ignore it anyway bool mcTrue = false; + float mcMass = 0.f; if (isMC_) { reco::GenParticleRef mtag = (*tagMatches)[it->tag], mprobe = (*probeMatches)[it->probe]; mcTrue = checkMother(mtag) && checkMother(mprobe); - if (mcTrue && mcFiller_.get()) mcFiller_->fill(reco::CandidateBaseRef(mprobe)); - } + if (mcTrue) { + mcMass = (mtag->p4() + mprobe->p4()).mass(); + if (mcFiller_.get()) mcFiller_->fill(reco::CandidateBaseRef(mprobe)); + } + } // fill in the variables for this t+p pair if (tagFiller_.get()) tagFiller_->fill(it->tag); if (oldTagFiller_.get()) oldTagFiller_->fill(it->tag); if (pairFiller_.get()) pairFiller_->fill(it->pair); - treeFiller_->fill(it->probe, it->mass, mcTrue); + treeFiller_->fill(it->probe, it->mass, mcTrue, mcMass); } if (isMC_ && makeMCUnbiasTree_) { diff --git a/PhysicsTools/TagAndProbe/plugins/TrgMatchedObjectProducer.cc b/PhysicsTools/TagAndProbe/plugins/TrgMatchedObjectProducer.cc index 30794c37fb85b..75b18c860ae97 100644 --- a/PhysicsTools/TagAndProbe/plugins/TrgMatchedObjectProducer.cc +++ b/PhysicsTools/TagAndProbe/plugins/TrgMatchedObjectProducer.cc @@ -14,6 +14,10 @@ DEFINE_FWK_MODULE( trgMatchedMuonProducer ); typedef TriggerCandProducer< reco::GsfElectron > trgMatchedGsfElectronProducer; DEFINE_FWK_MODULE( trgMatchedGsfElectronProducer ); +#include "DataFormats/PatCandidates/interface/Electron.h" +typedef TriggerCandProducer< reco::GsfElectron > trgMatchedPatElectronProducer; +DEFINE_FWK_MODULE( trgMatchedPatElectronProducer ); + #include "DataFormats/JetReco/interface/Jet.h" typedef TriggerCandProducer< reco::Jet > trgMatchedJetProducer; DEFINE_FWK_MODULE( trgMatchedJetProducer ); diff --git a/PhysicsTools/TagAndProbe/src/BaseTreeFiller.cc b/PhysicsTools/TagAndProbe/src/BaseTreeFiller.cc index a903f1e53a233..078d63ed12eb2 100644 --- a/PhysicsTools/TagAndProbe/src/BaseTreeFiller.cc +++ b/PhysicsTools/TagAndProbe/src/BaseTreeFiller.cc @@ -50,6 +50,11 @@ tnp::BaseTreeFiller::BaseTreeFiller(const char *name, const edm::ParameterSet& i if (weightMode_ != None) { tree_->Branch("weight", &weight_, "weight/F"); } + storePUweight_ = iConfig.existsAs("PUWeightSrc") ? true: false; + if(storePUweight_) { + PUweightSrcToken_ = iC.consumes(iConfig.getParameter("PUWeightSrc")); + tree_->Branch("PUweight", &PUweight_, "PUweight/F"); + } addRunLumiInfo_ = iConfig.existsAs("addRunLumiInfo") ? iConfig.getParameter("addRunLumiInfo") : false; if (addRunLumiInfo_) { @@ -86,9 +91,12 @@ tnp::BaseTreeFiller::BaseTreeFiller(const char *name, const edm::ParameterSet& i } tnp::BaseTreeFiller::BaseTreeFiller(BaseTreeFiller &main, const edm::ParameterSet &iConfig, edm::ConsumesCollector && iC, const std::string &branchNamePrefix) : - addEventVariablesInfo_(false), - tree_(0) + addRunLumiInfo_(false), + addEventVariablesInfo_(false), + tree_(0) { + addRunLumiInfo_ = main.addRunLumiInfo_; + storePUweight_ = main.storePUweight_; addBranches_(main.tree_, iConfig, iC, branchNamePrefix); } @@ -149,6 +157,14 @@ void tnp::BaseTreeFiller::init(const edm::Event &iEvent) const { weight_ = *weight; } + ///// ********** Pileup weight: needed for MC re-weighting for PU ************* + edm::Handle > weightPU; + if(storePUweight_) { + bool isPresent = iEvent.getByToken(PUweightSrcToken_, weightPU); + if(isPresent) PUweight_ = (*weightPU).at(0); + else PUweight_ = 1.0; + } + if (addEventVariablesInfo_) { /// *********** store some event variables: MET, SumET ****** //////////// Primary vertex ////////////// diff --git a/PhysicsTools/TagAndProbe/src/TPTreeFiller.cc b/PhysicsTools/TagAndProbe/src/TPTreeFiller.cc index ccec8660c4e0d..65493c73fe3bf 100644 --- a/PhysicsTools/TagAndProbe/src/TPTreeFiller.cc +++ b/PhysicsTools/TagAndProbe/src/TPTreeFiller.cc @@ -9,7 +9,9 @@ tnp::TPTreeFiller::TPTreeFiller(const edm::ParameterSet& config, edm::ConsumesCo // set up MC if needed if (config.getParameter("isMC")) { tree_->Branch("mcTrue", &mcTrue_, "mcTrue/I"); + tree_->Branch("mcMass", &mcMass_, "mcMass/F"); } + } tnp::TPTreeFiller::~TPTreeFiller() {} @@ -18,8 +20,9 @@ void tnp::TPTreeFiller::init(const edm::Event &iEvent) const { tnp::BaseTreeFiller::init(iEvent); } -void tnp::TPTreeFiller::fill(const reco::CandidateBaseRef &probe, double mass, bool mcTrue) const { +void tnp::TPTreeFiller::fill(const reco::CandidateBaseRef &probe, double mass, bool mcTrue, float mcMass) const { mass_ = mass; mcTrue_ = mcTrue; + mcMass_ = mcMass; tnp::BaseTreeFiller::fill(probe); } diff --git a/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc b/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc index f85ff458abb7e..ddf965a2791ca 100644 --- a/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc +++ b/PhysicsTools/TagAndProbe/src/TagProbeFitter.cc @@ -7,37 +7,43 @@ #include "TPad.h" #include "TText.h" #include "TCanvas.h" +#include "TGraphAsymmErrors.h" #include "TH2F.h" #include "TStyle.h" -#include "RooWorkspace.h" -#include "RooDataSet.h" -#include "RooDataHist.h" -#include "RooRealVar.h" -#include "RooFormulaVar.h" +#include "Math/QuantFuncMathCore.h" +#include "Roo1DTable.h" +#include "RooAbsDataStore.h" +#include "RooAbsReal.h" #include "RooAddPdf.h" -#include "RooGlobalFunc.h" -#include "RooCategory.h" -#include "RooSimultaneous.h" -#include "RooPlot.h" -#include "RooFitResult.h" #include "RooBinning.h" #include "RooBinningCategory.h" -#include "RooMultiCategory.h" +#include "RooCategory.h" +#include "RooChebychev.h" +#include "RooDataHist.h" +#include "RooDataSet.h" +#include "RooEfficiency.h" +#include "RooExtendPdf.h" +#include "RooFitResult.h" +#include "RooFormulaVar.h" +#include "RooGaussian.h" +#include "RooGenericPdf.h" +#include "RooGlobalFunc.h" +#include "RooLinkedListIter.h" #include "RooMappedCategory.h" -#include "RooThresholdCategory.h" -#include "Roo1DTable.h" +#include "RooMinimizer.h" #include "RooMinuit.h" +#include "RooMsgService.h" +#include "RooMultiCategory.h" #include "RooNLLVar.h" -#include "RooAbsDataStore.h" -#include "RooEfficiency.h" -#include "RooGaussian.h" -#include "RooChebychev.h" +#include "RooNumIntConfig.h" +#include "RooPlot.h" #include "RooProdPdf.h" -#include "RooGenericPdf.h" -#include "RooExtendPdf.h" +#include "RooProfileLL.h" +#include "RooRealVar.h" +#include "RooSimultaneous.h" +#include "RooThresholdCategory.h" #include "RooTrace.h" -#include "RooMsgService.h" -#include "Math/QuantFuncMathCore.h" +#include "RooWorkspace.h" using namespace std; using namespace RooFit; @@ -66,6 +72,12 @@ TagProbeFitter::TagProbeFitter(const std::vector& inputFileNames, s quiet = false; binnedFit = false; + + doSaveDistributionsPlot = true; + + // make integration very precise + RooAbsReal::defaultIntegratorConfig()->setEpsAbs(1e-13); + RooAbsReal::defaultIntegratorConfig()->setEpsRel(1e-13); } TagProbeFitter::~TagProbeFitter(){ @@ -84,7 +96,9 @@ void TagProbeFitter::setQuiet(bool quiet_) { } } bool TagProbeFitter::addVariable(string name, string title, double low, double hi, string units){ - variables.addClone(RooRealVar(name.c_str(), title.c_str(), low, hi, units.c_str())); + RooRealVar temp(name.c_str(), title.c_str(), low, hi, units.c_str()); + temp.setBins(5000,"cache"); + variables.addClone(temp); return true; } @@ -235,7 +249,7 @@ string TagProbeFitter::calculateEfficiency(string dirName,const std::vector0)?binToPDFmap[0].c_str():""); + RooMappedCategory pdfCategory("_pdfCategory_", "_pdfCategory_", allCats, (binToPDFmap.size()>0)?binToPDFmap[0].c_str():"all"); for(unsigned int i = 1; igetVal()))); + RooAbsData* data_bin = (RooDataSet*) data.reduce(Cut(TString::Format("allCats==%d",t->getVal()))); //set the category variables by reading the first event const RooArgSet* row = data_bin->get(); @@ -293,14 +306,17 @@ string TagProbeFitter::calculateEfficiency(string dirName,const std::vectorimport(*data_bin); + delete data_bin; // clean up earlier + data_bin = w->data("data"); // point to the data that's in the workspace now (saves memory) + //save the distribution of variables - saveDistributionsPlot(w); + if (doSaveDistributionsPlot) saveDistributionsPlot(w); //do the fitting only if there is sufficient number of events if(data_bin->numEntries()>0){ //set the values of binnedVariables to the mean value in this data bin RooArgSet meanOfVariables; - TIterator* vit = binnedVariables.createIterator(); - for(RooRealVar* v = (RooRealVar*)vit->Next(); v!=0; v = (RooRealVar*)vit->Next() ){ + RooLinkedListIter vit = binnedVariables.iterator(); + for(RooRealVar* v = (RooRealVar*)vit.Next(); v!=0; v = (RooRealVar*)vit.Next() ){ meanOfVariables.addClone(*v); double mean = w->data("data")->mean(*v); RooBinning binning((RooBinning&)v->getBinning()); @@ -309,7 +325,7 @@ string TagProbeFitter::calculateEfficiency(string dirName,const std::vectorget(0) meanOfVariables.addClone(*data_bin->get(0), true); @@ -332,7 +348,6 @@ string TagProbeFitter::calculateEfficiency(string dirName,const std::vectorWrite("w"); } //clean up - delete data_bin; delete w; //get back to the initial directory gDirectory->cd(".."); @@ -359,30 +374,40 @@ string TagProbeFitter::calculateEfficiency(string dirName,const std::vector res(0); + RooAbsData *data = w->data("data"); + std::auto_ptr bdata; if (binnedFit) { // get variables from data, which contain also other binning or expression variables const RooArgSet *dataObs = data->get(0); // remove everything which is not a dependency of the pdf RooArgSet *obs = w->pdf("simPdf")->getObservables(dataObs); - RooDataHist *bdata = new RooDataHist("data_binned", "data_binned", *obs, *data); + bdata.reset(new RooDataHist("data_binned", "data_binned", *obs, *data)); w->import(*bdata); - data = bdata; + data = w->data("data_binned"); delete obs; } double totPassing = data->sumEntries("_efficiencyCategory_==_efficiencyCategory_::Passed"); double totFailing = data->sumEntries("_efficiencyCategory_==_efficiencyCategory_::Failed"); + RooAbsReal* simNLL = w->pdf("simPdf")->createNLL(*data,Extended(true),NumCPU(numCPU)); + + RooMinimizer minimizer(*simNLL); // we are going to use this for 'scan' + RooMinuit minuit(*simNLL); + minuit.setStrategy(1); + minuit.setProfile(true); + RooProfileLL profileLL("simPdfNLL","",*simNLL,*w->var("efficiency")); + + //******* The block of code below is to make the fit converge faster. // ****** This part is OPTIONAL, i.e., off be default. User can activate this // ****** by setting the following parameters: "fixVars" and "floatShapeParameters" @@ -412,11 +437,21 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar // fix them varFixer(w,true); //do fit - w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), PrintLevel(quiet?-1:1), PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); + minimizer.minimize("Minuit2","Scan"); + minuit.migrad(); + minuit.hesse(); + //minuit.minos(); + //w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), Strategy(2), + //PrintLevel(quiet?-1:1), PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); //release vars varFixer(w,false); //do fit - w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), PrintLevel(quiet?-1:1), PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); + minimizer.minimize("Minuit2","Scan"); + minuit.migrad(); + minuit.hesse(); + //minuit.minos(); + //w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), Strategy(2), + //PrintLevel(quiet?-1:1), PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); //save vars varSaver(w); // now we have a starting point. Fit will converge faster. @@ -425,23 +460,36 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar // here we can use initial values if we want (this works for each bin) if(!floatShapeParameters) varRestorer(w); //restore vars - - // if we don't want to "floatShapeParameters" we just fix, fit, - // release, and fit again. No need for global fitting above. - //fix vars - varFixer(w,true); //do fit - res = w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), Minos(*w->var("efficiency")), PrintLevel(quiet?-1:1), PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); + minimizer.minimize("Minuit2","Scan"); + minuit.migrad(); + minuit.hesse(); + // initialize the profile likelihood + profileLL.getVal(); + RooMinimizer* profMinuit = profileLL.minimizer(); + profMinuit->setProfile(true); + profMinuit->setStrategy(2); + profMinuit->setPrintLevel(1); + profMinuit->minos(*w->var("efficiency")); + res.reset( profMinuit->save() ); + //res = w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), Strategy(2), + //Minos(*w->var("efficiency")), PrintLevel(quiet?-1:1), + //PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); }//if(!fixVars.empty()) - + // (default = true) if we don't want to fix any parameters or want to fit each bin with all parameters floating if(floatShapeParameters){ //release vars varFixer(w,false); //do fit - res = w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), Minos(*w->var("efficiency")), PrintLevel(quiet?-1:1), PrintEvalErrors(quiet?-1:1), Warnings(!quiet)); - } + minimizer.minimize("Minuit2","Scan"); + minuit.migrad(); + minuit.hesse(); + res.reset( w->pdf("simPdf")->fitTo(*data, Save(true), Extended(true), NumCPU(numCPU), Strategy(2), + Minos(*w->var("efficiency")), PrintLevel(quiet?-1:1), + PrintEvalErrors(quiet?-1:1), Warnings(!quiet)) ); + } @@ -460,9 +508,9 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar efficiency.setAsymError(errLo, errHi); if (totPassing * totFailing == 0) { - RooRealVar* nS = (RooRealVar*) res->floatParsFinal().find("numSignalAll"); - //RooRealVar* nB = (RooRealVar*) res->floatParsFinal().find(totPassing != 0 ? "numBackgroundPass" : "numBackgroundFail"); - double cerr = ROOT::Math::beta_quantile( 1-(1.0-.68540158589942957)/2, 1, nS->getVal() ); + RooRealVar* nTot = (RooRealVar*) res->floatParsFinal().find("numTot"); + RooRealVar* fSig = (RooRealVar*) res->floatParsFinal().find("fSigAll"); + double cerr = ROOT::Math::beta_quantile( 1-(1.0-.68540158589942957)/2, 1, nTot->getVal() * fSig->getVal() ); /* std::cout << "======================================================================================" << std::endl; std::cout << "======= totPassing " << totPassing << ", totFailing " << totFailing << std::endl; @@ -480,6 +528,8 @@ void TagProbeFitter::doFitEfficiency(RooWorkspace* w, string pdfName, RooRealVar efficiency.setAsymError(-cerr,0); } } + + delete simNLL; } void TagProbeFitter::createPdf(RooWorkspace* w, vector& pdfCommands){ @@ -497,8 +547,11 @@ void TagProbeFitter::createPdf(RooWorkspace* w, vector& pdfCommands){ } } // setup the simultaneous extended pdf - w->factory("expr::numSignalPass('efficiency*numSignalAll', efficiency, numSignalAll[0.,1e10])"); - w->factory("expr::numSignalFail('(1-efficiency)*numSignalAll', efficiency, numSignalAll)"); + + w->factory("expr::nSignalPass('efficiency*fSigAll*numTot', efficiency, fSigAll[.9,0,1],numTot[1,0,1e10])"); + w->factory("expr::nSignalFail('(1-efficiency)*fSigAll*numTot', efficiency, fSigAll,numTot)"); + w->factory("expr::nBkgPass('effBkg*(1-fSigAll)*numTot', effBkg[.9,0,1],fSigAll,numTot)"); + w->factory("expr::nBkgFail('(1-effBkg)*(1-fSigAll)*numTot', effBkg,fSigAll,numTot)"); TString sPass = "signal", sFail = "signal"; if (w->pdf("signalPass") != 0 && w->pdf("signalFail") != 0) { if (w->pdf("signal") != 0) throw std::logic_error("You must either define one 'signal' PDF or two PDFs ('signalPass', 'signalFail'), not both!"); @@ -510,8 +563,9 @@ void TagProbeFitter::createPdf(RooWorkspace* w, vector& pdfCommands){ } else { throw std::logic_error("You must either define one 'signal' PDF or two PDFs ('signalPass', 'signalFail')"); } - w->factory("SUM::pdfPass(numSignalPass*"+sPass+", numBackgroundPass[0.,1e10]*backgroundPass)"); - w->factory("SUM::pdfFail(numSignalFail*"+sFail+", numBackgroundFail[0.,1e10]*backgroundFail)"); + w->factory("SUM::pdfPass(nSignalPass*"+sPass+", nBkgPass*backgroundPass)"); //fBkgPass* + w->factory("SUM::pdfFail(nSignalFail*"+sFail+", nBkgFail*backgroundFail)"); //fBkgFail* + w->factory("SIMUL::simPdf(_efficiencyCategory_, Passed=pdfPass, Failed=pdfFail)"); // signalFractionInPassing is not used in the fit just to set the initial values if (w->pdf("simPdf") == 0) throw std::runtime_error("Could not create simultaneous fit pdf."); @@ -526,37 +580,31 @@ void TagProbeFitter::setInitialValues(RooWorkspace* w){ double totPassing = w->data("data")->sumEntries("_efficiencyCategory_==_efficiencyCategory_::Passed"); double totFailinging = w->data("data")->sumEntries("_efficiencyCategory_==_efficiencyCategory_::Failed"); double numSignalAll = totPassing*signalFractionInPassing/signalEfficiency; + + //std::cout << "Number of probes: " << totPassing+totFailinging << std::endl; + // check if this value is inconsistent on the failing side if(numSignalAll*(1-signalEfficiency) > totFailinging) numSignalAll = totFailinging; // now set the values - w->var("numSignalAll")->setVal(numSignalAll); - w->var("numBackgroundPass")->setVal(totPassing - numSignalAll*signalEfficiency); - w->var("numBackgroundFail")->setVal(totFailinging - numSignalAll*(1-signalEfficiency)); + w->var("numTot")->setVal(totPassing+totFailinging); + w->var("numTot")->setMax(2.0*(totPassing+totFailinging)+10); //wiggle room in case of 0 events in bin if (totPassing == 0) { w->var("efficiency")->setVal(0.0); w->var("efficiency")->setAsymError(0,1); w->var("efficiency")->setConstant(false); - w->var("numBackgroundPass")->setVal(0.0); - w->var("numBackgroundPass")->setConstant(true); - w->var("numBackgroundFail")->setConstant(false); } else if (totFailinging == 0) { w->var("efficiency")->setVal(1.0); w->var("efficiency")->setAsymError(-1,0); w->var("efficiency")->setConstant(false); - w->var("numBackgroundPass")->setConstant(false); - w->var("numBackgroundFail")->setVal(0.0); - w->var("numBackgroundFail")->setConstant(true); } else { w->var("efficiency")->setConstant(false); - w->var("numBackgroundPass")->setConstant(false); - w->var("numBackgroundFail")->setConstant(false); } // if signal fraction is 1 then set the number of background events to 0. - RooRealVar* fBkgPass = w->var("numBackgroundPass"); - if(signalFractionInPassing==1.0) { fBkgPass->setVal(0.0); fBkgPass->setConstant(true); } + //RooRealVar* fBkgPass = w->var("numBackgroundPass"); + //if(signalFractionInPassing==1.0) { fBkgPass->setVal(0.0); fBkgPass->setConstant(true); } // save initial state for reference w->saveSnapshot("initialState",w->components()); @@ -569,10 +617,10 @@ void TagProbeFitter::saveFitPlot(RooWorkspace* w){ RooAbsData* dataPass = dataAll->reduce(Cut("_efficiencyCategory_==_efficiencyCategory_::Passed")); RooAbsData* dataFail = dataAll->reduce(Cut("_efficiencyCategory_==_efficiencyCategory_::Failed")); RooAbsPdf& pdf = *w->pdf("simPdf"); - RooArgSet *obs = pdf.getObservables(*dataAll); + std::auto_ptr obs(pdf.getObservables(*dataAll)); RooRealVar* mass = 0; - TIterator* it = obs->createIterator(); - for(RooAbsArg* v = (RooAbsArg*)it->Next(); v!=0; v = (RooAbsArg*)it->Next() ){ + RooLinkedListIter it = obs->iterator(); + for(RooAbsArg* v = (RooAbsArg*)it.Next(); v!=0; v = (RooAbsArg*)it.Next() ){ if(!v->InheritsFrom("RooRealVar")) continue; mass = (RooRealVar*)v; break; @@ -616,6 +664,7 @@ void TagProbeFitter::saveFitPlot(RooWorkspace* w){ // draw only the parameter box not the whole frame frames.back()->findObject(Form("%s_paramBox",pdf.GetName()))->Draw(); //save and clean up + canvas.Draw(); canvas.Write(); for (size_t i=0; iget(); vector reals; - TIterator* it = vars->createIterator(); - for(RooAbsArg* v = (RooAbsArg*)it->Next(); v!=0; v = (RooAbsArg*)it->Next() ){ + RooLinkedListIter it = vars->iterator(); + for(RooAbsArg* v = (RooAbsArg*)it.Next(); v!=0; v = (RooAbsArg*)it.Next() ){ if(!v->InheritsFrom("RooRealVar")) continue; reals.push_back((RooRealVar*)v); } @@ -660,6 +709,7 @@ void TagProbeFitter::saveDistributionsPlot(RooWorkspace* w){ dataAll->statOn(frames.back()); frames.back()->Draw(); } + canvas.Draw(); canvas.Write(); for (size_t i=0; iNext(); v1!=0; v1 = (RooRealVar*)v1it->Next() ){ +void TagProbeFitter::saveEfficiencyPlots(RooDataSet& eff, const TString& effName, RooArgSet& binnedVariables,RooArgSet& mappedCategories){ + RooLinkedListIter v1it = binnedVariables.iterator(); + bool isOnePoint = (eff.numEntries() == 1); // for datasets with > 1 entry, we don't make plots for variables with just one bin + for(RooRealVar* v1 = (RooRealVar*)v1it.Next(); v1!=0; v1 = (RooRealVar*)v1it.Next() ){ RooArgSet binCategories1D; - TIterator* v2it = binnedVariables.createIterator(); - for(RooRealVar* v2 = (RooRealVar*)v2it->Next(); v2!=0; v2 = (RooRealVar*)v2it->Next() ){ + if (v1->numBins() == 1 && !isOnePoint) continue; + RooLinkedListIter v2it = binnedVariables.iterator(); + for(RooRealVar* v2 = (RooRealVar*)v2it.Next(); v2!=0; v2 = (RooRealVar*)v2it.Next() ){ if(v2 == v1) continue; + if (v2->numBins() == 1 && !isOnePoint) continue; binCategories1D.addClone( RooBinningCategory(TString(v2->GetName())+"_bins", TString(v2->GetName())+"_bins", *v2) ); RooArgSet binCategories2D; - TIterator* v3it = binnedVariables.createIterator(); - for(RooRealVar* v3 = (RooRealVar*)v3it->Next(); v3!=0; v3 = (RooRealVar*)v3it->Next() ){ + RooLinkedListIter v3it = binnedVariables.iterator(); + for(RooRealVar* v3 = (RooRealVar*)v3it.Next(); v3!=0; v3 = (RooRealVar*)v3it.Next() ){ if(v3 == v1 || v3 == v2) continue; binCategories2D.addClone( RooBinningCategory(TString(v3->GetName())+"_bins", TString(v3->GetName())+"_bins", *v3) ); } @@ -689,14 +742,12 @@ void TagProbeFitter::saveEfficiencyPlots(RooDataSet& eff, const TString& effName }else{ RooDataSet myEff(eff); myEff.addColumn(allCats2D); - TIterator* catIt = allCats2D.typeIterator(); + std::auto_ptr catIt(allCats2D.typeIterator()); for(RooCatType* t = (RooCatType*)catIt->Next(); t!=0; t = (RooCatType*)catIt->Next() ){ TString catName = t->GetName(); if(catName.Contains("NotMapped")) continue; catName.ReplaceAll("{","").ReplaceAll("}","").ReplaceAll(";","_&_"); - RooDataSet* eff_bin = (RooDataSet*) myEff.reduce( Cut(TString::Format("allCats2D==%d",t->getVal())) ); - makeEfficiencyPlot2D(*eff_bin, *v1, *v2, TString::Format("%s_%s_PLOT_%s",v1->GetName(), v2->GetName(), catName.Data()), catName, effName); - delete eff_bin; + makeEfficiencyPlot2D(myEff, *v1, *v2, TString::Format("%s_%s_PLOT_%s",v1->GetName(), v2->GetName(), catName.Data()), catName, effName, "allCats1D", t->getVal()); } } } @@ -706,34 +757,47 @@ void TagProbeFitter::saveEfficiencyPlots(RooDataSet& eff, const TString& effName }else{ RooDataSet myEff(eff); myEff.addColumn(allCats1D); - TIterator* catIt = allCats1D.typeIterator(); + std::auto_ptr catIt(allCats1D.typeIterator()); for(RooCatType* t = (RooCatType*)catIt->Next(); t!=0; t = (RooCatType*)catIt->Next() ){ TString catName = t->GetName(); if(catName.Contains("NotMapped")) continue; catName.ReplaceAll("{","").ReplaceAll("}","").ReplaceAll(";","_&_"); - RooDataSet* eff_bin = (RooDataSet*) myEff.reduce( Cut(TString::Format("allCats1D==%d",t->getVal())) ); - makeEfficiencyPlot1D(*eff_bin, *v1, TString::Format("%s_PLOT_%s", v1->GetName(), catName.Data()), catName, effName); - delete eff_bin; + makeEfficiencyPlot1D(myEff, *v1, TString::Format("%s_PLOT_%s", v1->GetName(), catName.Data()), catName, effName, "allCats1D", t->getVal()); } } } } -void TagProbeFitter::makeEfficiencyPlot1D(RooDataSet& eff, RooRealVar& v, const TString& plotName, const TString& plotTitle, const TString& effName){ +void TagProbeFitter::makeEfficiencyPlot1D(RooDataSet& eff, RooRealVar& v, const TString& plotName, const TString& plotTitle, const TString& effName, const char *catName, int catIndex){ + TGraphAsymmErrors *p = new TGraphAsymmErrors(); + const RooArgSet *entry = eff.get(); + const RooRealVar &vi = dynamic_cast(*entry->find(v.GetName())); + const RooRealVar &ei = dynamic_cast(*entry->find("efficiency")); + for (unsigned int i = 0, n = eff.numEntries(); i < n; ++i) { + entry = eff.get(i); + if (catName != 0 && entry->getCatIndex(catName) != catIndex) continue; + int j = p->GetN(); p->Set(j+1); + p->SetPoint(j, vi.getVal(), ei.getVal() ); + p->SetPointError(j, -vi.getAsymErrorLo(), vi.getAsymErrorHi(), -ei.getAsymErrorLo(), ei.getAsymErrorHi() ); + } TCanvas canvas(plotName); - const RooArgSet* set = eff.get(); - RooRealVar* e = (RooRealVar*) set->find("efficiency"); - RooPlot* p = v.frame(Name(plotName), Title(plotTitle)); - eff.plotOnXY(p,YVar(*e)); - p->SetYTitle(TString("Efficiency of ")+effName); - p->SetAxisRange(0,1,"Y"); - p->Draw(); + TH1F *frame = new TH1F("frame", "Efficiency of "+effName, 1, v.getMin(), v.getMax()); frame->SetDirectory(0); + p->SetNameTitle(Form("hxy_%s", eff.GetName()), "Efficiency of "+effName); + p->GetXaxis()->SetTitle(strlen(v.getUnit()) ? Form("%s (%s)", v.GetName(), v.getUnit()) : v.GetName()); + p->GetYaxis()->SetTitle("Efficiency of "+effName); + frame->GetXaxis()->SetTitle(strlen(v.getUnit()) ? Form("%s (%s)", v.GetName(), v.getUnit()) : v.GetName()); + frame->GetYaxis()->SetTitle("Efficiency of "+effName); + frame->GetYaxis()->SetRangeUser(0,1); + frame->Draw(); + p->SetLineWidth(2); p->SetMarkerStyle(kFullCircle); p->SetMarkerSize(1.2); + p->Draw("P SAME"); canvas.Write(); + delete frame; delete p; } -void TagProbeFitter::makeEfficiencyPlot2D(RooDataSet& eff, RooRealVar& v1, RooRealVar& v2, const TString& plotName, const TString& plotTitle, const TString& effName){ - TCanvas canvas(plotName); +void TagProbeFitter::makeEfficiencyPlot2D(RooDataSet& eff, RooRealVar& v1, RooRealVar& v2, const TString& plotName, const TString& plotTitle, const TString& effName, const char *catName, int catIndex){ + TCanvas canvas(plotName); canvas.SetRightMargin(0.15); TH2F* h = new TH2F(plotName, plotName, v1.getBinning().numBins(), v1.getBinning().array(), v2.getBinning().numBins(), v2.getBinning().array()); const RooArgSet* set = eff.get(); @@ -747,11 +811,13 @@ void TagProbeFitter::makeEfficiencyPlot2D(RooDataSet& eff, RooRealVar& v1, RooRe h->GetZaxis()->SetRangeUser(-0.001,1.001); h->SetStats(kFALSE); for(int i=0; igetCatIndex(catName) != catIndex) continue; h->SetBinContent(h->FindBin(v1_->getVal(), v2_->getVal()), e->getVal()); h->SetBinError(h->FindBin(v1_->getVal(), v2_->getVal()), (e->getErrorHi()-e->getErrorLo())/2.); } h->Draw(); + canvas.Draw(); canvas.Write(); delete h; } diff --git a/PhysicsTools/TagAndProbe/src/TagProbePairMaker.cc b/PhysicsTools/TagAndProbe/src/TagProbePairMaker.cc index 40e2b3b3a8c52..afe25d77a21bf 100644 --- a/PhysicsTools/TagAndProbe/src/TagProbePairMaker.cc +++ b/PhysicsTools/TagAndProbe/src/TagProbePairMaker.cc @@ -1,4 +1,5 @@ #include "PhysicsTools/TagAndProbe/interface/TagProbePairMaker.h" +#include "DataFormats/Candidate/interface/Candidate.h" tnp::TagProbePairMaker::TagProbePairMaker(const edm::ParameterSet &iConfig, edm::ConsumesCollector && iC) : srcToken_(iC.consumes(iConfig.getParameter("tagProbePairs"))), @@ -22,6 +23,14 @@ tnp::TagProbePairMaker::TagProbePairMaker(const edm::ParameterSet &iConfig, edm: } else throw cms::Exception("Configuration") << "TagProbePairMakerOnTheFly: the only currently " << "allowed values for 'arbitration' are " << "'None', 'OneProbe', 'BestMass', 'Random2'\n"; + + if (iConfig.existsAs("phiCutForTwoLeg")) { + phiCutForTwoLeg_ = iConfig.getParameter("phiCutForTwoLeg"); + //std::cout << "Set phiCutForTwoLeg_ to " << phiCutForTwoLeg_ << std::endl; + } else { + phiCutForTwoLeg_ = false; + //std::cout << "Set phiCutForTwoLeg_ to default " << phiCutForTwoLeg_ << std::endl; + } } @@ -48,10 +57,58 @@ tnp::TagProbePairMaker::run(const edm::Event &iEvent) const arbitrate(pairs); } + if (phiCutForTwoLeg_ && pairs.size() > 0) { + int eventNum = iEvent.id().event(); + std::cout << "Calling phiCutByEventNumber on eventNum=" << eventNum << std::endl; + phiCutByEventNumber(pairs,eventNum); + } + // return return pairs; } +void +tnp::TagProbePairMaker::phiCutByEventNumber(TagProbePairs &pairs, int eventNumber) const +{ + unsigned int currentNum = 0; + + size_t nclean = pairs.size(); + for (TagProbePairs::iterator it = pairs.begin(), ed = pairs.end(); it != ed; ++it) { + if (it->tag.isNull()) continue; // skip already invalidated pairs + if (eventNumber%2) { + std::cout << "Odd event number " << eventNumber << ", require 0 < phi(tag) < pi... "; + if (!(it->tag->phi() > 0. && it->tag->phi() < 3.141592654)) { + std::cout << "Rejecting pair number " << currentNum++ << " with tag phi " << it->tag->phi(); + nclean--; + it->tag = reco::CandidateBaseRef(); --nclean; + } else { + std::cout << "Keeping pair number " << currentNum++ << " with tag phi " << it->tag->phi(); + } + } else { + std::cout << "Even event number " << eventNumber << ", require -pi < phi(tag) < 0... "; + // if (!(it->tag->phi() > 3.141592654 && it->tag->phi() < 2*3.141592654)) { + if (!(it->tag->phi() > -3.141592654 && it->tag->phi() < 0)) { + std::cout << "Rejecting pair number " << currentNum++ << " with tag phi " << it->tag->phi(); + nclean--; + it->tag = reco::CandidateBaseRef(); --nclean; + } else { + std::cout << "Keeping pair number " << currentNum++ << " with tag phi " << it->tag->phi(); + } + } + std::cout << std::endl; + } + + if (nclean == 0) { + pairs.clear(); + } else if (nclean < pairs.size()) { + TagProbePairs cleaned; cleaned.reserve(nclean); + for (TagProbePairs::iterator it = pairs.begin(), ed = pairs.end(); it != ed; ++it) { + if (it->tag.isNonnull()) cleaned.push_back(*it); + } + pairs.swap(cleaned); + } +} + void tnp::TagProbePairMaker::arbitrate(TagProbePairs &pairs) const { diff --git a/PhysicsTools/TagAndProbe/src/TriggerCandProducer.icc b/PhysicsTools/TagAndProbe/src/TriggerCandProducer.icc index c425d7e109005..fadcaa824a837 100644 --- a/PhysicsTools/TagAndProbe/src/TriggerCandProducer.icc +++ b/PhysicsTools/TagAndProbe/src/TriggerCandProducer.icc @@ -9,15 +9,11 @@ template TriggerCandProducer::TriggerCandProducer(const edm::ParameterSet& iConfig ) { - _inputProducer = iConfig.template getParameter("InputProducer"); _inputProducerToken = consumes >(_inputProducer); // **************** Trigger ******************* // const edm::InputTag dTriggerEventTag("hltTriggerSummaryAOD","","HLT"); - triggerEventTag_ = - iConfig.getUntrackedParameter("triggerEventTag", - dTriggerEventTag); - triggerEventToken_ = consumes(triggerEventTag_); + triggerEventToken_ = consumes(triggerEventTag_); const edm::InputTag dTriggerResults("TriggerResults","","HLT"); @@ -25,7 +21,6 @@ TriggerCandProducer::TriggerCandProducer(const edm::ParameterSet& iConfi triggerResultsTag_ = iConfig.getUntrackedParameter("triggerResultsTag", dTriggerResults); triggerResultsToken_ = consumes(triggerResultsTag_); - hltTags_ = iConfig.getParameter >("hltTags"); // Trigger-matching window. We use some default deltaR. delRMatchingCut_ = iConfig.getUntrackedParameter("triggerDelRMatch", 0.30); @@ -34,9 +29,13 @@ TriggerCandProducer::TriggerCandProducer(const edm::ParameterSet& iConfi // ******************************************** // //Whether using HLT trigger path name or the actual trigger filter name. Trigger path is default. + objEtMin_ = iConfig.getUntrackedParameter("objEtMin",0.0); + objEtaMax_ = iConfig.getUntrackedParameter("objEtaMax",1000.0); + isTriggerOR_ = iConfig.getUntrackedParameter("isTriggerOR",false); isFilter_ = iConfig.getUntrackedParameter("isTriggerFilter",false); - - + antiSelect_ = iConfig.getUntrackedParameter("antiSelect",false); + noHltFiring_ = iConfig.getUntrackedParameter("noHltFiring",false); + // By default, do not print debugging information for each event. printIndex_ = iConfig.getUntrackedParameter("verbose",false); @@ -127,8 +126,9 @@ void TriggerCandProducer::produce(edm::Event &event, const edm::EventSet iMyHLT != hltTags_.end(); ++iMyHLT) { if ((*iMyHLT).label() == *iHLT) { triggerInMenu[(*iMyHLT).label()] = true; - if (hltConfig_.prescaleValue(event, eventSetup, *iHLT) == 1) - triggerUnprescaled[(*iMyHLT).label()] = true; + if (hltConfig_.prescaleValues(event, eventSetup, *iHLT).first == 1 && hltConfig_.prescaleValues(event, eventSetup, *iHLT).second == 1){ + triggerUnprescaled[(*iMyHLT).label()] = true; +} } } } @@ -152,6 +152,18 @@ void TriggerCandProducer::produce(edm::Event &event, const edm::EventSet } } + if (isFilter_) + { + for (std::vector::const_iterator iMyHLT = hltTags_.begin(); + iMyHLT != hltTags_.end(); ++iMyHLT) + { + if (theRightHLTTag_.label() == (*iMyHLT).label()) + { + theRightHLTTag_ = edm::InputTag((*iMyHLT).label(), (*iMyHLT).instance(), (*iMyHLT).process()); + // std::cout << "Found it " << (*iMyHLT).label() << "\t" <<(*iMyHLT).instance() << "\t" << (*iMyHLT).process() << std::endl; + } + } + } // some sanity checks if (numOKHLTPaths == 0) { @@ -164,7 +176,7 @@ void TriggerCandProducer::produce(edm::Event &event, const edm::EventSet edm::LogError("TriggerCandProducer") << err.str(); throw cms::Exception("GarbageInGarbageOut") << err.str(); } - if (numOKHLTPaths > 1) { + if (numOKHLTPaths > 1 && !isTriggerOR_) { stringstream err; err << "****** Error: There are multiple trigger paths. I cannot figure out how to perform trigger matching :(" << " Multiple HLT paths in "; @@ -232,54 +244,104 @@ void TriggerCandProducer::produce(edm::Event &event, const edm::EventSet filterName_ << " index " << index << " sizeFilters " << trgEvent->sizeFilters() << std::endl; - //----------------------------------------------------------------- - // find how many relevant - /* - edm::InputTag l1testTag(filterName_,"", theRightHLTTag_.process() ); - const int index = trgEvent->filterIndex( l1testTag ); - */ - //----------------------------------------------------------------- - - - if( index >= trgEvent->sizeFilters() ) { - edm::LogInfo("info")<< "******** Following TRIGGER Name Not in Dataset: " << - theRightHLTTag_.label(); - event.put(outColRef); - // event.put(outColPtr); - return; - } - - // find how many objects there are - const trigger::Keys& KEYS(trgEvent->filterKeys(index)); - const size_type nK(KEYS.size()); - - //did this event fire the HLT? - const edm::TriggerNames &trgNames = event.triggerNames(*pTrgResults); - const unsigned int trgIndex = trgNames.triggerIndex(theRightHLTTag_.label()); - bool firedHLT = (trgIndex < trgNames.size()) && (pTrgResults->accept(trgIndex)); - // Loop over the candidate collection unsigned int counter=0; + bool foundMatch = false; + bool foundPath = false; + + for( typename edm::View< object>::const_iterator j = candHandle->begin(); + j != candHandle->end(); ++j, ++counter) + { + +// std::cout << counter << " " << j->eta() << " " << j->phi() << std::endl; + + foundMatch = false; +// for (std::vector::const_iterator iMyHLT = hltTags_.begin(); +// iMyHLT != hltTags_.end(); ++iMyHLT) +// { +// std::cout << "theRightHLTTag_.label() list " << +// (*iMyHLT).label() << " filter name " << +// (*iMyHLT).instance() << std::endl; +// } + for (std::vector::const_iterator iMyHLT = hltTags_.begin(); + iMyHLT != hltTags_.end(); ++iMyHLT) + { + if (foundMatch) break; + if (isTriggerOR_ && isFilter_) + { + theRightHLTTag_ = edm::InputTag((*iMyHLT).label(), (*iMyHLT).instance(), (*iMyHLT).process()); + filterName_ = theRightHLTTag_.instance(); + // std::cout << "theRightHLTTag_.label() test " << + // theRightHLTTag_.label() << " filter name " << + // filterName_ << std::endl; + } + + + edm::InputTag l1testTag(filterName_,"", theRightHLTTag_.process() ); + const int index = trgEvent->filterIndex( l1testTag ); + + if( index >= trgEvent->sizeFilters() ) + { + // std::cout << "theRightHLTTag_.label() fail " << + // theRightHLTTag_.label() << " filter name " << + // filterName_ << std::endl; + + if (isTriggerOR_) continue; + // edm::LogInfo("info")<< "******** Following TRIGGER Name Not in Dataset: " << + // theRightHLTTag_.label(); + // event.put(outColRef); + // return; + } else + { + foundPath = true; + // find how many objects there are + const trigger::Keys& KEYS(trgEvent->filterKeys(index)); + const size_type nK(KEYS.size()); - for( typename edm::View< object>::const_iterator j = candHandle->begin(); - j != candHandle->end(); ++j, ++counter) { - + //did this event fire the HLT? + const edm::TriggerNames &trgNames = event.triggerNames(*pTrgResults); + const unsigned int trgIndex = trgNames.triggerIndex(theRightHLTTag_.label()); + bool firedHLT = (trgIndex < trgNames.size()) && (pTrgResults->accept(trgIndex)); + bool founddRMatch = false; // Get cut decision for each candidate // Did this candidate cause a HLT trigger? - bool hltTrigger = false; - for(int ipart = 0; ipart != nK; ++ipart) { - - const trigger::TriggerObject& TO = TOC[KEYS[ipart]]; - double dRval = deltaR( j->eta(), j->phi(), + for(int ipart = 0; ipart != nK; ++ipart) + { + const trigger::TriggerObject& TO = TOC[KEYS[ipart]]; + double dRval = deltaR( j->eta(), j->phi(), TO.eta(), TO.phi()); - hltTrigger = dRval < delRMatchingCut_; - if( hltTrigger ) break; - } +// std::cout << "theRightHLTTag_.label() test " << +// theRightHLTTag_.label() << " filter name " << +// filterName_ << " index " << index << " " << counter << " " << j->eta() << " " << TO.eta() << " " << j->phi() << " " << TO.phi() << std::endl; + founddRMatch = dRval < delRMatchingCut_ && TO.et() > objEtMin_ && fabs(TO.eta()) < objEtaMax_; + if( founddRMatch ) break; + } + foundMatch = founddRMatch && (firedHLT || noHltFiring_ ); + if(founddRMatch && (firedHLT || noHltFiring_ ) && !antiSelect_) + { + outColRef->push_back( candHandle->refAt(counter) ); +// std::cout << "theRightHLTTag_.label() select" << +// theRightHLTTag_.label() << " filter name " << +// filterName_ << " index " << index << " " << counter << " " << j->eta() << std::endl; + } + } + + } - if(hltTrigger && firedHLT) { - outColRef->push_back( candHandle->refAt(counter) ); - //outColPtr->push_back( candHandle->ptrAt(counter) ); + if (antiSelect_ && !foundMatch) + { + outColRef->push_back( candHandle->refAt(counter) ); +// std::cout << "theRightHLTTag_.label() antiselect" << +// theRightHLTTag_.label() << " filter name " << +// filterName_ << " index " << index << " " << counter << " " << j->eta() << std::endl; } + } + + if(!foundPath) { + edm::LogInfo("info")<< "******** Following TRIGGER Name Not in Dataset: " << + theRightHLTTag_.label(); + event.put(outColRef); + return; } event.put(outColRef); @@ -295,7 +357,6 @@ void TriggerCandProducer::produce(edm::Event &event, const edm::EventSet - // ---- method called once each job just before starting event loop --- template void TriggerCandProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup){ diff --git a/PhysicsTools/TagAndProbe/test/Electron_TagProbeTreeProducer_cfg.py b/PhysicsTools/TagAndProbe/test/Electron_TagProbeTreeProducer_cfg.py index 7588d5f5daf48..fda29de54b2b9 100644 --- a/PhysicsTools/TagAndProbe/test/Electron_TagProbeTreeProducer_cfg.py +++ b/PhysicsTools/TagAndProbe/test/Electron_TagProbeTreeProducer_cfg.py @@ -13,7 +13,7 @@ ## * ## * History: ## * -## * +## * ## *****************************************************************************/ @@ -26,116 +26,16 @@ ## \___\___/|_| |_|___/\__\__,_|_| |_|\__|___/ ## ################################################ -## Following HLT paths are available in MC sample -## "/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/Fall10-START38_V12-v1" -## Please look into the trigger menu to find out the prescale for these paths. -## Process name used is: "HLT" -## -## HLT_Ele10_SW_L1R, HLT_Ele12_SW_TightEleId_L1R -## HLT_Ele12_SW_TightEleIdIsol_L1R -## HLT_Ele12_SW_TightEleIdIsol_NoDEtaInEE_L1R -## HLT_Ele17_SW_L1R -## HLT_Ele17_SW_CaloEleId_L1R -## HLT_Ele17_SW_LooseEleId_L1R -## HLT_Ele17_SW_EleId_L1R -## HLT_Ele22_SW_CaloEleId_L1R -## HLT_Ele40_SW_L1R -## HLT_DoubleEle4_SW_eeRes_L1R -## HLT_DoubleEle10_SW_L1R, -## HLT_Photon10_Cleaned_L1R -## HLT_Photon15_Cleaned_L1R -## HLT_Photon20_NoHE_L1R -## HLT_Photon20_Cleaned_L1R -## HLT_Photon30_Cleaned_L1R -## HLT_Photon50_NoHE_L1R -## HLT_Photon50_NoHE_Cleaned_L1R -## HLT_DoublePhoton5_CEP_L1R -## HLT_DoublePhoton5_L1R, -## HLT_DoublePhoton10_L1R -## HLT_DoublePhoton15_L1R -## HLT_DoublePhoton17_L1R -################################################ -## Following HLT paths are available in MC sample -## "/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/Winter10-E7TeV_ProbDist_2010Data_BX156_START39_V8-v1" -## Process name used is: "REDIGI39X" -## -## HLT_Ele10_SW_L1R_v2 -## HLT_Ele12_SW_TighterEleId_L1R_v2 -## HLT_Ele17_SW_L1R_v2 -## HLT_Ele17_SW_Isol_L1R_v2 -## HLT_Ele17_SW_TighterEleIdIsol_L1R_v3 -## HLT_Ele17_SW_TightCaloEleId_Ele8HE_L1R_v2 -## HLT_Ele22_SW_L1R_v2 -## HLT_Ele22_SW_TighterCaloIdIsol_L1R_v2 -## HLT_Ele22_SW_TighterEleId_L1R_v3 -## HLT_Ele32_SW_TighterEleId_L1R_v2 -## HLT_DoubleEle4_SW_eeRes_L1R_v2 -## HLT_DoubleEle5_SW_Upsilon_L1R_v2 -## HLT_DoubleEle17_SW_L1R_v1 -## HLT_Photon10_Cleaned_L1R -## HLT_Photon17_Isol_SC17HE_L1R_v1 -## HLT_Photon20_NoHE_L1R -## HLT_Photon20_Cleaned_L1R -## HLT_Photon20_Isol_Cleaned_L1R_v1 -## HLT_Photon22_SC22HE_L1R_v1 -## HLT_Photon30_Cleaned_L1R -## HLT_Photon40_CaloId_Cleaned_L1R_v1 -## HLT_Photon40_Isol_Cleaned_L1R_v1 -## HLT_Photon50_Cleaned_L1R_v1 -## HLT_Photon50_NoHE_L1R -## HLT_Photon70_Cleaned_L1R_v1 -## HLT_Photon110_NoHE_Cleaned_L1R_v1 -## HLT_DoublePhoton5_CEP_L1R_v3 -## HLT_DoublePhoton17_SingleIsol_L1R_v1 -## HLT_DoublePhoton22_L1R_v1 -################################################ -## Following electron/photon HLT paths are available in Run2010B data (first file) -## (replace "v1" with "v2", "v3" etc. for later runs). -## Please look into the trigger menu to find out the prescale for these paths. -## Process name used is: "HLT" -## -## HLT_Ele10_SW_L1R -## HLT_Ele12_SW_TightEleId_L1R -## HLT_Ele12_SW_TighterEleId_L1R_v1 -## HLT_Ele12_SW_TighterEleIdIsol_L1R_v1 -## HLT_Ele17_SW_L1R -## HLT_Ele17_SW_TightEleId_L1R -## HLT_Ele17_SW_TighterEleId_L1R_v1 -## HLT_Ele17_SW_TightEleIdIsol_L1R_v1 -## HLT_Ele17_SW_TighterEleIdIsol_L1R_v1 -## HLT_Ele17_SW_TightCaloEleId_SC8HE_L1R_v1 -## HLT_Ele17_SW_TightCaloEleId_Ele8HE_L1R_v1 -## HLT_Ele27_SW_TightCaloEleIdTrack_L1R_v1 -## HLT_Ele32_SW_TightCaloEleIdTrack_L1R_v1 -## HLT_DoubleEle4_SW_eeRes_L1R -## HLT_DoubleEle15_SW_L1R_v1 -## HLT_Photon10_Cleaned_L1R -## HLT_Photon15_Cleaned_L1R -## HLT_Photon17_SC17HE_L1R_v1 -## HLT_Photon20_NoHE_L1R -## HLT_Photon20_Cleaned_L1R -## HLT_Photon30_Cleaned_L1R -## HLT_Photon30_Isol_EBOnly_Cleaned_L1R_v1 -## HLT_Photon35_Isol_Cleaned_L1R_v1 -## HLT_Photon50_Cleaned_L1R_v1 -## HLT_Photon50_NoHE_L1R -## HLT_Photon70_NoHE_Cleaned_L1R_v1 -## HLT_Photon100_NoHE_Cleaned_L1R_v1 -## HLT_DoublePhoton5_CEP_L1R, HLT_DoublePhoton17_L1R -################################################ - -MC_flag = False -GLOBAL_TAG = 'GR_R_39X_V4::All' +MC_flag = True +GLOBAL_TAG = 'GR_R_42_V12::All' if MC_flag: - #GLOBAL_TAG = 'START38_V14::All' - GLOBAL_TAG = 'START39_V8::All' + GLOBAL_TAG = 'START42_V12::All' -HLTPath = "HLT_Ele17_SW_TightEleId_L1R" +HLTPath = "HLT_Ele52_CaloIdVT_TrkIdT_v3" HLTProcessName = "HLT" if MC_flag: - #HLTPath = "HLT_Ele17_SW_LooseEleId_L1R" - HLTPath = "HLT_Ele17_SW_TighterEleIdIsol_L1R_v3" - HLTProcessName = "REDIGI39X" + HLTPath = "HLT_Ele32_SW_TighterEleId_L1R_v2" + HLTProcessName = "HLT" OUTPUT_FILE_NAME = "testNewWrite.root" @@ -176,6 +76,15 @@ #process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) process.MessageLogger.cerr.FwkReport.reportEvery = 1000 + + +############# Needed for pileup re-weighting ########## +process.pileupReweightingProducer = cms.EDProducer("PileupWeightProducer", + FirstTime = cms.untracked.bool(True), + PileupMCFile = cms.untracked.string("PUMC_dist_flat10.root"), + PileupDataFile = cms.untracked.string("PUData_finebin_dist.root") +) +######### ## ____ _ ____ ## | _ \ ___ ___ | / ___| ___ _ _ _ __ ___ ___ ## | |_) / _ \ / _ \| \___ \ / _ \| | | | '__/ __/ _ \ @@ -184,47 +93,27 @@ ## process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/454/ACDEDA3C-B7D3-DF11-A7A1-0030487C6A66.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/454/223CD93D-B7D3-DF11-885E-0030487CD7B4.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/EAB3E588-B6D3-DF11-8BDC-0030487A3232.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/AA0C5537-B7D3-DF11-9194-0030487CD7C6.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/A28CBA36-B7D3-DF11-9F37-00304879BAB2.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/8C67199B-B1D3-DF11-AAC4-0030487CD7CA.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/823B32EE-B7D3-DF11-B2CB-0030487CAF0E.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/3C66014F-B2D3-DF11-9E18-0030487CD6DA.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/3AA99C36-B7D3-DF11-BB90-0030487CAEAC.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/26B82C89-B6D3-DF11-9584-0030487CD6B4.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/453/0AA663A1-B8D3-DF11-ADD8-0030487CD6B4.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/452/F08E2485-95D3-DF11-842A-0030486780B8.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/452/DCF42686-95D3-DF11-8DF0-0030487CD76A.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/452/5E17B94C-9DD3-DF11-A952-001617E30F58.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/452/54CDACD8-94D3-DF11-B6A6-001617E30D12.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/452/346D9037-96D3-DF11-88DF-001617C3B710.root', -## '/store/data/Run2010B/Electron/RECO/PromptReco-v2/000/147/452/029B8885-95D3-DF11-B1FE-001617E30D4A.root', - -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0008/A0A4E0F2-90CF-DF11-B893-00163EC21201.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0008/62CCB894-91CF-DF11-99D7-1CC1DE052068.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0008/223B153C-91CF-DF11-B769-0018FE286D32.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0008/1E5E9669-91CF-DF11-8BCB-001A648F1E2A.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0006/FCECED70-35CE-DF11-91A0-1CC1DE052030.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0006/FC5D8454-7CCE-DF11-9C04-0017A4770C00.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0006/FC35628B-58CE-DF11-84DB-0018FE283E0C.root', -## '/store/mc/Fall10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/GEN-SIM-RECO/START38_V12-v1/0006/F828D75A-43CE-DF11-B389-00163E120701.root', - - - - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0034/B29E60A0-1511-E011-8C55-0017A4770030.root', - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0033/7AD2434E-1B10-E011-9BFC-0017A477103C.root', - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0032/FC974EDD-E90F-E011-BD2E-1CC1DE051038.root', - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0032/FC6DFEE1-0910-E011-A0FF-0017A477080C.root', - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0032/FA72FB40-0510-E011-89D9-0025B3E0228C.root', - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0032/F4C5FEE4-FC0F-E011-992C-0017A477003C.root', - '/store/mc/Winter10/DYToEE_M-20_CT10_TuneZ2_7TeV-powheg-pythia/AODSIM/E7TeV_ProbDist_2010Data_BX156_START39_V8-v1/0032/F4537EED-FA0F-E011-A56C-001F296B758E.root', - + +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/283/BC0BDDDF-829D-E011-89EE-0030487CF41E.root', +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/282/F0A7CE51-AE9D-E011-9C9E-003048D374F2.root', +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/282/B2D25F4E-A79D-E011-94AD-003048F024DC.root', +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/282/A89EC329-979D-E011-92F3-001D09F24DDF.root', +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/282/5831779B-989D-E011-995A-0019B9F730D2.root', +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/282/5021FAFB-AE9D-E011-B07F-003048D37538.root', +## '/store/data/Run2011A/SingleElectron/RECO/PromptReco-v4/000/167/282/34B74172-A99D-E011-8CD1-003048D2BDD8.root', + + '/store/mc/Summer11/ZJetToEE_Pt-30to50_TuneZ2_7TeV_pythia6/AODSIM/PU_S3_START42_V11-v2/0000/F6082563-6C7F-E011-9730-00215E222790.root', + '/store/mc/Summer11/ZJetToEE_Pt-30to50_TuneZ2_7TeV_pythia6/AODSIM/PU_S3_START42_V11-v2/0000/F4B4B87C-927F-E011-9805-00215E21D786.root', + '/store/mc/Summer11/ZJetToEE_Pt-30to50_TuneZ2_7TeV_pythia6/AODSIM/PU_S3_START42_V11-v2/0000/E673A7C3-927F-E011-B8C0-00215E2205AC.root', + '/store/mc/Summer11/ZJetToEE_Pt-30to50_TuneZ2_7TeV_pythia6/AODSIM/PU_S3_START42_V11-v2/0000/D0725463-6C7F-E011-9285-00215E222790.root', + '/store/mc/Summer11/ZJetToEE_Pt-30to50_TuneZ2_7TeV_pythia6/AODSIM/PU_S3_START42_V11-v2/0000/BC3E4618-BC80-E011-8AB8-E41F13181A50.root', + '/store/mc/Summer11/ZJetToEE_Pt-30to50_TuneZ2_7TeV_pythia6/AODSIM/PU_S3_START42_V11-v2/0000/A60D2563-6C7F-E011-84A1-00215E222790.root', + + ) ) -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) ) process.source.inputCommands = cms.untracked.vstring("keep *","drop *_MEtoEDMConverter_*_*") ## ____ ____ _ _ @@ -493,7 +382,6 @@ triggerResultsTag = cms.untracked.InputTag("TriggerResults","",HLTProcessName) ) - ## _____ _ _ __ __ ## | ____|_ _| |_ ___ _ __ _ __ __ _| | \ \ / /_ _ _ __ ___ ## | _| \ \/ / __/ _ \ '__| '_ \ / _` | | \ \ / / _` | '__/ __| @@ -1305,6 +1193,8 @@ process.GsfElectronPlusGsfElectron.pairVariables.costheta = cms.InputTag("CSVarsGsfGsf","costheta") process.GsfElectronPlusGsfElectron.pairVariables.sin2theta = cms.InputTag("CSVarsGsfGsf","sin2theta") process.GsfElectronPlusGsfElectron.pairVariables.tanphi = cms.InputTag("CSVarsGsfGsf","tanphi") +if MC_flag: + process.GsfElectronPlusGsfElectron.PUWeightSrc = cms.InputTag("pileupReweightingProducer","pileupWeights") process.GsfElectronPlusMet = process.GsfElectronToId.clone() @@ -1370,6 +1260,9 @@ probeMatches = cms.InputTag("McMatchWP95"), allProbes = cms.InputTag("PassingWP95") ) +if MC_flag: + process.WP95ToHLT.PUWeightSrc = cms.InputTag("pileupReweightingProducer","pileupWeights") + ## WP90 --> HLT process.WP90ToHLT = process.WP95ToHLT.clone() @@ -1490,7 +1383,7 @@ process.tagAndProbe = cms.Path( process.sc_sequence + process.eIDSequence + process.ele_sequence + process.ext_ToNearestJet_sequence + - process.allTagsAndProbes + + process.allTagsAndProbes + process.pileupReweightingProducer + process.mc_sequence + process.tree_sequence ) diff --git a/PhysicsTools/TagAndProbe/test/dumpScaleFactorTables.C b/PhysicsTools/TagAndProbe/test/dumpScaleFactorTables.C index 24b3be61377fb..a570319595eca 100644 --- a/PhysicsTools/TagAndProbe/test/dumpScaleFactorTables.C +++ b/PhysicsTools/TagAndProbe/test/dumpScaleFactorTables.C @@ -10,21 +10,21 @@ void dumpScaleFactorTables() { -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "WP90"); -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "WP85"); -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "WP80"); - -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicLoose"); -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicTight"); -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicSuperTight"); -dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicHyperTight1"); - -dumpScaleFactorTables("efficiency-data-SCToGsfElectron.root", "efficiency-mc-SCToGsfElectron.root", "SuperClusterToGsfElectron", "efficiency"); - dumpScaleFactorTables("efficiency-data-WP90ToHLT.root", "efficiency-mc-WP90ToHLT.root", "WP90ToHLT", "efficiency"); - dumpScaleFactorTables("efficiency-data-WP85ToHLT.root", "efficiency-mc-WP85ToHLT.root", "WP85ToHLT", "efficiency"); - dumpScaleFactorTables("efficiency-data-WP80ToHLT.root", "efficiency-mc-WP80ToHLT.root", "WP80ToHLT", "efficiency"); - dumpScaleFactorTables("efficiency-data-CicLooseToHLT.root", "efficiency-mc-CicLooseToHLT.root", "CicLooseToHLT", "efficiency"); - dumpScaleFactorTables("efficiency-data-CicTightToHLT.root", "efficiency-mc-CicTightToHLT.root", "CicTightToHLT", "efficiency"); +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "WP90"); +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "WP85"); +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "WP80"); + +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicLoose"); +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicTight"); +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicSuperTight"); +// dumpScaleFactorTables("efficiency-data-GsfElectronToId.root", "efficiency-mc-GsfElectronToId.root", "GsfElectronToId", "CicHyperTight1"); + +// dumpScaleFactorTables("efficiency-data-SCToGsfElectron.root", "efficiency-mc-SCToGsfElectron.root", "SuperClusterToGsfElectron", "efficiency"); + dumpScaleFactorTables("Eff-defaultBin-data/efficiency-data-WP90ToHLT.root", "efficiency-mc-WP90ToHLT.root", "WP90ToHLT", "efficiency"); + dumpScaleFactorTables("Eff-defaultBin-data/efficiency-data-WP85ToHLT.root", "efficiency-mc-WP85ToHLT.root", "WP85ToHLT", "efficiency"); + dumpScaleFactorTables("Eff-defaultBin-data/efficiency-data-WP80ToHLT.root", "efficiency-mc-WP80ToHLT.root", "WP80ToHLT", "efficiency"); + dumpScaleFactorTables("Eff-defaultBin-data/efficiency-data-CicLooseToHLT.root", "efficiency-mc-CicLooseToHLT.root", "CicLooseToHLT", "efficiency"); + dumpScaleFactorTables("Eff-defaultBin-data/efficiency-data-CicTightToHLT.root", "efficiency-mc-CicTightToHLT.root", "CicTightToHLT", "efficiency"); } diff --git a/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeAnalyzer_Zee.py b/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeAnalyzer_Zee.py index 3a23d867d3e4f..701e51f80d8ae 100644 --- a/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeAnalyzer_Zee.py +++ b/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeAnalyzer_Zee.py @@ -18,9 +18,8 @@ ################################################ -isMC = False -## InputFileName = "testNewWrite.root" -InputFileName = "/uscms_data/d2/kalanand/allTPtrees_35invpb_Dec22ReReco.root" +isMC = True +InputFileName = "testNewWrite.root" OutputFilePrefix = "efficiency-data-" @@ -30,7 +29,6 @@ PDFName = "pdfSignalPlusBackground" if isMC: - InputFileName = "/uscms_data/d2/kalanand/allTPtrees_mc_39.root" PDFName = "" OutputFilePrefix = "efficiency-mc-" ################################################ @@ -190,6 +188,7 @@ # defines all the discrete variables of the probes available in the input tree and intended for use in the efficiency calculations Categories = cms.PSet( + weight = cms.vstring("weight", "0.0", "10.0", ""), mcTrue = cms.vstring("MC true", "dummy[true=1,false=0]"), probe_passConvRej = cms.vstring("probe_passConvRej", "dummy[pass=1,fail=0]"), ## probe_isWP95 = cms.vstring("probe_isWP95", "dummy[pass=1,fail=0]"), @@ -242,64 +241,66 @@ ## ), WP90 = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isWP90","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isWP90","pass"), ), WP85 = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isWP85","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isWP85","pass"), ), WP80 = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isWP80","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isWP80","pass"), ), ## WP70 = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isWP70","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isWP70","pass"), ## ), ## WP60 = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isWP60","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isWP60","pass"), ## ), ## CicVeryLoose = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicVeryLoose","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isCicVeryLoose","pass"), ## ), CicLoose = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicLoose","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isCicLoose","pass"), ), ## CicMedium = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicMedium","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isCicMedium","pass"), ## ), CicTight = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicTight","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isCicTight","pass"), ), CicSuperTight = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicSuperTight","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isCicSuperTight","pass"), ), CicHyperTight1 = cms.PSet( EfficiencyBinningSpecification, - EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicHyperTight1","pass"), + EfficiencyCategoryAndState = cms.vstring("probe_isCicHyperTight1","pass"), ), ## CicHyperTight2 = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicHyperTight2","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isCicHyperTight2","pass"), ## ), ## CicHyperTight3 = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicHyperTight3","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isCicHyperTight3","pass"), ## ), ## CicHyperTight4 = cms.PSet( ## EfficiencyBinningSpecification, -## EfficiencyCategoryAndState = cms.vstring("probe_passConvRej","pass","probe_isCicHyperTight4","pass"), +## EfficiencyCategoryAndState = cms.vstring("probe_isCicHyperTight4","pass"), ## ), ############################################################################################ ############################################################################################ ) ) +if isMC: + process.GsfElectronToId.WeightVariable = cms.string("PUweight") ############################################################################################ diff --git a/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeProducer_ZMuMu.py b/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeProducer_ZMuMu.py index 43e0a04e16859..8510125dbd782 100644 --- a/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeProducer_ZMuMu.py +++ b/PhysicsTools/TagAndProbe/test/testTagProbeFitTreeProducer_ZMuMu.py @@ -12,35 +12,7 @@ process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/D68EFA42-9FE2-DE11-9CEC-002618943856.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/D68C1E7D-8EE2-DE11-A6DE-002618943843.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/D4D52FFE-8CE2-DE11-B614-0026189438F4.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/C4FDD49F-A6E2-DE11-8F4F-001A9281170A.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/C47F4CB3-A3E2-DE11-B364-001731AF6933.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/BE0507A9-A5E2-DE11-97E0-001731AF669D.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/B6112976-8FE2-DE11-BB92-0026189437E8.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/B24A3001-8CE2-DE11-9D8B-0026189438BC.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/B0493230-A4E2-DE11-88C0-001731AF66BD.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/AE2254FE-8CE2-DE11-A10D-002618943961.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/A8C333FB-8DE2-DE11-91F3-003048678D86.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/A4A2E76C-92E2-DE11-ADA5-0026189437E8.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/A4286326-A5E2-DE11-BA9C-001A9281170A.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/A2B8E3C6-9BE2-DE11-97BD-0018F3D09648.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/9EE00419-AAE2-DE11-853D-001731AF6A49.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/90ECED25-A7E2-DE11-ABB3-0018F3D0970A.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/8AC633FA-90E2-DE11-9558-002618943877.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/8A3213FA-90E2-DE11-8C98-002354EF3BD2.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/881A239C-A8E2-DE11-9FA3-00173199E924.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/78A721F9-8EE2-DE11-8ABD-002618943879.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/6823076D-92E2-DE11-B4FA-002618FDA20E.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/66C7B8F3-8FE2-DE11-9760-0018F3D096BC.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/66185789-8DE2-DE11-8953-002618FDA250.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/609FD873-91E2-DE11-93F5-002618943916.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/4ED2B082-ACE2-DE11-9D98-001A92810A92.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/348CC0B5-A1E2-DE11-A714-001A92971B80.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/2AF34C6F-90E2-DE11-9327-002354EF3BD2.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/2A5A24BC-A0E2-DE11-A367-001A9281170A.root', - '/store/relval/CMSSW_3_4_0_pre7/RelValZmumuJets_Pt_20_300_GEN/GEN-SIM-RECO/MC_3XY_V14_LowLumiPileUp-v1/0004/1843924A-09E3-DE11-B0D9-002618943919.root', + '/store/relval/CMSSW_7_2_1/RelValZMM_13/GEN-SIM-RECO/PU50ns_PHYS14_25_V1_Phys14-v1/00000/287B9489-B85E-E411-95DF-02163E00EB3F.root' ) ) process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(500) ) diff --git a/RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositProducer.cc b/RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositProducer.cc index 827bf6e0008f3..3ab06826d20d4 100644 --- a/RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositProducer.cc +++ b/RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositProducer.cc @@ -60,6 +60,15 @@ MuIsoDepositProducer::MuIsoDepositProducer(const ParameterSet& par) : if (theDepositNames[i] != "") alias += "_" + theDepositNames[i]; produces(theDepositNames[i]).setBranchAlias(alias); } + + if (!theExtractor) { + edm::ParameterSet extractorPSet = theConfig.getParameter("ExtractorPSet"); + std::string extractorName = extractorPSet.getParameter("ComponentName"); + theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector()); + LogDebug(metname)<<" Load extractor..."<("ExtractorPSet"); - std::string extractorName = extractorPSet.getParameter("ComponentName"); - theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector()); - LogDebug(metname)<<" Load extractor..."<