#include <CaloWindow.h>
Public Member Functions | |
bool | addHit (double eta, double phi, double energy) |
CaloWindow () | |
CaloWindow (double eta, double phi, unsigned nRings, double deltaR, unsigned nPanes, double axis=0.0) | |
std::map< unsigned, CaloRing > | 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, CaloRing > | energies_ |
unsigned | nPanes_ |
unsigned | nRings_ |
Friends | |
std::ostream & | operator<< (std::ostream &s, const CaloWindow &caloWindow) |
Definition at line 94 of file CaloWindow.h.
CaloWindow::CaloWindow | ( | ) |
CaloWindow::CaloWindow | ( | double | eta, |
double | phi, | ||
unsigned | nRings, | ||
double | deltaR, | ||
unsigned | nPanes, | ||
double | axis = 0.0 |
||
) |
CaloWindow::~CaloWindow | ( | ) | [virtual] |
Definition at line 156 of file CaloWindow.cc.
{ }
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 226 of file CaloWindow.cc.
References pftools::CaloRing::addEnergy(), trackerHits::c, energies_, nRings_, position, and relativePosition().
Referenced by pftools::TestCaloWindow::doTest(), and pftools::Calibratable::fillCaloWindow().
{ std::pair<unsigned, unsigned> position = relativePosition(eta, phi); if (position.first >= nRings_) { /* double dEta = eta - baryEta_; double dPhi = deltaPhi(phi, baryPhi_); double dR = deltaR(eta, phi, baryEta_, baryPhi_); LogDebug("CaloWindow") << "Hit is outside my range - it would be in ring " << position.first << ", with dR = " << dR << std::endl;*/ return false; } // std::cout << "Adding hit to ring " << position.first << " in position " // << position.second << " with energy " << energy << "\n"; CaloRing& c = energies_[position.first]; c.addEnergy(position.second, energy); return true; }
std::map<unsigned, CaloRing> 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 122 of file CaloWindow.h.
References energies_.
{ return energies_; }
std::map< unsigned, double > CaloWindow::getRingEnergySummations | ( | ) | const |
Definition at line 246 of file CaloWindow.cc.
References submit::answer, and energies_.
void CaloWindow::init | ( | double | eta, |
double | phi, | ||
unsigned | nRings, | ||
double | deltaR, | ||
unsigned | nPanes, | ||
double | axis = 0.0 |
||
) |
Definition at line 138 of file CaloWindow.cc.
References axis_, baryEta_, baryPhi_, trackerHits::c, deltaR(), deltaR_, energies_, eta(), j, nPanes_, nRings_, phi, and csvReporter::r.
Referenced by CaloWindow().
void CaloWindow::printEnergies | ( | std::ostream & | s, |
double | range = 1.0 |
||
) |
Definition at line 113 of file CaloWindow.cc.
References trackerHits::c, energies_, and pftools::CaloRing::printEnergies().
std::pair< unsigned, unsigned > CaloWindow::relativePosition | ( | double | eta, |
double | phi | ||
) | const [private] |
Definition at line 160 of file CaloWindow.cc.
References axis_, baryEta_, baryPhi_, Geom::deltaPhi(), deltaR(), deltaR_, dPhi(), energies_, nRings_, Pi, relativeConstraints::ring, and edm::second().
Referenced by addHit().
{ //How far is this hit from the barycentre in deltaR? double dEta = eta - baryEta_; double dPhi = deltaPhi(phi, baryPhi_); double dR = deltaR(eta, phi, baryEta_, baryPhi_); unsigned ring = static_cast<unsigned> (floor(dR / deltaR_)); if (ring == 0) { //LogDebug("CaloWindow") << "Relative position: adding to central ring\n"; return std::pair<unsigned, unsigned>(0, 0); } if (ring >= nRings_) { return std::pair<unsigned, unsigned>(ring, 0); } double dTheta = 0; if (dEta > 0) { if (dPhi > 0) dTheta = TMath::ATan(dPhi / dEta); else dTheta = 2 * TMath::Pi() + TMath::ATan(dPhi / dEta); } else { if (dPhi > 0) dTheta = TMath::Pi() + TMath::ATan(dPhi / dEta); else dTheta = TMath::Pi() + TMath::ATan(dPhi / dEta); } //Rotation. Rotate theta into axis of caloWindow // and also by half a window pane. //TODO: bug check!! //double dThetaOrig(dTheta); double paneOn2 = TMath::Pi() / (*energies_.find(ring)).second.getNPanes(); dTheta = dTheta - axis_ - paneOn2; //Original theta between 0 and 2 Pi, but transform above might move us beyond this, so... //double dThetaCopy(dTheta); //std::cout << "dTheta " << dThetaOrig << ", axis " << axis_ << ", paneOn2 " << paneOn2 << ", thetaPrime " << dTheta << "\n"; if(dTheta > 2 *TMath::Pi()) { //std::cout << "To infinity and beyond...\n"; while(dTheta > 2 * TMath::Pi()) { dTheta -= 2 * TMath::Pi(); //std::cout << "dTheta1 " << dTheta << "\n"; } } else if (dTheta < 0) { //std::cout << "To infinity and beyond 2... dTheta = " << dTheta << "\n"; while(dTheta < 0) { dTheta += 2 * TMath::Pi(); //std::cout << "dTheta2 " << dTheta << "\n"; } } // std::cout << "\tdTheta is " << dTheta << " rad \n"; unsigned division = static_cast<unsigned> (floor((*energies_.find(ring)).second.getNPanes() * dTheta / (TMath::Pi() * 2))); //LogDebug("CaloWindow") << "Ring is " << ring << ", pane is " // << division << "\n"; return std::pair<unsigned, unsigned>(ring, division); }
void CaloWindow::reset | ( | void | ) |
Definition at line 134 of file CaloWindow.cc.
References energies_.
Referenced by pftools::CandidateWrapper::CandidateWrapper(), pftools::Calibratable::reset(), and pftools::CandidateWrapper::reset().
{ energies_.clear(); }
vector< double > CaloWindow::stream | ( | double | normalisation = 1.0 | ) | const |
Collapses all energies in all CaloRings into one vector of doubles
normalisation | - divide each energy by this value |
Definition at line 95 of file CaloWindow.cc.
References trackerHits::c, energies_, pftools::CaloRing::getEnergies(), and i.
{ vector<double> stream; for (map<unsigned, pftools::CaloRing>::const_iterator cit = energies_.begin(); cit != energies_.end(); ++cit) { CaloRing c = (*cit).second; std::vector<double> ringE = c.getEnergies(); stream.insert(stream.end(), ringE.begin(), ringE.end()); } if(normalisation != 1.0){ for(vector<double>::iterator i = stream.begin(); i != stream.end(); ++i) { double& entry = *i; entry /= normalisation; } } return stream; }
std::ostream& operator<< | ( | std::ostream & | s, |
const CaloWindow & | caloWindow | ||
) | [friend] |
double pftools::CaloWindow::axis_ [private] |
Definition at line 154 of file CaloWindow.h.
Referenced by init(), and relativePosition().
double pftools::CaloWindow::baryEta_ [private] |
Definition at line 144 of file CaloWindow.h.
Referenced by init(), and relativePosition().
double pftools::CaloWindow::baryPhi_ [private] |
Definition at line 145 of file CaloWindow.h.
Referenced by init(), and relativePosition().
double pftools::CaloWindow::deltaR_ [private] |
Definition at line 149 of file CaloWindow.h.
Referenced by init(), and relativePosition().
std::map<unsigned, CaloRing> pftools::CaloWindow::energies_ [private] |
Definition at line 163 of file CaloWindow.h.
Referenced by addHit(), getRingDepositions(), getRingEnergySummations(), init(), printEnergies(), relativePosition(), reset(), and stream().
unsigned pftools::CaloWindow::nPanes_ [private] |
Definition at line 151 of file CaloWindow.h.
Referenced by init().
unsigned pftools::CaloWindow::nRings_ [private] |
Definition at line 147 of file CaloWindow.h.
Referenced by addHit(), init(), and relativePosition().