CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PickEvents Class Reference

#include <DPGAnalysis/PickEvents/src/PickEvents.cc>

Inheritance diagram for PickEvents:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PickEvents (const edm::ParameterSet &)
 
 ~PickEvents ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
virtual bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< edm::EventNumber_tendevent
 
std::vector< edm::RunNumber_tendrun
 
std::string listrunevents_
 
std::string listruneventsinpath_
 
int nEventsAnalyzed
 
int nEventsSelected
 
std::vector< edm::EventNumber_tstartevent
 
std::vector< edm::RunNumber_tstartrun
 
std::vector< bool > whattodo
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 46 of file PickEvents.cc.

Constructor & Destructor Documentation

PickEvents::PickEvents ( const edm::ParameterSet iConfig)
explicit

Definition at line 72 of file PickEvents.cc.

References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), listrunevents_, listruneventsinpath_, and AlCaHLTBitMon_QueryRunRegistry::string.

73 {
74 
75  listruneventsinpath_=iConfig.getUntrackedParameter<std::string> ("RunEventList","");
76  edm::FileInPath listruneventstmp("DPGAnalysis/Skims/data/"+listruneventsinpath_);
77 
78  listrunevents_=listruneventstmp.fullPath();
79 
80  std::cout <<"File with run/event list:"<< listrunevents_<<std::endl;
81 
82 }
T getUntrackedParameter(std::string const &, T const &) const
std::string listrunevents_
Definition: PickEvents.cc:56
std::string listruneventsinpath_
Definition: PickEvents.cc:57
tuple cout
Definition: gather_cfg.py:121
PickEvents::~PickEvents ( )

Definition at line 85 of file PickEvents.cc.

86 {
87 }

Member Function Documentation

void PickEvents::beginJob ( void  )
overrideprivatevirtual

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, AlCaHLTBitMon_QueryRunRegistry::string, and whattodo.

120 {
121  using namespace std;
122 
124  std::string buf;
125 
126  std::stringstream ss;
127  std::vector<std::string> tokens;
128 
129  nEventsAnalyzed = 0;
130  nEventsSelected = 0;
131 
132  // open file listevent file
133  std::ifstream listfile;
134  listfile.open(listrunevents_.c_str());
135  if (listfile.is_open())
136  {
137  while (! listfile.eof() )
138  {
139  getline (listfile,line);
140  ss.clear();
141  ss.str(line);
142  tokens.clear();
143  while (ss>>buf)
144  {
145  tokens.push_back(buf);
146  // std::cout << buf << std::endl;
147  }
148  // std::cout << tokens.size() << std::endl;
149  if (tokens.size()<3)
150  {
151  // std::cout << "strange selection line:" << line << std::endl;
152  // std::cout << "skipping it" << std::endl;
153  continue;
154  }
155  if(tokens[0]=="-" || tokens[0]=="+")
156  {
157  // it's a selection line, use it
158  if(tokens[0]=="-") whattodo.push_back(false);
159  else whattodo.push_back(true);
160 
161  // start with run selecion
162  int loc=tokens[1].find(":",0);
163 
164  std::string first=tokens[1].substr(0,loc);
165  startrun.push_back((edm::RunNumber_t)atoi(first.c_str()));
166 
167  std::string last=tokens[1].substr(loc+1,tokens[1].size());
168  if (last=="infty")
170  else
171  endrun.push_back((edm::RunNumber_t) atoi(last.c_str()));
172 
173  // then event number selecion
174  loc=tokens[2].find(":",0);
175 
176  first=tokens[2].substr(0,loc);
177  startevent.push_back((edm::EventNumber_t)atoi(first.c_str()));
178 
179  last=tokens[2].substr(loc+1,tokens[2].size());
180  if (last=="infty")
182  // endevent.push_back(std::numeric_limits<long long int>::max());
183  else
184  endevent.push_back((edm::EventNumber_t)atoi(last.c_str()));
185 
186  }
187  }
188  listfile.close();
189  // printout summary
190  std::cout << "Summary from list of run/event number selection" << std::endl;
191  for (unsigned int cond=0; cond<whattodo.size();cond++)
192  {
193  std::string what;
194  if(whattodo[cond]) what="select";
195  else what="reject";
196  std::cout << what << " ";
197  std::cout << "from run " << startrun[cond] << " to run " << endrun[cond] << " ";
198  std::cout << "from eve " << startevent[cond] << " to eve " << endevent[cond] << std::endl;
199  }
200  }
201 
202  else std::cout << "Unable to open file";
203 
204 }
std::string listrunevents_
Definition: PickEvents.cc:56
unsigned int EventNumber_t
Definition: EventID.h:30
int nEventsSelected
Definition: PickEvents.cc:66
const T & max(const T &a, const T &b)
std::vector< edm::RunNumber_t > startrun
Definition: PickEvents.cc:60
std::vector< edm::EventNumber_t > endevent
Definition: PickEvents.cc:63
bool first
Definition: L1TdeRCT.cc:79
std::vector< bool > whattodo
Definition: PickEvents.cc:59
std::vector< edm::EventNumber_t > startevent
Definition: PickEvents.cc:62
int nEventsAnalyzed
Definition: PickEvents.cc:65
static EventNumber_t maxEventNumber()
Definition: EventID.h:106
std::vector< edm::RunNumber_t > endrun
Definition: PickEvents.cc:61
tuple cout
Definition: gather_cfg.py:121
unsigned int RunNumber_t
Definition: EventRange.h:32
tuple size
Write out results.
void PickEvents::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 206 of file PickEvents.cc.

