194 const std::vector<CaloParticle>&
caloParticles = *caloParticleHandle;
206 std::map<DetId, const HGCRecHit*> hitmap;
212 const auto& rechitsEE = *recHitHandleEE;
213 const auto& rechitsFH = *recHitHandleFH;
214 const auto& rechitsBH = *recHitHandleBH;
215 for (
unsigned int i = 0;
i < rechitsEE.size(); ++
i) {
216 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
218 for (
unsigned int i = 0;
i < rechitsFH.size(); ++
i) {
219 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
221 for (
unsigned int i = 0;
i < rechitsBH.size(); ++
i) {
222 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
229 for (
unsigned int i = 0;
i < rechitsEE.
size();
i++) {
230 hitmap[rechitsEE[
i].detid()] = &rechitsEE[
i];
237 const auto& rechitsFH = *recHitHandleFH;
238 const auto& rechitsBH = *recHitHandleBH;
239 for (
unsigned int i = 0;
i < rechitsFH.size();
i++) {
240 hitmap[rechitsFH[
i].detid()] = &rechitsFH[
i];
242 for (
unsigned int i = 0;
i < rechitsBH.size();
i++) {
243 hitmap[rechitsBH[
i].detid()] = &rechitsBH[
i];
254 float seedEnergy = 0.;
256 <<
"Number of caloParticles: " << caloParticles.size() << std::endl;
257 for (
const auto& it_caloPart : caloParticles) {
264 for (
const auto& it_sc : simClusterRefVector) {
267 <<
">>> SC.energy(): " << simCluster.
energy()
268 <<
" SC.simEnergy(): " << simCluster.
simEnergy()
270 const std::vector<std::pair<uint32_t, float> >& hits_and_fractions =
274 for (
const auto& it_haf : hits_and_fractions) {
276 DetId hitid = (it_haf.first);
292 <<
">>> MC Energy: " << it_caloPart.energy()
293 <<
" reco energy: " << sumCalibRecHitCalib_fraction
297 it_caloPart.energy());
300 const auto&
clusters = *hgcalMultiClustersHandle;
301 float total_energy = 0.;
302 float max_dR2 = 0.0025;
303 auto closest = std::min_element(
clusters.begin(),
310 auto ERatio_b =
b.correctedEnergy()/it_caloPart.energy();
313 if (dR2_a < max_dR2 && dR2_b < max_dR2)
314 return ERatio_a > ERatio_b;
315 return dR2_a < dR2_b;
319 total_energy = closest->correctedEnergy();
323 it_caloPart.energy());
327 auto closest_fcn = [&](
auto const &
a,
auto const&
b){
330 auto ERatio_a = a.
energy()/it_caloPart.energy();
331 auto ERatio_b =
b.energy()/it_caloPart.energy();
334 if (dR2_a < max_dR2 && dR2_b < max_dR2)
335 return ERatio_a > ERatio_b;
336 return dR2_a < dR2_b;
339 if (PFElectronHandle.
isValid()) {
340 auto const & ele = (*PFElectronHandle);
341 auto closest = std::min_element(ele.begin(),
344 if (closest != ele.end()
345 && closest->superCluster()->seed()->seed().det() ==
DetId::Forward 350 it_caloPart.energy());
356 if (PFPhotonHandle.
isValid()) {
357 auto const &
photon = (*PFPhotonHandle);
358 auto closest = std::min_element(
photon.begin(),
361 if (closest !=
photon.end()
362 && closest->superCluster()->seed()->seed().det() ==
DetId::Forward 367 it_caloPart.energy());
edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_
edm::EDGetTokenT< std::vector< reco::Photon > > photons_
std::array< float, layers_ > Energy_layer_calib_fraction_
edm::EDGetTokenT< std::vector< reco::PFCluster > > hgcalMultiClusters_
std::map< int, MonitorElement * > hgcal_EoP_CPene_calib_fraction_
double correctedEnergy() const
edm::EDGetTokenT< HGCRecHitCollection > recHitsFH_
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
edm::EDGetTokenT< HGCRecHitCollection > recHitsEE_
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< int, MonitorElement * > hgcal_ele_EoP_CPene_calib_fraction_
#define IfLogTrace(cond, cat)
std::map< int, MonitorElement * > hgcal_photon_EoP_CPene_calib_fraction_
edm::EDGetTokenT< HGCRecHitCollection > recHitsBH_
Monte Carlo truth information used for tracking validation.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
float energy() const
Energy. Note this is taken from the first SimTrack only.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
double energy() const
cluster energy
hgcal::RecHitTools recHitTools_
float simEnergy() const
returns the accumulated sim energy in the cluster
edm::EDGetTokenT< std::vector< reco::GsfElectron > > electrons_
std::map< int, MonitorElement * > h_EoP_CPene_calib_fraction_
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
void fillWithRecHits(std::map< DetId, const HGCRecHit * > &, DetId, unsigned int, float, int &, float &)
std::array< float, layers_ > Energy_layer_calib_
Detector det() const
get the detector field from this detid