CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes
HcalLaserEventFilter2012 Class Reference

#include <UserCode/HcalLaserEventFilter2012/src/HcalLaserEventFilter2012.cc>

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

Public Member Functions

 HcalLaserEventFilter2012 (const edm::ParameterSet &)
 
 ~HcalLaserEventFilter2012 () 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- 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 ()
 

Public Attributes

friend HcalLaserEventFiltProducer2012
 

Private Types

typedef std::vector< std::string > strVec
 
typedef std::vector< std::string >::iterator strVecI
 

Private Member Functions

void addEventString (const std::string &eventString)
 
void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
void readEventListFile (const std::string &eventFileName)
 

Private Attributes

std::vector< std::string > EventList_
 
bool forceFilterTrue_
 
int maxrun_
 
int maxRunInFile
 
int minrun_
 
int minRunInFile
 
std::ofstream outfile_
 
std::string prefix_
 
bool verbose_
 
bool WriteBadToFile_
 

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
 
- 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: [Remove known HCAL laser events in 2012 data]

Implementation: [Notes on implementation]

Definition at line 41 of file HcalLaserEventFilter2012.h.

Member Typedef Documentation

typedef std::vector< std::string > HcalLaserEventFilter2012::strVec
private

Definition at line 58 of file HcalLaserEventFilter2012.h.

typedef std::vector< std::string >::iterator HcalLaserEventFilter2012::strVecI
private

Definition at line 59 of file HcalLaserEventFilter2012.h.

Constructor & Destructor Documentation

HcalLaserEventFilter2012::HcalLaserEventFilter2012 ( const edm::ParameterSet ps)
explicit

Definition at line 25 of file HcalLaserEventFilter2012.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), jetUpdater_cfi::sort, and AlCaHLTBitMon_QueryRunRegistry::string.

