15 using namespace hgcal;
21 invThicknessCorrection_({1. / 1.132, 1. / 1.092, 1. / 1.084}),
22 pca_(
new TPrincipal(3,
"D")) {
35 unsigned int total_size = recHitHandleEE->
size() + recHitHandleFH->
size() + recHitHandleBH->
size();
36 hits_.resize(total_size);
39 for (
const auto&
handle : {recHitHandleEE, recHitHandleFH, recHitHandleBH}) {
40 unsigned int collection_size =
handle->size();
41 for (
unsigned int i = 0;
i < collection_size; ++
i) {
55 std::vector<std::pair<DetId, float>>
result;
57 const std::vector<std::pair<DetId, float>>&
hf = (*it)->hitsAndFractions();
69 std::vector<double> pcavars;
70 pcavars.resize(3, 0.);
79 unsigned hfsize =
hf.size();
81 std::cout <<
"The seed cluster constains " << hfsize <<
" hits " << std::endl;
86 for (
unsigned int j = 0;
j < hfsize;
j++) {
90 std::unordered_map<DetId, const unsigned int>::const_iterator itcheck =
hitMap_->find(rh_detid);
91 if (itcheck ==
hitMap_->end()) {
92 edm::LogWarning(
"EgammaPCAHelper") <<
" Big problem, unable to find a hit " << rh_detid.
rawId() <<
" " 93 << rh_detid.
det() <<
" " <<
HGCalDetId(rh_detid) << std::endl;
99 std::cout <<
"DetId " << rh_detid.
rawId() <<
" " << layer <<
" " <<
hit->energy() << std::endl;
106 if (thickIndex > -1 and thickIndex < 3)
112 if (pcavars[2] == 0.)
127 pca_ = std::make_unique<TPrincipal>(3,
"D");
128 bool initialCalculation =
radius < 0;
130 std::cout <<
" Initial calculation " << initialCalculation << std::endl;
131 if (initialCalculation && withHalo) {
132 edm::LogWarning(
"EGammaPCAHelper") <<
"Warning - in the first iteration, the halo hits are excluded " << std::endl;
137 if (!initialCalculation) {
155 if (!withHalo && (!spot.isCore()))
157 if (initialCalculation) {
161 layers.insert(spot.layer());
162 for (
int i = 0;
i < spot.multiplicity(); ++
i)
163 pca_->AddRow(spot.row());
167 if (
local.Perp2() > radius2)
169 layers.insert(spot.layer());
170 for (
int i = 0;
i < spot.multiplicity(); ++
i)
171 pca_->AddRow(spot.row());
180 pca_->MakePrincipals();
182 const TVectorD&
means = *(
pca_->GetMeanValues());
183 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
201 Point globalPoint(spot.row()[0], spot.row()[1], spot.row()[2]);
203 if (
local.Perp2() > radius2)
207 if (withHalo && spot.fraction() < 0)
209 if (!withHalo && !(spot.isCore()))
218 cyl_ene += spot.energy();
222 const double inv_cyl_ene = 1. / cyl_ene;
237 std::cout <<
" The PCA has not been run yet " << std::endl;
241 std::cout <<
" The PCA has been run only once - careful " << std::endl;
245 std::cout <<
" Not enough layers to perform PCA " << std::endl;
282 if (!withHalo && !spot.isCore())
285 if (
local.Perp2() > radius2)
288 layers.insert(spot.layer());
290 energyEE += spot.energy();
292 energyFH += spot.energy();
294 energyBH += spot.energy();
303 for (
unsigned i = 0;
i < nSpots; ++
i) {
306 if (
local.Perp2() < radius2) {
315 unsigned int firstLayer = 0;
316 for (
unsigned il = 1; il <=
maxlayer_; ++il) {
327 float& measuredDepth,
328 float& expectedDepth,
329 float& expectedSigma) {
330 expectedDepth = -999.;
331 expectedSigma = -999.;
332 measuredDepth = -999.;
void computeShowerWidth(float radius, bool withHalo=true)
std::vector< const HGCRecHit * > hits_
void printHits(float radius) const
math::XYZPoint barycenter_
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
void computePCA(float radius, bool withHalo=true)
LongDeps energyPerLayer(float radius, bool withHalo=true)
std::unique_ptr< TPrincipal > pca_
const double * row() const
const std::vector< float > & energyPerLayer() const
constexpr Detector det() const
get the detector field from this detid
double phi() const
azimuthal angle of cluster centroid
void storeRecHits(const reco::CaloCluster &theCluster)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Abs< T >::type abs(const T &t)
float getClusterDepthCompatibility(float measuredDepth, float emEnergy, float &expectedDepth, float &expectedSigma) const
std::vector< Spot > theSpots_
const std::unordered_map< DetId, const unsigned int > * hitMap_
ROOT::Math::Transform3D Transform3D
component_iterator end() const
bool checkIteration() const
void setRecHitTools(const hgcal::RecHitTools *recHitTools)
float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma)
float findZFirstLayer(const LongDeps &) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
constexpr uint32_t rawId() const
get the raw id
XYZPointD XYZPoint
point in space with cartesian internal representation
void setHitMap(const std::unordered_map< DetId, const unsigned int > *hitMap)
to set once per event
component_iterator begin() const
Structure Point Contains parameters of Gaussian fits to DMRs.
std::vector< double > invThicknessCorrection_
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
double eta() const
pseudorapidity of cluster centroid
Log< level::Warning, false > LogWarning
ROOT::Math::Transform3D::Point Point
void setRecHits(edm::Handle< HGCRecHitCollection > recHitHandleEE, edm::Handle< HGCRecHitCollection > recHitHandleFH, edm::Handle< HGCRecHitCollection > recHitHandleBH)
const hgcal::RecHitTools * recHitTools_