CMS 3D CMS Logo

EgammaHadTower.cc
Go to the documentation of this file.
6 
7 #include <algorithm>
8 #include <iostream>
9 
12  es.get<CaloGeometryRecord>().get(ctmaph);
13  towerMap_ = &(*ctmaph);
14  NMaxClusters_ = 4;
15 }
16 
18  DetId detid = cluster.seed();
19  if(detid.det() != DetId::Ecal) {
20  // Basic clusters of hybrid super-cluster do not have the seed set; take the first DetId instead
21  // Should be checked . The single Tower Mode should be favoured until fixed
22  detid = cluster.hitsAndFractions()[0].first;
23  if(detid.det() != DetId::Ecal) {
24  CaloTowerDetId tower;
25  return tower;
26  }
27  }
29  return id;
30 }
31 
32 std::vector<CaloTowerDetId> EgammaHadTower::towersOf(const reco::SuperCluster& sc) const {
33  std::vector<CaloTowerDetId> towers;
34  std::vector<reco::CaloClusterPtr> orderedClusters;
35 
36  // in this mode, check only the tower behind the seed
37  if ( mode_ == SingleTower ) {
38  towers.push_back(towerOf(*sc.seed()));
39  }
40 
41  // in this mode check the towers behind each basic cluster
42  if ( mode_ == TowersBehindCluster ) {
43  // Loop on the basic clusters
46 
47  for ( ; it !=itend; ++it) {
48  orderedClusters.push_back(*it);
49  }
50  std::sort(orderedClusters.begin(),orderedClusters.end(),ClusterGreaterThan);
51  unsigned nclusters=orderedClusters.size();
52  for ( unsigned iclus =0 ; iclus <nclusters && iclus < NMaxClusters_; ++iclus) {
53  // Get the tower
54  CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
55  std::vector<CaloTowerDetId>::const_iterator itcheck=find(towers.begin(),towers.end(),id);
56  if( itcheck == towers.end() ) {
57  towers.push_back(id);
58  }
59  }
60  }
61 // if(towers.size() > 4) {
62 // std::cout << " NTOWERS " << towers.size() << " ";
63 // for(unsigned i=0; i<towers.size() ; ++i) {
64 // std::cout << towers[i] << " ";
65 // }
66 // std::cout << std::endl;
67 // for ( unsigned iclus=0 ; iclus < orderedClusters.size(); ++iclus) {
68 // // Get the tower
69 // CaloTowerDetId id = towerOf(*(orderedClusters[iclus]));
70 // std::cout << " Pos " << orderedClusters[iclus]->position() << " " << orderedClusters[iclus]->energy() << " " << id ;
71 // }
72 // std::cout << std::endl;
73 // }
74  return towers;
75 }
76 
77 double EgammaHadTower::getDepth1HcalESum(const std::vector<CaloTowerDetId> & towers) const {
78  double esum=0.;
81  for( ; trItr != trItrEnd ; ++trItr){
82  std::vector<CaloTowerDetId>::const_iterator itcheck = find(towers.begin(), towers.end(), trItr->id());
83  if( itcheck != towers.end() ) {
84  esum += trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEnergy() : trItr->hadEnergyHeInnerLayer() ;
85  }
86  }
87  return esum;
88 }
89 
90 double EgammaHadTower::getDepth2HcalESum(const std::vector<CaloTowerDetId> & towers) const {
91  double esum=0.;
94  for( ; trItr != trItrEnd ; ++trItr){
95  std::vector<CaloTowerDetId>::const_iterator itcheck = find(towers.begin(), towers.end(), trItr->id());
96  if( itcheck != towers.end() ) {
97  esum += trItr->hadEnergyHeOuterLayer();
98  }
99  }
100  return esum;
101 }
102 
104  return getDepth1HcalESum(towersOf(sc)) ;
105 }
106 
108  return getDepth2HcalESum(towersOf(sc)) ;
109 }
110 
112  towerCollection_ = towerCollection;
113 }
114 
116  return (*c1 > *c2);
117 }
const CaloTowerCollection * towerCollection_
CaloTowerDetId towerOf(const reco::CaloCluster &cluster) const
std::vector< CaloTower >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:195
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void setTowerCollection(const CaloTowerCollection *towercollection)
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
double getDepth1HcalESum(const reco::SuperCluster &sc) const
bool ClusterGreaterThan(const reco::CaloClusterPtr &c1, const reco::CaloClusterPtr &c2)
const_iterator end() const
const CaloTowerConstituentsMap * towerMap_
Definition: DetId.h:18
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:205
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
double getDepth2HcalESum(const reco::SuperCluster &sc) const
T get() const
Definition: EventSetup.h:63
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
EgammaHadTower(const edm::EventSetup &es, HoeMode mode=SingleTower)
const_iterator begin() const
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39