CMS 3D CMS Logo

AlignmentTrackSelectorModule.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/Framework/interface/MakerMacros.h"
00003 #include "PhysicsTools/UtilAlgos/interface/ObjectSelector.h"
00004 
00005 //the selectores used to select the tracks
00006 #include "Alignment/CommonAlignmentProducer/interface/AlignmentTrackSelector.h"
00007 #include "Alignment/CommonAlignmentProducer/interface/AlignmentGlobalTrackSelector.h"
00008 #include "Alignment/CommonAlignmentProducer/interface/AlignmentTwoBodyDecayTrackSelector.h"
00009 
00010 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00011 
00012 // the following include is necessary to clone all track branches
00013 // including recoTrackExtras and TrackingRecHitsOwned (in future also "owned clusters"?).
00014 // if you remove it the code will compile, but the cloned
00015 // tracks have only the recoTracks branch!
00016 #include "PhysicsTools/RecoAlgos/interface/TrackSelector.h"
00017 
00018 struct TrackConfigSelector {
00019 
00020   typedef std::vector<const reco::Track*> container;
00021   typedef container::const_iterator const_iterator;
00022   typedef reco::TrackCollection collection; 
00023 
00024  TrackConfigSelector( const edm::ParameterSet & cfg ) :
00025     theBaseSelector(cfg),
00026     theGlobalSelector(cfg.getParameter<edm::ParameterSet>("GlobalSelector")),
00027     theTwoBodyDecaySelector(cfg.getParameter<edm::ParameterSet>("TwoBodyDecaySelector"))
00028   {
00029     //TODO Wrap the BaseSelector into its own PSet
00030     theBaseSwitch = theBaseSelector.useThisFilter();
00031     
00032     theGlobalSwitch =  theGlobalSelector.useThisFilter();
00033       
00034     theTwoBodyDecaySwitch = theTwoBodyDecaySelector.useThisFilter();
00035   }
00036   
00037   const_iterator begin() const { return theSelectedTracks.begin(); }
00038   const_iterator end() const { return theSelectedTracks.end(); }
00039   size_t size() const { return theSelectedTracks.size(); }
00040 
00041   void select( const edm::Handle<reco::TrackCollection> & c,  const edm::Event & evt,
00042                const edm::EventSetup &/*dummy*/)
00043   {
00044     theSelectedTracks.clear();
00045     for( reco::TrackCollection::const_iterator i=c.product()->begin();i!=c.product()->end();++i){
00046       theSelectedTracks.push_back(& * i );
00047     }
00048     // might add EvetSetup to the select(...) method of the Selectors
00049     if(theBaseSwitch)
00050       theSelectedTracks=theBaseSelector.select(theSelectedTracks,evt);
00051     if(theGlobalSwitch)
00052       theSelectedTracks=theGlobalSelector.select(theSelectedTracks,evt);    
00053     if(theTwoBodyDecaySwitch)
00054       theSelectedTracks=theTwoBodyDecaySelector.select(theSelectedTracks,evt);
00055   }
00056 
00057 private:
00058   container theSelectedTracks;
00059 
00060   bool theBaseSwitch, theGlobalSwitch, theTwoBodyDecaySwitch;
00061   AlignmentTrackSelector theBaseSelector;
00062   AlignmentGlobalTrackSelector theGlobalSelector;
00063   AlignmentTwoBodyDecayTrackSelector theTwoBodyDecaySelector;
00064 
00065 };
00066 
00067 typedef ObjectSelector<TrackConfigSelector>  AlignmentTrackSelectorModule;
00068 
00069 DEFINE_FWK_MODULE( AlignmentTrackSelectorModule );

Generated on Tue Jun 9 17:23:53 2009 for CMSSW by  doxygen 1.5.4