CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
EgammaHadTower Class Reference

#include <EgammaHadTower.h>

Public Types

enum  HoeMode { SingleTower = 0, TowersBehindCluster = 1 }
 

Public Member Functions

 EgammaHadTower (const edm::EventSetup &es, HoeMode mode=SingleTower)
 
double getDepth1HcalESum (const std::vector< CaloTowerDetId > &towers, CaloTowerCollection const &) const
 
double getDepth2HcalESum (const std::vector< CaloTowerDetId > &towers, CaloTowerCollection const &) const
 
bool hasActiveHcal (const std::vector< CaloTowerDetId > &towers) const
 
CaloTowerDetId towerOf (const reco::CaloCluster &cluster) const
 
std::vector< CaloTowerDetIdtowersOf (const reco::SuperCluster &sc) const
 

Private Attributes

const HcalChannelQualityhcalQuality_
 
const HcalTopologyhcalTopology_
 
HoeMode mode_
 
unsigned int nMaxClusters_
 
const CaloTowerConstituentsMaptowerMap_
 

Detailed Description

Definition at line 17 of file EgammaHadTower.h.

Member Enumeration Documentation

◆ HoeMode

Enumerator
SingleTower 
TowersBehindCluster 

Definition at line 19 of file EgammaHadTower.h.

19 { SingleTower = 0, TowersBehindCluster = 1 };

Constructor & Destructor Documentation

◆ EgammaHadTower()

EgammaHadTower::EgammaHadTower ( const edm::EventSetup es,
HoeMode  mode = SingleTower 
)

Definition at line 20 of file EgammaHadTower.cc.

20  : mode_(mode) {
22  es.get<CaloGeometryRecord>().get(ctmaph);
23  towerMap_ = &(*ctmaph);
24  nMaxClusters_ = 4;
25 
27  es.get<HcalChannelQualityRcd>().get("withTopo", hQuality);
28  hcalQuality_ = hQuality.product();
29 
30  edm::ESHandle<HcalTopology> hcalTopology;
31  es.get<HcalRecNumberingRecord>().get(hcalTopology);
32  hcalTopology_ = hcalTopology.product();
33 }

References edm::EventSetup::get(), get, hcalQuality_, hcalTopology_, nMaxClusters_, edm::ESHandle< T >::product(), and towerMap_.

Member Function Documentation

◆ getDepth1HcalESum()

double EgammaHadTower::getDepth1HcalESum ( const std::vector< CaloTowerDetId > &  towers,
CaloTowerCollection const &  towerCollection 
) const

Definition at line 94 of file EgammaHadTower.cc.

95  {
96  double esum = 0.;
97  for (auto const& tower : towerCollection) {
98  if (std::find(towers.begin(), towers.end(), tower.id()) != towers.end()) {
99  esum += tower.ietaAbs() < 18 || tower.ietaAbs() > 29 ? tower.hadEnergy() : tower.hadEnergyHeInnerLayer();
100  }
101  }
102  return esum;
103 }

References spr::find(), hgcalTowerProducer_cfi::tower, HLT_2018_cff::towerCollection, and HLT_2018_cff::towers.

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), ElectronHcalHelper::hcalESumDepth1BehindClusters(), and EgammaHLTBcHcalIsolationProducersRegional::produce().

◆ getDepth2HcalESum()

double EgammaHadTower::getDepth2HcalESum ( const std::vector< CaloTowerDetId > &  towers,
CaloTowerCollection const &  towerCollection 
) const

Definition at line 105 of file EgammaHadTower.cc.

106  {
107  double esum = 0.;
108  for (auto const& tower : towerCollection) {
109  if (std::find(towers.begin(), towers.end(), tower.id()) != towers.end()) {
110  esum += tower.hadEnergyHeOuterLayer();
111  }
112  }
113  return esum;
114 }

References spr::find(), hgcalTowerProducer_cfi::tower, HLT_2018_cff::towerCollection, and HLT_2018_cff::towers.

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), ElectronHcalHelper::hcalESumDepth2BehindClusters(), and EgammaHLTBcHcalIsolationProducersRegional::produce().

◆ hasActiveHcal()

bool EgammaHadTower::hasActiveHcal ( const std::vector< CaloTowerDetId > &  towers) const

Definition at line 116 of file EgammaHadTower.cc.

