Skip to content

Commit

Permalink
Merge pull request #8270 from Martin-Grunewald/MultiThreadingHLTcore74X
Browse files Browse the repository at this point in the history
MultiThreading of HLTcore plugins
  • Loading branch information
cmsbuild committed Mar 20, 2015
2 parents fc14fe9 + ceeb312 commit 76380aa
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 151 deletions.
2 changes: 1 addition & 1 deletion HLTrigger/Configuration/test/examLogs.csh
Expand Up @@ -7,7 +7,7 @@ foreach gtag ( MC DATA )
echo
echo $gtag

foreach table ( FULL Fake GRun HIon PIon )
foreach table ( Fake GRun HIon PIon 50nsGRun )

echo
set name = ${table}_${gtag}
Expand Down
1 change: 1 addition & 0 deletions HLTrigger/HLTcore/BuildFile.xml
@@ -1,3 +1,4 @@
<use name="tbb"/>
<use name="boost"/>
<use name="DataFormats/Common"/>
<use name="FWCore/Framework"/>
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/interface/HLTEventAnalyzerAOD.h
Expand Up @@ -12,7 +12,7 @@
*/

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/stream/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "DataFormats/Common/interface/TriggerResults.h"
Expand All @@ -24,7 +24,7 @@ namespace edm {
//
// class declaration
//
class HLTEventAnalyzerAOD : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
class HLTEventAnalyzerAOD : public edm::stream::EDAnalyzer< > {

public:
explicit HLTEventAnalyzerAOD(const edm::ParameterSet&);
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/interface/HLTEventAnalyzerRAW.h
Expand Up @@ -12,7 +12,7 @@
*/

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/stream/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "DataFormats/Common/interface/TriggerResults.h"
Expand All @@ -24,7 +24,7 @@ namespace edm {
//
// class declaration
//
class HLTEventAnalyzerRAW : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
class HLTEventAnalyzerRAW : public edm::stream::EDAnalyzer< > {

public:
explicit HLTEventAnalyzerRAW(const edm::ParameterSet&);
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/interface/TriggerSummaryAnalyzerAOD.h
Expand Up @@ -13,7 +13,7 @@

#include "DataFormats/HLTReco/interface/TriggerEvent.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/stream/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
namespace edm {
class ConfigurationDescriptions;
Expand All @@ -22,7 +22,7 @@ namespace edm {
//
// class declaration
//
class TriggerSummaryAnalyzerAOD : public edm::one::EDAnalyzer<> {
class TriggerSummaryAnalyzerAOD : public edm::stream::EDAnalyzer<> {

public:
explicit TriggerSummaryAnalyzerAOD(const edm::ParameterSet&);
Expand Down
4 changes: 2 additions & 2 deletions HLTrigger/HLTcore/interface/TriggerSummaryAnalyzerRAW.h
Expand Up @@ -13,7 +13,7 @@

#include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/stream/EDAnalyzer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
namespace edm {
class ConfigurationDescriptions;
Expand All @@ -22,7 +22,7 @@ namespace edm {
//
// class declaration
//
class TriggerSummaryAnalyzerRAW : public edm::one::EDAnalyzer<> {
class TriggerSummaryAnalyzerRAW : public edm::stream::EDAnalyzer<> {

public:
explicit TriggerSummaryAnalyzerRAW(const edm::ParameterSet&);
Expand Down
35 changes: 28 additions & 7 deletions HLTrigger/HLTcore/interface/TriggerSummaryProducerAOD.h
Expand Up @@ -12,7 +12,7 @@
*/

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/GetterOfProducts.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
Expand Down Expand Up @@ -49,6 +49,9 @@
#include <string>
#include <vector>

#include <functional>
#include "tbb/concurrent_unordered_set.h"

namespace edm {
class EventSetup;
}
Expand All @@ -61,16 +64,34 @@ namespace edm {
// class declaration
//

class TriggerSummaryProducerAOD : public edm::EDProducer {
/// GlobalCache
struct InputTagHash {
std::size_t operator()(const edm::InputTag& inputTag) const {
std::hash<std::string> Hash;
// bit-wise xor
return Hash(inputTag.label()) ^ Hash(inputTag.instance()) ^ Hash(inputTag.process());
}
};
struct GlobalInputTags {
GlobalInputTags(): filterTagsGlobal_(),collectionTagsGlobal_(){ }
mutable tbb::concurrent_unordered_set<edm::InputTag,InputTagHash> filterTagsGlobal_;
mutable tbb::concurrent_unordered_set<edm::InputTag,InputTagHash> collectionTagsGlobal_;
};

class TriggerSummaryProducerAOD : public edm::stream::EDProducer<edm::GlobalCache<GlobalInputTags>> {

public:
explicit TriggerSummaryProducerAOD(const edm::ParameterSet&);
explicit TriggerSummaryProducerAOD(const edm::ParameterSet&, const GlobalInputTags *);
~TriggerSummaryProducerAOD();
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
virtual void produce(edm::Event&, const edm::EventSetup&);
virtual void endJob();
virtual void produce(edm::Event&, const edm::EventSetup&) override;
virtual void endStream() override;
static void globalEndJob(const GlobalInputTags *);

// additional
static std::unique_ptr<GlobalInputTags> initializeGlobalCache(edm::ParameterSet const&) {
return std::unique_ptr<GlobalInputTags> (new GlobalInputTags());
};

template <typename C>
void fillTriggerObjectCollections(const edm::Event&, edm::GetterOfProducts<C>& );
Expand Down Expand Up @@ -118,11 +139,11 @@ class TriggerSummaryProducerAOD : public edm::EDProducer {

/// list of L3 filter tags
InputTagSet filterTagsEvent_;
InputTagSet filterTagsGlobal_;
InputTagSet filterTagsStream_;

/// list of L3 collection tags
InputTagSet collectionTagsEvent_;
InputTagSet collectionTagsGlobal_;
InputTagSet collectionTagsStream_;

/// trigger object collection
trigger::TriggerObjectCollection toc_;
Expand Down
33 changes: 17 additions & 16 deletions HLTrigger/HLTcore/plugins/HLTEventAnalyzerAOD.cc
Expand Up @@ -11,6 +11,7 @@
#include "FWCore/Common/interface/TriggerResultsByName.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "HLTrigger/HLTcore/interface/HLTEventAnalyzerAOD.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <cassert>

//
Expand All @@ -27,7 +28,7 @@ HLTEventAnalyzerAOD::HLTEventAnalyzerAOD(const edm::ParameterSet& ps) :
using namespace std;
using namespace edm;

cout << "HLTEventAnalyzerAOD configuration: " << endl
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD configuration: " << endl
<< " ProcessName = " << processName_ << endl
<< " TriggerName = " << triggerName_ << endl
<< " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
Expand Down Expand Up @@ -69,10 +70,10 @@ HLTEventAnalyzerAOD::beginRun(edm::Run const & iRun, edm::EventSetup const& iSet
const unsigned int n(hltConfig_.size());
const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
if (triggerIndex>=n) {
cout << "HLTEventAnalyzerAOD::analyze:"
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyze:"
<< " TriggerName " << triggerName_
<< " not available in (new) config!" << endl;
cout << "Available TriggerNames are: " << endl;
LogVerbatim("HLTEventAnalyzerAOD") << "Available TriggerNames are: " << endl;
hltConfig_.dump("Triggers");
}
}
Expand All @@ -85,7 +86,7 @@ HLTEventAnalyzerAOD::beginRun(edm::Run const & iRun, edm::EventSetup const& iSet
hltConfig_.dump("ProcessPSet");
}
} else {
cout << "HLTEventAnalyzerAOD::analyze:"
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyze:"
<< " config extraction failure with process name "
<< processName_ << endl;
}
Expand All @@ -98,17 +99,17 @@ HLTEventAnalyzerAOD::analyze(const edm::Event& iEvent, const edm::EventSetup& iS
using namespace std;
using namespace edm;

cout << endl;
LogVerbatim("HLTEventAnalyzerAOD") << endl;

// get event products
iEvent.getByToken(triggerResultsToken_,triggerResultsHandle_);
if (!triggerResultsHandle_.isValid()) {
cout << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerResults product from Event!" << endl;
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerResults product from Event!" << endl;
return;
}
iEvent.getByToken(triggerEventToken_,triggerEventHandle_);
if (!triggerEventHandle_.isValid()) {
cout << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerEvent product from Event!" << endl;
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyze: Error in getting TriggerEvent product from Event!" << endl;
return;
}
// sanity check
Expand All @@ -135,21 +136,21 @@ void HLTEventAnalyzerAOD::analyzeTrigger(const edm::Event& iEvent, const edm::Ev
using namespace reco;
using namespace trigger;

cout << endl;
LogVerbatim("HLTEventAnalyzerAOD") << endl;

const unsigned int n(hltConfig_.size());
const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName));
assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(triggerName));

// abort on invalid trigger name
if (triggerIndex>=n) {
cout << "HLTEventAnalyzerAOD::analyzeTrigger: path "
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyzeTrigger: path "
<< triggerName << " - not found!" << endl;
return;
}

const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerName));
cout << "HLTEventAnalyzerAOD::analyzeTrigger: path "
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyzeTrigger: path "
<< triggerName << " [" << triggerIndex << "] "
<< "prescales L1T,HLT: " << prescales.first << "," << prescales.second
<< endl;
Expand All @@ -158,7 +159,7 @@ void HLTEventAnalyzerAOD::analyzeTrigger(const edm::Event& iEvent, const edm::Ev
for (unsigned int i=0; i<prescalesInDetail.first.size(); ++i) {
message << " " << i << ":" << prescalesInDetail.first[i].first << "/" << prescalesInDetail.first[i].second;
}
cout << "HLTEventAnalyzerAOD::analyzeTrigger: path "
LogVerbatim("HLTEventAnalyzerAOD") << "HLTEventAnalyzerAOD::analyzeTrigger: path "
<< triggerName << " [" << triggerIndex << "] "
<< endl
<< "prescales L1T: " << prescalesInDetail.first.size() << message.str()
Expand All @@ -171,13 +172,13 @@ void HLTEventAnalyzerAOD::analyzeTrigger(const edm::Event& iEvent, const edm::Ev
const vector<string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex));

// Results from TriggerResults product
cout << " Trigger path status:"
LogVerbatim("HLTEventAnalyzerAOD") << " Trigger path status:"
<< " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
<< " Accept=" << triggerResultsHandle_->accept(triggerIndex)
<< " Error =" << triggerResultsHandle_->error(triggerIndex)
<< endl;
const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
cout << " Last active module - label/type: "
LogVerbatim("HLTEventAnalyzerAOD") << " Last active module - label/type: "
<< moduleLabels[moduleIndex] << "/" << hltConfig_.moduleType(moduleLabels[moduleIndex])
<< " [" << moduleIndex << " out of 0-" << (m-1) << " on this path]"
<< endl;
Expand All @@ -191,18 +192,18 @@ void HLTEventAnalyzerAOD::analyzeTrigger(const edm::Event& iEvent, const edm::Ev
// check whether the module is packed up in TriggerEvent product
const unsigned int filterIndex(triggerEventHandle_->filterIndex(InputTag(moduleLabel,"",processName_)));
if (filterIndex<triggerEventHandle_->sizeFilters()) {
cout << " 'L3' filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType << endl;
LogVerbatim("HLTEventAnalyzerAOD") << " 'L3' filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType << endl;
const Vids& VIDS (triggerEventHandle_->filterIds(filterIndex));
const Keys& KEYS(triggerEventHandle_->filterKeys(filterIndex));
const size_type nI(VIDS.size());
const size_type nK(KEYS.size());
assert(nI==nK);
const size_type n(max(nI,nK));
cout << " " << n << " accepted 'L3' objects found: " << endl;
LogVerbatim("HLTEventAnalyzerAOD") << " " << n << " accepted 'L3' objects found: " << endl;
const TriggerObjectCollection& TOC(triggerEventHandle_->getObjects());
for (size_type i=0; i!=n; ++i) {
const TriggerObject& TO(TOC[KEYS[i]]);
cout << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": "
LogVerbatim("HLTEventAnalyzerAOD") << " " << i << " " << VIDS[i] << "/" << KEYS[i] << ": "
<< TO.id() << " " << TO.pt() << " " << TO.eta() << " " << TO.phi() << " " << TO.mass()
<< endl;
}
Expand Down

0 comments on commit 76380aa

Please sign in to comment.