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 | Private Member Functions | Private Attributes
HcalLaserEventFilter Class Reference

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

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

Public Member Functions

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

Private Member Functions

virtual void beginJob () override
 
virtual void endJob () override
 
virtual bool filter (edm::Event &, const edm::EventSetup &) override
 
std::vector< int > GetCMSSWVersion (std::string const &)
 
bool IsGreaterThanMinCMSSWVersion (std::vector< int > const &)
 

Private Attributes

const bool debug_
 
int errorcount
 
bool forceUseHcalNoiseSummary_
 
bool forceUseRecHitCollection_
 
const edm::InputTag hbheInputLabel_
 
edm::EDGetTokenT
< HBHERecHitCollection
hbheToken_
 
const edm::InputTag hcalNoiseSummaryLabel_
 
edm::EDGetTokenT
< HcalNoiseSummary
hcalNoiseSummaryToken_
 
int maxerrormessage_
 
const unsigned int minOccupiedHBHE_
 
std::vector< int > minVersion_
 
const bool reverseFilter_
 
std::vector< std::pair
< edm::RunNumber_t,
edm::EventNumber_t > > 
RunEventData_
 
const bool taggingMode_
 
bool useHcalNoiseSummary_
 
const bool vetoByHBHEOccupancy_
 
const bool vetoByRunEventNumber_
 

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: Filter for removing Hcal laser events

Implementation: Filter allows users to remove specific (run,event) pairs that have been identified as noise It also allows users to remove events in which the number of HBHE rechits exceeds a given threshold (5000 by default).

Definition at line 49 of file HcalLaserEventFilter.cc.

Constructor & Destructor Documentation

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

Definition at line 111 of file HcalLaserEventFilter.cc.

References errorcount, edm::ParameterSet::getUntrackedParameter(), i, DTTTrigCorrFirst::run, and RunEventData_.

114  : vetoByRunEventNumber_ (iConfig.getUntrackedParameter<bool>("vetoByRunEventNumber",true))
115  , vetoByHBHEOccupancy_ (iConfig.getUntrackedParameter<bool>("vetoByHBHEOccupancy",false))
116  , minOccupiedHBHE_ (iConfig.getUntrackedParameter<unsigned int>("minOccupiedHBHE",5000))
117  , debug_ (iConfig.getUntrackedParameter<bool>("debug",false))
118  , reverseFilter_ (iConfig.getUntrackedParameter<bool>("reverseFilter",false))
119  , hbheInputLabel_ (iConfig.getUntrackedParameter<edm::InputTag>("hbheInputLabel",edm::InputTag("hbhereco")))
120  , hbheToken_ (mayConsume<HBHERecHitCollection>(hbheInputLabel_))
121 
122  , hcalNoiseSummaryLabel_ (iConfig.getUntrackedParameter<edm::InputTag>("hcalNoiseSummaryLabel",edm::InputTag("hcalnoise")))
123  , hcalNoiseSummaryToken_ (mayConsume<HcalNoiseSummary>(hcalNoiseSummaryLabel_))
124  , taggingMode_ (iConfig.getParameter<bool>("taggingMode"))
125  , maxerrormessage_ (iConfig.getUntrackedParameter<int>("maxerrormessage",1))
126  , forceUseRecHitCollection_ (iConfig.getUntrackedParameter<bool>("forceUseRecHitCollection",false))
127  , forceUseHcalNoiseSummary_ (iConfig.getUntrackedParameter<bool>("forceUseHcalNoiseSummary",false))
128 
129 {
130  std::vector<unsigned int> dummy; // dummy empty vector
131  dummy.clear();
132 
133  std::vector<unsigned int> temprunevt = iConfig.getUntrackedParameter<std::vector<unsigned int> >("BadRunEventNumbers",dummy);
134 
135  // Make (run,evt) pairs for storing bad events
136  // Make this a map for better search performance?
137  for (unsigned int i=0;i+1<temprunevt.size();i+=2)
138  {
139  edm::RunNumber_t run=temprunevt[i];
140  edm::EventNumber_t evt=temprunevt[i+1];
141  RunEventData_.push_back(std::make_pair(run,evt));
142  }
143  errorcount=0;
144  produces<bool>();
145 }
edm::EDGetTokenT< HBHERecHitCollection > hbheToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< HcalNoiseSummary > hcalNoiseSummaryToken_
const edm::InputTag hcalNoiseSummaryLabel_
const edm::InputTag hbheInputLabel_
unsigned long long EventNumber_t
std::vector< std::pair< edm::RunNumber_t, edm::EventNumber_t > > RunEventData_
const unsigned int minOccupiedHBHE_
unsigned int RunNumber_t
HcalLaserEventFilter::~HcalLaserEventFilter ( )

