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
 
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)
 
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::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 55 of file PickEvents.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file PickEvents.cc.

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

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

Definition at line 107 of file PickEvents.cc.

108 {
109 }

Member Function Documentation

void PickEvents::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 176 of file PickEvents.cc.

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

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

Reimplemented from edm::EDFilter.

Definition at line 275 of file PickEvents.cc.

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

275  {
276  using namespace std;
277  std::cout << "================================================\n"
278  << " n Events Analyzed ............... " << nEventsAnalyzed << std::endl
279  << " n Events Selected ............... " << nEventsSelected<< std::endl
280  << "================================================\n\n" ;
281 }
int nEventsSelected
Definition: PickEvents.cc:78
int nEventsAnalyzed
Definition: PickEvents.cc:77
bool PickEvents::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 112 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().

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

Member Data Documentation

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

Definition at line 75 of file PickEvents.cc.

Referenced by beginJob(), and filter().

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

Definition at line 73 of file PickEvents.cc.

Referenced by beginJob(), and filter().

bool PickEvents::isRunLsBased_
private

Definition at line 67 of file PickEvents.cc.

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

std::string PickEvents::listrunevents_
private

Definition at line 65 of file PickEvents.cc.

Referenced by beginJob(), and PickEvents().

std::string PickEvents::listruneventsinpath_
private

Definition at line 66 of file PickEvents.cc.

Referenced by PickEvents().

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

Definition at line 68 of file PickEvents.cc.

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

int PickEvents::nEventsAnalyzed
private

Definition at line 77 of file PickEvents.cc.

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

int PickEvents::nEventsSelected
private

Definition at line 78 of file PickEvents.cc.

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

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

Definition at line 74 of file PickEvents.cc.

Referenced by beginJob(), and filter().

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

Definition at line 72 of file PickEvents.cc.

Referenced by beginJob(), and filter().

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

Definition at line 71 of file PickEvents.cc.

Referenced by beginJob(), and filter().