1 #ifndef ERRORSANALYZER_CC 2 #define ERRORSANALYZER_CC 7 treeFileName_( iConfig.getParameter<
std::
string>(
"InputFileName") ),
8 resolFitType_( iConfig.getParameter<
int>(
"ResolFitType") ),
9 maxEvents_( iConfig.getParameter<
int>(
"MaxEvents") ),
10 outputFileName_( iConfig.getParameter<
std::
string>(
"OutputFileName") ),
11 ptBins_( iConfig.getParameter<
int>(
"PtBins") ),
12 ptMin_( iConfig.getParameter<double>(
"PtMin") ),
13 ptMax_( iConfig.getParameter<double>(
"PtMax") ),
14 etaBins_( iConfig.getParameter<
int>(
"EtaBins") ),
15 etaMin_( iConfig.getParameter<double>(
"EtaMin") ),
16 etaMax_( iConfig.getParameter<double>(
"EtaMax") ),
17 debug_( iConfig.getParameter<
bool>(
"Debug") )
24 std::cout <<
"Error: parameters and errors have different number of values" << std::endl;
52 std::vector<double>::const_iterator parIt =
parameters_.begin();
53 std::vector<double>::const_iterator errIt =
errors_.begin();
54 std::vector<int>::const_iterator errFactorIt =
errorFactors_.begin();
56 for( ; parIt !=
parameters_.end(); ++parIt, ++errIt, ++errFactorIt, ++
i ) {
64 gROOT->SetStyle(
"Plain");
81 const TProfile * histoMinusErr,
const TString &
type)
83 TH1D * sigmaPtVsEtaTH1D =
new TH1D(type, type, histo->GetNbinsX(),
84 histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
85 TH1D * sigmaPtVsEtaPlusErrTH1D =
new TH1D(type+
"PlusErr", type+
"PlusErr", histo->GetNbinsX(),
86 histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
87 TH1D * sigmaPtVsEtaMinusErrTH1D =
new TH1D(type+
"MinusErr", type+
"MinusErr", histo->GetNbinsX(),
88 histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
90 TH1D * sigmaMassVsEtaTH1D =
new TH1D(type, type, histo->GetNbinsX(),
91 histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
92 TH1D * sigmaMassVsEtaPlusErrTH1D =
new TH1D(type+
"PlusErr", type+
"PlusErr", histo->GetNbinsX(),
93 histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
94 TH1D * sigmaMassVsEtaMinusErrTH1D =
new TH1D(type+
"MinusErr", type+
"MinusErr", histo->GetNbinsX(),
95 histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
97 TCanvas *
canvas =
new TCanvas(
"canvas"+type,
"canvas"+type, 1000, 800);
98 for(
int iBin = 1; iBin <= histo->GetNbinsX(); ++iBin ) {
99 sigmaPtVsEtaTH1D->SetBinContent(iBin, histo->GetBinContent(iBin));
100 sigmaPtVsEtaPlusErrTH1D->SetBinContent(iBin, histoPlusErr->GetBinContent(iBin));
101 sigmaPtVsEtaMinusErrTH1D->SetBinContent(iBin, histoMinusErr->GetBinContent(iBin));
103 int numBins = sigmaPtVsEtaTH1D->GetNbinsX();
105 Double_t *
values = sigmaPtVsEtaTH1D->GetArray();
106 Double_t * valuesPlus = sigmaPtVsEtaPlusErrTH1D->GetArray();
107 Double_t * valuesMinus = sigmaPtVsEtaMinusErrTH1D->GetArray();
108 double * posErrors =
new double[numBins];
109 double * negErrors =
new double[numBins];
111 TGraphAsymmErrors * graphAsymmErrors =
new TGraphAsymmErrors(sigmaPtVsEtaTH1D);
112 TGraph * graph =
new TGraph(sigmaPtVsEtaTH1D);
114 for(
int i=1;
i<=numBins; ++
i ) {
116 posErrors[
i-1] = valuesPlus[
i] - values[
i];
117 if( valuesMinus[
i] < 0 ) negErrors[
i-1] = values[
i];
118 else negErrors[
i-1] = values[
i] - valuesMinus[
i];
120 graphAsymmErrors->SetPointEYlow(
i-1, negErrors[
i-1]);
121 graphAsymmErrors->SetPointEYhigh(
i-1, posErrors[
i-1]);
129 graphAsymmErrors->SetTitle(
"");
130 graphAsymmErrors->SetFillColor(kGray);
131 graphAsymmErrors->Draw(
"A2");
133 if( type ==
"Eta" ) title =
"#eta";
134 graphAsymmErrors->GetXaxis()->SetTitle(title);
135 graphAsymmErrors->GetYaxis()->SetTitle(
"#sigmaPt/Pt");
156 sigmaPtVsEtaPlusErrTH1D->Write();
157 sigmaPtVsEtaTH1D->Write();
158 sigmaPtVsEtaMinusErrTH1D->Write();
165 sigmaMassVsEtaPlusErrTH1D->Write();
166 sigmaMassVsEtaTH1D->Write();
167 sigmaMassVsEtaMinusErrTH1D->Write();
186 typedef std::vector<std::pair<lorentzVector,lorentzVector> >
MuonPairVector;
187 MuonPairVector savedPair;
188 std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
200 MuonPairVector::iterator it = savedPair.begin();
201 std::cout <<
"Starting loop on " << savedPair.size() <<
" muons" << std::endl;
202 for( ; it != savedPair.end(); ++it, ++
i ) {
203 double pt1 = it->first.pt();
204 double eta1 = it->first.eta();
205 double pt2 = it->second.pt();
206 double eta2 = it->second.eta();
209 std::cout <<
"pt1 = " << pt1 <<
", eta1 = " << eta1 <<
", pt2 = " << pt2 <<
", eta2 = " << eta2 << std::endl;
212 if( pt1 == 0 && pt2 == 0 && eta1 == 0 && eta2 == 0 )
continue;
226 std::cout <<
"sigmaPt1 = " << sigmaPt1 <<
" + " << sigmaPtPlusErr1 <<
" - " << sigmaPtMinusErr1 << std::endl;
227 std::cout <<
"sigmaPt2 = " << sigmaPt2 <<
" + " << sigmaPtPlusErr2 <<
" - " << sigmaPtMinusErr2 << std::endl;
228 std::cout <<
"sigmaMass = " << sigmaMass <<
" + " << sigmaMassPlusErr <<
" - " << sigmaMassMinusErr << std::endl;
232 if( pt1 != pt1 )
continue;
233 if( pt2 != pt2 )
continue;
234 if( eta1 != eta1 )
continue;
235 if( eta2 != eta2 )
continue;
236 if( sigmaPt1 != sigmaPt1 )
continue;
237 if( sigmaPt2 != sigmaPt2 )
continue;
238 if( sigmaPtPlusErr1 != sigmaPtPlusErr1 )
continue;
239 if( sigmaPtPlusErr2 != sigmaPtPlusErr2 )
continue;
240 if( sigmaPtMinusErr1 != sigmaPtMinusErr1 )
continue;
241 if( sigmaPtMinusErr2 != sigmaPtMinusErr2 )
continue;
242 if( sigmaMass != sigmaMass )
continue;
243 if( sigmaMassPlusErr != sigmaMassPlusErr )
continue;
244 if( sigmaMassMinusErr != sigmaMassMinusErr )
continue;
246 std::cout <<
"Muon pair number " << i << std::endl;
T getParameter(std::string const &) const
TProfile * sigmaMassVsPtPlusErr_
TProfile * sigmaMassVsEta_
~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_
#define DEFINE_FWK_MODULE(type)
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_
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)
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
std::vector< int > errorFactors_
std::vector< double > valuePlusError_
TProfile * sigmaPtVsPtPlusErr_
TProfile * sigmaMassVsEtaMinusErr_
TProfile * sigmaMassVsPt_
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
std::vector< double > parameters_
ErrorsAnalyzer(const edm::ParameterSet &)
static std::vector< int > resfind
TProfile * sigmaPtVsEtaPlusErr_
static resolutionFunctionBase< double * > * resolutionFunction