File indexing completed on 2025-02-05 23:50:57
0001 #include "FWCore/Framework/interface/ConsumesCollector.h"
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0004 #include "CommonTools/UtilAlgos/interface/ObjectSelector.h"
0005
0006
0007 #include "Alignment/CommonAlignmentProducer/interface/AlignmentTrackSelector.h"
0008 #include "Alignment/CommonAlignmentProducer/interface/AlignmentGlobalTrackSelector.h"
0009 #include "Alignment/CommonAlignmentProducer/interface/AlignmentTwoBodyDecayTrackSelector.h"
0010
0011 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0012
0013
0014
0015
0016
0017 #include "CommonTools/RecoAlgos/interface/TrackSelector.h"
0018
0019 struct TrackConfigSelector {
0020 typedef std::vector<const reco::Track*> container;
0021 typedef container::const_iterator const_iterator;
0022 typedef reco::TrackCollection collection;
0023
0024 TrackConfigSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
0025 : theBaseSelector(cfg, iC),
0026 theGlobalSelector(cfg.getParameter<edm::ParameterSet>("GlobalSelector"), iC),
0027 theTwoBodyDecaySelector(cfg.getParameter<edm::ParameterSet>("TwoBodyDecaySelector"), iC) {
0028
0029 theBaseSwitch = theBaseSelector.useThisFilter();
0030
0031 theGlobalSwitch = theGlobalSelector.useThisFilter();
0032
0033 theTwoBodyDecaySwitch = theTwoBodyDecaySelector.useThisFilter();
0034 }
0035
0036 const_iterator begin() const { return theSelectedTracks.begin(); }
0037 const_iterator end() const { return theSelectedTracks.end(); }
0038 size_t size() const { return theSelectedTracks.size(); }
0039
0040 void select(const edm::Handle<reco::TrackCollection>& c, const edm::Event& evt, const edm::EventSetup& eSetup) {
0041 theSelectedTracks.clear();
0042 for (reco::TrackCollection::const_iterator i = c.product()->begin(); i != c.product()->end(); ++i) {
0043 theSelectedTracks.push_back(&*i);
0044 }
0045
0046 if (theBaseSwitch)
0047 theSelectedTracks = theBaseSelector.select(theSelectedTracks, evt, eSetup);
0048 if (theGlobalSwitch)
0049 theSelectedTracks = theGlobalSelector.select(theSelectedTracks, evt, eSetup);
0050 if (theTwoBodyDecaySwitch)
0051 theSelectedTracks = theTwoBodyDecaySelector.select(theSelectedTracks, evt, eSetup);
0052 }
0053
0054 static void fillPSetDescription(edm::ParameterSetDescription& desc) {
0055 AlignmentTrackSelector::fillPSetDescription(desc);
0056
0057 edm::ParameterSetDescription globalSelectorDesc;
0058 AlignmentGlobalTrackSelector::fillPSetDescription(globalSelectorDesc);
0059 desc.add<edm::ParameterSetDescription>("GlobalSelector", globalSelectorDesc);
0060
0061 edm::ParameterSetDescription twoBodySelectorDesc;
0062 AlignmentTwoBodyDecayTrackSelector::fillPSetDescription(twoBodySelectorDesc);
0063 desc.add<edm::ParameterSetDescription>("TwoBodyDecaySelector", twoBodySelectorDesc);
0064 }
0065
0066 private:
0067 container theSelectedTracks;
0068
0069 bool theBaseSwitch, theGlobalSwitch, theTwoBodyDecaySwitch;
0070 AlignmentTrackSelector theBaseSelector;
0071 AlignmentGlobalTrackSelector theGlobalSelector;
0072 AlignmentTwoBodyDecayTrackSelector theTwoBodyDecaySelector;
0073 };
0074
0075 typedef ObjectSelector<TrackConfigSelector> AlignmentTrackSelectorModule;
0076
0077 DEFINE_FWK_MODULE(AlignmentTrackSelectorModule);