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();
68 result.insert(result.end(), hf.begin(), hf.end());
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;
143 float radius2 = radius *
radius;
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());
182 std::cout <<
" Nlayers " << layers.size() << std::endl;
183 if (layers.size() < 3) {
187 pca_->MakePrincipals();
189 const TVectorD& means = *(
pca_->GetMeanValues());
190 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
206 float radius2 = radius *
radius;
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()))
223 sigu_ += local.x() * local.x() * spot.energy();
224 sigv_ += local.y() * local.y() * spot.energy();
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;
271 float radius2 = radius *
radius;
289 if (!withHalo && !spot.isCore())
292 if (local.Perp2() > radius2)
294 energyPerLayer[spot.layer()] += spot.energy();
295 layers.insert(spot.layer());
297 energyEE += spot.energy();
299 energyFH += spot.energy();
301 energyBH += spot.energy();
304 return LongDeps(radius, energyPerLayer, energyEE, energyFH, energyBH, layers);
309 float radius2 = radius *
radius;
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.;
void computeShowerWidth(float radius, bool withHalo=true)
math::XYZPoint barycenter_
void computePCA(float radius, bool withHalo=true)
std::map< DetId, const HGCRecHit * > * hitMap_
LongDeps energyPerLayer(float radius, bool withHalo=true)
float findZFirstLayer(const LongDeps &) const
std::unique_ptr< TPrincipal > pca_
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
void storeRecHits(const reco::CaloCluster &theCluster)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
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
void setHitMap(std::map< DetId, const HGCRecHit * > *hitMap)
to set from outside - once per event
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
Structure Point Contains parameters of Gaussian fits to DMRs.
const double * row() const
std::vector< double > invThicknessCorrection_
void fillHitMap(const HGCRecHitCollection &HGCEERecHits, const HGCRecHitCollection &HGCFHRecHits, const HGCRecHitCollection &HGCBHRecHits)
to compute from inside - once per event
std::vector< double > dEdXWeights_
const reco::CaloCluster * theCluster_
bool checkIteration() const
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