Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:16

0001 #ifndef TauTagValidation_h
0002 #define TauTagValidation_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    TauTagValidation
0007 // Class:      TauTagValidation
0008 //
0009 /* *\class TauTagValidation TauTagValidation.cc
0010 
0011  Description: EDAnalyzer to validate the Collections from the ConeIsolation Producer
0012  It is supposed to be used for Offline Tau Reconstrction, so PrimaryVertex should be used.
0013  Implementation:
0014 
0015 */
0016 // Original Author: Ricardo Vasquez Sierra On August 29, 2007
0017 // user include files
0018 
0019 #include "FWCore/Common/interface/Provenance.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/MakerMacros.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "FWCore/ServiceRegistry/interface/Service.h"
0025 #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
0026 #include "DataFormats/Math/interface/Vector3D.h"
0027 #include "DataFormats/Math/interface/LorentzVector.h"
0028 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
0029 #include "DataFormats/Provenance/interface/ProductProvenance.h"
0030 #include "DataFormats/TauReco/interface/PFTau.h"
0031 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
0032 #include "DataFormats/TauReco/interface/TauDiscriminatorContainer.h"
0033 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0034 
0035 #include "RecoParticleFlow/Benchmark/interface/PFBenchmarkAlgo.h"
0036 
0037 // Math
0038 #include "Math/GenVector/VectorUtil.h"
0039 #include "Math/GenVector/PxPyPzE4D.h"
0040 #include "TLorentzVector.h"
0041 #include "TH1D.h"
0042 #include "TH1.h"
0043 #include "TH1F.h"
0044 #include <vector>
0045 #include <string>
0046 
0047 // Include DQM core
0048 #include <DQMServices/Core/interface/DQMStore.h>
0049 #include <DQMServices/Core/interface/DQMEDAnalyzer.h>
0050 
0051 typedef math::XYZTLorentzVectorD LV;
0052 typedef std::vector<LV> LVCollection;
0053 
0054 struct hinfo {
0055   int nbins;
0056   double min;
0057   double max;
0058   hinfo(int n, double m, double M) {
0059     nbins = n;
0060     min = m;
0061     max = M;
0062   }
0063   hinfo(const edm::ParameterSet& config) {
0064     nbins = config.getParameter<int>("nbins");
0065     min = config.getParameter<double>("min");
0066     max = config.getParameter<double>("max");
0067   }
0068 };
0069 
0070 // class declaration
0071 class TauTagValidation : public DQMEDAnalyzer {
0072 public:
0073   explicit TauTagValidation(const edm::ParameterSet&);
0074   ~TauTagValidation() override;
0075 
0076   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0077   void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
0078   void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0079 
0080 private:
0081   /// label of the current module
0082   std::string moduleLabel_;
0083   ///sum the transversal momentum of all candidates
0084   double getSumPt(const std::vector<edm::Ptr<reco::Candidate> >& candidates);
0085   ///get rid of redundant parts to shorten the label
0086   bool stripDiscriminatorLabel(const std::string& discriminatorLabel, std::string& newLabel);
0087 
0088   edm::ParameterSet histoSettings_;
0089   /// generic access to dynamic trigger table
0090   GenericTriggerEventFlag* genericTriggerEventFlag_;
0091 
0092   /// What's the reference for the Validation Leptons or Jets
0093   std::string dataType_;
0094 
0095   // Matching criteria
0096   double matchDeltaR_Leptons_;
0097   double matchDeltaR_Jets_;
0098   double TauPtCut_;
0099 
0100   //optional: filter candidates by passed cuts
0101   std::string recoCuts_, genCuts_;
0102 
0103   // output histograms
0104   bool saveoutputhistograms_, turnOnTrigger_;
0105 
0106   // Reference Collection
0107   edm::InputTag refCollectionInputTag_;
0108   edm::EDGetTokenT<edm::View<reco::Candidate> > refCollectionInputTagToken_;
0109   edm::EDGetTokenT<reco::PFTauCollection> tauProducerInputTagToken_;
0110   edm::EDGetTokenT<reco::VertexCollection> primaryVertexCollectionToken_;
0111   std::vector<edm::EDGetTokenT<reco::PFTauDiscriminator> > currentDiscriminatorToken_;
0112   std::vector<std::pair<edm::EDGetTokenT<reco::TauDiscriminatorContainer>, int> > currentDiscriminatorContainerToken_;
0113   std::vector<std::string> currentDiscriminatorContainerProvCfgName_;
0114   std::vector<std::pair<std::string, std::string> > currentDiscriminatorContainerIdName_;
0115   edm::ProcessHistoryID phID_;
0116   std::string refCollection_;
0117 
0118   // In case you need to distinguish the output file
0119   std::string extensionName_;
0120 
0121   // Reconstructed product of interest
0122   edm::InputTag TauProducerInputTag_, PrimaryVertexCollection_;
0123   std::string TauProducer_;
0124 
0125   // std::vector<std::string> TauProducerDiscriminators_;
0126   // std::vector<double> TauDiscriminatorCuts_;
0127 
0128   std::vector<edm::ParameterSet> discriminators_;
0129 
0130   // CMSSW version
0131 
0132   std::string tversion;
0133   std::string outPutFile_;
0134 
0135   std::map<std::string, MonitorElement*> ptTauVisibleMap;
0136   std::map<std::string, MonitorElement*> etaTauVisibleMap;
0137   std::map<std::string, MonitorElement*> phiTauVisibleMap;
0138   std::map<std::string, MonitorElement*> pileupTauVisibleMap;
0139   std::map<std::string, MonitorElement*> nTauVisibleMap;
0140   std::map<std::string, MonitorElement*> massTauVisibleMap;
0141   std::map<std::string, MonitorElement*> plotMap_;
0142   std::map<std::string, MonitorElement*> summaryMap;
0143 
0144   std::map<std::string, int> tauDecayCountMap_;
0145 
0146   MonitorElement* nTaus_;
0147 
0148   // All the extra MonitorElements that we would like to add for each Tau Tagging step
0149   // First for the PFTaus
0150   // Number of PFTau Candidates with a leading charged hadron in it (within a cone of 0.1 avound the jet axis and a minimum pt of 6 GeV)
0151 
0152   MonitorElement* nPFJet_LeadingChargedHadron_ChargedHadronsSignal_;
0153   MonitorElement* nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_;
0154   MonitorElement* nPFJet_LeadingChargedHadron_GammasSignal_;
0155   MonitorElement* nPFJet_LeadingChargedHadron_GammasIsolAnnulus_;
0156   MonitorElement* nPFJet_LeadingChargedHadron_NeutralHadronsSignal_;
0157   MonitorElement* nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_;
0158 
0159   // Isolated PFTau with a Leading charged hadron with no Charged Hadrons inside the isolation annulus
0160 
0161   MonitorElement* nIsolated_NoChargedHadrons_ChargedHadronsSignal_;
0162   MonitorElement* nIsolated_NoChargedHadrons_GammasSignal_;
0163   MonitorElement* nIsolated_NoChargedHadrons_GammasIsolAnnulus_;
0164   MonitorElement* nIsolated_NoChargedHadrons_NeutralHadronsSignal_;
0165   MonitorElement* nIsolated_NoChargedHadrons_NeutralHadronsIsolAnnulus_;
0166 
0167   // Isolated PFTau with a Leading charge hadron with no Charged Hadron inside the isolation annulus with no Ecal/Gamma candidates in the isolation annulus
0168 
0169   MonitorElement* nIsolated_NoChargedNoGammas_ChargedHadronsSignal_;
0170   MonitorElement* nIsolated_NoChargedNoGammas_GammasSignal_;
0171   MonitorElement* nIsolated_NoChargedNoGammas_NeutralHadronsSignal_;
0172   MonitorElement* nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_;
0173 
0174   // book-keeping variables
0175   int numEvents_;
0176 
0177 protected:
0178   PFBenchmarkAlgo* algo_;
0179 
0180 private:
0181   bool chainCuts_;
0182 };
0183 
0184 #endif