Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-09 23:34:07

0001 #ifndef HGCalValidator_h
0002 #define HGCalValidator_h
0003 
0004 /** \class HGCalValidator
0005  *  Class that produces histograms to validate HGCal Reconstruction performances
0006  *
0007  *  \author HGCal
0008  */
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0012 #include "FWCore/Utilities/interface/EDGetToken.h"
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "FWCore/ParameterSet/interface/FileInPath.h"
0015 
0016 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0017 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0019 #include "DataFormats/HGCalReco/interface/Trackster.h"
0020 #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h"
0021 #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"
0022 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0023 
0024 #include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"
0025 
0026 #include "Validation/HGCalValidation/interface/TICLCandidateValidator.h"
0027 #include "Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h"
0028 #include "Validation/HGCalValidation/interface/CaloParticleSelector.h"
0029 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalClusteringAlgoBase.h"
0030 
0031 #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h"
0032 #include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h"
0033 #include "SimDataFormats/Associations/interface/TICLAssociationMap.h"
0034 
0035 #include "CommonTools/RecoAlgos/interface/MultiVectorManager.h"
0036 
0037 class PileupSummaryInfo;
0038 
0039 struct HGCalValidatorHistograms {
0040   HGVHistoProducerAlgoHistograms histoProducerAlgo;
0041   TICLCandidateValidatorHistograms histoTICLCandidates;
0042   std::vector<dqm::reco::MonitorElement*> h_layerclusters_coll;
0043 };
0044 
0045 class HGCalValidator : public DQMGlobalEDAnalyzer<HGCalValidatorHistograms> {
0046 public:
0047   using Histograms = HGCalValidatorHistograms;
0048   using TracksterToTracksterMap =
0049       ticl::AssociationMap<ticl::mapWithSharedEnergyAndScore, std::vector<ticl::Trackster>, std::vector<ticl::Trackster>>;
0050   using SimClusterToCaloParticleMap =
0051       ticl::AssociationMap<ticl::oneToOneMapWithFraction, std::vector<SimCluster>, std::vector<CaloParticle>>;
0052 
0053   /// Constructor
0054   HGCalValidator(const edm::ParameterSet& pset);
0055 
0056   /// Destructor
0057   ~HGCalValidator() override;
0058 
0059   /// Method called once per event
0060   void dqmAnalyze(const edm::Event&, const edm::EventSetup&, const Histograms&) const override;
0061   /// Method called to book the DQM histograms
0062   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
0063 
0064   void cpParametersAndSelection(const Histograms& histograms,
0065                                 std::vector<CaloParticle> const& cPeff,
0066                                 std::vector<SimVertex> const& simVertices,
0067                                 std::vector<size_t>& selected_cPeff,
0068                                 unsigned int layers,
0069                                 std::unordered_map<DetId, const unsigned int> const&,
0070                                 MultiVectorManager<HGCRecHit> const& hits) const;
0071 
0072   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0073 
0074 protected:
0075   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0076   edm::InputTag label_lcl;
0077   std::vector<edm::InputTag> label_tst;
0078   std::vector<edm::InputTag> allTracksterTracksterAssociatorsLabels_;
0079   std::vector<edm::InputTag> allTracksterTracksterByHitsAssociatorsLabels_;
0080   edm::InputTag label_simTS, label_simTSFromCP;
0081   edm::InputTag associator_;
0082   edm::InputTag associatorSim_;
0083   const bool SaveGeneralInfo_;
0084   const bool doCaloParticlePlots_;
0085   const bool doCaloParticleSelection_;
0086   const bool doSimClustersPlots_;
0087   edm::InputTag label_SimClustersPlots_, label_SimClustersLevel_;
0088   const bool doLayerClustersPlots_;
0089   edm::InputTag label_layerClustersPlots_, label_LCToCPLinking_;
0090   const bool doTrackstersPlots_;
0091   std::string label_TS_, label_TSbyHitsCP_, label_TSbyHits_, label_TSbyLCsCP_, label_TSbyLCs_;
0092   std::vector<edm::InputTag> label_clustersmask;
0093   const bool doCandidatesPlots_;
0094   std::string label_candidates_;
0095   const edm::FileInPath cummatbudinxo_;
0096   const bool isTICLv5_;
0097 
0098   std::vector<edm::EDGetTokenT<reco::CaloClusterCollection>> labelToken;
0099   edm::EDGetTokenT<std::vector<SimCluster>> simClusters_;
0100   edm::EDGetTokenT<reco::CaloClusterCollection> layerclusters_;
0101   std::vector<edm::EDGetTokenT<ticl::TracksterCollection>> label_tstTokens;
0102   edm::EDGetTokenT<ticl::TracksterCollection> simTracksters_;
0103   edm::EDGetTokenT<ticl::TracksterCollection> simTracksters_fromCPs_;
0104   edm::EDGetTokenT<std::map<uint, std::vector<uint>>> simTrackstersMap_;
0105   edm::EDGetTokenT<std::vector<CaloParticle>> label_cp_effic;
0106   edm::EDGetTokenT<std::vector<CaloParticle>> label_cp_fake;
0107   edm::EDGetTokenT<std::vector<SimVertex>> simVertices_;
0108   std::vector<edm::EDGetTokenT<std::vector<float>>> clustersMaskTokens_;
0109   edm::EDGetTokenT<std::unordered_map<DetId, const unsigned int>> hitMap_;
0110   edm::EDGetTokenT<ticl::RecoToSimCollection> associatorMapRtS;
0111   edm::EDGetTokenT<ticl::SimToRecoCollection> associatorMapStR;
0112   edm::EDGetTokenT<ticl::SimToRecoCollectionWithSimClusters> associatorMapSimtR;
0113   edm::EDGetTokenT<ticl::RecoToSimCollectionWithSimClusters> associatorMapRtSim;
0114   std::unique_ptr<HGVHistoProducerAlgo> histoProducerAlgo_;
0115   std::vector<edm::InputTag> hits_label_;
0116   std::vector<edm::EDGetTokenT<HGCRecHitCollection>> hits_tokens_;
0117   std::unique_ptr<TICLCandidateValidator> candidateVal_;
0118   std::vector<edm::EDGetTokenT<TracksterToTracksterMap>> tracksterToTracksterAssociatorsTokens_;
0119   std::vector<edm::EDGetTokenT<TracksterToTracksterMap>> tracksterToTracksterByHitsAssociatorsTokens_;
0120   edm::EDGetTokenT<SimClusterToCaloParticleMap> scToCpMapToken_;
0121 
0122 private:
0123   CaloParticleSelector cpSelector;
0124   std::shared_ptr<hgcal::RecHitTools> tools_;
0125   std::map<double, double> cumulative_material_budget;
0126   std::vector<int> particles_to_monitor_;
0127   unsigned totallayers_to_monitor_;
0128   std::vector<int> thicknesses_to_monitor_;
0129   std::string dirName_;
0130 };
0131 
0132 #endif