Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBHE stuck ADC filter #44955

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EventFilter/HcalRawToDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<library file="HcalCalibFEDSelector.cc,HcalCalibTypeFilter.cc,HcalDigiToRaw.cc,HcalEmptyEventFilter.cc,HcalHistogramRawToDigi.cc,HcalRawToDigi.cc,modules.cc,HcalDigiToRawuHTR.cc,HcalRawToDigiFake.cc" name="EventFilterHcalRawToDigiPlugins">
</library>

<library file="HcalLaserEventFiltProducer2012.cc, HcalLaserEventFilter2012.cc,HcalLaserHFFilter2012.cc,HcalLaserHBHEFilter2012.cc,HcalLaserHBHEHFFilter2012.cc" name="EventFilterHcalRawToDigiFiltersPlugins">
<library file="HcalLaserEventFiltProducer2012.cc, HcalLaserEventFilter2012.cc,HcalLaserHFFilter2012.cc,HcalLaserHBHEFilter2012.cc,HcalLaserHBHEHFFilter2012.cc, HBHEstuckADCfilter.cc" name="EventFilterHcalRawToDigiFiltersPlugins">
</library>

<iftool name="cuda-gcc-support">
Expand Down
94 changes: 94 additions & 0 deletions EventFilter/HcalRawToDigi/plugins/HBHEstuckADCfilter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// simple filter slecting events with all-equal 8 ADC counts > threshold
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/one/EDFilter.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
#include "DataFormats/HcalDigi/interface/QIE11DataFrame.h"
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <fstream>

class HBHEstuckADCfilter : public edm::one::EDFilter<> {
public:
explicit HBHEstuckADCfilter(const edm::ParameterSet&);
~HBHEstuckADCfilter() override;

static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
bool filter(edm::Event&, const edm::EventSetup&) override;
void endJob() override;

edm::EDGetTokenT<QIE11DigiCollection> tok_qie11_;
int thresholdADC_;
bool writeList_;
std::ofstream outfile_;
};

HBHEstuckADCfilter::HBHEstuckADCfilter(const edm::ParameterSet& conf)
: tok_qie11_(consumes<QIE11DigiCollection>(conf.getParameter<edm::InputTag>("digiLabel"))),
thresholdADC_(conf.getParameter<int>("thresholdADC")),
writeList_(conf.getParameter<bool>("writeList")) {
if (writeList_)
outfile_.open("events_list_stuckADC.txt");
}

HBHEstuckADCfilter::~HBHEstuckADCfilter() {}

bool HBHEstuckADCfilter::filter(edm::Event& ev, const edm::EventSetup& set) {
edm::Handle<QIE11DigiCollection> theDigis;
ev.getByToken(tok_qie11_, theDigis);

bool result = true;
for (QIE11DigiCollection::const_iterator itr = theDigis->begin(); itr != theDigis->end(); itr++) {
int tsize = (*itr).size();
const QIE11DataFrame frame = *itr;

bool flag = true;
int adc0 = (frame[0]).adc();
if (adc0 < thresholdADC_)
flag = false;
else {
for (int i = 1; i < tsize; i++) {
if ((frame[i]).adc() != adc0) {
flag = false;
break;
}
}
}

// report explicitly
if (flag) {
const HcalDetId cell(itr->id());
edm::LogWarning("HBHEstuckADCfilter") << "stuck ADC = " << adc0 << " in " << cell << std::endl;
result = false;
}
}
if (!result && writeList_)
outfile_ << ev.id().run() << ":" << ev.luminosityBlock() << ":" << ev.id().event() << std::endl;

return result;
}

void HBHEstuckADCfilter::endJob() {
if (writeList_)
outfile_.close();
}

void HBHEstuckADCfilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("digiLabel", edm::InputTag("hcalDigis"));
desc.add<int>("thresholdADC", 100);
desc.add<bool>("writeList", true);
descriptions.add("hbhestuckADCfilter", desc);
}

//define as a plug-in
DEFINE_FWK_MODULE(HBHEstuckADCfilter);
5 changes: 5 additions & 0 deletions EventFilter/HcalRawToDigi/python/HBHEstuckADCfilter_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import FWCore.ParameterSet.Config as cms

import EventFilter.HcalRawToDigi.hbhestuckADCfilter_cfi
stuckADCfilter = EventFilter.HcalRawToDigi.hbhestuckADCfilter_cfi.hbhestuckADCfilter.clone()
stuckADCfilter.thresholdADC = 100