CMS 3D CMS Logo

Functions
multibsvspvplots.cc File Reference
#include "multibsvspvplots.h"
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include "TPad.h"
#include "TH1D.h"
#include "TFile.h"
#include "TH2F.h"
#include "TH1F.h"
#include "TF1.h"
#include "TProfile.h"
#include "TProfile2D.h"
#include "DPGAnalysis/SiStripTools/interface/CommonAnalyzer.h"
#include "TCanvas.h"
#include "TSystem.h"
#include "TStyle.h"
#include "TText.h"
#include "TLegend.h"

Go to the source code of this file.

Functions

void multibsvspvplots (const char *module, const char *label, const char *postfix, const char *)
 

Function Documentation

◆ multibsvspvplots()

void multibsvspvplots ( const char *  module,
const char *  label,
const char *  postfix,
const char *   
)

Definition at line 22 of file multibsvspvplots.cc.

22  {
23  TFile* file[5];
24 
25  file[0] = new TFile("rootfiles/Tracking_PFG_Run2012A_prompt_minbias_v1_190456-194076_muon_relumi_v55_fittedV0.root");
26  file[1] = new TFile("rootfiles/Tracking_PFG_Run2012B_prompt_minbias_v1_190456-196531_muon_relumi_v55_fittedV0.root");
27  file[2] = new TFile("rootfiles/Tracking_PFG_Run2012C_prompt_minbias_v1_190456-199011_muon_relumi_v55_fittedV0.root");
28  file[3] = new TFile("rootfiles/Tracking_PFG_Run2012C_prompt_minbias_v2_190456-203002_muon_relumi_v57_fittedV0.root");
29  file[4] = new TFile("rootfiles/Tracking_PFG_Run2012D_prompt_minbias_v1_190456-208686_muon_relumi_v57_fittedV0.root");
30 
31  char modfull[300];
32  sprintf(modfull, "%s%s", module, postfix);
33 
34  char labfull[300];
35  sprintf(labfull, "%s%s", label, postfix);
36 
37  // Summary histograms
38  TH1D* deltaxsum = new TH1D("deltaxsum", "(PV-BS) Fitted X position vs run", 10, 0., 10.);
39  deltaxsum->SetCanExtend(TH1::kAllAxes);
40  TH1D* deltaysum = new TH1D("deltaysum", "(PV-BS) Fitted Y position vs run", 10, 0., 10.);
41  deltaysum->SetCanExtend(TH1::kAllAxes);
42 
43  TH1D* deltaxmeansum = new TH1D("deltaxmeansum", "(PV-BS) Mean X position vs run", 10, 0., 10.);
44  deltaxmeansum->SetCanExtend(TH1::kAllAxes);
45  TH1D* deltaymeansum = new TH1D("deltaymeansum", "(PV-BS) Mean Y position vs run", 10, 0., 10.);
46  deltaymeansum->SetCanExtend(TH1::kAllAxes);
47 
48  TH1D* deltazmeansum = new TH1D("deltazmeansum", "(PV-BS) Mean Z position vs run", 10, 0., 10.);
49  deltazmeansum->SetCanExtend(TH1::kAllAxes);
50 
51  TF1* fdoubleg = new TF1("doubleg",
52  "[1]*exp(-0.5*((x-[0])/[2])**2)+[3]*exp(-0.5*((x-[0])/[4])**2)+[5]*exp(sqrt((x-[0])**2)*[6])",
53  -.2,
54  .2);
55  fdoubleg->SetLineColor(kRed);
56  fdoubleg->SetLineWidth(1);
57 
58  for (unsigned int ifile = 0; ifile < 5; ++ifile) {
59  CommonAnalyzer castat(file[ifile], "", modfull);
60 
61  std::vector<unsigned int> runs = castat.getRunList();
62  std::sort(runs.begin(), runs.end());
63 
64  {
65  std::cout << "Found " << runs.size() << " runs" << std::endl;
66 
67  for (unsigned int i = 0; i < runs.size(); ++i) {
68  char runlabel[100];
69  sprintf(runlabel, "%d", runs[i]);
70  char runpath[100];
71  sprintf(runpath, "run_%d", runs[i]);
72  castat.setPath(runpath);
73  std::cout << runpath << std::endl;
74 
75  TH1F* deltax = (TH1F*)castat.getObject("deltaxrun");
76  if (deltax && deltax->GetEntries() > 0) {
77  fdoubleg->SetParameter(0, deltax->GetMean());
78  fdoubleg->SetParameter(2, deltax->GetRMS());
79  fdoubleg->SetParameter(4, deltax->GetRMS());
80  fdoubleg->SetParameter(1, deltax->GetMaximum());
81  fdoubleg->SetParameter(3, 0.1 * deltax->GetMaximum());
82  fdoubleg->SetParameter(5, 0.1 * deltax->GetMaximum());
83  /* const int result = */ deltax->Fit(fdoubleg, "q0b", "", -.05, .05);
84 
85  int bin = deltaxsum->Fill(runlabel, fdoubleg->GetParameter(0));
86  deltaxsum->SetBinError(bin, fdoubleg->GetParError(0));
87 
88  bin = deltaxmeansum->Fill(runlabel, deltax->GetMean());
89  deltaxmeansum->SetBinError(bin, deltax->GetMeanError());
90  }
91  TH1F* deltay = (TH1F*)castat.getObject("deltayrun");
92  if (deltay && deltay->GetEntries() > 0) {
93  fdoubleg->SetParameter(0, deltay->GetMean());
94  fdoubleg->SetParameter(2, deltay->GetRMS());
95  fdoubleg->SetParameter(4, deltay->GetRMS());
96  fdoubleg->SetParameter(1, deltay->GetMaximum());
97  fdoubleg->SetParameter(3, 0.1 * deltay->GetMaximum());
98  fdoubleg->SetParameter(5, 0.1 * deltay->GetMaximum());
99  /* const int result = */ deltay->Fit(fdoubleg, "q0b", "", -.05, .05);
100  int bin = deltaysum->Fill(runlabel, fdoubleg->GetParameter(0));
101  deltaysum->SetBinError(bin, fdoubleg->GetParError(0));
102 
103  bin = deltaymeansum->Fill(runlabel, deltay->GetMean());
104  deltaymeansum->SetBinError(bin, deltay->GetMeanError());
105  }
106  TH1F* deltaz = (TH1F*)castat.getObject("deltazrun");
107  if (deltaz && deltaz->GetEntries() > 0) {
108  int bin = deltazmeansum->Fill(runlabel, deltaz->GetMean());
109  deltazmeansum->SetBinError(bin, deltaz->GetMeanError());
110  }
111  }
112  }
113  }
114 
115  std::string plotfilename;
116 
117  plotfilename = "/afs/cern.ch/cms/tracking/output/";
118  // plotfilename += dirname;
119  // plotfilename += "/";
120  // plotfilename += labfull;
121  plotfilename += "/deltaxsum_";
122  plotfilename += labfull;
123  // plotfilename += "_";
124  // plotfilename += dirname;
125  plotfilename += ".gif";
126 
127  /* TCanvas * cwidedeltax = */ new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
128 
129  deltaxsum->SetLineColor(kRed);
130  deltaxsum->SetMarkerColor(kRed);
131  deltaxsum->GetYaxis()->SetRangeUser(-.002, .002);
132  deltaxsum->GetYaxis()->SetTitle("#Delta x (cm)");
133  deltaxsum->Draw();
134  deltaxmeansum->Draw("esame");
135  TLegend deltaxleg(.7, .8, .85, .9, "#Delta(x)");
136  deltaxleg.AddEntry(deltaxsum, "fitted mean", "l");
137  deltaxleg.AddEntry(deltaxmeansum, "aritm. mean", "l");
138  deltaxleg.Draw();
139  gPad->Print(plotfilename.c_str());
140  // delete cwidedeltax;
141 
142  plotfilename = "/afs/cern.ch/cms/tracking/output/";
143  // plotfilename += dirname;
144  // plotfilename += "/";
145  // plotfilename += labfull;
146  plotfilename += "/deltaysum_";
147  plotfilename += labfull;
148  // plotfilename += "_";
149  // plotfilename += dirname;
150  plotfilename += ".gif";
151 
152  /* TCanvas * cwidedeltay = */ new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
153 
154  deltaysum->SetLineColor(kRed);
155  deltaysum->SetMarkerColor(kRed);
156  deltaysum->GetYaxis()->SetRangeUser(-.002, .002);
157  deltaysum->GetYaxis()->SetTitle("#Delta y (cm)");
158  deltaysum->Draw();
159  deltaymeansum->Draw("esame");
160  TLegend deltayleg(.7, .8, .85, .9, "#Delta(y)");
161  deltayleg.AddEntry(deltaysum, "fitted mean", "l");
162  deltayleg.AddEntry(deltaymeansum, "aritm. mean", "l");
163  deltayleg.Draw();
164  gPad->Print(plotfilename.c_str());
165  // delete cwidedeltay;
166 
167  plotfilename = "/afs/cern.ch/cms/tracking/output/";
168  // plotfilename += dirname;
169  // plotfilename += "/";
170  // plotfilename += labfull;
171  plotfilename += "/deltazsum_";
172  plotfilename += labfull;
173  // plotfilename += "_";
174  // plotfilename += dirname;
175  plotfilename += ".gif";
176 
177  /* TCanvas * cwidedeltaz = */ new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
178 
179  deltazmeansum->GetYaxis()->SetRangeUser(-2., 2.);
180  deltazmeansum->GetYaxis()->SetTitle("#Delta z (cm)");
181  deltazmeansum->Draw();
182  gPad->Print(plotfilename.c_str());
183  // delete cwidedeltaz;
184  /*
185  delete deltaxsum;
186  delete deltaysum;
187  delete deltaxmeansum;
188  delete deltaymeansum;
189  delete deltazmeansum;
190  */
191  delete fdoubleg;
192 }

References newFWLiteAna::bin, gather_cfg::cout, FrontierConditions_GlobalTag_cff::file, CommonAnalyzer::getObject(), CommonAnalyzer::getRunList(), mps_fire::i, compare_using_db::ifile, label, writedatasetfile::runs, CommonAnalyzer::setPath(), jetUpdater_cfi::sort, and AlCaHLTBitMon_QueryRunRegistry::string.

mps_fire.i
i
Definition: mps_fire.py:428
gather_cfg.cout
cout
Definition: gather_cfg.py:144
writedatasetfile.runs
runs
Definition: writedatasetfile.py:27
CommonAnalyzer
Definition: CommonAnalyzer.h:12
compare_using_db.ifile
ifile
Definition: compare_using_db.py:251
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
label
const char * label
Definition: PFTauDecayModeTools.cc:11