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::one::EDFilter<> edm::one::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PickEvents (const edm::ParameterSet &)
 
 ~PickEvents () override
 
- Public Member Functions inherited from edm::one::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDFilterBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDFilterBase
typedef EDFilterBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::one::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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

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

Definition at line 54 of file PickEvents.cc.

Constructor & Destructor Documentation

◆ PickEvents()

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

Definition at line 79 of file PickEvents.cc.

References cms::cuda::assert(), 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
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
Definition: ParameterSet.h:307
std::string listrunevents_
Definition: PickEvents.cc:64
bool isRunLsBased_
Definition: PickEvents.cc:66
assert(be >=bs)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::LuminosityBlockRange > luminositySectionsBlockRanges_
Definition: PickEvents.cc:67
std::string listruneventsinpath_
Definition: PickEvents.cc:65

◆ ~PickEvents()

PickEvents::~PickEvents ( )
override

Definition at line 105 of file PickEvents.cc.

105 {}

Member Function Documentation

◆ beginJob()

void PickEvents::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDFilterBase.

Definition at line 164 of file PickEvents.cc.

References visDQMUpload::buf, 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, jetUpdater_cfi::sort, contentValuesCheck::ss, startevent, startrun, AlCaHLTBitMon_QueryRunRegistry::string, and whattodo.

164  {
165  using namespace std;
166 
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
std::vector< edm::RunNumber_t > endrun
Definition: PickEvents.cc:71
unsigned int RunNumber_t

◆ endJob()

void PickEvents::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDFilterBase.

Definition at line 255 of file PickEvents.cc.

References gather_cfg::cout, 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

◆ filter()

bool PickEvents::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDFilterBase.

Definition at line 107 of file PickEvents.cc.

References endevent, endrun, iEvent, isRunLsBased_, luminositySectionsBlockRanges_, nEventsAnalyzed, nEventsSelected, startevent, startrun, and whattodo.

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 }
unsigned long long EventNumber_t
bool isRunLsBased_
Definition: PickEvents.cc:66
unsigned int LuminosityBlockNumber_t
int nEventsSelected
Definition: PickEvents.cc:76
std::vector< edm::LuminosityBlockRange > luminositySectionsBlockRanges_
Definition: PickEvents.cc:67
int iEvent
Definition: GenABIO.cc:224
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
HLT enums.
std::vector< edm::RunNumber_t > endrun
Definition: PickEvents.cc:71
unsigned int RunNumber_t

Member Data Documentation

◆ endevent

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

Definition at line 73 of file PickEvents.cc.

Referenced by beginJob(), and filter().

◆ endrun

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

Definition at line 71 of file PickEvents.cc.

Referenced by beginJob(), and filter().

◆ isRunLsBased_

bool PickEvents::isRunLsBased_
private

Definition at line 66 of file PickEvents.cc.

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

◆ listrunevents_

std::string PickEvents::listrunevents_
private

Definition at line 64 of file PickEvents.cc.

Referenced by beginJob(), and PickEvents().

◆ listruneventsinpath_

std::string PickEvents::listruneventsinpath_
private

Definition at line 65 of file PickEvents.cc.

Referenced by PickEvents().

◆ luminositySectionsBlockRanges_

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

Definition at line 67 of file PickEvents.cc.

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

◆ nEventsAnalyzed

int PickEvents::nEventsAnalyzed
private

Definition at line 75 of file PickEvents.cc.

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

◆ nEventsSelected

int PickEvents::nEventsSelected
private

Definition at line 76 of file PickEvents.cc.

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

◆ startevent

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

Definition at line 72 of file PickEvents.cc.

Referenced by beginJob(), and filter().

◆ startrun

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

Definition at line 70 of file PickEvents.cc.

Referenced by beginJob(), and filter().

◆ whattodo

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

Definition at line 69 of file PickEvents.cc.

Referenced by beginJob(), and filter().