CMS 3D CMS Logo

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