Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-15 01:24:56

0001 
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "CommonTools/UtilAlgos/interface/ObjectSelector.h"
0005 
0006 //the selectores used to select the tracks
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 // the following include is necessary to clone all track branches
0014 // including recoTrackExtras and TrackingRecHitsOwned (in future also "owned clusters"?).
0015 // if you remove it the code will compile, but the cloned
0016 // tracks have only the recoTracks branch!
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     //TODO Wrap the BaseSelector into its own PSet
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     // might add EvetSetup to the select(...) method of the Selectors
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 private:
0055   container theSelectedTracks;
0056 
0057   bool theBaseSwitch, theGlobalSwitch, theTwoBodyDecaySwitch;
0058   AlignmentTrackSelector theBaseSelector;
0059   AlignmentGlobalTrackSelector theGlobalSelector;
0060   AlignmentTwoBodyDecayTrackSelector theTwoBodyDecaySelector;
0061 };
0062 
0063 typedef ObjectSelector<TrackConfigSelector> AlignmentTrackSelectorModule;
0064 
0065 DEFINE_FWK_MODULE(AlignmentTrackSelectorModule);