References gather_cfg::cout, nEventsAnalyzed, and nEventsSelected.

206  {
207  using namespace std;
208  std::cout << "================================================\n"
209  << " n Events Analyzed ............... " << nEventsAnalyzed << std::endl
210  << " n Events Selected ............... " << nEventsSelected<< std::endl
211  << "================================================\n\n" ;
212 }
int nEventsSelected
Definition: PickEvents.cc:66
int nEventsAnalyzed
Definition: PickEvents.cc:65
tuple cout
Definition: gather_cfg.py:121
bool PickEvents::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

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.

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

91 {
92  using namespace edm;
93 
94  RunNumber_t kRun = iEvent.id().run();
95  EventNumber_t kEvent = iEvent.id().event();
96 
97  bool selectThisEvent = false;
98 
99  for (unsigned int cond=0; cond<whattodo.size();cond++)
100  {
101  // std::string what;
102  if ( kRun>=startrun[cond] &&
103  kRun<=endrun[cond] &&
104  kEvent>=startevent[cond] &&
105  kEvent<=endevent[cond] )
106  { // it's in the range, use
107  selectThisEvent=whattodo[cond];
108  }
109  }
110 
111  nEventsAnalyzed++;
112  if (selectThisEvent) nEventsSelected++;
113  // if (selectThisEvent) std::cout << "Event selected: " << kRun << " " << kEvent << std::endl;
114 
115  return selectThisEvent;
116 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
unsigned int EventNumber_t
Definition: EventID.h:30
int nEventsSelected
Definition: PickEvents.cc:66
std::vector< edm::RunNumber_t > startrun
Definition: PickEvents.cc:60
std::vector< edm::EventNumber_t > endevent
Definition: PickEvents.cc:63
std::vector< bool > whattodo
Definition: PickEvents.cc:59
std::vector< edm::EventNumber_t > startevent
Definition: PickEvents.cc:62
int nEventsAnalyzed
Definition: PickEvents.cc:65
edm::EventID id() const
Definition: EventBase.h:56
std::vector< edm::RunNumber_t > endrun
Definition: PickEvents.cc:61
unsigned int RunNumber_t
Definition: EventRange.h:32

Member Data Documentation

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().