File indexing completed on 2024-04-06 12:11:01
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "EventFilter/SiStripChannelChargeFilter/interface/TECClusterFilter.h"
0010 #include "DataFormats/Common/interface/Handle.h"
0011 #include "DataFormats/Common/interface/DetSetVector.h"
0012 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015 using namespace std;
0016
0017 namespace cms {
0018
0019 TECClusterFilter::TECClusterFilter(const edm::ParameterSet& ps) {
0020
0021 ModulesToBeExcluded.clear();
0022 ModulesToBeExcluded = ps.getParameter<std::vector<unsigned> >("ModulesToBeExcluded");
0023 edm::LogInfo("TECClusterFilter") << "Clusters from " << ModulesToBeExcluded.size()
0024 << " modules will be ignored in the filter:";
0025 for (std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end();
0026 imod++) {
0027 edm::LogInfo("TECClusterFilter") << *imod;
0028 }
0029
0030 ChargeThresholdTEC = ps.getParameter<int>("ChargeThresholdTEC");
0031 edm::LogInfo("TECClusterFilter") << "ChargeThresholdTEC" << ChargeThresholdTEC;
0032 minNrOfTECClusters = ps.getParameter<int>("MinNrOfTECClusters");
0033 edm::LogInfo("TECClusterFilter") << "MinNrOfTECClusters" << minNrOfTECClusters;
0034 clusterProducer = ps.getParameter<string>("ClusterProducer");
0035 edm::LogInfo("TECClusterFilter") << "ClusterProducer" << clusterProducer;
0036
0037
0038 produces<int>();
0039 }
0040
0041 bool TECClusterFilter::filter(edm::Event& e, edm::EventSetup const& c) {
0042 edm::Handle<edm::DetSetVector<SiStripCluster> > h;
0043 e.getByLabel(clusterProducer, h);
0044 bool decision = false;
0045 unsigned int nr_clusters_above_threshold = 0;
0046 for (edm::DetSetVector<SiStripCluster>::const_iterator it = h->begin(); it != h->end(); it++) {
0047 DetId thedetId = DetId(it->detId());
0048 bool exclude_this_detid = false;
0049 for (vector<SiStripCluster>::const_iterator vit = (it->data).begin(); vit != (it->data).end(); vit++) {
0050 for (std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin();
0051 imod != ModulesToBeExcluded.end();
0052 imod++) {
0053 if (*imod == thedetId.rawId())
0054 exclude_this_detid = true;
0055 }
0056 if ((!exclude_this_detid) &&
0057 (thedetId.subdetId() == StripSubdetector::TEC))
0058 {
0059 unsigned int amplclus = 0;
0060
0061 for (auto ia = vit->amplitudes().begin(); ia != vit->amplitudes().end(); ia++) {
0062 if ((*ia) > 0)
0063 amplclus += (*ia);
0064 }
0065 if (amplclus > ChargeThresholdTEC)
0066 nr_clusters_above_threshold++;
0067 }
0068 }
0069 }
0070 if (nr_clusters_above_threshold >= minNrOfTECClusters)
0071 decision = true;
0072 e.put(std::make_unique<int>(decision));
0073 return decision;
0074 }
0075 }