CMS 3D CMS Logo

EcalClusterPUCleaningTools.cc
Go to the documentation of this file.
2 
7 
9 
11 
13 
15 {
16  getGeometry( es );
17  getEBRecHits( ev, redEBRecHits );
18  getEERecHits( ev, redEERecHits );
19 }
20 
21 
22 
24 {
25 }
26 
27 
29 {
31  es.get<CaloGeometryRecord>().get(pGeometry);
32  geometry_ = pGeometry.product();
33 }
34 
36 {
38  ev.getByLabel( redEBRecHits, pEBRecHits );
39  ebRecHits_ = pEBRecHits.product();
40 }
41 
42 
43 
45 {
47  ev.getByLabel( redEERecHits, pEERecHits );
48  eeRecHits_ = pEERecHits.product();
49 }
50 
51 
53 
54  //std::cout << "\nEcalClusterPUCleaningTools::CleanedSuperCluster called, this will give you back a cleaned supercluster" << std::endl;
55 
56  // seed basic cluster of initial SC: this will remain in the cleaned SC, by construction
57  const reco::CaloClusterPtr& seed = scluster.seed();
58 
59  float seedBCEnergy = (scluster.seed())->energy(); // this should be replaced by the 5x5 around the seed; a good approx of how E_seed is defined
60  float eSeed = 0.35; // standard eSeed in EB ; see CMS IN-2010/008
61  int numBcRemoved = 0;
62 
63  double ClusterE = 0; //Sum of cluster energies for supercluster.
64  //Holders for position of this supercluster.
65  double posX=0;
66  double posY=0;
67  double posZ=0;
68 
70 
71  // looping on basic clusters within the Supercluster
72  for(reco::CaloCluster_iterator bcIt = scluster.clustersBegin(); bcIt!=scluster.clustersEnd(); bcIt++)
73  {
74  // E_seed is an Et selection on 5x1 dominoes (around which BC's are built), see CMS IN-2010/008
75  // here such selection is implemented on the full BC around it
76  if( (*bcIt)->energy() > sqrt( eSeed*eSeed + xi*xi*seedBCEnergy*seedBCEnergy/cosh((*bcIt)->eta())/cosh((*bcIt)->eta()) ) )
77  {
78  ;
79  }// the sum only of the BC's that pass the Esee selection
80  else{
81  numBcRemoved++;
82  continue;
83  }// count how many basic cluster get removed by the cleaning
84 
85  // if BC passes dynamic selection, include it in the 'cleaned' supercluster
86  thissc.push_back( (*bcIt) );
87  // cumulate energy and position of the cleaned supercluster
88  ClusterE += (*bcIt)->energy();
89  posX += (*bcIt)->energy() * (*bcIt)->position().X();
90  posY += (*bcIt)->energy() * (*bcIt)->position().Y();
91  posZ += (*bcIt)->energy() * (*bcIt)->position().Z();
92 
93  }// loop on basic clusters of the original SC
94 
95  posX /= ClusterE;
96  posY /= ClusterE;
97  posZ /= ClusterE;
98 
99  // make temporary 'cleaned' supercluster in oder to compute the covariances
100  double Epreshower=scluster.preshowerEnergy();
101  double phiWidth=0.;
102  double etaWidth=0.;
103  reco::SuperCluster suCltmp(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
104 
105 
106  // construct cluster shape to compute ieta and iphi covariances of the SC
107  const CaloSubdetectorGeometry *geometry_p=nullptr;
108  if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalBarrel){
110  SuperClusterShapeAlgo SCShape( ebRecHits_ , geometry_p);
111  SCShape.Calculate_Covariances( suCltmp );
112  phiWidth= SCShape.phiWidth();
113  etaWidth= SCShape.etaWidth();
114  }
115  else if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalEndcap){
117  SuperClusterShapeAlgo SCShape( eeRecHits_ , geometry_p);
118  SCShape.Calculate_Covariances( suCltmp );
119  phiWidth= SCShape.phiWidth();
120  etaWidth= SCShape.etaWidth();
121  }
122  else {
123  std::cout << "The seed crystal of this SC is neither in EB nor in EE. This is a problem. Bailing out " << std::endl;
124  assert(-1);
125  }
126 
127  // return the cleaned supercluster SCluster, with covariances updated
128  return reco::SuperCluster(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
129 
130 }
void getEBRecHits(const edm::Event &ev, const edm::InputTag &redEBRecHits)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
const EcalRecHitCollection * eeRecHits_
void Calculate_Covariances(const reco::SuperCluster &passedCluster)
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
const EcalRecHitCollection * ebRecHits_
void getEERecHits(const edm::Event &ev, const edm::InputTag &redEERecHits)
EcalClusterPUCleaningTools(const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag &redEBRecHits, const edm::InputTag &redEERecHits)
bool ev
void getGeometry(const edm::EventSetup &es)
T sqrt(T t)
Definition: SSEVec.h:18
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:475
T const * product() const
Definition: Handle.h:81
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:59
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:50
T const * product() const
Definition: ESHandle.h:86
reco::SuperCluster CleanedSuperCluster(float xi, const reco::SuperCluster &cluster, const edm::Event &ev)
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78