CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/PhysicsTools/SelectorUtils/interface/PVObjectSelector.h

Go to the documentation of this file.
00001 #ifndef Analysis_AnalysisFilters_interface_PVObjectSelector_h
00002 #define Analysis_AnalysisFilters_interface_PVObjectSelector_h
00003 
00004 #include "FWCore/Common/interface/EventBase.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 
00007 #include "PhysicsTools/SelectorUtils/interface/Selector.h"
00008 #include "DataFormats/VertexReco/interface/Vertex.h"
00009 
00010 #include <vector>
00011 #include <string>
00012 
00013 // make a selector for this selection
00014 class PVObjectSelector : public Selector<reco::Vertex> {
00015 public:
00016 
00017   PVObjectSelector() {}
00018 
00019  PVObjectSelector( edm::ParameterSet const & params )  {
00020     push_back("PV NDOF", params.getParameter<double>("minNdof") );
00021     push_back("PV Z", params.getParameter<double>("maxZ") );
00022     push_back("PV RHO", params.getParameter<double>("maxRho") );
00023     set("PV NDOF");
00024     set("PV Z");
00025     set("PV RHO");
00026 
00027     indexNDOF_ = index_type (&bits_, "PV NDOF");
00028     indexZ_    = index_type (&bits_, "PV Z");
00029     indexRho_  = index_type (&bits_, "PV RHO");
00030     
00031     if ( params.exists("cutsToIgnore") )
00032       setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
00033 
00034     retInternal_ = getBitTemplate();
00035   }
00036   
00037  bool operator() ( reco::Vertex const & pv,  pat::strbitset & ret ) {
00038     if ( pv.isFake() ) return false;
00039 
00040     if ( pv.ndof() >= cut(indexNDOF_, double() )
00041          || ignoreCut(indexNDOF_)    ) {
00042       passCut(ret, indexNDOF_ );
00043       if ( fabs(pv.z()) <= cut(indexZ_, double()) 
00044            || ignoreCut(indexZ_)    ) {
00045         passCut(ret, indexZ_ );
00046         if ( fabs(pv.position().Rho()) <= cut(indexRho_, double() )
00047              || ignoreCut(indexRho_) ) {
00048           passCut( ret, indexRho_);
00049         }
00050       }
00051     }
00052 
00053     setIgnored(ret);
00054   
00055     return (bool)ret;
00056   }
00057 
00058  using Selector<reco::Vertex>::operator();
00059 
00060 private:
00061   index_type indexNDOF_;
00062   index_type indexZ_;
00063   index_type indexRho_;
00064 };
00065 
00066 #endif