Definition at line 148 of file HcalLaserEventFilter.cc.

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

Member Function Documentation

void HcalLaserEventFilter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 258 of file HcalLaserEventFilter.cc.

References GetCMSSWVersion(), edm::getReleaseVersion(), IsGreaterThanMinCMSSWVersion(), minVersion_, AlCaHLTBitMon_QueryRunRegistry::string, and useHcalNoiseSummary_.

259 {
260  // Specify the minimum release that has the rechit counts in the HcalNoiseSummary object.
261  // If current release >= that release, then HcalNoiseSummary will be used. Otherwise, Rechit collection will be used.
262  std::string minRelease="\"CMSSW_5_2_0\"";
263 
264  minVersion_=GetCMSSWVersion(minRelease);
265  std::vector <int> currentVersion=GetCMSSWVersion(edm::getReleaseVersion());
266 
267  if (IsGreaterThanMinCMSSWVersion(currentVersion)) // current Version is >= minVersion_
269  else
270  useHcalNoiseSummary_=false;
271 }
std::vector< int > GetCMSSWVersion(std::string const &)
std::string getReleaseVersion()
std::vector< int > minVersion_
bool IsGreaterThanMinCMSSWVersion(std::vector< int > const &)
void HcalLaserEventFilter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 275 of file HcalLaserEventFilter.cc.

275  {
276 }
void HcalLaserEventFilter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 280 of file HcalLaserEventFilter.cc.

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

280  {
281  //The following says we do not know what parameters are allowed so do no validation
282  // Please change this to state exactly what you do use, even if it is no parameters
284  desc.setUnknown();
285  descriptions.addDefault(desc);
286 }
void addDefault(ParameterSetDescription const &psetDescription)
bool HcalLaserEventFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 163 of file HcalLaserEventFilter.cc.

References gather_cfg::cout, debug_, errorcount, edm::EventID::event(), forceUseHcalNoiseSummary_, forceUseRecHitCollection_, edm::Event::getByToken(), hbheInputLabel_, hbheToken_, hcalNoiseSummaryLabel_, hcalNoiseSummaryToken_, i, edm::EventBase::id(), maxerrormessage_, minOccupiedHBHE_, edm::Event::put(), reverseFilter_, edm::EventID::run(), RunEventData_, taggingMode_, useHcalNoiseSummary_, vetoByHBHEOccupancy_, and vetoByRunEventNumber_.

