CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PFBadHcalPseudoClusterProducer Class Reference
Inheritance diagram for PFBadHcalPseudoClusterProducer:
edm::stream::EDProducer<>

Public Member Functions

 PFBadHcalPseudoClusterProducer (const edm::ParameterSet &)
 
 ~PFBadHcalPseudoClusterProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void init (const EventSetup &c)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< reco::PFClusterbadAreasC_
 
std::vector< reco::PFRecHitbadAreasRH_
 
unsigned long long cacheId_geom_
 
unsigned long long cacheId_quality_
 
bool debug_
 
bool enabled_
 
edm::ESHandle< CaloGeometryhGeom_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordhGeomToken_
 
edm::ESHandle< HcalChannelQualityhQuality_
 
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcdhQualityToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 41 of file PFBadHcalPseudoClusterProducer.cc.

Constructor & Destructor Documentation

◆ PFBadHcalPseudoClusterProducer()

PFBadHcalPseudoClusterProducer::PFBadHcalPseudoClusterProducer ( const edm::ParameterSet ps)
explicit

Definition at line 65 of file PFBadHcalPseudoClusterProducer.cc.

66  : enabled_(ps.getParameter<bool>("enable")),
67  debug_(ps.getUntrackedParameter<bool>("debug", false)),
69  cacheId_geom_(0),
70  hQualityToken_(esConsumes(edm::ESInputTag("", "withTopo"))),
72  produces<std::vector<reco::PFCluster>>();
73  produces<std::vector<reco::PFRecHit>>("hits");
74 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > hGeomToken_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > hQualityToken_
T getUntrackedParameter(std::string const &, T const &) const

◆ ~PFBadHcalPseudoClusterProducer()

PFBadHcalPseudoClusterProducer::~PFBadHcalPseudoClusterProducer ( )
override

Definition at line 76 of file PFBadHcalPseudoClusterProducer.cc.

76 {}

Member Function Documentation

◆ fillDescriptions()

void PFBadHcalPseudoClusterProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 168 of file PFBadHcalPseudoClusterProducer.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

