CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  const CaloCellGeometry *this_cell = geometry_->getGeometry(rHit->id());
39  if ( this_cell == 0 ) {
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:126
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:192
const CaloSubdetectorGeometry * geometry_
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
list denominator
Definition: cuy.py:484
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T sqrt(T t)
Definition: SSEVec.h:48
double energy() const
cluster energy
Definition: CaloCluster.h:121
const_iterator end() const
const EcalRecHitCollection * recHits_
T eta() const
Definition: PV3DBase.h:76
iterator find(key_type k)
double pi()
Definition: Pi.h:31
static int position[264][3]
Definition: ReadPGInfo.cc:509
double twoPi()
Definition: Pi.h:32
SuperClusterShapeAlgo(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.