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);
edm::RefProd
Definition: EDProductfwd.h:25
ClusterRemovalInfo.h
mps_fire.i
i
Definition: mps_fire.py:355
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
HLT_2018_cff.stripClusters
stripClusters
Definition: HLT_2018_cff.py:8683
ProductID.h
SiStripClusterTools.h
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
SiStripCluster.h
Event.h
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
ValueMap.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
edmNew::DetSetVector
Definition: DetSetNew.h:13
DetId.h
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