Skip to content

Commit

Permalink
consumes for HLTriggerOffline/SUSYBSM and HLTriggerOffline/Muon packages
Browse files Browse the repository at this point in the history
  • Loading branch information
deguio committed Dec 6, 2013
1 parent 6f28d55 commit e5352d0
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 169 deletions.
20 changes: 16 additions & 4 deletions HLTriggerOffline/Higgs/interface/HLTHiggsSubAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
#include "DataFormats/MuonReco/interface/Muon.h"
Expand Down Expand Up @@ -60,7 +61,8 @@ class HLTHiggsSubAnalysis
};

HLTHiggsSubAnalysis(const edm::ParameterSet & pset,
const std::string & analysisname );
const std::string & analysisname,
edm::ConsumesCollector&& iC);
~HLTHiggsSubAnalysis();
void beginJob();
void beginRun(const edm::Run & iRun, const edm::EventSetup & iEventSetup);
Expand All @@ -71,7 +73,7 @@ class HLTHiggsSubAnalysis


private:
void bookobjects(const edm::ParameterSet & anpset);
void bookobjects(const edm::ParameterSet & anpset, edm::ConsumesCollector& iC);
void initobjects(const edm::Event & iEvent, EVTColContainer * col);
void InitSelector(const unsigned int & objtype);
void insertcandidates(const unsigned int & objtype, const EVTColContainer * col,
Expand All @@ -83,7 +85,7 @@ class HLTHiggsSubAnalysis
const std::string & variable, const float & value );

edm::ParameterSet _pset;

std::string _analysisname;

//! The minimum number of reco/gen candidates needed by the analysis
Expand All @@ -101,13 +103,22 @@ class HLTHiggsSubAnalysis

// The name of the object collections to be used in this
// analysis.
std::string _genParticleLabel;
edm::EDGetTokenT<reco::GenParticleCollection> _genParticleLabel;

std::map<unsigned int,std::string> _recLabels;
edm::EDGetTokenT<reco::MuonCollection> _recLabelsMuon;
edm::EDGetTokenT<reco::GsfElectronCollection> _recLabelsElec;
edm::EDGetTokenT<reco::PhotonCollection> _recLabelsPhoton;
edm::EDGetTokenT<reco::CaloMETCollection> _recLabelsCaloMET;
edm::EDGetTokenT<reco::PFTauCollection> _recLabelsPFTau;


//! Some kinematical parameters
std::vector<double> _parametersEta;
std::vector<double> _parametersPhi;
std::vector<double> _parametersTurnOn;
edm::EDGetTokenT<edm::TriggerResults> _trigResultsTag;


std::map<unsigned int,double> _cutMinPt;
std::map<unsigned int,double> _cutMaxEta;
Expand All @@ -127,6 +138,7 @@ class HLTHiggsSubAnalysis
StringCutObjectSelector<reco::Photon> * _recPhotonSelector;
StringCutObjectSelector<reco::Track> * _recTrackSelector;


// The plotters: managers of each hlt path where the plots are done
std::vector<HLTHiggsPlotter> _analyzers;

Expand Down
60 changes: 24 additions & 36 deletions HLTriggerOffline/Higgs/src/HLTHiggsSubAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@


