50 void analyzeHits(std::vector<PCaloHit>&, std::vector<PCaloHit>&, std::vector<PCaloHit>&);
89 tkHighLab[0] =
"TrackerHitsPixelBarrelHighTof";
90 tkHighLab[1] =
"TrackerHitsPixelEndcapHighTof";
95 tkLowLab[0] =
"TrackerHitsPixelBarrelLowTof";
96 tkLowLab[1] =
"TrackerHitsPixelEndcapLowTof";
97 tkLowLab[2] =
"TrackerHitsTECLowTof";
98 tkLowLab[3] =
"TrackerHitsTIBLowTof";
99 tkLowLab[4] =
"TrackerHitsTIDLowTof";
100 tkLowLab[5] =
"TrackerHitsTOBLowTof";
103 for (
unsigned i = 0;
i != 4;
i++)
106 for (
unsigned i = 0;
i != 3;
i++)
109 for (
unsigned i = 0;
i != 6;
i++) {
115 <<
hitLab[2] <<
", " <<
hitLab[3] <<
" MaxEnergy: " << maxEnergy_
116 <<
" Tmax: " <<
tmax_ <<
" MIP Cut: " <<
eMIP_;
120 if (!
tfile.isAvailable())
122 <<
"please add it to config file";
124 sprintf(
title,
"Incident PT (GeV)");
127 ptInc_->GetYaxis()->SetTitle(
"Events");
128 sprintf(
title,
"Incident Energy (GeV)");
131 eneInc_->GetYaxis()->SetTitle(
"Events");
132 sprintf(
title,
"Incident #eta");
135 etaInc_->GetYaxis()->SetTitle(
"Events");
136 sprintf(
title,
"Incident #phi");
139 phiInc_->GetYaxis()->SetTitle(
"Events");
140 std::string dets[9] = {
"EB",
"EB(APD)",
"EB(ATJ)",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
141 for (
int i = 0;
i < 9;
i++) {
142 sprintf(
name,
"Hit%d",
i);
143 sprintf(
title,
"Number of hits in %s", dets[
i].c_str());
146 hit_[
i]->GetYaxis()->SetTitle(
"Events");
147 sprintf(
name,
"Time%d",
i);
148 sprintf(
title,
"Time of the hit (ns) in %s", dets[
i].c_str());
151 time_[
i]->GetYaxis()->SetTitle(
"Hits");
152 sprintf(
name,
"TimeAll%d",
i);
153 sprintf(
title,
"Hit time (ns) in %s with no check on Track ID", dets[
i].c_str());
156 timeAll_[
i]->GetYaxis()->SetTitle(
"Hits");
157 double ymax = maxEnergy_;
158 if (
i == 1 ||
i == 2 ||
i == 4)
160 else if (
i > 4 &&
i < 8)
162 sprintf(
name,
"Edep%d",
i);
163 sprintf(
title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
166 edep_[
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");
172 sprintf(
name,
"EdepHad%d",
i);
173 sprintf(
title,
"Energy deposit (GeV) by hadrons in %s", dets[
i].c_str());
176 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");
182 sprintf(
name,
"EtotG%d",
i);
183 sprintf(
title,
"Total energy deposit (GeV) in %s (t < 100 ns)", dets[
i].c_str());
186 etotg_[
i]->GetYaxis()->SetTitle(
"Events");
197 for (
int i = 0;
i < 9;
i++) {
199 if (
i == 0 ||
i == 3 ||
i == 6)
201 sprintf(
name,
"EdepCal%d",
i);
202 sprintf(
title,
"Energy deposit in %s", detx[
i].c_str());
205 edepC_[
i]->GetYaxis()->SetTitle(
"Events");
206 sprintf(
name,
"EdepCalT%d",
i);
207 sprintf(
title,
"Energy deposit (t < %f ns) in %s",
tmax_, detx[
i].c_str());
210 edepT_[
i]->GetYaxis()->SetTitle(
"Events");
212 hitLow =
tfile->make<TH1F>(
"HitLow",
"Number of hits in Track (Low)", 1000, 0, 10000.);
213 hitLow->GetXaxis()->SetTitle(
"Number of hits in Track (Low)");
214 hitLow->GetYaxis()->SetTitle(
"Events");
215 hitHigh =
tfile->make<TH1F>(
"HitHigh",
"Number of hits in Track (High)", 1000, 0, 10000.);
216 hitHigh->GetXaxis()->SetTitle(
"Number of hits in Track (High)");
217 hitHigh->GetYaxis()->SetTitle(
"Events");
218 hitMu =
tfile->make<TH1F>(
"HitMu",
"Number of hits in Track (Muon)", 1000, 0, 5000.);
219 hitMu->GetXaxis()->SetTitle(
"Number of hits in Muon");
220 hitMu->GetYaxis()->SetTitle(
"Events");
222 "Pixel Endcap (High)",
227 "Pixel Barrel (Low)",
228 "Pixel Endcap (Low)",
236 for (
int i = 0;
i < 15;
i++) {
237 sprintf(
name,
"HitTk%d",
i);
238 sprintf(
title,
"Number of hits in %s", dett[
i].c_str());
241 hitTk_[
i]->GetYaxis()->SetTitle(
"Events");
242 sprintf(
name,
"TimeTk%d",
i);
243 sprintf(
title,
"Time of the hit (ns) in %s", dett[
i].c_str());
246 tofTk_[
i]->GetYaxis()->SetTitle(
"Hits");
247 sprintf(
name,
"EdepTk%d",
i);
248 sprintf(
title,
"Energy deposit (GeV) in %s", dett[
i].c_str());
251 edepTk_[
i]->GetYaxis()->SetTitle(
"Hits");
263 desc.addUntracked<
double>(
"MaxEnergy", 200.0);
264 desc.addUntracked<
double>(
"TimeCut", 100.0);
265 desc.addUntracked<
double>(
"MIPCut", 0.70);
266 desc.addUntracked<
bool>(
"StoreRL",
false);
267 desc.addUntracked<
bool>(
"TestNumbering",
false);
268 descriptions.
add(
"CaloSimHitStudy",
desc);
272 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy:Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
278 double eInc = 0, etaInc = 0, phiInc = 0;
279 HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
280 if (
p != myGenEvent->particles_end()) {
281 eInc = (*p)->momentum().e();
282 etaInc = (*p)->momentum().eta();
283 phiInc = (*p)->momentum().phi();
285 double ptInc = eInc / std::cosh(etaInc);
291 std::vector<PCaloHit> ebHits, eeHits, hcHits;
292 for (
int i = 0;
i < 4;
i++) {
293 bool getHits =
false;
298 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy: Input flags Hits " << getHits;
301 std::vector<PCaloHit> caloHits;
302 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
304 ebHits.insert(ebHits.end(), hitsCalo->begin(), hitsCalo->end());
306 eeHits.insert(eeHits.end(), hitsCalo->begin(), hitsCalo->end());
308 hcHits.insert(hcHits.end(), hitsCalo->begin(), hitsCalo->end());
309 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy: Hit buffer " << caloHits.size();
315 std::vector<PSimHit> muonHits;
317 for (
int i = 0;
i < 3;
i++) {
320 muonHits.insert(muonHits.end(), hitsTrack->begin(), hitsTrack->end());
324 unsigned int nhmu = muonHits.size();
325 hitMu->Fill(
double(nhmu));
326 std::vector<PSimHit> tkHighHits;
327 for (
int i = 0;
i < 6;
i++) {
330 tkHighHits.insert(tkHighHits.end(), hitsTrack->begin(), hitsTrack->end());
334 unsigned int nhtkh = tkHighHits.size();
336 std::vector<PSimHit> tkLowHits;
337 for (
int i = 0;
i < 6;
i++) {
340 tkLowHits.insert(tkLowHits.end(), hitsTrack->begin(), hitsTrack->end());
344 unsigned int nhtkl = tkLowHits.size();
345 hitLow->Fill(
double(nhtkl));
349 int nHit =
hits.size();
350 int nHB = 0, nHE = 0, nHO = 0, nHF = 0, nEB = 0, nEBAPD = 0, nEBATJ = 0, nEE = 0, nES = 0, nBad = 0;
351 std::map<unsigned int, double> hitMap;
352 std::vector<double> etot(9, 0), etotG(9, 0);
353 for (
int i = 0;
i < nHit;
i++) {
354 double edep =
hits[
i].energy();
356 unsigned int id_ =
hits[
i].id();
357 double edepEM =
hits[
i].energyEM();
358 double edepHad =
hits[
i].energyHad();
366 std::map<unsigned int, double>::const_iterator it = hitMap.find(id_);
367 if (it == hitMap.end()) {
368 hitMap.insert(std::pair<unsigned int, double>(id_,
time));
395 if (indx >= 0 && indx < 3) {
407 subdet =
id.subdet();
412 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
415 }
else if (subdet == static_cast<int>(
HcalOuter)) {
418 }
else if (subdet == static_cast<int>(
HcalForward)) {
436 etot_[indx + 2]->Fill(etot[indx + 2]);
437 etotg_[indx + 2]->Fill(etotG[indx + 2]);
439 etot_[indx]->Fill(etot[indx]);
440 etotg_[indx]->Fill(etotG[indx]);
441 etot_[indx + 1]->Fill(etot[indx + 1]);
442 etotg_[indx + 1]->Fill(etotG[indx + 1]);
443 hit_[indx]->Fill(
double(nEB));
444 hit_[indx + 1]->Fill(
double(nEBAPD));
445 hit_[indx + 2]->Fill(
double(nEBATJ));
447 hit_[indx + 2]->Fill(
double(nHit));
449 }
else if (indx == 3) {
450 hit_[5]->Fill(
double(nHB));
451 hit_[6]->Fill(
double(nHE));
452 hit_[7]->Fill(
double(nHO));
453 hit_[8]->Fill(
double(nHF));
460 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy::analyzeHits: EB " << nEB <<
", " << nEBAPD <<
", " << nEBATJ
461 <<
" EE " << nEE <<
" ES " << nES <<
" HB " << nHB <<
" HE " << nHE <<
" HO " << nHO
462 <<
" HF " << nHF <<
" Bad " << nBad <<
" All " << nHit <<
" Reduced " << hitMap.size();
463 std::map<unsigned int, double>::const_iterator it = hitMap.begin();
464 for (; it != hitMap.end(); it++) {
465 double time = it->second;
466 unsigned int id_ = (it->first);
470 if ((id_ & 0x20000) != 0)
472 else if ((id_ & 0x40000) != 0)
481 }
else if (indx == 3) {
482 int idx(-1), subdet(0);
488 subdet =
id.subdet();
492 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
494 }
else if (subdet == static_cast<int>(
HcalOuter)) {
496 }
else if (subdet == static_cast<int>(
HcalForward)) {
508 edm::PSimHitContainer::const_iterator ihit;
510 if (indx >= 0 && indx < 6)
512 else if (indx >= 6 && indx < 12)
514 else if (indx >= 12 && indx < 15)
516 for (ihit =
hits->begin(); ihit !=
hits->end(); ihit++) {
517 edepTk_[indx]->Fill(ihit->energyLoss());
518 tofTk_[indx]->Fill(ihit->timeOfFlight());
521 hitTk_[indx]->Fill(
float(nHit));
522 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy::analyzeHits: for " <<
label <<
" Index " << indx <<
" # of Hits "
527 std::vector<PCaloHit>& eeHits,
528 std::vector<PCaloHit>& hcHits) {
529 double edepEB = 0, edepEBT = 0;
530 for (
unsigned int i = 0;
i < ebHits.size();
i++) {
531 double edep = ebHits[
i].energy();
532 double time = ebHits[
i].time();
539 double edepEE = 0, edepEET = 0;
540 for (
unsigned int i = 0;
i < eeHits.size();
i++) {
541 double edep = eeHits[
i].energy();
542 double time = eeHits[
i].time();
547 double edepH = 0, edepHT = 0, edepHO = 0, edepHOT = 0;
548 for (
unsigned int i = 0;
i < hcHits.size();
i++) {
549 double edep = hcHits[
i].energy();
550 double time = hcHits[
i].time();
557 subdet =
id.subdet();
563 }
else if (subdet == static_cast<int>(
HcalOuter)) {
569 double edepE = edepEB + edepEE;
570 double edepET = edepEBT + edepEET;
571 double edepHC = edepH + edepHO;
572 double edepHCT = edepHT + edepHOT;
573 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy::energy in EB " << edepEB <<
" (" << edepEBT <<
") from "
574 << ebHits.size() <<
" hits; "
575 <<
" energy in EE " << edepEE <<
" (" << edepEET <<
") from " << eeHits.size()
576 <<
" hits; energy in HC " << edepH <<
", " << edepHO <<
" (" << edepHT <<
", " << edepHOT
577 <<
") from " << hcHits.size() <<
" hits";
594 if (edepET <
eMIP_) {