Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-22 00:50:33

0001 #ifndef DQMOffline_Physics_HeavyFlavorDQMAnalyzer_h
0002 #define DQMOffline_Physics_HeavyFlavorDQMAnalyzer_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    DQMOffline/HeavyFlavorDQMAnalyzer
0007 // Class:      HeavyFlavorDQMAnalyzer
0008 //
0009 /**\class HeavyFlavorDQMAnalyzer HeavyFlavorDQMAnalyzer.cc DQMOffline/HeavyFlavorDQMAnalyzer/plugins/HeavyFlavorDQMAnalyzer.cc
0010 
0011  Description: [one line class summary]
0012 
0013  Implementation:
0014      [Notes on implementation]
0015 */
0016 //
0017 // Original Author:  Enrico Lusiani
0018 //         Created:  Mon, 22 Nov 2021 14:36:39 GMT
0019 //
0020 //
0021 
0022 #include <string>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"
0027 
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 
0033 #include "DataFormats/Common/interface/Ref.h"
0034 #include "DataFormats/PatCandidates/interface/CompositeCandidate.h"
0035 #include "DataFormats/VertexReco/interface/Vertex.h"
0036 
0037 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0038 #include "RecoVertex/VertexTools/interface/VertexDistanceXY.h"
0039 
0040 #include "HeavyFlavorAnalysis/RecoDecay/interface/BPHTrackReference.h"
0041 
0042 //
0043 // class declaration
0044 //
0045 
0046 struct ComponentHists {
0047   dqm::reco::MonitorElement* h_pt;
0048   dqm::reco::MonitorElement* h_eta;
0049   dqm::reco::MonitorElement* h_phi;
0050 
0051   dqm::reco::MonitorElement* h_dxy;
0052   dqm::reco::MonitorElement* h_exy;
0053   dqm::reco::MonitorElement* h_dz;
0054   dqm::reco::MonitorElement* h_ez;
0055 
0056   dqm::reco::MonitorElement* h_chi2;
0057 };
0058 
0059 struct DecayHists {
0060   // kinematics
0061   dqm::reco::MonitorElement* h_mass;
0062   dqm::reco::MonitorElement* h_pt;
0063   dqm::reco::MonitorElement* h_eta;
0064   dqm::reco::MonitorElement* h_phi;
0065 
0066   // position
0067   dqm::reco::MonitorElement* h_displ2D;
0068   dqm::reco::MonitorElement* h_displ3D;
0069   dqm::reco::MonitorElement* h_sign2D;
0070   dqm::reco::MonitorElement* h_sign3D;
0071 
0072   // ct and pointing angle
0073   dqm::reco::MonitorElement* h_ct;
0074   dqm::reco::MonitorElement* h_pointing;
0075 
0076   // quality
0077   dqm::reco::MonitorElement* h_vertNormChi2;
0078   dqm::reco::MonitorElement* h_vertProb;
0079 
0080   std::vector<ComponentHists> decayComponents;
0081 };
0082 
0083 struct Histograms_HeavyFlavorDQMAnalyzer {
0084   DecayHists oniaToMuMuPrompt;
0085   DecayHists oniaToMuMuDispl;
0086   DecayHists oniaToMuMu;
0087   DecayHists kx0ToKPiPrompt;
0088   DecayHists kx0ToKPiDispl;
0089   DecayHists kx0ToKPi;
0090   DecayHists phiToKKPrompt;
0091   DecayHists phiToKKDispl;
0092   DecayHists phiToKK;
0093   DecayHists psi2SToJPsiPiPiPrompt;
0094   DecayHists psi2SToJPsiPiPiDispl;
0095   DecayHists psi2SToJPsiPiPi;
0096   DecayHists k0sToPiPi;
0097   DecayHists lambda0ToPPi;
0098   DecayHists buToJPsiK;
0099   DecayHists buToPsi2SK;
0100   DecayHists bdToJPsiKx0;
0101   DecayHists bsToJPsiPhi;
0102   DecayHists bdToJPsiK0s;
0103   DecayHists bcToJPsiPi;
0104   DecayHists lambdaBToJPsiLambda0;
0105 };
0106 
0107 class HeavyFlavorDQMAnalyzer : public DQMGlobalEDAnalyzer<Histograms_HeavyFlavorDQMAnalyzer> {
0108 public:
0109   using Histograms = Histograms_HeavyFlavorDQMAnalyzer;
0110 
0111   explicit HeavyFlavorDQMAnalyzer(const edm::ParameterSet&);
0112   ~HeavyFlavorDQMAnalyzer() override;
0113 
0114   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0115 
0116 private:
0117   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
0118 
0119   void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms const&) const override;
0120 
0121   void bookDecayHists(DQMStore::IBooker&,
0122                       edm::Run const&,
0123                       edm::EventSetup const&,
0124                       DecayHists&,
0125                       std::string const&,
0126                       std::string const&,
0127                       int,
0128                       float,
0129                       float,
0130                       float distanceScaleFactor = 1.) const;
0131   void initComponentHists(DQMStore::IBooker&,
0132                           edm::Run const&,
0133                           edm::EventSetup const&,
0134                           DecayHists&,
0135                           TString const&) const;  // TString for the IBooker interface
0136 
0137   void initOniaToMuMuComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0138   void initKx0ToKPiComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0139   void initPhiToKKComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0140   void initK0sToPiPiComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0141   void initLambda0ToPPiComponentHistograms(DQMStore::IBooker&,
0142                                            edm::Run const&,
0143                                            edm::EventSetup const&,
0144                                            DecayHists&) const;
0145   void initBuToJPsiKComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0146   void initBuToPsi2SKComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0147   void initBdToJPsiKx0ComponentHistograms(DQMStore::IBooker&,
0148                                           edm::Run const&,
0149                                           edm::EventSetup const&,
0150                                           DecayHists&) const;
0151   void initBsToJPsiPhiComponentHistograms(DQMStore::IBooker&,
0152                                           edm::Run const&,
0153                                           edm::EventSetup const&,
0154                                           DecayHists&) const;
0155   void initBdToJPsiK0sComponentHistograms(DQMStore::IBooker&,
0156                                           edm::Run const&,
0157                                           edm::EventSetup const&,
0158                                           DecayHists&) const;
0159   void initBcToJPsiPiComponentHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, DecayHists&) const;
0160   void initLambdaBToJPsiLambda0ComponentHistograms(DQMStore::IBooker&,
0161                                                    edm::Run const&,
0162                                                    edm::EventSetup const&,
0163                                                    DecayHists&) const;
0164   void initPsi2SToJPsiPiPiComponentHistograms(DQMStore::IBooker&,
0165                                               edm::Run const&,
0166                                               edm::EventSetup const&,
0167                                               DecayHists&) const;
0168 
0169   reco::Vertex const* fillDecayHistograms(DecayHists const&,
0170                                           pat::CompositeCandidate const& cand,
0171                                           reco::VertexCollection const& pvs) const;
0172   void fillComponentHistograms(ComponentHists const& histos,
0173                                reco::Track const& component,
0174                                reco::BeamSpot const* bs,
0175                                reco::Vertex const* pv) const;
0176 
0177   int fillComponentHistogramsSinglePart(DecayHists const&,
0178                                         pat::CompositeCandidate const& cand,
0179                                         std::string const& name,
0180                                         reco::BeamSpot const* bs,
0181                                         reco::Vertex const* pv,
0182                                         int startPosition = 0) const;
0183   int fillComponentHistogramsLeadSoft(DecayHists const&,
0184                                       pat::CompositeCandidate const& cand,
0185                                       std::string const& name1,
0186                                       std::string const& name2,
0187                                       reco::BeamSpot const* bs,
0188                                       reco::Vertex const* pv,
0189                                       int startPosition = 0) const;
0190 
0191   const reco::Track* getDaughterTrack(pat::CompositeCandidate const& cand,
0192                                       std::string const& name,
0193                                       bool throwOnMissing = true) const;
0194   bool allTracksAvailable(pat::CompositeCandidate const& cand) const;
0195 
0196   int fillOniaToMuMuComponents(DecayHists const& histos,
0197                                pat::CompositeCandidate const& cand,
0198                                reco::BeamSpot const* bs,
0199                                reco::Vertex const* pv,
0200                                int startPosition = 0) const;
0201   int fillKx0ToKPiComponents(DecayHists const& histos,
0202                              pat::CompositeCandidate const& cand,
0203                              reco::BeamSpot const* bs,
0204                              reco::Vertex const* pv,
0205                              int startPosition = 0) const;
0206   int fillPhiToKKComponents(DecayHists const& histos,
0207                             pat::CompositeCandidate const& cand,
0208                             reco::BeamSpot const* bs,
0209                             reco::Vertex const* pv,
0210                             int startPosition = 0) const;
0211   int fillK0sToPiPiComponents(DecayHists const& histos,
0212                               pat::CompositeCandidate const& cand,
0213                               reco::BeamSpot const* bs,
0214                               reco::Vertex const* pv,
0215                               int startPosition = 0) const;
0216   int fillLambda0ToPPiComponents(DecayHists const& histos,
0217                                  pat::CompositeCandidate const& cand,
0218                                  reco::BeamSpot const* bs,
0219                                  reco::Vertex const* pv,
0220                                  int startPosition = 0) const;
0221   int fillBuToJPsiKComponents(DecayHists const& histos,
0222                               pat::CompositeCandidate const& cand,
0223                               reco::BeamSpot const* bs,
0224                               reco::Vertex const* pv,
0225                               int startPosition = 0) const;
0226   int fillBuToPsi2SKComponents(DecayHists const& histos,
0227                                pat::CompositeCandidate const& cand,
0228                                reco::BeamSpot const* bs,
0229                                reco::Vertex const* pv,
0230                                int startPosition = 0) const;
0231   int fillBdToJPsiKx0Components(DecayHists const& histos,
0232                                 pat::CompositeCandidate const& cand,
0233                                 reco::BeamSpot const* bs,
0234                                 reco::Vertex const* pv,
0235                                 int startPosition = 0) const;
0236   int fillBsToJPsiPhiComponents(DecayHists const& histos,
0237                                 pat::CompositeCandidate const& cand,
0238                                 reco::BeamSpot const* bs,
0239                                 reco::Vertex const* pv,
0240                                 int startPosition = 0) const;
0241   int fillBdToJPsiK0sComponents(DecayHists const& histos,
0242                                 pat::CompositeCandidate const& cand,
0243                                 reco::BeamSpot const* bs,
0244                                 reco::Vertex const* pv,
0245                                 int startPosition = 0) const;
0246   int fillBcToJPsiPiComponents(DecayHists const& histos,
0247                                pat::CompositeCandidate const& cand,
0248                                reco::BeamSpot const* bs,
0249                                reco::Vertex const* pv,
0250                                int startPosition = 0) const;
0251   int fillLambdaBToJPsiLambda0Components(DecayHists const& histos,
0252                                          pat::CompositeCandidate const& cand,
0253                                          reco::BeamSpot const* bs,
0254                                          reco::Vertex const* pv,
0255                                          int startPosition = 0) const;
0256   int fillPsi2SToJPsiPiPiComponents(DecayHists const& histos,
0257                                     pat::CompositeCandidate const& cand,
0258                                     reco::BeamSpot const* bs,
0259                                     reco::Vertex const* pv,
0260                                     int startPosition = 0) const;
0261 
0262   // ------------ member data ------------
0263   std::string folder_;
0264 
0265   edm::EDGetTokenT<reco::VertexCollection> pvCollectionToken;
0266   edm::EDGetTokenT<reco::BeamSpot> beamSpotToken;
0267 
0268   edm::EDGetTokenT<pat::CompositeCandidateCollection> oniaToMuMuCandsToken;
0269   edm::EDGetTokenT<pat::CompositeCandidateCollection> kx0ToKPiCandsToken;
0270   edm::EDGetTokenT<pat::CompositeCandidateCollection> phiToKKCandsToken;
0271   edm::EDGetTokenT<pat::CompositeCandidateCollection> buToJPsiKCandsToken;
0272   edm::EDGetTokenT<pat::CompositeCandidateCollection> buToPsi2SKCandsToken;
0273   edm::EDGetTokenT<pat::CompositeCandidateCollection> bdToJPsiKx0CandsToken;
0274   edm::EDGetTokenT<pat::CompositeCandidateCollection> bsToJPsiPhiCandsToken;
0275   edm::EDGetTokenT<pat::CompositeCandidateCollection> k0sToPiPiCandsToken;
0276   edm::EDGetTokenT<pat::CompositeCandidateCollection> lambda0ToPPiCandsToken;
0277   edm::EDGetTokenT<pat::CompositeCandidateCollection> bdToJPsiK0sCandsToken;
0278   edm::EDGetTokenT<pat::CompositeCandidateCollection> lambdaBToJPsiLambda0CandsToken;
0279   edm::EDGetTokenT<pat::CompositeCandidateCollection> bcToJPsiPiCandsToken;
0280   edm::EDGetTokenT<pat::CompositeCandidateCollection> psi2SToJPsiPiPiCandsToken;
0281 };
0282 
0283 #endif