CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
PositionCalc Class Reference

#include <PositionCalc.h>

Public Types

typedef std::vector< std::pair
< DetId, double > > 
HitsAndEnergies
 
typedef std::vector< std::pair
< DetId, float > > 
HitsAndFractions
 

Public Member Functions

template<typename HitType >
math::XYZPoint Calculate_Location (const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
 
const PositionCalcoperator= (const PositionCalc &rhs)
 
 PositionCalc (const edm::ParameterSet &par)
 
 PositionCalc ()
 

Private Attributes

const CaloSubdetectorGeometrym_esGeom
 
bool m_esMinus
 
bool m_esPlus
 
bool param_LogWeighted_
 
double param_T0_barl_
 
double param_T0_endc_
 
double param_T0_endcPresh_
 
double param_W0_
 
double param_X0_
 

Detailed Description

Definition at line 29 of file PositionCalc.h.

Member Typedef Documentation

typedef std::vector< std::pair<DetId,double> > PositionCalc::HitsAndEnergies

Definition at line 33 of file PositionCalc.h.

typedef std::vector< std::pair<DetId,float> > PositionCalc::HitsAndFractions

Definition at line 32 of file PositionCalc.h.

Constructor & Destructor Documentation

PositionCalc::PositionCalc ( const edm::ParameterSet par)

Definition at line 4 of file PositionCalc.cc.

4  :
5  param_LogWeighted_ ( par.getParameter<bool>("LogWeighted")) ,
6  param_T0_barl_ ( par.getParameter<double>("T0_barl")) ,
7  param_T0_endc_ ( par.getParameter<double>("T0_endc")) ,
8  param_T0_endcPresh_ ( par.getParameter<double>("T0_endcPresh")) ,
9  param_W0_ ( par.getParameter<double>("W0")) ,
10  param_X0_ ( par.getParameter<double>("X0")) ,
11  m_esGeom ( 0 ) ,
12  m_esPlus ( false ) ,
13  m_esMinus ( false )
14 {
15 }
T getParameter(std::string const &) const
double param_T0_endc_
Definition: PositionCalc.h:55
double param_W0_
Definition: PositionCalc.h:57
double param_X0_
Definition: PositionCalc.h:58
bool param_LogWeighted_
Definition: PositionCalc.h:53
double param_T0_endcPresh_
Definition: PositionCalc.h:56
double param_T0_barl_
Definition: PositionCalc.h:54
const CaloSubdetectorGeometry * m_esGeom
Definition: PositionCalc.h:60
PositionCalc::PositionCalc ( )
inline

Definition at line 38 of file PositionCalc.h.

38 { };

Member Function Documentation

template<typename HitType >
math::XYZPoint PositionCalc::Calculate_Location ( const HitsAndFractions iDetIds,
const edm::SortedCollection< HitType > *  iRecHits,
const CaloSubdetectorGeometry iSubGeom,
const CaloSubdetectorGeometry iESGeom = 0 
)

Definition at line 68 of file PositionCalc.h.

References HLT_25ns14e33_v1_cff::depth, EcalBarrel, edm::SortedCollection< T, SORT >::end(), relval_parameters_module::energy, edm::hlt::Exception, edm::SortedCollection< T, SORT >::find(), cropTnPTrees::frac, CaloSubdetectorGeometry::getGeometry(), CaloSubdetectorGeometry::getValidDetIds(), j, cmsBatch::log, LogDebug, m_esGeom, m_esMinus, m_esPlus, bookConverter::max, HLT_25ns14e33_v1_cff::maxDepth, gen::n, DetId::null(), param_LogWeighted_, param_T0_barl_, param_T0_endc_, param_T0_endcPresh_, param_W0_, param_X0_, edm::SortedCollection< T, SORT >::size(), DetId::subdetId(), histoStyle::weight, detailsBasic3DVector::z, and zw().

Referenced by DQMSourcePi0::analyze(), HLTAlCa::analyze(), HybridClusterAlgo::e2Et(), HybridClusterAlgo::et25(), PhotonProducer::fillPhotonCollection(), Multi5x5ClusterAlgo::mainSearch(), HybridClusterAlgo::mainSearch(), IslandClusterAlgo::makeCluster(), CosmicClusterAlgo::makeCluster(), Multi5x5ClusterAlgo::makeCluster(), EgammaHLTNxNClusterProducer::makeNxNClusters(), and PiZeroAnalyzer::makePizero().

71  {
72  typedef edm::SortedCollection<HitType> HitTypeCollection;
73  math::XYZPoint returnValue ( 0, 0, 0 ) ;
74 
75  // Throw an error if the cluster was not initialized properly
76 
77  if( 0 == iRecHits || 0 == iSubGeom ) {
78  throw cms::Exception("PositionCalc")
79  << "Calculate_Location() called uninitialized or wrong initialization.";
80  }
81 
82  if( 0 != iDetIds.size() &&
83  0 != iRecHits->size() ) {
84 
85  HitsAndEnergies detIds;
86  detIds.reserve( iDetIds.size() ) ;
87 
88  double eTot ( 0 ) ;
89  double eMax ( 0 ) ;
90  DetId maxId ;
91 
92  // Check that DetIds are nonzero
93  typename HitTypeCollection::const_iterator endRecHits ( iRecHits->end() ) ;
94  HitsAndFractions::const_iterator n, endDiDs( iDetIds.end() );
95  for( n = iDetIds.begin(); n != endDiDs ; ++n ) {
96  const DetId dId ( (*n).first ) ;
97  const float frac( (*n).second) ;
98  if( !dId.null() ) {
99  typename HitTypeCollection::const_iterator iHit ( iRecHits->find( dId ) ) ;
100  if( iHit != endRecHits ) {
101  const double energy ( iHit->energy() *frac ) ;
102  detIds.push_back( std::make_pair(dId,energy) );
103  if( 0.0 < energy ) { // only save positive energies
104  if( eMax < energy ) {
105  eMax = energy ;
106  maxId = dId ;
107  }
108  eTot += energy ;
109  }
110  }
111  }
112  }
113 
114  if( 0.0 >= eTot ) {
115  LogDebug("ZeroClusterEnergy") << "cluster with 0 energy: "
116  << eTot << " size: " << detIds.size()
117  << " , returning (0,0,0)";
118  } else {
119  // first time or when es geom changes set flags
120  if( 0 != iESGeom && m_esGeom != iESGeom ) {
121  m_esGeom = iESGeom ;
122  for( uint32_t ic ( 0 ) ;
123  ( ic != m_esGeom->getValidDetIds().size() ) &&
124  ( (!m_esPlus) || (!m_esMinus) ) ; ++ic ) {
125  const double z ( m_esGeom->getGeometry( m_esGeom->getValidDetIds()[ic] )->getPosition().z() ) ;
126  m_esPlus = m_esPlus || ( 0 < z ) ;
127  m_esMinus = m_esMinus || ( 0 > z ) ;
128  }
129  }
130 
131  //Select the correct value of the T0 parameter depending on subdetector
132  const CaloCellGeometry* center_cell ( iSubGeom->getGeometry( maxId ) ) ;
133  const double ctreta (center_cell->getPosition().eta());
134 
135  // for barrel, use barrel T0;
136  // for endcap: if preshower present && in preshower fiducial,
137  // use preshower T0
138  // else use endcap only T0
139  const double preshowerStartEta = 1.653;
140  const int subdet = maxId.subdetId();
141  const double T0 ( subdet == EcalBarrel ? param_T0_barl_ :
142  ( ( ( preshowerStartEta < fabs( ctreta ) ) &&
143  ( ( ( 0 < ctreta ) &&
144  m_esPlus ) ||
145  ( ( 0 > ctreta ) &&
146  m_esMinus ) ) ) ?
148 
149  // Calculate shower depth
150  const float maxDepth ( param_X0_ * ( T0 + log( eTot ) ) ) ;
151  const float maxToFront ( center_cell->getPosition().mag() ) ; // to front face
152 
153  // Loop over hits and get weights
154  double total_weight = 0;
155  const double eTot_inv = 1.0/eTot;
156  const double logETot_inv = ( param_LogWeighted_ ? log(eTot_inv) : 0 );
157 
158  double xw ( 0 ) ;
159  double yw ( 0 ) ;
160  double zw ( 0 ) ;
161 
162 
163  HitsAndEnergies::const_iterator j, hAndE_end = detIds.end();
164  for( j = detIds.begin() ; j != hAndE_end ; ++j ) {
165  const DetId dId ( (*j).first ) ;
166  const double e_j( (*j).second ) ;
167 
168  double weight = 0;
169  if ( param_LogWeighted_ ) {
170  if ( e_j > 0.0 ) {
171  weight = std::max( 0., param_W0_ + log(e_j) + logETot_inv );
172  } else {
173  weight = 0;
174  }
175  } else {
176  weight = e_j*eTot_inv;
177  }
178 
179  const CaloCellGeometry* cell ( iSubGeom->getGeometry( dId ) ) ;
180  const float depth ( maxDepth + maxToFront - cell->getPosition().mag() ) ;
181 
182  const GlobalPoint pos (static_cast<const TruncatedPyramid*>( cell )->getPosition( depth ) );
183 
184  xw += weight*pos.x() ;
185  yw += weight*pos.y() ;
186  zw += weight*pos.z() ;
187 
188  total_weight += weight ;
189  }
190  returnValue = math::XYZPoint( xw/total_weight,
191  yw/total_weight,
192  zw/total_weight ) ;
193  }
194  }
195  return returnValue ;
196 }
#define LogDebug(id)
double param_T0_endc_
Definition: PositionCalc.h:55
double param_W0_
Definition: PositionCalc.h:57
auto zw(V v) -> Vec2< typenamestd::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:62
double param_X0_
Definition: PositionCalc.h:58
float float float z
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
bool param_LogWeighted_
Definition: PositionCalc.h:53
double param_T0_endcPresh_
Definition: PositionCalc.h:56
int j
Definition: DBlmapReader.cc:9
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::vector< std::pair< DetId, double > > HitsAndEnergies
Definition: PositionCalc.h:33
const_iterator end() const
Definition: DetId.h:18
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double param_T0_barl_
Definition: PositionCalc.h:54
iterator find(key_type k)
size_type size() const
const CaloSubdetectorGeometry * m_esGeom
Definition: PositionCalc.h:60
int weight
Definition: histoStyle.py:50
tuple log
Definition: cmsBatch.py:347
const PositionCalc & PositionCalc::operator= ( const PositionCalc rhs)

Definition at line 17 of file PositionCalc.cc.

References m_esGeom, m_esMinus, m_esPlus, param_LogWeighted_, param_T0_barl_, param_T0_endc_, param_T0_endcPresh_, param_W0_, and param_X0_.

18 {
23  param_W0_ = rhs.param_W0_;
24  param_X0_ = rhs.param_X0_;
25 
26  m_esGeom = rhs.m_esGeom ;
27  m_esPlus = rhs.m_esPlus ;
28  m_esMinus = rhs.m_esMinus ;
29  return *this;
30 }
double param_T0_endc_
Definition: PositionCalc.h:55
double param_W0_
Definition: PositionCalc.h:57
double param_X0_
Definition: PositionCalc.h:58
bool param_LogWeighted_
Definition: PositionCalc.h:53
double param_T0_endcPresh_
Definition: PositionCalc.h:56
double param_T0_barl_
Definition: PositionCalc.h:54
const CaloSubdetectorGeometry * m_esGeom
Definition: PositionCalc.h:60

Member Data Documentation

const CaloSubdetectorGeometry* PositionCalc::m_esGeom
private

Definition at line 60 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

bool PositionCalc::m_esMinus
private

Definition at line 62 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

bool PositionCalc::m_esPlus
private

Definition at line 61 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

bool PositionCalc::param_LogWeighted_
private

Definition at line 53 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

double PositionCalc::param_T0_barl_
private

Definition at line 54 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

double PositionCalc::param_T0_endc_
private

Definition at line 55 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

double PositionCalc::param_T0_endcPresh_
private

Definition at line 56 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

double PositionCalc::param_W0_
private

Definition at line 57 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().

double PositionCalc::param_X0_
private

Definition at line 58 of file PositionCalc.h.

Referenced by Calculate_Location(), and operator=().