#include <DPGAnalysis/PickEvents/src/PickEvents.cc>
Public Member Functions | |
PickEvents (const edm::ParameterSet &) | |
~PickEvents () | |
Private Member Functions | |
virtual void | beginJob () |
virtual void | endJob () |
virtual bool | filter (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
std::vector< edm::EventNumber_t > | endevent |
std::vector< edm::RunNumber_t > | endrun |
std::string | listrunevents_ |
std::string | listruneventsinpath_ |
int | nEventsAnalyzed |
int | nEventsSelected |
std::vector< edm::EventNumber_t > | startevent |
std::vector< edm::RunNumber_t > | startrun |
std::vector< bool > | whattodo |
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 46 of file PickEvents.cc.
PickEvents::PickEvents | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 72 of file PickEvents.cc.
References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), listrunevents_, and listruneventsinpath_.
{ listruneventsinpath_=iConfig.getUntrackedParameter<std::string> ("RunEventList",""); edm::FileInPath listruneventstmp("DPGAnalysis/Skims/data/"+listruneventsinpath_); listrunevents_=listruneventstmp.fullPath(); std::cout <<"File with run/event list:"<< listrunevents_<<std::endl; }
PickEvents::~PickEvents | ( | ) |
Definition at line 85 of file PickEvents.cc.
{ }
void PickEvents::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDFilter.
Definition at line 119 of file PickEvents.cc.
References gather_cfg::cout, endevent, endrun, first, prof2calltree::last, geometryCSVtoXML::line, listrunevents_, max(), edm::EventID::maxEventNumber(), nEventsAnalyzed, nEventsSelected, findQualityFiles::size, startevent, startrun, and whattodo.
{ using namespace std; std::string line; std::string buf; std::stringstream ss; std::vector<std::string> tokens; nEventsAnalyzed = 0; nEventsSelected = 0; // open file listevent file ifstream listfile; listfile.open(listrunevents_.c_str()); if (listfile.is_open()) { while (! listfile.eof() ) { getline (listfile,line); ss.clear(); ss.str(line); tokens.clear(); while (ss>>buf) { tokens.push_back(buf); // std::cout << buf << std::endl; } // std::cout << tokens.size() << std::endl; if (tokens.size()<3) { // std::cout << "strange selection line:" << line << std::endl; // std::cout << "skipping it" << std::endl; continue; } if(tokens[0]=="-" || tokens[0]=="+") { // it's a selection line, use it if(tokens[0]=="-") whattodo.push_back(false); else whattodo.push_back(true); // start with run selecion int loc=tokens[1].find(":",0); std::string first=tokens[1].substr(0,loc); startrun.push_back((edm::RunNumber_t)atoi(first.c_str())); std::string last=tokens[1].substr(loc+1,tokens[1].size()); if (last=="infty") endrun.push_back(std::numeric_limits<unsigned int>::max()); else endrun.push_back((edm::RunNumber_t) atoi(last.c_str())); // then event number selecion loc=tokens[2].find(":",0); first=tokens[2].substr(0,loc); startevent.push_back((edm::EventNumber_t)atoi(first.c_str())); last=tokens[2].substr(loc+1,tokens[2].size()); if (last=="infty") endevent.push_back(edm::EventID::maxEventNumber()); // endevent.push_back(std::numeric_limits<long long int>::max()); else endevent.push_back((edm::EventNumber_t)atoi(last.c_str())); } } listfile.close(); // printout summary std::cout << "Summary from list of run/event number selection" << std::endl; for (unsigned int cond=0; cond<whattodo.size();cond++) { std::string what; if(whattodo[cond]) what="select"; else what="reject"; std::cout << what << " "; std::cout << "from run " << startrun[cond] << " to run " << endrun[cond] << " "; std::cout << "from eve " << startevent[cond] << " to eve " << endevent[cond] << std::endl; } } else std::cout << "Unable to open file"; }
void PickEvents::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDFilter.
Definition at line 206 of file PickEvents.cc.
References gather_cfg::cout, nEventsAnalyzed, and nEventsSelected.
{ using namespace std; std::cout << "================================================\n" << " n Events Analyzed ............... " << nEventsAnalyzed << std::endl << " n Events Selected ............... " << nEventsSelected<< std::endl << "================================================\n\n" ; }
bool PickEvents::filter | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDFilter.
Definition at line 90 of file PickEvents.cc.
References endevent, endrun, edm::EventID::event(), edm::EventBase::id(), ecaldqm::kRun, nEventsAnalyzed, nEventsSelected, edm::EventID::run(), startevent, startrun, and whattodo.
{ using namespace edm; RunNumber_t kRun = iEvent.id().run(); EventNumber_t kEvent = iEvent.id().event(); bool selectThisEvent = false; for (unsigned int cond=0; cond<whattodo.size();cond++) { // std::string what; if ( kRun>=startrun[cond] && kRun<=endrun[cond] && kEvent>=startevent[cond] && kEvent<=endevent[cond] ) { // it's in the range, use selectThisEvent=whattodo[cond]; } } nEventsAnalyzed++; if (selectThisEvent) nEventsSelected++; // if (selectThisEvent) std::cout << "Event selected: " << kRun << " " << kEvent << std::endl; return selectThisEvent; }
std::vector<edm::EventNumber_t> PickEvents::endevent [private] |
Definition at line 63 of file PickEvents.cc.
Referenced by beginJob(), and filter().
std::vector<edm::RunNumber_t> PickEvents::endrun [private] |
Definition at line 61 of file PickEvents.cc.
Referenced by beginJob(), and filter().
std::string PickEvents::listrunevents_ [private] |
Definition at line 56 of file PickEvents.cc.
Referenced by beginJob(), and PickEvents().
std::string PickEvents::listruneventsinpath_ [private] |
Definition at line 57 of file PickEvents.cc.
Referenced by PickEvents().
int PickEvents::nEventsAnalyzed [private] |
Definition at line 65 of file PickEvents.cc.
Referenced by beginJob(), endJob(), and filter().
int PickEvents::nEventsSelected [private] |
Definition at line 66 of file PickEvents.cc.
Referenced by beginJob(), endJob(), and filter().
std::vector<edm::EventNumber_t> PickEvents::startevent [private] |
Definition at line 62 of file PickEvents.cc.
Referenced by beginJob(), and filter().
std::vector<edm::RunNumber_t> PickEvents::startrun [private] |
Definition at line 60 of file PickEvents.cc.
Referenced by beginJob(), and filter().
std::vector<bool> PickEvents::whattodo [private] |
Definition at line 59 of file PickEvents.cc.
Referenced by beginJob(), and filter().