Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:29:57

0001 #ifndef DQM_Physics_EwkTauDQM_h
0002 #define DQM_Physics_EwkTauDQM_h
0003 
0004 /** \class EwkTauDQM

0005  *

0006  * Booking and filling of histograms for data-quality monitoring purposes

0007  * in EWK tau analyses; individual channels are implemented in separate

0008  *Ewk..HistManager classes,

0009  * so far:

0010  *  o Z --> electron + tau-jet channel (EwkElecTauHistManager)

0011  *  o Z --> muon + tau-jet channel (EwkMuTauHistManager)

0012  *

0013  * \authors Letizia Lusito,

0014  *          Joshua Swanson,

0015  *          Christian Veelken

0016  */
0017 
0018 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0019 #include "DQMServices/Core/interface/DQMStore.h"
0020 
0021 #include <string>
0022 #include <Math/VectorUtil.h>
0023 
0024 class EwkElecTauHistManager;
0025 class EwkMuTauHistManager;
0026 
0027 class EwkTauDQM : public DQMOneEDAnalyzer<> {
0028 public:
0029   EwkTauDQM(const edm::ParameterSet&);
0030   ~EwkTauDQM() override;
0031 
0032   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0033   void analyze(const edm::Event&, const edm::EventSetup&) override;
0034   void dqmEndRun(const edm::Run&, const edm::EventSetup&) override;
0035 
0036 private:
0037   std::string dqmDirectory_;
0038   int maxNumWarnings_;
0039 
0040   EwkElecTauHistManager* elecTauHistManager_;
0041   EwkMuTauHistManager* muTauHistManager_;
0042 };
0043 
0044 //-------------------------------------------------------------------------------

0045 // code specific to Z --> e + tau-jet channel

0046 //-------------------------------------------------------------------------------

