CMS 3D CMS Logo

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

#include <CaloBox.h>

Public Member Functions

 CaloBox (double centerEta, double centerPhi, double dEta, double dPhi, unsigned nEta, unsigned nPhi)
 
std::ostream & dump (std::ostream &stream, double norm=1.0, std::string rowDelim="\n") const
 
const std::map< std::pair< int,
int >, double > & 
energies () const
 
bool fill (double eta, double phi, double energy)
 
void reset ()
 
void test ()
 
virtual ~CaloBox ()
 

Public Attributes

double centerEta_
 
double centerPhi_
 
double dEta_
 
double dPhi_
 
int etaNegBound_
 
int etaPosBound_
 
unsigned nEta_
 
unsigned nPhi_
 
int phiNegBound_
 
int phiPosBound_
 

Private Member Functions

 CaloBox ()
 

Private Attributes

std::map< std::pair< int, int >
, double > 
energies_
 

Detailed Description

Definition at line 17 of file CaloBox.h.

Constructor & Destructor Documentation

CaloBox::CaloBox ( double  centerEta,
double  centerPhi,
double  dEta,
double  dPhi,
unsigned  nEta,
unsigned  nPhi 
)

Definition at line 15 of file CaloBox.cc.

References gather_cfg::cout, etaNegBound_, etaPosBound_, nEta_, nPhi_, phiNegBound_, phiPosBound_, and reset().

16  :
17  centerEta_(centerEta), centerPhi_(centerPhi), dEta_(dEta), dPhi_(dPhi),
18  nEta_(nEta), nPhi_(nPhi) {
19  if (nEta_ % 2 != 1) {
20  cout << __PRETTY_FUNCTION__
21  << ": should use odd numbers for nEta and nPhi as CaloBox won't be symmetric otherwise!\n";
22  etaPosBound_ = (nEta / 2);
23  etaNegBound_ = -1 * static_cast<int> ((nEta / 2) + 1);
24 
25  } else {
26  etaPosBound_ = (nEta - 1) / 2;
27  etaNegBound_ = -1 * static_cast<int> ((nEta - 1) / 2);
28  }
29 
30  if (nPhi_ % 2 != 1) {
31  cout << __PRETTY_FUNCTION__
32  << ": should use odd numbers for nEta and nPhi as CaloBox won't be symmetric otherwise!\n";
33 
34  phiPosBound_ = (nPhi / 2);
35  phiNegBound_ = -1 * static_cast<int> ((nPhi / 2) + 1);
36  } else {
37  phiPosBound_ = (nPhi - 1) / 2;
38  phiNegBound_ = -1 * static_cast<int> ((nPhi - 1) / 2);
39  }
40 
41  reset();
42 
43  //cout << "CaloBox with n+ " << etaPosBound_ << ", n- " << etaNegBound_
44  // << ", p+ " << phiPosBound_ << ", p-" << phiNegBound_ << "\n";
45 
46 }
void reset()
Definition: CaloBox.cc:48
int etaNegBound_
Definition: CaloBox.h:35
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
double centerEta_
Definition: CaloBox.h:27
int phiPosBound_
Definition: CaloBox.h:36
int etaPosBound_
Definition: CaloBox.h:34
double dEta_
Definition: CaloBox.h:29
unsigned nPhi_
Definition: CaloBox.h:32
int phiNegBound_
Definition: CaloBox.h:37
double centerPhi_
Definition: CaloBox.h:28
tuple cout
Definition: gather_cfg.py:145
double dPhi_
Definition: CaloBox.h:30
unsigned nEta_
Definition: CaloBox.h:31
CaloBox::~CaloBox ( )
virtual

Definition at line 57 of file CaloBox.cc.

57  {
58 
59 }
pftools::CaloBox::CaloBox ( )
private

Member Function Documentation

std::ostream & CaloBox::dump ( std::ostream &  stream,
double  norm = 1.0,
std::string  rowDelim = "\n" 
) const

Definition at line 82 of file CaloBox.cc.

References EnergyCorrector::c, energies_, relval_parameters_module::energy, etaNegBound_, etaPosBound_, phiNegBound_, phiPosBound_, and alignCSCRings::r.

Referenced by pftools::operator<<().

82  {
83 
84  for (int r = phiPosBound_; r >= phiNegBound_; --r) {
85  for (int c = etaNegBound_; c <= etaPosBound_; ++c) {
86  pair<int, int> pos(c, r);
87  double energy = energies_.find(pos)->second/norm;
88  stream << energy << "\t";
89  }
90  stream << rowDelim;
91  }
92 //
93 // for (map<pair<int, int> , double>::const iterator i = energies_.begin(); i
94 // != energies_.end(); ++i) {
95 // pair<int, int> loc = i->first;
96 // double en = i->second;
97 // stream << loc.first << ", " << loc.second << ": " << en << "\n";
98 // }
99 
100  return stream;
101 }
int etaNegBound_
Definition: CaloBox.h:35
int phiPosBound_
Definition: CaloBox.h:36
int etaPosBound_
Definition: CaloBox.h:34
std::map< std::pair< int, int >, double > energies_
Definition: CaloBox.h:48
int phiNegBound_
Definition: CaloBox.h:37
const std::map<std::pair<int, int>, double>& pftools::CaloBox::energies ( ) const
inline

Definition at line 41 of file CaloBox.h.

References energies_.

41  {
42  return energies_;
43  }
std::map< std::pair< int, int >, double > energies_
Definition: CaloBox.h:48
bool CaloBox::fill ( double  eta,
double  phi,
double  energy 
)

