CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
pftools::CaloWindow Class Reference

#include <CaloWindow.h>

Public Member Functions

bool addHit (double eta, double phi, double energy)
 
double baryEta () const
 
double baryPhi () const
 
 CaloWindow ()
 
 CaloWindow (double eta, double phi, unsigned nRings, double deltaR, unsigned nPanes, double axis=0.0)
 
std::map< unsigned, CaloRing > const & getRingDepositions () const
 
std::map< unsigned, double > getRingEnergySummations () const
 
void init (double eta, double phi, unsigned nRings, double deltaR, unsigned nPanes, double axis=0.0)
 
void printEnergies (std::ostream &s, double range=1.0)
 
void reset ()
 
std::vector< double > stream (double normalisation=1.0) const
 
virtual ~CaloWindow ()
 

Private Member Functions

std::pair< unsigned, unsigned > relativePosition (double eta, double phi) const
 

Private Attributes

double axis_
 
double baryEta_
 
double baryPhi_
 
double deltaR_
 
std::map< unsigned, CaloRingenergies_
 
unsigned nPanes_
 
unsigned nRings_
 

Detailed Description

Definition at line 93 of file CaloWindow.h.

Constructor & Destructor Documentation

CaloWindow::CaloWindow ( )

Definition at line 123 of file CaloWindow.cc.

123  :
124  baryEta_(0.0), baryPhi_(0.0), nRings_(1), deltaR_(0.1), nPanes_(1), axis_(0.0) {
125 
126 }
CaloWindow::CaloWindow ( double  eta,
double  phi,
unsigned  nRings,
double  deltaR,
unsigned  nPanes,
double  axis = 0.0 
)

Create a circular calo window centred on eta, phi, with nRings of size deltaR.

Definition at line 128 of file CaloWindow.cc.

References init().

128  {
129 
130  init(eta, phi, nRings, deltaR, nPanes, axis);
131 }
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void init(double eta, double phi, unsigned nRings, double deltaR, unsigned nPanes, double axis=0.0)
Definition: CaloWindow.cc:137
CaloWindow::~CaloWindow ( )
virtual

Definition at line 155 of file CaloWindow.cc.

155  {
156 
157 }

Member Function Documentation

bool CaloWindow::addHit ( double  eta,
double  phi,
double  energy 
)

Adds a hit contribution. If eta, phi are outside the window, this method returns false and does not add the energy to the window.

If ok, it returns true.

Definition at line 225 of file CaloWindow.cc.

References pftools::CaloRing::addEnergy(), EnergyCorrector::c, energies_, nRings_, position, and relativePosition().

Referenced by pftools::TestCaloWindow::doTest(), and pftools::Calibratable::fillCaloWindow().