0047 
0048 /** \class EwkElecTauHistManager

0049  *

0050  * Booking and filling of histograms for data-quality monitoring purposes

0051  * in Z --> electron + tau-jet channel

0052  *

0053  * \author Joshua Swanson

0054  *        (modified by Christian Veelken)

0055  *

0056  *

0057  *

0058  */
0059 
0060 #include "FWCore/Framework/interface/Event.h"
0061 #include "FWCore/Framework/interface/EventSetup.h"
0062 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0063 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0064 #include "FWCore/Utilities/interface/InputTag.h"
0065 
0066 #include <string>
0067 
0068 class EwkElecTauHistManager {
0069 public:
0070   typedef EwkTauDQM::DQMStore DQMStore;
0071   typedef EwkTauDQM::MonitorElement MonitorElement;
0072 
0073   EwkElecTauHistManager(const edm::ParameterSet&);
0074 
0075   void bookHistograms(DQMStore::IBooker&);
0076   void fillHistograms(const edm::Event&, const edm::EventSetup&);
0077   void finalizeHistograms();
0078 
0079 private:
0080   //--- labels of electron, tau-jet and MEt collections being used

0081   //    in event selection and when filling histograms

0082   edm::InputTag triggerResultsSource_;
0083   edm::InputTag vertexSource_;
0084   edm::InputTag beamSpotSource_;
0085   edm::InputTag electronSource_;
0086   edm::InputTag tauJetSource_;
0087   edm::InputTag caloMEtSource_;
0088   edm::InputTag pfMEtSource_;
0089 
0090   edm::InputTag tauDiscrByLeadTrackFinding_;
0091   edm::InputTag tauDiscrByLeadTrackPtCut_;
0092   edm::InputTag tauDiscrByTrackIso_;
0093   edm::InputTag tauDiscrByEcalIso_;
0094   edm::InputTag tauDiscrAgainstElectrons_;
0095   edm::InputTag tauDiscrAgainstMuons_;
0096 
0097   //--- event selection criteria

0098   typedef std::vector<std::string> vstring;
0099   vstring hltPaths_;
0100 
0101   double electronEtaCut_;
0102   double electronPtCut_;
0103   double electronTrackIsoCut_;
0104   double electronEcalIsoCut_;
0105   int electronIsoMode_;
0106 
0107   double tauJetEtaCut_;
0108   double tauJetPtCut_;
0109 
0110   double visMassCut_;
0111 
0112   //--- name of DQM directory in which histograms for Z --> electron + tau-jet

0113   // channel get stored

0114   std::string dqmDirectory_;
0115 
0116   //--- histograms

0117   // MonitorElement* hNumIdElectrons_;

0118   MonitorElement* hElectronPt_;
0119   MonitorElement* hElectronEta_;
0120   MonitorElement* hElectronPhi_;
0121   MonitorElement* hElectronTrackIsoPt_;
0122   MonitorElement* hElectronEcalIsoPt_;
0123   // MonitorElement* hElectronHcalIsoPt_;

0124 
0125   MonitorElement* hTauJetPt_;
0126   MonitorElement* hTauJetEta_;
0127   // MonitorElement* hTauJetPhi_;

0128   // MonitorElement* hTauLeadTrackPt_;

0129   // MonitorElement* hTauTrackIsoPt_;

0130   // MonitorElement* hTauEcalIsoPt_;

0131   // MonitorElement* hTauDiscrAgainstElectrons_;

0132   // MonitorElement* hTauDiscrAgainstMuons_;

0133   // MonitorElement* hTauJetCharge_;

0134   // MonitorElement* hTauJetNumSignalTracks_;

0135   // MonitorElement* hTauJetNumIsoTracks_;

0136 
0137   MonitorElement* hVisMass_;
0138   // MonitorElement* hMtElecCaloMEt_;

0139   MonitorElement* hMtElecPFMEt_;
0140   // MonitorElement* hPzetaCaloMEt_;

0141   // MonitorElement* hPzetaPFMEt_;

0142   MonitorElement* hElecTauAcoplanarity_;
0143   MonitorElement* hElecTauCharge_;
0144 
0145   // MonitorElement* hVertexChi2_;

0146   MonitorElement* hVertexZ_;
0147   // MonitorElement* hVertexD0_;

0148 
0149   MonitorElement* hCaloMEtPt_;
0150   // MonitorElement* hCaloMEtPhi_;

0151 
0152   MonitorElement* hPFMEtPt_;
0153   // MonitorElement* hPFMEtPhi_;

0154 
0155   MonitorElement* hCutFlowSummary_;
0156   enum {
0157     kPassedPreselection = 1,
0158     kPassedTrigger = 2,
0159     kPassedElectronId = 3,
0160     kPassedElectronTrackIso = 4,
0161     kPassedElectronEcalIso = 5,
0162     kPassedTauLeadTrack = 6,
0163     kPassedTauLeadTrackPt = 7,
0164     kPassedTauDiscrAgainstElectrons = 8,
0165     kPassedTauDiscrAgainstMuons = 9,
0166     kPassedTauTrackIso = 10,
0167     kPassedTauEcalIso = 11
0168   };
0169 
0170   //--- counters for filter-statistics output

0171   unsigned numEventsAnalyzed_;
0172   unsigned numEventsSelected_;
0173 
0174   int cfgError_;
0175 
0176   int maxNumWarnings_;
0177 
0178   long numWarningsTriggerResults_;
0179   long numWarningsHLTpath_;
0180   long numWarningsVertex_;
0181   long numWarningsBeamSpot_;
0182   long numWarningsElectron_;
0183   long numWarningsTauJet_;
0184   long numWarningsTauDiscrByLeadTrackFinding_;
0185   long numWarningsTauDiscrByLeadTrackPtCut_;
0186   long numWarningsTauDiscrByTrackIso_;
0187   long numWarningsTauDiscrByEcalIso_;
0188   long numWarningsTauDiscrAgainstElectrons_;
0189   long numWarningsTauDiscrAgainstMuons_;
0190   long numWarningsCaloMEt_;
0191   long numWarningsPFMEt_;
0192 };
0193 
0194 //-------------------------------------------------------------------------------

0195 // code specific to Z --> mu + tau-jet channel

0196 //-------------------------------------------------------------------------------

