CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
PlotCombiner.cc File Reference
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "TString.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TH1F.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TLegend.h"

Go to the source code of this file.

Functions

void PlotCombiner ()
 
void plotMaker (TString histoName, TString typeOfplot, vector< TString > file, vector< TString > type, vector< double > weight, TString xtitle, Int_t NBins, Double_t min, Double_t max)
 

Function Documentation

void PlotCombiner ( )

Definition at line 81 of file PlotCombiner.cc.

References EnergyCorrector::c, gather_cfg::cout, relativeConstraints::empty, MainPageGenerator::files, alignmentValidation::fname, i, input, j, geometryCSVtoXML::line, plotMaker(), AlCaHLTBitMon_QueryRunRegistry::string, w, and create_public_pileup_plots::weights.

82 {
83  // read the file
84  ifstream input("inputFiles");
85  int i = 0;
86  TString typeOfplot = "";
87  vector<TString> types;
88  vector<TString> files;
89  vector<double> weights;
90 
91  if (input.is_open()) {
92  std::string myline;
93  while (! input.eof()) {
94  getline(input, myline);
95  TString line(myline);
96  TString c('#');
97  TString empty(' ');
98  if (line[0] != c) {
99  ++i;
100  if (i==1) typeOfplot=line;
101  else {
102  // read until you find 3 words
103  TString fname("");
104  TString ftype("");
105  TString fw("");
106  int lineSize = (int) line.Length();
107  int j=0;
108  while (j<lineSize) {
109  if(line[j] != empty) fname += line[j];
110  else break;
111  ++j;
112  }
113  while (j<lineSize) {
114  if(line[j] != empty) ftype += line[j];
115  else if(ftype.Length()==3) break;
116  ++j;
117  }
118  while (j<lineSize) {
119  if(line[j] != empty) fw += line[j];
120  else{ if(fw.Length()>0) break;}
121  ++j;
122  }
123  if (fname.Length() == 0) break;
124  files.push_back(fname);
125  types.push_back(ftype);
126  double w = fw.Atof();
127  weights.push_back(w);
128  std::cout << fname << ", " << ftype << ", "<< w << std::endl;
129  }
130  }
131  }
132  input.close();
133  }
134  else {
135  std::cout << "File with name inputFile was not found" << std::endl;
136  return;
137  }
138 
139  // now you can launch the jobs
140  if (typeOfplot == "wenu") {
141  cout << "wenu plot maker" << endl;
142  // ====================
143  // =====> WHICH HISTOS TO PLOT
144  // ====================
145  plotMaker("h_met", typeOfplot, files, types, weights, "MET (GeV)", 100,0,100);
146  }
147  else {
148  cout << "zee plot maker" << endl;
149  // ====================
150  // =====> WHICH HISTOS TO PLOT
151  // ====================
152  plotMaker("h_mee", typeOfplot, files, types, weights, "M_{ee} (GeV)", 150,0,150);
153  }
154 
155 
156 }
int i
Definition: DBlmapReader.cc:9
void plotMaker(TString histoName, TString typeOfplot, vector< TString > file, vector< TString > type, vector< double > weight, TString xtitle)
const double w
Definition: UKUtility.cc:23
static std::string const input
Definition: EdmProvDump.cc:43
int j
Definition: DBlmapReader.cc:9
string fname
main script
tuple cout
Definition: gather_cfg.py:121
void plotMaker ( TString  histoName,
TString  typeOfplot,
vector< TString >  file,
vector< TString >  type,
vector< double >  weight,
TString  xtitle,
Int_t  NBins,
Double_t  min,
Double_t  max 
)

Definition at line 160 of file PlotCombiner.cc.

References EnergyCorrector::c, f, h, i, and create_public_lumi_plots::leg.

