00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #include <iostream>
00085 #include <fstream>
00086 #include <vector>
00087 #include <string>
00088 #include "TString.h"
00089 #include "TROOT.h"
00090 #include "TStyle.h"
00091 #include "TH1F.h"
00092 #include "TFile.h"
00093 #include "TCanvas.h"
00094 #include "TGraph.h"
00095 #include "TLegend.h"
00096
00097 void plotMaker(TString histoName, TString typeOfplot,
00098 vector<TString> file, vector<TString> type,
00099 vector<double> weight, TString xtitle);
00100
00101 void abcd(vector<TString> file, vector<TString> type, vector<double> weight,
00102 double METCut, double I, double dI, double Fz, double dFz,
00103 double FzP, double dFzP, double ewkerror,
00104 double data, double mc, double mcOnly);
00105 double searchABCDstring(TString abcdString, TString keyword);
00106 double Trionym(double a, double b, double c, double sum);
00107 double CalcABCD
00108 (double I, double Fz, double FzP, double K, double ewk,
00109 double Na_, double Nb_, double Nc_, double Nd_,
00110 double Ea_, double Eb_, double Ec_, double Ed_);
00111
00112
00113 const double EWK_SYST_MIN = 0.3;
00114 const double EWK_SYST_MAX = 0.3;
00115
00116 const double I_SYST_MIN = 0.05;
00117 const double I_SYST_MAX = 0.05;
00118
00119 const double FZ_SYST_MIN = 0.1;
00120 const double FZ_SYST_MAX = 0.1;
00121
00122 const double FZP_SYST_MIN = 0.1;
00123 const double FZP_SYST_MAX = 0.1;
00124
00125 const double K_SYST_MIN = 0.8;
00126 const double K_SYST_MAX = 0.8;
00127
00128
00129 using namespace std;
00130
00131 void PlotCombiner()
00132 {
00133
00134 ifstream input("inputFiles");
00135 int i = 0;
00136 TString typeOfplot = "";
00137 vector<TString> types;
00138 vector<TString> files;
00139 vector<double> weights;
00140
00141 if (input.is_open()) {
00142 std::string myline;
00143 while (! input.eof()) {
00144 getline(input, myline);
00145 TString line(myline);
00146 TString c('#');
00147 TString empty(' ');
00148 if (line[0] != c) {
00149 ++i;
00150 if (i==1) typeOfplot=line;
00151 else {
00152
00153 TString fname("");
00154 TString ftype("");
00155 TString fw("");
00156 int lineSize = (int) line.Length();
00157 int j=0;
00158 while (j<lineSize) {
00159 if(line[j] != empty) fname += line[j];
00160 else break;
00161 ++j;
00162 }
00163 while (j<lineSize) {
00164 if(line[j] != empty) ftype += line[j];
00165 else if(ftype.Length()==3) break;
00166 ++j;
00167 }
00168 while (j<lineSize) {
00169 if(line[j] != empty) fw += line[j];
00170 else{ if(fw.Length()>0) break;}
00171 ++j;
00172 }
00173 if (fname.Length() == 0) break;
00174 files.push_back(fname);
00175 types.push_back(ftype);
00176 double w = fw.Atof();
00177 weights.push_back(w);
00178 if (w>0)
00179 std::cout << fname << ", " << ftype << ", "<< w << std::endl;
00180 }
00181 }
00182 }
00183 input.close();
00184 }
00185 else {
00186 std::cout << "File with name inputFile was not found" << std::endl;
00187 return;
00188 }
00189
00190
00191 if (typeOfplot == "wenu") {
00192 cout << "wenu plot maker" << endl;
00193
00194
00195
00196 plotMaker("h_met", typeOfplot, files, types, weights, "MET (GeV)");
00197 }
00198 else if (typeOfplot == "zee"){
00199 cout << "zee plot maker" << endl;
00200
00201
00202
00203 plotMaker("h_mee", typeOfplot, files, types, weights, "M_{ee} (GeV)");
00204 }
00205 else if (typeOfplot(0,4) == "abcd") {
00206
00207
00208 double I = searchABCDstring(typeOfplot, "I");
00209 double dI= searchABCDstring(typeOfplot, "dI");
00210
00211 double Fz = searchABCDstring(typeOfplot, "Fz");
00212 double dFz= searchABCDstring(typeOfplot, "dFz");
00213
00214 double FzP = searchABCDstring(typeOfplot, "FzP");
00215 double dFzP= searchABCDstring(typeOfplot, "dFzP");
00216
00217 double METCut =searchABCDstring(typeOfplot, "METCut");
00218
00219 double data = searchABCDstring(typeOfplot, "data");
00220 double mc = searchABCDstring(typeOfplot, "mc");
00221 double mcOnly = searchABCDstring(typeOfplot, "mcOnly");
00222
00223 double ewkerror = searchABCDstring(typeOfplot, "ewkerror");
00224
00225 if (METCut<0 || (data<-0.7 && mc<-0.7 && mcOnly<-0.7)) {
00226 cout << "Error in your configurtion!" << endl;
00227 if (METCut <0) cout << "Error in MET Cut" << endl;
00228 else cout << "You need to specify one mc or data or mcOnly"
00229 << endl;
00230 abort();
00231 }
00232 if (mc>-0.7 && mc <0 && ewkerror<0) {
00233 cout << "You have specified mc option, but you have forgotten"
00234 << " to set the ewkerror!" << endl;
00235 abort();
00236 }
00237
00238
00239
00240 cout << "doing ABCD with input: " << typeOfplot << endl;
00241 abcd(files, types, weights, METCut, I, dI, Fz, dFz, FzP, dFzP,
00242 ewkerror, data, mc, mcOnly);
00243
00244 }
00245
00246
00247 abort();
00248
00249 }
00250
00251 void abcd( vector<TString> file, vector<TString> type, vector<double> weight,
00252 double METCut, double I, double dI, double Fz, double dFz,
00253 double FzP, double dFzP, double ewkerror,
00254 double data, double mc, double mcOnly)
00255 {
00256 gROOT->Reset();
00257 gROOT->ProcessLine(".L tdrstyle.C");
00258 gROOT->ProcessLine("setTDRStyle()");
00259
00260 std::cout << "Trying ABCD method for Background subtration" << std::endl;
00261
00262
00263 TString histoName_Ba("h_met_EB");
00264 TString histoName_Bb("h_met_inverse_EB");
00265 TString histoName_Ea("h_met_EE");
00266 TString histoName_Eb("h_met_inverse_EE");
00267
00268
00269 int fmax = (int) file.size();
00270 int NBins = 0; double min = 0; double max = -1;
00271 for (int i=0; i<fmax; ++i) {
00272 if (weight[i]>0) {
00273
00274 TFile f(file[i]);
00275 TH1F *h = (TH1F*) f.Get(histoName_Ba);
00276 NBins = h->GetNbinsX();
00277 min = h->GetBinLowEdge(1);
00278 max = h->GetBinLowEdge(NBins+1);
00279 break;
00280 }
00281 }
00282 if (NBins ==0 || (max<min)) {
00283 std::cout << "PlotCombiner::abcd error: Could not find valid histograms in file"
00284 << std::endl;
00285 abort();
00286 }
00287 cout << "Histograms with "<< NBins <<" bins and range " << min << "-" << max << endl;
00288
00289
00290 TH1F h_wenu("h_wenu", "h_wenu", NBins, min, max);
00291 TH1F h_wenu_inv("h_wenu_inv", "h_wenu_inv", NBins, min, max);
00292 for (int i=0; i<fmax; ++i) {
00293 if (type[i] == "sig" && weight[i]>0 ) {
00294 TFile f(file[i]);
00295
00296 TH1F *h_ba = (TH1F*) f.Get(histoName_Ba);
00297 h_wenu.Add(h_ba, weight[i]);
00298 TH1F *h_ea = (TH1F*) f.Get(histoName_Ea);
00299 h_wenu.Add(h_ea, weight[i]);
00300
00301 TH1F *h_bb = (TH1F*) f.Get(histoName_Bb);
00302 h_wenu_inv.Add(h_bb, weight[i]);
00303 TH1F *h_eb = (TH1F*) f.Get(histoName_Eb);
00304 h_wenu_inv.Add(h_eb, weight[i]);
00305 }
00306 }
00307
00308 TH1F h_qcd("h_qcd", "h_qcd", NBins, min, max);
00309 TH1F h_qcd_inv("h_qcd_inv", "h_qcd_inv", NBins, min, max);
00310 for (int i=0; i<fmax; ++i) {
00311 if ((type[i] == "qcd" || type[i] == "bce"
00312 || type[i] == "gje") && weight[i]>0) {
00313 TFile f(file[i]);
00314
00315 TH1F *h_ba = (TH1F*) f.Get(histoName_Ba);
00316 h_qcd.Add(h_ba, weight[i]);
00317 TH1F *h_ea = (TH1F*) f.Get(histoName_Ea);
00318 h_qcd.Add(h_ea, weight[i]);
00319
00320 TH1F *h_bb = (TH1F*) f.Get(histoName_Bb);
00321 h_qcd_inv.Add(h_bb, weight[i]);
00322 TH1F *h_eb = (TH1F*) f.Get(histoName_Eb);
00323 h_qcd_inv.Add(h_eb, weight[i]);
00324 }
00325 }
00326
00327 TH1F h_ewk("h_ewk", "h_ewk", NBins, min, max);
00328 TH1F h_ewk_inv("h_ewk_inv", "h_ewk_inv", NBins, min, max);
00329 for (int i=0; i<fmax; ++i) {
00330 if ( type[i] == "ewk" && weight[i]>0) {
00331 TFile f(file[i]);
00332
00333 TH1F *h_ba = (TH1F*) f.Get(histoName_Ba);
00334 h_ewk.Add(h_ba, weight[i]);
00335 TH1F *h_ea = (TH1F*) f.Get(histoName_Ea);
00336 h_ewk.Add(h_ea, weight[i]);
00337
00338 TH1F *h_bb = (TH1F*) f.Get(histoName_Bb);
00339 h_ewk_inv.Add(h_bb, weight[i]);
00340 TH1F *h_eb = (TH1F*) f.Get(histoName_Eb);
00341 h_ewk_inv.Add(h_eb, weight[i]);
00342 }
00343 }
00344
00345
00346
00347
00348
00349 int IMET = int ((METCut - min)/(max-min) * double(NBins));
00350
00351 double metCalc = min + (max-min)*double(IMET)/double(NBins);
00352 if (metCalc < METCut || metCalc > METCut) {
00353 std::cout << "PlotCombiner:abcd: your MET Cut is not in low egde bin position"
00354 << std::endl;
00355 }
00356 cout << "MET Cut in " << METCut << "GeV corresponds to bin #" << IMET << endl;
00357
00358
00359 double a_sig = h_wenu.Integral(IMET,NBins+1);
00360 double b_sig = h_wenu.Integral(0,IMET-1);
00361 double c_sig = h_wenu_inv.Integral(0,IMET-1);
00362 double d_sig = h_wenu_inv.Integral(IMET,NBins+1);
00363
00364 double a_qcd = h_qcd.Integral(IMET,NBins+1);
00365 double b_qcd = h_qcd.Integral(0,IMET-1);
00366 double c_qcd = h_qcd_inv.Integral(0,IMET-1);
00367 double d_qcd = h_qcd_inv.Integral(IMET,NBins+1);
00368
00369 double a_ewk = h_ewk.Integral(IMET,NBins+1);
00370 double b_ewk = h_ewk.Integral(0,IMET-1);
00371 double c_ewk = h_ewk_inv.Integral(0,IMET-1);
00372 double d_ewk = h_ewk_inv.Integral(IMET,NBins+1);
00374
00375
00376
00377 if (data < 0 && data >-0.75) {
00378
00379
00380 std::cout << "Calculating ABCD Result and Stat Error Assuming DATA"
00381 << std::endl << "Summary: in this implementation we have assumed"
00382 << " that what real 'data' appear with type sig in the input"
00383 << std::endl << "No systematics available with this type of"
00384 << " calculation. If you need systematics try one of the other"
00385 << " options" << std::endl;
00386 double A = (1.0-I)*(FzP-Fz);
00387 double B = I*(FzP+1.0)*(FzP*(c_sig-c_ewk)-(d_sig-d_ewk)) +
00388 (1+Fz)*(1-I)*((a_sig-a_ewk)-dFzP*(b_sig-b_ewk));
00389 double C = I*(1.+Fz)*(1.+FzP)*((d_sig-d_ewk)*(b_sig-b_ewk) - (a_sig-a_ewk)*(c_sig-c_ewk));
00390
00391
00392 double S = Trionym(A,B,C, a_sig+b_sig);
00393
00394
00395
00396 double ApI=0, ApFz=0, ApFzP=0, ApNa=0, ApNb=0, ApNc=0, ApNd=0;
00397 double BpI=0, BpFz=0, BpFzP=0, BpNa=0, BpNb=0, BpNc=0, BpNd=0;
00398 double CpI=0, CpFz=0, CpFzP=0, CpNa=0, CpNb=0, CpNc=0, CpNd=0;
00399 double SpI=0, SpFz=0, SpFzP=0, SpNa=0, SpNb=0, SpNc=0, SpNd=0;
00400
00401 double Na = a_sig, Nb = b_sig, Nc=c_sig, Nd = d_sig;
00402 double Ea = a_ewk, Eb = b_ewk, Ec=c_ewk, Ed = d_ewk;
00403 if (A != 0) {
00404
00405 ApI = -(FzP-Fz);
00406 ApFz = -(1.0-I);
00407 ApFzP = (1.0-I);
00408 ApNa = 0.0;
00409 ApNb = 0.0;
00410 ApNc = 0.0;
00411 ApNd = 0.0;
00412
00413 BpI = (FzP+1.0)*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0+Fz)*((Na-Ea)-FzP*(Nb-Eb));
00414 BpFz = I*(FzP+1.0)*(Nc-Ec)+(1.0-I)*((Na-Ea)-FzP*(Nb-Eb));
00415 BpFzP = I*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0-I)*(1.0+Fz)*(Nb-Eb);
00416 BpNa = (1.0-I)*(1.0+Fz);
00417 BpNb = -(1.0-I)*(1.0+Fz)*FzP;
00418 BpNc = I*(FzP+1.0)*Fz;
00419 BpNd = -I*(FzP+1.0);
00420
00421 CpI = (1.0+Fz)*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00422 CpFz = I*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00423 CpFzP = I*(1.0+Fz)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00424 CpNa = -I*(1.0+Fz)*(1.0+FzP)*(Nc-Ec);
00425 CpNb = I*(1.0+Fz)*(1.0+FzP)*(Nd-Ed);
00426 CpNc = -I*(1.0+Fz)*(1.0+FzP)*(Na-Ea);
00427 CpNd = I*(1.0+Fz)*(1.0+FzP)*(Nb-Eb);
00428
00429 SpI = (-BpI + (B*BpI -2.0*ApI*C -2.0*A*CpI) /fabs(2.0*A*S+B)- 2.0*ApI*S) /(2.0*A);
00430 SpFz = (-BpFz + (B*BpFz -2.0*ApFz*C -2.0*A*CpFz) /fabs(2.0*A*S+B)- 2.0*ApFz*S) /(2.0*A);
00431 SpFzP = (-BpFzP + (B*BpFzP -2.0*ApFzP*C -2.0*A*CpFzP)/fabs(2.0*A*S+B)- 2.0*ApFzP*S)/(2.0*A);
00432 SpNa = (-BpNa + (B*BpNa -2.0*ApNa*C -2.0*A*CpNa) /fabs(2.0*A*S+B)- 2.0*ApNa*S) /(2.0*A);
00433 SpNb = (-BpNb + (B*BpNb -2.0*ApNb*C -2.0*A*CpNb) /fabs(2.0*A*S+B)- 2.0*ApNb*S) /(2.0*A);
00434 SpNc = (-BpNc + (B*BpNc -2.0*ApNc*C -2.0*A*CpNc) /fabs(2.0*A*S+B)- 2.0*ApNc*S) /(2.0*A);
00435 SpNd = (-BpNd + (B*BpNd -2.0*ApNd*C -2.0*A*CpNd) /fabs(2.0*A*S+B)- 2.0*ApNd*S) /(2.0*A);
00436 }
00437 else {
00438 BpI = (FzP+1.0)*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0+Fz)*((Na-Ea)-FzP*(Nb-Eb));
00439 BpFz = I*(FzP+1.0)*(Nc-Ec)+(1.0-I)*((Na-Ea)-FzP*(Nb-Eb));
00440 BpFzP = I*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0-I)*(1.0+Fz)*(Nb-Eb);
00441 BpNa = (1.0-I)*(1.0+Fz);
00442 BpNb = -(1.0-I)*(1.0+Fz)*FzP;
00443 BpNc = I*(FzP+1.0)*Fz;
00444 BpNd = -I*(FzP+1.0);
00445
00446 CpI = (1.0+Fz)*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00447 CpFz = I*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00448 CpFzP = I*(1.0+Fz)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00449 CpNa = -I*(1.0+Fz)*(1.0+FzP)*(Nc-Ec);
00450 CpNb = I*(1.0+Fz)*(1.0+FzP)*(Nd-Ed);
00451 CpNc = -I*(1.0+Fz)*(1.0+FzP)*(Na-Ea);
00452 CpNd = I*(1.0+Fz)*(1.0+FzP)*(Nb-Eb);
00453
00454 SpI = -CpI/B+C*BpI/(B*B);
00455 SpFz = -CpFz/B+C*BpFz/(B*B);
00456 SpFzP = -CpFzP/B+C*BpFzP/(B*B);
00457 SpNa = -CpNa/B+C*BpNa/(B*B);
00458 SpNb = -CpNb/B+C*BpNb/(B*B);
00459 SpNc = -CpNc/B+C*BpNc/(B*B);
00460 SpNd = -CpNd/B+C*BpNd/(B*B);
00461 }
00462 double DS;
00463 DS = sqrt( SpI*dI*SpI*dI + SpFz*dFz*SpFz*dFz + SpFzP*dFzP*SpFzP*dFzP +
00464 SpNa*SpNa*Na + SpNb*SpNb*Nb + SpNc*SpNc*Nc + SpNd*SpNd*Nd );
00465
00466 cout << "********************************************************" << endl;
00467 cout << "Signal Prediction: " << S << "+-" << DS << "(stat)" << endl;
00468 cout << "********************************************************" << endl;
00469 cout << "Parameters used in calculation: " << endl;
00470 cout << "I= " << I << "+-" << dI << endl;
00471 cout << "Fz= " << Fz << "+-" << dFz << endl;
00472 cout << "FzP=" << FzP << "+-" << dFzP << endl;
00473 cout << endl;
00474 cout << "ABCD Regions population:" << endl;
00475 cout << "A: N=" << Na << ", sig=" << a_sig << ", qcd=" << a_qcd
00476 << ", ewk=" << a_ewk << endl;
00477 cout << "B: N=" << Nb << ", sig=" << b_sig << ", qcd=" << b_qcd
00478 << ", ewk=" << b_ewk << endl;
00479 cout << "C: N=" << Nc << ", sig=" << c_sig << ", qcd=" << c_qcd
00480 << ", ewk=" << c_ewk << endl;
00481 cout << "D: N=" << Nd << ", sig=" << d_sig << ", qcd=" << d_qcd
00482 << ", ewk=" << d_ewk << endl;
00483 cout << endl;
00484
00485 cout << "Statistical Error Summary: " << endl;
00486 cout << "due to Fz = "<< SpFz*dFz<< ", ("<<SpFz*dFz*100./S << "%)"<< endl;
00487 cout << "due to FzP= "<< SpFzP*dFzP
00488 << ", ("<<SpFzP*dFzP*100./S << "%)"<< endl;
00489 cout << "due to I = "<< SpI*dI
00490 << ", ("<<SpI*dI*100./S << "%)"<< endl;
00491 cout << "due to Na = "<< SpNa*sqrt(Na)
00492 << ", ("<< SpNa*sqrt(Na)*100./S << "%)"<< endl;
00493 cout << "due to Nb = "<< SpNb*sqrt(Nb)
00494 << ", ("<< SpNb*sqrt(Nb)*100./S << "%)"<< endl;
00495 cout << "due to Nc = "<< SpNc*sqrt(Nc)
00496 << ", ("<< SpNc*sqrt(Nc)*100./S << "%)"<< endl;
00497 cout << "due to Nd = "<< SpNd*sqrt(Nd)
00498 << ", ("<< SpNd*sqrt(Nd)*100./S << "%)"<< endl;
00499 cout << "Total Statistical Error: "
00500 << DS << ", (" << DS*100./S << "%)"<< endl;
00501 cout << "Stat Error percentages are wrt S prediction, not S mc" << endl;
00502 }
00503
00504
00505
00506
00507
00508 if (mc < 0 && mc >-0.75) {
00509
00510
00512 double A = (1.0-I)*(FzP-Fz);
00513 double B = I*(FzP+1.0)*(FzP*(c_sig+c_qcd)-(d_sig+d_qcd)) +
00514 (1+Fz)*(1-I)*((a_sig+a_qcd)-dFzP*(b_sig+b_qcd));
00515 double C = I*(1.+Fz)*(1.+FzP)*((d_sig+d_qcd)*(b_sig+b_qcd) -
00516 (a_sig+a_qcd)*(c_sig+c_qcd));
00517
00518
00519 double S = Trionym(A,B,C, a_sig+b_sig);
00520
00521 double ApI=0, ApFz=0, ApFzP=0, ApNa=0, ApNb=0, ApNc=0, ApNd=0;
00522 double BpI=0, BpFz=0, BpFzP=0, BpNa=0, BpNb=0, BpNc=0, BpNd=0;
00523 double CpI=0, CpFz=0, CpFzP=0, CpNa=0, CpNb=0, CpNc=0, CpNd=0;
00524 double SpI=0, SpFz=0, SpFzP=0, SpNa=0, SpNb=0, SpNc=0, SpNd=0;
00525
00526 double Na = a_sig+a_qcd+a_ewk, Nb = b_sig+b_qcd+b_ewk;
00527 double Nc=c_sig+c_qcd+c_ewk, Nd = d_sig+d_qcd+d_ewk;
00528 double Ea = a_ewk, Eb = b_ewk, Ec=c_ewk, Ed = d_ewk;
00529 if (A != 0) {
00530
00531 ApI = -(FzP-Fz);
00532 ApFz = -(1.0-I);
00533 ApFzP = (1.0-I);
00534 ApNa = 0.0;
00535 ApNb = 0.0;
00536 ApNc = 0.0;
00537 ApNd = 0.0;
00538
00539 BpI = (FzP+1.0)*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0+Fz)*((Na-Ea)-FzP*(Nb-Eb));
00540 BpFz = I*(FzP+1.0)*(Nc-Ec)+(1.0-I)*((Na-Ea)-FzP*(Nb-Eb));
00541 BpFzP = I*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0-I)*(1.0+Fz)*(Nb-Eb);
00542 BpNa = (1.0-I)*(1.0+Fz);
00543 BpNb = -(1.0-I)*(1.0+Fz)*FzP;
00544 BpNc = I*(FzP+1.0)*Fz;
00545 BpNd = -I*(FzP+1.0);
00546
00547 CpI = (1.0+Fz)*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00548 CpFz = I*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00549 CpFzP = I*(1.0+Fz)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00550 CpNa = -I*(1.0+Fz)*(1.0+FzP)*(Nc-Ec);
00551 CpNb = I*(1.0+Fz)*(1.0+FzP)*(Nd-Ed);
00552 CpNc = -I*(1.0+Fz)*(1.0+FzP)*(Na-Ea);
00553 CpNd = I*(1.0+Fz)*(1.0+FzP)*(Nb-Eb);
00554
00555 SpI = (-BpI + (B*BpI -2.0*ApI*C -2.0*A*CpI) /fabs(2.0*A*S+B)- 2.0*ApI*S) /(2.0*A);
00556 SpFz = (-BpFz + (B*BpFz -2.0*ApFz*C -2.0*A*CpFz) /fabs(2.0*A*S+B)- 2.0*ApFz*S) /(2.0*A);
00557 SpFzP = (-BpFzP + (B*BpFzP -2.0*ApFzP*C -2.0*A*CpFzP)/fabs(2.0*A*S+B)- 2.0*ApFzP*S)/(2.0*A);
00558 SpNa = (-BpNa + (B*BpNa -2.0*ApNa*C -2.0*A*CpNa) /fabs(2.0*A*S+B)- 2.0*ApNa*S) /(2.0*A);
00559 SpNb = (-BpNb + (B*BpNb -2.0*ApNb*C -2.0*A*CpNb) /fabs(2.0*A*S+B)- 2.0*ApNb*S) /(2.0*A);
00560 SpNc = (-BpNc + (B*BpNc -2.0*ApNc*C -2.0*A*CpNc) /fabs(2.0*A*S+B)- 2.0*ApNc*S) /(2.0*A);
00561 SpNd = (-BpNd + (B*BpNd -2.0*ApNd*C -2.0*A*CpNd) /fabs(2.0*A*S+B)- 2.0*ApNd*S) /(2.0*A);
00562 }
00563 else {
00564 BpI = (FzP+1.0)*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0+Fz)*((Na-Ea)-FzP*(Nb-Eb));
00565 BpFz = I*(FzP+1.0)*(Nc-Ec)+(1.0-I)*((Na-Ea)-FzP*(Nb-Eb));
00566 BpFzP = I*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0-I)*(1.0+Fz)*(Nb-Eb);
00567 BpNa = (1.0-I)*(1.0+Fz);
00568 BpNb = -(1.0-I)*(1.0+Fz)*FzP;
00569 BpNc = I*(FzP+1.0)*Fz;
00570 BpNd = -I*(FzP+1.0);
00571
00572 CpI = (1.0+Fz)*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00573 CpFz = I*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00574 CpFzP = I*(1.0+Fz)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00575 CpNa = -I*(1.0+Fz)*(1.0+FzP)*(Nc-Ec);
00576 CpNb = I*(1.0+Fz)*(1.0+FzP)*(Nd-Ed);
00577 CpNc = -I*(1.0+Fz)*(1.0+FzP)*(Na-Ea);
00578 CpNd = I*(1.0+Fz)*(1.0+FzP)*(Nb-Eb);
00579
00580 SpI = -CpI/B+C*BpI/(B*B);
00581 SpFz = -CpFz/B+C*BpFz/(B*B);
00582 SpFzP = -CpFzP/B+C*BpFzP/(B*B);
00583 SpNa = -CpNa/B+C*BpNa/(B*B);
00584 SpNb = -CpNb/B+C*BpNb/(B*B);
00585 SpNc = -CpNc/B+C*BpNc/(B*B);
00586 SpNd = -CpNd/B+C*BpNd/(B*B);
00587 }
00588 double DS;
00589 DS = sqrt( SpI*dI*SpI*dI + SpFz*dFz*SpFz*dFz + SpFzP*dFzP*SpFzP*dFzP +
00590 SpNa*SpNa*Na + SpNb*SpNb*Nb + SpNc*SpNc*Nc + SpNd*SpNd*Nd );
00591
00593
00595
00596 double Imc = (a_sig + b_sig) / (a_sig + b_sig + c_sig + d_sig);
00597 double dImc = sqrt(Imc*(1-Imc)/(a_sig + b_sig + c_sig + d_sig));
00598 double Fzmc = a_sig/b_sig;
00599 double e =a_sig/(a_sig + b_sig);
00600 double de = sqrt(e*(1-e)/(a_sig + b_sig));
00601 double alpha = de/(2.*Fzmc-e);
00602 double dFzmc = alpha/(1-alpha);
00603 double FzPmc = d_sig/c_sig;
00604 double ep =d_sig/(c_sig + d_sig);
00605 double dep = sqrt(ep*(1-ep)/(c_sig + d_sig));
00606 double alphap = dep/(2.*FzPmc-ep);
00607 double dFzPmc = alphap/(1-alphap);
00608
00609
00610 double KMC = (d_qcd/c_qcd)/(a_qcd/b_qcd);
00611 double SMC = a_sig + b_sig;
00612
00613 double dfz = Fz -Fzmc;
00614 double di = I - Imc;
00615 double dfzp = FzP - FzPmc;
00616 double fk = fabs(1-KMC);
00618
00619 double fm = 1.-ewkerror;
00620 double fp = 1.+ewkerror;
00621 double S_EWK_PLUS = CalcABCD(Imc, Fzmc, FzPmc, KMC, fp, Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00622 double S_EWK_MINUS = CalcABCD(Imc, Fzmc, FzPmc, KMC, fm, Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00623
00624 double S_K= CalcABCD(Imc, Fzmc, FzPmc, 1., 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00625
00626 double S_FZ= CalcABCD(Imc, Fz, FzPmc, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00627
00628 double S_FZP= CalcABCD(Imc, Fzmc, FzP, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00629
00630 double S_I = CalcABCD(I, Fzmc, FzPmc, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00631
00632
00633
00634
00635
00636
00637
00638
00639 int const POINTS = 10;
00640 int const allPOINTS = 2*POINTS;
00641 TGraph g_ewk(allPOINTS);
00642 TGraph g_fz(allPOINTS);
00643 TGraph g_fzp(allPOINTS);
00644 TGraph g_k(allPOINTS);
00645 TGraph g_i(allPOINTS);
00646
00647 double ewk_syst_min = EWK_SYST_MIN;
00648 double i_syst_min = Imc*(1.-I_SYST_MIN);
00649 double fz_syst_min = Fzmc*(1.-FZ_SYST_MIN);
00650 double fzp_syst_min = FzPmc*(1.-FZP_SYST_MIN);
00651 double k_syst_min = KMC*(1.-K_SYST_MIN);
00652
00653 double ewk_syst_max = EWK_SYST_MAX;
00654 double i_syst_max = Imc*I_SYST_MAX;
00655 double fz_syst_max = Fzmc*FZ_SYST_MAX;
00656 double fzp_syst_max = FzPmc*FZP_SYST_MAX;
00657 double k_syst_max = KMC*K_SYST_MAX;
00658
00659
00660 for (int i=0; i<POINTS; ++i) {
00661 double x_ewk = 1.-ewk_syst_min + (ewk_syst_min)*i/POINTS;
00662 double x_fz = fz_syst_min + (Fzmc-fz_syst_min)*i/POINTS;
00663 double x_fzp = fzp_syst_min + (FzPmc-fzp_syst_min)*i/POINTS;
00664 double x_k = k_syst_min + (KMC-k_syst_min)*i/POINTS;
00665 double x_i = i_syst_min + (Imc-i_syst_min)*i/POINTS;
00666
00667 double y_ewk= CalcABCD(Imc, Fzmc, FzPmc, KMC, x_ewk, Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00668 double y_fz = CalcABCD(Imc, x_fz, FzPmc, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00669 double y_fzp= CalcABCD(Imc, Fzmc, x_fzp, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00670 double y_k = CalcABCD(Imc, Fzmc, FzPmc, x_k, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00671 double y_i = CalcABCD(x_i, Fzmc, FzPmc, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00672
00673 g_ewk.SetPoint(i,(x_ewk-1.)*100., 100.*fabs(y_ewk-SMC)/SMC);
00674 g_fz.SetPoint(i,(x_fz-Fzmc)*100./Fzmc, 100.*fabs(y_fz-SMC)/SMC);
00675 g_fzp.SetPoint(i,(x_fzp-FzPmc)*100./FzPmc, 100.*fabs(y_fzp-SMC)/SMC);
00676 g_i.SetPoint(i,(x_i-Imc)*100./Imc, 100.*fabs(y_i-SMC)/SMC);
00677 g_k.SetPoint(i,(x_k-KMC)*100./KMC, 100.*fabs(y_k-SMC)/SMC);
00678 }
00679
00680
00681 for (int i=0; i<=POINTS; ++i) {
00682 double x_ewk = 1.+ewk_syst_max*i/POINTS;
00683 double x_fz = Fzmc+fz_syst_max*i/POINTS;
00684 double x_fzp = FzPmc+fzp_syst_max*i/POINTS;
00685 double x_k = KMC+k_syst_max*i/POINTS;
00686 double x_i = Imc+i_syst_max*i/POINTS;
00687
00688 double y_ewk= CalcABCD(Imc, Fzmc, FzPmc, KMC, x_ewk, Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00689 double y_fz = CalcABCD(Imc, x_fz, FzPmc, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00690 double y_fzp= CalcABCD(Imc, Fzmc, x_fzp, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00691 double y_k = CalcABCD(Imc, Fzmc, FzPmc, x_k, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00692 double y_i = CalcABCD(x_i, Fzmc, FzPmc, KMC, 1., Na, Nb, Nc, Nd, Ea,Eb,Ec,Ed);
00693
00694 g_ewk.SetPoint(i+POINTS,(x_ewk-1.)*100., 100.*fabs(y_ewk-SMC)/SMC);
00695 g_fz.SetPoint(i+POINTS,(x_fz-Fzmc)*100./Fzmc, 100.*fabs(y_fz-SMC)/SMC);
00696 g_fzp.SetPoint(i+POINTS,(x_fzp-FzPmc)*100./FzPmc, 100.*fabs(y_fzp-SMC)/SMC);
00697 g_i.SetPoint(i+POINTS,(x_i-Imc)*100./Imc, 100.*fabs(y_i-SMC)/SMC);
00698 g_k.SetPoint(i+POINTS,(x_k-KMC)*100./KMC, 100.*fabs(y_k-SMC)/SMC);
00699 }
00700 TString yaxis("(S-S_{mc})/S_{mc} (%)");
00701 TCanvas c;
00702 g_ewk.SetLineWidth(2);
00703 g_ewk.GetXaxis()->SetTitle("EWK Variation (%)");
00704 g_ewk.GetYaxis()->SetTitle(yaxis);
00705 g_ewk.Draw("AL");
00706 c.Print("ewk_syst_variation.C");
00707
00708 g_fz.SetLineWidth(2);
00709 g_fz.GetXaxis()->SetTitle("F_{z} Variation (%)");
00710 g_fz.GetYaxis()->SetTitle(yaxis);
00711 g_fz.Draw("AL");
00712 c.Print("fz_syst_variation.C");
00713
00714 g_fzp.SetLineWidth(2);
00715 g_fzp.GetXaxis()->SetTitle("F_{z}' Variation (%)");
00716 g_fzp.GetYaxis()->SetTitle(yaxis);
00717 g_fzp.Draw("AL");
00718 c.Print("fzp_syst_variation.C");
00719
00720 g_i.SetLineWidth(2);
00721 g_i.GetXaxis()->SetTitle("I Variation (%)");
00722 g_i.GetYaxis()->SetTitle(yaxis);
00723 g_i.Draw("AL");
00724 c.Print("i_syst_variation.C");
00725
00726 g_k.SetLineWidth(2);
00727 g_k.GetXaxis()->SetTitle("K Variation (%)");
00728 g_k.GetYaxis()->SetTitle(yaxis);
00729 g_k.Draw("AL");
00730 c.Print("k_syst_variation.C");
00731
00732
00733
00734
00735
00736 double err_ewk = std::max(fabs(SMC-S_EWK_PLUS),fabs(SMC-S_EWK_MINUS));
00737 double err_fz = fabs(SMC-S_FZ);
00738 double err_fzp = fabs(SMC-S_FZP);
00739 double err_i = fabs(SMC-S_I);
00740 double err_k = fabs(SMC-S_K);
00741
00742 double DS_syst = sqrt(err_ewk*err_ewk + err_fz*err_fz + err_fzp*err_fzp+
00743 err_i*err_i + err_k*err_k);
00744
00745 cout << "********************************************************" << endl;
00746 cout << "Signal Prediction: " << S << "+-" << DS << "(stat) +-"
00747 << DS_syst << "(syst)" << endl;
00748 cout << "stat error: " << 100.*DS/S <<"%" << endl;
00749 cout << "syt error: " << 100.*DS_syst/S<< "%" << endl;
00750 cout << "********************************************************" << endl;
00751 cout << "Parameters used in calculation: " << endl;
00752 cout << "I= " << I << "+-" << dI << endl;
00753 cout << "Fz= " << Fz << "+-" << dFz << endl;
00754 cout << "FzP=" << FzP << "+-" << dFzP << endl;
00755 cout << "EWK error assumed to be: " << ewkerror << endl;
00756 cout << endl;
00757 cout << "ABCD Regions population:" << endl;
00758 cout << "A: N=" << Na << ", sig=" << a_sig << ", qcd=" << a_qcd
00759 << ", ewk=" << a_ewk << endl;
00760 cout << "B: N=" << Nb << ", sig=" << b_sig << ", qcd=" << b_qcd
00761 << ", ewk=" << b_ewk << endl;
00762 cout << "C: N=" << Nc << ", sig=" << c_sig << ", qcd=" << c_qcd
00763 << ", ewk=" << c_ewk << endl;
00764 cout << "D: N=" << Nd << ", sig=" << d_sig << ", qcd=" << d_qcd
00765 << ", ewk=" << d_ewk << endl;
00766 cout << endl;
00767 cout << "Parameters from MC: " << endl;
00768 cout << "I= " << Imc << "+-" << dImc << endl;
00769 cout << "Fz= " << Fzmc << "+-" << dFzmc << endl;
00770 cout << "FzP=" << FzPmc << "+-" << dFzPmc << endl;
00771 cout << endl;
00772 cout << "Real value of K=" << KMC << endl;
00773 cout << "Real value of Signal=" << SMC << endl;
00774 cout << endl;
00775 cout << "Difference Measured - MC value (% wrt MC value except K=1): "
00776 << endl;
00777 cout << "Fz : " << dfz << ", (" << dfz*100./Fzmc << "%)" << endl;
00778 cout << "FzP: " << dfzp << ", (" << dfzp*100./FzPmc << "%)" << endl;
00779 cout << "I : " << di << ", (" << di*100./Imc << "%)" << endl;
00780 cout << "K : " << fk << ", (" << fk*100./1. << "%)" << endl;
00781 cout << endl;
00782
00783 cout << "DETAILS OF THE CALCULATION" << endl;
00784 cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
00785 cout << "Statistical Error Summary: " << endl;
00786 cout << "due to Fz = "<< SpFz*dFz<< ", ("<<SpFz*dFz*100./S << "%)"<< endl;
00787 cout << "due to FzP= "<< SpFzP*dFzP
00788 << ", ("<<SpFzP*dFzP*100./S << "%)"<< endl;
00789 cout << "due to I = "<< SpI*dI
00790 << ", ("<<SpI*dI*100./S << "%)"<< endl;
00791 cout << "due to Na = "<< SpNa*sqrt(Na)
00792 << ", ("<< SpNa*sqrt(Na)*100./S << "%)"<< endl;
00793 cout << "due to Nb = "<< SpNb*sqrt(Nb)
00794 << ", ("<< SpNb*sqrt(Nb)*100./S << "%)"<< endl;
00795 cout << "due to Nc = "<< SpNc*sqrt(Nc)
00796 << ", ("<< SpNc*sqrt(Nc)*100./S << "%)"<< endl;
00797 cout << "due to Nd = "<< SpNd*sqrt(Nd)
00798 << ", ("<< SpNd*sqrt(Nd)*100./S << "%)"<< endl;
00799 cout << "Total Statistical Error: "
00800 << DS << ", (" << DS*100./S << "%)"<< endl;
00801 cout << "Stat Error percentages are wrt S prediction, not S mc" << endl;
00802 cout << endl;
00803 cout << "Systematic Error Summary:" << endl;
00804 cout << "due to k = " << err_k << " ( " << err_k*100./S << "%)" << endl;
00805 cout << "due to Fz = " << err_fz << " ( " << err_fz*100./S << "%)" << endl;
00806 cout << "due to FzP = " << err_fzp << " ( " << err_fzp*100./S << "%)" << endl;
00807 cout << "due to I = " << err_i << " ( " << err_i*100./S << "%)" << endl;
00808 cout << "due to EWK = " << err_ewk << " ( " << err_ewk*100./S << "%)" << endl;
00809
00810 cout << "Syst Error percentages are wrt S prediction, not S mc" << endl;
00811 }
00812
00813
00814 if (mcOnly < 0 && mcOnly >-0.75) {
00815
00816 cout << "=======================================================" << endl;
00817 cout << "Calculating ABCD Result and Stat Error Assuming MC ONLY" << endl;
00818 cout << "=======================================================" << endl;
00819 cout << "All input parameters that the user have inserted will be "
00820 << "ignored and recalculated from MC" << endl;
00821 cout << "This option will not give you systematics estimation" << endl;
00822
00823 I = (a_sig + b_sig) / (a_sig + b_sig + c_sig + d_sig);
00824 dI = sqrt(I*(1-I)/(a_sig + b_sig + c_sig + d_sig));
00825 Fz = a_sig/b_sig;
00826 double e =a_sig/(a_sig + b_sig);
00827 double de = sqrt(e*(1-e)/(a_sig + b_sig));
00828 double alpha = de/(2.*Fz-e);
00829 dFz = alpha/(1-alpha);
00830 FzP = d_sig/c_sig;
00831 double ep =d_sig/(c_sig + d_sig);
00832 double dep = sqrt(ep*(1-ep)/(c_sig + d_sig));
00833 double alphap = dep/(2.*FzP-ep);
00834 dFzP = alphap/(1-alphap);
00835
00836 double KMC = (d_qcd/c_qcd)/(a_qcd/b_qcd);
00837
00838
00839 double A = (1.0-I)*(FzP-Fz);
00840 double B = I*(FzP+1.0)*(FzP*(c_sig+c_qcd)-(d_sig+d_qcd)) +
00841 (1+Fz)*(1-I)*((a_sig+a_qcd)-dFzP*(b_sig+b_qcd));
00842 double C = I*(1.+Fz)*(1.+FzP)*((d_sig+d_qcd)*(b_sig+b_qcd) -
00843 (a_sig+a_qcd)*(c_sig+c_qcd));
00844
00845
00846 double S = Trionym(A,B,C, a_sig+b_sig);
00847
00848
00849
00850 double ApI=0, ApFz=0, ApFzP=0, ApNa=0, ApNb=0, ApNc=0, ApNd=0;
00851 double BpI=0, BpFz=0, BpFzP=0, BpNa=0, BpNb=0, BpNc=0, BpNd=0;
00852 double CpI=0, CpFz=0, CpFzP=0, CpNa=0, CpNb=0, CpNc=0, CpNd=0;
00853 double SpI=0, SpFz=0, SpFzP=0, SpNa=0, SpNb=0, SpNc=0, SpNd=0;
00854
00855 double Na = a_sig+a_qcd+a_ewk, Nb = b_sig+b_qcd+b_ewk;
00856 double Nc=c_sig+c_qcd+c_ewk, Nd = d_sig+d_qcd+d_ewk;
00857 double Ea = a_ewk, Eb = b_ewk, Ec=c_ewk, Ed = d_ewk;
00858 if (A != 0) {
00859
00860 ApI = -(FzP-Fz);
00861 ApFz = -(1.0-I);
00862 ApFzP = (1.0-I);
00863 ApNa = 0.0;
00864 ApNb = 0.0;
00865 ApNc = 0.0;
00866 ApNd = 0.0;
00867
00868 BpI = (FzP+1.0)*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0+Fz)*((Na-Ea)-FzP*(Nb-Eb));
00869 BpFz = I*(FzP+1.0)*(Nc-Ec)+(1.0-I)*((Na-Ea)-FzP*(Nb-Eb));
00870 BpFzP = I*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0-I)*(1.0+Fz)*(Nb-Eb);
00871 BpNa = (1.0-I)*(1.0+Fz);
00872 BpNb = -(1.0-I)*(1.0+Fz)*FzP;
00873 BpNc = I*(FzP+1.0)*Fz;
00874 BpNd = -I*(FzP+1.0);
00875
00876 CpI = (1.0+Fz)*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00877 CpFz = I*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00878 CpFzP = I*(1.0+Fz)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00879 CpNa = -I*(1.0+Fz)*(1.0+FzP)*(Nc-Ec);
00880 CpNb = I*(1.0+Fz)*(1.0+FzP)*(Nd-Ed);
00881 CpNc = -I*(1.0+Fz)*(1.0+FzP)*(Na-Ea);
00882 CpNd = I*(1.0+Fz)*(1.0+FzP)*(Nb-Eb);
00883
00884 SpI = (-BpI + (B*BpI -2.0*ApI*C -2.0*A*CpI) /fabs(2.0*A*S+B)- 2.0*ApI*S) /(2.0*A);
00885 SpFz = (-BpFz + (B*BpFz -2.0*ApFz*C -2.0*A*CpFz) /fabs(2.0*A*S+B)- 2.0*ApFz*S) /(2.0*A);
00886 SpFzP = (-BpFzP + (B*BpFzP -2.0*ApFzP*C -2.0*A*CpFzP)/fabs(2.0*A*S+B)- 2.0*ApFzP*S)/(2.0*A);
00887 SpNa = (-BpNa + (B*BpNa -2.0*ApNa*C -2.0*A*CpNa) /fabs(2.0*A*S+B)- 2.0*ApNa*S) /(2.0*A);
00888 SpNb = (-BpNb + (B*BpNb -2.0*ApNb*C -2.0*A*CpNb) /fabs(2.0*A*S+B)- 2.0*ApNb*S) /(2.0*A);
00889 SpNc = (-BpNc + (B*BpNc -2.0*ApNc*C -2.0*A*CpNc) /fabs(2.0*A*S+B)- 2.0*ApNc*S) /(2.0*A);
00890 SpNd = (-BpNd + (B*BpNd -2.0*ApNd*C -2.0*A*CpNd) /fabs(2.0*A*S+B)- 2.0*ApNd*S) /(2.0*A);
00891 }
00892 else {
00893 BpI = (FzP+1.0)*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0+Fz)*((Na-Ea)-FzP*(Nb-Eb));
00894 BpFz = I*(FzP+1.0)*(Nc-Ec)+(1.0-I)*((Na-Ea)-FzP*(Nb-Eb));
00895 BpFzP = I*(Fz*(Nc-Ec)-(Nd-Ed))-(1.0-I)*(1.0+Fz)*(Nb-Eb);
00896 BpNa = (1.0-I)*(1.0+Fz);
00897 BpNb = -(1.0-I)*(1.0+Fz)*FzP;
00898 BpNc = I*(FzP+1.0)*Fz;
00899 BpNd = -I*(FzP+1.0);
00900
00901 CpI = (1.0+Fz)*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00902 CpFz = I*(1.0+FzP)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00903 CpFzP = I*(1.0+Fz)*((Nd-Ed)*(Nb-Eb)-(Na-Ea)*(Nc-Ec));
00904 CpNa = -I*(1.0+Fz)*(1.0+FzP)*(Nc-Ec);
00905 CpNb = I*(1.0+Fz)*(1.0+FzP)*(Nd-Ed);
00906 CpNc = -I*(1.0+Fz)*(1.0+FzP)*(Na-Ea);
00907 CpNd = I*(1.0+Fz)*(1.0+FzP)*(Nb-Eb);
00908
00909 SpI = -CpI/B+C*BpI/(B*B);
00910 SpFz = -CpFz/B+C*BpFz/(B*B);
00911 SpFzP = -CpFzP/B+C*BpFzP/(B*B);
00912 SpNa = -CpNa/B+C*BpNa/(B*B);
00913 SpNb = -CpNb/B+C*BpNb/(B*B);
00914 SpNc = -CpNc/B+C*BpNc/(B*B);
00915 SpNd = -CpNd/B+C*BpNd/(B*B);
00916 }
00917 double DS;
00918 DS = sqrt( SpI*dI*SpI*dI + SpFz*dFz*SpFz*dFz + SpFzP*dFzP*SpFzP*dFzP +
00919 SpNa*SpNa*Na + SpNb*SpNb*Nb + SpNc*SpNc*Nc + SpNd*SpNd*Nd );
00920
00921 cout << "********************************************************" << endl;
00922 cout << "Signal Prediction: " << S << "+-" << DS << "(stat)" << endl;
00923 cout << "********************************************************" << endl;
00924 cout << "Parameters used in calculation: " << endl;
00925 cout << "I= " << I << "+-" << dI << endl;
00926 cout << "Fz= " << Fz << "+-" << dFz << endl;
00927 cout << "FzP=" << FzP << "+-" << dFzP << endl;
00928 cout << endl;
00929 cout << "ABCD Regions population:" << endl;
00930 cout << "A: N=" << Na << ", sig=" << a_sig << ", qcd=" << a_qcd
00931 << ", ewk=" << a_ewk << endl;
00932 cout << "B: N=" << Nb << ", sig=" << b_sig << ", qcd=" << b_qcd
00933 << ", ewk=" << b_ewk << endl;
00934 cout << "C: N=" << Nc << ", sig=" << c_sig << ", qcd=" << c_qcd
00935 << ", ewk=" << c_ewk << endl;
00936 cout << "D: N=" << Nd << ", sig=" << d_sig << ", qcd=" << d_qcd
00937 << ", ewk=" << d_ewk << endl;
00938 cout << "K value from MC: " << KMC << endl;
00939 cout << endl;
00940 cout << "Statistical Error Summary: " << endl;
00941 cout << "due to Fz = "<< SpFz*dFz<< ", ("<<SpFz*dFz*100./S << "%)"<< endl;
00942 cout << "due to FzP= "<< SpFzP*dFzP
00943 << ", ("<<SpFzP*dFzP*100./S << "%)"<< endl;
00944 cout << "due to I = "<< SpI*dI
00945 << ", ("<<SpI*dI*100./S << "%)"<< endl;
00946 cout << "due to Na = "<< SpNa*sqrt(Na)
00947 << ", ("<< SpNa*sqrt(Na)*100./S << "%)"<< endl;
00948 cout << "due to Nb = "<< SpNb*sqrt(Nb)
00949 << ", ("<< SpNb*sqrt(Nb)*100./S << "%)"<< endl;
00950 cout << "due to Nc = "<< SpNc*sqrt(Nc)
00951 << ", ("<< SpNc*sqrt(Nc)*100./S << "%)"<< endl;
00952 cout << "due to Nd = "<< SpNd*sqrt(Nd)
00953 << ", ("<< SpNd*sqrt(Nd)*100./S << "%)"<< endl;
00954 cout << "Total Statistical Error: "
00955 << DS << ", (" << DS*100./S << "%)"<< endl;
00956 cout << "Stat Error percentages are wrt S prediction, not S mc" << endl;
00957 }
00958
00959
00960 }
00961
00962 void plotMaker(TString histoName, TString wzsignal,
00963 vector<TString> file, vector<TString> type,
00964 vector<double> weight, TString xtitle)
00965 {
00966 gROOT->Reset();
00967 gROOT->ProcessLine(".L tdrstyle.C");
00968 gROOT->ProcessLine("setTDRStyle()");
00969
00970 int NBins = 0; double min = 0; double max = -1;
00971 for (int i=0; i< (int) file.size(); ++i) {
00972 if (weight[i]>0) {
00973 TFile f(file[i]);
00974 TH1F *h = (TH1F*) f.Get(histoName);
00975 NBins = h->GetNbinsX();
00976 min = h->GetBinLowEdge(1);
00977 max = h->GetBinLowEdge(NBins+1);
00978 break;
00979 }
00980 }
00981 if (NBins ==0 || (max<min)) {
00982 std::cout << "PlotCombiner::abcd error: Could not find valid histograms in file"
00983 << std::endl;
00984 abort();
00985 }
00986 cout << "Histograms with "<< NBins <<" bins and range " << min << "-" << max << endl;
00987
00988 TH1F h_wenu("h_wenu", "h_wenu", NBins, min, max);
00989 int fmax = (int) file.size();
00990 for (int i=0; i<fmax; ++i) {
00991 if (type[i] == "sig" && weight[i]>0) {
00992 TFile f(file[i]);
00993 TH1F *h = (TH1F*) f.Get(histoName);
00994 h_wenu.Add(h, weight[i]);
00995 }
00996 }
00997
00998
00999
01000 TH1F h_qcd("h_qcd", "h_qcd", NBins, min, max);
01001 for (int i=0; i<fmax; ++i) {
01002 if (type[i] == "qcd" && weight[i]>0) {
01003 TFile f(file[i]);
01004 TH1F *h = (TH1F*) f.Get(histoName);
01005 h_qcd.Add(h, weight[i]);
01006 }
01007 }
01008
01009 TH1F h_bce("h_bce", "h_bce", NBins, min, max);
01010 for (int i=0; i<fmax; ++i) {
01011 if (type[i] == "bce" && weight[i]>0) {
01012 TFile f(file[i]);
01013 TH1F *h = (TH1F*) f.Get(histoName);
01014 h_bce.Add(h, weight[i]);
01015 }
01016 }
01017
01018 TH1F h_gj("h_gj", "h_gj", NBins, min, max);
01019 for (int i=0; i<fmax; ++i) {
01020 if (type[i] == "gje" && weight[i]>0) {
01021 TFile f(file[i]);
01022 TH1F *h = (TH1F*) f.Get(histoName);
01023 h_gj.Add(h, weight[i]);
01024 }
01025 }
01026
01027 TH1F h_ewk("h_ewk", "h_ewk", NBins, min, max);
01028 for (int i=0; i<fmax; ++i) {
01029 if (type[i] == "ewk" && weight[i]>0) {
01030 TFile f(file[i]);
01031 TH1F *h = (TH1F*) f.Get(histoName);
01032 h_ewk.Add(h, weight[i]);
01033 }
01034 }
01035
01036
01037
01038 h_ewk.SetFillColor(3);
01039
01040
01041 h_gj.Add(&h_ewk);
01042 h_gj.SetFillColor(1);
01043
01044 h_bce.Add(&h_qcd);
01045 h_bce.Add(&h_gj);
01046 h_bce.SetFillColor(2);
01047
01048 TH1F h_tot("h_tot", "h_tot", NBins, min, max);
01049 h_tot.Add(&h_bce);
01050 h_tot.Add(&h_wenu);
01051 h_wenu.SetLineColor(4); h_wenu.SetLineWidth(2);
01052
01053 TCanvas c;
01054 h_tot.GetXaxis()->SetTitle(xtitle);
01055 h_tot.Draw("PE");
01056 h_bce.Draw("same");
01057 h_gj.Draw("same");
01058 h_ewk.Draw("same");
01059 h_wenu.Draw("same");
01060
01061
01062 TLegend leg(0.6,0.65,0.95,0.92);
01063 if (wzsignal == "wenu")
01064 leg.AddEntry(&h_wenu, "W#rightarrow e#nu","l");
01065 else
01066 leg.AddEntry(&h_wenu, "Z#rightarrow ee","l");
01067 leg.AddEntry(&h_tot, "Signal + Bkg","p");
01068 leg.AddEntry(&h_bce, "dijets","f");
01069 leg.AddEntry(&h_gj, "#gamma + jets","f");
01070 leg.AddEntry(&h_ewk, "EWK+t#bar t", "f");
01071 leg.Draw("same");
01072
01073 c.Print("test.png");
01074
01075
01076
01077 }
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089 double searchABCDstring(TString abcdString, TString keyword)
01090 {
01091 int size = keyword.Sizeof();
01092 int existsEntry = abcdString.Index(keyword);
01093
01094 if (existsEntry==-1) return -1.;
01095
01096 TString previousVal = abcdString(existsEntry-1);
01097 if (!(previousVal == "," || previousVal == " " ||
01098 previousVal == "(" )) return -1.;
01099
01100 TString afterVal = abcdString(existsEntry+size-1);
01101
01102 if (afterVal =="," || afterVal==")") return -0.5;
01103 else if (afterVal != "=") return -1.;
01104
01105
01106 int comma = abcdString.Index(",",existsEntry);
01107
01108 if (comma<0) comma = abcdString.Index(")",existsEntry);
01109 if (comma<0) {
01110 std::cout << "Error in parcing abcd line, chech syntax "
01111 << std::endl;
01112 return -99.;
01113 }
01114 TString svalue=abcdString(existsEntry+size,comma-existsEntry-size);
01115 std::cout << "Found ABCD parameter "<< keyword
01116 << " with value " << svalue << endl;
01117
01118 double value = svalue.Atof();
01119 return value;
01120
01121 }
01122
01123
01124 double Trionym(double a, double b, double c, double sum)
01125 {
01126 if (a==0) {
01127 return -c/b;
01128 }
01129 double D2 = b*b - 4.*a*c;
01130
01131 if (D2 > 0) {
01132 double s1 = (-b + sqrt(D2)) / (2.*a);
01133 double s2 = (-b - sqrt(D2)) / (2.*a);
01134 double solution = fabs(s1-sum)<fabs(s2-sum)?s1:s2;
01135 return solution;
01136 }
01137 else {
01138 return -1.;
01139 }
01140 }
01141
01142
01143
01144
01145
01146
01147 double CalcABCD
01148 (double I, double Fz, double FzP, double K, double ewk,
01149 double Na_, double Nb_, double Nc_, double Nd_ ,
01150 double Ea_, double Eb_, double Ec_, double Ed_)
01151 {
01152 double A, B, C;
01153 A = (1.0-I)*(FzP-K*Fz);
01154 B = I*(FzP+1.0)*(K*Fz*(Nc_-ewk*Ec_)-(Nd_-ewk*Ed_))+
01155 (1.0-I)*(1.0+Fz)*(K*(Na_-ewk*Ea_)-FzP*(Nb_-ewk*Eb_));
01156 C = I*(1.0+Fz)*(1.0+FzP)*((Nd_-ewk*Ed_)*(Nb_-ewk*Eb_)-
01157 K*(Na_-ewk*Ea_)*(Nc_-ewk*Ec_));
01158
01159 return Trionym(A, B, C, Na_+Nb_-Ea_-Eb_);
01160
01161 }