CMS 3D CMS Logo

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

#include <PositionCalc.h>

Public Member Functions

math::XYZPoint Calculate_Location (const std::vector< std::pair< DetId, float > > &iDetIds, const EcalRecHitCollection *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 25 of file PositionCalc.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file PositionCalc.cc.

11  :
12  param_LogWeighted_ ( par.getParameter<bool>("LogWeighted")) ,
13  param_T0_barl_ ( par.getParameter<double>("T0_barl")) ,
14  param_T0_endc_ ( par.getParameter<double>("T0_endc")) ,
15  param_T0_endcPresh_ ( par.getParameter<double>("T0_endcPresh")) ,
16  param_W0_ ( par.getParameter<double>("W0")) ,
17  param_X0_ ( par.getParameter<double>("X0")) ,
18  m_esGeom ( 0 ) ,
19  m_esPlus ( false ) ,
20  m_esMinus ( false )
21 {
22 }
T getParameter(std::string const &) const
double param_T0_endc_
Definition: PositionCalc.h:48
double param_W0_
Definition: PositionCalc.h:50
double param_X0_
Definition: PositionCalc.h:51
bool param_LogWeighted_
Definition: PositionCalc.h:46
double param_T0_endcPresh_
Definition: PositionCalc.h:49
double param_T0_barl_
Definition: PositionCalc.h:47
const CaloSubdetectorGeometry * m_esGeom
Definition: PositionCalc.h:53
PositionCalc::PositionCalc ( )
inline

Definition at line 32 of file PositionCalc.h.

32 { };

Member Function Documentation

math::XYZPoint PositionCalc::Calculate_Location ( const std::vector< std::pair< DetId, float > > &  iDetIds,
const EcalRecHitCollection iRecHits,
const CaloSubdetectorGeometry iSubGeom,
const CaloSubdetectorGeometry iESGeom = 0 
)

Definition at line 40 of file PositionCalc.cc.

References EcalBarrel, jptDQMConfig_cff::eMax, edm::SortedCollection< T, SORT >::end(), relval_parameters_module::energy, edm::SortedCollection< T, SORT >::find(), CaloSubdetectorGeometry::getGeometry(), CaloSubdetectorGeometry::getValidDetIds(), j, create_public_lumi_plots::log, LogDebug, m_esGeom, m_esMinus, m_esPlus, max(), n, DetId::null(), param_LogWeighted_, param_T0_barl_, param_T0_endc_, param_T0_endcPresh_, param_W0_, param_X0_, pos, edm::SortedCollection< T, SORT >::size(), DetId::subdetId(), CommonMethods::weight(), and detailsBasic3DVector::z.

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

44 {
45  math::XYZPoint returnValue ( 0, 0, 0 ) ;
46 
47  // Throw an error if the cluster was not initialized properly
48 
49  if( 0 == iRecHits ||
50  0 == iSubGeom )
51  {
52  throw(std::runtime_error("\n\nPositionCalc::Calculate_Location called uninitialized or wrong initialization.\n\n"));
53  }
54 
55  if( 0 != iDetIds.size() &&
56  0 != iRecHits->size() )
57  {
58  typedef std::vector<DetId> DetIdVec ;
59 
60  DetIdVec detIds ;
61  detIds.reserve( iDetIds.size() ) ;
62 
63  double eTot ( 0 ) ;
64  double eMax ( 0 ) ;
65  DetId maxId ;
66 
67  // Check that DetIds are nonzero
68  EcalRecHitCollection::const_iterator endRecHits ( iRecHits->end() ) ;
69  for( std::vector< std::pair<DetId, float> >::const_iterator n ( iDetIds.begin() ) ; n != iDetIds.end() ; ++n )
70  {
71  const DetId dId ( (*n).first ) ;
72  if( !dId.null() )
73  {
74  EcalRecHitCollection::const_iterator iHit ( iRecHits->find( dId ) ) ;
75  if( iHit != endRecHits )
76  {
77  detIds.push_back( dId );
78 
79  const double energy ( iHit->energy() ) ;
80 
81  if( 0 < energy ) // only save positive energies
82  {
83  if( eMax < energy )
84  {
85  eMax = energy ;
86  maxId = dId ;
87  }
88  eTot += energy ;
89  }
90  }
91  }
92  }
93 
94  if( 0 >= eTot )
95  {
96  LogDebug("ZeroClusterEnergy") << "cluster with 0 energy: " << eTot
97  << ", returning (0,0,0)";
98  }
99  else
100  {
101  // first time or when es geom changes set flags
102  if( 0 != iESGeom &&
103  m_esGeom != iESGeom )
104  {
105  m_esGeom = iESGeom ;
106  for( uint32_t ic ( 0 ) ;
107  ( ic != m_esGeom->getValidDetIds().size() ) &&
108  ( (!m_esPlus) || (!m_esMinus) ) ; ++ic )
109  {
110  const double z ( m_esGeom->getGeometry( m_esGeom->getValidDetIds()[ic] )->getPosition().z() ) ;
111  m_esPlus = m_esPlus || ( 0 < z ) ;
112  m_esMinus = m_esMinus || ( 0 > z ) ;
113  }
114  }
115 
116  //Select the correct value of the T0 parameter depending on subdetector
117 
118  const CaloCellGeometry* center_cell ( iSubGeom->getGeometry( maxId ) ) ;
119  const double ctreta (center_cell->getPosition().eta());
120 
121  // for barrel, use barrel T0;
122  // for endcap: if preshower present && in preshower fiducial,
123  // use preshower T0
124  // else use endcap only T0
125 
126  const double preshowerStartEta = 1.653;
127  const int subdet = maxId.subdetId();
128  const double T0 ( subdet == EcalBarrel ? param_T0_barl_ :
129  ( ( ( preshowerStartEta < fabs( ctreta ) ) &&
130  ( ( ( 0 < ctreta ) &&
131  m_esPlus ) ||
132  ( ( 0 > ctreta ) &&
133  m_esMinus ) ) ) ?
135 
136  // Calculate shower depth
137  const float maxDepth ( param_X0_ * ( T0 + log( eTot ) ) ) ;
138  const float maxToFront ( center_cell->getPosition().mag() ) ; // to front face
139 
140  // Loop over hits and get weights
141  double total_weight = 0;
142 
143  double xw ( 0 ) ;
144  double yw ( 0 ) ;
145  double zw ( 0 ) ;
146 
147  for( DetIdVec::const_iterator j ( detIds.begin() ) ; j != detIds.end() ; ++j )
148  {
149  const DetId dId ( *j ) ;
150  EcalRecHitCollection::const_iterator iR ( iRecHits->find( dId ) ) ;
151  const double e_j ( iR->energy() ) ;
152 
153  double weight = 0;
154  if ( param_LogWeighted_ ) {
155  if ( e_j > 0 ) {
156  weight = std::max( 0., param_W0_ + log(e_j/eTot) );
157  } else {
158  weight = 0;
159  }
160  } else {
161  weight = e_j/eTot;
162  }
163 
164  const CaloCellGeometry* cell ( iSubGeom->getGeometry( dId ) ) ;
165  const float depth ( maxDepth + maxToFront - cell->getPosition().mag() ) ;
166 
167  const GlobalPoint pos (
168  dynamic_cast<const TruncatedPyramid*>( cell )->getPosition( depth ) );
169 
170  xw += weight*pos.x() ;
171  yw += weight*pos.y() ;
172  zw += weight*pos.z() ;
173 
174  total_weight += weight ;
175  }
176  returnValue = math::XYZPoint( xw/total_weight,
177  yw/total_weight,
178  zw/total_weight ) ;
179  }
180  }
181  return returnValue ;
182 }
#define LogDebug(id)
double param_T0_endc_
Definition: PositionCalc.h:48
double param_W0_
Definition: PositionCalc.h:50
std::vector< EcalRecHit >::const_iterator const_iterator
double param_X0_
Definition: PositionCalc.h:51
double double double 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:46
double param_T0_endcPresh_
Definition: PositionCalc.h:49
const T & max(const T &a, const T &b)
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:39
const_iterator end() const
Definition: DetId.h:20
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
double param_T0_barl_
Definition: PositionCalc.h:47
iterator find(key_type k)
size_type size() const
const CaloSubdetectorGeometry * m_esGeom
Definition: PositionCalc.h:53
const PositionCalc & PositionCalc::operator= ( const PositionCalc rhs)

Definition at line 24 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_.

25 {
30  param_W0_ = rhs.param_W0_;
31  param_X0_ = rhs.param_X0_;
32 
33  m_esGeom = rhs.m_esGeom ;
34  m_esPlus = rhs.m_esPlus ;
35  m_esMinus = rhs.m_esMinus ;
36  return *this;
37 }
double param_T0_endc_
Definition: PositionCalc.h:48
double param_W0_
Definition: PositionCalc.h:50
double param_X0_
Definition: PositionCalc.h:51
bool param_LogWeighted_
Definition: PositionCalc.h:46
double param_T0_endcPresh_
Definition: PositionCalc.h:49
double param_T0_barl_
Definition: PositionCalc.h:47
const CaloSubdetectorGeometry * m_esGeom
Definition: PositionCalc.h:53

Member Data Documentation

const CaloSubdetectorGeometry* PositionCalc::m_esGeom
private

Definition at line 53 of file PositionCalc.h.

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

bool PositionCalc::m_esMinus
private

Definition at line 55 of file PositionCalc.h.

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

bool PositionCalc::m_esPlus
private

Definition at line 54 of file PositionCalc.h.

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

bool PositionCalc::param_LogWeighted_
private

Definition at line 46 of file PositionCalc.h.

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

double PositionCalc::param_T0_barl_
private

Definition at line 47 of file PositionCalc.h.

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

double PositionCalc::param_T0_endc_
private

Definition at line 48 of file PositionCalc.h.

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

double PositionCalc::param_T0_endcPresh_
private

Definition at line 49 of file PositionCalc.h.

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

double PositionCalc::param_W0_
private

Definition at line 50 of file PositionCalc.h.

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

double PositionCalc::param_X0_
private

Definition at line 51 of file PositionCalc.h.

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