Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rev 1.0: Post-LS1 CSC integration - updated to new data format CSC packe... #4034

Merged
merged 14 commits into from Jun 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions CommonTools/CandAlgos/interface/CandDecaySelector.h
Expand Up @@ -43,10 +43,10 @@ namespace helper {
std::auto_ptr<reco::CandidateCollection> selCands_;
};

template<>
struct StoreManagerTrait<reco::CandidateCollection> {
template<typename EdmFilter>
struct StoreManagerTrait<reco::CandidateCollection, EdmFilter> {
typedef CandDecayStoreManager type;
typedef ObjectSelectorBase<reco::CandidateCollection> base;
typedef ObjectSelectorBase<reco::CandidateCollection, EdmFilter> base;
};

}
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/RecoAlgos/plugins/VertexSelector.cc
Expand Up @@ -26,9 +26,9 @@
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

typedef SingleObjectSelector<
using VertexSelector = SingleObjectSelectorStream<
reco::VertexCollection,
StringCutObjectSelector<reco::Vertex>
> VertexSelector;
>;

DEFINE_FWK_MODULE(VertexSelector);
4 changes: 2 additions & 2 deletions CommonTools/UtilAlgos/interface/NullPostProcessor.h
Expand Up @@ -7,12 +7,12 @@
#include "FWCore/Framework/interface/ConsumesCollector.h"
namespace helper {

template<typename OutputCollection>
template<typename OutputCollection, typename EdmFilter=edm::EDFilter>
struct NullPostProcessor {
NullPostProcessor( const edm::ParameterSet & iConfig, edm::ConsumesCollector && iC ) :
NullPostProcessor( iConfig ) { }
NullPostProcessor( const edm::ParameterSet & iConfig ) { }
void init( edm::EDFilter & ) { }
void init( EdmFilter & ) { }
void process( edm::OrphanHandle<OutputCollection>, edm::Event & ) { }
};

Expand Down
13 changes: 7 additions & 6 deletions CommonTools/UtilAlgos/interface/ObjectSelector.h
Expand Up @@ -31,21 +31,22 @@
template<typename Selector,
typename OutputCollection = typename ::helper::SelectedOutputCollectionTrait<typename Selector::collection>::type,
typename SizeSelector = NonNullNumberSelector,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection>,
typename StoreManager = typename ::helper::StoreManagerTrait<OutputCollection>::type,
typename Base = typename ::helper::StoreManagerTrait<OutputCollection>::base,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection, edm::EDFilter>,
typename StoreManager = typename ::helper::StoreManagerTrait<OutputCollection, edm::EDFilter>::type,
typename Base = typename ::helper::StoreManagerTrait<OutputCollection, edm::EDFilter>::base,
typename Init = typename ::reco::modules::EventSetupInit<Selector>::type
>
class ObjectSelector : public Base {
public:
/// constructor
// ObjectSelector()=default;
explicit ObjectSelector(const edm::ParameterSet & cfg) :
Base(cfg),
srcToken_(edm::EDFilter::consumes<typename Selector::collection>(cfg.template getParameter<edm::InputTag>("src"))),
srcToken_( this-> template consumes<typename Selector::collection>(cfg.template getParameter<edm::InputTag>("src"))),
filter_(false),
selector_(cfg, edm::EDFilter::consumesCollector()),
selector_(cfg, this->consumesCollector()),
sizeSelector_(reco::modules::make<SizeSelector>(cfg)),
postProcessor_(cfg, edm::EDFilter::consumesCollector()) {
postProcessor_(cfg, this->consumesCollector()) {
const std::string filter("filter");
std::vector<std::string> bools = cfg.template getParameterNamesForType<bool>();
bool found = std::find(bools.begin(), bools.end(), filter) != bools.end();
Expand Down
4 changes: 2 additions & 2 deletions CommonTools/UtilAlgos/interface/SingleObjectRefSelector.h
Expand Up @@ -15,8 +15,8 @@ template<typename InputType, typename Selector,
typename OutputCollection = typename ::helper::SelectedOutputCollectionTrait<edm::View<InputType> >::type,
typename StoreContainer = typename ::helper::StoreContainerTrait<OutputCollection>::type,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection>,
typename StoreManager = typename ::helper::StoreManagerTrait<OutputCollection>::type,
typename Base = typename ::helper::StoreManagerTrait<OutputCollection>::base,
typename StoreManager = typename ::helper::StoreManagerTrait<OutputCollection, edm::EDFilter>::type,
typename Base = typename ::helper::StoreManagerTrait<OutputCollection, edm::EDFilter>::base,
typename RefAdder = typename ::helper::SelectionAdderTrait<edm::View<InputType>, StoreContainer>::type>
class SingleObjectRefSelector :
public ObjectSelector<SingleElementCollectionRefSelector<InputType, Selector, OutputCollection, StoreContainer, RefAdder>,
Expand Down
56 changes: 49 additions & 7 deletions CommonTools/UtilAlgos/interface/SingleObjectSelector.h
Expand Up @@ -9,22 +9,64 @@
#include "CommonTools/UtilAlgos/interface/SelectionAdderTrait.h"
#include "CommonTools/UtilAlgos/interface/SingleElementCollectionSelector.h"



/* the following is just to ease transition
* grep -r SingleObjectSelector * | wc
* 209 540 22532
*/


template<typename InputCollection, typename Selector,
typename EdmFilter,
typename OutputCollection = typename ::helper::SelectedOutputCollectionTrait<InputCollection>::type,
typename StoreContainer = typename ::helper::StoreContainerTrait<OutputCollection>::type,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection>,
typename StoreManager = typename ::helper::StoreManagerTrait<OutputCollection>::type,
typename Base = typename ::helper::StoreManagerTrait<OutputCollection>::base,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection, EdmFilter>,
typename StoreManager = typename ::helper::StoreManagerTrait<OutputCollection, EdmFilter>::type,
typename Base = typename ::helper::StoreManagerTrait<OutputCollection, EdmFilter>::base,
typename RefAdder = typename ::helper::SelectionAdderTrait<InputCollection, StoreContainer>::type>
class SingleObjectSelector :
class SingleObjectSelectorBase :
public ObjectSelector<SingleElementCollectionSelector<InputCollection, Selector, OutputCollection, StoreContainer, RefAdder>,
OutputCollection, NonNullNumberSelector, PostProcessor, StoreManager, Base> {
public:
explicit SingleObjectSelector( const edm::ParameterSet & cfg ) :
// SingleObjectSelectorBase() = default;
explicit SingleObjectSelectorBase( const edm::ParameterSet & cfg ) :
ObjectSelector<SingleElementCollectionSelector<InputCollection, Selector, OutputCollection, StoreContainer, RefAdder>,
OutputCollection, NonNullNumberSelector, PostProcessor>( cfg ) { }
virtual ~SingleObjectSelector() { }
OutputCollection, NonNullNumberSelector, PostProcessor, StoreManager, Base>( cfg ) { }
virtual ~SingleObjectSelectorBase() { }
};



template<typename InputCollection, typename Selector,
typename OutputCollection = typename ::helper::SelectedOutputCollectionTrait<InputCollection>::type,
typename StoreContainer = typename ::helper::StoreContainerTrait<OutputCollection>::type,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection, edm::EDFilter> >
using SingleObjectSelectorLegacy = SingleObjectSelectorBase<InputCollection,Selector, edm::EDFilter,
OutputCollection,StoreContainer,PostProcessor
>;



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

template<typename InputCollection, typename Selector,
typename OutputCollection = typename ::helper::SelectedOutputCollectionTrait<InputCollection>::type,
typename StoreContainer = typename ::helper::StoreContainerTrait<OutputCollection>::type,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection, edm::stream::EDFilter<> > >
using SingleObjectSelectorStream = SingleObjectSelectorBase<InputCollection,Selector, edm::stream::EDFilter<>,
OutputCollection,StoreContainer,PostProcessor
>;


template<typename InputCollection, typename Selector,
typename OutputCollection = typename ::helper::SelectedOutputCollectionTrait<InputCollection>::type,
typename StoreContainer = typename ::helper::StoreContainerTrait<OutputCollection>::type,
typename PostProcessor = ::helper::NullPostProcessor<OutputCollection, edm::stream::EDFilter<> > >
using SingleObjectSelector = SingleObjectSelectorStream<InputCollection,Selector,
OutputCollection,StoreContainer,PostProcessor>;



#endif

40 changes: 8 additions & 32 deletions CommonTools/UtilAlgos/interface/StoreManagerTrait.h
Expand Up @@ -63,39 +63,15 @@ namespace helper {
}
};

/*
template<typename OutputCollection, typename InputCollection>
struct OutputCollectionCreator {
static std::auto_ptr<OutputCollection> createNewCollection( const edm::Handle<InputCollection> & ) {
return std::auto_ptr<OutputCollection>( new OutputCollection );
}
};

template<typename T, typename InputCollection>
struct OutputCollectionCreator<edm::RefToBaseVector<T>, InputCollection> {
static std::auto_ptr<edm::RefToBaseVector<T> > createNewCollection( const edm::Handle<InputCollection> & h ) {
return std::auto_ptr<edm::RefToBaseVector<T> >( new edm::RefToBaseVector<T>(h) );
}
};
*/

/*
template<typename T1, typename T2>
struct OutputCollectionCreator<RefToBaseVector<T1>, RefToBaseVector<T2> > {
static RefToBaseVector<T1> * createNewCollection( const edm::Handle<RefToBaseVector<T2> > & h ) {
return new RefToBaseVector<T1>(h);
}
};
*/

template<typename OutputCollection,
typename ClonePolicy = IteratorToObjectConverter<OutputCollection> >
struct CollectionStoreManager {
typedef OutputCollection collection;
template<typename C>
CollectionStoreManager( const edm::Handle<C> & h ) :
selected_( new OutputCollection ) {
// selected_ = OutputCollectionCreator<OutputCollection, C>::createNewCollection(h);
selected_( new OutputCollection ) {
}
template<typename I>
void cloneAndStore( const I & begin, const I & end, edm::Event & ) {
Expand All @@ -113,17 +89,17 @@ namespace helper {
std::auto_ptr<collection> selected_;
};

template<typename OutputCollection>
struct ObjectSelectorBase : public edm::EDFilter {
ObjectSelectorBase( const edm::ParameterSet & cfg ) {
produces<OutputCollection>();
template<typename OutputCollection, typename EdmFilter>
struct ObjectSelectorBase : public EdmFilter {
ObjectSelectorBase( const edm::ParameterSet &) {
this-> template produces<OutputCollection>();
}
};

template<typename OutputCollection>
template<typename OutputCollection, typename EdmFilter=edm::EDFilter>
struct StoreManagerTrait {
typedef CollectionStoreManager<OutputCollection> type;
typedef ObjectSelectorBase<OutputCollection> base;
using type = CollectionStoreManager<OutputCollection>;
using base = ObjectSelectorBase<OutputCollection, EdmFilter>;
};

}
Expand Down