Skip to content

Commit

Permalink
Merge pull request #1611 from perrotta/fixHLTanalyzers
Browse files Browse the repository at this point in the history
Consumes migration -- Get rid of last remaining getByLabel calls in HLTrigger/HLTanalyzers
  • Loading branch information
ktf committed Nov 29, 2013
2 parents a9bd51d + 007b5a8 commit 2c6e131
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 40 deletions.
5 changes: 2 additions & 3 deletions HLTrigger/HLTanalyzers/interface/EventHeader.h
Expand Up @@ -17,11 +17,10 @@
*/
class EventHeader {
public:
EventHeader(edm::ConsumesCollector && iC);
EventHeader();
EventHeader();
~EventHeader();

void setup(TTree* tree);
void setup(edm::ConsumesCollector && iC, TTree* tree);

/** Analyze the Data */
void analyze(edm::Event const& iEvent, TTree* tree);
Expand Down
2 changes: 1 addition & 1 deletion HLTrigger/HLTanalyzers/interface/HLTBitAnalyzer.h
Expand Up @@ -80,6 +80,6 @@ class HLTBitAnalyzer : public edm::EDAnalyzer {
std::string _HistName; // Name of histogram file
double _EtaMin,_EtaMax;
TFile* m_file; // pointer to Histogram file
bool _UseTFileService;
bool _UseTFileService;

};
1 change: 0 additions & 1 deletion HLTrigger/HLTanalyzers/interface/HLTHeavyIon.h
Expand Up @@ -59,7 +59,6 @@ typedef std::vector<std::string> MyStrings;
class HLTHeavyIon {
public:
HLTHeavyIon(edm::ConsumesCollector && iC);
HLTHeavyIon();

void setup(const edm::ParameterSet& pSet, TTree* tree);
void beginRun(const edm::Run& , const edm::EventSetup& );
Expand Down
17 changes: 5 additions & 12 deletions HLTrigger/HLTanalyzers/src/EventHeader.cc
Expand Up @@ -8,12 +8,6 @@

#include "HLTrigger/HLTanalyzers/interface/EventHeader.h"


EventHeader::EventHeader(edm::ConsumesCollector && iC) : EventHeader::EventHeader()
{
lumi_Token = iC.consumes<LumiSummary>(edm::InputTag("lumiProducer"));
}

EventHeader::EventHeader() :
fRun( -1 ),
fEvent( -1 ),
Expand All @@ -22,16 +16,14 @@ EventHeader::EventHeader() :
fOrbit( -1 ),
fAvgInstDelLumi( -999. ),
_Debug( false )
{
// lumi_Token = consumes<LumiSummary>(edm::InputTag("lumiProducer"));
}
{ }

EventHeader::~EventHeader() {

}

/* Setup the analysis to put the branch-variables into the tree. */
void EventHeader::setup(TTree* HltTree) {
void EventHeader::setup(edm::ConsumesCollector && iC, TTree* HltTree) {

fRun = -1;
fEvent = -1;
Expand All @@ -46,6 +38,8 @@ void EventHeader::setup(TTree* HltTree) {
HltTree->Branch("Bx", &fBx, "Bx/I");
HltTree->Branch("Orbit", &fOrbit, "Orbit/I");
HltTree->Branch("AvgInstDelLumi", &fAvgInstDelLumi, "AvgInstDelLumi/D");

lumi_Token = iC.consumes<LumiSummary,edm::InLumi>(edm::InputTag("lumiProducer"));
}

/* **Analyze the event** */
Expand All @@ -62,8 +56,7 @@ void EventHeader::analyze(edm::Event const& iEvent, TTree* HltTree) {
const edm::LuminosityBlock& iLumi = iEvent.getLuminosityBlock();
edm::Handle<LumiSummary> lumiSummary;
try{
if (!lumi_Token.isUnitialized() ) iLumi.getByToken(lumi_Token, lumiSummary);
else iLumi.getByLabel(edm::InputTag("lumiProducer"), lumiSummary);
iLumi.getByToken(lumi_Token, lumiSummary);
lumiSummary->isValid();
}
catch(cms::Exception&){
Expand Down
8 changes: 2 additions & 6 deletions HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc
Expand Up @@ -13,11 +13,7 @@ template <class T>
static inline
bool getCollection(const edm::Event & event, std::vector<MissingCollectionInfo> & missing, edm::Handle<T> & handle, const edm::InputTag & name, const edm::EDGetTokenT<T> token, const char * description)
{
if (token.isUnitialized()) {
event.getByLabel(name, handle);
std::cout << "*** HLTAnalyzer/getCollection: Token corresponding to label " << name << "is not initialized" << std::endl;
}
else event.getByToken(token, handle);
event.getByToken(token, handle);
bool valid = handle.isValid();
if (not valid) {
missing.push_back( std::make_pair(description, & name) );
Expand Down Expand Up @@ -378,7 +374,7 @@ HLTAnalyzer::HLTAnalyzer(edm::ParameterSet const& conf) {
hlt_analysis_.setup(conf, HltTree);
vrt_analysisHLT_.setup(conf, HltTree, "HLT");
vrt_analysisOffline0_.setup(conf, HltTree, "Offline0");
evt_header_.setup(HltTree);
evt_header_.setup(consumesCollector(), HltTree);
}

void HLTAnalyzer::beginRun(const edm::Run& run, const edm::EventSetup& c){
Expand Down
8 changes: 2 additions & 6 deletions HLTrigger/HLTanalyzers/src/HLTBitAnalyzer.cc
Expand Up @@ -15,11 +15,7 @@ template <class T>
static inline
bool getCollection(const edm::Event & event, std::vector<MissingCollectionInfo> & missing, edm::Handle<T> & handle, const edm::InputTag & name, const edm::EDGetTokenT<T> token, const char * description)
{
if (token.isUnitialized()) {
event.getByLabel(name, handle);
std::cout << "*** HLTAnalyzer/getCollection: Token corresponding to label " << name << "is not initialized" << std::endl;
}
else event.getByToken(token, handle);
event.getByToken(token, handle);
bool valid = handle.isValid();
if (not valid) {
missing.push_back( std::make_pair(description, & name) );
Expand Down Expand Up @@ -97,7 +93,7 @@ HLTBitAnalyzer::HLTBitAnalyzer(edm::ParameterSet const& conf) {

// Setup the different analysis
hlt_analysis_.setup(conf, HltTree);
evt_header_.setup(HltTree);
evt_header_.setup(consumesCollector(), HltTree);
}

// Boiler-plate "analyze" method declaration for an analyzer module.
Expand Down
14 changes: 3 additions & 11 deletions HLTrigger/HLTanalyzers/src/HLTHeavyIon.cc
Expand Up @@ -18,20 +18,14 @@
#include "DataFormats/HeavyIonEvent/interface/Centrality.h"
using namespace std;

HLTHeavyIon::HLTHeavyIon(edm::ConsumesCollector && iC) : HLTHeavyIon::HLTHeavyIon()
{
centralityBin_Token = iC.consumes<int>( centralityBin_Label);
}

HLTHeavyIon::HLTHeavyIon() {

HLTHeavyIon::HLTHeavyIon(edm::ConsumesCollector && iC) {
//set parameter defaults
_Monte = false;
_Debug = false;
_OR_BXes=false;
UnpackBxInEvent=1;
centralityBin_Label = edm::InputTag("centralityBin");

centralityBin_Token = iC.consumes<int>( centralityBin_Label);
}

void
Expand All @@ -47,7 +41,6 @@ HLTHeavyIon::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {

void HLTHeavyIon::beginRun(const edm::Run& run, const edm::EventSetup& c){


bool changed(true);
if (hltConfig_.init(run,c,processName_,changed)) {
// if init returns TRUE, initialisation has succeeded!
Expand Down Expand Up @@ -169,8 +162,7 @@ void HLTHeavyIon::analyze(const edm::Handle<edm::TriggerResults>
}

edm::Handle<int> binHandle;
if (!centralityBin_Token.isUnitialized()) iEvent.getByToken(centralityBin_Token,binHandle);
else iEvent.getByLabel(centralityBin_Label,binHandle);
iEvent.getByToken(centralityBin_Token,binHandle);
hiBin = *binHandle;

hiNpix = centrality->multiplicityPixel();
Expand Down

0 comments on commit 2c6e131

Please sign in to comment.