CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 &)
 

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)
 
virtual void endJob () override
 
virtual 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
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 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(), python.multivaluedict::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:165
void readEventListFile(const std::string &eventFileName)
HcalLaserEventFilter2012::~HcalLaserEventFilter2012 ( )

Definition at line 151 of file HcalLaserEventFilter2012.cc.

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

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 event(), newFWLiteAna::found, eostools::ls(), and DTTTrigCorrFirst::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
Definition: eostools.py:348
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void HcalLaserEventFilter2012::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 197 of file HcalLaserEventFilter2012.cc.

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

Definition at line 203 of file HcalLaserEventFilter2012.cc.

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

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

Implements edm::EDFilter.

Definition at line 166 of file HcalLaserEventFilter2012.cc.

References gather_cfg::cout, edm::EventID::event(), edm::EventBase::id(), edm::EventBase::luminosityBlock(), edm::EventID::run(), and DTTTrigCorrFirst::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().

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

Definition at line 96 of file HcalLaserEventFilter2012.cc.

References mergeVDriftHistosByStation::file, i, LENGTH, and NULL.

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 (1) {
111  bytes_read = gzread (file, buffer, LENGTH - 1);
112  buffer[bytes_read] = '\0';
113  i=0;
114  pch = strtok (buffer,"\n");
115  if (buffer[0] == '\n' ) {
116  addEventString(b2);
117  ++i;
118  } else b2+=pch;
119 
120  while (pch != NULL)
121  {
122  i+=strlen(pch)+1;
123  if (i>b2.size()) b2= pch;
124  if (i==(LENGTH-1)) {
125  if ((buffer[LENGTH-2] == '\n' )|| (buffer[LENGTH-2] == '\0' )){
126  addEventString(b2);
127  b2="";
128  }
129  } else if (i<LENGTH) {
130  addEventString(b2);
131  }
132  pch = strtok (NULL, "\n");
133  }
134  if (bytes_read < LENGTH - 1) {
135  if (gzeof (file)) break;
136  else {
137  const char * error_string;
138  error_string = gzerror (file, & err);
139  if (err) {
140  edm::LogError("HcalLaserEventFilter2012")<<"Error while reading gzipped file: "<<error_string;
141  return;
142  }
143  }
144  }
145  }
146  gzclose (file);
147  return;
148 }
int i
Definition: DBlmapReader.cc:9
#define NULL
Definition: scimark2.h:8
#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.