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.;
void computeShowerWidth(float radius, bool withHalo=true)
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
constexpr std::array< uint8_t, layerIndexSize > layer
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_
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
component_iterator begin() const
Structure Point Contains parameters of Gaussian fits to DMRs.
std::vector< double > invThicknessCorrection_
void setHitMap(const std::unordered_map< DetId, const HGCRecHit *> *hitMap)
to set once per event
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
double eta() const
pseudorapidity of cluster centroid
const std::unordered_map< DetId, const HGCRecHit * > * hitMap_
Log< level::Warning, false > LogWarning
ROOT::Math::Transform3D::Point Point
const hgcal::RecHitTools * recHitTools_