164 {
165  using namespace edm;
166 
167  bool filterDecision=true;
168 
169  if (debug_) std::cout <<"<HcalLaserEventFilter> Run = "<<iEvent.id().run()<<" Event = "<<iEvent.id().event()<<std::endl;
170 
171  // Veto events by run/event numbers
173  {
174  for (unsigned int i=0;i<RunEventData_.size();++i)
175  {
176  if (iEvent.id().run()==RunEventData_[i].first &&
177  iEvent.id().event()==RunEventData_[i].second)
178  {
179  if (debug_) std::cout<<"\t<HcalLaserEventFilter> Filtering bad event; Run "<<iEvent.id().run()<<" Event = "<<iEvent.id().event()<<std::endl;
180  filterDecision=false;
181  break;
182  }
183  }
184  } // if (vetoByRunEventNumber_)
185 
186  //Veto events by HBHE rechit collection size
188  {
189  // The decision on whether or not to use the noise summary is made based on the CMSSW version.
190  // As of CMSSW_5_2_0, the HcalNoiseSummary contains the total number of HBHE hits, as well as number of hits > 1.5 GeV and some other info.
191  // The boolean 'forceUseRecHitCollection_' can be used to override this automatic behavior, and to use the RecHit collection itself, regardless of CMSSW version.
192 
193 
195  //
196  // Apply Filtering based on RecHit information in HBHERecHitcollection
197  //
199 
200 
202  {
204  if (iEvent.getByToken(hbheToken_,hbheRecHits))
205  {
206  if (debug_) std::cout <<"Rechit size = "<<hbheRecHits->size()<<" threshold = "<<minOccupiedHBHE_<<std::endl;
207  if (hbheRecHits->size()>=minOccupiedHBHE_)
208  {
209  if (debug_) std::cout <<"<HcalLaserEventFilter> Filtering because of large HBHE rechit size; "<<hbheRecHits->size()<<" rechits is greater than or equal to the allowed maximum of "<<minOccupiedHBHE_<<std::endl;
210  filterDecision=false;
211  }
212  }
213  else
214  {
216  std::cout <<"<HcalLaserEventFilter::Error> No valid HBHERecHitCollection with label '"<<hbheInputLabel_<<"' found"<<std::endl;
217  ++errorcount;
218  }
219  }
220 
222  //
223  // Apply Filtering based on RecHit information in HcalNoiseSummary object
224  //
226  else if (useHcalNoiseSummary_==true || forceUseHcalNoiseSummary_==true)
227  {
228  Handle<HcalNoiseSummary> hSummary;
229  if (iEvent.getByToken(hcalNoiseSummaryToken_,hSummary)) // get by label, usually with label 'hcalnoise'
230  {
231  if (debug_) std::cout << " RECHIT SIZE (from HcalNoiseSummary) = "<<hSummary->GetRecHitCount()<<" threshold = "<<minOccupiedHBHE_<<std::endl;
232  if (hSummary->GetRecHitCount() >= (int)minOccupiedHBHE_)
233  {
234  if (debug_) std::cout <<"<HcalLaserEventFilter> Filtering because of large HBHE rechit size in HcalNoiseSummary; "<<hSummary->GetRecHitCount()<<" rechits is greater than or equal to the allowed maximum of "<<minOccupiedHBHE_<<std::endl;
235  filterDecision=false;
236  }
237  }
238  else
239  {
241  std::cout <<"<HcalLaserEventFilter::Error> No valid HcalNoiseSummary with label '"<<hcalNoiseSummaryLabel_<<"' found"<<std::endl;
242  ++errorcount;
243  }
244  }
245  }// if (vetoByHBHEOccupancy_)
246 
247  // Reverse decision, if specified by user
248  if (reverseFilter_)
249  filterDecision=!filterDecision;
250 
251  iEvent.put( std::auto_ptr<bool>(new bool(filterDecision)) );
252 
253  return taggingMode_ || filterDecision;
254 }
edm::EDGetTokenT< HBHERecHitCollection > hbheToken_
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< HcalNoiseSummary > hcalNoiseSummaryToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
const edm::InputTag hcalNoiseSummaryLabel_
const edm::InputTag hbheInputLabel_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::EventID id() const
Definition: EventBase.h:60
std::vector< std::pair< edm::RunNumber_t, edm::EventNumber_t > > RunEventData_
const unsigned int minOccupiedHBHE_
tuple cout
Definition: gather_cfg.py:121
std::vector< int > HcalLaserEventFilter::GetCMSSWVersion ( std::string const &  instring)
private

Definition at line 288 of file HcalLaserEventFilter.cc.

References prof2calltree::prefix, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, and groupFilesInBlocks::temp.

Referenced by beginJob().

289 {
290  std::vector <int> temp;
291 
292 
294  std::string v1, v2, v3;
295 
296  std::istringstream oss(instring);
297  getline(oss, prefix,'_');
298  getline(oss, v1,'_');
299  getline(oss, v2,'_');
300  getline(oss, v3,'_');
301 
302  std::stringstream buffer(v1);
303  int t;
304  buffer>>t;
305  temp.push_back(t);
306  buffer.str();
307  buffer<<v2;
308  buffer>>t;
309  temp.push_back(t);
310  buffer.str();
311  buffer<<v3;
312  buffer>>t;
313  temp.push_back(t);
314 
315  //std::cout <<"PREFIX = "<<prefix<<" "<<temp[0]<<" "<<temp[1]<<" "<<temp[2]<<std::endl;
316  //( ex: PREFIX = "CMSSW 5 5 5 )
317  return temp;
318 }
bool HcalLaserEventFilter::IsGreaterThanMinCMSSWVersion ( std::vector< int > const &  currentVersion)
private

