CMS 3D CMS Logo

SuperClusterShapeAlgo.cc
Go to the documentation of this file.
1 #include <iostream>
2 
9 
13 
15  const CaloSubdetectorGeometry* geo) :
16  recHits_(hits), geometry_(geo) { }
17 
19 {
20  double numeratorEtaWidth = 0;
21  double numeratorPhiWidth = 0;
22 
23  double scEnergy = passedCluster.energy();
24  double denominator = scEnergy;
25 
26  double scEta = passedCluster.position().eta();
27  double scPhi = passedCluster.position().phi();
28 
29  const std::vector<std::pair<DetId,float> > &detId = passedCluster.hitsAndFractions();
30  // Loop over recHits associated with the given SuperCluster
31  for (std::vector<std::pair<DetId,float> >::const_iterator hit = detId.begin();
32  hit != detId.end(); ++hit) {
34  //FIXME: THIS IS JUST A WORKAROUND A FIX SHOULD BE APPLIED
35  if(rHit == recHits_->end()) {
36  continue;
37  }
38  auto this_cell = geometry_->getGeometry(rHit->id());
39  if ( this_cell == nullptr ) {
40  //edm::LogInfo("SuperClusterShapeAlgo") << "pointer to the cell in Calculate_Covariances is NULL!";
41  continue;
42  }
43  GlobalPoint position = this_cell->getPosition();
44  //take into account energy fractions
45  double energyHit = rHit->energy()*hit->second;
46 
47  //form differences
48  double dPhi = position.phi() - scPhi;
49  if (dPhi > + Geom::pi()) { dPhi = Geom::twoPi() - dPhi; }
50  if (dPhi < - Geom::pi()) { dPhi = Geom::twoPi() + dPhi; }
51 
52  double dEta = position.eta() - scEta;
53 
54  if ( energyHit > 0 ) {
55  numeratorEtaWidth += energyHit * dEta * dEta;
56  numeratorPhiWidth += energyHit * dPhi * dPhi;
57  }
58 
59  etaWidth_ = sqrt(numeratorEtaWidth / denominator);
60  phiWidth_ = sqrt(numeratorPhiWidth / denominator);
61  }
62 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
void Calculate_Covariances(const reco::SuperCluster &passedCluster)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
const CaloSubdetectorGeometry * geometry_
T sqrt(T t)
Definition: SSEVec.h:18
double energy() const
cluster energy
Definition: CaloCluster.h:126
const_iterator end() const
const EcalRecHitCollection * recHits_
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
static int position[264][3]
Definition: ReadPGInfo.cc:509
SuperClusterShapeAlgo(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
constexpr double pi()
Definition: Pi.h:31
constexpr double twoPi()
Definition: Pi.h:32