225  {
226 
227  std::pair<unsigned, unsigned> position = relativePosition(eta, phi);
228  if (position.first >= nRings_) {
229 /* double dEta = eta - baryEta_;
230  double dPhi = deltaPhi(phi, baryPhi_);
231  double dR = deltaR(eta, phi, baryEta_, baryPhi_);
232  LogDebug("CaloWindow")
233  << "Hit is outside my range - it would be in ring "
234  << position.first << ", with dR = " << dR << std::endl;*/
235  return false;
236  }
237 // std::cout << "Adding hit to ring " << position.first << " in position "
238 // << position.second << " with energy " << energy << "\n";
239 
240  CaloRing& c = energies_[position.first];
241  c.addEnergy(position.second, energy);
242 
243  return true;
244 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
bool addEnergy(unsigned pane, double energy)
Definition: CaloWindow.cc:36
std::pair< unsigned, unsigned > relativePosition(double eta, double phi) const
Definition: CaloWindow.cc:159
static int position[264][3]
Definition: ReadPGInfo.cc:509
double pftools::CaloWindow::baryEta ( ) const
inline

Definition at line 141 of file CaloWindow.h.

Referenced by pftools::operator<<().

141 {return baryEta_;}
double pftools::CaloWindow::baryPhi ( ) const
inline

Definition at line 142 of file CaloWindow.h.

Referenced by pftools::operator<<().

142 { return baryPhi_;}
std::map<unsigned, CaloRing> const& pftools::CaloWindow::getRingDepositions ( ) const
inline

Return a vector of vectors: Each inner vector corresponds to a ring of window panes around the barycentre and the first entry of the bary centre itself

Definition at line 121 of file CaloWindow.h.

References pftools::CaloRing::printEnergies(), pftools::CaloRing::reset(), and alignCSCRings::s.

Referenced by pftools::operator<<().

121  {
122  return energies_;
123  }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
std::map< unsigned, double > CaloWindow::getRingEnergySummations ( ) const

Definition at line 245 of file CaloWindow.cc.

References submit::answer, and energies_.

245  {
246  std::map<unsigned, double> answer;
247  for (std::map<unsigned, CaloRing>::const_iterator cit = energies_.begin(); cit
248  != energies_.end(); ++cit) {
249  std::pair<unsigned, CaloRing> pair = *cit;
250  answer[pair.first] = pair.second.totalE();
251  }
252 
253  return answer;
254 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
answer
Definition: submit.py:44
void CaloWindow::init ( double  eta,
double  phi,
unsigned  nRings,
double  deltaR,
unsigned  nPanes,
double  axis = 0.0 
)

Definition at line 137 of file CaloWindow.cc.

References axis_, baryEta_, baryPhi_, EnergyCorrector::c, deltaR(), deltaR_, energies_, PVValHelper::eta, nPanes_, nRings_, and alignCSCRings::r.

Referenced by CaloWindow().

137  {
138  baryEta_ = eta;
139  baryPhi_ = phi;
140  nRings_ = nRings;
141  deltaR_ = deltaR;
142  nPanes_ = nPanes;
143  axis_ = axis;
144 
145  energies_.clear();
146  CaloRing c(1);
147  energies_[0] = c;
148  for (unsigned j(1); j < nRings_; ++j) {
149 
150  CaloRing r(nPanes);
151  energies_[j] = r;
152  }
153 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void CaloWindow::printEnergies ( std::ostream &  s,
double  range = 1.0 
)

Definition at line 112 of file CaloWindow.cc.

References EnergyCorrector::c, and pftools::CaloRing::printEnergies().

112  {
113 
114  for (std::map<unsigned, pftools::CaloRing>::const_iterator cit =
115  energies_.begin(); cit != energies_.end(); ++cit) {
116  CaloRing c = (*cit).second;
117  c.printEnergies(s, range);
118  s << "\t";
119  }
120 
121 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
void printEnergies(std::ostream &s, double range=1.0)
Definition: CaloWindow.cc:60
std::pair< unsigned, unsigned > CaloWindow::relativePosition ( double  eta,
double  phi 
) const
private

Definition at line 159 of file CaloWindow.cc.

References axis_, baryEta_, baryPhi_, hiPixelPairStep_cff::deltaPhi, deltaR(), deltaR_, particleFlow_cfi::dEta, particleFlow_cfi::dPhi, PATTauDiscriminationAgainstElectronDeadECAL_cfi::dR, energies_, nRings_, Pi, relativeConstraints::ring, and edm::second().

Referenced by addHit().

160  {
161  //How far is this hit from the barycentre in deltaR?
162  double dEta = eta - baryEta_;
163  double dPhi = deltaPhi(phi, baryPhi_);
164 
165  double dR = deltaR(eta, phi, baryEta_, baryPhi_);
166 
167  unsigned ring = static_cast<unsigned> (floor(dR / deltaR_));
168 
169  if (ring == 0) {
170  //LogDebug("CaloWindow") << "Relative position: adding to central ring\n";
171  return std::pair<unsigned, unsigned>(0, 0);
172  }
173 
174  if (ring >= nRings_) {
175  return std::pair<unsigned, unsigned>(ring, 0);
176  }
177 
178  double dTheta = 0;
179 
180  if (dEta > 0) {
181  if (dPhi > 0)
182  dTheta = TMath::ATan(dPhi / dEta);
183  else
184  dTheta = 2 * TMath::Pi() + TMath::ATan(dPhi / dEta);
185  } else {
186  if (dPhi > 0)
187  dTheta = TMath::Pi() + TMath::ATan(dPhi / dEta);
188  else
189  dTheta = TMath::Pi() + TMath::ATan(dPhi / dEta);
190  }
191  //Rotation. Rotate theta into axis of caloWindow
192  // and also by half a window pane.
193  //TODO: bug check!!
194  //double dThetaOrig(dTheta);
195  double paneOn2 = TMath::Pi() / (*energies_.find(ring)).second.getNPanes();
196  dTheta = dTheta - axis_ - paneOn2;
197  //Original theta between 0 and 2 Pi, but transform above might move us beyond this, so...
198  //double dThetaCopy(dTheta);
199  //std::cout << "dTheta " << dThetaOrig << ", axis " << axis_ << ", paneOn2 " << paneOn2 << ", thetaPrime " << dTheta << "\n";
200  if(dTheta > 2 *TMath::Pi()) {
201  //std::cout << "To infinity and beyond...\n";
202  while(dTheta > 2 * TMath::Pi()) {
203  dTheta -= 2 * TMath::Pi();
204  //std::cout << "dTheta1 " << dTheta << "\n";
205  }
206  }
207  else if (dTheta < 0) {
208  //std::cout << "To infinity and beyond 2... dTheta = " << dTheta << "\n";
209  while(dTheta < 0) {
210  dTheta += 2 * TMath::Pi();
211  //std::cout << "dTheta2 " << dTheta << "\n";
212  }
213  }
214 
215 // std::cout << "\tdTheta is " << dTheta << " rad \n";
216  unsigned division = static_cast<unsigned> (floor((*energies_.find(ring)).second.getNPanes() * dTheta
217  / (TMath::Pi() * 2)));
218  //LogDebug("CaloWindow") << "Ring is " << ring << ", pane is "
219  // << division << "\n";
220 
221  return std::pair<unsigned, unsigned>(ring, division);
222 
223 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
const double Pi
U second(std::pair< T, U > const &p)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void CaloWindow::reset ( void  )

Definition at line 133 of file CaloWindow.cc.

References energies_.

Referenced by pftools::CandidateWrapper::reset(), and pftools::Calibratable::reset().

133  {
134  energies_.clear();
135 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
vector< double > CaloWindow::stream ( double  normalisation = 1.0) const

Collapses all energies in all CaloRings into one vector of doubles

Parameters
normalisation- divide each energy by this value
Returns
a vector of doubles

Definition at line 94 of file CaloWindow.cc.

References EnergyCorrector::c, mps_splice::entry, pftools::CaloRing::getEnergies(), and mps_fire::i.

94  {
95  vector<double> stream;
96  for (map<unsigned, pftools::CaloRing>::const_iterator cit =
97  energies_.begin(); cit != energies_.end(); ++cit) {
98  CaloRing c = (*cit).second;
99  std::vector<double> ringE = c.getEnergies();
100  stream.insert(stream.end(), ringE.begin(), ringE.end());
101  }
102  if(normalisation != 1.0){
103  for(vector<double>::iterator i = stream.begin(); i != stream.end(); ++i) {
104  double& entry = *i;
105  entry /= normalisation;
106  }
107  }
108  return stream;
109 
110 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:165
std::vector< double > stream(double normalisation=1.0) const
Definition: CaloWindow.cc:94
std::vector< double > const & getEnergies() const
Definition: CaloWindow.h:71

Member Data Documentation

double pftools::CaloWindow::axis_
private

Definition at line 156 of file CaloWindow.h.

Referenced by init(), and relativePosition().

double pftools::CaloWindow::baryEta_
private

Definition at line 146 of file CaloWindow.h.

Referenced by init(), and relativePosition().

double pftools::CaloWindow::baryPhi_
private

Definition at line 147 of file CaloWindow.h.

Referenced by init(), and relativePosition().

double pftools::CaloWindow::deltaR_
private

Definition at line 151 of file CaloWindow.h.

Referenced by init(), and relativePosition().

std::map<unsigned, CaloRing> pftools::CaloWindow::energies_
private

Definition at line 165 of file CaloWindow.h.

Referenced by addHit(), getRingEnergySummations(), init(), relativePosition(), and reset().

unsigned pftools::CaloWindow::nPanes_
private

Definition at line 153 of file CaloWindow.h.

Referenced by init().

unsigned pftools::CaloWindow::nRings_
private

Definition at line 149 of file CaloWindow.h.

Referenced by addHit(), init(), and relativePosition().