164 {
165  gROOT->Reset();
166  gROOT->ProcessLine(".L tdrstyle.C");
167  gROOT->ProcessLine("setTDRStyle()");
168 
169  // Wenu Signal .......................................................
170  TH1F h_wenu("h_wenu", "h_wenu", NBins, min, max);
171  int fmax = (int) file.size();
172  for (int i=0; i<fmax; ++i) {
173  if (type[i] == "sig" && weight[i]>0) {
174  TFile f(file[i]);
175  TH1F *h = (TH1F*) f.Get(histoName);
176  h_wenu.Add(h, weight[i]);
177  }
178  }
179  // Bkgs ..............................................................
180  //
181  // QCD light flavor
182  TH1F h_qcd("h_qcd", "h_qcd", NBins, min, max);
183  for (int i=0; i<fmax; ++i) {
184  if (type[i] == "qcd" && weight[i]>0) {
185  TFile f(file[i]);
186  TH1F *h = (TH1F*) f.Get(histoName);
187  h_qcd.Add(h, weight[i]);
188  }
189  }
190  // QCD heavy flavor
191  TH1F h_bce("h_bce", "h_bce", NBins, min, max);
192  for (int i=0; i<fmax; ++i) {
193  if (type[i] == "bce" && weight[i]>0) {
194  TFile f(file[i]);
195  TH1F *h = (TH1F*) f.Get(histoName);
196  h_bce.Add(h, weight[i]);
197  }
198  }
199  // QCD Gjets
200  TH1F h_gj("h_gj", "h_gj", NBins, min, max);
201  for (int i=0; i<fmax; ++i) {
202  if (type[i] == "gje" && weight[i]>0) {
203  TFile f(file[i]);
204  TH1F *h = (TH1F*) f.Get(histoName);
205  h_gj.Add(h, weight[i]);
206  }
207  }
208  // Other EWK bkgs
209  TH1F h_ewk("h_ewk", "h_ewk", NBins, min, max);
210  for (int i=0; i<fmax; ++i) {
211  if (type[i] == "ewk" && weight[i]>0) {
212  TFile f(file[i]);
213  TH1F *h = (TH1F*) f.Get(histoName);
214  h_ewk.Add(h, weight[i]);
215  }
216  }
217  //
218  // ok now decide how to plot them:
219  // first the EWK bkgs
220  h_ewk.SetFillColor(3);
221  //
222  // then the gjets
223  h_gj.Add(&h_ewk);
224  h_gj.SetFillColor(1);
225  // thent the QCD dijets
226  h_bce.Add(&h_qcd);
227  h_bce.Add(&h_gj);
228  h_bce.SetFillColor(2);
229  // and the signal at last
230  TH1F h_tot("h_tot", "h_tot", NBins, min, max);
231  h_tot.Add(&h_bce);
232  h_tot.Add(&h_wenu);
233  h_wenu.SetLineColor(4); h_wenu.SetLineWidth(2);
234  //
235  TCanvas c;
236  h_tot.GetXaxis()->SetTitle(xtitle);
237  h_tot.Draw("PE");
238  h_bce.Draw("same");
239  h_gj.Draw("same");
240  h_ewk.Draw("same");
241  h_wenu.Draw("same");
242 
243  // the Legend
244  TLegend leg(0.6,0.65,0.95,0.92);
245  if (wzsignal == "wenu")
246  leg.AddEntry(&h_wenu, "W#rightarrow e#nu","l");
247  else
248  leg.AddEntry(&h_wenu, "Z#rightarrow ee","l");
249  leg.AddEntry(&h_tot, "Signal + Bkg","p");
250  leg.AddEntry(&h_bce, "dijets","f");
251  leg.AddEntry(&h_gj, "#gamma + jets","f");
252  leg.AddEntry(&h_ewk, "EWK+t#bar t", "f");
253  leg.Draw("same");
254 
255  c.Print("test.png");
256 
257 
258 
259 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
double f[11][100]
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
T min(T a, T b)
Definition: MathUtil.h:58