51 void analyzeHits(std::vector<PCaloHit>&, std::vector<PCaloHit>&, std::vector<PCaloHit>&);
90 tkHighLab[0] =
"TrackerHitsPixelBarrelHighTof";
91 tkHighLab[1] =
"TrackerHitsPixelEndcapHighTof";
96 tkLowLab[0] =
"TrackerHitsPixelBarrelLowTof";
97 tkLowLab[1] =
"TrackerHitsPixelEndcapLowTof";
98 tkLowLab[2] =
"TrackerHitsTECLowTof";
99 tkLowLab[3] =
"TrackerHitsTIBLowTof";
100 tkLowLab[4] =
"TrackerHitsTIDLowTof";
101 tkLowLab[5] =
"TrackerHitsTOBLowTof";
104 for (
unsigned i = 0;
i != 4;
i++)
107 for (
unsigned i = 0;
i != 3;
i++)
110 for (
unsigned i = 0;
i != 6;
i++) {
116 <<
hitLab[2] <<
", " <<
hitLab[3] <<
" MaxEnergy: " << maxEnergy_
117 <<
" Tmax: " <<
tmax_ <<
" MIP Cut: " <<
eMIP_;
121 if (!
tfile.isAvailable())
123 <<
"please add it to config file";
125 sprintf(
title,
"Incident PT (GeV)");
128 ptInc_->GetYaxis()->SetTitle(
"Events");
129 sprintf(
title,
"Incident Energy (GeV)");
132 eneInc_->GetYaxis()->SetTitle(
"Events");
133 sprintf(
title,
"Incident #eta");
136 etaInc_->GetYaxis()->SetTitle(
"Events");
137 sprintf(
title,
"Incident #phi");
140 phiInc_->GetYaxis()->SetTitle(
"Events");
141 std::string dets[9] = {
"EB",
"EB(APD)",
"EB(ATJ)",
"EE",
"ES",
"HB",
"HE",
"HO",
"HF"};
142 for (
int i = 0;
i < 9;
i++) {
143 sprintf(
name,
"Hit%d",
i);
144 sprintf(
title,
"Number of hits in %s", dets[
i].c_str());
147 hit_[
i]->GetYaxis()->SetTitle(
"Events");
148 sprintf(
name,
"Time%d",
i);
149 sprintf(
title,
"Time of the hit (ns) in %s", dets[
i].c_str());
152 time_[
i]->GetYaxis()->SetTitle(
"Hits");
153 sprintf(
name,
"TimeAll%d",
i);
154 sprintf(
title,
"Hit time (ns) in %s with no check on Track ID", dets[
i].c_str());
157 timeAll_[
i]->GetYaxis()->SetTitle(
"Hits");
158 double ymax = maxEnergy_;
159 if (
i == 1 ||
i == 2 ||
i == 4)
161 else if (
i > 4 &&
i < 8)
163 sprintf(
name,
"Edep%d",
i);
164 sprintf(
title,
"Energy deposit (GeV) in %s", dets[
i].c_str());
167 edep_[
i]->GetYaxis()->SetTitle(
"Hits");
168 sprintf(
name,
"EdepEM%d",
i);
169 sprintf(
title,
"Energy deposit (GeV) by EM particles in %s", dets[
i].c_str());
172 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");
178 sprintf(
name,
"Etot%d",
i);
179 sprintf(
title,
"Total energy deposit (GeV) in %s", dets[
i].c_str());
182 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");
198 for (
int i = 0;
i < 9;
i++) {
200 if (
i == 0 ||
i == 3 ||
i == 6)
202 sprintf(
name,
"EdepCal%d",
i);
203 sprintf(
title,
"Energy deposit in %s", detx[
i].c_str());
206 edepC_[
i]->GetYaxis()->SetTitle(
"Events");
207 sprintf(
name,
"EdepCalT%d",
i);
208 sprintf(
title,
"Energy deposit (t < %f ns) in %s",
tmax_, detx[
i].c_str());
211 edepT_[
i]->GetYaxis()->SetTitle(
"Events");
213 hitLow =
tfile->make<TH1F>(
"HitLow",
"Number of hits in Track (Low)", 1000, 0, 10000.);
214 hitLow->GetXaxis()->SetTitle(
"Number of hits in Track (Low)");
215 hitLow->GetYaxis()->SetTitle(
"Events");
216 hitHigh =
tfile->make<TH1F>(
"HitHigh",
"Number of hits in Track (High)", 1000, 0, 10000.);
217 hitHigh->GetXaxis()->SetTitle(
"Number of hits in Track (High)");
218 hitHigh->GetYaxis()->SetTitle(
"Events");
219 hitMu =
tfile->make<TH1F>(
"HitMu",
"Number of hits in Track (Muon)", 1000, 0, 5000.);
220 hitMu->GetXaxis()->SetTitle(
"Number of hits in Muon");
221 hitMu->GetYaxis()->SetTitle(
"Events");
223 "Pixel Endcap (High)",
228 "Pixel Barrel (Low)",
229 "Pixel Endcap (Low)",
237 for (
int i = 0;
i < 15;
i++) {
238 sprintf(
name,
"HitTk%d",
i);
239 sprintf(
title,
"Number of hits in %s", dett[
i].c_str());
242 hitTk_[
i]->GetYaxis()->SetTitle(
"Events");
243 sprintf(
name,
"TimeTk%d",
i);
244 sprintf(
title,
"Time of the hit (ns) in %s", dett[
i].c_str());
247 tofTk_[
i]->GetYaxis()->SetTitle(
"Hits");
248 sprintf(
name,
"EdepTk%d",
i);
249 sprintf(
title,
"Energy deposit (GeV) in %s", dett[
i].c_str());
252 edepTk_[
i]->GetYaxis()->SetTitle(
"Hits");
269 descriptions.
add(
"CaloSimHitStudy", desc);
273 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy:Run = " <<
e.id().run() <<
" Event = " <<
e.id().event();
279 double eInc = 0, etaInc = 0, phiInc = 0;
280 HepMC::GenEvent::particle_const_iterator
p = myGenEvent->particles_begin();
281 if (
p != myGenEvent->particles_end()) {
282 eInc = (*p)->momentum().e();
283 etaInc = (*p)->momentum().eta();
284 phiInc = (*p)->momentum().phi();
286 double ptInc = eInc / std::cosh(etaInc);
292 std::vector<PCaloHit> ebHits, eeHits, hcHits;
293 for (
int i = 0;
i < 4;
i++) {
294 bool getHits =
false;
299 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy: Input flags Hits " << getHits;
302 std::vector<PCaloHit> caloHits;
303 caloHits.insert(caloHits.end(), hitsCalo->begin(), hitsCalo->end());
305 ebHits.insert(ebHits.end(), hitsCalo->begin(), hitsCalo->end());
307 eeHits.insert(eeHits.end(), hitsCalo->begin(), hitsCalo->end());
309 hcHits.insert(hcHits.end(), hitsCalo->begin(), hitsCalo->end());
310 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy: Hit buffer " << caloHits.size();
316 std::vector<PSimHit> muonHits;
318 for (
int i = 0;
i < 3;
i++) {
321 muonHits.insert(muonHits.end(), hitsTrack->begin(), hitsTrack->end());
325 unsigned int nhmu = muonHits.size();
326 hitMu->Fill(
double(nhmu));
327 std::vector<PSimHit> tkHighHits;
328 for (
int i = 0;
i < 6;
i++) {
331 tkHighHits.insert(tkHighHits.end(), hitsTrack->begin(), hitsTrack->end());
335 unsigned int nhtkh = tkHighHits.size();
337 std::vector<PSimHit> tkLowHits;
338 for (
int i = 0;
i < 6;
i++) {
341 tkLowHits.insert(tkLowHits.end(), hitsTrack->begin(), hitsTrack->end());
345 unsigned int nhtkl = tkLowHits.size();
346 hitLow->Fill(
double(nhtkl));
350 int nHit =
hits.size();
351 int nHB = 0, nHE = 0, nHO = 0, nHF = 0, nEB = 0, nEBAPD = 0, nEBATJ = 0, nEE = 0, nES = 0, nBad = 0;
352 std::map<unsigned int, double> hitMap;
353 std::vector<double> etot(9, 0), etotG(9, 0);
354 for (
int i = 0;
i < nHit;
i++) {
355 double edep =
hits[
i].energy();
357 unsigned int id_ =
hits[
i].id();
358 double edepEM =
hits[
i].energyEM();
359 double edepHad =
hits[
i].energyHad();
367 std::map<unsigned int, double>::const_iterator it = hitMap.find(id_);
368 if (it == hitMap.end()) {
369 hitMap.insert(std::pair<unsigned int, double>(id_,
time));
396 if (indx >= 0 && indx < 3) {
408 subdet =
id.subdet();
413 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
416 }
else if (subdet == static_cast<int>(
HcalOuter)) {
419 }
else if (subdet == static_cast<int>(
HcalForward)) {
437 etot_[indx + 2]->Fill(etot[indx + 2]);
438 etotg_[indx + 2]->Fill(etotG[indx + 2]);
440 etot_[indx]->Fill(etot[indx]);
441 etotg_[indx]->Fill(etotG[indx]);
442 etot_[indx + 1]->Fill(etot[indx + 1]);
443 etotg_[indx + 1]->Fill(etotG[indx + 1]);
444 hit_[indx]->Fill(
double(nEB));
445 hit_[indx + 1]->Fill(
double(nEBAPD));
446 hit_[indx + 2]->Fill(
double(nEBATJ));
448 hit_[indx + 2]->Fill(
double(nHit));
450 }
else if (indx == 3) {
451 hit_[5]->Fill(
double(nHB));
452 hit_[6]->Fill(
double(nHE));
453 hit_[7]->Fill(
double(nHO));
454 hit_[8]->Fill(
double(nHF));
461 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy::analyzeHits: EB " << nEB <<
", " << nEBAPD <<
", " << nEBATJ
462 <<
" EE " << nEE <<
" ES " << nES <<
" HB " << nHB <<
" HE " << nHE <<
" HO " << nHO
463 <<
" HF " << nHF <<
" Bad " << nBad <<
" All " << nHit <<
" Reduced " << hitMap.size();
464 std::map<unsigned int, double>::const_iterator it = hitMap.begin();
465 for (; it != hitMap.end(); it++) {
466 double time = it->second;
467 unsigned int id_ = (it->first);
471 if ((id_ & 0x20000) != 0)
473 else if ((id_ & 0x40000) != 0)
482 }
else if (indx == 3) {
483 int idx(-1), subdet(0);
489 subdet =
id.subdet();
493 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
495 }
else if (subdet == static_cast<int>(
HcalOuter)) {
497 }
else if (subdet == static_cast<int>(
HcalForward)) {
509 edm::PSimHitContainer::const_iterator ihit;
511 if (indx >= 0 && indx < 6)
513 else if (indx >= 6 && indx < 12)
515 else if (indx >= 12 && indx < 15)
517 for (ihit =
hits->begin(); ihit !=
hits->end(); ihit++) {
518 edepTk_[indx]->Fill(ihit->energyLoss());
519 tofTk_[indx]->Fill(ihit->timeOfFlight());
522 hitTk_[indx]->Fill(
float(nHit));
523 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy::analyzeHits: for " <<
label <<
" Index " << indx <<
" # of Hits "
528 std::vector<PCaloHit>& eeHits,
529 std::vector<PCaloHit>& hcHits) {
530 double edepEB = 0, edepEBT = 0;
531 for (
unsigned int i = 0;
i < ebHits.size();
i++) {
532 double edep = ebHits[
i].energy();
533 double time = ebHits[
i].time();
540 double edepEE = 0, edepEET = 0;
541 for (
unsigned int i = 0;
i < eeHits.size();
i++) {
542 double edep = eeHits[
i].energy();
543 double time = eeHits[
i].time();
548 double edepH = 0, edepHT = 0, edepHO = 0, edepHOT = 0;
549 for (
unsigned int i = 0;
i < hcHits.size();
i++) {
550 double edep = hcHits[
i].energy();
551 double time = hcHits[
i].time();
558 subdet =
id.subdet();
564 }
else if (subdet == static_cast<int>(
HcalOuter)) {
570 double edepE = edepEB + edepEE;
571 double edepET = edepEBT + edepEET;
572 double edepHC = edepH + edepHO;
573 double edepHCT = edepHT + edepHOT;
574 edm::LogVerbatim(
"HitStudy") <<
"CaloSimHitStudy::energy in EB " << edepEB <<
" (" << edepEBT <<
") from "
575 << ebHits.size() <<
" hits; "
576 <<
" energy in EE " << edepEE <<
" (" << edepEET <<
") from " << eeHits.size()
577 <<
" hits; energy in HC " << edepH <<
", " << edepHO <<
" (" << edepHT <<
", " << edepHOT
578 <<
") from " << hcHits.size() <<
" hits";
595 if (edepET <
eMIP_) {