Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-07-09 05:00:38

0001 #ifndef BarrelValidator_h
0002 #define BarrelValidator_h
0003 
0004 /** \class BarrelValidator
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/BarrelVHistoProducerAlgo.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 BarrelValidatorHistograms {
0040   BarrelVHistoProducerAlgoHistograms histoProducerAlgo;
0041   std::vector<dqm::reco::MonitorElement*> h_layerclusters_coll;
0042 };
0043 
0044 class BarrelValidator : public DQMGlobalEDAnalyzer<BarrelValidatorHistograms> {
0045 public:
0046   using Histograms = BarrelValidatorHistograms;
0047   using TracksterToTracksterMap =
0048       ticl::AssociationMap<ticl::mapWithSharedEnergyAndScore, std::vector<ticl::Trackster>, std::vector<ticl::Trackster>>;
0049   using SimClusterToCaloParticleMap =
0050       ticl::AssociationMap<ticl::oneToOneMapWithFraction, std::vector<SimCluster>, std::vector<CaloParticle>>;
0051 
0052   /// Constructor
0053   BarrelValidator(const edm::ParameterSet& pset);
0054 
0055   /// Destructor
0056   ~BarrelValidator() override;
0057 
0058   /// Method called once per event
0059   void dqmAnalyze(const edm::Event&, const edm::EventSetup&, const Histograms&) const override;
0060   /// Method called to book the DQM histograms
0061   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
0062 
0063   void cpParametersAndSelection(const Histograms& histograms,
0064                                 std::vector<CaloParticle> const& cPeff,
0065                                 std::vector<SimVertex> const& simVertices,
0066                                 std::vector<size_t>& selected_cPeff,
0067                                 unsigned int layers,
0068                                 std::unordered_map<DetId, const unsigned int> const&,
0069                                 MultiVectorManager<reco::PFRecHit> const& barrelHits) const;
0070 
0071   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0072 
0073 protected:
0074   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0075   edm::InputTag label_lcl;
0076   std::vector<edm::InputTag> associator_;
0077   std::vector<edm::InputTag> associatorSim_;
0078   const bool SaveGeneralInfo_;
0079   const bool doCaloParticlePlots_;
0080   const bool doCaloParticleSelection_;
0081   const bool doSimClustersPlots_;
0082   edm::InputTag label_SimClustersPlots_, label_SimClustersLevel_;
0083   const bool doLayerClustersPlots_;
0084   edm::InputTag label_layerClustersPlots_, label_LCToCPLinking_;
0085   std::vector<edm::InputTag> label_clustersmask;
0086 
0087   std::vector<edm::EDGetTokenT<reco::CaloClusterCollection>> labelToken;
0088   edm::EDGetTokenT<std::vector<SimCluster>> simClusters_;
0089   edm::EDGetTokenT<reco::CaloClusterCollection> layerclusters_;
0090   edm::EDGetTokenT<std::vector<CaloParticle>> label_cp_effic;
0091   edm::EDGetTokenT<std::vector<CaloParticle>> label_cp_fake;
0092   edm::EDGetTokenT<std::vector<SimVertex>> simVertices_;
0093   std::vector<edm::EDGetTokenT<std::vector<float>>> clustersMaskTokens_;
0094   edm::EDGetTokenT<std::unordered_map<DetId, const unsigned int>> barrelHitMap_;
0095   std::vector<edm::EDGetTokenT<ticl::RecoToSimCollection>> associatorMapRtS;
0096   std::vector<edm::EDGetTokenT<ticl::SimToRecoCollection>> associatorMapStR;
0097   std::vector<edm::EDGetTokenT<ticl::SimToRecoCollectionWithSimClusters>> associatorMapSimtR;
0098   std::vector<edm::EDGetTokenT<ticl::RecoToSimCollectionWithSimClusters>> associatorMapRtSim;
0099   std::unique_ptr<BarrelVHistoProducerAlgo> histoProducerAlgo_;
0100   std::vector<edm::InputTag> barrel_hits_label_;
0101   std::vector<edm::EDGetTokenT<std::vector<reco::PFRecHit>>> barrel_hits_tokens_;
0102   edm::EDGetTokenT<SimClusterToCaloParticleMap> scToCpMapToken_;
0103 
0104 private:
0105   CaloParticleSelector cpSelector;
0106   std::shared_ptr<hgcal::RecHitTools> tools_;
0107   std::vector<int> particles_to_monitor_;
0108   unsigned totallayers_to_monitor_;
0109   std::string dirName_;
0110 };
0111 
0112 #endif