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 reco::SuperCluster &sc) const
 
double getDepth1HcalESum (const std::vector< CaloTowerDetId > &towers) const
 
double getDepth2HcalESum (const reco::SuperCluster &sc) const
 
double getDepth2HcalESum (const std::vector< CaloTowerDetId > &towers) const
 
bool hasActiveHcal (const reco::SuperCluster &sc) const
 
bool hasActiveHcal (const std::vector< CaloTowerDetId > &towers) const
 
void setTowerCollection (const CaloTowerCollection *towercollection)
 
CaloTowerDetId towerOf (const reco::CaloCluster &cluster) const
 
std::vector< CaloTowerDetIdtowersOf (const reco::SuperCluster &sc) const
 
 ~EgammaHadTower ()
 

Private Attributes

const HcalChannelQualityhcalQuality_
 
const HcalTopologyhcalTopology_
 
HoeMode mode_
 
unsigned int NMaxClusters_
 
const CaloTowerCollectiontowerCollection_
 
const CaloTowerConstituentsMaptowerMap_
 

Detailed Description

Definition at line 17 of file EgammaHadTower.h.

Member Enumeration Documentation

Enumerator
SingleTower 
TowersBehindCluster 

Definition at line 20 of file EgammaHadTower.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file EgammaHadTower.cc.

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

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 
34 }
const HcalTopology * hcalTopology_
const HcalChannelQuality * hcalQuality_
const CaloTowerConstituentsMap * towerMap_
T get() const
Definition: EventSetup.h:71
unsigned int NMaxClusters_
T const * product() const
Definition: ESHandle.h:86
EgammaHadTower::~EgammaHadTower ( )
inline

Member Function Documentation

double EgammaHadTower::getDepth1HcalESum ( const reco::SuperCluster sc) const

Definition at line 177 of file EgammaHadTower.cc.

References towersOf().

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), ElectronHcalHelper::hcalESumDepth1BehindClusters(), and ~EgammaHadTower().

177  {
178  return getDepth1HcalESum(towersOf(sc)) ;
179 }
double getDepth1HcalESum(const reco::SuperCluster &sc) const
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
double EgammaHadTower::getDepth1HcalESum ( const std::vector< CaloTowerDetId > &  towers) const

Definition at line 99 of file EgammaHadTower.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), spr::find(), and towerCollection_.

99  {
100  double esum=0.;
103  for( ; trItr != trItrEnd ; ++trItr){
104  std::vector<CaloTowerDetId>::const_iterator itcheck = find(towers.begin(), towers.end(), trItr->id());
105  if( itcheck != towers.end() ) {
106  esum += trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEnergy() : trItr->hadEnergyHeInnerLayer() ;
107  }
108  }
109  return esum;
110 }
const CaloTowerCollection * towerCollection_
std::vector< CaloTower >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const_iterator end() const
const_iterator begin() const
double EgammaHadTower::getDepth2HcalESum ( const reco::SuperCluster sc) const

Definition at line 181 of file EgammaHadTower.cc.

References towersOf().

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), ElectronHcalHelper::hcalESumDepth2BehindClusters(), and ~EgammaHadTower().

181  {
182  return getDepth2HcalESum(towersOf(sc)) ;
183 }
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
double getDepth2HcalESum(const reco::SuperCluster &sc) const
double EgammaHadTower::getDepth2HcalESum ( const std::vector< CaloTowerDetId > &  towers) const

Definition at line 112 of file EgammaHadTower.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), spr::find(), and towerCollection_.

112  {
113  double esum=0.;
116  for( ; trItr != trItrEnd ; ++trItr){
117  std::vector<CaloTowerDetId>::const_iterator itcheck = find(towers.begin(), towers.end(), trItr->id());
118  if( itcheck != towers.end() ) {
119  esum += trItr->hadEnergyHeOuterLayer();
120  }
121  }
122  return esum;
123 }
const CaloTowerCollection * towerCollection_
std::vector< CaloTower >::const_iterator const_iterator
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const_iterator end() const
const_iterator begin() const
bool EgammaHadTower::hasActiveHcal ( const reco::SuperCluster sc) const

