68 std::vector<edm::EDGetTokenT<edm::PCaloHitContainer> >
toks_calo_;
87 : g4Label_(ps.getUntrackedParameter<
std::
string>(
"moduleLabel",
"g4SimHits")),
89 timeSliceUnit_(ps.getParameter<
std::
vector<double> >(
"timeSliceUnit")),
90 maxEnergy_(ps.getUntrackedParameter<double>(
"maxEnergy", 250.0)),
91 maxTime_(ps.getUntrackedParameter<double>(
"maxTime", 1000.0)),
92 tMax_(ps.getUntrackedParameter<double>(
"timeCut", 100.0)),
93 tScale_(ps.getUntrackedParameter<double>(
"timeScale", 1.0)),
94 tCut_(ps.getUntrackedParameter<double>(
"timeThreshold", 15.0)),
95 testNumber_(ps.getUntrackedParameter<
bool>(
"testNumbering",
false)),
96 passive_(ps.getUntrackedParameter<
bool>(
"passiveHits",
false)),
97 allSteps_(ps.getUntrackedParameter<
int>(
"allSteps", 100)),
102 for (
unsigned int i = 0;
i <
hitLab_.size();
i++)
107 for (
unsigned int i = 0;
i <
hitLab_.size();
i++)
115 if (!
tfile.isAvailable())
117 <<
"please add it to config file";
121 sprintf(
name,
"Hit%d",
i);
122 sprintf(
title,
"Number of hits in %s", dets[
i].c_str());
125 h_hit_[
i]->GetYaxis()->SetTitle(
"Events");
126 sprintf(
name,
"Time%d",
i);
127 sprintf(
title,
"Time of the hit (ns) in %s", dets[
i].c_str());
130 h_time_[
i]->GetYaxis()->SetTitle(
"Hits");
131 sprintf(
name,
"TimeT%d",
i);
132 sprintf(
title,
"Time of each hit (ns) in %s", dets[
i].c_str());
135 h_timeT_[
i]->GetYaxis()->SetTitle(
"Hits");
136 double ymax = (
i > 1) ? 0.01 : 0.1;
137 double ymx0 = (
i > 1) ? 0.0025 : 0.025;
138 sprintf(
name,
"Edep%d",
i);
139 sprintf(
title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
142 h_edep_[
i]->GetYaxis()->SetTitle(
"Hits");
143 sprintf(
name,
"EdepT%d",
i);
144 sprintf(
title,
"Energy deposit (GeV) of each hit in %s", dets[
i].c_str());
147 h_edepT_[
i]->GetYaxis()->SetTitle(
"Hits");
148 sprintf(
name,
"EdepEM%d",
i);
149 sprintf(
title,
"Energy deposit (GeV) by EM particles in %s", dets[
i].c_str());
153 sprintf(
name,
"EdepHad%d",
i);
154 sprintf(
title,
"Energy deposit (GeV) by hadrons in %s", dets[
i].c_str());
158 sprintf(
name,
"Edep15%d",
i);
159 sprintf(
title,
"Energy deposit (GeV) for T > %4.0f ns in %s",
tCut_, dets[
i].c_str());
162 h_edep1_[
i]->GetYaxis()->SetTitle(
"Hits");
163 sprintf(
name,
"EdepT15%d",
i);
164 sprintf(
title,
"Energy deposit (GeV) of each hit for T > %4.0f in %s",
tCut_, dets[
i].c_str());
169 sprintf(
name,
"Etot%d",
i);
170 sprintf(
title,
"Total energy deposit (GeV) in %s", dets[
i].c_str());
173 h_etot_[
i]->GetYaxis()->SetTitle(
"Events");
174 sprintf(
name,
"EtotG%d",
i);
175 sprintf(
title,
"Total energy deposit (GeV) in %s (t < 100 ns)", dets[
i].c_str());
178 h_etotg_[
i]->GetYaxis()->SetTitle(
"Events");
179 sprintf(
name,
"rr%d",
i);
180 sprintf(
title,
"R of hit point (cm) in %s", dets[
i].c_str());
183 h_rr_[
i]->GetYaxis()->SetTitle(
"Hits");
184 sprintf(
name,
"zz%d",
i);
185 sprintf(
title,
"z of hit point (cm) in %s", dets[
i].c_str());
188 h_zz_[
i]->GetYaxis()->SetTitle(
"Hits");
189 sprintf(
name,
"eta%d",
i);
190 sprintf(
title,
"#eta of hit point in %s", dets[
i].c_str());
193 h_eta_[
i]->GetYaxis()->SetTitle(
"Hits");
194 sprintf(
name,
"phi%d",
i);
195 sprintf(
title,
"#phi of hit point in %s", dets[
i].c_str());
198 h_phi_[
i]->GetYaxis()->SetTitle(
"Hits");
200 sprintf(
title,
"R vs Z of hit point");
202 h_rz_->GetXaxis()->SetTitle(
"z (cm)");
203 h_rz_->GetYaxis()->SetTitle(
"R (cm)");
204 sprintf(
title,
"R vs Z of hit point for hits with T > %4.0f ns",
tCut_);
206 h_rz1_->GetXaxis()->SetTitle(
"z (cm)");
207 h_rz1_->GetYaxis()->SetTitle(
"R (cm)");
208 sprintf(
title,
"#phi vs #eta of hit point");
214 h_hitp_ =
tfile->make<TH1F>(
"hitp",
"All Steps", 100, 0.0, 20000.0);
215 h_hitp_->GetXaxis()->SetTitle(
"Hits");
216 h_hitp_->GetYaxis()->SetTitle(
"Events");
217 h_trackp_ =
tfile->make<TH1F>(
"trackp",
"All Steps", 100, 0.0, 200000.0);
218 h_hitp_->GetXaxis()->SetTitle(
"Tracks");
219 h_hitp_->GetYaxis()->SetTitle(
"Events");
220 h_edepp_ =
tfile->make<TH1F>(
"edepp",
"All Steps", 100, 0.0, 50.0);
221 h_edepp_->GetXaxis()->SetTitle(
"Energy Deposit (MeV)");
222 h_edepp_->GetYaxis()->SetTitle(
"Hits");
223 h_timep_ =
tfile->make<TH1F>(
"timep",
"All Steps", 100, 0.0, 100.0);
224 h_timep_->GetXaxis()->SetTitle(
"Hits");
225 h_timep_->GetYaxis()->SetTitle(
"Hit Time (ns)");
226 h_stepp_ =
tfile->make<TH1F>(
"stepp",
"All Steps", 1000, 0.0, 100.0);
227 h_stepp_->GetXaxis()->SetTitle(
"Hits");
228 h_stepp_->GetYaxis()->SetTitle(
"Step length (cm)");
230 sprintf(
name,
"edept%d",
k);
233 h_edepTk_.back()->GetYaxis()->SetTitle(
"Hits");
235 sprintf(
name,
"timet%d",
k);
238 h_timeTk_.back()->GetYaxis()->SetTitle(
"Hits");
243 int dmax = (
eta < 16) ? 4 : 7;
246 sprintf(
title,
"R vs Z (#eta = %d, depth = %d)",
eta,
depth);
249 h_rzH_.back()->GetXaxis()->SetTitle(
"z (cm)");
250 h_rzH_.back()->GetYaxis()->SetTitle(
"R (cm)");
259 std::vector<std::string>
labels = {
"EcalHitsEB1",
"EcalHitsEE1",
"HcalHits1"};
260 std::vector<double> times = {1, 1, 1};
262 desc.add<std::vector<std::string> >(
"hitCollection",
labels);
263 desc.add<std::vector<double> >(
"timeSliceUnit", times);
264 desc.addUntracked<
double>(
"maxEnergy", 250.0);
265 desc.addUntracked<
double>(
"maxTime", 1000.0);
266 desc.addUntracked<
double>(
"timeCut", 100.0);
267 desc.addUntracked<
double>(
"timeScale", 1.0);
268 desc.addUntracked<
double>(
"timeThreshold", 15.0);
269 desc.addUntracked<
bool>(
"testNumbering",
false);
270 desc.addUntracked<
bool>(
"passiveHits",
false);
271 std::vector<std::string>
names = {
"PixelBarrel",
"PixelForward",
"TIB",
"TID",
"TOB",
"TEC"};
272 desc.addUntracked<std::vector<std::string> >(
"detNames",
names);
273 desc.addUntracked<
int>(
"allStep", 100);
274 descriptions.
add(
"caloSimHitAnalysis",
desc);
278 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis:Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
288 bool getHits = (hitsCalo.
isValid());
290 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis: Input flags Hits[" <<
i <<
"]: " << getHits;
293 std::vector<PCaloHit> caloHits;
294 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
296 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis: Hit buffer [" <<
i <<
"] " << caloHits.size();
305 bool getHits = (hitsPassive.
isValid());
310 std::vector<PassiveHit> passiveHits;
311 passiveHits.insert(passiveHits.end(), hitsPassive->begin(), hitsPassive->end());
313 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis: Passive Hit buffer " << passiveHits.size();
321 int nHit =
hits.size();
322 int nHB = 0, nHE = 0, nHO = 0, nHF = 0, nEB = 0, nEE = 0, nBad = 0, iHit = 0;
323 std::map<CaloHitID, std::pair<double, double> > hitMap;
325 for (
unsigned int k = 0;
k <
nCalo_; ++
k) {
326 etot[
k] = etotG[
k] = 0;
329 double edep =
hit.energy();
331 uint32_t
id =
hit.
id();
332 int itra =
hit.geantTrackId();
333 double edepEM =
hit.energyEM();
334 double edepHad =
hit.energyHad();
354 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
357 }
else if (subdet == static_cast<int>(
HcalOuter)) {
360 }
else if (subdet == static_cast<int>(
HcalForward)) {
366 edm::LogVerbatim(
"HitStudy") <<
"Hit[" << iHit <<
":" << nHit <<
":" <<
idx <<
"] E " << edep <<
":" << edepEM
367 <<
":" << edepHad <<
" T " <<
time <<
" itra " << itra <<
" ID " << std::hex <<
id
373 auto itr = hitMap.find(hid);
374 if (itr == hitMap.end())
375 hitMap[hid] = std::make_pair(
time, edep);
377 ((itr->second).second) += edep;
392 for (
auto itr = hitMap.begin(); itr != hitMap.end(); ++itr) {
395 DetId id((itr->first).unitID());
398 << std::hex <<
id.rawId() <<
std::dec;
404 int subdet =
id.subdetId();
407 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
409 }
else if (subdet == static_cast<int>(
HcalOuter)) {
411 }
else if (subdet == static_cast<int>(
HcalForward)) {
416 double edep = (itr->second).
second;
442 h_etot_[indx]->Fill(etot[indx]);
445 h_hit_[indx]->Fill(
double(nEB));
447 h_hit_[indx]->Fill(
double(nEE));
449 h_hit_[2]->Fill(
double(nHB));
450 h_hit_[3]->Fill(
double(nHE));
451 h_hit_[4]->Fill(
double(nHO));
452 h_hit_[5]->Fill(
double(nHF));
459 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis::analyzeHits: EB " << nEB <<
" EE " << nEE <<
" HB " << nHB
460 <<
" HE " << nHE <<
" HO " << nHO <<
" HF " << nHF <<
" Bad " << nBad <<
" All " << nHit
461 <<
" Reduced " << hitMap.size();
467 std::map<std::pair<std::string, uint32_t>,
int> hitx;
468 std::map<int, int>
tracks;
469 unsigned int passive1(0), passive2(0);
472 std::pair<std::string, uint32_t> volume = std::make_pair(
name, (
hit.
id() % 1000000));
473 auto itr = hitx.find(volume);
474 if (itr == hitx.end())
486 if ((
name.find(active) != std::string::npos) || (
name.find(sensor) != std::string::npos)) {
501 uint32_t
id =
hit.
id();
507 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis::ID: " << hid <<
" Index " << indx <<
" Iterator "
512 uint32_t ipos = itr->second;
514 if (ipos <
h_rzH_.size()) {
524 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitAnalysis::analyzPassiveHits: Total " <<
hits.size() <<
" Cells "
525 << hitx.size() <<
" Tracks " <<
tracks.size() <<
" Passive " << passive1 <<
":"