CMS 3D CMS Logo

ClusterChargeMasker.cc
Go to the documentation of this file.
6 
9 
14 
16 
18 
21 
22 namespace {
23 
24  class ClusterChargeMasker : public edm::stream::EDProducer<> {
25  public:
26  ClusterChargeMasker(const edm::ParameterSet& iConfig);
27  ~ClusterChargeMasker() override {}
28  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
29 
30  private:
33 
34  bool mergeOld_;
35  float minGoodStripCharge_;
36 
39 
40  edm::EDGetTokenT<PixelMaskContainer> oldPxlMaskToken_;
41  edm::EDGetTokenT<StripMaskContainer> oldStrMaskToken_;
42  };
43 
44  ClusterChargeMasker::ClusterChargeMasker(const edm::ParameterSet& iConfig)
45  : mergeOld_(iConfig.exists("oldClusterRemovalInfo")), minGoodStripCharge_(clusterChargeCut(iConfig)) {
46  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster>>>();
47  produces<edm::ContainerMask<edmNew::DetSetVector<SiStripCluster>>>();
48 
49  pixelClusters_ =
50  consumes<edmNew::DetSetVector<SiPixelCluster>>(iConfig.getParameter<edm::InputTag>("pixelClusters"));
51  stripClusters_ =
52  consumes<edmNew::DetSetVector<SiStripCluster>>(iConfig.getParameter<edm::InputTag>("stripClusters"));
53 
54  if (mergeOld_) {
55  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<edm::InputTag>("oldClusterRemovalInfo"));
56  oldStrMaskToken_ = consumes<StripMaskContainer>(iConfig.getParameter<edm::InputTag>("oldClusterRemovalInfo"));
57  }
58  }
59 
60  void ClusterChargeMasker::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
62  iEvent.getByToken(pixelClusters_, pixelClusters);
64  iEvent.getByToken(stripClusters_, stripClusters);
65 
66  std::vector<bool> collectedStrips;
67  std::vector<bool> collectedPixels;
68 
69  if (mergeOld_) {
72  iEvent.getByToken(oldPxlMaskToken_, oldPxlMask);
73  iEvent.getByToken(oldStrMaskToken_, oldStrMask);
74  LogDebug("ClusterChargeMasker") << "to merge in, " << oldStrMask->size() << " strp and " << oldPxlMask->size()
75  << " pxl";
76  oldStrMask->copyMaskTo(collectedStrips);
77  oldPxlMask->copyMaskTo(collectedPixels);
78  assert(stripClusters->dataSize() >= collectedStrips.size());
79  collectedStrips.resize(stripClusters->dataSize(), false);
80  } else {
81  collectedStrips.resize(stripClusters->dataSize(), false);
82  collectedPixels.resize(pixelClusters->dataSize(), false);
83  }
84 
85  auto const& clusters = stripClusters->data();
86  for (auto const& item : stripClusters->ids()) {
87  if (!item.isValid())
88  continue; // not umpacked (hlt only)
89 
90  auto detid = item.id;
91 
92  for (int i = item.offset; i < item.offset + int(item.size); ++i) {
93  auto clusCharge = siStripClusterTools::chargePerCM(detid, clusters[i]);
94  if (clusCharge < minGoodStripCharge_)
95  collectedStrips[i] = true;
96  }
97  }
98 
99  LogDebug("ClusterChargeMasker") << "total strip to skip: "
100  << std::count(collectedStrips.begin(), collectedStrips.end(), true);
101  // std::cout << "ClusterChargeMasker " <<"total strip to skip: "<<std::count(collectedStrips.begin(),collectedStrips.end(),true)
102  // << " for CCC " << minGoodStripCharge_ <<std::endl;
103  iEvent.put(std::make_unique<StripMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiStripCluster>>(stripClusters),
104  collectedStrips));
105 
106  LogDebug("ClusterChargeMasker") << "total pxl to skip: "
107  << std::count(collectedPixels.begin(), collectedPixels.end(), true);
108  iEvent.put(std::make_unique<PixelMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiPixelCluster>>(pixelClusters),
109  collectedPixels));
110  }
111 
112 } // namespace
113 
116 DEFINE_FWK_MODULE(ClusterChargeMasker);
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
float chargePerCM(DetId detid, Iter a, Iter b)
float clusterChargeCut(const edm::ParameterSet &conf, const char *name="clusterChargeCut")
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
#define LogDebug(id)