Definition at line 189 of file EgammaHadTower.cc.

References towersOf().

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

189  {
190  return hasActiveHcal(towersOf(sc)) ;
191 }
bool hasActiveHcal(const reco::SuperCluster &sc) const
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
bool EgammaHadTower::hasActiveHcal ( const std::vector< CaloTowerDetId > &  towers) const

Definition at line 125 of file EgammaHadTower.cc.

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(), and towerMap_.

125  {
126 
127  bool active = false;
129 #ifdef EDM_ML_DEBUG
130  std::cout << "DEBUG: hasActiveHcal called with " << towers.size()
131  << " detids. First tower detid ieta " << towers.front().ieta()
132  << " iphi " << towers.front().iphi() << std::endl;
133 #endif
134  for (auto towerid : towers) {
135  unsigned int ngood = 0, nbad = 0;
136  for (DetId id : towerMap_->constituentsOf(towerid)) {
137  if (id.det() != DetId::Hcal) {
138  continue;
139  }
140  HcalDetId hid(id);
141  if (hid.subdet() != HcalBarrel && hid.subdet() != HcalEndcap) continue;
142 #ifdef EDM_ML_DEBUG
143  std::cout << "EgammaHadTower DetId " << std::hex << id.rawId()
144  << " hid.rawId " << hid.rawId() << std::dec
145  << " sub " << hid.subdet() << " ieta " << hid.ieta()
146  << " iphi " << hid.iphi()
147  << " depth " << hid.depth() << std::endl;
148 #endif
149  // Sunanda's fix for 2017 Plan1
150  // and removed protection
151  int status = hcalQuality_->getValues((DetId)(hcalTopology_->idFront(HcalDetId(id))),/*throwOnFail=*/true)->getValue();
152 
153 #ifdef EDM_ML_DEBUG
154  std::cout << "channels status = " << std::hex << status << std::dec
155  << " int value = " << status << std::endl;
156 #endif
157 
158  if (status & statusMask) {
159 #ifdef EDM_ML_DEBUG
160  std::cout << " BAD!" << std::endl;
161 #endif
162  nbad++;
163  } else {
164  ngood++;
165  }
166  }
167 #ifdef EDM_ML_DEBUG
168  std::cout << " overall ngood " << ngood << " nbad " << nbad << "\n";
169 #endif
170  if (nbad == 0 || (ngood > 0 && nbad < ngood)) {
171  active = true;
172  }
173  }
174  return active;
175 }
const HcalTopology * hcalTopology_
const HcalChannelQuality * hcalQuality_
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
const CaloTowerConstituentsMap * towerMap_
Definition: DetId.h:18
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:177
uint32_t getValue() const
void EgammaHadTower::setTowerCollection ( const CaloTowerCollection towercollection)

Definition at line 185 of file EgammaHadTower.cc.

References towerCollection_.

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), ElectronHcalHelper::readEvent(), and ~EgammaHadTower().

185  {
186  towerCollection_ = towerCollection;
187 }
const CaloTowerCollection * towerCollection_
CaloTowerDetId EgammaHadTower::towerOf ( const reco::CaloCluster cluster) const

Definition at line 36 of file EgammaHadTower.cc.

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

Referenced by towersOf(), and ~EgammaHadTower().

36  {
37  DetId detid = cluster.seed();
38  if(detid.det() != DetId::Ecal) {
39  // Basic clusters of hybrid super-cluster do not have the seed set; take the first DetId instead
40  // Should be checked . The single Tower Mode should be favoured until fixed
41  detid = cluster.hitsAndFractions()[0].first;
42  if(detid.det() != DetId::Ecal) {
43  CaloTowerDetId tower;
44  return tower;
45  }
46  }
48  return id;
49 }
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
const CaloTowerConstituentsMap * towerMap_
Definition: DetId.h:18
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:207
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
std::vector< CaloTowerDetId > EgammaHadTower::towersOf ( const reco::SuperCluster sc) const

