108 descriptions.
add(
"EcalSimHitStudy", desc);
113 if (!
tfile.isAvailable())
115 <<
"please add it to config file";
117 sprintf(
title,
"Incident PT (GeV)");
120 ptInc_->GetYaxis()->SetTitle(
"Events");
121 sprintf(
title,
"Incident Energy (GeV)");
124 eneInc_->GetYaxis()->SetTitle(
"Events");
125 sprintf(
title,
"Incident #eta");
128 etaInc_->GetYaxis()->SetTitle(
"Events");
129 sprintf(
title,
"Incident #phi");
132 phiInc_->GetYaxis()->SetTitle(
"Events");
135 sprintf(
name,
"Hit%d",
i);
136 sprintf(
title,
"Number of hits in %s", dets[
i].c_str());
139 hit_[
i]->GetYaxis()->SetTitle(
"Events");
141 sprintf(
name,
"Time%d",
i);
142 sprintf(
title,
"Time of the hit (ns) in %s", dets[
i].c_str());
145 time_[
i]->GetYaxis()->SetTitle(
"Hits");
147 sprintf(
name,
"TimeAll%d",
i);
148 sprintf(
title,
"Hit time (ns) in %s (for first hit in the cell)", dets[
i].c_str());
151 timeAll_[
i]->GetYaxis()->SetTitle(
"Hits");
153 sprintf(
name,
"Edep%d",
i);
154 sprintf(
title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
157 edep_[
i]->GetYaxis()->SetTitle(
"Hits");
159 sprintf(
name,
"EdepAll%d",
i);
160 sprintf(
title,
"Total Energy deposit in the cell (GeV) in %s", dets[
i].c_str());
163 edepAll_[
i]->GetYaxis()->SetTitle(
"Hits");
165 sprintf(
name,
"EdepEM%d",
i);
166 sprintf(
title,
"Energy deposit (GeV) by EM particles in %s", dets[
i].c_str());
169 edepEM_[
i]->GetYaxis()->SetTitle(
"Hits");
171 sprintf(
name,
"EdepHad%d",
i);
172 sprintf(
title,
"Energy deposit (GeV) by hadrons in %s", dets[
i].c_str());
175 edepHad_[
i]->GetYaxis()->SetTitle(
"Hits");
177 sprintf(
name,
"Etot%d",
i);
178 sprintf(
title,
"Total energy deposit (GeV) in %s", dets[
i].c_str());
181 etot_[
i]->GetYaxis()->SetTitle(
"Events");
183 sprintf(
name,
"EtotG%d",
i);
184 sprintf(
title,
"Total energy deposit (GeV) in %s (t < 100 ns)", dets[
i].c_str());
187 etotg_[
i]->GetYaxis()->SetTitle(
"Events");
189 sprintf(
name,
"r1by9%d",
i);
190 sprintf(
title,
"E1/E9 in %s", dets[
i].c_str());
193 r1by9_[
i]->GetYaxis()->SetTitle(
"Events");
195 sprintf(
name,
"r1by25%d",
i);
196 sprintf(
title,
"E1/E25 in %s", dets[
i].c_str());
199 r1by25_[
i]->GetYaxis()->SetTitle(
"Events");
201 sprintf(
name,
"r9by25%d",
i);
202 sprintf(
title,
"E9/E25 in %s", dets[
i].c_str());
205 r9by25_[
i]->GetYaxis()->SetTitle(
"Events");
207 double ymax = (
i == 0) ? 0.0005 : 0.005;
208 sprintf(
name,
"sEtaEta%d",
i);
209 sprintf(
title,
"Cov(#eta,#eta) in %s", dets[
i].c_str());
212 sEtaEta_[
i]->GetYaxis()->SetTitle(
"Events");
214 sprintf(
name,
"sEtaPhi%d",
i);
215 sprintf(
title,
"Cov(#eta,#phi) in %s", dets[
i].c_str());
218 sEtaPhi_[
i]->GetYaxis()->SetTitle(
"Events");
220 ymax = (
i == 0) ? 0.001 : 0.01;
221 sprintf(
name,
"sPhiPhi%d",
i);
222 sprintf(
title,
"Cov(#phi,#phi) in %s", dets[
i].c_str());
225 sPhiPhi_[
i]->GetYaxis()->SetTitle(
"Events");
232 edm::LogVerbatim(
"HitStudy") <<
"Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
243 double eInc = 0, etaInc = 0, phiInc = 0;
244 HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
245 if (
p != myGenEvent->particles_end()) {
246 eInc = (*p)->momentum().e();
247 etaInc = (*p)->momentum().eta();
248 phiInc = (*p)->momentum().phi();
250 double ptInc = eInc / std::cosh(etaInc);
268 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy: Input flags Hits " << getHits <<
" with " << hitsCalo->size()
272 std::vector<PCaloHit> caloHits;
273 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
274 if (!caloHits.empty())
282 std::map<unsigned int, EcalHit> hitMap;
283 double etot(0), etotG(0);
285 double edep =
hit.energy();
287 unsigned int id_ =
hit.
id();
288 double edepEM =
hit.energyEM();
289 double edepHad =
hit.energyHad();
291 if ((
hit.depth() == 1) || (
hit.depth() == 2))
295 auto it = hitMap.find(id_);
296 if (it == hitMap.end()) {
297 uint16_t dep =
hit.depth();
300 (it->second).
energy += edep;
306 edep_[indx]->Fill(edep);
315 for (
auto it : hitMap) {
316 if (it.second.energy > edepM) {
318 edepM = it.second.energy;
325 if ((depM & 0X4) != 0)
331 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::analyzeHits: Index " << indx <<
" Emax " << edepM <<
" IDMax "
333 <<
" Hits " <<
hits.size() <<
":" << nEC <<
":" << hitMap.size() <<
" ETotal " << etot
337 etot_[indx]->Fill(etot);
338 etotg_[indx]->Fill(etotG);
339 hit_[indx]->Fill(
double(nEC));
340 for (
auto it : hitMap) {
341 timeAll_[indx]->Fill((it.second).time);
342 edepAll_[indx]->Fill((it.second).energy);
346 std::vector<math::XYZVector>
position;
347 std::vector<double>
energy;
348 double e9(0), e25(0);
349 for (
auto it : hitMap) {
351 int deta(99), dphi(99),
dz(0);
363 if (deta <= 1 && dphi <= 1 &&
dz < 1)
365 if (deta <= 2 && dphi <= 2 &&
dz < 1) {
366 e25 += (it.second).
energy;
369 meanPosition += (it.second).
energy *
pos;
371 energy.push_back((it.second).energy);
374 double r1by9 = (e9 > 0) ? (edepM / e9) : -1;
375 double r1by25 = (e25 > 0) ? (edepM / e25) : -1;
376 double r9by25 = (e25 > 0) ? (e9 / e25) : -1;
379 double denom(0), numEtaEta(0), numEtaPhi(0), numPhiPhi(0);
380 for (
unsigned int k = 0;
k <
position.size(); ++
k) {
400 double sEtaEta = (
denom > 0) ? (numEtaEta /
denom) : -1.0;
401 double sEtaPhi = (
denom > 0) ? (numEtaPhi /
denom) : -1.0;
402 double sPhiPhi = (
denom > 0) ? (numPhiPhi /
denom) : -1.0;
405 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::Ratios " << r1by9 <<
" : " << r1by25 <<
" : " << r9by25
406 <<
" Covariances " << sEtaEta <<
" : " << sEtaPhi <<
" : " << sPhiPhi;
408 r1by9_[indx]->Fill(r1by9);