CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

std::vector< edm::EventNumber_tendevent
 
std::vector< edm::RunNumber_tendrun
 
bool isRunLsBased_
 
std::string listrunevents_
 
std::string listruneventsinpath_
 
std::vector< edm::LuminosityBlockRangeluminositySectionsBlockRanges_
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 54 of file PickEvents.cc.

Constructor & Destructor Documentation

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

Definition at line 79 of file PickEvents.cc.

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

79  {
80  isRunLsBased_ = iConfig.getParameter<bool>("IsRunLsBased");
82  iConfig.getUntrackedParameter<std::vector<edm::LuminosityBlockRange> >("LuminositySectionsBlockRange");
83 
84  listruneventsinpath_ = iConfig.getUntrackedParameter<std::string>("RunEventList", "");
85  edm::FileInPath listruneventstmp(listruneventsinpath_);
86  listrunevents_ = listruneventstmp.fullPath();
87 
88  // sanity checks
89  if (isRunLsBased_ && luminositySectionsBlockRanges_.empty()) {
90  assert("ERROR: selection based on run/Lumisection from json file, but LuminositySectionsBlockRange is emptpy." ==
91  nullptr);
92  }
93  if ((!isRunLsBased_) && !luminositySectionsBlockRanges_.empty()) {
94  assert("ERROR: selection based on run/event from txt file, but LuminositySectionsBlockRange is not emptpy." ==
95  nullptr);
96  }
97 
98  if (isRunLsBased_) {
99  std::cout << "Selection based on run/luminositySection; file with run/event list: " << std::endl;
100  } else {
101  std::cout << "Selection based on run/event; file with run/event list: " << listrunevents_ << std::endl;
102  }
103 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string listrunevents_
Definition: PickEvents.cc:64
bool isRunLsBased_
Definition: PickEvents.cc:66
std::vector< edm::LuminosityBlockRange > luminositySectionsBlockRanges_
Definition: PickEvents.cc:67
std::string listruneventsinpath_
Definition: PickEvents.cc:65
PickEvents::~PickEvents ( )
override

Definition at line 105 of file PickEvents.cc.

105 {}

Member Function Documentation

void PickEvents::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 164 of file PickEvents.cc.

References gather_cfg::cout, endevent, endrun, dqmdumpme::first, isRunLsBased_, dqmdumpme::last, mps_splice::line, listrunevents_, luminositySectionsBlockRanges_, SiStripPI::max, edm::EventID::maxEventNumber(), nEventsAnalyzed, nEventsSelected, orderLuminosityBlockRange(), findQualityFiles::size, contentValuesCheck::ss, startevent, startrun, AlCaHLTBitMon_QueryRunRegistry::string, and whattodo.

164  {
165  using namespace std;
166 
168  std::string buf;
169 
170  std::stringstream ss;
171  std::vector<std::string> tokens;
172 
173  nEventsAnalyzed = 0;
174  nEventsSelected = 0;
175 
176  if (isRunLsBased_) {
177  // sorting luminositySectionsBlockRanges_ according to the starting run of the block allows the speedup the search by an average factor 2
179  } // if isRunLsBased_
180 
181  else { // !isRunLsBased_
182 
183  // open file listevent file
184  std::ifstream listfile;
185  listfile.open(listrunevents_.c_str());
186  if (listfile.is_open()) {
187  while (!listfile.eof()) {
188  getline(listfile, line);
189  ss.clear();
190  ss.str(line);
191  tokens.clear();
192  while (ss >> buf) {
193  tokens.push_back(buf);
194  // std::cout << buf << std::endl;
195  }
196  // std::cout << tokens.size() << std::endl;
197  if (tokens.size() < 3) {
198  // std::cout << "strange selection line:" << line << std::endl;
199  // std::cout << "skipping it" << std::endl;
200  continue;
201  }
202  if (tokens[0] == "-" || tokens[0] == "+") {
203  // it's a selection line, use it
204  if (tokens[0] == "-")
205  whattodo.push_back(false);
206  else
207  whattodo.push_back(true);
208 
209  // start with run selecion
210  int loc = tokens[1].find(":", 0);
211 
212  std::string first = tokens[1].substr(0, loc);
213  startrun.push_back((edm::RunNumber_t)atoi(first.c_str()));
214 
215  std::string last = tokens[1].substr(loc + 1, tokens[1].size());
216  if (last == "infty")
218  else
219  endrun.push_back((edm::RunNumber_t)atoi(last.c_str()));
220 
221  // then event number selecion
222  loc = tokens[2].find(":", 0);
223 
224  first = tokens[2].substr(0, loc);
225  startevent.push_back((edm::EventNumber_t)atoi(first.c_str()));
226 
227  last = tokens[2].substr(loc + 1, tokens[2].size());
228  if (last == "infty")
230  // endevent.push_back(std::numeric_limits<long long int>::max());
231  else
232  endevent.push_back((edm::EventNumber_t)atoi(last.c_str()));
233  }
234  }
235  listfile.close();
236  // printout summary
237  std::cout << "Summary from list of run/event number selection" << std::endl;
238  for (unsigned int cond = 0; cond < whattodo.size(); cond++) {
239  std::string what;
240  if (whattodo[cond])
241  what = "select";
242  else
243  what = "reject";
244  std::cout << what << " ";
245  std::cout << "from run " << startrun[cond] << " to run " << endrun[cond] << " ";
246  std::cout << "from eve " << startevent[cond] << " to eve " << endevent[cond] << std::endl;
247  }
248  }
249 
250  else
251  std::cout << "Unable to open file";
252 
253  } // !isRunLsBased_
254 }
size
Write out results.
std::string listrunevents_
Definition: PickEvents.cc:64
unsigned long long EventNumber_t
bool isRunLsBased_
Definition: PickEvents.cc:66
int nEventsSelected
Definition: PickEvents.cc:76
std::vector< edm::LuminosityBlockRange > luminositySectionsBlockRanges_
Definition: PickEvents.cc:67
std::vector< edm::RunNumber_t > startrun
Definition: PickEvents.cc:70
std::vector< edm::EventNumber_t > endevent
Definition: PickEvents.cc:73
bool orderLuminosityBlockRange(edm::LuminosityBlockRange u, edm::LuminosityBlockRange v)
Definition: PickEvents.cc:46
std::vector< bool > whattodo
Definition: PickEvents.cc:69
std::vector< edm::EventNumber_t > startevent
Definition: PickEvents.cc:72
int nEventsAnalyzed
Definition: PickEvents.cc:75
static EventNumber_t maxEventNumber()
Definition: EventID.h:96
Definition: plugin.cc:23
std::vector< edm::RunNumber_t > endrun
Definition: PickEvents.cc:71
unsigned int RunNumber_t
void PickEvents::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 255 of file PickEvents.cc.

References gather_cfg::cout, DEFINE_FWK_MODULE, nEventsAnalyzed, and nEventsSelected.

255  {
256  using namespace std;
257  std::cout << "================================================\n"
258  << " n Events Analyzed ............... " << nEventsAnalyzed << std::endl
259  << " n Events Selected ............... " << nEventsSelected << std::endl
260  << "================================================\n\n";
261 }
int nEventsSelected
Definition: PickEvents.cc:76
int nEventsAnalyzed
Definition: PickEvents.cc:75
bool PickEvents::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 107 of file PickEvents.cc.

References endevent, endrun, edm::EventID::event(), edm::EventBase::id(), isRunLsBased_, edm::EventID::luminosityBlock(), luminositySectionsBlockRanges_, 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().

107  {
108  using namespace edm;
109 
110  RunNumber_t kRun = iEvent.id().run();
111  EventNumber_t kEvent = iEvent.id().event();
112  LuminosityBlockNumber_t kLumi = iEvent.id().luminosityBlock();
113 
114  bool selectThisEvent = false;
115 
116  // two alternative definition of the filter selection are possible, according to isRunLsBased_
117 
118  if (isRunLsBased_) {
119  // std::cout << "GF DEBUG: kRun is " << kRun << " kLumi is: " << kLumi << std::endl;
120 
121  for (std::vector<edm::LuminosityBlockRange>::iterator oneLumiRange = luminositySectionsBlockRanges_.begin();
122  oneLumiRange != luminositySectionsBlockRanges_.end();
123  ++oneLumiRange) {
124  // luminositySectionsBlockRanges_ is sorted according to startRun()
125  // => if kRun below it, you can stop the loop and return false
126  if (kRun < (*oneLumiRange).startRun()) {
127  // std::cout << "GF DEBUG: LS has NOT PASSED (early bail-out) ! ***" << std::endl;
128  break;
129  }
130 
131  // if endRun() below kRun, go to the next iteration
132  if ((*oneLumiRange).endRun() < kRun)
133  continue;
134 
135  // if the run number and lumi section match => exit from the loop
136  if ((*oneLumiRange).startLumi() <= kLumi && kLumi <= (*oneLumiRange).endLumi()) {
137  selectThisEvent = true;
138  // std::cout << "GF DEBUG: LS HAS PASSED ! ***" << std::endl;
139  break;
140  }
141  }
142 
143  } // end of isRunLsBased_
144  else { // !isRunLsBased_
145 
146  for (unsigned int cond = 0; cond < whattodo.size(); cond++) {
147  // std::string what;
148  if (kRun >= startrun[cond] && kRun <= endrun[cond] && kEvent >= startevent[cond] &&
149  kEvent <= endevent[cond]) { // it's in the range, use
150  selectThisEvent = whattodo[cond];
151  }
152  } // loop on whattodo
153 
154  } // !isRunLsBased_
155 
156  nEventsAnalyzed++;
157  if (selectThisEvent)
158  nEventsSelected++;
159  // if (selectThisEvent) std::cout << "Event selected: " << kRun << " " << kEvent << std::endl;
160 
161  return selectThisEvent;
162 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
unsigned long long EventNumber_t
bool isRunLsBased_
Definition: PickEvents.cc:66
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
unsigned int LuminosityBlockNumber_t
int nEventsSelected
Definition: PickEvents.cc:76
std::vector< edm::LuminosityBlockRange > luminositySectionsBlockRanges_
Definition: PickEvents.cc:67
std::vector< edm::RunNumber_t > startrun
Definition: PickEvents.cc:70
std::vector< edm::EventNumber_t > endevent
Definition: PickEvents.cc:73
std::vector< bool > whattodo
Definition: PickEvents.cc:69
std::vector< edm::EventNumber_t > startevent
Definition: PickEvents.cc:72
int nEventsAnalyzed
Definition: PickEvents.cc:75
edm::EventID id() const
Definition: EventBase.h:59
Definition: plugin.cc:23
HLT enums.
std::vector< edm::RunNumber_t > endrun
Definition: PickEvents.cc:71
unsigned int RunNumber_t

Member Data Documentation

std::vector<edm::EventNumber_t> PickEvents::endevent
private

Definition at line 73 of file PickEvents.cc.

Referenced by beginJob(), and filter().

std::vector<edm::RunNumber_t> PickEvents::endrun
private

Definition at line 71 of file PickEvents.cc.

Referenced by beginJob(), and filter().

bool PickEvents::isRunLsBased_
private

Definition at line 66 of file PickEvents.cc.

Referenced by beginJob(), filter(), and PickEvents().

std::string PickEvents::listrunevents_
private

Definition at line 64 of file PickEvents.cc.

Referenced by beginJob(), and PickEvents().

std::string PickEvents::listruneventsinpath_
private

Definition at line 65 of file PickEvents.cc.

Referenced by PickEvents().

std::vector<edm::LuminosityBlockRange> PickEvents::luminositySectionsBlockRanges_
private

Definition at line 67 of file PickEvents.cc.

Referenced by beginJob(), filter(), and PickEvents().

int PickEvents::nEventsAnalyzed
private

Definition at line 75 of file PickEvents.cc.

Referenced by beginJob(), endJob(), and filter().

int PickEvents::nEventsSelected
private

Definition at line 76 of file PickEvents.cc.

Referenced by beginJob(), endJob(), and filter().

std::vector<edm::EventNumber_t> PickEvents::startevent
private

Definition at line 72 of file PickEvents.cc.

Referenced by beginJob(), and filter().

std::vector<edm::RunNumber_t> PickEvents::startrun
private

Definition at line 70 of file PickEvents.cc.

Referenced by beginJob(), and filter().

std::vector<bool> PickEvents::whattodo
private

Definition at line 69 of file PickEvents.cc.

Referenced by beginJob(), and filter().