Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-26 00:02:29

0001 #ifndef PhotonAnalyzer_H
0002 #define PhotonAnalyzer_H
0003 
0004 #include "FWCore/ServiceRegistry/interface/Service.h"
0005 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0006 //
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 // DataFormats
0012 #include "DataFormats/Math/interface/deltaR.h"
0013 #include "DataFormats/Common/interface/Handle.h"
0014 #include "DataFormats/TrackReco/interface/Track.h"
0015 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0016 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0017 #include "DataFormats/Common/interface/ValueMap.h"
0018 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
0019 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
0020 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0021 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0022 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0023 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0024 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0025 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
0026 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0027 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0028 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0029 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0030 #include "DataFormats/DetId/interface/DetId.h"
0031 
0032 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0033 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
0034 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0035 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0036 
0037 /// EgammaCoreTools
0038 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
0039 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
0040 
0041 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0042 
0043 // Geometry
0044 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0045 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0046 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0047 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0048 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0049 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0050 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0051 #include "Geometry/CaloTopology/interface/EcalEndcapTopology.h"
0052 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
0053 
0054 #include "TFile.h"
0055 #include "TH1.h"
0056 #include "TH2.h"
0057 #include "TTree.h"
0058 #include "TVector3.h"
0059 #include "TProfile.h"
0060 
0061 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0062 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0063 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0064 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0065 #include "FWCore/Framework/interface/Event.h"
0066 #include "FWCore/Framework/interface/EventSetup.h"
0067 #include "FWCore/Framework/interface/ESHandle.h"
0068 
0069 //DQM services
0070 #include <DQMServices/Core/interface/DQMStore.h>
0071 #include <DQMServices/Core/interface/DQMEDAnalyzer.h>
0072 
0073 //
0074 
0075 #include <vector>
0076 #include <string>
0077 
0078 /** \class PhotonAnalyzer
0079  **  
0080  **
0081  **  $Id: PhotonAnalyzer
0082  **  authors: 
0083  **   Nancy Marinelli, U. of Notre Dame, US  
0084  **   Jamie Antonelli, U. of Notre Dame, US
0085  **     
0086  ***/
0087 
0088 // forward declarations
0089 class TFile;
0090 class TH1F;
0091 class TH2F;
0092 class TProfile;
0093 class TTree;
0094 class SimVertex;
0095 class SimTrack;
0096 
0097 class PhotonAnalyzer : public DQMEDAnalyzer {
0098 public:
0099   explicit PhotonAnalyzer(const edm::ParameterSet&);
0100   ~PhotonAnalyzer() override;
0101   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0102   void analyze(const edm::Event&, const edm::EventSetup&) override;
0103 
0104 private:
0105   void bookHistogramsForHistogramCounts(DQMStore::IBooker&);
0106 
0107   void bookHistogramsEfficiency(DQMStore::IBooker&);
0108   void bookHistogramsInvMass(DQMStore::IBooker&);
0109   void bookHistogramsPhotons(DQMStore::IBooker&);
0110   void bookHistogramsConversions(DQMStore::IBooker&);
0111 
0112   void fillHistogramsForHistogramCounts(DQMStore::IBooker&);
0113 
0114   MonitorElement* bookHisto(
0115       DQMStore::IBooker&, std::string histoName, std::string title, int bin, double min, double max);
0116   void book2DHistoVector(DQMStore::IBooker&,
0117                          std::vector<std::vector<MonitorElement*> >& toFill,
0118                          std::string histoType,
0119                          std::string histoName,
0120                          std::string title,
0121                          int xbin,
0122                          double xmin,
0123                          double xmax,
0124                          int ybin = 1,
0125                          double ymin = 1,
0126                          double ymax = 2);
0127   void book3DHistoVector(DQMStore::IBooker&,
0128                          std::vector<std::vector<std::vector<MonitorElement*> > >& toFill,
0129                          std::string histoType,
0130                          std::string histoName,
0131                          std::string title,
0132                          int xbin,
0133                          double xmin,
0134                          double xmax,
0135                          int ybin = 1,
0136                          double ymin = 1,
0137                          double ymax = 2);
0138 
0139   void fill2DHistoVector(std::vector<std::vector<MonitorElement*> >& histoVector, double x, int cut, int type);
0140   void fill2DHistoVector(std::vector<std::vector<MonitorElement*> >& histoVector, double x, double y, int cut, int type);
0141 
0142   void fill3DHistoVector(
0143       std::vector<std::vector<std::vector<MonitorElement*> > >& histoVector, double x, int cut, int type, int part);
0144   void fill3DHistoVector(std::vector<std::vector<std::vector<MonitorElement*> > >& histoVector,
0145                          double x,
0146                          double y,
0147                          int cut,
0148                          int type,
0149                          int part);
0150 
0151   bool photonSelection(const reco::Photon* p);
0152   bool photonSelectionSlimmed(const reco::Photon* p);
0153   float phiNormalization(float& a);
0154 
0155   //////////
0156 
0157   std::string fName_;
0158 
0159   unsigned int prescaleFactor_;
0160 
0161   edm::EDGetTokenT<std::vector<reco::Photon> > photon_token_;
0162   edm::EDGetTokenT<edm::ValueMap<bool> > PhotonIDLoose_token_;
0163   edm::EDGetTokenT<edm::ValueMap<bool> > PhotonIDTight_token_;
0164   edm::EDGetTokenT<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit> > > barrelRecHit_token_;
0165   edm::EDGetTokenT<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit> > > endcapRecHit_token_;
0166   edm::EDGetTokenT<trigger::TriggerEvent> triggerEvent_token_;
0167   edm::EDGetTokenT<reco::VertexCollection> offline_pvToken_;
0168 
0169   double minPhoEtCut_;
0170   double photonMaxEta_;
0171   double invMassEtCut_;
0172 
0173   double cutStep_;
0174   int numberOfSteps_;
0175 
0176   bool useBinning_;
0177   bool useTriggerFiltering_;
0178   bool standAlone_;
0179 
0180   bool minimalSetOfHistos_;
0181   bool excludeBkgHistos_;
0182 
0183   int isolationStrength_;
0184 
0185   bool isHeavyIon_;
0186 
0187   ////////
0188 
0189   std::stringstream currentFolder_;
0190 
0191   int histo_index_photons_;
0192   int histo_index_conversions_;
0193   int histo_index_efficiency_;
0194   int histo_index_invMass_;
0195 
0196   int nEvt_;
0197 
0198   std::vector<std::string> types_;
0199   std::vector<std::string> parts_;
0200 
0201   //////////
0202 
0203   // Histogram parameters
0204   int etaBin_;
0205   double etaMin_;
0206   double etaMax_;
0207 
0208   int etBin_;
0209   double etMin_;
0210   double etMax_;
0211 
0212   int phiBin_;
0213   double phiMin_;
0214   double phiMax_;
0215 
0216   int eBin_;
0217   double eMin_;
0218   double eMax_;
0219 
0220   int numberBin_;
0221   double numberMin_;
0222   double numberMax_;
0223 
0224   int r9Bin_;
0225   double r9Min_;
0226   double r9Max_;
0227 
0228   int sigmaIetaBin_;
0229   double sigmaIetaMin_;
0230   double sigmaIetaMax_;
0231 
0232   int sumBin_;
0233   double sumMin_;
0234   double sumMax_;
0235 
0236   int hOverEBin_;
0237   double hOverEMin_;
0238   double hOverEMax_;
0239 
0240   int eOverPBin_;
0241   double eOverPMin_;
0242   double eOverPMax_;
0243 
0244   int dPhiTracksBin_;
0245   double dPhiTracksMin_;
0246   double dPhiTracksMax_;
0247 
0248   int dEtaTracksBin_;
0249   double dEtaTracksMin_;
0250   double dEtaTracksMax_;
0251 
0252   int chi2Bin_;
0253   double chi2Min_;
0254   double chi2Max_;
0255 
0256   int zBin_;
0257   double zMin_;
0258   double zMax_;
0259 
0260   int rBin_;
0261   double rMin_;
0262   double rMax_;
0263 
0264   int xBin_;
0265   double xMin_;
0266   double xMax_;
0267 
0268   int yBin_;
0269   double yMin_;
0270   double yMax_;
0271 
0272   int reducedEtBin_;
0273   int reducedEtaBin_;
0274   int reducedR9Bin_;
0275   int reducedSumBin_;
0276 
0277   MonitorElement* totalNumberOfHistos_efficiencyFolder;
0278   MonitorElement* totalNumberOfHistos_invMassFolder;
0279   MonitorElement* totalNumberOfHistos_photonsFolder;
0280   MonitorElement* totalNumberOfHistos_conversionsFolder;
0281 
0282   MonitorElement* h_nRecoVtx_;
0283 
0284   MonitorElement* h_phoEta_Loose_;
0285   MonitorElement* h_phoEta_Tight_;
0286   MonitorElement* h_phoEt_Loose_;
0287   MonitorElement* h_phoEt_Tight_;
0288 
0289   MonitorElement* h_phoEta_preHLT_;
0290   MonitorElement* h_phoEta_postHLT_;
0291   MonitorElement* h_phoEt_preHLT_;
0292   MonitorElement* h_phoEt_postHLT_;
0293 
0294   MonitorElement* h_convEta_Loose_;
0295   MonitorElement* h_convEta_Tight_;
0296   MonitorElement* h_convEt_Loose_;
0297   MonitorElement* h_convEt_Tight_;
0298 
0299   MonitorElement* h_phoEta_Vertex_;
0300 
0301   MonitorElement* h_invMassTwoWithTracks_;
0302   MonitorElement* h_invMassOneWithTracks_;
0303   MonitorElement* h_invMassZeroWithTracks_;
0304   MonitorElement* h_invMassAllPhotons_;
0305   MonitorElement* h_invMassPhotonsEBarrel_;
0306   MonitorElement* h_invMassPhotonsEEndcap_;
0307   MonitorElement* h_invMassPhotonsEEndcapEBarrel_;
0308 
0309   ////////2D vectors of histograms
0310 
0311   std::vector<std::vector<MonitorElement*> > h_nTrackIsolSolidVsEta_;
0312   std::vector<std::vector<MonitorElement*> > h_trackPtSumSolidVsEta_;
0313   std::vector<std::vector<MonitorElement*> > h_nTrackIsolHollowVsEta_;
0314   std::vector<std::vector<MonitorElement*> > h_trackPtSumHollowVsEta_;
0315   std::vector<std::vector<MonitorElement*> > h_ecalSumVsEta_;
0316   std::vector<std::vector<MonitorElement*> > h_hcalSumVsEta_;
0317 
0318   std::vector<std::vector<MonitorElement*> > h_nTrackIsolSolidVsEt_;
0319   std::vector<std::vector<MonitorElement*> > h_trackPtSumSolidVsEt_;
0320   std::vector<std::vector<MonitorElement*> > h_nTrackIsolHollowVsEt_;
0321   std::vector<std::vector<MonitorElement*> > h_trackPtSumHollowVsEt_;
0322   std::vector<std::vector<MonitorElement*> > h_ecalSumVsEt_;
0323   std::vector<std::vector<MonitorElement*> > h_hcalSumVsEt_;
0324 
0325   std::vector<std::vector<MonitorElement*> > h_nTrackIsolSolid_;
0326   std::vector<std::vector<MonitorElement*> > h_trackPtSumSolid_;
0327   std::vector<std::vector<MonitorElement*> > h_nTrackIsolHollow_;
0328   std::vector<std::vector<MonitorElement*> > h_trackPtSumHollow_;
0329   std::vector<std::vector<MonitorElement*> > h_ecalSum_;
0330   std::vector<std::vector<MonitorElement*> > h_ecalSumEBarrel_;
0331   std::vector<std::vector<MonitorElement*> > h_ecalSumEEndcap_;
0332   std::vector<std::vector<MonitorElement*> > h_hcalSum_;
0333   std::vector<std::vector<MonitorElement*> > h_hcalSumEBarrel_;
0334   std::vector<std::vector<MonitorElement*> > h_hcalSumEEndcap_;
0335 
0336   std::vector<std::vector<MonitorElement*> > h_phoIsoBarrel_;
0337   std::vector<std::vector<MonitorElement*> > h_phoIsoEndcap_;
0338   std::vector<std::vector<MonitorElement*> > h_chHadIsoBarrel_;
0339   std::vector<std::vector<MonitorElement*> > h_chHadIsoEndcap_;
0340   std::vector<std::vector<MonitorElement*> > h_nHadIsoBarrel_;
0341   std::vector<std::vector<MonitorElement*> > h_nHadIsoEndcap_;
0342 
0343   std::vector<std::vector<MonitorElement*> > p_nTrackIsolSolidVsEta_;
0344   std::vector<std::vector<MonitorElement*> > p_trackPtSumSolidVsEta_;
0345   std::vector<std::vector<MonitorElement*> > p_nTrackIsolHollowVsEta_;
0346   std::vector<std::vector<MonitorElement*> > p_trackPtSumHollowVsEta_;
0347   std::vector<std::vector<MonitorElement*> > p_ecalSumVsEta_;
0348   std::vector<std::vector<MonitorElement*> > p_hcalSumVsEta_;
0349 
0350   std::vector<std::vector<MonitorElement*> > p_nTrackIsolSolidVsEt_;
0351   std::vector<std::vector<MonitorElement*> > p_trackPtSumSolidVsEt_;
0352   std::vector<std::vector<MonitorElement*> > p_nTrackIsolHollowVsEt_;
0353   std::vector<std::vector<MonitorElement*> > p_trackPtSumHollowVsEt_;
0354 
0355   std::vector<std::vector<MonitorElement*> > p_r9VsEt_;
0356   std::vector<std::vector<MonitorElement*> > p_r9VsEta_;
0357 
0358   std::vector<std::vector<MonitorElement*> > p_e1x5VsEt_;
0359   std::vector<std::vector<MonitorElement*> > p_e1x5VsEta_;
0360 
0361   std::vector<std::vector<MonitorElement*> > p_e2x5VsEt_;
0362   std::vector<std::vector<MonitorElement*> > p_e2x5VsEta_;
0363 
0364   std::vector<std::vector<MonitorElement*> > p_maxEXtalOver3x3VsEt_;
0365   std::vector<std::vector<MonitorElement*> > p_maxEXtalOver3x3VsEta_;
0366 
0367   std::vector<std::vector<MonitorElement*> > p_r1x5VsEt_;
0368   std::vector<std::vector<MonitorElement*> > p_r1x5VsEta_;
0369 
0370   std::vector<std::vector<MonitorElement*> > p_r2x5VsEt_;
0371   std::vector<std::vector<MonitorElement*> > p_r2x5VsEta_;
0372 
0373   std::vector<std::vector<MonitorElement*> > p_sigmaIetaIetaVsEta_;
0374 
0375   std::vector<std::vector<MonitorElement*> > p_dCotTracksVsEta_;
0376 
0377   std::vector<std::vector<MonitorElement*> > p_hOverEVsEta_;
0378   std::vector<std::vector<MonitorElement*> > p_hOverEVsEt_;
0379 
0380   std::vector<std::vector<MonitorElement*> > h_phoEta_;
0381   std::vector<std::vector<MonitorElement*> > h_scEta_;
0382 
0383   std::vector<std::vector<MonitorElement*> > h_phoConvEtaForEfficiency_;
0384 
0385   std::vector<std::vector<MonitorElement*> > h_phoEta_BadChannels_;
0386   std::vector<std::vector<MonitorElement*> > h_phoEt_BadChannels_;
0387   std::vector<std::vector<MonitorElement*> > h_phoPhi_BadChannels_;
0388 
0389   std::vector<std::vector<MonitorElement*> > h_phoConvEta_;
0390 
0391   std::vector<std::vector<MonitorElement*> > h_convVtxRvsZ_;
0392   std::vector<std::vector<MonitorElement*> > h_convVtxZEndcap_;
0393   std::vector<std::vector<MonitorElement*> > h_convVtxZ_;
0394   std::vector<std::vector<MonitorElement*> > h_convVtxYvsX_;
0395   std::vector<std::vector<MonitorElement*> > h_convVtxR_;
0396 
0397   std::vector<std::vector<MonitorElement*> > h_r9VsEt_;
0398   std::vector<std::vector<MonitorElement*> > h_r9VsEta_;
0399 
0400   std::vector<std::vector<MonitorElement*> > h_e1x5VsEt_;
0401   std::vector<std::vector<MonitorElement*> > h_e1x5VsEta_;
0402 
0403   std::vector<std::vector<MonitorElement*> > h_e2x5VsEt_;
0404   std::vector<std::vector<MonitorElement*> > h_e2x5VsEta_;
0405 
0406   std::vector<std::vector<MonitorElement*> > h_maxEXtalOver3x3VsEt_;
0407   std::vector<std::vector<MonitorElement*> > h_maxEXtalOver3x3VsEta_;
0408 
0409   std::vector<std::vector<MonitorElement*> > h_r1x5VsEt_;
0410   std::vector<std::vector<MonitorElement*> > h_r1x5VsEta_;
0411 
0412   std::vector<std::vector<MonitorElement*> > h_r2x5VsEt_;
0413   std::vector<std::vector<MonitorElement*> > h_r2x5VsEta_;
0414 
0415   std::vector<std::vector<MonitorElement*> > h_sigmaIetaIetaVsEta_;
0416 
0417   std::vector<std::vector<MonitorElement*> > h_tkChi2_;
0418 
0419   std::vector<std::vector<MonitorElement*> > h_vertexChi2Prob_;
0420 
0421   std::vector<std::vector<MonitorElement*> > p_nHitsVsEta_;
0422 
0423   std::vector<std::vector<MonitorElement*> > p_tkChi2VsEta_;
0424 
0425   ////////3D std::vectors of histograms
0426 
0427   std::vector<std::vector<std::vector<MonitorElement*> > > p_ecalSumVsEt_;
0428   std::vector<std::vector<std::vector<MonitorElement*> > > p_hcalSumVsEt_;
0429 
0430   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoE_;
0431   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoSigmaEoverE_;
0432   std::vector<std::vector<std::vector<MonitorElement*> > > p_phoSigmaEoverEvsNVtx_;
0433   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoEt_;
0434   std::vector<std::vector<std::vector<MonitorElement*> > > h_r9_;
0435   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoPhi_;
0436   std::vector<std::vector<std::vector<MonitorElement*> > > h_scPhi_;
0437   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoConvPhiForEfficiency_;
0438   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoConvPhi_;
0439 
0440   std::vector<std::vector<std::vector<MonitorElement*> > > h_hOverE_;
0441   std::vector<std::vector<std::vector<MonitorElement*> > > h_h1OverE_;
0442   std::vector<std::vector<std::vector<MonitorElement*> > > h_h2OverE_;
0443 
0444   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoSigmaIetaIeta_;
0445 
0446   std::vector<std::vector<std::vector<MonitorElement*> > > h_nPho_;
0447 
0448   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoConvE_;
0449   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoConvEt_;
0450   std::vector<std::vector<std::vector<MonitorElement*> > > h_phoConvR9_;
0451 
0452   std::vector<std::vector<std::vector<MonitorElement*> > > h_nConv_;
0453 
0454   std::vector<std::vector<std::vector<MonitorElement*> > > h_eOverPTracks_;
0455   std::vector<std::vector<std::vector<MonitorElement*> > > h_pOverETracks_;
0456 
0457   std::vector<std::vector<std::vector<MonitorElement*> > > h_dCotTracks_;
0458 
0459   std::vector<std::vector<std::vector<MonitorElement*> > > h_dPhiTracksAtVtx_;
0460   std::vector<std::vector<std::vector<MonitorElement*> > > h_dPhiTracksAtEcal_;
0461 
0462   std::vector<std::vector<std::vector<MonitorElement*> > > h_dEtaTracksAtEcal_;
0463 };
0464 
0465 #endif