CMS 3D CMS Logo

EgammaHadTower.cc
Go to the documentation of this file.
6 
7 #include <iostream>
8 #include <algorithm>
9 
11  DetId detid = cluster.seed();
12  if (detid.det() != DetId::Ecal) {
13  // Basic clusters of hybrid super-cluster do not have the seed set; take the first DetId instead
14  // Should be checked . The single Tower Mode should be favoured until fixed
15  detid = cluster.hitsAndFractions()[0].first;
16  if (detid.det() != DetId::Ecal) {
18  return tower;
19  }
20  }
21  CaloTowerDetId id(towerMap.towerOf(detid));
22  return id;
23 }
24 
25 std::vector<CaloTowerDetId> egamma::towersOf(const reco::SuperCluster& sc,
26  CaloTowerConstituentsMap const& towerMap,
27  HoeMode mode) {
28  constexpr unsigned int nMaxClusters = 4;
29 
30  std::vector<CaloTowerDetId> towers;
31  std::vector<reco::CaloClusterPtr> orderedClusters;
32 
33  // in this mode, check only the tower behind the seed
34  if (mode == HoeMode::SingleTower) {
35  towers.push_back(towerOf(*sc.seed(), towerMap));
36  }
37 
38  // in this mode check the towers behind each basic cluster
39  if (mode == HoeMode::TowersBehindCluster) {
40  // Loop on the basic clusters
41  for (auto it = sc.clustersBegin(); it != sc.clustersEnd(); ++it) {
42  orderedClusters.push_back(*it);
43  }
44  std::sort(orderedClusters.begin(), orderedClusters.end(), [](auto& c1, auto& c2) { return (*c1 > *c2); });
45  unsigned nclusters = orderedClusters.size();
46  for (unsigned iclus = 0; iclus < nclusters && iclus < nMaxClusters; ++iclus) {
47  // Get the tower
48  CaloTowerDetId id = towerOf(*(orderedClusters[iclus]), towerMap);
49 #ifdef EDM_ML_DEBUG
50  std::cout << "CaloTowerId " << id << std::endl;
51 #endif
52  if (std::find(towers.begin(), towers.end(), id) == towers.end()) {
53  towers.push_back(id);
54  }
55  }
56  }
57  // if(towers.size() > 4) {
58  // std::cout << " NTOWERS " << towers.size() << " ";
59  // for(unsigned i=0; i<towers.size() ; ++i) {
60  // std::cout << towers[i] << " ";
61  // }
62  // std::cout << std::endl;
63  // for ( unsigned iclus=0 ; iclus < orderedClusters.size(); ++iclus) {
64  // // Get the tower
65  // CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
66  // std::cout << " Pos " << orderedClusters[iclus]->position() << " " << orderedClusters[iclus]->energy() << " " << id ;
67  // }
68  // std::cout << std::endl;
69  // }
70  return towers;
71 }
72 
73 double egamma::depth1HcalESum(const std::vector<CaloTowerDetId>& towers, CaloTowerCollection const& towerCollection) {
74  double esum = 0.;
75  for (auto const& tower : towerCollection) {
76  if (std::find(towers.begin(), towers.end(), tower.id()) != towers.end()) {
77  esum += tower.ietaAbs() < 18 || tower.ietaAbs() > 29 ? tower.hadEnergy() : tower.hadEnergyHeInnerLayer();
78  }
79  }
80  return esum;
81 }
82 
83 double egamma::depth2HcalESum(const std::vector<CaloTowerDetId>& towers, CaloTowerCollection const& towerCollection) {
84  double esum = 0.;
85  for (auto const& tower : towerCollection) {
86  if (std::find(towers.begin(), towers.end(), tower.id()) != towers.end()) {
87  esum += tower.hadEnergyHeOuterLayer();
88  }
89  }
90  return esum;
91 }
92 
93 bool egamma::hasActiveHcal(const std::vector<CaloTowerDetId>& towers,
94  CaloTowerConstituentsMap const& towerMap,
95  const HcalChannelQuality& hcalQuality,
96  HcalTopology const& hcalTopology) {
97  bool active = false;
98  int statusMask = ((1 << HcalChannelStatus::HcalCellOff) | (1 << HcalChannelStatus::HcalCellMask) |
100 #ifdef EDM_ML_DEBUG
101  std::cout << "DEBUG: hasActiveHcal called with " << towers.size() << " detids. First tower detid ieta "
102  << towers.front().ieta() << " iphi " << towers.front().iphi() << std::endl;
103 #endif
104  for (auto towerid : towers) {
105  unsigned int ngood = 0, nbad = 0;
106  for (DetId id : towerMap.constituentsOf(towerid)) {
107  if (id.det() != DetId::Hcal) {
108  continue;
109  }
110  HcalDetId hid(id);
111  if (hid.subdet() != HcalBarrel && hid.subdet() != HcalEndcap)
112  continue;
113 #ifdef EDM_ML_DEBUG
114  std::cout << "EgammaHadTower DetId " << std::hex << id.rawId() << " hid.rawId " << hid.rawId() << std::dec
115  << " sub " << hid.subdet() << " ieta " << hid.ieta() << " iphi " << hid.iphi() << " depth "
116  << hid.depth() << std::endl;
117 #endif
118  // Sunanda's fix for 2017 Plan1
119  // and removed protection
120  int status =
121  hcalQuality.getValues((DetId)(hcalTopology.idFront(HcalDetId(id))), /*throwOnFail=*/true)->getValue();
122 
123 #ifdef EDM_ML_DEBUG
124  std::cout << "channels status = " << std::hex << status << std::dec << " int value = " << status << std::endl;
125 #endif
126 
127  if (status & statusMask) {
128 #ifdef EDM_ML_DEBUG
129  std::cout << " BAD!" << std::endl;
130 #endif
131  nbad++;
132  } else {
133  ngood++;
134  }
135  }
136 #ifdef EDM_ML_DEBUG
137  std::cout << " overall ngood " << ngood << " nbad " << nbad << "\n";
138 #endif
139  if (nbad == 0 || (ngood > 0 && nbad < ngood)) {
140  active = true;
141  }
142  }
143  return active;
144 }
HLT_FULL_cff.towers
towers
Definition: HLT_FULL_cff.py:36379
HcalTopology::idFront
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
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
HcalDetId::iphi
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
reco::SuperCluster
Definition: SuperCluster.h:18
mps_update.status
status
Definition: mps_update.py:68
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
HcalTopology
Definition: HcalTopology.h:26
DetId::Hcal
Definition: DetId.h:28
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
edm::SortedCollection< CaloTower >
HcalDetId::depth
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164
HcalChannelQuality
Definition: HcalChannelQuality.h:17
HcalBarrel
Definition: HcalAssistant.h:33
egamma::depth2HcalESum
double depth2HcalESum(std::vector< CaloTowerDetId > const &towers, CaloTowerCollection const &)
Definition: EgammaHadTower.cc:83
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HcalChannelStatus::HcalCellMask
Definition: HcalChannelStatus.h:18
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
EgammaHadTower.h
DetId
Definition: DetId.h:17
HcalChannelStatus::HcalCellOff
Definition: HcalChannelStatus.h:17
reco::CaloCluster
Definition: CaloCluster.h:31
CaloTowerConstituentsMap
Definition: CaloTowerConstituentsMap.h:18
egamma::HoeMode
HoeMode
Definition: EgammaHadTower.h:16
egamma::towerOf
CaloTowerDetId towerOf(reco::CaloCluster const &cluster, CaloTowerConstituentsMap const &towerMap)
Definition: EgammaHadTower.cc:10
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
egamma::towersOf
std::vector< CaloTowerDetId > towersOf(reco::SuperCluster const &sc, CaloTowerConstituentsMap const &towerMap, HoeMode mode=HoeMode::SingleTower)
Definition: EgammaHadTower.cc:25
HcalDetId::ieta
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
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
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
HcalDetId.h
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
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
HcalChannelStatus.h
reco::CaloCluster::seed
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
HcalChannelQuality.h
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalChannelStatus::HcalCellDead
Definition: HcalChannelStatus.h:20
HcalEndcap
Definition: HcalAssistant.h:34
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
SuperCluster.h
egamma::depth1HcalESum
double depth1HcalESum(std::vector< CaloTowerDetId > const &towers, CaloTowerCollection const &)
Definition: EgammaHadTower.cc:73
egamma::hasActiveHcal
bool hasActiveHcal(std::vector< CaloTowerDetId > const &towers, CaloTowerConstituentsMap const &towerMap, HcalChannelQuality const &hcalQuality, HcalTopology const &hcalTopology)
Definition: EgammaHadTower.cc:93
reco::SuperCluster::clustersEnd
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
CaloTowerDetId
Definition: CaloTowerDetId.h:12