15 using namespace hgcal;
21 invThicknessCorrection_({1. / 1.132, 1. / 1.092, 1. / 1.084}),
22 pca_(
new TPrincipal(3,
"D")) {
24 hitMap_ =
new std::map<DetId, const HGCRecHit *>();
46 for (
const auto&
hit : rechitsEE) {
50 for (
const auto&
hit : rechitsFH) {
54 for (
const auto&
hit : rechitsBH) {
64 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;
89 unsigned hfsize =
hf.size();
91 std::cout <<
"The seed cluster constains " << hfsize <<
" hits " << std::endl;
93 if (hfsize == 0)
return;
96 for (
unsigned int j = 0; j < hfsize; j++) {
99 const DetId rh_detid =
hf[j].first;
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() <<
" " << rh_detid.
det() <<
" " <<
HGCalDetId(rh_detid) << std::endl;
106 std::cout <<
"DetId " << rh_detid.
rawId() <<
" " << layer <<
" " << itcheck->second->energy() <<std::endl;
107 std::cout <<
" Hit " << itcheck->second <<
" " << itcheck->second->energy() << std::endl;
118 if (pcavars[2] == 0.)
121 Spot mySpot(rh_detid,itcheck->second->energy(),pcavars,layer,
fraction,mip);
132 pca_.reset(
new TPrincipal(3,
"D"));
133 bool initialCalculation = radius < 0;
135 std::cout <<
" Initial calculation " << initialCalculation << std::endl;
136 if (initialCalculation && withHalo) {
137 edm::LogWarning(
"EGammaPCAHelper") <<
"Warning - in the first iteration, the halo hits are excluded " << std::endl;
141 float radius2 = radius*
radius;
142 if (! initialCalculation) {
155 if (!withHalo && (! spot.isCore() ))
157 if (initialCalculation) {
159 if ( ! spot.isCore() )
continue;
160 layers.insert(spot.layer());
161 for (
int i = 0;
i < spot.multiplicity(); ++
i)
162 pca_->AddRow(spot.row());
167 if (local.Perp2() > radius2)
continue;
168 layers.insert(spot.layer());
169 for (
int i = 0;
i < spot.multiplicity(); ++
i)
170 pca_->AddRow(spot.row());
174 std::cout <<
" Nlayers " << layers.size() << std::endl;
175 if (layers.size() < 3) {
179 pca_->MakePrincipals();
181 const TVectorD& means = *(
pca_->GetMeanValues());
182 const TMatrixD& eigens = *(
pca_->GetEigenVectors());
198 float radius2 = radius *
radius;
200 Point globalPoint(spot.row()[0],spot.row()[1],spot.row()[2]);
202 if (local.Perp2() > radius2)
continue;
205 if (withHalo && spot.fraction() < 0)
continue;
206 if (!withHalo && !(spot.isCore()))
continue;
212 sigu_ += local.x() * local.x() * spot.energy();
213 sigv_ += local.y() * local.y() * spot.energy();
214 cyl_ene += spot.energy();
218 const double inv_cyl_ene = 1. / cyl_ene;
233 std::cout <<
" The PCA has not been run yet " << std::endl;
237 std::cout <<
" The PCA has been run only once - careful " << std::endl;
241 std::cout <<
" Not enough layers to perform PCA " << std::endl;
259 float radius2 = radius*
radius;
273 if (!withHalo && ! spot.isCore())
276 if (local.Perp2() > radius2)
continue;
277 energyPerLayer[spot.layer()] += spot.energy();
278 layers.insert(spot.layer());
284 return LongDeps(radius,energyPerLayer,energyEE,energyFH,energyBH,layers);
289 float radius2=radius*
radius;
290 for (
unsigned i =0;
i< nSpots ; ++
i) {
293 if (local.Perp2() < radius2 ) {
301 unsigned int firstLayer = 0;
313 expectedDepth = -999.;
314 expectedSigma = -999.;
315 measuredDepth = -999.;
void computeShowerWidth(float radius, bool withHalo=true)
math::XYZPoint barycenter_
static const unsigned int maxlayer
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
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
ROOT::Math::Transform3DPJ Transform3D
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
float getClusterDepthCompatibility(float measuredDepth, float emEnergy, float &expectedDepth, float &expectedSigma) const
double eta() const
pseudorapidity of cluster centroid
void storeRecHits(const reco::CaloCluster &theCluster)
ROOT::Math::Transform3DPJ::Point Point
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_
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
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
const hgcal::RecHitTools * recHitTools_
constexpr Detector det() const
get the detector field from this detid