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 Member Functions | Private Attributes | Friends
pftools::CaloWindow Class Reference

#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, CaloRinggetRingDepositions () 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_
 

Friends

std::ostream & operator<< (std::ostream &s, const CaloWindow &caloWindow)
 

Detailed Description

Definition at line 94 of file CaloWindow.h.

Constructor & Destructor Documentation

CaloWindow::CaloWindow ( )

Definition at line 124 of file CaloWindow.cc.

124  :
125  baryEta_(0.0), baryPhi_(0.0), nRings_(1), deltaR_(0.1), nPanes_(1), axis_(0.0) {
126 
127 }
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 129 of file CaloWindow.cc.

References init().

129  {
130 
131  init(eta, phi, nRings, deltaR, nPanes, axis);
132 }
T eta() const
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:138
Definition: DDAxes.h:10
CaloWindow::~CaloWindow ( )
virtual

Definition at line 156 of file CaloWindow.cc.

156  {
157 
158 }

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 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().

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

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

Definition at line 246 of file CaloWindow.cc.

References submit::answer, and energies_.

246  {
247  std::map<unsigned, double> answer;
248  for (std::map<unsigned, CaloRing>::const_iterator cit = energies_.begin(); cit
249  != energies_.end(); ++cit) {
250  std::pair<unsigned, CaloRing> pair = *cit;
251  answer[pair.first] = pair.second.totalE();
252  }
253 
254  return answer;
255 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:163
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 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().

138  {
139  baryEta_ = eta;
140  baryPhi_ = phi;
141  nRings_ = nRings;
142  deltaR_ = deltaR;
143  nPanes_ = nPanes;
144  axis_ = axis;
145 
146  energies_.clear();
147  CaloRing c(1);
148  energies_[0] = c;
149  for (unsigned j(1); j < nRings_; ++j) {
150 
151  CaloRing r(nPanes);
152  energies_[j] = r;
153  }
154 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:163
T eta() const
int j
Definition: DBlmapReader.cc:9
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
Definition: DDAxes.h:10
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().

113  {
114 
115  for (std::map<unsigned, pftools::CaloRing>::const_iterator cit =
116  energies_.begin(); cit != energies_.end(); ++cit) {
117  CaloRing c = (*cit).second;
118  c.printEnergies(s, range);
119  s << "\t";
120  }
121 
122 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:163
void printEnergies(std::ostream &s, double range=1.0)
Definition: CaloWindow.cc:60
string s
Definition: asciidump.py:422
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().

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

Definition at line 134 of file CaloWindow.cc.

References energies_.

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

134  {
135  energies_.clear();
136 }
std::map< unsigned, CaloRing > energies_
Definition: CaloWindow.h:163
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 95 of file CaloWindow.cc.

References trackerHits::c, energies_, pftools::CaloRing::getEnergies(), and i.

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

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const CaloWindow caloWindow 
)
friend

Member Data Documentation

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
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().