Skip to content

Commit

Permalink
Merge pull request #10671 from lgray/threaded_miniaod_75X
Browse files Browse the repository at this point in the history
Convert all remaining RECO & MiniAOD modules that are executed to threaded FW (75X)
  • Loading branch information
cmsbuild committed Sep 23, 2015
2 parents 2d7dad7 + 13095bd commit 01e471a
Show file tree
Hide file tree
Showing 89 changed files with 1,252 additions and 1,444 deletions.
8 changes: 4 additions & 4 deletions CommonTools/ParticleFlow/plugins/TopProjector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/Event.h"
Expand Down Expand Up @@ -134,7 +134,7 @@ template < class Top, class Bottom>
};

template< class Top, class Bottom, class Matcher = TopProjectorFwdPtrOverlap<Top,Bottom> >
class TopProjector : public edm::EDProducer {
class TopProjector : public edm::stream::EDProducer<> {

public:

Expand Down Expand Up @@ -199,8 +199,8 @@ TopProjector< Top, Bottom, Matcher>::TopProjector(const edm::ParameterSet& iConf


template< class Top, class Bottom, class Matcher >
void TopProjector< Top, Bottom, Matcher >::produce(edm::Event& iEvent,
const edm::EventSetup& iSetup) {
void TopProjector< Top, Bottom, Matcher >::produce( edm::Event& iEvent,
const edm::EventSetup& iSetup) {
// get the various collections

// Access the masking collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/


#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"

#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/BTauReco/interface/CATopJetTagInfo.h"
Expand All @@ -34,7 +34,7 @@
#include "DataFormats/Math/interface/deltaR.h"

template < class T, class I >
class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer {
class JetDeltaRTagInfoValueMapProducer : public edm::global::EDProducer<> {

public:

Expand All @@ -57,7 +57,7 @@ class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer {
virtual void beginJob() override {}
virtual void endJob() override {}

virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {
virtual void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override {

std::auto_ptr< TagInfosCollection > mappedTagInfos ( new TagInfosCollection() );

Expand All @@ -69,7 +69,7 @@ class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer {
edm::Handle< typename edm::View<I> > h_tagInfos;
iEvent.getByToken( matchedTagInfosToken_, h_tagInfos );

double distMax2 = distMax_*distMax_;
const double distMax2 = distMax_*distMax_;

std::vector<bool> jets2_locks( h_jets2->size(), false );

Expand Down Expand Up @@ -126,10 +126,10 @@ class JetDeltaRTagInfoValueMapProducer : public edm::EDProducer {
iEvent.put(mappedTagInfos);
}

edm::EDGetTokenT< typename edm::View<T> > srcToken_;
edm::EDGetTokenT< typename edm::View<T> > matchedToken_;
edm::EDGetTokenT< typename edm::View<I> > matchedTagInfosToken_;
double distMax_;
const edm::EDGetTokenT< typename edm::View<T> > srcToken_;
const edm::EDGetTokenT< typename edm::View<T> > matchedToken_;
const edm::EDGetTokenT< typename edm::View<I> > matchedTagInfosToken_;
const double distMax_;

};

Expand Down
19 changes: 8 additions & 11 deletions CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/


#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"

#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/JetReco/interface/PFJet.h"
Expand All @@ -29,7 +29,7 @@
#include "DataFormats/Math/interface/deltaR.h"

template < class T >
class JetDeltaRValueMapProducer : public edm::EDProducer {
class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {

public:

Expand All @@ -47,7 +47,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer {
{
if( value_!="" )
{
evaluationMap_.insert( std::make_pair( value_, StringObjectFunction<T>( value_, lazyParser_ ) ) );
evaluationMap_.insert( std::make_pair( value_, std::unique_ptr<StringObjectFunction<T> >( new StringObjectFunction<T>( value_, lazyParser_ ) ) ) );
produces< JetValueMap >();
}

Expand All @@ -58,7 +58,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer {
multiValue_ = true;
for( size_t i=0; i<valueLabels_.size(); ++i)
{
evaluationMap_.insert( std::make_pair( valueLabels_[i], StringObjectFunction<T>( values_[i], lazyParser_ ) ) );
evaluationMap_.insert( std::make_pair( valueLabels_[i], std::unique_ptr<StringObjectFunction<T> >( new StringObjectFunction<T>( values_[i], lazyParser_ ) ) ) );
produces< JetValueMap >(valueLabels_[i]);
}
}
Expand All @@ -70,10 +70,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer {
virtual ~JetDeltaRValueMapProducer() {}

private:

virtual void beginJob() override {}
virtual void endJob() override {}


virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {

edm::Handle< typename edm::View<T> > h_jets1;
Expand Down Expand Up @@ -121,11 +118,11 @@ class JetDeltaRValueMapProducer : public edm::EDProducer {
{
jets1_locks.at(matched_index) = true;
if( value_!="" )
values.at(matched_index) = (evaluationMap_.at(value_))(*ijet);
values.at(matched_index) = (*(evaluationMap_.at(value_)))(*ijet);
if( multiValue_ )
{
for( size_t i=0; i<valueLabels_.size(); ++i)
valuesMap.at(valueLabels_[i]).at(matched_index) = (evaluationMap_.at(valueLabels_[i]))(*ijet);
valuesMap.at(valueLabels_[i]).at(matched_index) = (*(evaluationMap_.at(valueLabels_[i])))(*ijet);
}
}
}
Expand Down Expand Up @@ -166,7 +163,7 @@ class JetDeltaRValueMapProducer : public edm::EDProducer {
const std::vector<std::string> valueLabels_;
const bool lazyParser_;
bool multiValue_;
std::map<std::string, StringObjectFunction<T> > evaluationMap_;
std::map<std::string, std::unique_ptr<const StringObjectFunction<T> > > evaluationMap_;
};

typedef JetDeltaRValueMapProducer<reco::Jet> RecoJetDeltaRValueMapProducer;
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/RecoUtils/interface/PFCand_AssoMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -34,7 +34,7 @@
// class declaration
//

class PFCand_AssoMap : public edm::EDProducer, public PFCand_AssoMapAlgos {
class PFCand_AssoMap : public edm::stream::EDProducer<>, public PFCand_AssoMapAlgos {
public:
explicit PFCand_AssoMap(const edm::ParameterSet&);
~PFCand_AssoMap();
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/RecoUtils/interface/PF_PU_AssoMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand All @@ -38,7 +38,7 @@
// class declaration
//

class PF_PU_AssoMap : public edm::EDProducer, public PF_PU_AssoMapAlgos {
class PF_PU_AssoMap : public edm::stream::EDProducer<>, public PF_PU_AssoMapAlgos {
public:
explicit PF_PU_AssoMap(const edm::ParameterSet&);
~PF_PU_AssoMap();
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/UtilAlgos/interface/PhysObjectMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* (3) the ranking of several matches.
*
*/
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "CommonTools/UtilAlgos/interface/DeltaR.h"
Expand Down Expand Up @@ -60,7 +60,7 @@ namespace reco {
typename C2::value_type>,
C1, C2 >
>
class PhysObjectMatcher : public edm::EDProducer {
class PhysObjectMatcher : public edm::stream::EDProducer<> {
public:
PhysObjectMatcher(const edm::ParameterSet & cfg);
~PhysObjectMatcher();
Expand Down
13 changes: 7 additions & 6 deletions CommonTools/Utils/src/MethodInvoker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,14 @@ invoker(const edm::TypeWithDict& type) const
{
//std::cout << "LazyInvoker for " << name_ << " called on type " <<
// type.qualifiedName() << std::endl;
SingleInvokerPtr& invoker = invokers_[edm::TypeID(type.typeInfo())];
if (!invoker) {
//std::cout << " Making new invoker for " << name_ << " on type " <<
// type.qualifiedName() << std::endl;
invoker.reset(new SingleInvoker(type, name_, argsBeforeFixups_));
const edm::TypeID thetype(type.typeInfo());
auto found = invokers_.find(thetype);
if( found != invokers_.cend() ) {
return *(found->second);
}
return *invoker;
auto to_add = std::make_shared<SingleInvoker>(type, name_, argsBeforeFixups_);
auto emplace_result = invokers_.insert(std::make_pair(thetype,to_add) );
return *(emplace_result.first->second);
}

edm::ObjectWithDict
Expand Down
18 changes: 15 additions & 3 deletions CommonTools/Utils/src/MethodInvoker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
#include <map>
#include <vector>

#include "tbb/concurrent_unordered_map.h"

namespace edm {
struct TypeIDHasher {
size_t operator()(TypeID const& tid) const {
tbb::tbb_hash<std::string> hasher;
return hasher(std::string(tid.name()));
}
};
}

namespace reco {
namespace parser {

Expand Down Expand Up @@ -88,14 +99,15 @@ struct SingleInvoker : boost::noncopyable {

/// Keeps different SingleInvokers for each dynamic type of the objects passed to invoke()
struct LazyInvoker {
typedef std::shared_ptr<SingleInvoker> SingleInvokerPtr;
typedef tbb::concurrent_unordered_map<edm::TypeID, SingleInvokerPtr,edm::TypeIDHasher> InvokerMap;
private: // Private Data Members
std::string name_;
std::vector<AnyMethodArgument> argsBeforeFixups_;
// the shared ptr is only to make the code exception safe
// otherwise I think it could leak if the constructor of
// SingleInvoker throws an exception (which can happen)
typedef boost::shared_ptr<SingleInvoker> SingleInvokerPtr;
mutable std::map<edm::TypeID, SingleInvokerPtr> invokers_;
// SingleInvoker throws an exception (which can happen)
mutable InvokerMap invokers_;
private: // Private Function Members
const SingleInvoker& invoker(const edm::TypeWithDict&) const;
public: // Public Function Members
Expand Down
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/src/TriggerObjectStandAlone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ void TriggerObjectStandAlone::packPathNames(const edm::TriggerNames &names) {
for (unsigned int i = 0; i < n; ++i) {
uint16_t id = names.triggerIndex(pathNames_[i]);
if (id >= end) {
static int _warn = 0;
if (++_warn < 5) std::cerr << "Warning: can't resolve '" << pathNames_[i] << "' to a path index" << std::endl;
static std::atomic<int> _warn(0);
if (++_warn < 5) edm::LogWarning("TriggerObjectStandAlone::packPathNames()") << "Warning: can't resolve '" << pathNames_[i] << "' to a path index" << std::endl;
ok = false; break;
} else {
indices[i] = id;
Expand Down
6 changes: 3 additions & 3 deletions JetMETCorrections/Type1MET/interface/CorrectedMETProducerT.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down Expand Up @@ -61,7 +61,7 @@ namespace CorrectedMETProducer_namespace
}

template<typename T>
class CorrectedMETProducerT : public edm::EDProducer
class CorrectedMETProducerT : public edm::stream::EDProducer<>
{
typedef std::vector<T> METCollection;

Expand Down Expand Up @@ -94,7 +94,7 @@ class CorrectedMETProducerT : public edm::EDProducer
for ( typename METCollection::const_iterator rawMEt = rawMEtCollection->begin();
rawMEt != rawMEtCollection->end(); ++rawMEt ) {
CorrMETData correction = algorithm_->compMETCorrection(evt, es);

static const CorrectedMETProducer_namespace::CorrectedMETFactoryT<T> correctedMET_factory {};
T correctedMEt = correctedMET_factory(*rawMEt, correction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down Expand Up @@ -68,7 +68,7 @@ namespace PFJetMETcorrInputProducer_namespace
}

template <typename T, typename Textractor>
class PFJetMETcorrInputProducerT : public edm::EDProducer
class PFJetMETcorrInputProducerT : public edm::stream::EDProducer<>
{
public:

Expand Down Expand Up @@ -169,6 +169,7 @@ class PFJetMETcorrInputProducerT : public edm::EDProducer

const static PFJetMETcorrInputProducer_namespace::RawJetExtractorT<T> rawJetExtractor {};
reco::Candidate::LorentzVector rawJetP4 = rawJetExtractor(jet);

if ( skipMuons_ ) {
const std::vector<reco::CandidatePtr> & cands = jet.daughterPtrVector();
for ( std::vector<reco::CandidatePtr>::const_iterator cand = cands.begin();
Expand Down
20 changes: 8 additions & 12 deletions JetMETCorrections/Type1MET/plugins/PFCandMETcorrInputProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@ PFCandMETcorrInputProducer::PFCandMETcorrInputProducer(const edm::ParameterSet&
vParameterSet cfgBinning = cfg.getParameter<vParameterSet>("binning");
for ( vParameterSet::const_iterator cfgBinningEntry = cfgBinning.begin();
cfgBinningEntry != cfgBinning.end(); ++cfgBinningEntry ) {
binning_.push_back(new binningEntryType(*cfgBinningEntry));
binning_.emplace_back(new binningEntryType(*cfgBinningEntry));
}
} else {
binning_.push_back(new binningEntryType());
binning_.emplace_back(new binningEntryType());
}

for ( std::vector<binningEntryType*>::const_iterator binningEntry = binning_.begin();
for ( auto binningEntry = binning_.begin();
binningEntry != binning_.end(); ++binningEntry ) {
produces<CorrMETData>((*binningEntry)->binLabel_);
}
}

PFCandMETcorrInputProducer::~PFCandMETcorrInputProducer()
{
for ( std::vector<binningEntryType*>::const_iterator it = binning_.begin();
it != binning_.end(); ++it ) {
delete (*it);
}
{
}

void PFCandMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup& es)
{
for ( std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
for ( auto binningEntry = binning_.begin();
binningEntry != binning_.end(); ++binningEntry ) {
(*binningEntry)->binUnclEnergySum_ = CorrMETData();
}
Expand All @@ -45,7 +41,7 @@ void PFCandMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup&

for ( edm::View<reco::Candidate>::const_iterator cand = cands->begin();
cand != cands->end(); ++cand ) {
for ( std::vector<binningEntryType*>::iterator binningEntry = binning_.begin();
for ( auto binningEntry = binning_.begin();
binningEntry != binning_.end(); ++binningEntry ) {
if ( !(*binningEntry)->binSelection_ || (*(*binningEntry)->binSelection_)(cand->p4()) ) {
(*binningEntry)->binUnclEnergySum_.mex += cand->px();
Expand All @@ -56,8 +52,8 @@ void PFCandMETcorrInputProducer::produce(edm::Event& evt, const edm::EventSetup&
}

//--- add momentum sum of PFCandidates not within jets ("unclustered energy") to the event
for ( std::vector<binningEntryType*>::const_iterator binningEntry = binning_.begin();
binningEntry != binning_.end(); ++binningEntry ) {
for ( auto binningEntry = binning_.cbegin();
binningEntry != binning_.cend(); ++binningEntry ) {
evt.put(std::auto_ptr<CorrMETData>(new CorrMETData((*binningEntry)->binUnclEnergySum_)), (*binningEntry)->binLabel_);
}
}
Expand Down
Loading

0 comments on commit 01e471a

Please sign in to comment.