34 #include <TGraphAsymmErrors.h> 55 const TProfile* histoPlusErr,
56 const TProfile* histoMinusErr,
58 const TString& yLabel);
64 const std::vector<double>& parval,
65 const double& sigmaPt1,
66 const double& sigmaPt2);
70 const double& sigmaPt1,
71 const double& sigmaPt2);
124 : treeFileName_(iConfig.getParameter<
std::
string>(
"InputFileName")),
125 resolFitType_(iConfig.getParameter<
int>(
"ResolFitType")),
126 maxEvents_(iConfig.getParameter<
int>(
"MaxEvents")),
127 outputFileName_(iConfig.getParameter<
std::
string>(
"OutputFileName")),
128 ptBins_(iConfig.getParameter<
int>(
"PtBins")),
129 ptMin_(iConfig.getParameter<double>(
"PtMin")),
130 ptMax_(iConfig.getParameter<double>(
"PtMax")),
131 etaBins_(iConfig.getParameter<
int>(
"EtaBins")),
132 etaMin_(iConfig.getParameter<double>(
"EtaMin")),
133 etaMax_(iConfig.getParameter<double>(
"EtaMax")),
134 debug_(iConfig.getParameter<
bool>(
"Debug")),
135 ptMinCut_(iConfig.getUntrackedParameter<double>(
"PtMinCut", 0.)),
136 ptMaxCut_(iConfig.getUntrackedParameter<double>(
"PtMaxCut", 999999.)),
137 etaMinCut_(iConfig.getUntrackedParameter<double>(
"EtaMinCut", 0.)),
138 etaMaxCut_(iConfig.getUntrackedParameter<double>(
"EtaMaxCut", 100.)) {
144 std::cout <<
"Error: parameters and errors have different number of values" << std::endl;
162 new TProfile(
"sigmaMassVsPtMinusErrProfile",
"sigmaMassVsPtMinusErr",
ptBins_,
ptMin_,
ptMax_);
171 new TProfile(
"sigmaMassOverMassVsPtProfile",
"sigmaMassOverMassVsPt",
ptBins_,
ptMin_,
ptMax_);
173 new TProfile(
"sigmaMassOverMassVsPtPlusErrProfile",
"sigmaMassOverMassVsPtPlusErr",
ptBins_,
ptMin_,
ptMax_);
175 new TProfile(
"sigmaMassOverMassVsPtMinusErrProfile",
"sigmaMassOverMassVsPtMinusErr",
ptBins_,
ptMin_,
ptMax_);
180 new TProfile(
"sigmaMassOverMassVsEtaPlusErrProfile",
"sigmaMassOverMassVsEtaPlusErr",
etaBins_,
etaMin_,
etaMax_);
192 std::vector<double>::const_iterator parIt =
parameters_.begin();
193 std::vector<double>::const_iterator errIt =
errors_.begin();
194 std::vector<int>::const_iterator errFactorIt =
errorFactors_.begin();
196 for (; parIt !=
parameters_.end(); ++parIt, ++errIt, ++errFactorIt, ++
i) {
203 gROOT->SetStyle(
"Plain");
218 "sigmaMassOverMassVsEta",
223 "sigmaMassOverMassVsPt",
234 const TProfile* histoPlusErr,
235 const TProfile* histoMinusErr,
237 const TString& yLabel) {
238 TH1D* sigmaPtVsEtaTH1D =
240 TH1D* sigmaPtVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
243 histo->GetXaxis()->GetXmin(),
244 histo->GetXaxis()->GetXmax());
245 TH1D* sigmaPtVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
248 histo->GetXaxis()->GetXmin(),
249 histo->GetXaxis()->GetXmax());
251 TH1D* sigmaMassVsEtaTH1D =
253 TH1D* sigmaMassVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
256 histo->GetXaxis()->GetXmin(),
257 histo->GetXaxis()->GetXmax());
258 TH1D* sigmaMassVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
261 histo->GetXaxis()->GetXmin(),
262 histo->GetXaxis()->GetXmax());
264 TH1D* sigmaMassOverMassVsEtaTH1D =
266 TH1D* sigmaMassOverMassVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
269 histo->GetXaxis()->GetXmin(),
270 histo->GetXaxis()->GetXmax());
271 TH1D* sigmaMassOverMassVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
274 histo->GetXaxis()->GetXmin(),
275 histo->GetXaxis()->GetXmax());
277 TCanvas*
canvas =
new TCanvas(
"canvas" +
type,
"canvas" +
type, 1000, 800);
278 for (
int iBin = 1; iBin <=
histo->GetNbinsX(); ++iBin) {
279 sigmaPtVsEtaTH1D->SetBinContent(iBin,
histo->GetBinContent(iBin));
280 sigmaPtVsEtaPlusErrTH1D->SetBinContent(iBin, histoPlusErr->GetBinContent(iBin));
281 sigmaPtVsEtaMinusErrTH1D->SetBinContent(iBin, histoMinusErr->GetBinContent(iBin));
283 int numBins = sigmaPtVsEtaTH1D->GetNbinsX();
285 Double_t*
values = sigmaPtVsEtaTH1D->GetArray();
286 Double_t* valuesPlus = sigmaPtVsEtaPlusErrTH1D->GetArray();
287 Double_t* valuesMinus = sigmaPtVsEtaMinusErrTH1D->GetArray();
288 double* posErrors =
new double[numBins];
289 double* negErrors =
new double[numBins];
291 TGraphAsymmErrors* graphAsymmErrors =
new TGraphAsymmErrors(sigmaPtVsEtaTH1D);
292 TGraph* graph =
new TGraph(sigmaPtVsEtaTH1D);
294 for (
int i = 1;
i <= numBins; ++
i) {
296 posErrors[
i - 1] = valuesPlus[
i] -
values[
i];
297 if (valuesMinus[
i] < 0)
300 negErrors[
i - 1] =
values[
i] - valuesMinus[
i];
302 graphAsymmErrors->SetPointEYlow(
i - 1, negErrors[
i - 1]);
303 graphAsymmErrors->SetPointEYhigh(
i - 1, posErrors[
i - 1]);
311 graphAsymmErrors->SetTitle(
"");
312 graphAsymmErrors->SetFillColor(kGray);
313 graphAsymmErrors->Draw(
"A2");
317 graphAsymmErrors->GetXaxis()->SetTitle(
title);
318 graphAsymmErrors->GetYaxis()->SetTitle(
"yLabel");
339 sigmaPtVsEtaPlusErrTH1D->Write();
340 sigmaPtVsEtaTH1D->Write();
341 sigmaPtVsEtaMinusErrTH1D->Write();
348 sigmaMassVsEtaPlusErrTH1D->Write();
349 sigmaMassVsEtaTH1D->Write();
350 sigmaMassVsEtaMinusErrTH1D->Write();
352 sigmaMassOverMassVsEtaPlusErrTH1D->Write();
353 sigmaMassOverMassVsEtaTH1D->Write();
354 sigmaMassOverMassVsEtaMinusErrTH1D->Write();
372 const std::vector<double>& parval,
373 const double& sigmaPt1,
374 const double& sigmaPt2) {
375 double*
p =
new double[(
int)(parval.size())];
376 std::vector<double>::const_iterator
it = parval.begin();
378 for (;
it != parval.end(); ++
it, ++
id) {
389 const double& sigmaPt1,
390 const double& sigmaPt2) {
392 double pt1 = mu1.Pt();
393 double phi1 = mu1.Phi();
394 double eta1 = mu1.Eta();
395 double theta1 = 2 * atan(
exp(-
eta1));
396 double pt2 = mu2.Pt();
397 double phi2 = mu2.Phi();
398 double eta2 = mu2.Eta();
399 double theta2 = 2 * atan(
exp(-
eta2));
415 double dmdcotgth1 = (
pt1 *
pt1 *
cos(theta1) /
sin(theta1) *
420 double dmdcotgth2 = (
pt2 *
pt2 *
cos(theta2) /
sin(theta2) *
430 double sigma_pt1 = sigmaPt1;
431 double sigma_pt2 = sigmaPt2;
442 std::pow(dmdcotgth1 * sigma_cotgth1, 2) +
std::pow(dmdcotgth2 * sigma_cotgth2, 2) +
443 2 * dmdpt1 * dmdpt2 * cov_pt1pt2);
452 typedef std::vector<std::pair<lorentzVector, lorentzVector> >
MuonPairVector;
454 std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
469 MuonPairVector::iterator
it = savedPair.begin();
470 std::cout <<
"Starting loop on " << savedPair.size() <<
" muons" << std::endl;
471 for (;
it != savedPair.end(); ++
it, ++
i) {
472 double pt1 =
it->first.pt();
473 double eta1 =
it->first.eta();
474 double pt2 =
it->second.pt();
475 double eta2 =
it->second.eta();
511 std::cout <<
"sigmaPt1 = " << sigmaPt1 <<
" + " << sigmaPtPlusErr1 <<
" - " << sigmaPtMinusErr1 << std::endl;
512 std::cout <<
"sigmaPt2 = " << sigmaPt2 <<
" + " << sigmaPtPlusErr2 <<
" - " << sigmaPtMinusErr2 << std::endl;
513 std::cout <<
"sigmaMass = " << sigmaMass <<
" + " << sigmaMassPlusErr <<
" - " << sigmaMassMinusErr << std::endl;
525 if (sigmaPt1 != sigmaPt1)
527 if (sigmaPt2 != sigmaPt2)
529 if (sigmaPtPlusErr1 != sigmaPtPlusErr1)
531 if (sigmaPtPlusErr2 != sigmaPtPlusErr2)
533 if (sigmaPtMinusErr1 != sigmaPtMinusErr1)
535 if (sigmaPtMinusErr2 != sigmaPtMinusErr2)
537 if (sigmaMass != sigmaMass)
539 if (sigmaMassPlusErr != sigmaMassPlusErr)
541 if (sigmaMassMinusErr != sigmaMassMinusErr)
546 std::cout <<
"Muon pair number " <<
i << std::endl;
TProfile * sigmaPtVsEtaPlusErr_
TProfile * sigmaMassOverMassVsEta_
T getParameter(std::string const &) const
Returns ( sigmaPt/Pt(data)^2 - sigmaPt/Pt(MC)^2 )
~ErrorsPropagationAnalyzer() override
TProfile * sigmaMassOverMassVsPtPlusErr_
std::vector< double > valueMinusError_
static bool debugMassResol_
Sin< T >::type sin(const T &t)
TProfile * sigmaMassVsEtaMinusErr_
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 * sigmaMassOverMassVsEtaMinusErr_
std::vector< double > valuePlusError_
reco::Particle::LorentzVector lorentzVector
TProfile * sigmaMassVsPtPlusErr_
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
TProfile * sigmaMassVsEtaPlusErr_
resolutionFunctionBase< std::vector< double > > * resolutionFunctionVecService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier when receiving a std::...
TProfile * sigmaPtVsEtaMinusErr_
TProfile * sigmaMassOverMassVsPtMinusErr_
std::vector< int > errorFactors_
Cos< T >::type cos(const T &t)
TProfile * sigmaPtVsEtaDiff_
virtual double covPt1Pt2(const double &pt1, const double &eta1, const double &pt2, const double &eta2, const T &parval)
std::vector< double > parameters_
#define DEFINE_FWK_MODULE(type)
TProfile * sigmaPtVsPtMinusErr_
double squaredDiff(const double &eta)
double massResolution(const lorentzVector &mu1, const lorentzVector &mu2, const std::vector< double > &parval, const double &sigmaPt1, const double &sigmaPt2)
Modified method to take into account the error.
virtual double sigmaCotgTh(const double &pt, const double &eta, const T &parval)=0
TProfile * sigmaMassVsEta_
TProfile * sigmaMassOverMassVsPt_
void drawHistograms(const TProfile *histo, const TProfile *histoPlusErr, const TProfile *histoMinusErr, const TString &type, const TString &yLabel)
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
TProfile * sigmaMassOverMassVsEtaPlusErr_
std::vector< double > errors_
ErrorsPropagationAnalyzer(const edm::ParameterSet &)
virtual double sigmaPhi(const double &pt, const double &eta, const T &parval)=0
static std::vector< int > resfind
TProfile * sigmaPtVsPtDiff_
TProfile * sigmaMassVsPtMinusErr_
virtual double sigmaPtError(const double &pt, const double &eta, const T &parval, const T &parError)
void analyze(const edm::Event &, const edm::EventSetup &) override
Power< A, B >::type pow(const A &a, const B &b)
TProfile * sigmaPtVsPtPlusErr_
static resolutionFunctionBase< double * > * resolutionFunction
TProfile * sigmaMassVsPt_