CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQMOffline/JetMET/interface/JPTJetAnalyzer.h

Go to the documentation of this file.
00001 #ifndef JPTJetAnalyzer_H
00002 #define JPTJetAnalyzer_H
00003 
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "DQMOffline/JetMET/interface/JetAnalyzerBase.h"
00015 #include "FWCore/Utilities/interface/InputTag.h"
00016 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 #include "DataFormats/JetReco/interface/JPTJet.h"
00019 #include "DataFormats/JetReco/interface/JPTJetCollection.h"
00020 #include <memory>
00021 // forward declare classes which do not need to be defined for interface
00022 class DQMStore;
00023 namespace reco {
00024   namespace helper {
00025     class JetIDHelper;
00026   }
00027 }
00028 namespace jptJetAnalysis {
00029   class TrackPropagatorToCalo;
00030   class StripSignalOverNoiseCalculator;
00031 }
00032 namespace jpt {
00033   class MatchedTracks;
00034 }
00035 class JetPlusTrackCorrector;
00036 class JetCorrector;
00037 class TrackingRecHit;
00038 class SiStripRecHit2D;
00039 
00040 
00042 class JPTJetAnalyzer : public JetAnalyzerBase {
00043  public:
00045   JPTJetAnalyzer(const edm::ParameterSet& config);
00046   
00048   virtual ~JPTJetAnalyzer();
00049   
00051   void beginJob(DQMStore * dbe);
00052   
00054   void analyze(const edm::Event& event, const edm::EventSetup& eventSetup, const reco::JPTJet& jptJet, double& pt1, double& pt2, double& pt3);
00055   void analyze(const edm::Event& event, const edm::EventSetup& eventSetup, const reco::JPTJetCollection& jptJets);
00056   
00058   virtual void endJob();
00059   
00060  private:
00061    
00062   // Helper classes
00064   struct HistogramConfig {
00065     bool enabled;
00066     unsigned int nBins;
00067     double min;
00068     double max;
00069     unsigned int nBinsY;
00070     double minY;
00071     double maxY;
00072     HistogramConfig();
00073     HistogramConfig(const unsigned int theNBins, const double theMin, const double theMax);
00074     HistogramConfig(const unsigned int theNBinsX, const double theMinX, const double theMaxX,
00075                     const unsigned int theNBinsY, const double theMinY, const double theMaxY);
00076   };
00078   struct TrackHistograms {
00079     MonitorElement* nTracksHisto;
00080     MonitorElement* ptHisto;
00081     MonitorElement* phiHisto;
00082     MonitorElement* etaHisto;
00083     MonitorElement* nHitsHisto;
00084     MonitorElement* nLayersHisto;
00085     MonitorElement* ptVsEtaHisto;
00086     MonitorElement* dzHisto;
00087     MonitorElement* dxyHisto;
00088     MonitorElement* trackDirectionJetDRHisto;
00089     MonitorElement* trackImpactPointJetDRHisto;
00090     TrackHistograms();
00091     TrackHistograms(MonitorElement* theNTracksHisto, MonitorElement* thePtHisto, MonitorElement* thePhiHisto, MonitorElement* theEtaHisto,
00092                     MonitorElement* theNHitsHisto, MonitorElement* theNLayersHisto, MonitorElement* thePtVsEtaHisto,
00093                     MonitorElement* dzHisto, MonitorElement* dxyHisto,
00094                     MonitorElement* theTrackDirectionJetDRHisto, MonitorElement* theTrackImpactPointJetDRHisto);
00095   };
00096   
00097   // Private methods
00099   void getConfigForHistogram(const std::string& configName, const edm::ParameterSet& psetContainingConfigPSet, std::ostringstream* pDebugStream = NULL);
00101   void getConfigForTrackHistograms(const std::string& tag, const edm::ParameterSet& psetContainingConfigPSet,std::ostringstream* pDebugStream = NULL);
00103   MonitorElement* bookHistogram(const std::string& name, const std::string& title, const std::string& xAxisTitle, DQMStore* dqm);
00104   MonitorElement* book2DHistogram(const std::string& name, const std::string& title, const std::string& xAxisTitle, const std::string& yAxisTitle, DQMStore* dqm);
00105   MonitorElement* bookProfile(const std::string& name, const std::string& title, const std::string& xAxisTitle, const std::string& yAxisTitle, DQMStore* dqm);
00107   void bookHistograms(DQMStore* dqm);
00109   void bookTrackHistograms(TrackHistograms* histos, const std::string& tag, const std::string& titleTag,
00110                            MonitorElement* trackDirectionJetDRHisto, MonitorElement* trackImpactPointJetDRHisto, DQMStore* dqm);
00112   void fillHistogram(MonitorElement* histogram, const double value);
00113   void fillHistogram(MonitorElement* histogram, const double valueX, const double valueY);
00115   void fillTrackHistograms(TrackHistograms& allTracksHistos, TrackHistograms& inCaloInVertexHistos,
00116                            TrackHistograms& inCaloOutVertexHistos, TrackHistograms& outCaloInVertexHistos,
00117                            const reco::TrackRefVector& inVertexInCalo,
00118                            const reco::TrackRefVector& outVertexInCalo,
00119                            const reco::TrackRefVector& inVertexOutCalo,
00120                            const reco::Jet& rawJet);
00121   void fillTrackHistograms(TrackHistograms& histos, const reco::TrackRefVector& tracks, const reco::Jet& rawJet);
00123   void fillSiStripSoNForTracks(const reco::TrackRefVector& tracks);
00124   void fillSiStripHitSoN(const TrackingRecHit& hit);
00125   void fillSiStripHitSoNForSingleHit(const SiStripRecHit2D& hit);
00127   static double findPtFractionInCone(const reco::TrackRefVector& inConeTracks, const reco::TrackRefVector& outOfConeTracks);
00128   
00130   static const char* messageLoggerCatregory;
00131   
00132   // Config
00134   const std::string histogramPath_;
00136   const bool verbose_;
00138   std::map<std::string,HistogramConfig> histogramConfig_;
00139   
00141   const bool writeDQMStore_;
00143   std::string dqmStoreFileName_;
00144   
00146   const int n90HitsMin_;
00147   const double fHPDMax_;
00148   const double resEMFMin_;
00149   const double correctedPtMin_;
00150   
00152   std::auto_ptr<jptJetAnalysis::TrackPropagatorToCalo> trackPropagator_;
00154   std::auto_ptr<jptJetAnalysis::StripSignalOverNoiseCalculator> sOverNCalculator_;
00156   std::auto_ptr<reco::helper::JetIDHelper> jetID_;
00157   
00158   // Histograms
00159   MonitorElement *JetE_, *JetEt_, *JetP_, *JetMass_, *JetPt_;
00160   MonitorElement *JetPt1_, *JetPt2_, *JetPt3_;
00161   MonitorElement *JetPx_, *JetPy_, *JetPz_;
00162   MonitorElement *JetEta_, *JetPhi_, *JetDeltaEta_, *JetDeltaPhi_, *JetPhiVsEta_;
00163   MonitorElement *JetN90Hits_, *JetfHPD_, *JetResEMF_, *JetfRBX_;
00164   MonitorElement *TrackSiStripHitStoNHisto_;
00165   MonitorElement *InCaloTrackDirectionJetDRHisto_, *OutCaloTrackDirectionJetDRHisto_;
00166   MonitorElement *InVertexTrackImpactPointJetDRHisto_, *OutVertexTrackImpactPointJetDRHisto_;
00167   MonitorElement *NTracksPerJetHisto_, *NTracksPerJetVsJetEtHisto_, *NTracksPerJetVsJetEtaHisto_;
00168   MonitorElement *PtFractionInConeHisto_, *PtFractionInConeVsJetRawEtHisto_, *PtFractionInConeVsJetEtaHisto_;
00169   MonitorElement *CorrFactorHisto_, *CorrFactorVsJetEtHisto_, *CorrFactorVsJetEtaHisto_;
00170   MonitorElement *ZSPCorrFactorHisto_, *ZSPCorrFactorVsJetEtHisto_, *ZSPCorrFactorVsJetEtaHisto_;
00171   MonitorElement *JPTCorrFactorHisto_, *JPTCorrFactorVsJetEtHisto_, *JPTCorrFactorVsJetEtaHisto_;
00172   TrackHistograms allPionHistograms_, inCaloInVertexPionHistograms_, inCaloOutVertexPionHistograms_, outCaloInVertexPionHistograms_;
00173   TrackHistograms allMuonHistograms_, inCaloInVertexMuonHistograms_, inCaloOutVertexMuonHistograms_, outCaloInVertexMuonHistograms_;
00174   TrackHistograms allElectronHistograms_, inCaloInVertexElectronHistograms_, inCaloOutVertexElectronHistograms_, outCaloInVertexElectronHistograms_;
00175   
00177   DQMStore* dqm_;
00178 };
00179 
00180 inline void JPTJetAnalyzer::fillHistogram(MonitorElement* histogram, const double value)
00181 {
00182   if (histogram) histogram->Fill(value);
00183 }
00184 
00185 inline void JPTJetAnalyzer::fillHistogram(MonitorElement* histogram, const double valueX, const double valueY)
00186 {
00187   if (histogram) histogram->Fill(valueX,valueY);
00188 }
00189 
00190 #endif