CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Calibration/TkAlCaRecoProducers/plugins/CalibrationTrackSelectorModule.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/Framework/interface/MakerMacros.h"
00003 #include "CommonTools/UtilAlgos/interface/ObjectSelector.h"
00004 
00005 //the selectores used to select the tracks
00006 #include "Calibration/TkAlCaRecoProducers/interface/CalibrationTrackSelector.h"
00007 
00008 // the following include is necessary to clone all track branches
00009 // including recoTrackExtras and TrackingRecHitsOwned.
00010 // if you remove it the code will compile, but the cloned
00011 // tracks have only the recoTracks branch!
00012 #include "CommonTools/RecoAlgos/interface/TrackSelector.h"
00013 
00014 struct SiStripCalTrackConfigSelector {
00015 
00016   typedef std::vector<const reco::Track*> container;
00017   typedef container::const_iterator const_iterator;
00018   typedef reco::TrackCollection collection; 
00019 
00020  SiStripCalTrackConfigSelector( const edm::ParameterSet & cfg ) :
00021     theBaseSelector(cfg)
00022   {
00023     //TODO Wrap the BaseSelector into its own PSet
00024     theBaseSwitch = 
00025       cfg.getParameter<bool>("applyBasicCuts") ||
00026       cfg.getParameter<bool>("minHitsPerSubDet") ||
00027       cfg.getParameter<bool>("applyNHighestPt") ||
00028       cfg.getParameter<bool>("applyMultiplicityFilter");
00029     
00030   }
00031   
00032   const_iterator begin() const { return theSelectedTracks.begin(); }
00033   const_iterator end() const { return theSelectedTracks.end(); }
00034   size_t size() const { return theSelectedTracks.size(); }
00035 
00036   void select( const edm::Handle<reco::TrackCollection> & c,  const edm::Event & evt,
00037                const edm::EventSetup &/*dummy*/)
00038   {
00039     theSelectedTracks.clear();
00040     for( reco::TrackCollection::const_iterator i=c.product()->begin();i!=c.product()->end();++i){
00041       theSelectedTracks.push_back(& * i );
00042     }
00043     // might add EvetSetup to the select(...) method of the Selectors
00044     if(theBaseSwitch)
00045       theSelectedTracks=theBaseSelector.select(theSelectedTracks,evt);
00046   }
00047 
00048 private:
00049   container theSelectedTracks;
00050 
00051   bool theBaseSwitch;
00052   CalibrationTrackSelector theBaseSelector;
00053 
00054 };
00055 
00056 typedef ObjectSelector<SiStripCalTrackConfigSelector>  CalibrationTrackSelectorModule;
00057 
00058 DEFINE_FWK_MODULE( CalibrationTrackSelectorModule );