CMS 3D CMS Logo

EcalClusterPUCleaningTools.cc
Go to the documentation of this file.
3 
6 
8 
10 
12 
14  const edm::InputTag &redEBRecHits,
15  const edm::InputTag &redEERecHits)
16  : pEBRecHitsToken_(cc.consumes<EcalRecHitCollection>(redEBRecHits)),
17  pEERecHitsToken_(cc.consumes<EcalRecHitCollection>(redEERecHits)),
18  geometryToken_(cc.esConsumes()) {}
19 
21 
24  ev.getByToken(pEBRecHitsToken_, pEBRecHits);
25  ebRecHits_ = pEBRecHits.product();
26 }
27 
30  ev.getByToken(pEERecHitsToken_, pEERecHits);
31  eeRecHits_ = pEERecHits.product();
32 }
33 
35  const reco::SuperCluster &scluster,
36  const edm::Event &ev,
37  const edm::EventSetup &es) {
38  // get the geometry
39  const auto &geometry = es.getData(geometryToken_);
40 
41  // get the RecHits
44 
45  // seed basic cluster of initial SC: this will remain in the cleaned SC, by construction
46  const reco::CaloClusterPtr &seed = scluster.seed();
47 
48  // this should be replaced by the 5x5 around the seed; a good approx of how E_seed is defined
49  float seedBCEnergy = (scluster.seed())->energy();
50  float eSeed = 0.35; // standard eSeed in EB ; see CMS IN-2010/008
51  int numBcRemoved = 0;
52 
53  double ClusterE = 0; //Sum of cluster energies for supercluster.
54  //Holders for position of this supercluster.
55  double posX = 0;
56  double posY = 0;
57  double posZ = 0;
58 
60 
61  // looping on basic clusters within the Supercluster
62  for (reco::CaloCluster_iterator bcIt = scluster.clustersBegin(); bcIt != scluster.clustersEnd(); bcIt++) {
63  // E_seed is an Et selection on 5x1 dominoes (around which BC's are built), see CMS IN-2010/008
64  // here such selection is implemented on the full BC around it
65  if ((*bcIt)->energy() >
66  sqrt(eSeed * eSeed + xi * xi * seedBCEnergy * seedBCEnergy / cosh((*bcIt)->eta()) / cosh((*bcIt)->eta()))) {
67  ;
68  } // the sum only of the BC's that pass the Esee selection
69  else {
70  numBcRemoved++;
71  continue;
72  } // count how many basic cluster get removed by the cleaning
73 
74  // if BC passes dynamic selection, include it in the 'cleaned' supercluster
75  thissc.push_back((*bcIt));
76  // cumulate energy and position of the cleaned supercluster
77  ClusterE += (*bcIt)->energy();
78  posX += (*bcIt)->energy() * (*bcIt)->position().X();
79  posY += (*bcIt)->energy() * (*bcIt)->position().Y();
80  posZ += (*bcIt)->energy() * (*bcIt)->position().Z();
81 
82  } // loop on basic clusters of the original SC
83 
84  posX /= ClusterE;
85  posY /= ClusterE;
86  posZ /= ClusterE;
87 
88  // make temporary 'cleaned' supercluster in oder to compute the covariances
89  double Epreshower = scluster.preshowerEnergy();
90  double phiWidth = 0.;
91  double etaWidth = 0.;
92  reco::SuperCluster suCltmp(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
93 
94  // construct cluster shape to compute ieta and iphi covariances of the SC
95  const CaloSubdetectorGeometry *geometry_p = nullptr;
96  if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalBarrel) {
97  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
98  SuperClusterShapeAlgo SCShape(ebRecHits_, geometry_p);
99  SCShape.Calculate_Covariances(suCltmp);
100  phiWidth = SCShape.phiWidth();
101  etaWidth = SCShape.etaWidth();
102  } else if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalEndcap) {
103  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
104  SuperClusterShapeAlgo SCShape(eeRecHits_, geometry_p);
105  SCShape.Calculate_Covariances(suCltmp);
106  phiWidth = SCShape.phiWidth();
107  etaWidth = SCShape.etaWidth();
108  } else {
109  edm::LogError("SeedError")
110  << "The seed crystal of this SC is neither in EB nor in EE. This is a problem. Bailing out";
111  assert(-1);
112  }
113 
114  // return the cleaned supercluster SCluster, with covariances updated
115  return reco::SuperCluster(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
116 }
const EcalRecHitCollection * eeRecHits_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void Calculate_Covariances(const reco::SuperCluster &passedCluster)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
const EcalRecHitCollection * ebRecHits_
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:88
T const * product() const
Definition: Handle.h:70
Log< level::Error, false > LogError
assert(be >=bs)
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:91
T sqrt(T t)
Definition: SSEVec.h:19
void getEBRecHits(const edm::Event &ev)
const edm::EDGetTokenT< EcalRecHitCollection > pEERecHitsToken_
reco::SuperCluster CleanedSuperCluster(float xi, const reco::SuperCluster &cluster, const edm::Event &ev, const edm::EventSetup &es)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:79
const edm::EDGetTokenT< EcalRecHitCollection > pEBRecHitsToken_
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:63
void getEERecHits(const edm::Event &ev)
EcalClusterPUCleaningTools(edm::ConsumesCollector &cc, const edm::InputTag &redEBRecHits, const edm::InputTag &redEERecHits)