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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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::ESHandle< HcalChannelQualityhQuality_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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 62 of file PFBadHcalPseudoClusterProducer.cc.

63  : enabled_(ps.getParameter<bool>("enable")),
64  debug_(ps.getUntrackedParameter<bool>("debug", false)),
66  cacheId_geom_(0) {
67  produces<std::vector<reco::PFCluster>>();
68  produces<std::vector<reco::PFRecHit>>("hits");
69 }

◆ ~PFBadHcalPseudoClusterProducer()

PFBadHcalPseudoClusterProducer::~PFBadHcalPseudoClusterProducer ( )
override

Definition at line 71 of file PFBadHcalPseudoClusterProducer.cc.

71 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 165 of file PFBadHcalPseudoClusterProducer.cc.

165  {
167  desc.add<bool>("enable", false)
168  ->setComment("activate the module (if false, it doesn't check the DB and produces an empty collection)");
169  desc.addUntracked<bool>("debug", false);
170  descriptions.add("particleFlowBadHcalPseudoCluster", desc);
171 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and edm::ParameterSetDescription::addUntracked().

◆ init()

void PFBadHcalPseudoClusterProducer::init ( const EventSetup c)
privatevirtual

Definition at line 73 of file PFBadHcalPseudoClusterProducer.cc.

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

References badAreasC_, badAreasRH_, reco::CaloCluster::badHcalMarker, Reference_intrackfit_cff::barrel, cacheId_geom_, cacheId_quality_, gather_cfg::cout, debug_, MillePedeFileConverter_cfg::e, edm::EventSetup::get(), get, HcalCondObjectContainer< Item >::getAllChannels(), ecaldqm::getGeometry(), CaloGeometry::getSubdetectorGeometry(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), DetId::Hcal, PFLayer::HCAL_BARREL1, PFLayer::HCAL_ENDCAP, HcalBarrel, HcalChannelStatus::HcalCellDead, HcalChannelStatus::HcalCellMask, HcalChannelStatus::HcalCellOff, HcalEmpty, HcalEndcap, hGeom_, hQuality_, mps_fire::i, triggerObjects_cff::id, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, mps_update::status, and hgcalTowerProducer_cfi::tower.

Referenced by produce().

◆ produce()

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

Definition at line 144 of file PFBadHcalPseudoClusterProducer.cc.

144  {
145  if (enabled_) {
147  cacheId_geom_ != iSetup.get<CaloGeometryRecord>().cacheIdentifier()) {
148  init(iSetup);
149  }
150  }
151 
152  auto outRH = std::make_unique<std::vector<reco::PFRecHit>>(badAreasRH_);
153  auto rhHandle = iEvent.put(std::move(outRH), "hits");
154 
155  auto outC = std::make_unique<std::vector<reco::PFCluster>>(badAreasC_);
156 
157  // now we go set references
158  for (unsigned int i = 0, n = rhHandle->size(); i < n; ++i) {
159  (*outC)[i].addRecHitFraction(reco::PFRecHitFraction(reco::PFRecHitRef(rhHandle, i), 1.0));
160  }
161 
162  iEvent.put(std::move(outC));
163 }

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.

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().

◆ hQuality_

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

Definition at line 55 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

PFBadHcalPseudoClusterProducer::hQuality_
edm::ESHandle< HcalChannelQuality > hQuality_
Definition: PFBadHcalPseudoClusterProducer.cc:55
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
reco::PFRecHitFraction
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
Definition: PFRecHitFraction.h:18
HcalChannelQualityRcd
Definition: HcalChannelQualityRcd.h:8
mps_update.status
status
Definition: mps_update.py:69
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
DetId::Hcal
Definition: DetId.h:28
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:3
PFLayer::HCAL_ENDCAP
Definition: PFLayer.h:37
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HcalChannelQuality
Definition: HcalChannelQuality.h:17
PFBadHcalPseudoClusterProducer::badAreasRH_
std::vector< reco::PFRecHit > badAreasRH_
Definition: PFBadHcalPseudoClusterProducer.cc:59
HcalBarrel
Definition: HcalAssistant.h:33
HcalEmpty
Definition: HcalAssistant.h:32
HcalChannelStatus::HcalCellMask
Definition: HcalChannelStatus.h:18
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
PFBadHcalPseudoClusterProducer::debug_
bool debug_
Definition: PFBadHcalPseudoClusterProducer.cc:53
edm::Ref< PFRecHitCollection >
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
DetId
Definition: DetId.h:17
PFBadHcalPseudoClusterProducer::cacheId_quality_
unsigned long long cacheId_quality_
Definition: PFBadHcalPseudoClusterProducer.cc:57
CaloGeometry
Definition: CaloGeometry.h:21
HcalChannelStatus::HcalCellOff
Definition: HcalChannelStatus.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
PFBadHcalPseudoClusterProducer::init
virtual void init(const EventSetup &c)
Definition: PFBadHcalPseudoClusterProducer.cc:73
PFLayer::HCAL_BARREL1
Definition: PFLayer.h:35
edm::ESHandle< HcalChannelQuality >
reco::CaloCluster::badHcalMarker
Definition: CaloCluster.h:50
ecaldqm::getGeometry
const CaloGeometry * getGeometry()
Definition: EcalDQMCommonUtils.cc:478
PFBadHcalPseudoClusterProducer::cacheId_geom_
unsigned long long cacheId_geom_
Definition: PFBadHcalPseudoClusterProducer.cc:57
PFBadHcalPseudoClusterProducer::enabled_
bool enabled_
Definition: PFBadHcalPseudoClusterProducer.cc:52
Point3DBase< float, GlobalTag >
PFBadHcalPseudoClusterProducer::hGeom_
edm::ESHandle< CaloGeometry > hGeom_
Definition: PFBadHcalPseudoClusterProducer.cc:56
PFLayer::Layer
Layer
layer definition
Definition: PFLayer.h:29
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: HcalCondObjectContainer.h:312
PFBadHcalPseudoClusterProducer::badAreasC_
std::vector< reco::PFCluster > badAreasC_
Definition: PFBadHcalPseudoClusterProducer.cc:58
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalChannelStatus::HcalCellDead
Definition: HcalChannelStatus.h:20
HcalEndcap
Definition: HcalAssistant.h:34
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::eventsetup::EventSetupRecord::cacheIdentifier
unsigned long long cacheIdentifier() const
Definition: EventSetupRecord.h:185
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37