116  {
117  bool active = false;
118  int statusMask = ((1 << HcalChannelStatus::HcalCellOff) | (1 << HcalChannelStatus::HcalCellMask) |
120 #ifdef EDM_ML_DEBUG
121  std::cout << "DEBUG: hasActiveHcal called with " << towers.size() << " detids. First tower detid ieta "
122  << towers.front().ieta() << " iphi " << towers.front().iphi() << std::endl;
123 #endif
124  for (auto towerid : towers) {
125  unsigned int ngood = 0, nbad = 0;
126  for (DetId id : towerMap_->constituentsOf(towerid)) {
127  if (id.det() != DetId::Hcal) {
128  continue;
129  }
130  HcalDetId hid(id);
131  if (hid.subdet() != HcalBarrel && hid.subdet() != HcalEndcap)
132  continue;
133 #ifdef EDM_ML_DEBUG
134  std::cout << "EgammaHadTower DetId " << std::hex << id.rawId() << " hid.rawId " << hid.rawId() << std::dec
135  << " sub " << hid.subdet() << " ieta " << hid.ieta() << " iphi " << hid.iphi() << " depth "
136  << hid.depth() << std::endl;
137 #endif
138  // Sunanda's fix for 2017 Plan1
139  // and removed protection
140  int status =
141  hcalQuality_->getValues((DetId)(hcalTopology_->idFront(HcalDetId(id))), /*throwOnFail=*/true)->getValue();
142 
143 #ifdef EDM_ML_DEBUG
144  std::cout << "channels status = " << std::hex << status << std::dec << " int value = " << status << std::endl;
145 #endif
146 
147  if (status & statusMask) {
148 #ifdef EDM_ML_DEBUG
149  std::cout << " BAD!" << std::endl;
150 #endif
151  nbad++;
152  } else {
153  ngood++;
154  }
155  }
156 #ifdef EDM_ML_DEBUG
157  std::cout << " overall ngood " << ngood << " nbad " << nbad << "\n";
158 #endif
159  if (nbad == 0 || (ngood > 0 && nbad < ngood)) {
160  active = true;
161  }
162  }
163  return active;
164 }

References CaloTowerConstituentsMap::constituentsOf(), gather_cfg::cout, TauDecayModes::dec, HcalDetId::depth(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), DetId::Hcal, HcalBarrel, HcalChannelStatus::HcalCellDead, HcalChannelStatus::HcalCellMask, HcalChannelStatus::HcalCellOff, HcalEndcap, hcalQuality_, hcalTopology_, HcalTopology::idFront(), HcalDetId::ieta(), HcalDetId::iphi(), DetId::rawId(), mps_update::status, HcalDetId::subdet(), towerMap_, and HLT_2018_cff::towers.

Referenced by GEDPhotonProducer::fillPhotonCollection(), and ElectronHcalHelper::hasActiveHcal().

◆ towerOf()

CaloTowerDetId EgammaHadTower::towerOf ( const reco::CaloCluster cluster) const

Definition at line 35 of file EgammaHadTower.cc.

35  {
36  DetId detid = cluster.seed();
37  if (detid.det() != DetId::Ecal) {
38  // Basic clusters of hybrid super-cluster do not have the seed set; take the first DetId instead
39  // Should be checked . The single Tower Mode should be favoured until fixed
40  detid = cluster.hitsAndFractions()[0].first;
41  if (detid.det() != DetId::Ecal) {
43  return tower;
44  }
45  }
47  return id;
48 }

References DetId::det(), DetId::Ecal, reco::CaloCluster::hitsAndFractions(), triggerObjects_cff::id, reco::CaloCluster::seed(), hgcalTowerProducer_cfi::tower, towerMap_, and CaloTowerConstituentsMap::towerOf().

Referenced by towersOf().

◆ towersOf()

std::vector< CaloTowerDetId > EgammaHadTower::towersOf ( const reco::SuperCluster sc) const

Definition at line 50 of file EgammaHadTower.cc.

50  {
51  std::vector<CaloTowerDetId> towers;
52  std::vector<reco::CaloClusterPtr> orderedClusters;
53 
54  // in this mode, check only the tower behind the seed
55  if (mode_ == SingleTower) {
56  towers.push_back(towerOf(*sc.seed()));
57  }
58 
59  // in this mode check the towers behind each basic cluster
60  if (mode_ == TowersBehindCluster) {
61  // Loop on the basic clusters
62  for (auto it = sc.clustersBegin(); it != sc.clustersEnd(); ++it) {
63  orderedClusters.push_back(*it);
64  }
65  std::sort(orderedClusters.begin(), orderedClusters.end(), [](auto& c1, auto& c2) { return (*c1 > *c2); });
66  unsigned nclusters = orderedClusters.size();
67  for (unsigned iclus = 0; iclus < nclusters && iclus < nMaxClusters_; ++iclus) {
68  // Get the tower
69  CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
70 #ifdef EDM_ML_DEBUG
71  std::cout << "CaloTowerId " << id << std::endl;
72 #endif
73  if (std::find(towers.begin(), towers.end(), id) == towers.end()) {
74  towers.push_back(id);
75  }
76  }
77  }
78  // if(towers.size() > 4) {
79  // std::cout << " NTOWERS " << towers.size() << " ";
80  // for(unsigned i=0; i<towers.size() ; ++i) {
81  // std::cout << towers[i] << " ";
82  // }
83  // std::cout << std::endl;
84  // for ( unsigned iclus=0 ; iclus < orderedClusters.size(); ++iclus) {
85  // // Get the tower
86  // CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
87  // std::cout << " Pos " << orderedClusters[iclus]->position() << " " << orderedClusters[iclus]->energy() << " " << id ;
88  // }
89  // std::cout << std::endl;
90  // }
91  return towers;
92 }

References alignmentValidation::c1, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), gather_cfg::cout, spr::find(), triggerObjects_cff::id, mode_, nMaxClusters_, reco::SuperCluster::seed(), SingleTower, towerOf(), HLT_2018_cff::towers, and TowersBehindCluster.

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), ElectronHcalHelper::hasActiveHcal(), ElectronHcalHelper::hcalTowersBehindClusters(), and EgammaHLTBcHcalIsolationProducersRegional::produce().

