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();
42 result.insert(result.end(), hf.begin(), hf.end());
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++) {
73 const DetId rh_detid = hf[
j].first;
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;
117 float radius2 = radius *
radius;
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());
156 std::cout <<
" Nlayers " << layers.size() << std::endl;
157 if (layers.size() < 3) {
161 pca_->MakePrincipals();
163 const TVectorD&
means = *(
pca_->GetMeanValues());
164 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
180 float radius2 = radius *
radius;
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()))
197 sigu_ += local.x() * local.x() * spot.energy();
198 sigv_ += local.y() * local.y() * spot.energy();
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;
245 float radius2 = radius *
radius;
263 if (!withHalo && !spot.isCore())
266 if (local.Perp2() > radius2)
268 energyPerLayer[spot.layer()] += spot.energy();
269 layers.insert(spot.layer());
271 energyEE += spot.energy();
273 energyFH += spot.energy();
275 energyBH += spot.energy();
278 return LongDeps(radius, energyPerLayer, energyEE, energyFH, energyBH, layers);
283 float radius2 = radius *
radius;
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)
math::XYZPoint barycenter_
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
void computePCA(float radius, bool withHalo=true)
LongDeps energyPerLayer(float radius, bool withHalo=true)
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
float findZFirstLayer(const LongDeps &) const
std::unique_ptr< TPrincipal > pca_
void setHitMap(const std::unordered_map< DetId, const HGCRecHit * > *hitMap)
to set once per event
component_iterator begin() const
constexpr uint32_t rawId() const
get the raw id
float getClusterDepthCompatibility(float measuredDepth, float emEnergy, float &expectedDepth, float &expectedSigma) const
double eta() const
pseudorapidity of cluster centroid
constexpr std::array< uint8_t, layerIndexSize > layer
void storeRecHits(const reco::CaloCluster &theCluster)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Abs< T >::type abs(const T &t)
std::vector< Spot > theSpots_
ROOT::Math::Transform3D Transform3D
component_iterator end() const
void setRecHitTools(const hgcal::RecHitTools *recHitTools)
float clusterDepthCompatibility(const LongDeps &, float &measuredDepth, float &expectedDepth, float &expectedSigma)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const std::vector< float > & energyPerLayer() const
void printHits(float radius) const
pca_(new TPrincipal(3,"D"))
Structure Point Contains parameters of Gaussian fits to DMRs.
const double * row() const
std::vector< double > invThicknessCorrection_
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
bool checkIteration() const
const std::unordered_map< DetId, const HGCRecHit * > * hitMap_
Log< level::Warning, false > LogWarning
double phi() const
azimuthal angle of cluster centroid
ROOT::Math::Transform3D::Point Point
const hgcal::RecHitTools * recHitTools_
constexpr Detector det() const
get the detector field from this detid