168  {
170  desc.add<bool>("enable", true)
171  ->setComment("activate the module (if false, it doesn't check the DB and produces an empty collection)");
172  desc.addUntracked<bool>("debug", false);
173  descriptions.add("particleFlowBadHcalPseudoCluster", desc);
174 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ init()

void PFBadHcalPseudoClusterProducer::init ( const EventSetup c)
privatevirtual

Definition at line 78 of file PFBadHcalPseudoClusterProducer.cc.

References badAreasC_, badAreasRH_, reco::CaloCluster::badHcalMarker, Reference_intrackfit_cff::barrel, cacheId_geom_, cacheId_quality_, gather_cfg::cout, debug_, MillePedeFileConverter_cfg::e, edm::EventSetup::get(), HcalCondObjectContainer< Item >::getAllChannels(), edm::EventSetup::getHandle(), CaloGeometry::getSubdetectorGeometry(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), caHitNtupletGeneratorKernels::good, DetId::Hcal, PFLayer::HCAL_BARREL1, PFLayer::HCAL_ENDCAP, HcalBarrel, HcalChannelStatus::HcalCellDead, HcalChannelStatus::HcalCellMask, HcalChannelStatus::HcalCellOff, HcalEmpty, HcalEndcap, hGeom_, hGeomToken_, hQuality_, hQualityToken_, mps_fire::i, l1ctLayer2EG_cff::id, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, nano_mu_digi_cff::layer, mps_update::status, and l1tHGCalTowerProducer_cfi::tower.

Referenced by produce().

78  {
79  badAreasC_.clear();
80  badAreasRH_.clear();
81 
82  hQuality_ = iSetup.getHandle(hQualityToken_);
83  const HcalChannelQuality& chanquality = *hQuality_;
84 
85  hGeom_ = iSetup.getHandle(hGeomToken_);
86  const CaloGeometry& caloGeom = *hGeom_;
89 
90  int statusMask = ((1 << HcalChannelStatus::HcalCellOff) | (1 << HcalChannelStatus::HcalCellMask) |
92  // histogram the number of bad depths at each ieta, iphi
93  std::map<std::pair<int, int>, int> good, bads;
94  std::map<std::pair<int, int>, std::pair<int, HcalSubdetector>> minDepths;
95  for (const DetId& i : chanquality.getAllChannels()) {
96  if (i.det() != DetId::Hcal)
97  continue; // not an hcal cell
98  HcalDetId id = HcalDetId(i);
99  if (id.subdet() != HcalBarrel && id.subdet() != HcalEndcap)
100  continue; // we don't deal with HO and HF here
101  int status = chanquality.getValues(id)->getValue();
102  auto tower = std::make_pair(id.ieta(), id.iphi());
103  if (status & statusMask) {
104  bads[tower]++;
105  if (debug_)
106  std::cout << "Channel " << i() << " (subdet " << id.subdet() << ", zside " << id.zside() << ", ieta "
107  << id.ieta() << ", iphi " << id.iphi() << " depth " << id.depth() << " has status " << status
108  << " masked " << (status & statusMask) << std::endl;
109  } else {
110  good[tower]++;
111  }
112  auto& minD = minDepths[tower];
113  if (minD.second == HcalEmpty || minD.first > id.depth()) {
114  minD.first = id.depth();
115  minD.second = id.subdet();
116  }
117  }
118 
119  const float dummyEnergy = 1e-5; // non-zero, but small (even if it shouldn't ever be used)
120  for (const auto& rec : bads) {
121  int ieta = rec.first.first, iphi = rec.first.second, nbad = rec.second, ngood = good[rec.first];
122  auto minDepth = minDepths[rec.first];
123  bool barrel = minDepth.second == HcalBarrel;
124  HcalDetId id(minDepth.second, ieta, iphi, minDepth.first);
125  bool isBad = (nbad > 0 && nbad >= ngood);
126  if (debug_)
127  std::cout << "At ieta " << id.ieta() << ", iphi " << id.iphi() << " I have " << nbad << " bad depths, " << ngood
128  << " good depths. First depth is in " << (barrel ? "HB" : "HE") << " depth " << minDepth.first << "; "
129  << (isBad ? " MARK BAD" : " ignore") << std::endl;
130  if (!isBad)
131  continue;
133  // make a PF RecHit
134  std::shared_ptr<const CaloCellGeometry> thisCell = (barrel ? hbGeom : heGeom)->getGeometry(id);
135  const GlobalPoint& pos = thisCell->getPosition();
136  badAreasRH_.emplace_back(thisCell, id(), layer, dummyEnergy);
137  // make a PF cluster (but can't add the rechit, as for that I need an edm::Ref)
138  badAreasC_.emplace_back(layer, dummyEnergy, pos.x(), pos.y(), pos.z());
140  }
141 
142  cacheId_quality_ = iSetup.get<HcalChannelQualityRcd>().cacheIdentifier();
143  cacheId_geom_ = iSetup.get<CaloGeometryRecord>().cacheIdentifier();
144 }
std::vector< reco::PFCluster > badAreasC_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > hGeomToken_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > hQualityToken_
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< DetId > getAllChannels() const
edm::ESHandle< HcalChannelQuality > hQuality_
uint32_t getValue() const
Layer
layer definition
Definition: PFLayer.h:29
Definition: DetId.h:17
std::vector< reco::PFRecHit > badAreasRH_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34

◆ produce()

void PFBadHcalPseudoClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 147 of file PFBadHcalPseudoClusterProducer.cc.

References badAreasC_, badAreasRH_, cacheId_geom_, cacheId_quality_, edm::eventsetup::EventSetupRecord::cacheIdentifier(), enabled_, edm::EventSetup::get(), mps_fire::i, iEvent, init(), eostools::move(), and dqmiodumpmetadata::n.

147  {
148  if (enabled_) {
150  cacheId_geom_ != iSetup.get<CaloGeometryRecord>().cacheIdentifier()) {
151  init(iSetup);
152  }
153  }
154 
155  auto outRH = std::make_unique<std::vector<reco::PFRecHit>>(badAreasRH_);
156  auto rhHandle = iEvent.put(std::move(outRH), "hits");
157 
158  auto outC = std::make_unique<std::vector<reco::PFCluster>>(badAreasC_);
159 
160  // now we go set references
161  for (unsigned int i = 0, n = rhHandle->size(); i < n; ++i) {
162  (*outC)[i].addRecHitFraction(reco::PFRecHitFraction(reco::PFRecHitRef(rhHandle, i), 1.0));
163  }
164 
165  iEvent.put(std::move(outC));
166 }
std::vector< reco::PFCluster > badAreasC_
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
unsigned long long cacheIdentifier() const
int iEvent
Definition: GenABIO.cc:224
T get() const
Definition: EventSetup.h:79
std::vector< reco::PFRecHit > badAreasRH_
virtual void init(const EventSetup &c)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ badAreasC_

std::vector<reco::PFCluster> PFBadHcalPseudoClusterProducer::badAreasC_
private

Definition at line 58 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

◆ badAreasRH_

std::vector<reco::PFRecHit> PFBadHcalPseudoClusterProducer::badAreasRH_
private

Definition at line 59 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

◆ cacheId_geom_

unsigned long long PFBadHcalPseudoClusterProducer::cacheId_geom_
private

Definition at line 57 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

◆ cacheId_quality_

unsigned long long PFBadHcalPseudoClusterProducer::cacheId_quality_
private

Definition at line 57 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

◆ debug_

bool PFBadHcalPseudoClusterProducer::debug_
private

Definition at line 53 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

◆ enabled_

bool PFBadHcalPseudoClusterProducer::enabled_
private

Definition at line 52 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by produce().

◆ hGeom_

edm::ESHandle<CaloGeometry> PFBadHcalPseudoClusterProducer::hGeom_
private

Definition at line 56 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

◆ hGeomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> PFBadHcalPseudoClusterProducer::hGeomToken_
private

Definition at line 62 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

◆ hQuality_

edm::ESHandle<HcalChannelQuality> PFBadHcalPseudoClusterProducer::hQuality_
private

Definition at line 55 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

◆ hQualityToken_

edm::ESGetToken<HcalChannelQuality, HcalChannelQualityRcd> PFBadHcalPseudoClusterProducer::hQualityToken_
private

Definition at line 61 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().