34 #include <TGraphAsymmErrors.h> 54 const TProfile* histoPlusErr,
55 const TProfile* histoMinusErr,
98 : treeFileName_(iConfig.getParameter<
std::
string>(
"InputFileName")),
99 resolFitType_(iConfig.getParameter<
int>(
"ResolFitType")),
100 maxEvents_(iConfig.getParameter<
int>(
"MaxEvents")),
101 outputFileName_(iConfig.getParameter<
std::
string>(
"OutputFileName")),
102 ptBins_(iConfig.getParameter<
int>(
"PtBins")),
103 ptMin_(iConfig.getParameter<double>(
"PtMin")),
104 ptMax_(iConfig.getParameter<double>(
"PtMax")),
105 etaBins_(iConfig.getParameter<
int>(
"EtaBins")),
106 etaMin_(iConfig.getParameter<double>(
"EtaMin")),
107 etaMax_(iConfig.getParameter<double>(
"EtaMax")),
108 debug_(iConfig.getParameter<
bool>(
"Debug")) {
114 std::cout <<
"Error: parameters and errors have different number of values" << std::endl;
132 new TProfile(
"sigmaMassVsPtMinusErrProfile",
"sigmaMassVsPtMinusErr",
ptBins_,
ptMin_,
ptMax_);
145 std::vector<double>::const_iterator parIt =
parameters_.begin();
146 std::vector<double>::const_iterator errIt =
errors_.begin();
147 std::vector<int>::const_iterator errFactorIt =
errorFactors_.begin();
149 for (; parIt !=
parameters_.end(); ++parIt, ++errIt, ++errFactorIt, ++
i) {
156 gROOT->SetStyle(
"Plain");
173 const TProfile* histoPlusErr,
174 const TProfile* histoMinusErr,
175 const TString&
type) {
176 TH1D* sigmaPtVsEtaTH1D =
178 TH1D* sigmaPtVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
181 histo->GetXaxis()->GetXmin(),
182 histo->GetXaxis()->GetXmax());
183 TH1D* sigmaPtVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
186 histo->GetXaxis()->GetXmin(),
187 histo->GetXaxis()->GetXmax());
189 TH1D* sigmaMassVsEtaTH1D =
191 TH1D* sigmaMassVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
194 histo->GetXaxis()->GetXmin(),
195 histo->GetXaxis()->GetXmax());
196 TH1D* sigmaMassVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
199 histo->GetXaxis()->GetXmin(),
200 histo->GetXaxis()->GetXmax());
202 TCanvas*
canvas =
new TCanvas(
"canvas" +
type,
"canvas" +
type, 1000, 800);
203 for (
int iBin = 1; iBin <=
histo->GetNbinsX(); ++iBin) {
204 sigmaPtVsEtaTH1D->SetBinContent(iBin,
histo->GetBinContent(iBin));
205 sigmaPtVsEtaPlusErrTH1D->SetBinContent(iBin, histoPlusErr->GetBinContent(iBin));
206 sigmaPtVsEtaMinusErrTH1D->SetBinContent(iBin, histoMinusErr->GetBinContent(iBin));
208 int numBins = sigmaPtVsEtaTH1D->GetNbinsX();
210 Double_t*
values = sigmaPtVsEtaTH1D->GetArray();
211 Double_t* valuesPlus = sigmaPtVsEtaPlusErrTH1D->GetArray();
212 Double_t* valuesMinus = sigmaPtVsEtaMinusErrTH1D->GetArray();
213 double* posErrors =
new double[numBins];
214 double* negErrors =
new double[numBins];
216 TGraphAsymmErrors* graphAsymmErrors =
new TGraphAsymmErrors(sigmaPtVsEtaTH1D);
217 TGraph* graph =
new TGraph(sigmaPtVsEtaTH1D);
219 for (
int i = 1;
i <= numBins; ++
i) {
221 posErrors[
i - 1] = valuesPlus[
i] -
values[
i];
222 if (valuesMinus[
i] < 0)
225 negErrors[
i - 1] =
values[
i] - valuesMinus[
i];
227 graphAsymmErrors->SetPointEYlow(
i - 1, negErrors[
i - 1]);
228 graphAsymmErrors->SetPointEYhigh(
i - 1, posErrors[
i - 1]);
236 graphAsymmErrors->SetTitle(
"");
237 graphAsymmErrors->SetFillColor(kGray);
238 graphAsymmErrors->Draw(
"A2");
242 graphAsymmErrors->GetXaxis()->SetTitle(
title);
243 graphAsymmErrors->GetYaxis()->SetTitle(
"#sigmaPt/Pt");
264 sigmaPtVsEtaPlusErrTH1D->Write();
265 sigmaPtVsEtaTH1D->Write();
266 sigmaPtVsEtaMinusErrTH1D->Write();
273 sigmaMassVsEtaPlusErrTH1D->Write();
274 sigmaMassVsEtaTH1D->Write();
275 sigmaMassVsEtaMinusErrTH1D->Write();
291 typedef std::vector<std::pair<lorentzVector, lorentzVector> >
MuonPairVector;
293 std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
305 MuonPairVector::iterator it = savedPair.begin();
306 std::cout <<
"Starting loop on " << savedPair.size() <<
" muons" << std::endl;
307 for (; it != savedPair.end(); ++it, ++
i) {
308 double pt1 = it->first.pt();
309 double eta1 = it->first.eta();
310 double pt2 = it->second.pt();
311 double eta2 = it->second.eta();
332 std::cout <<
"sigmaPt1 = " << sigmaPt1 <<
" + " << sigmaPtPlusErr1 <<
" - " << sigmaPtMinusErr1 << std::endl;
333 std::cout <<
"sigmaPt2 = " << sigmaPt2 <<
" + " << sigmaPtPlusErr2 <<
" - " << sigmaPtMinusErr2 << std::endl;
334 std::cout <<
"sigmaMass = " << sigmaMass <<
" + " << sigmaMassPlusErr <<
" - " << sigmaMassMinusErr << std::endl;
346 if (sigmaPt1 != sigmaPt1)
348 if (sigmaPt2 != sigmaPt2)
350 if (sigmaPtPlusErr1 != sigmaPtPlusErr1)
352 if (sigmaPtPlusErr2 != sigmaPtPlusErr2)
354 if (sigmaPtMinusErr1 != sigmaPtMinusErr1)
356 if (sigmaPtMinusErr2 != sigmaPtMinusErr2)
358 if (sigmaMass != sigmaMass)
360 if (sigmaMassPlusErr != sigmaMassPlusErr)
362 if (sigmaMassMinusErr != sigmaMassMinusErr)
365 std::cout <<
"Muon pair number " <<
i << std::endl;
TProfile * sigmaMassVsPtPlusErr_
TProfile * sigmaMassVsEta_
T getParameter(std::string const &) const
~ErrorsAnalyzer() override
std::vector< double > valueMinusError_
std::vector< double > errors_
void drawHistograms(const TProfile *histo, const TProfile *histoPlusErr, const TProfile *histoMinusErr, const TString &type)
TProfile * sigmaPtVsPtMinusErr_
TProfile * sigmaMassVsPtMinusErr_
static bool debugMassResol_
TProfile * sigmaMassVsEtaPlusErr_
void analyze(const edm::Event &, const edm::EventSetup &) override
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< unsigned int, unsigned long long > > *evtRun, MuonPairVector *genPair=nullptr)
TProfile * sigmaPtVsEtaMinusErr_
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
virtual double sigmaPt(const double &pt, const double &eta, const T &parval)=0
resolutionFunctionBase< std::vector< double > > * resolutionFunctionVecService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier when receiving a std::...
static double massResolution(const lorentzVector &mu1, const lorentzVector &mu2)
#define DEFINE_FWK_MODULE(type)
std::vector< int > errorFactors_
std::vector< double > valuePlusError_
TProfile * sigmaPtVsPtPlusErr_
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
TProfile * sigmaMassVsEtaMinusErr_
TProfile * sigmaMassVsPt_
std::vector< double > parameters_
ErrorsAnalyzer(const edm::ParameterSet &)
static std::vector< int > resfind
TProfile * sigmaPtVsEtaPlusErr_
static resolutionFunctionBase< double * > * resolutionFunction