Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-16 06:16:10

0001 #ifndef Validation_HGCalValidation_HGVHistoProducerAlgo_h
0002 #define Validation_HGCalValidation_HGVHistoProducerAlgo_h
0003 
0004 /* \author HGCal
0005  */
0006 
0007 #include <iostream>
0008 #include <fstream>
0009 #include <vector>
0010 #include <unordered_map>
0011 
0012 #include "FWCore/Framework/interface/ConsumesCollector.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 
0016 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0017 #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0018 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0019 #include "DataFormats/HGCRecHit/interface/HGCRecHit.h"
0020 #include "DataFormats/HGCalReco/interface/Trackster.h"
0021 
0022 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0023 #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h"
0024 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0025 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h"
0026 #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociatorBaseImpl.h"
0027 #include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociatorBaseImpl.h"
0028 
0029 #include "DQMServices/Core/interface/DQMStore.h"
0030 
0031 struct HGVHistoProducerAlgoHistograms {
0032   //Info
0033   //To be able to spot any issues both in -z and +z a layer id was introduced
0034   //that spans from 0 to 103 for hgcal_v9 geometry. The mapping for hgcal_v9 is:
0035   //-z: 0->51
0036   //+z: 52->103
0037   //We will pick the numbers below from RecHitTools just to avoid future problems
0038   dqm::reco::MonitorElement* lastLayerEEzm;  // last layer of EE -z
0039   dqm::reco::MonitorElement* lastLayerFHzm;  // last layer of FH -z
0040   dqm::reco::MonitorElement* maxlayerzm;     // last layer of BH -z
0041   dqm::reco::MonitorElement* lastLayerEEzp;  // last layer of EE +z
0042   dqm::reco::MonitorElement* lastLayerFHzp;  // last layer of FH +z
0043   dqm::reco::MonitorElement* maxlayerzp;     // last layer of BH +z
0044 
0045   //1D
0046   std::vector<dqm::reco::MonitorElement*> h_cluster_eta;
0047   std::vector<dqm::reco::MonitorElement*> h_mixedhitscluster_zminus;
0048   std::vector<dqm::reco::MonitorElement*> h_mixedhitscluster_zplus;
0049   std::vector<dqm::reco::MonitorElement*> h_energyclustered_zminus;
0050   std::vector<dqm::reco::MonitorElement*> h_energyclustered_zplus;
0051   std::vector<dqm::reco::MonitorElement*> h_longdepthbarycentre_zminus;
0052   std::vector<dqm::reco::MonitorElement*> h_longdepthbarycentre_zplus;
0053 
0054   std::unordered_map<int, dqm::reco::MonitorElement*> h_clusternum_perlayer;
0055   std::unordered_map<int, dqm::reco::MonitorElement*> h_energyclustered_perlayer;
0056   std::unordered_map<int, dqm::reco::MonitorElement*> h_score_layercl2caloparticle_perlayer;
0057   std::unordered_map<int, dqm::reco::MonitorElement*> h_score_caloparticle2layercl_perlayer;
0058   std::unordered_map<int, dqm::reco::MonitorElement*> h_energy_vs_score_caloparticle2layercl_perlayer;
0059   std::unordered_map<int, dqm::reco::MonitorElement*> h_energy_vs_score_layercl2caloparticle_perlayer;
0060   std::unordered_map<int, dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2layercl_perlayer;
0061   std::unordered_map<int, dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2layercl_vs_eta_perlayer;
0062   std::unordered_map<int, dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2layercl_vs_phi_perlayer;
0063   std::unordered_map<int, dqm::reco::MonitorElement*> h_sharedenergy_layercl2caloparticle_perlayer;
0064   std::unordered_map<int, dqm::reco::MonitorElement*> h_sharedenergy_layercl2caloparticle_vs_eta_perlayer;
0065   std::unordered_map<int, dqm::reco::MonitorElement*> h_sharedenergy_layercl2caloparticle_vs_phi_perlayer;
0066   std::unordered_map<int, dqm::reco::MonitorElement*> h_num_caloparticle_eta_perlayer;
0067   std::unordered_map<int, dqm::reco::MonitorElement*> h_numDup_caloparticle_eta_perlayer;
0068   std::unordered_map<int, dqm::reco::MonitorElement*> h_denom_caloparticle_eta_perlayer;
0069   std::unordered_map<int, dqm::reco::MonitorElement*> h_num_caloparticle_phi_perlayer;
0070   std::unordered_map<int, dqm::reco::MonitorElement*> h_numDup_caloparticle_phi_perlayer;
0071   std::unordered_map<int, dqm::reco::MonitorElement*> h_denom_caloparticle_phi_perlayer;
0072   std::unordered_map<int, dqm::reco::MonitorElement*> h_num_layercl_eta_perlayer;
0073   std::unordered_map<int, dqm::reco::MonitorElement*> h_numMerge_layercl_eta_perlayer;
0074   std::unordered_map<int, dqm::reco::MonitorElement*> h_denom_layercl_eta_perlayer;
0075   std::unordered_map<int, dqm::reco::MonitorElement*> h_num_layercl_phi_perlayer;
0076   std::unordered_map<int, dqm::reco::MonitorElement*> h_numMerge_layercl_phi_perlayer;
0077   std::unordered_map<int, dqm::reco::MonitorElement*> h_denom_layercl_phi_perlayer;
0078   std::unordered_map<int, dqm::reco::MonitorElement*> h_cellAssociation_perlayer;
0079   std::unordered_map<int, dqm::reco::MonitorElement*> h_clusternum_perthick;
0080   std::unordered_map<int, dqm::reco::MonitorElement*> h_cellsenedens_perthick;
0081 
0082   std::unordered_map<std::string, dqm::reco::MonitorElement*> h_cellsnum_perthickperlayer;
0083   std::unordered_map<std::string, dqm::reco::MonitorElement*> h_distancetoseedcell_perthickperlayer;
0084   std::unordered_map<std::string, dqm::reco::MonitorElement*> h_distancetoseedcell_perthickperlayer_eneweighted;
0085   std::unordered_map<std::string, dqm::reco::MonitorElement*> h_distancetomaxcell_perthickperlayer;
0086   std::unordered_map<std::string, dqm::reco::MonitorElement*> h_distancetomaxcell_perthickperlayer_eneweighted;
0087   std::unordered_map<std::string, dqm::reco::MonitorElement*> h_distancebetseedandmaxcell_perthickperlayer;
0088   std::unordered_map<std::string, dqm::reco::MonitorElement*>
0089       h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer;
0090 
0091   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_eta;
0092   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_eta_Zorigin;
0093   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_energy;
0094   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_selfenergy;
0095   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_energyDifference;
0096   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_pt;
0097   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_phi;
0098   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_nSimClusters;
0099   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_nHitsInSimClusters;
0100   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_firstlayer;
0101   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_lastlayer;
0102   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_layersnum;
0103   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_nHitsInSimClusters_matchedtoRecHit;
0104   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_nHits_matched_energy;
0105   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_nHits_matched_energy_layer;
0106   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_nHits_matched_energy_layer_1SimCl;
0107   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_sum_energy_layer;
0108   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_firstlayer_matchedtoRecHit;
0109   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_lastlayer_matchedtoRecHit;
0110   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_layersnum_matchedtoRecHit;
0111   std::unordered_map<int, dqm::reco::MonitorElement*> h_caloparticle_fractions, h_caloparticle_fractions_weight;
0112 
0113   //For SimClusters
0114   std::unordered_map<int, dqm::reco::MonitorElement*> h_simclusternum_perlayer;
0115   std::unordered_map<int, dqm::reco::MonitorElement*> h_simclusternum_perthick;
0116   dqm::reco::MonitorElement* h_mixedhitssimcluster_zminus;
0117   dqm::reco::MonitorElement* h_mixedhitssimcluster_zplus;
0118 
0119   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_denom_layercl_in_simcl_eta_perlayer;
0120   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_denom_layercl_in_simcl_phi_perlayer;
0121   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_score_layercl2simcluster_perlayer;
0122   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_sharedenergy_layercl2simcluster_perlayer;
0123   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_energy_vs_score_layercl2simcluster_perlayer;
0124   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_num_layercl_in_simcl_eta_perlayer;
0125   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_num_layercl_in_simcl_phi_perlayer;
0126   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_numMerge_layercl_in_simcl_eta_perlayer;
0127   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_numMerge_layercl_in_simcl_phi_perlayer;
0128   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_sharedenergy_layercl2simcluster_vs_eta_perlayer;
0129   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_sharedenergy_layercl2simcluster_vs_phi_perlayer;
0130   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_denom_simcluster_eta_perlayer;
0131   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_denom_simcluster_phi_perlayer;
0132   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_score_simcluster2layercl_perlayer;
0133   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_sharedenergy_simcluster2layercl_perlayer;
0134   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_energy_vs_score_simcluster2layercl_perlayer;
0135   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_num_simcluster_eta_perlayer;
0136   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_num_simcluster_phi_perlayer;
0137   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_numDup_simcluster_eta_perlayer;
0138   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_numDup_simcluster_phi_perlayer;
0139   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_sharedenergy_simcluster2layercl_vs_eta_perlayer;
0140   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_sharedenergy_simcluster2layercl_vs_phi_perlayer;
0141 
0142   // For Tracksters
0143   // Linking and Pattern Recognition
0144   std::vector<dqm::reco::MonitorElement*> h_score_trackster2caloparticle[2];
0145   std::vector<dqm::reco::MonitorElement*> h_score_trackster2bestCaloparticle[2];
0146   std::vector<dqm::reco::MonitorElement*> h_score_trackster2bestCaloparticle2[2];
0147   std::vector<dqm::reco::MonitorElement*> h_score_caloparticle2trackster[2];
0148   std::vector<dqm::reco::MonitorElement*> h_scorePur_caloparticle2trackster[2];
0149   std::vector<dqm::reco::MonitorElement*> h_scoreDupl_caloparticle2trackster[2];
0150   std::vector<dqm::reco::MonitorElement*> h_energy_vs_score_trackster2caloparticle[2];
0151   std::vector<dqm::reco::MonitorElement*> h_energy_vs_score_trackster2bestCaloparticle[2];
0152   std::vector<dqm::reco::MonitorElement*> h_energy_vs_score_trackster2bestCaloparticle2[2];
0153   std::vector<dqm::reco::MonitorElement*> h_energy_vs_score_caloparticle2trackster[2];
0154   std::vector<dqm::reco::MonitorElement*> h_energy_vs_score_caloparticle2bestTrackster[2];
0155   std::vector<dqm::reco::MonitorElement*> h_energy_vs_score_caloparticle2bestTrackster2[2];
0156   std::vector<dqm::reco::MonitorElement*> h_num_trackster_eta[2];
0157   std::vector<dqm::reco::MonitorElement*> h_num_trackster_phi[2];
0158   std::vector<dqm::reco::MonitorElement*> h_num_trackster_en[2];
0159   std::vector<dqm::reco::MonitorElement*> h_num_trackster_pt[2];
0160   std::vector<dqm::reco::MonitorElement*> h_numMerge_trackster_eta[2];
0161   std::vector<dqm::reco::MonitorElement*> h_numMerge_trackster_phi[2];
0162   std::vector<dqm::reco::MonitorElement*> h_numMerge_trackster_en[2];
0163   std::vector<dqm::reco::MonitorElement*> h_numMerge_trackster_pt[2];
0164   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_trackster2caloparticle[2];
0165   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_trackster2bestCaloparticle[2];
0166   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_trackster2bestCaloparticle2[2];
0167   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2trackster[2];
0168   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2trackster_assoc[2];
0169   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2trackster_assoc2[2];
0170   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_trackster2bestCaloparticle_vs_eta[2];
0171   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_trackster2bestCaloparticle_vs_phi[2];
0172   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2trackster_assoc_vs_eta[2];
0173   std::vector<dqm::reco::MonitorElement*> h_sharedenergy_caloparticle2trackster_assoc_vs_phi[2];
0174   std::vector<dqm::reco::MonitorElement*> h_denom_trackster_eta[2];
0175   std::vector<dqm::reco::MonitorElement*> h_denom_trackster_phi[2];
0176   std::vector<dqm::reco::MonitorElement*> h_denom_trackster_en[2];
0177   std::vector<dqm::reco::MonitorElement*> h_denom_trackster_pt[2];
0178   std::vector<dqm::reco::MonitorElement*> h_numEff_caloparticle_eta[2];
0179   std::vector<dqm::reco::MonitorElement*> h_numEff_caloparticle_phi[2];
0180   std::vector<dqm::reco::MonitorElement*> h_numEff_caloparticle_en[2];
0181   std::vector<dqm::reco::MonitorElement*> h_numEff_caloparticle_pt[2];
0182   std::vector<dqm::reco::MonitorElement*> h_num_caloparticle_eta[2];
0183   std::vector<dqm::reco::MonitorElement*> h_num_caloparticle_phi[2];
0184   std::vector<dqm::reco::MonitorElement*> h_num_caloparticle_en[2];
0185   std::vector<dqm::reco::MonitorElement*> h_num_caloparticle_pt[2];
0186   std::vector<dqm::reco::MonitorElement*> h_numDup_trackster_eta[2];
0187   std::vector<dqm::reco::MonitorElement*> h_numDup_trackster_phi[2];
0188   std::vector<dqm::reco::MonitorElement*> h_numDup_trackster_en[2];
0189   std::vector<dqm::reco::MonitorElement*> h_numDup_trackster_pt[2];
0190   std::vector<dqm::reco::MonitorElement*> h_denom_caloparticle_eta[2];
0191   std::vector<dqm::reco::MonitorElement*> h_denom_caloparticle_phi[2];
0192   std::vector<dqm::reco::MonitorElement*> h_denom_caloparticle_en[2];
0193   std::vector<dqm::reco::MonitorElement*> h_denom_caloparticle_pt[2];
0194   // Generic histograms
0195   std::vector<dqm::reco::MonitorElement*> h_tracksternum;
0196   std::vector<dqm::reco::MonitorElement*> h_conttracksternum;
0197   std::vector<dqm::reco::MonitorElement*> h_nonconttracksternum;
0198   std::vector<dqm::reco::MonitorElement*> h_clusternum_in_trackster;
0199   std::vector<std::unordered_map<int, dqm::reco::MonitorElement*>> h_clusternum_in_trackster_perlayer;
0200   std::vector<dqm::reco::MonitorElement*> h_multiplicityOfLCinTST;
0201   std::vector<dqm::reco::MonitorElement*> h_multiplicity_numberOfEventsHistogram;
0202   std::vector<dqm::reco::MonitorElement*> h_multiplicity_zminus_numberOfEventsHistogram;
0203   std::vector<dqm::reco::MonitorElement*> h_multiplicity_zplus_numberOfEventsHistogram;
0204   std::vector<dqm::reco::MonitorElement*> h_multiplicityOfLCinTST_vs_layercluster;
0205   std::vector<dqm::reco::MonitorElement*> h_multiplicityOfLCinTST_vs_layercluster_zminus;
0206   std::vector<dqm::reco::MonitorElement*> h_multiplicityOfLCinTST_vs_layercluster_zplus;
0207   std::vector<dqm::reco::MonitorElement*> h_multiplicityOfLCinTST_vs_layerclusterenergy;
0208   std::vector<dqm::reco::MonitorElement*> h_clusternum_in_trackster_vs_layer;
0209   std::vector<dqm::reco::MonitorElement*> h_trackster_pt;
0210   std::vector<dqm::reco::MonitorElement*> h_trackster_eta;
0211   std::vector<dqm::reco::MonitorElement*> h_trackster_phi;
0212   std::vector<dqm::reco::MonitorElement*> h_trackster_energy;
0213   std::vector<dqm::reco::MonitorElement*> h_trackster_x;
0214   std::vector<dqm::reco::MonitorElement*> h_trackster_y;
0215   std::vector<dqm::reco::MonitorElement*> h_trackster_z;
0216   std::vector<dqm::reco::MonitorElement*> h_trackster_firstlayer;
0217   std::vector<dqm::reco::MonitorElement*> h_trackster_lastlayer;
0218   std::vector<dqm::reco::MonitorElement*> h_trackster_layersnum;
0219 };
0220 
0221 using Density = hgcal_clustering::Density;
0222 
0223 class HGVHistoProducerAlgo {
0224 public:
0225   typedef dqm::legacy::DQMStore DQMStore;
0226   typedef dqm::legacy::MonitorElement MonitorElement;
0227 
0228   HGVHistoProducerAlgo(const edm::ParameterSet& pset);
0229   ~HGVHistoProducerAlgo();
0230 
0231   using Histograms = HGVHistoProducerAlgoHistograms;
0232 
0233   void bookInfo(DQMStore::IBooker& ibook, Histograms& histograms);
0234   void bookCaloParticleHistos(DQMStore::IBooker& ibook, Histograms& histograms, int pdgid, unsigned int layers);
0235 
0236   void bookSimClusterHistos(DQMStore::IBooker& ibook,
0237                             Histograms& histograms,
0238                             unsigned int layers,
0239                             std::vector<int> thicknesses);
0240 
0241   void bookSimClusterAssociationHistos(DQMStore::IBooker& ibook,
0242                                        Histograms& histograms,
0243                                        unsigned int layers,
0244                                        std::vector<int> thicknesses);
0245 
0246   void bookClusterHistos_ClusterLevel(DQMStore::IBooker& ibook,
0247                                       Histograms& histograms,
0248                                       unsigned int layers,
0249                                       std::vector<int> thicknesses,
0250                                       std::string pathtomatbudfile);
0251 
0252   void bookClusterHistos_LCtoCP_association(DQMStore::IBooker& ibook, Histograms& histograms, unsigned int layers);
0253 
0254   void bookClusterHistos_CellLevel(DQMStore::IBooker& ibook,
0255                                    Histograms& histograms,
0256                                    unsigned int layers,
0257                                    std::vector<int> thicknesses);
0258 
0259   void bookTracksterHistos(DQMStore::IBooker& ibook, Histograms& histograms, unsigned int layers);
0260   enum validationType { Linking = 0, PatternRecognition, PatternRecognition_CP };
0261   void bookTracksterSTSHistos(DQMStore::IBooker& ibook, Histograms& histograms, const validationType valType);
0262 
0263   void layerClusters_to_CaloParticles(const Histograms& histograms,
0264                                       edm::Handle<reco::CaloClusterCollection> clusterHandle,
0265                                       const reco::CaloClusterCollection& clusters,
0266                                       edm::Handle<std::vector<CaloParticle>> caloParticleHandle,
0267                                       std::vector<CaloParticle> const& cP,
0268                                       std::vector<size_t> const& cPIndices,
0269                                       std::vector<size_t> const& cPSelectedIndices,
0270                                       std::unordered_map<DetId, const HGCRecHit*> const&,
0271                                       unsigned int layers,
0272                                       const hgcal::RecoToSimCollection& recSimColl,
0273                                       const hgcal::SimToRecoCollection& simRecColl) const;
0274   void layerClusters_to_SimClusters(const Histograms& histograms,
0275                                     const int count,
0276                                     edm::Handle<reco::CaloClusterCollection> clusterHandle,
0277                                     const reco::CaloClusterCollection& clusters,
0278                                     edm::Handle<std::vector<SimCluster>> simClusterHandle,
0279                                     std::vector<SimCluster> const& simClusters,
0280                                     std::vector<size_t> const& sCIndices,
0281                                     const std::vector<float>& mask,
0282                                     std::unordered_map<DetId, const HGCRecHit*> const&,
0283                                     unsigned int layers,
0284                                     const hgcal::RecoToSimCollectionWithSimClusters& recSimColl,
0285                                     const hgcal::SimToRecoCollectionWithSimClusters& simRecColl) const;
0286   void tracksters_to_SimTracksters(const Histograms& histograms,
0287                                    const int count,
0288                                    const ticl::TracksterCollection& Tracksters,
0289                                    const reco::CaloClusterCollection& layerClusters,
0290                                    const ticl::TracksterCollection& simTS,
0291                                    const validationType valType,
0292                                    const ticl::TracksterCollection& simTS_fromCP,
0293                                    std::map<uint, std::vector<uint>> const& simTrackstersMap,
0294                                    std::vector<SimCluster> const& sC,
0295                                    const edm::ProductID& cPHandle_id,
0296                                    std::vector<CaloParticle> const& cP,
0297                                    std::vector<size_t> const& cPIndices,
0298                                    std::vector<size_t> const& cPSelectedIndices,
0299                                    std::unordered_map<DetId, const HGCRecHit*> const&,
0300                                    unsigned int layers) const;
0301   void fill_info_histos(const Histograms& histograms, unsigned int layers) const;
0302   void fill_caloparticle_histos(const Histograms& histograms,
0303                                 int pdgid,
0304                                 const CaloParticle& caloparticle,
0305                                 std::vector<SimVertex> const& simVertices,
0306                                 unsigned int layers,
0307                                 std::unordered_map<DetId, const HGCRecHit*> const&) const;
0308   void fill_generic_cluster_histos(const Histograms& histograms,
0309                                    const int count,
0310                                    edm::Handle<reco::CaloClusterCollection> clusterHandle,
0311                                    const reco::CaloClusterCollection& clusters,
0312                                    const Density& densities,
0313                                    edm::Handle<std::vector<CaloParticle>> caloParticleHandle,
0314                                    std::vector<CaloParticle> const& cP,
0315                                    std::vector<size_t> const& cPIndices,
0316                                    std::vector<size_t> const& cPSelectedIndices,
0317                                    std::unordered_map<DetId, const HGCRecHit*> const&,
0318                                    std::map<double, double> cummatbudg,
0319                                    unsigned int layers,
0320                                    std::vector<int> thicknesses,
0321                                    const hgcal::RecoToSimCollection& recSimColl,
0322                                    const hgcal::SimToRecoCollection& simRecColl) const;
0323   void fill_simCluster_histos(const Histograms& histograms,
0324                               std::vector<SimCluster> const& simClusters,
0325                               unsigned int layers,
0326                               std::vector<int> thicknesses) const;
0327   void fill_simClusterAssociation_histos(const Histograms& histograms,
0328                                          const int count,
0329                                          edm::Handle<reco::CaloClusterCollection> clusterHandle,
0330                                          const reco::CaloClusterCollection& clusters,
0331                                          edm::Handle<std::vector<SimCluster>> simClusterHandle,
0332                                          std::vector<SimCluster> const& simClusters,
0333                                          std::vector<size_t> const& sCIndices,
0334                                          const std::vector<float>& mask,
0335                                          std::unordered_map<DetId, const HGCRecHit*> const& hitMap,
0336                                          unsigned int layers,
0337                                          const hgcal::RecoToSimCollectionWithSimClusters& recSimColl,
0338                                          const hgcal::SimToRecoCollectionWithSimClusters& simRecColl) const;
0339   void fill_cluster_histos(const Histograms& histograms, const int count, const reco::CaloCluster& cluster) const;
0340   void fill_trackster_histos(const Histograms& histograms,
0341                              const int count,
0342                              const ticl::TracksterCollection& Tracksters,
0343                              const reco::CaloClusterCollection& layerClusters,
0344                              const ticl::TracksterCollection& simTS,
0345                              const ticl::TracksterCollection& simTS_fromCP,
0346                              std::map<uint, std::vector<uint>> const& simTrackstersMap,
0347                              std::vector<SimCluster> const& sC,
0348                              const edm::ProductID& cPHandle_id,
0349                              std::vector<CaloParticle> const& cP,
0350                              std::vector<size_t> const& cPIndices,
0351                              std::vector<size_t> const& cPSelectedIndices,
0352                              std::unordered_map<DetId, const HGCRecHit*> const&,
0353                              unsigned int layers) const;
0354   double distance2(const double x1, const double y1, const double x2, const double y2) const;
0355   double distance(const double x1, const double y1, const double x2, const double y2) const;
0356 
0357   void setRecHitTools(std::shared_ptr<hgcal::RecHitTools> recHitTools);
0358 
0359   DetId findmaxhit(const reco::CaloCluster& cluster, std::unordered_map<DetId, const HGCRecHit*> const&) const;
0360 
0361   struct detIdInfoInCluster {
0362     bool operator==(const detIdInfoInCluster& o) const { return clusterId == o.clusterId; };
0363     long unsigned int clusterId;
0364     float fraction;
0365   };
0366 
0367   struct detIdInfoInTrackster {
0368     bool operator==(const detIdInfoInTrackster& o) const { return tracksterId == o.tracksterId; };
0369     unsigned int tracksterId;
0370     long unsigned int clusterId;
0371     float fraction;
0372   };
0373 
0374   struct caloParticleOnLayer {
0375     unsigned int caloParticleId;
0376     float energy = 0;
0377     std::vector<std::pair<DetId, float>> hits_and_fractions;
0378     std::unordered_map<unsigned int, std::pair<float, float>> layerClusterIdToEnergyAndScore;
0379   };
0380 
0381 private:
0382   double getEta(double eta) const;
0383 
0384   std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0385 
0386   //private data members
0387   double minEta_, maxEta_;
0388   int nintEta_;
0389   bool useFabsEta_;
0390   double minEne_, maxEne_;
0391   int nintEne_;
0392   double minPt_, maxPt_;
0393   int nintPt_;
0394   double minPhi_, maxPhi_;
0395   int nintPhi_;
0396   double minMixedHitsSimCluster_, maxMixedHitsSimCluster_;
0397   int nintMixedHitsSimCluster_;
0398   double minMixedHitsCluster_, maxMixedHitsCluster_;
0399   int nintMixedHitsCluster_;
0400   double minEneCl_, maxEneCl_;
0401   int nintEneCl_;
0402   double minLongDepBary_, maxLongDepBary_;
0403   int nintLongDepBary_;
0404   double minZpos_, maxZpos_;
0405   int nintZpos_;
0406   double minTotNsimClsperlay_, maxTotNsimClsperlay_;
0407   int nintTotNsimClsperlay_;
0408   double minTotNClsperlay_, maxTotNClsperlay_;
0409   int nintTotNClsperlay_;
0410   double minEneClperlay_, maxEneClperlay_;
0411   int nintEneClperlay_;
0412   double minScore_, maxScore_;
0413   int nintScore_;
0414   double minSharedEneFrac_, maxSharedEneFrac_;
0415   int nintSharedEneFrac_;
0416   double minTSTSharedEneFracEfficiency_;
0417   double minTSTSharedEneFrac_, maxTSTSharedEneFrac_;
0418   int nintTSTSharedEneFrac_;
0419   double minTotNsimClsperthick_, maxTotNsimClsperthick_;
0420   int nintTotNsimClsperthick_;
0421   double minTotNClsperthick_, maxTotNClsperthick_;
0422   int nintTotNClsperthick_;
0423   double minTotNcellsperthickperlayer_, maxTotNcellsperthickperlayer_;
0424   int nintTotNcellsperthickperlayer_;
0425   double minDisToSeedperthickperlayer_, maxDisToSeedperthickperlayer_;
0426   int nintDisToSeedperthickperlayer_;
0427   double minDisToSeedperthickperlayerenewei_, maxDisToSeedperthickperlayerenewei_;
0428   int nintDisToSeedperthickperlayerenewei_;
0429   double minDisToMaxperthickperlayer_, maxDisToMaxperthickperlayer_;
0430   int nintDisToMaxperthickperlayer_;
0431   double minDisToMaxperthickperlayerenewei_, maxDisToMaxperthickperlayerenewei_;
0432   int nintDisToMaxperthickperlayerenewei_;
0433   double minDisSeedToMaxperthickperlayer_, maxDisSeedToMaxperthickperlayer_;
0434   int nintDisSeedToMaxperthickperlayer_;
0435   double minClEneperthickperlayer_, maxClEneperthickperlayer_;
0436   int nintClEneperthickperlayer_;
0437   double minCellsEneDensperthick_, maxCellsEneDensperthick_;
0438   int nintCellsEneDensperthick_;
0439   double minTotNTSTs_, maxTotNTSTs_;
0440   int nintTotNTSTs_;
0441   double minTotNClsinTSTs_, maxTotNClsinTSTs_;
0442   int nintTotNClsinTSTs_;
0443   double minTotNClsinTSTsperlayer_, maxTotNClsinTSTsperlayer_;
0444   int nintTotNClsinTSTsperlayer_;
0445   double minMplofLCs_, maxMplofLCs_;
0446   int nintMplofLCs_;
0447   double minSizeCLsinTSTs_, maxSizeCLsinTSTs_;
0448   int nintSizeCLsinTSTs_;
0449   double minClEnepermultiplicity_, maxClEnepermultiplicity_;
0450   int nintClEnepermultiplicity_;
0451   double minX_, maxX_;
0452   int nintX_;
0453   double minY_, maxY_;
0454   int nintY_;
0455   double minZ_, maxZ_;
0456   int nintZ_;
0457 };
0458 
0459 #endif