0197 
0198 /** \class EwkMuTauHistManager

0199  *

0200  * Booking and filling of histograms for data-quality monitoring purposes

0201  * in Z --> muon + tau-jet channel

0202  *

0203  * \author Letizia Lusito,

0204  *         Christian Veelken

0205  *

0206  *

0207  *

0208  */
0209 
0210 #include "FWCore/Framework/interface/Event.h"
0211 #include "FWCore/Framework/interface/EventSetup.h"
0212 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0213 #include "FWCore/Utilities/interface/InputTag.h"
0214 
0215 #include <string>
0216 
0217 class EwkMuTauHistManager {
0218 public:
0219   typedef EwkTauDQM::DQMStore DQMStore;
0220   typedef EwkTauDQM::MonitorElement MonitorElement;
0221 
0222   EwkMuTauHistManager(const edm::ParameterSet&);
0223 
0224   void bookHistograms(DQMStore::IBooker&);
0225   void fillHistograms(const edm::Event&, const edm::EventSetup&);
0226   void finalizeHistograms();
0227 
0228 private:
0229   //--- labels of muon, tau-jet and MEt collections being used

0230   //    in event selection and when filling histograms

0231   edm::InputTag triggerResultsSource_;
0232   edm::InputTag vertexSource_;
0233   edm::InputTag beamSpotSource_;
0234   edm::InputTag muonSource_;
0235   edm::InputTag tauJetSource_;
0236   edm::InputTag caloMEtSource_;
0237   edm::InputTag pfMEtSource_;
0238 
0239   edm::InputTag tauDiscrByLeadTrackFinding_;
0240   edm::InputTag tauDiscrByLeadTrackPtCut_;
0241   edm::InputTag tauDiscrByTrackIso_;
0242   edm::InputTag tauDiscrByEcalIso_;
0243   edm::InputTag tauDiscrAgainstMuons_;
0244 
0245   //--- event selection criteria

0246   typedef std::vector<std::string> vstring;
0247   vstring hltPaths_;
0248 
0249   double muonEtaCut_;
0250   double muonPtCut_;
0251   double muonTrackIsoCut_;
0252   double muonEcalIsoCut_;
0253   double muonCombIsoCut_;
0254   int muonIsoMode_;
0255 
0256   double tauJetEtaCut_;
0257   double tauJetPtCut_;
0258 
0259   double visMassCut_;
0260   double deltaRCut_;
0261 
0262   //--- name of DQM directory in which histograms for Z --> muon + tau-jet

0263   // channel get stored

0264   std::string dqmDirectory_;
0265 
0266   //--- histograms

0267   // MonitorElement* hNumGlobalMuons_;

0268   MonitorElement* hMuonPt_;
0269   MonitorElement* hMuonEta_;
0270   MonitorElement* hMuonPhi_;
0271   MonitorElement* hMuonTrackIsoPt_;
0272   MonitorElement* hMuonEcalIsoPt_;
0273   MonitorElement* hMuonCombIsoPt_;
0274 
0275   MonitorElement* hTauJetPt_;
0276   MonitorElement* hTauJetEta_;
0277   MonitorElement* hTauJetPhi_;
0278   MonitorElement* hTauLeadTrackPt_;
0279   MonitorElement* hTauTrackIsoPt_;
0280   MonitorElement* hTauEcalIsoPt_;
0281   MonitorElement* hTauDiscrAgainstMuons_;
0282   MonitorElement* hTauJetCharge_;
0283   MonitorElement* hTauJetNumSignalTracks_;
0284   MonitorElement* hTauJetNumIsoTracks_;
0285 
0286   MonitorElement* hVisMass_;
0287   MonitorElement* hMuTauDeltaR_;
0288   MonitorElement* hVisMassFinal_;
0289   // MonitorElement* hMtMuCaloMEt_;

0290   MonitorElement* hMtMuPFMEt_;
0291   // MonitorElement* hPzetaCmaxNumWarnings_aloMEt_;

0292   // MonitorElement* hPzetaPFMEt_;

0293   MonitorElement* hMuTauAcoplanarity_;
0294   // MonitorElement* hMuTauCharge_;

0295 
0296   // MonitorElement* hVertexChi2_;

0297   MonitorElement* hVertexZ_;
0298   // MonitorElement* hVertexD0_;

0299 
0300   MonitorElement* hCaloMEtPt_;
0301   // MonitorElement* hCaloMEtPhi_;

0302 
0303   MonitorElement* hPFMEtPt_;
0304   // MonitorElement* hPFMEtPhi_;

0305 
0306   MonitorElement* hCutFlowSummary_;
0307   enum {
0308     kPassedPreselection = 1,
0309     kPassedTrigger = 2,
0310     kPassedMuonId = 3,
0311     kPassedTauLeadTrack = 4,
0312     kPassedTauLeadTrackPt = 5,
0313     kPassedTauDiscrAgainstMuons = 6,
0314     kPassedDeltaR = 7,
0315     kPassedMuonTrackIso = 8,
0316     kPassedMuonEcalIso = 9,
0317     kPassedTauTrackIso = 10,
0318     kPassedTauEcalIso = 11
0319   };
0320 
0321   //--- counters for filter-statistics output

0322   unsigned numEventsAnalyzed_;
0323   unsigned numEventsSelected_;
0324 
0325   int cfgError_;
0326 
0327   int maxNumWarnings_;
0328 
0329   long numWarningsTriggerResults_;
0330   long numWarningsHLTpath_;
0331   long numWarningsVertex_;
0332   long numWarningsBeamSpot_;
0333   long numWarningsMuon_;
0334   long numWarningsTauJet_;
0335   long numWarningsTauDiscrByLeadTrackFinding_;
0336   long numWarningsTauDiscrByLeadTrackPtCut_;
0337   long numWarningsTauDiscrByTrackIso_;
0338   long numWarningsTauDiscrByEcalIso_;
0339   long numWarningsTauDiscrAgainstMuons_;
0340   long numWarningsCaloMEt_;
0341   long numWarningsPFMEt_;
0342 };
0343 
0344 //-------------------------------------------------------------------------------