Definition at line 320 of file HcalLaserEventFilter.cc.

References minVersion_.

Referenced by beginJob().

321 {
322  // Returns false if current version is less than min version
323  // Otherwise, returns true
324  // Assumes CMSSW versioning X_Y_Z
325 
326 
327 
328  // Compare X
329  if (currentVersion[0]<minVersion_[0]) return false;
330  if (currentVersion[0]>minVersion_[0]) return true;
331  // If neither is true, first value of CMSSW versions are the same
332 
333  // Compare Y
334  if (currentVersion[1]<minVersion_[1]) return false;
335  if (currentVersion[1]>minVersion_[1]) return true;
336 
337  // Compare Z
338  if (currentVersion[2]<minVersion_[2]) return false;
339  if (currentVersion[2]>minVersion_[2]) return true;
340 
341  return true; // versions are identical
342 }
std::vector< int > minVersion_

Member Data Documentation

const bool HcalLaserEventFilter::debug_
private

Definition at line 75 of file HcalLaserEventFilter.cc.

Referenced by filter().

int HcalLaserEventFilter::errorcount
private

Definition at line 90 of file HcalLaserEventFilter.cc.

Referenced by filter(), and HcalLaserEventFilter().

bool HcalLaserEventFilter::forceUseHcalNoiseSummary_
private

Definition at line 96 of file HcalLaserEventFilter.cc.

Referenced by filter().

bool HcalLaserEventFilter::forceUseRecHitCollection_
private

Definition at line 95 of file HcalLaserEventFilter.cc.

Referenced by filter().

const edm::InputTag HcalLaserEventFilter::hbheInputLabel_
private

Definition at line 82 of file HcalLaserEventFilter.cc.

Referenced by filter().

edm::EDGetTokenT<HBHERecHitCollection> HcalLaserEventFilter::hbheToken_
private

Definition at line 83 of file HcalLaserEventFilter.cc.

Referenced by filter().

const edm::InputTag HcalLaserEventFilter::hcalNoiseSummaryLabel_
private

Definition at line 84 of file HcalLaserEventFilter.cc.

Referenced by filter().

edm::EDGetTokenT<HcalNoiseSummary> HcalLaserEventFilter::hcalNoiseSummaryToken_
private

Definition at line 85 of file HcalLaserEventFilter.cc.

Referenced by filter().

int HcalLaserEventFilter::maxerrormessage_
private

Definition at line 91 of file HcalLaserEventFilter.cc.

Referenced by filter().

const unsigned int HcalLaserEventFilter::minOccupiedHBHE_
private

Definition at line 72 of file HcalLaserEventFilter.cc.

Referenced by filter().

std::vector<int> HcalLaserEventFilter::minVersion_
private

Definition at line 97 of file HcalLaserEventFilter.cc.

Referenced by beginJob(), and IsGreaterThanMinCMSSWVersion().

const bool HcalLaserEventFilter::reverseFilter_
private

Definition at line 79 of file HcalLaserEventFilter.cc.

Referenced by filter().

std::vector<std::pair<edm::RunNumber_t,edm::EventNumber_t> > HcalLaserEventFilter::RunEventData_
private

Definition at line 68 of file HcalLaserEventFilter.cc.

Referenced by filter(), and HcalLaserEventFilter().

const bool HcalLaserEventFilter::taggingMode_
private

Definition at line 87 of file HcalLaserEventFilter.cc.

Referenced by filter().

bool HcalLaserEventFilter::useHcalNoiseSummary_
private

Definition at line 94 of file HcalLaserEventFilter.cc.

Referenced by beginJob(), and filter().

const bool HcalLaserEventFilter::vetoByHBHEOccupancy_
private

Definition at line 71 of file HcalLaserEventFilter.cc.

Referenced by filter().

const bool HcalLaserEventFilter::vetoByRunEventNumber_
private

Definition at line 67 of file HcalLaserEventFilter.cc.

Referenced by filter().