File indexing completed on 2024-09-07 04:36:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "HLTrigger/JetMET/interface/HLTHcalLaserFilter.h"
0019
0020 #include "DataFormats/Common/interface/Handle.h"
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 #include "FWCore/Framework/interface/ESHandle.h"
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027
0028 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031
0032 #include <iostream>
0033
0034 HLTHcalLaserFilter::HLTHcalLaserFilter(const edm::ParameterSet& iConfig)
0035 : m_theCalibToken(consumes(iConfig.getParameter<edm::InputTag>("hcalDigiCollection"))),
0036 timeSlices_(iConfig.getParameter<std::vector<int> >("timeSlices")),
0037 thresholdsfC_(iConfig.getParameter<std::vector<double> >("thresholdsfC")),
0038 CalibCountFilterValues_(iConfig.getParameter<std::vector<int> >("CalibCountFilterValues")),
0039 CalibChargeFilterValues_(iConfig.getParameter<std::vector<double> >("CalibChargeFilterValues")),
0040 maxTotalCalibCharge_(iConfig.getParameter<double>("maxTotalCalibCharge")),
0041 maxAllowedHFcalib_(iConfig.getParameter<int>("maxAllowedHFcalib"))
0042
0043 {}
0044
0045 void HLTHcalLaserFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0046 edm::ParameterSetDescription desc;
0047 desc.add<edm::InputTag>("hcalDigiCollection", edm::InputTag("hltHcalDigis"));
0048 desc.add<double>("maxTotalCalibCharge", -1);
0049
0050 std::vector<int> dummy_vint;
0051 std::vector<double> dummy_vdouble;
0052
0053 desc.add<std::vector<int> >("timeSlices", dummy_vint);
0054 desc.add<std::vector<double> >("thresholdsfC", dummy_vdouble);
0055 desc.add<std::vector<int> >("CalibCountFilterValues", dummy_vint);
0056 desc.add<std::vector<double> >("CalibChargeFilterValues", dummy_vdouble);
0057 desc.add<int>("maxAllowedHFcalib", -1);
0058 descriptions.add("hltHcalLaserFilter", desc);
0059 }
0060
0061
0062
0063
0064
0065 bool HLTHcalLaserFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0066 edm::Handle<HcalCalibDigiCollection> hCalib;
0067 iEvent.getByToken(m_theCalibToken, hCalib);
0068
0069 int numHFcalib = 0;
0070
0071
0072 double totalCalibCharge = 0;
0073
0074
0075 std::vector<int> CalibCount;
0076 std::vector<double> CalibCharge;
0077 for (unsigned int i = 0; i < thresholdsfC_.size(); ++i) {
0078 CalibCount.push_back(0);
0079 CalibCharge.push_back(0);
0080 }
0081
0082 static constexpr float adc2fC[128] = {
0083 -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5,
0084 12.5, 13.5, 15., 17., 19., 21., 23., 25., 27., 29.5, 32.5, 35.5, 38.5,
0085 42., 46., 50., 54.5, 59.5, 64.5, 59.5, 64.5, 69.5, 74.5, 79.5, 84.5, 89.5,
0086 94.5, 99.5, 104.5, 109.5, 114.5, 119.5, 124.5, 129.5, 137., 147., 157., 167., 177.,
0087 187., 197., 209.5, 224.5, 239.5, 254.5, 272., 292., 312., 334.5, 359.5, 384.5, 359.5,
0088 384.5, 409.5, 434.5, 459.5, 484.5, 509.5, 534.5, 559.5, 584.5, 609.5, 634.5, 659.5, 684.5,
0089 709.5, 747., 797., 847., 897., 947., 997., 1047., 1109.5, 1184.5, 1259.5, 1334.5, 1422.,
0090 1522., 1622., 1734.5, 1859.5, 1984.5, 1859.5, 1984.5, 2109.5, 2234.5, 2359.5, 2484.5, 2609.5, 2734.5,
0091 2859.5, 2984.5, 3109.5, 3234.5, 3359.5, 3484.5, 3609.5, 3797., 4047., 4297., 4547., 4797., 5047.,
0092 5297., 5609.5, 5984.5, 6359.5, 6734.5, 7172., 7672., 8172., 8734.5, 9359.5, 9984.5};
0093
0094 if (hCalib.isValid() == true) {
0095
0096
0097
0098 for (auto const& digi : *hCalib) {
0099 if (digi.id().hcalSubdet() == 0)
0100 continue;
0101
0102 HcalCalibDetId myid = (HcalCalibDetId)digi.id();
0103 if (myid.hcalSubdet() == HcalBarrel || myid.hcalSubdet() == HcalEndcap) {
0104 if (myid.calibFlavor() == HcalCalibDetId::HOCrosstalk)
0105 continue;
0106
0107
0108 for (int i = 0; i < (int)digi.size(); i++)
0109 totalCalibCharge = totalCalibCharge + adc2fC[digi.sample(i).adc() & 0xff];
0110
0111 if (maxTotalCalibCharge_ >= 0 && totalCalibCharge > maxTotalCalibCharge_)
0112 return false;
0113
0114
0115 double sumCharge = 0;
0116 unsigned int NTS = timeSlices_.size();
0117 int digisize = (int)digi.size();
0118
0119 for (unsigned int ts = 0; ts < NTS; ++ts)
0120 {
0121 if (timeSlices_[ts] < 0 || timeSlices_[ts] > digisize)
0122 continue;
0123 sumCharge += adc2fC[digi.sample(timeSlices_[ts]).adc() & 0xff];
0124 }
0125
0126
0127 for (unsigned int thresh = 0; thresh < thresholdsfC_.size(); ++thresh) {
0128 if (sumCharge > thresholdsfC_[thresh]) {
0129 ++CalibCount[thresh];
0130 CalibCharge[thresh] += sumCharge;
0131
0132 if (CalibCount[thresh] >= CalibCountFilterValues_[thresh] && CalibCountFilterValues_[thresh] >= 0) {
0133
0134 return false;
0135 }
0136 if (CalibCharge[thresh] >= CalibChargeFilterValues_[thresh] && CalibChargeFilterValues_[thresh] >= 0) {
0137
0138 return false;
0139 }
0140 }
0141 }
0142 }
0143 else if (myid.hcalSubdet() == HcalForward && maxAllowedHFcalib_ >= 0) {
0144 ++numHFcalib;
0145
0146 if (numHFcalib > maxAllowedHFcalib_) {
0147
0148 return false;
0149 }
0150 }
0151 }
0152
0153
0154
0155
0156
0157
0158
0159 }
0160
0161 return true;
0162 }