20 minEta_(pset.getParameter<double>(
"minEta")),
21 maxEta_(pset.getParameter<double>(
"maxEta")),
22 nintEta_(pset.getParameter<
int>(
"nintEta")),
23 useFabsEta_(pset.getParameter<
bool>(
"useFabsEta")),
26 minEne_(pset.getParameter<double>(
"minEne")),
27 maxEne_(pset.getParameter<double>(
"maxEne")),
28 nintEne_(pset.getParameter<
int>(
"nintEne")),
31 minPt_(pset.getParameter<double>(
"minPt")),
32 maxPt_(pset.getParameter<double>(
"maxPt")),
33 nintPt_(pset.getParameter<
int>(
"nintPt")),
36 minPhi_(pset.getParameter<double>(
"minPhi")),
37 maxPhi_(pset.getParameter<double>(
"maxPhi")),
38 nintPhi_(pset.getParameter<
int>(
"nintPhi")),
41 minMixedHitsCluster_(pset.getParameter<double>(
"minMixedHitsCluster")),
42 maxMixedHitsCluster_(pset.getParameter<double>(
"maxMixedHitsCluster")),
43 nintMixedHitsCluster_(pset.getParameter<
int>(
"nintMixedHitsCluster")),
46 minEneCl_(pset.getParameter<double>(
"minEneCl")),
47 maxEneCl_(pset.getParameter<double>(
"maxEneCl")),
48 nintEneCl_(pset.getParameter<
int>(
"nintEneCl")),
51 minLongDepBary_(pset.getParameter<double>(
"minLongDepBary")),
52 maxLongDepBary_(pset.getParameter<double>(
"maxLongDepBary")),
53 nintLongDepBary_(pset.getParameter<
int>(
"nintLongDepBary")),
56 minZpos_(pset.getParameter<double>(
"minZpos")),
57 maxZpos_(pset.getParameter<double>(
"maxZpos")),
58 nintZpos_(pset.getParameter<
int>(
"nintZpos")),
61 minTotNClsperlay_(pset.getParameter<double>(
"minTotNClsperlay")),
62 maxTotNClsperlay_(pset.getParameter<double>(
"maxTotNClsperlay")),
63 nintTotNClsperlay_(pset.getParameter<
int>(
"nintTotNClsperlay")),
66 minEneClperlay_(pset.getParameter<double>(
"minEneClperlay")),
67 maxEneClperlay_(pset.getParameter<double>(
"maxEneClperlay")),
68 nintEneClperlay_(pset.getParameter<
int>(
"nintEneClperlay")),
73 minScore_(pset.getParameter<double>(
"minScore")),
74 maxScore_(pset.getParameter<double>(
"maxScore")),
75 nintScore_(pset.getParameter<
int>(
"nintScore")),
82 minSharedEneFrac_(pset.getParameter<double>(
"minSharedEneFrac")),
83 maxSharedEneFrac_(pset.getParameter<double>(
"maxSharedEneFrac")),
84 nintSharedEneFrac_(pset.getParameter<
int>(
"nintSharedEneFrac")),
87 minTotNClsperthick_(pset.getParameter<double>(
"minTotNClsperthick")),
88 maxTotNClsperthick_(pset.getParameter<double>(
"maxTotNClsperthick")),
89 nintTotNClsperthick_(pset.getParameter<
int>(
"nintTotNClsperthick")),
92 minTotNcellsperthickperlayer_(pset.getParameter<double>(
"minTotNcellsperthickperlayer")),
93 maxTotNcellsperthickperlayer_(pset.getParameter<double>(
"maxTotNcellsperthickperlayer")),
94 nintTotNcellsperthickperlayer_(pset.getParameter<
int>(
"nintTotNcellsperthickperlayer")),
97 minDisToSeedperthickperlayer_(pset.getParameter<double>(
"minDisToSeedperthickperlayer")),
98 maxDisToSeedperthickperlayer_(pset.getParameter<double>(
"maxDisToSeedperthickperlayer")),
99 nintDisToSeedperthickperlayer_(pset.getParameter<
int>(
"nintDisToSeedperthickperlayer")),
102 minDisToSeedperthickperlayerenewei_(pset.getParameter<double>(
"minDisToSeedperthickperlayerenewei")),
103 maxDisToSeedperthickperlayerenewei_(pset.getParameter<double>(
"maxDisToSeedperthickperlayerenewei")),
104 nintDisToSeedperthickperlayerenewei_(pset.getParameter<
int>(
"nintDisToSeedperthickperlayerenewei")),
107 minDisToMaxperthickperlayer_(pset.getParameter<double>(
"minDisToMaxperthickperlayer")),
108 maxDisToMaxperthickperlayer_(pset.getParameter<double>(
"maxDisToMaxperthickperlayer")),
109 nintDisToMaxperthickperlayer_(pset.getParameter<
int>(
"nintDisToMaxperthickperlayer")),
112 minDisToMaxperthickperlayerenewei_(pset.getParameter<double>(
"minDisToMaxperthickperlayerenewei")),
113 maxDisToMaxperthickperlayerenewei_(pset.getParameter<double>(
"maxDisToMaxperthickperlayerenewei")),
114 nintDisToMaxperthickperlayerenewei_(pset.getParameter<
int>(
"nintDisToMaxperthickperlayerenewei")),
117 minDisSeedToMaxperthickperlayer_(pset.getParameter<double>(
"minDisSeedToMaxperthickperlayer")),
118 maxDisSeedToMaxperthickperlayer_(pset.getParameter<double>(
"maxDisSeedToMaxperthickperlayer")),
119 nintDisSeedToMaxperthickperlayer_(pset.getParameter<
int>(
"nintDisSeedToMaxperthickperlayer")),
122 minClEneperthickperlayer_(pset.getParameter<double>(
"minClEneperthickperlayer")),
123 maxClEneperthickperlayer_(pset.getParameter<double>(
"maxClEneperthickperlayer")),
124 nintClEneperthickperlayer_(pset.getParameter<
int>(
"nintClEneperthickperlayer")),
127 minCellsEneDensperthick_(pset.getParameter<double>(
"minCellsEneDensperthick")),
128 maxCellsEneDensperthick_(pset.getParameter<double>(
"maxCellsEneDensperthick")),
129 nintCellsEneDensperthick_(pset.getParameter<
int>(
"nintCellsEneDensperthick"))
178 std::string subpathtomat = pathtomatbudfile.substr(pathtomatbudfile.find(
"Validation"));
185 for (
unsigned ilayer = 0; ilayer < 2*
layers; ++ilayer) {
186 auto istr1 = std::to_string(ilayer);
187 while(istr1.size() < 2) {istr1.insert(0,
"0");}
191 if (ilayer < layers){
192 istr2 = std::to_string(ilayer + 1) +
" in z-";
194 istr2 = std::to_string(ilayer - 51) +
" in z+";
228 for(std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
229 auto istr = std::to_string(*it);
237 for(std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
238 for (
unsigned ilayer = 0; ilayer < 2*
layers; ++ilayer) {
239 auto istr1 = std::to_string(*it);
240 auto istr2 = std::to_string(ilayer);
241 while(istr2.size() < 2)
242 istr2.insert(0,
"0");
243 auto istr = istr1 +
"_" + istr2;
247 if (ilayer < layers){
248 istr3 = std::to_string(ilayer + 1) +
" in z- ";
250 istr3 = std::to_string(ilayer - 51) +
" in z+ ";
292 std::vector<SimVertex>
const &
simVertices)
const {
315 std::vector<CaloParticle>
const & cP,
316 std::map<DetId, const HGCRecHit *>
const & hitMap,
320 auto nLayerClusters = clusters.size();
321 auto nCaloParticles = cP.size();
323 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster> > detIdToCaloParticleId_Map;
324 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster> > detIdToLayerClusterId_Map;
327 std::vector<std::vector<std::pair<unsigned int, float> > > cpsInLayerCluster;
328 cpsInLayerCluster.resize(nLayerClusters);
332 std::vector<std::vector<caloParticleOnLayer> > cPOnLayer;
333 cPOnLayer.resize(nCaloParticles);
334 for(
unsigned int i = 0;
i< nCaloParticles; ++
i)
336 cPOnLayer[
i].resize(layers*2);
337 for(
unsigned int j = 0; j< layers*2; ++j)
339 cPOnLayer[
i][j].caloParticleId =
i;
340 cPOnLayer[
i][j].energy = 0.f;
341 cPOnLayer[
i][j].hits_and_fractions.clear();
345 for(
unsigned int cpId =0; cpId < nCaloParticles; ++cpId)
348 for (
const auto& it_sc : simClusterRefVector) {
351 for (
const auto& it_haf : hits_and_fractions) {
352 DetId hitid = (it_haf.first);
354 std::map<DetId,const HGCRecHit *>::const_iterator itcheck= hitMap.find(hitid);
355 if(itcheck != hitMap.end())
358 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
359 if (hit_find_it == detIdToCaloParticleId_Map.end())
361 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster> ();
367 if( findHitIt != detIdToCaloParticleId_Map[hitid].
end() )
369 findHitIt->fraction +=it_haf.second;
376 cPOnLayer[cpId][cpLayerId].energy += it_haf.second*hit->
energy();
377 cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid,it_haf.second);
384 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId)
386 const std::vector<std::pair<DetId, float> >& hits_and_fractions = clusters[lcId].hitsAndFractions();
387 unsigned int numberOfHitsInLC = hits_and_fractions.size();
389 std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
390 const auto firstHitDetId = hits_and_fractions[0].first;
391 int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) + layers * ((
recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1;
393 int maxCPId_byNumberOfHits = -1;
394 unsigned int maxCPNumberOfHitsInLC = 0;
395 int maxCPId_byEnergy = -1;
396 float maxEnergySharedLCandCP = 0.f;
397 float energyFractionOfLCinCP = 0.f;
398 float energyFractionOfCPinLC = 0.f;
399 std::unordered_map<unsigned, unsigned> occurrencesCPinLC;
400 std::unordered_map<unsigned, float> CPEnergyInLC;
401 unsigned int numberOfNoiseHitsInLC = 0;
402 unsigned int numberOfHaloHitsInLC = 0;
404 for (
unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++)
406 DetId rh_detid = hits_and_fractions[hitId].first;
407 auto rhFraction = hits_and_fractions[hitId].second;
409 std::map<DetId,const HGCRecHit *>::const_iterator itcheck= hitMap.find(rh_detid);
413 auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid);
414 if (hit_find_in_LC == detIdToLayerClusterId_Map.end())
416 detIdToLayerClusterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster> ();
420 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
428 if (rhFraction == 0.) {
429 hitsToCaloParticleId[hitId] = -2;
430 numberOfHaloHitsInLC++;
432 if (hit_find_in_CP == detIdToCaloParticleId_Map.end())
434 hitsToCaloParticleId[hitId] -= 1;
438 auto maxCPEnergyInLC = 0.f;
440 for(
auto&
h: hit_find_in_CP->second)
442 CPEnergyInLC[
h.clusterId] +=
h.fraction*hit->
energy();
443 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[lcId].first +=
h.fraction*hit->
energy();
444 cpsInLayerCluster[lcId].emplace_back(std::make_pair<int, float>(
h.clusterId, 0.f));
445 if(
h.fraction >maxCPEnergyInLC)
447 maxCPEnergyInLC = CPEnergyInLC[
h.clusterId];
448 maxCPId =
h.clusterId;
451 hitsToCaloParticleId[hitId] = maxCPId;
453 histograms.
h_cellAssociation_perlayer.at(lcLayerId%52+1).fill(hitsToCaloParticleId[hitId] > 0. ? 0. : hitsToCaloParticleId[hitId]);
456 for(
auto&
c: hitsToCaloParticleId)
460 numberOfNoiseHitsInLC++;
464 occurrencesCPinLC[
c]++;
468 for(
auto&
c : occurrencesCPinLC)
470 if(
c.second > maxCPNumberOfHitsInLC)
472 maxCPId_byNumberOfHits =
c.first;
473 maxCPNumberOfHitsInLC =
c.second;
477 for(
auto&
c : CPEnergyInLC)
479 if(
c.second > maxEnergySharedLCandCP)
481 maxCPId_byEnergy =
c.first;
482 maxEnergySharedLCandCP =
c.second;
485 float totalCPEnergyOnLayer = 0.f;
486 if(maxCPId_byEnergy >=0) {
487 totalCPEnergyOnLayer = cPOnLayer[maxCPId_byEnergy][lcLayerId].energy;
488 energyFractionOfCPinLC = maxEnergySharedLCandCP/totalCPEnergyOnLayer;
489 if(clusters[lcId].energy()>0.
f)
491 energyFractionOfLCinCP = maxEnergySharedLCandCP/clusters[lcId].energy();
494 LogDebug(
"HGCalValidator") << std::setw(10) <<
"LayerId:"<<
"\t" 495 << std::setw(12) <<
"layerCluster"<<
"\t" 496 << std::setw(10) <<
"lc energy"<<
"\t" 497 << std::setw(5) <<
"nhits" <<
"\t" 498 << std::setw(12) <<
"noise hits" <<
"\t" 499 << std::setw(22) <<
"maxCPId_byNumberOfHits" <<
"\t" 500 << std::setw(8) <<
"nhitsCP"<<
"\t" 501 << std::setw(16) <<
"maxCPId_byEnergy" <<
"\t" 502 << std::setw(23) <<
"maxEnergySharedLCandCP" <<
"\t" 503 << std::setw(22) <<
"totalCPEnergyOnLayer" <<
"\t" 504 << std::setw(22) <<
"energyFractionOfLCinCP" <<
"\t" 505 << std::setw(25) <<
"energyFractionOfCPinLC" <<
"\t" <<
"\n";
506 LogDebug(
"HGCalValidator") << std::setw(10) << lcLayerId <<
"\t" 507 << std::setw(12) << lcId <<
"\t" 508 << std::setw(10) << clusters[lcId].energy()<<
"\t" 509 << std::setw(5) << numberOfHitsInLC <<
"\t" 510 << std::setw(12) << numberOfNoiseHitsInLC <<
"\t" 511 << std::setw(22) << maxCPId_byNumberOfHits <<
"\t" 512 << std::setw(8) << maxCPNumberOfHitsInLC<<
"\t" 513 << std::setw(16) << maxCPId_byEnergy <<
"\t" 514 << std::setw(23) << maxEnergySharedLCandCP <<
"\t" 515 << std::setw(22) << totalCPEnergyOnLayer <<
"\t" 516 << std::setw(22) << energyFractionOfLCinCP <<
"\t" 517 << std::setw(25) << energyFractionOfCPinLC <<
"\n";
520 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId)
525 cpsInLayerCluster[lcId].erase(
last, cpsInLayerCluster[lcId].
end());
526 const std::vector<std::pair<DetId, float> >& hits_and_fractions = clusters[lcId].hitsAndFractions();
527 unsigned int numberOfHitsInLC = hits_and_fractions.size();
528 auto firstHitDetId = hits_and_fractions[0].first;
529 int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) + layers * ((
recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1;
530 if (clusters[lcId].energy() == 0. && !cpsInLayerCluster[lcId].empty()) {
531 for(
auto& cpPair : cpsInLayerCluster[lcId]) {
533 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId
534 <<
"\t CP id: \t" << cpPair.first
535 <<
"\t score \t" << cpPair.second
541 float invLayerClusterEnergyWeight = 1.f/(clusters[lcId].energy()*clusters[lcId].energy());
542 for(
unsigned int i = 0;
i < numberOfHitsInLC; ++
i)
544 DetId rh_detid = hits_and_fractions[
i].first;
545 float rhFraction = hits_and_fractions[
i].second;
546 bool hitWithNoCP =
false;
548 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
549 if(hit_find_in_CP == detIdToCaloParticleId_Map.end()) hitWithNoCP =
true;
550 auto itcheck= hitMap.find(rh_detid);
554 for(
auto& cpPair : cpsInLayerCluster[lcId])
556 float cpFraction = 0.f;
560 if(findHitIt != detIdToCaloParticleId_Map[rh_detid].
end())
561 cpFraction = findHitIt->fraction;
563 cpPair.second += (rhFraction - cpFraction)*(rhFraction - cpFraction)*hitEnergyWeight*invLayerClusterEnergyWeight;
567 if(cpsInLayerCluster[lcId].
empty())
LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\tCP id:\t-1 " <<
"\t score \t-1" <<
"\n";
569 for(
auto& cpPair : cpsInLayerCluster[lcId])
571 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId
572 <<
"\t CP id: \t" << cpPair.first
573 <<
"\t score \t" << cpPair.second
576 auto const & cp_linked = cPOnLayer[cpPair.first][lcLayerId].layerClusterIdToEnergyAndScore[lcId];
581 auto assoc = std::count_if(
592 auto best = std::min_element(
595 [](
const auto &obj1,
const auto &obj2){
return obj1.second < obj2.second;});
596 auto const & best_cp_linked = cPOnLayer[best->first][lcLayerId].layerClusterIdToEnergyAndScore[lcId];
606 for(
unsigned int cpId =0; cpId < nCaloParticles; ++cpId)
609 for(
unsigned int layerId = 0; layerId< layers*2; ++layerId)
611 unsigned int CPNumberOfHits = cPOnLayer[cpId][layerId].hits_and_fractions.size();
612 float CPenergy = cPOnLayer[cpId][layerId].energy;
613 if(CPNumberOfHits==0)
continue;
614 int lcWithMaxEnergyInCP = -1;
615 float maxEnergyLCinCP = 0.f;
616 float CPEnergyFractionInLC = 0.f;
617 for(
auto& lc : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore)
619 if(lc.second.first > maxEnergyLCinCP)
621 maxEnergyLCinCP = lc.second.first;
622 lcWithMaxEnergyInCP = lc.first;
625 if(CPenergy >0.
f) CPEnergyFractionInLC = maxEnergyLCinCP/CPenergy;
627 LogDebug(
"HGCalValidator") << std::setw(8) <<
"LayerId:\t" 628 << std::setw(12) <<
"caloparticle\t" 629 << std::setw(15) <<
"cp total energy\t" 630 << std::setw(15) <<
"cpEnergyOnLayer\t" 631 << std::setw(14) <<
"CPNhitsOnLayer\t" 632 << std::setw(18) <<
"lcWithMaxEnergyInCP\t" 633 << std::setw(15) <<
"maxEnergyLCinCP\t" 634 << std::setw(20) <<
"CPEnergyFractionInLC" <<
"\n";
635 LogDebug(
"HGCalValidator") << std::setw(8) << layerId <<
"\t" 636 << std::setw(12) << cpId <<
"\t" 637 << std::setw(15) << cP[cpId].energy() <<
"\t" 638 << std::setw(15) << CPenergy <<
"\t" 639 << std::setw(14) << CPNumberOfHits <<
"\t" 640 << std::setw(18) << lcWithMaxEnergyInCP <<
"\t" 641 << std::setw(15) << maxEnergyLCinCP <<
"\t" 642 << std::setw(20) << CPEnergyFractionInLC <<
"\n";
644 for(
unsigned int i=0;
i< CPNumberOfHits; ++
i)
646 auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[
i].first;
647 auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[
i].second;
650 bool hitWithNoLC =
false;
651 if(cpFraction ==0.
f)
continue;
652 auto hit_find_in_LC = detIdToLayerClusterId_Map.find(cp_hitDetId);
653 if(hit_find_in_LC == detIdToLayerClusterId_Map.end()) hitWithNoLC =
true;
654 auto itcheck= hitMap.find(cp_hitDetId);
657 float invCPEnergyWeight = 1.f/(CPenergy*CPenergy);
658 for(
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore)
660 unsigned int layerClusterId = lcPair.first;
661 float lcFraction = 0.f;
666 detIdToLayerClusterId_Map[cp_hitDetId].
begin(),
667 detIdToLayerClusterId_Map[cp_hitDetId].
end(),
670 if(findHitIt != detIdToLayerClusterId_Map[cp_hitDetId].
end())
671 lcFraction = findHitIt->fraction;
673 if (lcFraction == 0.) {
676 lcPair.second.second += (lcFraction - cpFraction)*(lcFraction - cpFraction)*hitEnergyWeight*invCPEnergyWeight;
677 LogDebug(
"HGCalValidator") <<
"layerClusterId:\t" << layerClusterId <<
"\t" 678 <<
"lcfraction,cpfraction:\t" << lcFraction <<
", " << cpFraction <<
"\t" 679 <<
"hitEnergyWeight:\t" << hitEnergyWeight <<
"\t" 680 <<
"currect score:\t" << lcPair.second.second <<
"\t" 681 <<
"invCPEnergyWeight:\t" << invCPEnergyWeight <<
"\n";
687 if(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore.empty())
688 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\tLC id:\t-1 " <<
"\t score \t-1" <<
"\n";
690 for(
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore)
692 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t LC id: \t" 693 << lcPair.first <<
"\t score \t" 694 << lcPair.second.second <<
"\t" 695 <<
"shared energy:\t" << lcPair.second.first <<
"\t" 696 <<
"shared energy fraction:\t" << (lcPair.second.first/CPenergy) <<
"\n";
701 auto assoc = std::count_if(
702 std::begin(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
703 std::end(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
712 auto best = std::min_element(
713 std::begin(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
714 std::end(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
715 [](
const auto &obj1,
const auto &obj2){
return obj1.second.second < obj2.second.second;});
729 std::vector<CaloParticle>
const & cP,
730 std::map<DetId, const HGCRecHit*>
const & hitMap,
731 std::map<double, double> cummatbudg,
733 std::vector<int> thicknesses)
const {
743 std::vector<int> tnlcpl(1000, 0);
746 std::map<std::string, int> tnlcpthplus; tnlcpthplus.clear();
747 std::map<std::string, int> tnlcpthminus; tnlcpthminus.clear();
749 for(std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
750 tnlcpthplus.insert( std::pair<std::string, int>(std::to_string(*it), 0) );
751 tnlcpthminus.insert( std::pair<std::string, int>(std::to_string(*it), 0) );
754 tnlcpthplus.insert( std::pair<std::string, int>(
"mixed", 0) );
755 tnlcpthminus.insert( std::pair<std::string, int>(
"mixed", 0) );
761 std::vector<double> tecpl(1000, 0.0);
763 std::vector<double> ldbar(1000, 0.0);
766 double caloparteneplus = 0.;
767 double caloparteneminus = 0.;
768 for (
auto const caloParticle : cP) {
769 if (caloParticle.eta() >= 0. ) {caloparteneplus = caloparteneplus + caloParticle.energy();}
770 if (caloParticle.eta() < 0. ) {caloparteneminus = caloparteneminus + caloParticle.energy();}
774 for (
unsigned int layerclusterIndex = 0; layerclusterIndex < clusters.size(); layerclusterIndex++) {
776 const std::vector<std::pair<DetId, float> > hits_and_fractions = clusters[layerclusterIndex].hitsAndFractions();
778 const DetId seedid = clusters[layerclusterIndex].seed();
779 const double seedx =
recHitTools_->getPosition(seedid).x();
780 const double seedy =
recHitTools_->getPosition(seedid).y();
788 int nthhits120p = 0;
int nthhits200p = 0;
int nthhits300p = 0;
int nthhitsscintp = 0;
789 int nthhits120m = 0;
int nthhits200m = 0;
int nthhits300m = 0;
int nthhitsscintm = 0;
791 double thickness = 0.;
804 for (std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin(); it_haf != hits_and_fractions.end(); ++it_haf) {
805 const DetId rh_detid = it_haf->first;
815 LogDebug(
"HGCalValidator") <<
"These are HGCal layer clusters, you shouldn't be here !!! " << layerid <<
"\n";
820 std::string curistr = std::to_string( (
int) thickness );
822 while(lay_string.size() < 2)
823 lay_string.insert(0,
"0");
824 curistr +=
"_" + lay_string;
825 if (cluslay){ tnlcpl[layerid]++; istr = curistr; cluslay =
false; }
827 if ( (thickness == 120.) && (
recHitTools_->zside(rh_detid) > 0. ) ) {nthhits120p++;}
828 else if ( (thickness == 120.) && (
recHitTools_->zside(rh_detid) < 0. ) ) {nthhits120m++;}
829 else if ( (thickness == 200.) && (
recHitTools_->zside(rh_detid) > 0. ) ) {nthhits200p++;}
830 else if ( (thickness == 200.) && (
recHitTools_->zside(rh_detid) < 0. ) ) {nthhits200m++;}
831 else if ( (thickness == 300.) && (
recHitTools_->zside(rh_detid) > 0. ) ) {nthhits300p++;}
832 else if ( (thickness == 300.) && (
recHitTools_->zside(rh_detid) < 0. ) ) {nthhits300m++;}
833 else if ( (thickness == -1) && (
recHitTools_->zside(rh_detid) > 0. ) ) {nthhitsscintp++;}
834 else if ( (thickness == -1) && (
recHitTools_->zside(rh_detid) < 0. ) ) {nthhitsscintm++;}
836 LogDebug(
"HGCalValidator") <<
" You are running a geometry that contains thicknesses different than the normal ones. " <<
"\n";
839 std::map<DetId,const HGCRecHit *>::const_iterator itcheck= hitMap.find(rh_detid);
840 if (itcheck == hitMap.end()) {
841 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a hit " << rh_detid.
rawId() <<
" " << rh_detid.
det() <<
" " <<
HGCalDetId(rh_detid) <<
"\n";
849 const double hit_x =
recHitTools_->getPosition(rh_detid).x();
850 const double hit_y =
recHitTools_->getPosition(rh_detid).y();
851 double distancetoseed =
distance(seedx, seedy, hit_x, hit_y);
852 double distancetomax =
distance(maxx, maxy, hit_x, hit_y);
867 std::map< DetId, float >::const_iterator dit = densities.find( rh_detid );
868 if ( dit == densities.end() ){
869 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a density " << rh_detid.
rawId() <<
" " << rh_detid.
det() <<
" " <<
HGCalDetId(rh_detid) <<
"\n";
880 if ( (nthhits120p != 0 && nthhits200p != 0 ) || (nthhits120p != 0 && nthhits300p != 0 ) || (nthhits120p != 0 && nthhitsscintp != 0 ) ||
881 (nthhits200p != 0 && nthhits300p != 0 ) || (nthhits200p != 0 && nthhitsscintp != 0 ) || (nthhits300p != 0 && nthhitsscintp != 0 ) ){
882 tnlcpthplus[
"mixed"]++;
883 }
else if ( (nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0) ) {
885 tnlcpthplus[std::to_string((
int) thickness)]++;
887 if ( (nthhits120m != 0 && nthhits200m != 0 ) || (nthhits120m != 0 && nthhits300m != 0 ) || (nthhits120m != 0 && nthhitsscintm != 0 ) ||
888 (nthhits200m != 0 && nthhits300m != 0 ) || (nthhits200m != 0 && nthhitsscintm != 0 ) || (nthhits300m != 0 && nthhitsscintm != 0 ) ){
889 tnlcpthminus[
"mixed"]++;
890 }
else if ( (nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0) ) {
892 tnlcpthminus[std::to_string((
int) thickness)]++;
896 std::vector<int> bigamoth; bigamoth.clear();
898 bigamoth.push_back(nthhits120p);bigamoth.push_back(nthhits200p);bigamoth.push_back(nthhits300p);bigamoth.push_back(nthhitsscintp);
901 bigamoth.push_back(nthhits120m);bigamoth.push_back(nthhits200m);bigamoth.push_back(nthhits300m);bigamoth.push_back(nthhitsscintm);
903 auto bgth = std::max_element(bigamoth.begin(),bigamoth.end());
904 istr = std::to_string(thicknesses[
std::distance(bigamoth.begin(), bgth) ]);
906 while(lay_string.size() < 2)
907 lay_string.insert(0,
"0");
908 istr +=
"_" + lay_string;
914 double distancebetseedandmax =
distance(seedx, seedy, maxx, maxy);
916 std::string seedstr = std::to_string( (
int)
recHitTools_->getSiThickness(seedid) )+
"_" + std::to_string(layerid);
917 seedstr +=
"_" + lay_string;
926 tecpl[layerid] = tecpl[layerid] + clusters[layerclusterIndex].energy();
927 ldbar[layerid] = ldbar[layerid] + clusters[layerclusterIndex].energy() * cummatbudg[(double) lay];
933 double sumeneallcluspl = 0.;
double sumeneallclusmi = 0.;
935 double sumldbarpl = 0.;
double sumldbarmi = 0.;
937 for (
unsigned ilayer = 0; ilayer < layers*2; ++ilayer) {
943 if (ilayer < layers){
945 if ( caloparteneminus != 0.) {
950 sumeneallclusmi = sumeneallclusmi + tecpl[ilayer];
952 sumldbarmi = sumldbarmi + ldbar[ilayer];
955 if ( caloparteneplus != 0.) {
960 sumeneallcluspl = sumeneallcluspl + tecpl[ilayer];
962 sumldbarpl = sumldbarpl + ldbar[ilayer];
968 for(std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
989 const double dx = x1 -
x2;
990 const double dy = y1 - y2;
991 return (dx*dx + dy*dy);
1002 std::map<DetId, const HGCRecHit*>
const & hitMap)
const {
1005 const std::vector<std::pair<DetId, float> >& hits_and_fractions = cluster.
hitsAndFractions();
1008 for (std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin(); it_haf != hits_and_fractions.end(); ++it_haf) {
1009 DetId rh_detid = it_haf->first;
1011 std::map<DetId,const HGCRecHit *>::const_iterator itcheck= hitMap.find(rh_detid);
1014 if ( maxene < hit->energy() ){
1016 themaxid = rh_detid;
constexpr float energy() const
std::unordered_map< std::string, ConcurrentMonitorElement > h_distancebetseedandmaxcell_perthickperlayer
ConcurrentMonitorElement bookProfile(Args &&...args)
std::unordered_map< int, ConcurrentMonitorElement > h_denom_caloparticle_eta_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_caloparticle_eta_Zorigin
std::vector< ConcurrentMonitorElement > h_cluster_eta
std::unordered_map< int, ConcurrentMonitorElement > h_clusternum_perthick
std::unordered_map< int, ConcurrentMonitorElement > h_denom_caloparticle_phi_perlayer
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
ConcurrentMonitorElement lastLayerFHzm
std::vector< ConcurrentMonitorElement > h_energyclustered_zminus
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
ConcurrentMonitorElement maxlayerzp
double minDisToSeedperthickperlayerenewei_
std::vector< ConcurrentMonitorElement > h_energyclustered_zplus
std::unordered_map< int, ConcurrentMonitorElement > h_energy_vs_score_layercl2caloparticle_perlayer
std::unordered_map< std::string, ConcurrentMonitorElement > h_cellsnum_perthickperlayer
int nintCellsEneDensperthick_
int nintClEneperthickperlayer_
std::unordered_map< int, ConcurrentMonitorElement > h_clusternum_perlayer
void setRecHitTools(std::shared_ptr< hgcal::RecHitTools > recHitTools)
std::unordered_map< int, ConcurrentMonitorElement > h_caloparticle_eta
constexpr uint32_t rawId() const
get the raw id
std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer
std::unordered_map< int, ConcurrentMonitorElement > h_numDup_caloparticle_eta_perlayer
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
int nintDisToMaxperthickperlayerenewei_
std::unordered_map< int, ConcurrentMonitorElement > h_denom_layercl_eta_perlayer
void layerClusters_to_CaloParticles(const Histograms &histograms, const reco::CaloClusterCollection &clusters, std::vector< CaloParticle > const &cP, std::map< DetId, const HGCRecHit * > const &, unsigned layers) const
std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetoseedcell_perthickperlayer
std::unordered_map< int, ConcurrentMonitorElement > h_denom_layercl_phi_perlayer
const std::vector< SimTrack > & g4Tracks() const
float eta() const
Momentum pseudorapidity. Note this is taken from the simtrack before the calorimeter.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void fill_info_histos(const Histograms &histograms, unsigned layers) const
std::vector< ConcurrentMonitorElement > h_longdepthbarycentre_zminus
int nintDisToMaxperthickperlayer_
std::unordered_map< int, ConcurrentMonitorElement > h_caloparticle_energy
double eta() const
pseudorapidity of cluster centroid
ConcurrentMonitorElement bookInt(Args &&...args)
std::unordered_map< int, ConcurrentMonitorElement > h_num_caloparticle_phi_perlayer
double distance(const double x1, const double y1, const double x2, const double y2) const
std::unordered_map< int, ConcurrentMonitorElement > h_energy_vs_score_caloparticle2layercl_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_caloparticle_pt
std::unordered_map< int, ConcurrentMonitorElement > h_sharedenergy_caloparticle2layercl_vs_eta_perlayer
std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer_eneweighted
hgcal_clustering::Density Density
std::vector< ConcurrentMonitorElement > h_mixedhitscluster_zminus
void fill_caloparticle_histos(const Histograms &histograms, int pdgid, const CaloParticle &caloparticle, std::vector< SimVertex > const &simVertices) const
std::unordered_map< int, ConcurrentMonitorElement > h_score_layercl2caloparticle_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_numMerge_layercl_phi_perlayer
void bookClusterHistos(DQMStore::ConcurrentBooker &ibook, Histograms &histograms, unsigned layers, std::vector< int > thicknesses, std::string pathtomatbudfile)
Monte Carlo truth information used for tracking validation.
ConcurrentMonitorElement book2D(Args &&...args)
std::unordered_map< int, ConcurrentMonitorElement > h_num_layercl_phi_perlayer
def unique(seq, keepstr=True)
double maxMixedHitsCluster_
float energy() const
Energy. Note this is taken from the first SimTrack only.
double minDisSeedToMaxperthickperlayer_
ConcurrentMonitorElement lastLayerEEzp
int nintDisToSeedperthickperlayerenewei_
ConcurrentMonitorElement book1D(Args &&...args)
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
double minDisToMaxperthickperlayer_
ConcurrentMonitorElement lastLayerFHzp
double getEta(double eta) const
std::vector< ConcurrentMonitorElement > h_mixedhitscluster_zplus
std::unordered_map< int, ConcurrentMonitorElement > h_num_caloparticle_eta_perlayer
void fill_generic_cluster_histos(const Histograms &histograms, int count, const reco::CaloClusterCollection &clusters, const Density &densities, std::vector< CaloParticle > const &cP, std::map< DetId, const HGCRecHit * > const &, std::map< double, double > cummatbudg, unsigned layers, std::vector< int > thicknesses) const
double maxDisToMaxperthickperlayer_
const double ScoreCutLCtoCP_
DetId findmaxhit(const reco::CaloCluster &cluster, std::map< DetId, const HGCRecHit * > const &) const
double maxDisToSeedperthickperlayer_
std::unordered_map< int, ConcurrentMonitorElement > h_cellAssociation_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_score_caloparticle2layercl_perlayer
ConcurrentMonitorElement lastLayerEEzm
double distance2(const double x1, const double y1, const double x2, const double y2) const
double maxTotNcellsperthickperlayer_
std::unordered_map< std::string, ConcurrentMonitorElement > h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer
std::unordered_map< int, ConcurrentMonitorElement > h_caloparticle_phi
double maxDisSeedToMaxperthickperlayer_
double minDisToSeedperthickperlayer_
std::unordered_map< int, ConcurrentMonitorElement > h_num_layercl_eta_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_sharedenergy_layercl2caloparticle_vs_eta_perlayer
double maxDisToSeedperthickperlayerenewei_
std::shared_ptr< hgcal::RecHitTools > recHitTools_
std::vector< ConcurrentMonitorElement > h_longdepthbarycentre_zplus
double minTotNClsperthick_
std::unordered_map< int, ConcurrentMonitorElement > h_sharedenergy_layercl2caloparticle_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_numDup_caloparticle_phi_perlayer
void bookInfo(DQMStore::ConcurrentBooker &ibook, Histograms &histograms)
void fill_cluster_histos(const Histograms &histograms, int count, const reco::CaloCluster &cluster) const
float pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetoseedcell_perthickperlayer_eneweighted
float phi() const
Momentum azimuthal angle. Note this is taken from the first SimTrack only.
int nintDisSeedToMaxperthickperlayer_
std::unordered_map< int, ConcurrentMonitorElement > h_sharedenergy_caloparticle2layercl_perlayer
double minTotNcellsperthickperlayer_
double minClEneperthickperlayer_
void fill(Args &&...args) const
std::unordered_map< int, ConcurrentMonitorElement > h_sharedenergy_layercl2caloparticle_vs_phi_perlayer
static int position[264][3]
ConcurrentMonitorElement maxlayerzm
std::unordered_map< int, ConcurrentMonitorElement > h_energyclustered_perlayer
double minDisToMaxperthickperlayerenewei_
double maxTotNClsperthick_
std::unordered_map< int, ConcurrentMonitorElement > h_sharedenergy_caloparticle2layercl_vs_phi_perlayer
std::unordered_map< int, ConcurrentMonitorElement > h_numMerge_layercl_eta_perlayer
double maxCellsEneDensperthick_
double maxDisToMaxperthickperlayerenewei_
const double ScoreCutCPtoLC_
int nintMixedHitsCluster_
double minMixedHitsCluster_
double maxClEneperthickperlayer_
int nintDisToSeedperthickperlayer_
int nintTotNcellsperthickperlayer_
std::unordered_map< int, ConcurrentMonitorElement > h_cellsenedens_perthick
HGVHistoProducerAlgo(const edm::ParameterSet &pset)
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
constexpr Detector det() const
get the detector field from this detid
void bookCaloParticleHistos(DQMStore::ConcurrentBooker &ibook, Histograms &histograms, int pdgid)
double minCellsEneDensperthick_