CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Validation/RecoEgamma/plugins/PhotonValidator.h

Go to the documentation of this file.
00001 #ifndef PhotonValidator_H
00002 #define PhotonValidator_H
00003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00005 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011 #include "RecoEgamma/EgammaMCTools/interface/PhotonMCTruthFinder.h"
00012 #include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h"
00013 #include "MagneticField/Engine/interface/MagneticField.h"
00014 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00015 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00016 
00017 //#include "RecoEgamma/EgammaTools/interface/ConversionLikelihoodCalculator.h"
00018 //
00019 //DQM services
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 #include "FWCore/ServiceRegistry/interface/Service.h"
00022 #include "DQMServices/Core/interface/MonitorElement.h"
00023 
00024 //
00025 #include <map>
00026 #include <vector>
00038 // forward declarations
00039 class TFile;
00040 class TH1F;
00041 class TH2F;
00042 class TProfile;
00043 class TTree;
00044 class SimVertex;
00045 class SimTrack;
00046 
00047 
00048 
00049 class PhotonValidator : public edm::EDAnalyzer
00050 {
00051 
00052  public:
00053    
00054   //
00055   explicit PhotonValidator( const edm::ParameterSet& ) ;
00056   virtual ~PhotonValidator();
00057                                    
00058       
00059   virtual void analyze( const edm::Event&, const edm::EventSetup& ) ;
00060   virtual void beginJob();
00061   virtual void beginRun( edm::Run const & r, edm::EventSetup const & theEventSetup) ;
00062   virtual void endRun (edm::Run& r, edm::EventSetup const & es);
00063   virtual void endJob() ;
00064   
00065  private:
00066   //
00067 
00068   float  phiNormalization( float& a);
00069   float  etaTransformation( float a, float b);
00070 
00071       
00072   std::string fName_;
00073   DQMStore *dbe_;
00074   edm::ESHandle<MagneticField> theMF_;
00075 
00076   int verbosity_;
00077   int nEvt_;
00078   int nEntry_;
00079   int nSimPho_[2];
00080   int nSimConv_[2];
00081   int nMatched_;
00082   int nRecConv_;
00083   int nRecConvAss_;
00084   int nRecConvAssWithEcal_;
00085 
00086   int nInvalidPCA_;
00087 
00088   edm::ParameterSet parameters_;
00089   edm::ESHandle<CaloGeometry> theCaloGeom_;         
00090   edm::ESHandle<CaloTopology> theCaloTopo_;
00091 
00092   std::string photonCollectionProducer_;       
00093   std::string photonCollection_;
00094 
00095   edm::InputTag  bcBarrelCollection_;
00096   edm::InputTag  bcEndcapCollection_;
00097  
00098   edm::InputTag barrelEcalHits_;
00099   edm::InputTag endcapEcalHits_;
00100 
00101   edm::InputTag label_tp_;
00102 
00103 
00104   std::string conversionOITrackProducer_;
00105   std::string conversionIOTrackProducer_;
00106 
00107 
00108 
00109   PhotonMCTruthFinder*  thePhotonMCTruthFinder_;
00110   TrackAssociatorBase * theTrackAssociator_;
00111 
00112   bool fastSim_;
00113   bool isRunCentrally_;
00114 
00115 
00116   double minPhoEtCut_;
00117   double convTrackMinPtCut_;
00118   double likelihoodCut_;
00119   double trkIsolExtRadius_;
00120   double trkIsolInnRadius_;
00121   double trkPtLow_;
00122   double lip_;
00123   double ecalIsolRadius_;
00124   double bcEtLow_;
00125   double hcalIsolExtRadius_;
00126   double hcalIsolInnRadius_;
00127   double hcalHitEtLow_;
00128   int  numOfTracksInCone_;
00129   double trkPtSumCut_;
00130   double ecalEtSumCut_;
00131   double hcalEtSumCut_;
00132   bool dCotCutOn_;
00133   double dCotCutValue_;
00134   double dCotHardCutValue_;
00135 
00136 
00138   double mcPhi_;
00139   double mcEta_;
00140   double mcConvR_;      
00141   double mcConvZ_;
00142   double mcConvY_;            
00143   double mcConvX_;            
00144   double mcConvPhi_;            
00145   double mcConvEta_;            
00146   double mcJetEta_;
00147   double mcJetPhi_;
00148 
00149   edm::RefVector<TrackingParticleCollection> theConvTP_;
00150  //  std::vector<TrackingParticleRef> theConvTP_;
00151   
00152   double simMinPt_;
00153   double simMaxPt_;
00154   
00156   double recMinPt_;
00157   double recMaxPt_;
00158   MonitorElement* h_nRecoVtx_;
00159   //
00160   MonitorElement* h_nSimPho_[2];
00161   MonitorElement* h_SimPhoMotherType_[2];
00162   MonitorElement* h_SimPhoMotherEt_[2];
00163   MonitorElement* h_SimPhoMotherEta_[2];
00164   MonitorElement* h_SimPhoEtaSmallR9_;
00165   //
00166   MonitorElement* h_nSimConv_[2];
00167   MonitorElement* h_SimConvEtaPix_[2];
00168   //
00169   MonitorElement* h_simTkPt_;
00170   MonitorElement* h_simTkEta_;
00171 
00172   MonitorElement* h_simConvVtxRvsZ_[4];
00173   MonitorElement* h_simConvVtxYvsX_;
00174 
00175 
00177   MonitorElement*   h_SimPho_[3];
00178   MonitorElement*   h_AllSimConv_[5];
00179   MonitorElement*   h_VisSimConv_[6];
00180   MonitorElement*   h_VisSimConvLarge_;
00182   MonitorElement*   h_MatchedSimPho_[3];
00183   MonitorElement*   h_MatchedSimPhoBadCh_[3];
00184   MonitorElement*   h_SimConvOneTracks_[5];
00185   MonitorElement*   h_SimConvOneMTracks_[5];
00186   MonitorElement*   h_SimConvTwoTracks_[5];
00187   MonitorElement*   h_SimConvTwoMTracks_[5];
00188   MonitorElement*   h_SimConvTwoMTracksAndVtxPGT0_[5];
00189   MonitorElement*   h_SimConvTwoMTracksAndVtxPGT0005_[5];
00190   MonitorElement*   h_SimConvTwoMTracksAndVtxPGT01_[5];
00191   // Denominators for conversion fake rate
00192   MonitorElement*   h_RecoConvTwoTracks_[5];
00193   // Numerators for conversion fake rate
00194   MonitorElement*   h_RecoConvTwoMTracks_[5];
00195 
00196 
00198   MonitorElement* h_OIinnermostHitR_;
00199   MonitorElement* h_IOinnermostHitR_;
00200   MonitorElement* h_trkProv_[2];
00201 
00202 
00203   MonitorElement* h_phoDEta_[2];
00204   MonitorElement* h_phoDPhi_[2];
00205 
00206 
00207 
00208   MonitorElement* h_scEta_[2];
00209   MonitorElement* h_scEtaWidth_[2];
00210   MonitorElement* h_scPhi_[2];
00211   MonitorElement* h_scPhiWidth_[2];
00212   MonitorElement* h_scEtaPhi_[2];
00213 
00214  
00215   MonitorElement* h_scE_[2][3];
00216   MonitorElement* h_scEt_[2][3];
00217 
00218   MonitorElement* h_psE_;
00219 
00220   MonitorElement* h_EtR9Less093_[3][3];  
00221   MonitorElement* h_r9_[3][3];  
00222   MonitorElement* h2_r9VsEta_[3];
00223   MonitorElement* p_r9VsEta_[3];
00224   MonitorElement* h2_r9VsEt_[3];
00225   MonitorElement* p_r9VsEt_[3];
00226   //
00227   MonitorElement* h_r1_[3][3];  
00228   MonitorElement* h2_r1VsEta_[3];
00229   MonitorElement* p_r1VsEta_[3];
00230   MonitorElement* h2_r1VsEt_[3];
00231   MonitorElement* p_r1VsEt_[3];
00232   //  
00233   MonitorElement* h_r2_[3][3];  
00234   MonitorElement* h2_r2VsEta_[3];
00235   MonitorElement* p_r2VsEta_[3];
00236   MonitorElement* h2_r2VsEt_[3];
00237   MonitorElement* p_r2VsEt_[3];
00238   //
00239   MonitorElement* h_sigmaIetaIeta_[3][3];  
00240   MonitorElement* h2_sigmaIetaIetaVsEta_[3];
00241   MonitorElement* p_sigmaIetaIetaVsEta_[3];
00242   MonitorElement* h2_sigmaIetaIetaVsEt_[3];
00243   MonitorElement* p_sigmaIetaIetaVsEt_[3];
00244   //
00245   MonitorElement* h_hOverE_[3][3];  
00246   MonitorElement* h2_hOverEVsEta_[3];
00247   MonitorElement* p_hOverEVsEta_[3];
00248   MonitorElement* h2_hOverEVsEt_[3];
00249   MonitorElement* p_hOverEVsEt_[3];
00250 
00251 
00252 
00253   //
00254   MonitorElement* h_ecalRecHitSumEtConeDR04_[3][3];  
00255   MonitorElement* h2_ecalRecHitSumEtConeDR04VsEta_[3];
00256   MonitorElement* p_ecalRecHitSumEtConeDR04VsEta_[3];
00257   MonitorElement* h2_ecalRecHitSumEtConeDR04VsEt_[3];
00258   MonitorElement* p_ecalRecHitSumEtConeDR04VsEt_[3];
00259   //
00260   MonitorElement* h_hcalTowerSumEtConeDR04_[3][3];  
00261   MonitorElement* h2_hcalTowerSumEtConeDR04VsEta_[3];
00262   MonitorElement* p_hcalTowerSumEtConeDR04VsEta_[3];
00263   MonitorElement* h2_hcalTowerSumEtConeDR04VsEt_[3];
00264   MonitorElement* p_hcalTowerSumEtConeDR04VsEt_[3];
00265   //
00266   MonitorElement* h_isoTrkSolidConeDR04_[3][3];  
00267   MonitorElement* h2_isoTrkSolidConeDR04VsEta_[3];
00268   MonitorElement* p_isoTrkSolidConeDR04VsEta_[3];
00269   MonitorElement* h2_isoTrkSolidConeDR04VsEt_[3];
00270   MonitorElement* p_isoTrkSolidConeDR04VsEt_[3];
00271   //
00272   MonitorElement* h_nTrkSolidConeDR04_[3][3];  
00273   MonitorElement* h2_nTrkSolidConeDR04VsEta_[3];
00274   MonitorElement* p_nTrkSolidConeDR04VsEta_[3];
00275   MonitorElement* h2_nTrkSolidConeDR04VsEt_[3];
00276   MonitorElement* p_nTrkSolidConeDR04VsEt_[3];
00277   //
00278 
00279   MonitorElement*  h_gamgamMass_[3][3];
00280 
00281   MonitorElement* h_phoE_[2][3];
00282   MonitorElement* h_phoEt_[2][3];
00283   MonitorElement* h_phoERes_[3][3];
00284 
00285   MonitorElement* h2_eResVsEta_[3];
00286   MonitorElement* p_eResVsEta_[3];
00287   MonitorElement* h2_eResVsEt_[3][3];
00288   MonitorElement* p_eResVsEt_[3][3];
00289 
00290   MonitorElement* h2_eResVsR9_[3];
00291   MonitorElement* p_eResVsR9_[3];
00292   MonitorElement* h2_sceResVsR9_[3];
00293   MonitorElement* p_sceResVsR9_[3];
00294 
00295 
00296   MonitorElement* h_phoEta_[2];
00297   MonitorElement* h_phoPhi_[2];
00298 
00299 
00300 
00302   MonitorElement* h_nConv_[2][3];
00303   MonitorElement* h_convEta_[3];
00304   MonitorElement* h_convPhi_[2];
00305   MonitorElement* h_convERes_[2][3];
00306   MonitorElement*  p_eResVsR_;
00307 
00308   MonitorElement* h_convPtRes_[2][3];
00309 
00310   MonitorElement* h_invMass_[2][3];
00311   MonitorElement* h_r9VsNofTracks_[2][3];
00312   MonitorElement* h_EoverPTracks_[2][3];
00313   MonitorElement* h_PoverETracks_[2][3];
00314 
00315   MonitorElement* h_mvaOut_[3];
00316   MonitorElement* h2_etaVsRsim_[3];
00317   MonitorElement* h2_etaVsRreco_[3];
00318 
00319   MonitorElement* h2_EoverEtrueVsEoverP_[3];
00320   MonitorElement* h2_PoverPtrueVsEoverP_[3];
00321 
00322   MonitorElement* h2_EoverPVsEta_[3];
00323   MonitorElement* p_EoverPVsEta_[3];
00324   MonitorElement* h2_EoverPVsR_[3];
00325   MonitorElement* p_EoverPVsR_[3];
00326 
00327   MonitorElement* h2_EoverEtrueVsEta_[3];
00328   MonitorElement* p_EoverEtrueVsEta_[3];
00329   MonitorElement* h2_EoverEtrueVsR_[3];
00330   MonitorElement* p_EoverEtrueVsR_[3];
00331 
00332 
00333   MonitorElement* h2_PoverPtrueVsEta_[3];
00334   MonitorElement* p_PoverPtrueVsEta_[3];
00335 
00336   MonitorElement* h_DPhiTracksAtVtx_[2][3];
00337   MonitorElement* h2_DPhiTracksAtVtxVsEta_;
00338   MonitorElement* p_DPhiTracksAtVtxVsEta_;
00339   MonitorElement* h2_DPhiTracksAtVtxVsR_;
00340   MonitorElement* p_DPhiTracksAtVtxVsR_;
00341 
00342   MonitorElement* h_DCotTracks_[2][3];
00343   MonitorElement* h2_DCotTracksVsEta_;
00344   MonitorElement* p_DCotTracksVsEta_;
00345   MonitorElement* h2_DCotTracksVsR_;
00346   MonitorElement* p_DCotTracksVsR_;
00347 
00348   MonitorElement* h_distMinAppTracks_[2][3];
00349 
00350 
00351 
00352   MonitorElement* h_DPhiTracksAtEcal_[2][3];
00353   MonitorElement* h2_DPhiTracksAtEcalVsR_;
00354   MonitorElement* p_DPhiTracksAtEcalVsR_;
00355   MonitorElement* h2_DPhiTracksAtEcalVsEta_;
00356   MonitorElement* p_DPhiTracksAtEcalVsEta_;
00357 
00358 
00359   MonitorElement* h_DEtaTracksAtEcal_[2][3];
00360 
00361   
00362 
00363   MonitorElement* h_convVtxRvsZ_[3];
00364   MonitorElement* h_convVtxYvsX_;
00365   MonitorElement* h_convVtxRvsZ_zoom_[2];
00366   MonitorElement* h_convVtxYvsX_zoom_[2];
00367 
00368   MonitorElement* h_convVtxdX_;
00369   MonitorElement* h_convVtxdY_;
00370   MonitorElement* h_convVtxdZ_;
00371   MonitorElement* h_convVtxdR_;
00372 
00373   MonitorElement* h_convVtxdX_barrel_;
00374   MonitorElement* h_convVtxdY_barrel_;
00375   MonitorElement* h_convVtxdZ_barrel_;
00376   MonitorElement* h_convVtxdR_barrel_;
00377 
00378   MonitorElement* h_convVtxdX_endcap_;
00379   MonitorElement* h_convVtxdY_endcap_;
00380   MonitorElement* h_convVtxdZ_endcap_;
00381   MonitorElement* h_convVtxdR_endcap_;
00382 
00383   MonitorElement* h_convVtxdEta_;
00384   MonitorElement* h_convVtxdPhi_;
00385 
00386 
00387   MonitorElement* h2_convVtxdRVsR_;
00388   MonitorElement* p_convVtxdRVsR_;
00389   MonitorElement* h2_convVtxdRVsEta_;
00390   MonitorElement* p_convVtxdRVsEta_;
00391   MonitorElement* p_convVtxdXVsX_;
00392   MonitorElement* p_convVtxdYVsY_;
00393   MonitorElement* p_convVtxdZVsZ_;
00394 
00395   MonitorElement* h2_convVtxRrecVsTrue_;
00396 
00397   MonitorElement*  h_vtxChi2_[3];
00398   MonitorElement*  h_vtxChi2Prob_[3];
00399 
00400 
00401 
00402   MonitorElement* h_zPVFromTracks_[5]; 
00403   MonitorElement* h_dzPVFromTracks_[5]; 
00404   MonitorElement* h2_dzPVVsR_;
00405   MonitorElement* p_dzPVVsR_;
00406   MonitorElement* p_dzPVVsEta_;
00407 
00408 
00410   MonitorElement* p_nHitsVsEta_[2]; 
00411   MonitorElement* nHitsVsEta_[2]; 
00412   MonitorElement* p_nHitsVsR_[2]; 
00413   MonitorElement* nHitsVsR_[2]; 
00414   MonitorElement* h_tkChi2_[2];
00415   MonitorElement* h_tkChi2Large_[2];
00416   MonitorElement* h2_Chi2VsEta_[3];
00417   MonitorElement* p_Chi2VsEta_[3];
00418   MonitorElement* h2_Chi2VsR_[3];
00419   MonitorElement* p_Chi2VsR_[3];
00420 
00421   MonitorElement* h_TkD0_[3];
00422 
00423   MonitorElement* h_TkPtPull_[3];
00424   MonitorElement* h2_TkPtPull_[3];
00425   MonitorElement* p_TkPtPull_[3];
00426   MonitorElement* h2_PtRecVsPtSim_[3];
00427   MonitorElement* h2_PtRecVsPtSimMixProv_;
00428 
00429   MonitorElement* hBCEnergyOverTrackPout_[3];
00430 
00431   // ME for bkg efficiencies
00432   MonitorElement*   h_SimJet_[3];
00433   MonitorElement*   h_MatchedSimJet_[3];
00434   MonitorElement*   h_MatchedSimJetBadCh_[3];
00435   //
00436 
00437   MonitorElement*   h_nPho_;
00438 
00439   MonitorElement* h_scBkgEta_;
00440   MonitorElement* h_scBkgPhi_;
00441   MonitorElement* h_phoBkgEta_;
00442   MonitorElement* h_phoBkgPhi_;
00443   MonitorElement* h_phoBkgDEta_;
00444   MonitorElement* h_phoBkgDPhi_;
00445   MonitorElement* h_phoBkgE_[3];
00446   MonitorElement* h_phoBkgEt_[3];
00447   
00448 
00449   MonitorElement* h_scBkgE_[3];
00450   MonitorElement* h_scBkgEt_[3];
00451 
00452   MonitorElement* h_r9Bkg_[3];
00453   MonitorElement* h_r1Bkg_[3];
00454   MonitorElement* h_r2Bkg_[3];
00455   MonitorElement* h_hOverEBkg_[3];
00456 
00457   MonitorElement* h2_r9VsEtaBkg_;
00458   MonitorElement* h2_r9VsEtBkg_;
00459 
00460   MonitorElement* h2_r1VsEtaBkg_;
00461   MonitorElement* h2_r1VsEtBkg_;
00462   MonitorElement* p_r1VsEtaBkg_;
00463   MonitorElement* p_r1VsEtBkg_;
00464 
00465   MonitorElement* h2_r2VsEtaBkg_;
00466   MonitorElement* h2_r2VsEtBkg_;
00467   MonitorElement* p_r2VsEtaBkg_;
00468   MonitorElement* p_r2VsEtBkg_;
00469 
00470   MonitorElement* h_sigmaIetaIetaBkg_[3];  
00471   MonitorElement* h2_sigmaIetaIetaVsEtaBkg_;
00472   MonitorElement* p_sigmaIetaIetaVsEtaBkg_;
00473   MonitorElement* h2_sigmaIetaIetaVsEtBkg_[3];
00474   MonitorElement* p_sigmaIetaIetaVsEtBkg_[3];
00475 
00476 
00477   MonitorElement* h2_hOverEVsEtaBkg_;
00478   MonitorElement* h2_hOverEVsEtBkg_;
00479   MonitorElement* p_hOverEVsEtaBkg_;
00480   MonitorElement* p_hOverEVsEtBkg_;
00481 
00482 
00483   MonitorElement* h_ecalRecHitSumEtConeDR04Bkg_[3];
00484   MonitorElement* h2_ecalRecHitSumEtConeDR04VsEtaBkg_;
00485   MonitorElement* p_ecalRecHitSumEtConeDR04VsEtaBkg_;
00486   MonitorElement* h2_ecalRecHitSumEtConeDR04VsEtBkg_[3];
00487   MonitorElement* p_ecalRecHitSumEtConeDR04VsEtBkg_[3];
00488 
00489 
00490   MonitorElement* h_hcalTowerSumEtConeDR04Bkg_[3];
00491   MonitorElement* h2_hcalTowerSumEtConeDR04VsEtaBkg_;
00492   MonitorElement* p_hcalTowerSumEtConeDR04VsEtaBkg_;
00493   MonitorElement* h2_hcalTowerSumEtConeDR04VsEtBkg_[3];
00494   MonitorElement* p_hcalTowerSumEtConeDR04VsEtBkg_[3];
00495 
00496   MonitorElement* h_isoTrkSolidConeDR04Bkg_[3];  
00497   MonitorElement* h2_isoTrkSolidConeDR04VsEtaBkg_;
00498   MonitorElement* p_isoTrkSolidConeDR04VsEtaBkg_;
00499   MonitorElement* h2_isoTrkSolidConeDR04VsEtBkg_[3];
00500   MonitorElement* p_isoTrkSolidConeDR04VsEtBkg_[3];
00501   //
00502   MonitorElement* h_nTrkSolidConeDR04Bkg_[3];  
00503   MonitorElement* h2_nTrkSolidConeDR04VsEtaBkg_;
00504   MonitorElement* p_nTrkSolidConeDR04VsEtaBkg_;
00505   MonitorElement* h2_nTrkSolidConeDR04VsEtBkg_[3];
00506   MonitorElement* p_nTrkSolidConeDR04VsEtBkg_[3];
00507   //
00508   MonitorElement* h_convEtaBkg_;
00509   MonitorElement* h_convPhiBkg_;
00510   MonitorElement* h_mvaOutBkg_[3];
00511   MonitorElement* nHitsVsEtaBkg_;
00512   MonitorElement* h_tkChi2Bkg_;
00513   MonitorElement* h_EoverPTracksBkg_[3];
00514   MonitorElement* h_PoverETracksBkg_[3];
00515   MonitorElement* h_DPhiTracksAtVtxBkg_[3];
00516   MonitorElement* h_DCotTracksBkg_[3];
00517   MonitorElement* h_convVtxYvsXBkg_; 
00518   MonitorElement* h_convVtxRvsZBkg_[2];
00519 
00520 
00521 
00522 class  sortPhotons
00523 {
00524   public:
00525     bool operator () (const reco::Photon & lhs, const reco::Photon & rhs) 
00526     {
00527         return lhs.et() > rhs.et();
00528     }
00529 };
00530 
00531 
00532 
00533 };
00534 
00535 
00536 
00537 
00538 
00539 
00540 
00541 #endif