Member Data Documentation

◆ hcalQuality_

const HcalChannelQuality* EgammaHadTower::hcalQuality_
private

Definition at line 32 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), and hasActiveHcal().

◆ hcalTopology_

const HcalTopology* EgammaHadTower::hcalTopology_
private

Definition at line 33 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), and hasActiveHcal().

◆ mode_

HoeMode EgammaHadTower::mode_
private

Definition at line 30 of file EgammaHadTower.h.

Referenced by towersOf().

◆ nMaxClusters_

unsigned int EgammaHadTower::nMaxClusters_
private

Definition at line 31 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), and towersOf().

◆ towerMap_

const CaloTowerConstituentsMap* EgammaHadTower::towerMap_
private

Definition at line 29 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), hasActiveHcal(), and towerOf().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EgammaHadTower::SingleTower
Definition: EgammaHadTower.h:19
HcalTopology::idFront
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
EgammaHadTower::nMaxClusters_
unsigned int nMaxClusters_
Definition: EgammaHadTower.h:31
CaloTowerConstituentsMap::constituentsOf
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
Definition: CaloTowerConstituentsMap.cc:69
HcalChannelQualityRcd
Definition: HcalChannelQualityRcd.h:8
mps_update.status
status
Definition: mps_update.py:69
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DetId::Hcal
Definition: DetId.h:28
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:3
HcalBarrel
Definition: HcalAssistant.h:33
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EgammaHadTower::mode_
HoeMode mode_
Definition: EgammaHadTower.h:30
HcalChannelStatus::HcalCellMask
Definition: HcalChannelStatus.h:18
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
DetId
Definition: DetId.h:17
HcalChannelStatus::HcalCellOff
Definition: HcalChannelStatus.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EgammaHadTower::hcalQuality_
const HcalChannelQuality * hcalQuality_
Definition: EgammaHadTower.h:32
edm::ESHandle< CaloTowerConstituentsMap >
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
HcalDetId
Definition: HcalDetId.h:12
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
reco::SuperCluster::clustersBegin
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
CaloTowerConstituentsMap::towerOf
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
Definition: CaloTowerConstituentsMap.cc:26
DetId::Ecal
Definition: DetId.h:27
get
#define get
reco::CaloCluster::seed
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
HLT_2018_cff.towers
towers
Definition: HLT_2018_cff.py:35030
HcalChannelStatus::HcalCellDead
Definition: HcalChannelStatus.h:20
HLT_2018_cff.towerCollection
towerCollection
Definition: HLT_2018_cff.py:17558
HcalEndcap
Definition: HcalAssistant.h:34
EgammaHadTower::towerMap_
const CaloTowerConstituentsMap * towerMap_
Definition: EgammaHadTower.h:29
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EgammaHadTower::TowersBehindCluster
Definition: EgammaHadTower.h:19
reco::SuperCluster::clustersEnd
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
EgammaHadTower::hcalTopology_
const HcalTopology * hcalTopology_
Definition: EgammaHadTower.h:33
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
EgammaHadTower::towerOf
CaloTowerDetId towerOf(const reco::CaloCluster &cluster) const
Definition: EgammaHadTower.cc:35
CaloTowerDetId
Definition: CaloTowerDetId.h:12