HLTHiggsSubAnalysis::HLTHiggsSubAnalysis(const edm::ParameterSet & pset,
const std::string & analysisname) :
const std::string & analysisname,
edm::ConsumesCollector&& iC) :
_pset(pset),
_analysisname(analysisname),
_minCandidates(0),
_hltProcessName(pset.getParameter<std::string>("hltProcessName")),
_genParticleLabel(pset.getParameter<std::string>("genParticleLabel")),
_genParticleLabel(iC.consumes<reco::GenParticleCollection>(pset.getParameter<std::string>("genParticleLabel"))),
_parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
_parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
_parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
_trigResultsTag(iC.consumes<edm::TriggerResults>(edm::InputTag("TriggerResults","",_hltProcessName))),
_recMuonSelector(0),
_recElecSelector(0),
_recCaloMETSelector(0),
Expand All @@ -51,7 +53,7 @@ HLTHiggsSubAnalysis::HLTHiggsSubAnalysis(const edm::ParameterSet & pset,
edm::ParameterSet anpset = pset.getParameter<edm::ParameterSet>(analysisname);
// Collections labels (but genparticles already initialized)
// initializing _recLabels data member)
this->bookobjects( anpset );
this->bookobjects( anpset, iC );

// Generic objects: Initialization of cuts
for(std::map<unsigned int,std::string>::const_iterator it = _recLabels.begin();
Expand All @@ -68,6 +70,7 @@ HLTHiggsSubAnalysis::HLTHiggsSubAnalysis(const edm::ParameterSet & pset,
for(std::map<unsigned int,std::string>::const_iterator it = _recLabels.begin();
it != _recLabels.end(); ++it)
{

const std::string objStr = EVTColContainer::getTypeString(it->first);
try
{
Expand Down Expand Up @@ -427,31 +430,36 @@ const std::vector<unsigned int> HLTHiggsSubAnalysis::getObjectsType(const std::s


// Booking the maps: recLabels and genParticle selectors
void HLTHiggsSubAnalysis::bookobjects( const edm::ParameterSet & anpset )
void HLTHiggsSubAnalysis::bookobjects( const edm::ParameterSet & anpset, edm::ConsumesCollector& iC )
{
if( anpset.exists("recMuonLabel") )
{
_recLabels[EVTColContainer::MUON] = anpset.getParameter<std::string>("recMuonLabel");
_recLabels[EVTColContainer::MUON] = anpset.getParameter<std::string>("recMuonLabel");
_recLabelsMuon = iC.consumes<reco::MuonCollection>(anpset.getParameter<std::string>("recMuonLabel"));
_genSelectorMap[EVTColContainer::MUON] = 0 ;
}
if( anpset.exists("recElecLabel") )
{
_recLabels[EVTColContainer::ELEC] = anpset.getParameter<std::string>("recElecLabel");
_recLabels[EVTColContainer::ELEC] = anpset.getParameter<std::string>("recElecLabel");
_recLabelsElec = iC.consumes<reco::GsfElectronCollection>(anpset.getParameter<std::string>("recElecLabel"));
_genSelectorMap[EVTColContainer::ELEC] = 0 ;
}
if( anpset.exists("recPhotonLabel") )
{
_recLabels[EVTColContainer::PHOTON] = anpset.getParameter<std::string>("recPhotonLabel");
_recLabels[EVTColContainer::PHOTON] = anpset.getParameter<std::string>("recPhotonLabel");
_recLabelsPhoton = iC.consumes<reco::PhotonCollection>(anpset.getParameter<std::string>("recPhotonLabel"));
_genSelectorMap[EVTColContainer::PHOTON] = 0 ;
}
if( anpset.exists("recCaloMETLabel") )
{
_recLabels[EVTColContainer::CALOMET] = anpset.getParameter<std::string>("recCaloMETLabel");
_recLabels[EVTColContainer::CALOMET] = anpset.getParameter<std::string>("recCaloMETLabel");
_recLabelsCaloMET = iC.consumes<reco::CaloMETCollection>(anpset.getParameter<std::string>("recCaloMETLabel"));
_genSelectorMap[EVTColContainer::CALOMET] = 0 ;
}
if( anpset.exists("recPFTauLabel") )
{
_recLabels[EVTColContainer::PFTAU] = anpset.getParameter<std::string>("recPFTauLabel");
_recLabels[EVTColContainer::PFTAU] = anpset.getParameter<std::string>("recPFTauLabel");
_recLabelsPFTau = iC.consumes<reco::PFTauCollection>(anpset.getParameter<std::string>("recPFTauLabel"));
_genSelectorMap[EVTColContainer::PFTAU] = 0 ;
}
/*if( anpset.exists("recTrackLabel") )
Expand All @@ -478,31 +486,17 @@ void HLTHiggsSubAnalysis::initobjects(const edm::Event & iEvent, EVTColContainer
}*/
if( ! col->isCommonInit() )
{
// TO BE DEPRECATED AS we don't need it anymore.
// There is no match with HLT candidates... Use, then TriggerResults
/*edm::Handle<trigger::TriggerEventWithRefs> rawTEH;
iEvent.getByLabel("hltTriggerSummaryRAW",rawTEH);
if(rawTEH.failedToGet())
{
edm::LogError("HiggsValidation") << "HLTHiggsSubAnalysis::initobjecst, "
<< "No trigger summary found";
return;
}
col->rawTriggerEvent = rawTEH.product();*/
// END-- TO BE DEPRECATED

// extract the trigger results (path info, pass,...)
edm::Handle<edm::TriggerResults> trigResults;
edm::InputTag trigResultsTag("TriggerResults","",_hltProcessName);
iEvent.getByLabel(trigResultsTag,trigResults);
iEvent.getByToken(_trigResultsTag,trigResults);
if( trigResults.isValid() )
{
col->triggerResults = trigResults.product();
}

// GenParticle collection if is there
edm::Handle<reco::GenParticleCollection> genPart;
iEvent.getByLabel(_genParticleLabel,genPart);
iEvent.getByToken(_genParticleLabel,genPart);
if( genPart.isValid() )
{
col->genParticles = genPart.product();
Expand All @@ -515,39 +509,33 @@ void HLTHiggsSubAnalysis::initobjects(const edm::Event & iEvent, EVTColContainer
if( it->first == EVTColContainer::MUON )
{
edm::Handle<reco::MuonCollection> theHandle;
iEvent.getByLabel(it->second, theHandle);
iEvent.getByToken(_recLabelsMuon, theHandle);
col->set(theHandle.product());
}
else if( it->first == EVTColContainer::ELEC )
{
edm::Handle<reco::GsfElectronCollection> theHandle;
iEvent.getByLabel(it->second, theHandle);
iEvent.getByToken(_recLabelsElec, theHandle);
col->set(theHandle.product());
}
else if( it->first == EVTColContainer::PHOTON )
{
edm::Handle<reco::PhotonCollection> theHandle;
iEvent.getByLabel(it->second, theHandle);
iEvent.getByToken(_recLabelsPhoton, theHandle);
col->set(theHandle.product());
}
else if( it->first == EVTColContainer::CALOMET )
{
edm::Handle<reco::CaloMETCollection> theHandle;
iEvent.getByLabel(it->second, theHandle);
iEvent.getByToken(_recLabelsCaloMET, theHandle);
col->set(theHandle.product());
}
else if( it->first == EVTColContainer::PFTAU )
{
edm::Handle<reco::PFTauCollection> theHandle;
iEvent.getByLabel(it->second, theHandle);
iEvent.getByToken(_recLabelsPFTau, theHandle);
col->set(theHandle.product());
}
/* else if( it->first == EVTColContainer::TRACK )
{
edm::Handle<reco::TrackCollection> theHandle;
iEvent.getByLabel(it->second, theHandle);
col->set(theHandle.product());
}*/
else
{
edm::LogError("HiggsValidation") << "HLTHiggsSubAnalysis::initobjects "
Expand Down
16 changes: 9 additions & 7 deletions HLTriggerOffline/Higgs/src/HLTHiggsValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//

//
// Jordi Duarte Campderros (based on the Jason Slaunwhite
// Jordi Duarte Campderros (based on the Jason Slaunwhite
// and Jeff Klukas coded from the HLTriggerOffline/Muon package
//
//
Expand All @@ -28,6 +28,14 @@ HLTHiggsValidator::HLTHiggsValidator(const edm::ParameterSet& pset) :
_dbe(0)
{
_collections = new EVTColContainer;

//pass consumes list to the helper classes
for(size_t i = 0; i < _analysisnames.size() ; ++i)
{
HLTHiggsSubAnalysis analyzer(_pset, _analysisnames.at(i), consumesCollector());
_analyzers.push_back(analyzer);
}

}

HLTHiggsValidator::~HLTHiggsValidator()
Expand All @@ -39,14 +47,8 @@ HLTHiggsValidator::~HLTHiggsValidator()
}
}


void HLTHiggsValidator::beginRun(const edm::Run & iRun, const edm::EventSetup & iSetup)
{
for(size_t i = 0; i < _analysisnames.size() ; ++i)
{
HLTHiggsSubAnalysis analyzer(_pset, _analysisnames.at(i));
_analyzers.push_back(analyzer);
}
// Call the Plotter beginRun (which stores the triggers paths..:)
for(std::vector<HLTHiggsSubAnalysis>::iterator iter = _analyzers.begin();
iter != _analyzers.end(); ++iter)
Expand Down
1 change: 1 addition & 0 deletions HLTriggerOffline/Muon/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
<use name="TrackingTools/Records"/>
<use name="TrackingTools/TrajectoryState"/>
<flags EDM_PLUGIN="1"/>

20 changes: 17 additions & 3 deletions HLTriggerOffline/Muon/interface/HLTMuonPlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "DataFormats/Common/interface/RefToBase.h"
#include "DataFormats/TrackReco/interface/Track.h"
Expand Down Expand Up @@ -44,6 +45,7 @@
#include <iostream>
#include <algorithm>
#include <cctype>
#include "boost/tuple/tuple.hpp"

#include "TPRegexp.h"

Expand All @@ -57,11 +59,22 @@ class HLTMuonPlotter {

public:
HLTMuonPlotter(const edm::ParameterSet &, std::string,
const std::vector<std::string>&, const std::vector<std::string>&);
const std::vector<std::string>&,
const std::vector<std::string>&,
const boost::tuple<edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
edm::EDGetTokenT<reco::GenParticleCollection>,
edm::EDGetTokenT<reco::MuonCollection> >&
);

void beginJob();
void beginRun(const edm::Run &, const edm::EventSetup &);
void analyze(const edm::Event &, const edm::EventSetup &);

static boost::tuple<
edm::EDGetTokenT<trigger::TriggerEventWithRefs>,
edm::EDGetTokenT<reco::GenParticleCollection>,
edm::EDGetTokenT<reco::MuonCollection> > getTokens(const edm::ParameterSet&, edm::ConsumesCollector&&);

private:

struct MatchStruct {
Expand Down Expand Up @@ -106,8 +119,9 @@ class HLTMuonPlotter {
std::vector<std::string> moduleLabels_;
std::vector<std::string> stepLabels_;

std::string genParticleLabel_;
std::string recMuonLabel_;
edm::EDGetTokenT<trigger::TriggerEventWithRefs> hltTriggerSummaryRAW_;
edm::EDGetTokenT<reco::GenParticleCollection> genParticleLabel_;
edm::EDGetTokenT<reco::MuonCollection> recMuonLabel_;

std::vector<double> parametersEta_;
std::vector<double> parametersPhi_;
Expand Down
Loading

0 comments on commit e5352d0

Please sign in to comment.