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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 42 of file PFBadHcalPseudoClusterProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 64 of file PFBadHcalPseudoClusterProducer.cc.

64  :
65  enabled_(ps.getParameter<bool>("enable")),
66  debug_(ps.getUntrackedParameter<bool>("debug",false)),
68 {
69  produces<std::vector<reco::PFCluster>>();
70  produces<std::vector<reco::PFRecHit>>("hits");
71 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
PFBadHcalPseudoClusterProducer::~PFBadHcalPseudoClusterProducer ( )
override

Definition at line 74 of file PFBadHcalPseudoClusterProducer.cc.

75 {
76 }

Member Function Documentation

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

Definition at line 164 of file PFBadHcalPseudoClusterProducer.cc.

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

164  {
166  desc.add<bool>("enable", false)->setComment("activate the module (if false, it doesn't check the DB and produces an empty collection)");
167  desc.addUntracked<bool>("debug", false);
168  descriptions.add("particleFlowBadHcalPseudoCluster", desc);
169 }
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 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(), 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, mps_update::status, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

79 {
80  badAreasC_.clear();
81  badAreasRH_.clear();
82 
84  iSetup.get<HcalChannelQualityRcd>().get("withTopo",hQuality_);
85  const HcalChannelQuality & chanquality = *hQuality_;
86 
88  iSetup.get<CaloGeometryRecord>().get(hGeom_);
89  const CaloGeometry& caloGeom = *hGeom_;
92 
94  // histogram the number of bad depths at each ieta, iphi
95  std::map<std::pair<int,int>, int> good, bads;
96  std::map<std::pair<int,int>, std::pair<int,HcalSubdetector>> minDepths;
97  for (const DetId & i : chanquality.getAllChannels()) {
98  if (i.det()!=DetId::Hcal) continue; // not an hcal cell
99  HcalDetId id = HcalDetId(i);
100  if (id.subdet() != HcalBarrel && id.subdet() != HcalEndcap) 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_) std::cout << "Channel " << i() << " (subdet " << id.subdet() << ", zside " << id.zside() << ", ieta " << id.ieta() << ", iphi " << id.iphi() << " depth " << id.depth() << " has status " << status << " 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_) std::cout << "At ieta " << id.ieta() << ", iphi " << id.iphi() << " I have " << nbad << " bad depths, " << ngood << " good depths. First depth is in " << (barrel ? "HB" : "HE") << " depth " << minDepth.first <<"; " << (isBad ? " MARK BAD": " ignore") << std::endl;
124  if (!isBad) continue;
126  // make a PF RecHit
127  std::shared_ptr<const CaloCellGeometry> thisCell = (barrel ? hbGeom : heGeom)->getGeometry(id);
128  const GlobalPoint & pos = thisCell->getPosition();
129  badAreasRH_.emplace_back( thisCell, id(), layer, dummyEnergy );
130  // make a PF cluster (but can't add the rechit, as for that I need an edm::Ref)
131  badAreasC_.emplace_back( layer, dummyEnergy, pos.x(), pos.y(), pos.z() );
133  }
134 
135  cacheId_quality_ = iSetup.get<HcalChannelQualityRcd>().cacheIdentifier();
136  cacheId_geom_ = iSetup.get<CaloGeometryRecord>().cacheIdentifier();
137 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
std::vector< reco::PFCluster > badAreasC_
T y() const
Definition: PV3DBase.h:63
const Item * getValues(DetId fId, bool throwOnFail=true) const
CaloGeometry const * getGeometry()
std::vector< DetId > getAllChannels() const
T z() const
Definition: PV3DBase.h:64
edm::ESHandle< HcalChannelQuality > hQuality_
Layer
layer definition
Definition: PFLayer.h:31
Definition: DetId.h:18
std::vector< reco::PFRecHit > badAreasRH_
uint32_t getValue() const
T x() const
Definition: PV3DBase.h:62
void PFBadHcalPseudoClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 141 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(), gen::n, and edm::Event::put().

142 {
143  if (enabled_) {
145  cacheId_geom_ != iSetup.get<CaloGeometryRecord>().cacheIdentifier()) {
146  init(iSetup);
147  }
148  }
149 
150 
151  auto outRH = std::make_unique<std::vector<reco::PFRecHit>>(badAreasRH_);
152  auto rhHandle = iEvent.put(std::move(outRH), "hits");
153 
154  auto outC = std::make_unique<std::vector<reco::PFCluster>>(badAreasC_);
155 
156  // now we go set references
157  for (unsigned int i = 0, n = rhHandle->size(); i < n; ++i) {
158  (*outC)[i].addRecHitFraction( reco::PFRecHitFraction(reco::PFRecHitRef(rhHandle,i), 1.0) );
159  }
160 
161  iEvent.put(std::move(outC));
162 }
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:137
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
std::vector< reco::PFRecHit > badAreasRH_
T get() const
Definition: EventSetup.h:62
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 59 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

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

Definition at line 60 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

unsigned long long PFBadHcalPseudoClusterProducer::cacheId_geom_
private

Definition at line 58 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

unsigned long long PFBadHcalPseudoClusterProducer::cacheId_quality_
private

Definition at line 58 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init(), and produce().

bool PFBadHcalPseudoClusterProducer::debug_
private

Definition at line 54 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

bool PFBadHcalPseudoClusterProducer::enabled_
private

Definition at line 53 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by produce().

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

Definition at line 57 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().

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

Definition at line 56 of file PFBadHcalPseudoClusterProducer.cc.

Referenced by init().