CMS 3D CMS Logo

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