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 
52  double ClusterE = 0; //Sum of cluster energies for supercluster.
53  //Holders for position of this supercluster.
54  double posX = 0;
55  double posY = 0;
56  double posZ = 0;
57 
59 
60  // looping on basic clusters within the Supercluster
61  for (reco::CaloCluster_iterator bcIt = scluster.clustersBegin(); bcIt != scluster.clustersEnd(); bcIt++) {
62  // E_seed is an Et selection on 5x1 dominoes (around which BC's are built), see CMS IN-2010/008
63  // here such selection is implemented on the full BC around it
64  if ((*bcIt)->energy() >
65  sqrt(eSeed * eSeed + xi * xi * seedBCEnergy * seedBCEnergy / cosh((*bcIt)->eta()) / cosh((*bcIt)->eta()))) {
66  ;
67  } // the sum only of the BC's that pass the Esee selection
68 
69  // if BC passes dynamic selection, include it in the 'cleaned' supercluster
70  thissc.push_back((*bcIt));
71  // cumulate energy and position of the cleaned supercluster
72  ClusterE += (*bcIt)->energy();
73  posX += (*bcIt)->energy() * (*bcIt)->position().X();
74  posY += (*bcIt)->energy() * (*bcIt)->position().Y();
75  posZ += (*bcIt)->energy() * (*bcIt)->position().Z();
76 
77  } // loop on basic clusters of the original SC
78 
79  posX /= ClusterE;
80  posY /= ClusterE;
81  posZ /= ClusterE;
82 
83  // make temporary 'cleaned' supercluster in oder to compute the covariances
84  double Epreshower = scluster.preshowerEnergy();
85  double phiWidth = 0.;
86  double etaWidth = 0.;
87  reco::SuperCluster suCltmp(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
88 
89  // construct cluster shape to compute ieta and iphi covariances of the SC
90  const CaloSubdetectorGeometry *geometry_p = nullptr;
91  if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalBarrel) {
92  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
93  SuperClusterShapeAlgo SCShape(ebRecHits_, geometry_p);
94  SCShape.Calculate_Covariances(suCltmp);
95  phiWidth = SCShape.phiWidth();
96  etaWidth = SCShape.etaWidth();
97  } else if (seed->seed().det() == DetId::Ecal && seed->seed().subdetId() == EcalEndcap) {
98  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
99  SuperClusterShapeAlgo SCShape(eeRecHits_, geometry_p);
100  SCShape.Calculate_Covariances(suCltmp);
101  phiWidth = SCShape.phiWidth();
102  etaWidth = SCShape.etaWidth();
103  } else {
104  edm::LogError("SeedError")
105  << "The seed crystal of this SC is neither in EB nor in EE. This is a problem. Bailing out";
106  assert(-1);
107  }
108 
109  // return the cleaned supercluster SCluster, with covariances updated
110  return reco::SuperCluster(ClusterE, math::XYZPoint(posX, posY, posZ), seed, thissc, Epreshower, phiWidth, etaWidth);
111 }
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)