Definition at line 51 of file EgammaHadTower.cc.

References ClusterGreaterThan(), reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), gather_cfg::cout, spr::find(), triggerObjects_cff::id, mode_, NMaxClusters_, reco::SuperCluster::seed(), SingleTower, jetUpdater_cfi::sort, towerOf(), and TowersBehindCluster.

Referenced by PhotonProducer::fillPhotonCollection(), GEDPhotonProducer::fillPhotonCollection(), getDepth1HcalESum(), getDepth2HcalESum(), hasActiveHcal(), ElectronHcalHelper::hcalTowersBehindClusters(), and ~EgammaHadTower().

51  {
52  std::vector<CaloTowerDetId> towers;
53  std::vector<reco::CaloClusterPtr> orderedClusters;
54 
55  // in this mode, check only the tower behind the seed
56  if ( mode_ == SingleTower ) {
57  towers.push_back(towerOf(*sc.seed()));
58  }
59 
60  // in this mode check the towers behind each basic cluster
61  if ( mode_ == TowersBehindCluster ) {
62  // Loop on the basic clusters
65 
66  for ( ; it !=itend; ++it) {
67  orderedClusters.push_back(*it);
68  }
69  std::sort(orderedClusters.begin(),orderedClusters.end(),ClusterGreaterThan);
70  unsigned nclusters=orderedClusters.size();
71  for ( unsigned iclus =0 ; iclus <nclusters && iclus < NMaxClusters_; ++iclus) {
72  // Get the tower
73  CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
74 #ifdef EDM_ML_DEBUG
75  std:: cout << "CaloTowerId " << id << std::endl;
76 #endif
77  std::vector<CaloTowerDetId>::const_iterator itcheck=find(towers.begin(),towers.end(),id);
78  if( itcheck == towers.end() ) {
79  towers.push_back(id);
80  }
81  }
82  }
83 // if(towers.size() > 4) {
84 // std::cout << " NTOWERS " << towers.size() << " ";
85 // for(unsigned i=0; i<towers.size() ; ++i) {
86 // std::cout << towers[i] << " ";
87 // }
88 // std::cout << std::endl;
89 // for ( unsigned iclus=0 ; iclus < orderedClusters.size(); ++iclus) {
90 // // Get the tower
91 // CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
92 // std::cout << " Pos " << orderedClusters[iclus]->position() << " " << orderedClusters[iclus]->energy() << " " << id ;
93 // }
94 // std::cout << std::endl;
95 // }
96  return towers;
97 }
CaloTowerDetId towerOf(const reco::CaloCluster &cluster) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool ClusterGreaterThan(const reco::CaloClusterPtr &c1, const reco::CaloClusterPtr &c2)
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
unsigned int NMaxClusters_
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78

Member Data Documentation

const HcalChannelQuality* EgammaHadTower::hcalQuality_
private

Definition at line 40 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), and hasActiveHcal().

const HcalTopology* EgammaHadTower::hcalTopology_
private

Definition at line 41 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), and hasActiveHcal().

HoeMode EgammaHadTower::mode_
private

Definition at line 37 of file EgammaHadTower.h.

Referenced by towersOf().

unsigned int EgammaHadTower::NMaxClusters_
private

Definition at line 39 of file EgammaHadTower.h.

Referenced by EgammaHadTower(), and towersOf().

const CaloTowerCollection* EgammaHadTower::towerCollection_
private

Definition at line 38 of file EgammaHadTower.h.

Referenced by getDepth1HcalESum(), getDepth2HcalESum(), and setTowerCollection().

const CaloTowerConstituentsMap* EgammaHadTower::towerMap_
private

Definition at line 36 of file EgammaHadTower.h.

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