CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/PhysicsTools/SelectorUtils/interface/RunLumiSelector.h

Go to the documentation of this file.
00001 #ifndef Analysis_AnalysisFilters_interface_RunLumiSelector_h
00002 #define Analysis_AnalysisFilters_interface_RunLumiSelector_h
00003 
00004 #include "FWCore/Common/interface/EventBase.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 
00007 #include "PhysicsTools/SelectorUtils/interface/EventSelector.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 RunLumiSelector : public EventSelector {
00015 public:
00016   RunLumiSelector() {}
00017 
00018   RunLumiSelector( edm::ParameterSet const & params ) {
00019 
00020     push_back("RunLumi");
00021     
00022     if ( params.exists("lumisToProcess") ) {
00023       lumis_ = params.getUntrackedParameter<std::vector<edm::LuminosityBlockRange> > ("lumisToProcess");
00024       set("RunLumi" );
00025     }
00026     else {
00027       lumis_.clear();
00028       set("RunLumi", false);
00029     }
00030 
00031     retInternal_ = getBitTemplate();
00032   }
00033   
00034   bool operator() ( edm::EventBase const & ev,  pat::strbitset & ret ) {
00035 
00036     if ( !ignoreCut("RunLumi") ) {
00037       bool goodLumi = false;
00038       for ( std::vector<edm::LuminosityBlockRange>::const_iterator lumisBegin = lumis_.begin(),
00039               lumisEnd = lumis_.end(), ilumi = lumisBegin;
00040             ilumi != lumisEnd; ++ilumi ) {
00041         if ( ev.id().run() >= ilumi->startRun() && ev.id().run() <= ilumi->endRun()  &&
00042              ev.id().luminosityBlock() >= ilumi->startLumi() && ev.id().luminosityBlock() <= ilumi->endLumi() )  {
00043           goodLumi = true;
00044           break;
00045         }
00046       }
00047       if ( goodLumi ) passCut(ret, "RunLumi" );
00048     } else {
00049       passCut(ret, "RunLumi");
00050     }
00051 
00052     setIgnored(ret);
00053     return (bool)ret;
00054   }
00055 
00056   using EventSelector::operator();
00057 
00058 private:
00059 
00060   std::vector<edm::LuminosityBlockRange> lumis_;
00061 
00062 };
00063 
00064 #endif