0345 // common auxiliary functions used by different channels

0346 //-------------------------------------------------------------------------------

0347 
0348 /**

0349  *

0350  * Auxiliary functions to compute quantities used by EWK Tau DQM

0351  * (shared by different channels)

0352  *

0353  * \author Joshua Swanson

0354  *

0355  *

0356  *

0357  */
0358 
0359 #include "DataFormats/Candidate/interface/Candidate.h"
0360 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0361 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0362 #include "DataFormats/MuonReco/interface/Muon.h"
0363 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0364 #include "DataFormats/TauReco/interface/PFTau.h"
0365 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0366 #include "DataFormats/VertexReco/interface/Vertex.h"
0367 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0368 
0369 #include <string>
0370 
0371 enum { kAbsoluteIso, kRelativeIso, kUndefinedIso };
0372 
0373 template <typename T>
0374 void readEventData(const edm::Event& evt,
0375                    const edm::InputTag& src,
0376                    edm::Handle<T>& handle,
0377                    long& numWarnings,
0378                    int maxNumWarnings,
0379                    bool& error,
0380                    const char* errorMessage) {
0381   if (!evt.getByLabel(src, handle)) {
0382     if (numWarnings < maxNumWarnings || maxNumWarnings == -1)
0383       edm::LogWarning("readEventData") << errorMessage << " !!";
0384     ++numWarnings;
0385     error = true;
0386   }
0387 }
0388 
0389 int getIsoMode(const std::string&, int&);
0390 
0391 double calcDeltaPhi(double, double);
0392 double calcMt(double, double, double, double);
0393 double calcPzeta(const reco::Candidate::LorentzVector&, const reco::Candidate::LorentzVector&, double, double);
0394 
0395 bool passesElectronPreId(const reco::GsfElectron&);
0396 bool passesElectronId(const reco::GsfElectron&);
0397 
0398 const reco::GsfElectron* getTheElectron(const reco::GsfElectronCollection&, double, double);
0399 const reco::Muon* getTheMuon(const reco::MuonCollection&, double, double);
0400 const reco::PFTau* getTheTauJet(const reco::PFTauCollection&, double, double, int&);
0401 
0402 double getVertexD0(const reco::Vertex&, const reco::BeamSpot&);
0403 
0404 #endif