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 ( 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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
PFBadHcalPseudoClusterProducer::~PFBadHcalPseudoClusterProducer ( )
override

Definition at line 71 of file PFBadHcalPseudoClusterProducer.cc.

71 {}

Member Function Documentation

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

Definition at line 165 of file PFBadHcalPseudoClusterProducer.cc.

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

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 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PFBadHcalPseudoClusterProducer::init ( const EventSetup c)
privatevirtual

Definition at line 73 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(), 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, hgcalTowerProducer_cfi::tower, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

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 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
std::vector< reco::PFCluster > badAreasC_
T y() const
Definition: PV3DBase.h:60
const Item * getValues(DetId fId, bool throwOnFail=true) const
CaloGeometry const * getGeometry()
std::vector< DetId > getAllChannels() const
T z() const
Definition: PV3DBase.h:61
edm::ESHandle< HcalChannelQuality > hQuality_
Layer
layer definition
Definition: PFLayer.h:29
Definition: DetId.h:17
std::vector< reco::PFRecHit > badAreasRH_
uint32_t getValue() const
T x() const
Definition: PV3DBase.h:59
void PFBadHcalPseudoClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 144 of file PFBadHcalPseudoClusterProducer.cc.

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

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 }
unsigned long long cacheIdentifier() const
std::vector< reco::PFCluster > badAreasC_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
std::vector< reco::PFRecHit > badAreasRH_
T get() const
Definition: EventSetup.h:73
virtual void init(const EventSetup &c)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 58 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

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

Definition at line 59 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

unsigned long long PFBadHcalPseudoClusterProducer::cacheId_geom_
private

Definition at line 57 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

unsigned long long PFBadHcalPseudoClusterProducer::cacheId_quality_
private

Definition at line 57 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

bool PFBadHcalPseudoClusterProducer::debug_
private

Definition at line 53 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

bool PFBadHcalPseudoClusterProducer::enabled_
private

Definition at line 52 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by produce().

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

Definition at line 56 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

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

Definition at line 55 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().