107 desc.addUntracked<
double>(
"MaxEnergy", 200.0);
108 desc.addUntracked<
double>(
"TimeCut", 100.0);
109 desc.addUntracked<
int>(
"SelectX", -1);
110 descriptions.
add(
"EcalSimHitStudy",
desc);
115 if (!
tfile.isAvailable())
117 <<
"please add it to config file";
119 sprintf(
title,
"Incident PT (GeV)");
122 ptInc_->GetYaxis()->SetTitle(
"Events");
123 sprintf(
title,
"Incident Energy (GeV)");
126 eneInc_->GetYaxis()->SetTitle(
"Events");
127 sprintf(
title,
"Incident #eta");
130 etaInc_->GetYaxis()->SetTitle(
"Events");
131 sprintf(
title,
"Incident #phi");
134 phiInc_->GetYaxis()->SetTitle(
"Events");
137 sprintf(
name,
"Hit%d",
i);
138 sprintf(
title,
"Number of hits in %s", dets[
i].c_str());
141 hit_[
i]->GetYaxis()->SetTitle(
"Events");
143 sprintf(
name,
"Time%d",
i);
144 sprintf(
title,
"Time of the hit (ns) in %s", dets[
i].c_str());
147 time_[
i]->GetYaxis()->SetTitle(
"Hits");
149 sprintf(
name,
"TimeAll%d",
i);
150 sprintf(
title,
"Hit time (ns) in %s (for first hit in the cell)", dets[
i].c_str());
153 timeAll_[
i]->GetYaxis()->SetTitle(
"Hits");
155 sprintf(
name,
"Edep%d",
i);
156 sprintf(
title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
159 edep_[
i]->GetYaxis()->SetTitle(
"Hits");
161 sprintf(
name,
"EdepAll%d",
i);
162 sprintf(
title,
"Total Energy deposit in the cell (GeV) in %s", dets[
i].c_str());
165 edepAll_[
i]->GetYaxis()->SetTitle(
"Hits");
167 sprintf(
name,
"EdepEM%d",
i);
168 sprintf(
title,
"Energy deposit (GeV) by EM particles in %s", dets[
i].c_str());
171 edepEM_[
i]->GetYaxis()->SetTitle(
"Hits");
173 sprintf(
name,
"EdepHad%d",
i);
174 sprintf(
title,
"Energy deposit (GeV) by hadrons in %s", dets[
i].c_str());
177 edepHad_[
i]->GetYaxis()->SetTitle(
"Hits");
179 sprintf(
name,
"Etot%d",
i);
180 sprintf(
title,
"Total energy deposit (GeV) in %s", dets[
i].c_str());
183 etot_[
i]->GetYaxis()->SetTitle(
"Events");
185 sprintf(
name,
"EtotG%d",
i);
186 sprintf(
title,
"Total energy deposit (GeV) in %s (t < 100 ns)", dets[
i].c_str());
189 etotg_[
i]->GetYaxis()->SetTitle(
"Events");
191 sprintf(
name,
"r1by9%d",
i);
192 sprintf(
title,
"E1/E9 in %s", dets[
i].c_str());
195 r1by9_[
i]->GetYaxis()->SetTitle(
"Events");
197 sprintf(
name,
"r1by25%d",
i);
198 sprintf(
title,
"E1/E25 in %s", dets[
i].c_str());
201 r1by25_[
i]->GetYaxis()->SetTitle(
"Events");
203 sprintf(
name,
"r9by25%d",
i);
204 sprintf(
title,
"E9/E25 in %s", dets[
i].c_str());
207 r9by25_[
i]->GetYaxis()->SetTitle(
"Events");
209 double ymax = (
i == 0) ? 0.0005 : 0.005;
210 sprintf(
name,
"sEtaEta%d",
i);
211 sprintf(
title,
"Cov(#eta,#eta) in %s", dets[
i].c_str());
214 sEtaEta_[
i]->GetYaxis()->SetTitle(
"Events");
216 sprintf(
name,
"sEtaPhi%d",
i);
217 sprintf(
title,
"Cov(#eta,#phi) in %s", dets[
i].c_str());
220 sEtaPhi_[
i]->GetYaxis()->SetTitle(
"Events");
222 ymax = (
i == 0) ? 0.001 : 0.01;
223 sprintf(
name,
"sPhiPhi%d",
i);
224 sprintf(
title,
"Cov(#phi,#phi) in %s", dets[
i].c_str());
227 sPhiPhi_[
i]->GetYaxis()->SetTitle(
"Events");
230 sprintf(
title,
"%s+", dets[
i].c_str());
232 poszp_[
i]->GetXaxis()->SetTitle(
"i#eta");
233 poszp_[
i]->GetYaxis()->SetTitle(
"i#phi");
234 sprintf(
title,
"%s-", dets[
i].c_str());
236 poszn_[
i]->GetXaxis()->SetTitle(
"i#eta");
237 poszn_[
i]->GetYaxis()->SetTitle(
"i#phi");
239 sprintf(
title,
"%s+", dets[
i].c_str());
241 poszp_[
i]->GetXaxis()->SetTitle(
"x (cm)");
242 poszp_[
i]->GetYaxis()->SetTitle(
"y (cm)");
243 sprintf(
title,
"%s-", dets[
i].c_str());
245 poszn_[
i]->GetXaxis()->SetTitle(
"x (cm)");
246 poszn_[
i]->GetYaxis()->SetTitle(
"y (cm)");
248 poszp_[
i]->GetYaxis()->SetTitleOffset(1.2);
250 poszn_[
i]->GetYaxis()->SetTitleOffset(1.2);
257 edm::LogVerbatim(
"HitStudy") <<
"Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
264 double eInc = 0, etaInc = 0, phiInc = 0;
271 HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
272 if (
p != myGenEvent->particles_end()) {
273 eInc = (*p)->momentum().e();
274 etaInc = (*p)->momentum().eta();
275 phiInc = (*p)->momentum().phi();
277 double ptInc = eInc / std::cosh(etaInc);
289 int typeMin = (
type < 0) ? 0 :
type;
290 int typeMax = (
type < 0) ? 1 :
type;
294 bool getHits = (hitsCalo.
isValid());
296 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy: Input flags Hits " << getHits <<
" with " << hitsCalo->size()
300 std::vector<PCaloHit> caloHits;
301 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
302 if (!caloHits.empty())
310 std::map<unsigned int, EcalHit> hitMap;
311 double etot(0), etotG(0);
313 double edep =
hit.energy();
315 unsigned int id_ =
hit.
id();
316 double edepEM =
hit.energyEM();
317 double edepHad =
hit.energyHad();
319 if ((
hit.depth() == 1) || (
hit.depth() == 2))
323 auto it = hitMap.find(id_);
324 if (it == hitMap.end()) {
325 uint16_t dep =
hit.depth();
328 (it->second).
energy += edep;
334 edep_[indx]->Fill(edep);
343 for (
auto it : hitMap) {
344 if (it.second.energy > edepM) {
346 edepM = it.second.energy;
353 if ((depM & 0X4) != 0)
359 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::analyzeHits: Index " << indx <<
" Emax " << edepM <<
" IDMax "
361 <<
" Hits " <<
hits.size() <<
":" << nEC <<
":" << hitMap.size() <<
" ETotal " << etot
365 etot_[indx]->Fill(etot);
366 etotg_[indx]->Fill(etotG);
367 hit_[indx]->Fill(
double(nEC));
368 for (
auto it : hitMap) {
369 timeAll_[indx]->Fill((it.second).time);
370 edepAll_[indx]->Fill((it.second).energy);
380 poszp_[indx]->Fill(gpos.
x(), gpos.
y());
382 poszn_[indx]->Fill(gpos.
x(), gpos.
y());
387 std::vector<math::XYZVector>
position;
388 std::vector<double>
energy;
389 double e9(0), e25(0);
390 for (
auto it : hitMap) {
392 int deta(99), dphi(99),
dz(0);
404 if (deta <= 1 && dphi <= 1 &&
dz < 1)
406 if (deta <= 2 && dphi <= 2 &&
dz < 1) {
407 e25 += (it.second).
energy;
410 meanPosition += (it.second).
energy *
pos;
412 energy.push_back((it.second).energy);
415 double r1by9 = (e9 > 0) ? (edepM / e9) : -1;
416 double r1by25 = (e25 > 0) ? (edepM / e25) : -1;
417 double r9by25 = (e25 > 0) ? (e9 / e25) : -1;
420 double denom(0), numEtaEta(0), numEtaPhi(0), numPhiPhi(0);
421 for (
unsigned int k = 0;
k <
position.size(); ++
k) {
441 double sEtaEta = (
denom > 0) ? (numEtaEta /
denom) : -1.0;
442 double sEtaPhi = (
denom > 0) ? (numEtaPhi /
denom) : -1.0;
443 double sPhiPhi = (
denom > 0) ? (numPhiPhi /
denom) : -1.0;
446 edm::LogVerbatim(
"HitStudy") <<
"EcalSimHitStudy::Ratios " << r1by9 <<
" : " << r1by25 <<
" : " << r9by25
447 <<
" Covariances " << sEtaEta <<
" : " << sEtaPhi <<
" : " << sPhiPhi;
449 r1by9_[indx]->Fill(r1by9);