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);
edm::RefProd
Definition: EDProductfwd.h:25
ClusterRemovalInfo.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
LumiMonitor_cff.pixelClusters
pixelClusters
Definition: LumiMonitor_cff.py:10
ContainerMask.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
siStripClusterTools::chargePerCM
float chargePerCM(DetId detid, Iter a, Iter b)
Definition: SiStripClusterTools.h:29
SiPixelCluster.h
cms::cuda::assert
assert(be >=bs)
EDProducer.h
edm::ContainerMask
Definition: ContainerMask.h:36
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ProductID.h
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
SiStripClusterTools.h
HLT_FULL_cff.stripClusters
stripClusters
Definition: HLT_FULL_cff.py:10026
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripCluster.h
Event.h
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
ValueMap.h
edmNew::DetSetVector
Definition: DetSetNew.h:13
DetId.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ClusterChargeCut.h
ParameterSet.h
clusterChargeCut
float clusterChargeCut(const edm::ParameterSet &conf, const char *name="clusterChargeCut")
Definition: ClusterChargeCut.h:7
edm::Event
Definition: Event.h:73
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15