Definition at line 61 of file CaloBox.cc.

References centerEta_, centerPhi_, dEta_, dPhi_, energies_, relval_parameters_module::energy, etaNegBound_, etaPosBound_, relval_steps::key, phiNegBound_, and phiPosBound_.

Referenced by test().

61  {
62  int etaDiv = static_cast<int>(floor((eta - centerEta_ + dEta_ / 2.0) / dEta_));
63  int phiDiv = static_cast<int>(floor((phi - centerPhi_ + dPhi_ / 2.0) / dPhi_));
64  //cout << "Testing for " << etaDiv << ", " << phiDiv << "\n";
65 
66  if (etaDiv >= 0 && etaDiv > etaPosBound_)
67  return false;
68  if (etaDiv < 0 && etaDiv < etaNegBound_)
69  return false;
70  if (phiDiv >= 0 && phiDiv > phiPosBound_)
71  return false;
72  if (phiDiv < 0 && phiDiv < phiNegBound_)
73  return false;
74 
75  pair<int, int> key(etaDiv, phiDiv);
76 
77  energies_[key] += energy;
78  return true;
79 
80 }
int etaNegBound_
Definition: CaloBox.h:35
double centerEta_
Definition: CaloBox.h:27
int phiPosBound_
Definition: CaloBox.h:36
int etaPosBound_
Definition: CaloBox.h:34
double dEta_
Definition: CaloBox.h:29
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::map< std::pair< int, int >, double > energies_
Definition: CaloBox.h:48
int phiNegBound_
Definition: CaloBox.h:37
double centerPhi_
Definition: CaloBox.h:28
double dPhi_
Definition: CaloBox.h:30
void CaloBox::reset ( void  )

Definition at line 48 of file CaloBox.cc.

References EnergyCorrector::c, energies_, etaNegBound_, etaPosBound_, phiNegBound_, phiPosBound_, and alignCSCRings::r.

Referenced by CaloBox().

48  {
49  for (int r = phiPosBound_; r >= phiNegBound_; --r) {
50  for (int c = etaNegBound_; c <= etaPosBound_; ++c) {
51  std::pair<int, int> pos(c, r);
52  energies_[pos] = 0.0;
53  }
54  }
55 }
int etaNegBound_
Definition: CaloBox.h:35
int phiPosBound_
Definition: CaloBox.h:36
int etaPosBound_
Definition: CaloBox.h:34
std::map< std::pair< int, int >, double > energies_
Definition: CaloBox.h:48
int phiNegBound_
Definition: CaloBox.h:37
void CaloBox::test ( void  )

Definition at line 103 of file CaloBox.cc.

References KineDebug3::count(), gather_cfg::cout, fill(), and convertSQLiteXML::ok.

Referenced by edmIntegrityCheck.IntegrityCheck::report(), and edmIntegrityCheck.IntegrityCheck::structured().

103  {
104 
105  CaloBox cb(0.0, 0.0, 1.0, 1.0, 5, 5);
106 
107  unsigned count(0);
108  bool ok(false);
109 
110  ok = cb.fill(2, 1, 10);
111  if (!ok)
112  cout << "Box fill failed! Count = " << count << "\n";
113  ++count;
114 
115  ok = cb.fill(-1, 2, 20);
116  if (!ok)
117  cout << "Box fill failed! Count = " << count << "\n";
118  ++count;
119 
120  ok = cb.fill(-2, 5, 10);
121  if (!ok)
122  cout << "Box fill failed! Count = " << count << "\n";
123  ++count;
124 
125  ok = cb.fill(0.1, 1.3, 10);
126  if (!ok)
127  cout << "Box fill failed! Count = " << count << "\n";
128  ++count;
129 
130  ok = cb.fill(-1.4, 1.6, 10);
131  if (!ok)
132  cout << "Box fill failed! Count = " << count << "\n";
133  ++count;
134 
135  cout << cb;
136 
137 }
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

double pftools::CaloBox::centerEta_

Definition at line 27 of file CaloBox.h.

Referenced by fill(), and pftools::operator<<().

double pftools::CaloBox::centerPhi_

Definition at line 28 of file CaloBox.h.

Referenced by fill(), and pftools::operator<<().

double pftools::CaloBox::dEta_

Definition at line 29 of file CaloBox.h.

Referenced by fill().

double pftools::CaloBox::dPhi_

Definition at line 30 of file CaloBox.h.

Referenced by fill().

std::map<std::pair<int, int>, double> pftools::CaloBox::energies_
private

Definition at line 48 of file CaloBox.h.

Referenced by dump(), energies(), fill(), and reset().

int pftools::CaloBox::etaNegBound_

Definition at line 35 of file CaloBox.h.

Referenced by CaloBox(), dump(), fill(), and reset().

int pftools::CaloBox::etaPosBound_

Definition at line 34 of file CaloBox.h.

Referenced by CaloBox(), dump(), fill(), and reset().

unsigned pftools::CaloBox::nEta_

Definition at line 31 of file CaloBox.h.

Referenced by CaloBox().

unsigned pftools::CaloBox::nPhi_

Definition at line 32 of file CaloBox.h.

Referenced by CaloBox().

int pftools::CaloBox::phiNegBound_

Definition at line 37 of file CaloBox.h.

Referenced by CaloBox(), dump(), fill(), and reset().

int pftools::CaloBox::phiPosBound_

Definition at line 36 of file CaloBox.h.

Referenced by CaloBox(), dump(), fill(), and reset().