26 {
27  verbose_ = ps.getUntrackedParameter<bool>("verbose",false);
28  prefix_ = ps.getUntrackedParameter<std::string>("prefix","");
29  minrun_ = ps.getUntrackedParameter<int>("minrun",-1);
30  maxrun_ = ps.getUntrackedParameter<int>("maxrun",-1);
31  WriteBadToFile_=ps.getUntrackedParameter<bool>("WriteBadToFile",false);
32  if (WriteBadToFile_)
33  outfile_.open("badHcalLaserList_eventfilter.txt");
34  forceFilterTrue_=ps.getUntrackedParameter<bool>("forceFilterTrue",false);
35 
36  minRunInFile=999999; maxRunInFile=1;
37  string eventFileName0=ps.getParameter<string>("eventFileName");
38  string eventFileName = edm::FileInPath(eventFileName0).fullPath();
39 
40  if (verbose_) edm::LogInfo("HcalLaserEventFilter2012") << "HCAL laser event list from file "<<eventFileName;
41  readEventListFile(eventFileName);
42  std::sort(EventList_.begin(), EventList_.end());
43  if (verbose_) edm::LogInfo("HcalLaserEventFilter2012")<<" A total of "<<EventList_.size()<<" listed HCAL laser events found in given run range";
44  if (minrun_==-1 || minrun_<minRunInFile) minrun_=minRunInFile;
45  if (maxrun_==-1 || maxrun_>maxRunInFile) maxrun_=maxRunInFile;
46 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > EventList_
std::string fullPath() const
Definition: FileInPath.cc:163
void readEventListFile(const std::string &eventFileName)
HcalLaserEventFilter2012::~HcalLaserEventFilter2012 ( )
override

Definition at line 152 of file HcalLaserEventFilter2012.cc.

153 {
154 
155  // do anything here that needs to be done at desctruction time
156  // (e.g. close files, deallocate resources etc.)
157 
158 }

Member Function Documentation

void HcalLaserEventFilter2012::addEventString ( const std::string &  eventString)
private

Some event numbers are less than 0? -v1:201278:2145:-2130281065 – due to events being dumped out as ints, not uints!

Some event numbers are less than 0? -v1:201278:2145:-2130281065

Definition at line 48 of file HcalLaserEventFilter2012.cc.

References runEdmFileComparison::found, eostools::ls(), and writedatasetfile::run.

49 {
50  // Loop through list of bad events, and if run is in allowed range, add bad event to EventList
51  int run=0;
52  unsigned int ls=0;
53  unsigned int event=0;
54  // Check that event list object is in correct form
55  size_t found = eventString.find(":"); // find first colon
56  if (found!=std::string::npos)
57  run=atoi((eventString.substr(0,found)).c_str()); // convert to run
58  else
59  {
60  edm::LogError("HcalLaserEventFilter2012")<<" Unable to parse Event list input '"<<eventString<<"' for run number!";
61  return;
62  }
63  size_t found2 = eventString.find(":",found+1); // find second colon
64  if (found2!=std::string::npos)
65  {
67  ls=atoi((eventString.substr(found+1,(found2-found-1))).c_str()); // convert to ls
68  event=atoi((eventString.substr(found2+1)).c_str()); // convert to event
70  if (ls==0 || event==0) edm::LogWarning("HcalLaserEventFilter2012")<<" Strange lumi, event numbers for input '"<<eventString<<"'";
71  }
72  else
73  {
74  edm::LogError("HcalLaserEventFilter2012")<<"Unable to parse Event list input '"<<eventString<<"' for run number!";
75  return;
76  }
77  // If necessary, check that run is within allowed range
78  if (minrun_>-1 && run<minrun_)
79  {
80  if (verbose_) edm::LogInfo("HcalLaserEventFilter2012") <<"Skipping Event list input '"<<eventString<<"' because it is less than minimum run # "<<minrun_;
81  return;
82  }
83  if (maxrun_>-1 && run>maxrun_)
84  {
85  if (verbose_) edm::LogInfo("HcalLaserEventFilter2012") <<"Skipping Event list input '"<<eventString<<"' because it is greater than maximum run # "<<maxrun_;
86  return;
87  }
88  if (minRunInFile>run) minRunInFile=run;
89  if (maxRunInFile<run) maxRunInFile=run;
90  // Now add event to Event List
91  EventList_.push_back(eventString);
92 }
std::vector< std::string > EventList_
def ls(path, rec=False)
Definition: eostools.py:349
Definition: event.py:1
void HcalLaserEventFilter2012::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 198 of file HcalLaserEventFilter2012.cc.

198  {
199  if (WriteBadToFile_) outfile_.close();
200 }
void HcalLaserEventFilter2012::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 204 of file HcalLaserEventFilter2012.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

204  {
205  //The following says we do not know what parameters are allowed so do no validation
206  // Please change this to state exactly what you do use, even if it is no parameters
208  desc.setUnknown();
209  descriptions.addDefault(desc);
210 }
void addDefault(ParameterSetDescription const &psetDescription)
bool HcalLaserEventFilter2012::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 167 of file HcalLaserEventFilter2012.cc.

References gather_cfg::cout, edm::EventID::event(), edm::EventBase::id(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, edm::EventBase::luminosityBlock(), writedatasetfile::run, and edm::EventID::run().

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

168 {
169  int run = iEvent.id().run();
170  // if run is outside filter range, then always return true
171  if (minrun_>-1 && run<minrun_) return true;
172  if (maxrun_>-1 && run>maxrun_) return true;
173 
174  // Okay, now create a string object for this run:ls:event
175  std::stringstream thisevent;
176  thisevent<<run<<":"<<iEvent.luminosityBlock()<<":"<<iEvent.id().event();
177 
178  // Event not found in bad list; it is a good event
179  strVecI it = std::lower_bound(EventList_.begin(), EventList_.end(), thisevent.str());
180  if (it == EventList_.end() || thisevent.str() < *it) return true;
181  // Otherwise, this is a bad event
182  // if verbose, dump out event info
183  // Dump out via cout, or via LogInfo? For now, use cout
184  if (verbose_) std::cout <<prefix_<<thisevent.str()<<std::endl;
185 
186  // To use if we decide on LogInfo:
187  // if (verbose_) edm::LogInfo(prefix_)<<thisevent.str();
188 
189  // Write bad event to file
190  if (WriteBadToFile_)
191  outfile_<<iEvent.id().run()<<":"<<iEvent.luminosityBlock()<<":"<<iEvent.id().event()<<std::endl;
192  if (forceFilterTrue_) return true; // if special input boolean set, always return true, regardless of filter decision
193  return false;
194 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
std::vector< std::string > EventList_
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
edm::EventID id() const
Definition: EventBase.h:59
std::vector< std::string >::iterator strVecI
void HcalLaserEventFilter2012::readEventListFile ( const std::string &  eventFileName)
private

Definition at line 96 of file HcalLaserEventFilter2012.cc.

References edmScanValgrind::buffer, FrontierConditions_GlobalTag_cff::file, mps_fire::i, and LENGTH.

97 {
98  gzFile file = gzopen (eventFileName.c_str(), "r");
99  if (! file) {
100  edm::LogError("HcalLaserEventFilter2012")<<" Unable to open event list file "<<eventFileName;
101  return;
102  }
103  string b2;
104  int err;
105  int bytes_read;
106  char buffer[LENGTH];
107  unsigned int i;
108  char * pch;
109 
110  while (true) {
111  bytes_read = gzread (file, buffer, LENGTH - 1);
112  buffer[bytes_read] = '\0';
113  i=0;
114  char* saveptr;
115  pch = strtok_r (buffer,"\n",&saveptr);
116  if (buffer[0] == '\n' ) {
117  addEventString(b2);
118  ++i;
119  } else b2+=pch;
120 
121  while (pch != nullptr)
122  {
123  i+=strlen(pch)+1;
124  if (i>b2.size()) b2= pch;
125  if (i==(LENGTH-1)) {
126  if ((buffer[LENGTH-2] == '\n' )|| (buffer[LENGTH-2] == '\0' )){
127  addEventString(b2);
128  b2="";
129  }
130  } else if (i<LENGTH) {
131  addEventString(b2);
132  }
133  pch = strtok_r (nullptr, "\n", &saveptr);
134  }
135  if (bytes_read < LENGTH - 1) {
136  if (gzeof (file)) break;
137  else {
138  const char * error_string;
139  error_string = gzerror (file, & err);
140  if (err) {
141  edm::LogError("HcalLaserEventFilter2012")<<"Error while reading gzipped file: "<<error_string;
142  return;
143  }
144  }
145  }
146  }
147  gzclose (file);
148  return;
149 }
#define LENGTH
void addEventString(const std::string &eventString)

Member Data Documentation

std::vector< std::string > HcalLaserEventFilter2012::EventList_
private

Definition at line 61 of file HcalLaserEventFilter2012.h.

bool HcalLaserEventFilter2012::forceFilterTrue_
private

Definition at line 72 of file HcalLaserEventFilter2012.h.

friend HcalLaserEventFilter2012::HcalLaserEventFiltProducer2012

Definition at line 48 of file HcalLaserEventFilter2012.h.

int HcalLaserEventFilter2012::maxrun_
private

Definition at line 68 of file HcalLaserEventFilter2012.h.

int HcalLaserEventFilter2012::maxRunInFile
private

Definition at line 69 of file HcalLaserEventFilter2012.h.

int HcalLaserEventFilter2012::minrun_
private

Definition at line 67 of file HcalLaserEventFilter2012.h.

int HcalLaserEventFilter2012::minRunInFile
private

Definition at line 69 of file HcalLaserEventFilter2012.h.

std::ofstream HcalLaserEventFilter2012::outfile_
private

Definition at line 73 of file HcalLaserEventFilter2012.h.

std::string HcalLaserEventFilter2012::prefix_
private

Definition at line 63 of file HcalLaserEventFilter2012.h.

bool HcalLaserEventFilter2012::verbose_
private

Definition at line 62 of file HcalLaserEventFilter2012.h.

bool HcalLaserEventFilter2012::WriteBadToFile_
private

Definition at line 71 of file HcalLaserEventFilter2012.h.