15 using namespace hgcal;
21 invThicknessCorrection_({1. / 1.132, 1. / 1.092, 1. / 1.084}),
22 pca_(
new TPrincipal(3,
"D")) {
39 std::vector<std::pair<DetId, float>>
result;
41 const std::vector<std::pair<DetId, float>>&
hf = (*it)->hitsAndFractions();
53 std::vector<double> pcavars;
54 pcavars.resize(3, 0.);
63 unsigned hfsize =
hf.size();
65 std::cout <<
"The seed cluster constains " << hfsize <<
" hits " << std::endl;
70 for (
unsigned int j = 0;
j < hfsize;
j++) {
74 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck =
hitMap_->find(rh_detid);
75 if (itcheck ==
hitMap_->end()) {
76 edm::LogWarning(
"EgammaPCAHelper") <<
" Big problem, unable to find a hit " << rh_detid.
rawId() <<
" "
77 << rh_detid.
det() <<
" " <<
HGCalDetId(rh_detid) << std::endl;
81 std::cout <<
"DetId " << rh_detid.
rawId() <<
" " <<
layer <<
" " << itcheck->second->energy() << std::endl;
82 std::cout <<
" Hit " << itcheck->second <<
" " << itcheck->second->energy() << std::endl;
88 if (thickIndex > -1 and thickIndex < 3)
108 pca_ = std::make_unique<TPrincipal>(3,
"D");
109 bool initialCalculation =
radius < 0;
111 std::cout <<
" Initial calculation " << initialCalculation << std::endl;
112 if (initialCalculation && withHalo) {
113 edm::LogWarning(
"EGammaPCAHelper") <<
"Warning - in the first iteration, the halo hits are excluded " << std::endl;
118 if (!initialCalculation) {
136 if (!withHalo && (!spot.isCore()))
138 if (initialCalculation) {
142 layers.insert(spot.layer());
143 for (
int i = 0;
i < spot.multiplicity(); ++
i)
144 pca_->AddRow(spot.row());
148 if (
local.Perp2() > radius2)
150 layers.insert(spot.layer());
151 for (
int i = 0;
i < spot.multiplicity(); ++
i)
152 pca_->AddRow(spot.row());
161 pca_->MakePrincipals();
163 const TVectorD& means = *(
pca_->GetMeanValues());
164 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
182 Point globalPoint(spot.row()[0], spot.row()[1], spot.row()[2]);
184 if (
local.Perp2() > radius2)
188 if (withHalo && spot.fraction() < 0)
190 if (!withHalo && !(spot.isCore()))
199 cyl_ene += spot.energy();
203 const double inv_cyl_ene = 1. / cyl_ene;
218 std::cout <<
" The PCA has not been run yet " << std::endl;
222 std::cout <<
" The PCA has been run only once - careful " << std::endl;
226 std::cout <<
" Not enough layers to perform PCA " << std::endl;
263 if (!withHalo && !spot.isCore())
266 if (
local.Perp2() > radius2)
269 layers.insert(spot.layer());
271 energyEE += spot.energy();
273 energyFH += spot.energy();
275 energyBH += spot.energy();
284 for (
unsigned i = 0;
i < nSpots; ++
i) {
287 if (
local.Perp2() < radius2) {
296 unsigned int firstLayer = 0;
297 for (
unsigned il = 1; il <=
maxlayer_; ++il) {
308 float& measuredDepth,
309 float& expectedDepth,
310 float& expectedSigma) {
311 expectedDepth = -999.;
312 expectedSigma = -999.;
313 measuredDepth = -999.;