CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFMETMonitor.cc
Go to the documentation of this file.
4 
6 
7 #include <TROOT.h>
8 #include <TFile.h>
9 #include <TH1.h>
10 #include <TH2.h>
11 
12 //
13 // -- Constructor
14 //
16  Benchmark(mode),
17  candBench_(mode),
18  matchCandBench_(mode) {
19 
20  setRange( 0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
21 
22  px_ = 0;
23  sumEt_ = 0;
24  delta_ex_ = 0;
25  delta_ex_VS_set_ = 0;
28 
30  histogramBooked_ = false;
31 }
32 //
33 // -- Destructor
34 //
36 
37 //
38 // -- Set Parameters accessing them from ParameterSet
39 //
40 void PFMETMonitor::setParameters( const edm::ParameterSet & parameterSet) {
41 
42  mode_ = (Benchmark::Mode) parameterSet.getParameter<int>( "mode" );
43  createMETSpecificHistos_ = parameterSet.getParameter<bool>( "CreateMETSpecificHistos" );
44  setRange( parameterSet.getParameter<double>("ptMin"),
45  parameterSet.getParameter<double>("ptMax"),
46  parameterSet.getParameter<double>("etaMin"),
47  parameterSet.getParameter<double>("etaMax"),
48  parameterSet.getParameter<double>("phiMin"),
49  parameterSet.getParameter<double>("phiMax") );
50 
51 
54 }
55 //
56 // -- Set Parameters
57 //
59  float etamin, float etamax, float phimin,
60  float phimax, bool metSpHistos) {
61  mode_ = mode;
62  createMETSpecificHistos_ = metSpHistos;
63 
64  setRange( ptmin, ptmax, etamin, etamax, phimin, phimax);
65 
68 }
69 //
70 // -- Create histograms accessing parameters from ParameterSet
71 //
72 void PFMETMonitor::setup(const edm::ParameterSet & parameterSet) {
73  candBench_.setup(parameterSet);
74  matchCandBench_.setup(parameterSet);
75 
77 
78  edm::ParameterSet pxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
79  edm::ParameterSet dpxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
80  edm::ParameterSet dptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtHistoParameter");
81  edm::ParameterSet setPS = parameterSet.getParameter<edm::ParameterSet>("SumEtHistoParameter");
82  edm::ParameterSet dsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtHistoParameter");
83  edm::ParameterSet setOvsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtOvSumEtHistoParameter");
84 
85  if (pxPS.getParameter<bool>("switchOn")) {
86  px_ = book1D("px_", "px_;p_{X} (GeV)",
87  pxPS.getParameter<int32_t>("nBin"),
88  pxPS.getParameter<double>("xMin"),
89  pxPS.getParameter<double>("xMax"));
90  }
91  if (setPS.getParameter<bool>("switchOn")) {
92  sumEt_ = book1D("sumEt_", "sumEt_;#sumE_{T}",
93  setPS.getParameter<int32_t>("nBin"),
94  setPS.getParameter<double>("xMin"),
95  setPS.getParameter<double>("xMax"));
96  }
97  if (dpxPS.getParameter<bool>("switchOn")) {
98  delta_ex_ = book1D("delta_ex_", "#DeltaME_{X}",
99  dpxPS.getParameter<int32_t>("nBin"),
100  dpxPS.getParameter<double>("xMin"),
101  dpxPS.getParameter<double>("xMax"));
102  }
103 
104  if (dpxPS.getParameter<bool>("switchOn")) {
105  delta_ex_VS_set_ = book2D("delta_ex_VS_set_",
106  ";SE_{T, true} (GeV);#DeltaE_{X}",
107  setPS.getParameter<int32_t>("nBin"),
108  setPS.getParameter<double>("xMin"),
109  setPS.getParameter<double>("xMax"),
110  dptPS.getParameter<int32_t>("nBin"),
111  dptPS.getParameter<double>("xMin"),
112  dptPS.getParameter<double>("xMax"));
113  }
114  if (dsetPS.getParameter<bool>("switchOn")) {
115  delta_set_VS_set_ = book2D("delta_set_VS_set_",
116  ";SE_{T, true} (GeV);#DeltaSE_{T}",
117  setPS.getParameter<int32_t>("nBin"),
118  setPS.getParameter<double>("xMin"),
119  setPS.getParameter<double>("xMax"),
120  dsetPS.getParameter<int32_t>("nBin"),
121  dsetPS.getParameter<double>("xMin"),
122  dsetPS.getParameter<double>("xMax"));
123  }
124  if (setOvsetPS.getParameter<bool>("switchOn")) {
125  delta_set_Over_set_VS_set_ = book2D("delta_set_Over_set_VS_set_",
126  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
127  setPS.getParameter<int32_t>("nBin"),
128  setPS.getParameter<double>("xMin"),
129  setPS.getParameter<double>("xMax"),
130  setOvsetPS.getParameter<int32_t>("nBin"),
131  setOvsetPS.getParameter<double>("xMin"),
132  setOvsetPS.getParameter<double>("xMax"));
133  }
134  histogramBooked_ = true;
135  }
136 }
137 //
138 // -- Create histograms using local parameters
139 //
141  candBench_.setup();
143 
145 
146  PhaseSpace pxPS = PhaseSpace( 50, 0, 200);
147  PhaseSpace dpxPS = PhaseSpace( 50, -500, 500);
148  PhaseSpace setPS = PhaseSpace( 50, 0.0, 3000);
149  PhaseSpace dsetPS = PhaseSpace( 50, -1000.0, 1000);
150  PhaseSpace setOvsetPS = PhaseSpace( 100,0., 2.);
151 
152  px_ = book1D("px_", "px_;p_{X} (GeV)", pxPS.n, pxPS.m, pxPS.M);
153 
154  sumEt_ = book1D("sumEt_", "sumEt_;#sumE_{T}", setPS.n, setPS.m, setPS.M);
155 
156  delta_ex_ = book1D("delta_ex_", "#DeltaME_{X}", dpxPS.n, dpxPS.m, dpxPS.M);
157 
158  delta_ex_VS_set_ = book2D("delta_ex_VS_set_", ";SE_{T, true} (GeV);#DeltaE_{X}",
159  setPS.n, setPS.m, setPS.M,
160  dpxPS.n, dpxPS.m, dpxPS.M );
161 
162  delta_set_VS_set_ = book2D("delta_set_VS_set_",
163  ";SE_{T, true} (GeV);#DeltaSE_{T}",
164  setPS.n, setPS.m, setPS.M,
165  dsetPS.n, dsetPS.m, dsetPS.M );
166 
167  delta_set_Over_set_VS_set_ = book2D("delta_set_Over_set_VS_set_",
168  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
169  setPS.n, setPS.m, setPS.M,
170  setOvsetPS.n, setOvsetPS.m, setOvsetPS.M );
171  histogramBooked_ = true;
172  }
173 }
174 
175 void PFMETMonitor::setDirectory(TDirectory* dir) {
177 
180 }
181 
183  const reco::MET& matchedMet, float& minVal, float& maxVal) {
184  candBench_.fillOne(met);
185  matchCandBench_.fillOne(met, matchedMet);
187  if( !isInRange(met.pt(), met.eta(), met.phi() ) ) return;
188 
189  if (px_) px_->Fill(met.px());
190  if (delta_ex_) {
191  delta_ex_->Fill(met.px()-matchedMet.px());
192  delta_ex_->Fill(met.py()-matchedMet.py());
193  }
194  if (sumEt_) sumEt_->Fill( met.sumEt());
195 
196  if (delta_ex_VS_set_) {
197  delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px()-matchedMet.px());
198  delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py()-matchedMet.py());
199  }
200  if (delta_set_VS_set_) delta_set_VS_set_->Fill(matchedMet.sumEt(),met.sumEt()-matchedMet.sumEt());
201  if (delta_set_Over_set_VS_set_ && matchedMet.sumEt()>0.001 ) {
202  float setRes = (met.sumEt() - matchedMet.sumEt())/matchedMet.sumEt();
203  if (setRes > maxVal) maxVal = setRes;
204  if (setRes < minVal) minVal = setRes;
205  delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(),setRes);
206  }
207  }
208 }
TH1F * sumEt_
Definition: PFMETMonitor.h:40
T getParameter(std::string const &) const
void setParameters(Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool metSpHistos)
set the parameters locally
Definition: PFMETMonitor.cc:58
void setDirectory(TDirectory *dir)
set directory (to use in ROOT)
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
TH2F * delta_ex_VS_set_
Definition: PFMETMonitor.h:42
TH2F * delta_set_VS_set_
Definition: PFMETMonitor.h:43
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
void setup()
book histograms
void setup()
book histograms
abstract base class
Definition: Benchmark.h:20
bool histogramBooked_
Definition: PFMETMonitor.h:50
TH1F * delta_ex_
Definition: PFMETMonitor.h:41
virtual void setDirectory(TDirectory *dir)
Definition: Benchmark.cc:19
virtual double eta() const
momentum pseudorapidity
double sumEt() const
Definition: MET.h:48
TH2F * book2D(const char *histname, const char *title, int nbinsx, float xmin, float xmax, int nbinsy, float ymin, float ymax)
book a 2D histogram, either with DQM or plain root.
Definition: Benchmark.cc:43
Definition: MET.h:32
PFMETMonitor(Benchmark::Mode mode=Benchmark::DEFAULT)
Definition: PFMETMonitor.cc:15
void setParameters(Mode mode)
Definition: Benchmark.h:49
CandidateBenchmark candBench_
Definition: PFMETMonitor.h:46
void fillOne(const reco::MET &met, const reco::MET &matchedMet, float &minVal, float &maxVal)
virtual ~PFMETMonitor()
Definition: PFMETMonitor.cc:35
TH2F * delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:44
virtual double px() const
x coordinate of momentum vector
virtual double pt() const
transverse momentum
bool createMETSpecificHistos_
Definition: PFMETMonitor.h:49
void setRange(float ptMin, float ptMax, float etaMin, float etaMax, float phiMin, float phiMax)
Definition: Benchmark.h:51
double ptmin
Definition: HydjetWrapper.h:86
Mode mode_
Definition: Benchmark.h:86
dbl *** dir
Definition: mlp_gen.cc:35
void setup()
book histograms
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:58
MatchCandidateBenchmark matchCandBench_
Definition: PFMETMonitor.h:47
virtual double phi() const
momentum azimuthal angle
virtual double py() const
y coordinate of momentum vector
TH1F * book1D(const char *histname, const char *title, int nbins, float xmin, float xmax)
book a 1D histogram, either with DQM or plain root.
Definition: Benchmark.cc:25