CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Calibratable.cc
Go to the documentation of this file.
2 #include <algorithm>
3 
4 using namespace pftools;
5 
6 std::ostream& pftools::operator<<(std::ostream& s, const Calibratable& calib_) {
7  s << "Calibratable summary:\n\tsim:\t\t(" << calib_.sim_energyEvent_
8  << "),\t[" << calib_.sim_etaEcal_ << ", " << calib_.sim_phiEcal_
9  << "]\n";
10  s << "\ttestbeam:\t(" << calib_.tb_energyEvent_ << ", "
11  << calib_.tb_energyEcal_ << ", " << calib_.tb_energyHcal_ << "), ["
12  << calib_.tb_eta_ << ", " << calib_.tb_phi_ << "]\n";
13  s << "\trechits:\t(" << calib_.rechits_energyEvent_ << ", "
14  << calib_.rechits_energyEcal_ << ", " << calib_.rechits_energyHcal_
15  << ")\n";
16  s << "\tcluster:\t(" << calib_.cluster_energyEvent_ << ", "
17  << calib_.cluster_energyEcal_ << ", " << calib_.cluster_energyHcal_
18  << ")\n";
19  s << "\tcands:\t\t(" << calib_.cand_energyEvent_ << ", "
20  << calib_.cand_energyEcal_ << ", " << calib_.cand_energyHcal_
21  << "), ";
22  s << "\t[" << calib_.cand_eta_ << ", " << calib_.cand_phi_ << "], "
23  << calib_.cands_num_ << " of them\n";
24  for (std::vector<CandidateWrapper>::const_iterator c =
25  calib_.cands_.begin(); c != calib_.cands_.end(); ++c) {
26  const CandidateWrapper& cw = *c;
27  s << "\t\t\t\tType: " << cw.type_ << ", (" << cw.energy_ << ", "
28  << cw.energyEcal_ << ", " << cw.energyHcal_ << ") at [ "
29  << cw.eta_ << ", " << cw.phi_ << "]\n";
30  }
31  s << "\t\tNeutral EM energy: " << calib_.cand_energyNeutralEM_ << "\n";
32  s << "\t\tNeutral Had energy: " << calib_.cand_energyNeutralHad_ << "\n";
33 
34  return s;
35 }
36 
37 std::ostream& pftools::operator<<(std::ostream& s,
38  const CalibratableElement& ce) {
39  s << "CalibratableElement: (energy, eta, phi) = (" << ce.energy_ << ", "
40  << ce.eta_ << ", " << ce.phi_ << ")";
41 
42  return s;
43 }
44 
46 
53 
58  tb_numEcal_ = tb_ecal_.size();
59  tb_numHcal_ = tb_hcal_.size();
60 
65 
70 
72  + tb_meanHcal_.energy_ * tb_hcal_.size();
75 
76  cands_num_ = cands_.size();
78 
80  cand_energyEcal_ = 0;
81  cand_energyHcal_ = 0;
84  cand_type_ = 0;
87 
88  for (std::vector<CandidateWrapper>::iterator it = cands_.begin(); it
89  != cands_.end(); ++it) {
90  CandidateWrapper& c = *it;
91  if (c.type_ == 4)
93  if (c.type_ == 5)
98  cand_type_ += c.type_;
99  c.recompute();
100  }
101 
102  std::sort(tb_ecal_.begin(), tb_ecal_.end());
103  std::sort(tb_hcal_.begin(), tb_hcal_.end());
104  std::sort(rechits_ecal_.begin(), rechits_ecal_.end());
105  std::sort(rechits_hcal_.begin(), rechits_hcal_.end());
106  std::sort(cluster_ecal_.begin(), cluster_ecal_.end());
107  std::sort(cluster_hcal_.begin(), cluster_hcal_.end());
108 
109 }
110 
112  const std::vector<CandidateWrapper>& wrappers) {
113  CandidateWrapper cw;
114 
115  if (wrappers.size() == 0)
116  return cw;
117  for (std::vector<CandidateWrapper>::const_iterator it = wrappers.begin(); it
118  != wrappers.end(); ++it) {
119  const CandidateWrapper& c = *it;
120  cw.energy_ += c.energy_;
121  cw.phi_ += c.phi_;
122  cw.eta_ += c.eta_;
123  cw.energyEcal_ += c.energyEcal_;
124  cw.energyHcal_ += c.energyHcal_;
125  cw.type_ += c.type_;
126  }
127 
128  cw.energy_ /= wrappers.size();
129  cw.phi_ /= wrappers.size();
130  cw.eta_ /= wrappers.size();
131  cw.energyEcal_ /= wrappers.size();
132  cw.energyHcal_ /= wrappers.size();
133  cw.type_ /= wrappers.size();
134 
135  return cw;
136 }
137 
139  CalibratableElement>& diets) {
140  CalibratableElement dmean;
141  if (diets.size() == 0)
142  return dmean;
143  for (std::vector<CalibratableElement>::const_iterator cit = diets.begin(); cit
144  != diets.end(); ++cit) {
145  CalibratableElement d = *cit;
146  dmean.energy_ += d.energy_;
147  dmean.eta_ += d.eta_;
148  dmean.phi_ += d.phi_;
149  dmean.extent_ += d.extent_;
150  dmean.time_ += d.time_;
151  }
152  dmean.energy_ /= diets.size();
153  dmean.eta_ /= diets.size();
154  dmean.phi_ /= diets.size();
155  dmean.extent_ /= diets.size();
156  dmean.time_ /= diets.size();
157  return dmean;
158 }
159 
161  const std::vector<CalibratableElement>& source, CaloWindow& destination) const {
162  std::vector<CalibratableElement>::const_iterator cit = source.begin();
163  for (; cit != source.end(); ++cit) {
164  const CalibratableElement& ce = *cit;
165  bool ok = destination.addHit(ce.eta_, ce.phi_, ce.energy_);
166  if (!ok)
167  std::cout << __PRETTY_FUNCTION__
168  << ": couldn't fill CaloWindow with " << ce << "\n";
169  }
170 }
171 
173 
174  calibrations_.clear();
175 
176  sim_energyEvent_ = 0;
177  sim_energyEcal_ = 0;
178  sim_energyHcal_ = 0;
179  sim_eta_ = 0;
180  sim_phi_ = 0;
181  sim_numEvent_ = 0;
182  sim_isMC_ = false;
183 
184  tb_isTB_ = false;
185  tb_eta_ = 0.0;
186  tb_phi_ = 0.0;
187  tb_run_ = 0;
188  tb_pdg_ = 0;
189  tb_tof_ = 0;
190  tb_ck3_ = 0;
191  tb_ck2_ = 0;
192  tb_vetosPassed_ = 0;
193  tb_energyEvent_ = 0;
194  tb_energyEcal_ = 0;
195  tb_energyHcal_ = 0;
196  tb_ecal_.clear();
197  tb_hcal_.clear();
198  tb_numEcal_ = 0;
199  tb_numHcal_ = 0;
202 
203  sim_etaEcal_ = 0;
204  sim_etaHcal_ = 0;
205  sim_phiEcal_ = 0;
206  sim_phiHcal_ = 0;
207 
208  recotrk_numHits_ = 0;
209  recotrk_quality_ = 0;
210  recotrk_charge_ = 0;
211  recotrk_etaEcal_ = 0;
212  recotrk_phiEcal_ = 0;
213  //TODO:: check this is sufficient
214  recotrk_momentum_.SetPxPyPzE(0, 0, 0, 0);
216 
220  cluster_numEcal_ = 0;
221  cluster_numHcal_ = 0;
222  cluster_ecal_.clear();
223  cluster_hcal_.clear();
226 
228  rechits_ecal_.clear();
229  rechits_hcal_.clear();
232  rechits_numEcal_ = 0;
233  rechits_numHcal_ = 0;
236 
237  cands_.clear();
238  cands_num_ = 0;
239  cands_mean_.reset();
240  cand_energyEvent_ = 0;
241  cand_energyEcal_ = 0;
242  cand_energyHcal_ = 0;
243  cand_eta_ = 0;
244  cand_phi_ = 0;
245  cand_type_ = -1;
248 
251 
252 }
CalibratableElement rechits_meanHcal_
Definition: Calibratable.h:193
Wraps essential single particle calibration data ready for export to a Root file. ...
Definition: Calibratable.h:122
CalibratableElement cluster_meanEcal_
Definition: Calibratable.h:186
Small wrapper class for storing individual rechit and cluster information.
Definition: Calibratable.h:24
string destination
std::vector< CalibrationResultWrapper > calibrations_
Definition: Calibratable.h:206
std::vector< CalibratableElement > rechits_ecal_
Definition: Calibratable.h:191
tuple d
Definition: ztail.py:151
bool addHit(double eta, double phi, double energy)
Definition: CaloWindow.cc:226
CalibratableElement rechits_meanEcal_
Definition: Calibratable.h:193
CaloWindow calowindow_hcal_
Definition: Calibratable.h:179
CalibratableElement tb_meanEcal_
Definition: Calibratable.h:168
std::vector< CalibratableElement > rechits_hcal_
Definition: Calibratable.h:191
std::vector< CandidateWrapper > cands_
Definition: Calibratable.h:196
std::vector< CalibratableElement > tb_hcal_
Definition: Calibratable.h:165
virtual void reset()
std::vector< CalibratableElement > cluster_ecal_
Definition: Calibratable.h:184
virtual CalibratableElement computeMean(const std::vector< CalibratableElement > &diets)
virtual void recompute()
Definition: Calibratable.cc:45
std::vector< CalibratableElement > cluster_hcal_
Definition: Calibratable.h:184
CalibratableElement tb_meanHcal_
Definition: Calibratable.h:168
CalibratableElement cluster_meanHcal_
Definition: Calibratable.h:186
math::XYZTLorentzVector recotrk_momentum_
Definition: Calibratable.h:175
std::vector< CalibratableElement > tb_ecal_
Definition: Calibratable.h:165
tuple cout
Definition: gather_cfg.py:121
std::ostream & operator<<(std::ostream &s, const Calibratable &calib_)
Definition: Calibratable.cc:6
CandidateWrapper cands_mean_
Definition: Calibratable.h:197
static std::string const source
Definition: EdmProvDump.cc:42
CaloWindow calowindow_ecal_
Definition: Calibratable.h:178
Small wrapper class to store information associated with PFCandidates.
Definition: Calibratable.h:66
virtual void fillCaloWindow(const std::vector< CalibratableElement > &source, CaloWindow &destination) const