14 using namespace hgcal;
20 invThicknessCorrection_({1. / 1.132, 1. / 1.092, 1. / 1.084}),
21 pca_(
new TPrincipal(3,
"D")) {
23 hitMap_ =
new std::map<DetId, const HGCRecHit*>();
47 for (
const auto&
hit : rechitsEE) {
51 for (
const auto&
hit : rechitsFH) {
55 for (
const auto&
hit : rechitsBH) {
65 std::vector<std::pair<DetId, float>>
result;
67 const std::vector<std::pair<DetId, float>>&
hf = (*it)->hitsAndFractions();
79 std::vector<double> pcavars;
80 pcavars.resize(3, 0.);
89 unsigned hfsize =
hf.size();
91 std::cout <<
"The seed cluster constains " << hfsize <<
" hits " << std::endl;
96 for (
unsigned int j = 0;
j < hfsize;
j++) {
100 std::map<DetId, const HGCRecHit*>::const_iterator itcheck =
hitMap_->find(rh_detid);
101 if (itcheck ==
hitMap_->end()) {
102 edm::LogWarning(
"EgammaPCAHelper") <<
" Big problem, unable to find a hit " << rh_detid.
rawId() <<
" "
103 << rh_detid.
det() <<
" " <<
HGCalDetId(rh_detid) << std::endl;
107 std::cout <<
"DetId " << rh_detid.
rawId() <<
" " << layer <<
" " << itcheck->second->energy() << std::endl;
108 std::cout <<
" Hit " << itcheck->second <<
" " << itcheck->second->energy() << std::endl;
114 if (thickIndex > -1 and thickIndex < 3)
120 if (pcavars[2] == 0.)
123 Spot mySpot(rh_detid, itcheck->second->energy(), pcavars, layer,
fraction, mip);
134 pca_.reset(
new TPrincipal(3,
"D"));
135 bool initialCalculation =
radius < 0;
137 std::cout <<
" Initial calculation " << initialCalculation << std::endl;
138 if (initialCalculation && withHalo) {
139 edm::LogWarning(
"EGammaPCAHelper") <<
"Warning - in the first iteration, the halo hits are excluded " << std::endl;
144 if (!initialCalculation) {
162 if (!withHalo && (!spot.isCore()))
164 if (initialCalculation) {
168 layers.insert(spot.layer());
169 for (
int i = 0;
i < spot.multiplicity(); ++
i)
170 pca_->AddRow(spot.row());
174 if (
local.Perp2() > radius2)
176 layers.insert(spot.layer());
177 for (
int i = 0;
i < spot.multiplicity(); ++
i)
178 pca_->AddRow(spot.row());
187 pca_->MakePrincipals();
189 const TVectorD& means = *(
pca_->GetMeanValues());
190 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
208 Point globalPoint(spot.row()[0], spot.row()[1], spot.row()[2]);
210 if (
local.Perp2() > radius2)
214 if (withHalo && spot.fraction() < 0)
216 if (!withHalo && !(spot.isCore()))
225 cyl_ene += spot.energy();
229 const double inv_cyl_ene = 1. / cyl_ene;
244 std::cout <<
" The PCA has not been run yet " << std::endl;
248 std::cout <<
" The PCA has been run only once - careful " << std::endl;
252 std::cout <<
" Not enough layers to perform PCA " << std::endl;
289 if (!withHalo && !spot.isCore())
292 if (
local.Perp2() > radius2)
295 layers.insert(spot.layer());
297 energyEE += spot.energy();
299 energyFH += spot.energy();
301 energyBH += spot.energy();
310 for (
unsigned i = 0;
i < nSpots; ++
i) {
313 if (
local.Perp2() < radius2) {
322 unsigned int firstLayer = 0;
323 for (
unsigned il = 1; il <=
maxlayer_; ++il) {
334 float& measuredDepth,
335 float& expectedDepth,
336 float& expectedSigma) {
337 expectedDepth = -999.;
338 expectedSigma = -999.;
339 measuredDepth = -999.;