CMS 3D CMS Logo

Functions
offsetStack.cc File Reference
#include "TString.h"
#include "TFile.h"
#include "TProfile.h"
#include "TH1.h"
#include "THStack.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TLegend.h"
#include "TLatex.h"
#include <iostream>
#include <map>

Go to the source code of this file.

Functions

bool getHists (std::map< TString, TH1D *> &hists, TFile *&file, TString var, int var_val, float r)
 
int main (int argc, char *argv[])
 
void setStack (THStack *&stack, std::map< TString, TH1D *> &hists)
 
void setStyle ()
 
void split (const TString &str, TString &sub1, TString &sub2)
 

Function Documentation

◆ getHists()

bool getHists ( std::map< TString, TH1D *> &  hists,
TFile *&  file,
TString  var,
int  var_val,
float  r 
)

Definition at line 145 of file offsetStack.cc.

References gather_cfg::cout, geometryDiff::file, compare::hists, mps_fire::i, dqmiodumpmetadata::n, Skims_PA_cff::name, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, trigObjTnPSource_cfi::var, and fw3dlego::xbins.

Referenced by main().

145  {
146  for (auto& pair : hists) {
147  TString name = Form("p_offset_eta_%s%i_%s", var.Data(), var_val, pair.first.Data());
148  TProfile* p = (TProfile*)file->FindObjectAny(name);
149  if (!p) {
150  std::cout << "Could not find " + name << std::endl;
151  return false;
152  }
153  pair.second = p->ProjectionX(pair.first);
154  pair.second->Scale(r * r / 2 / var_val);
155 
156  const double* xbins = p->GetXaxis()->GetXbins()->GetArray();
157  for (int i = 1, n = p->GetNbinsX(); i <= n; i++) {
158  pair.second->SetBinContent(i, pair.second->GetBinContent(i) / (xbins[i] - xbins[i - 1]));
159  pair.second->SetBinError(i, pair.second->GetBinError(i) / (xbins[i] - xbins[i - 1]));
160  }
161  }
162  return true;
163 }
const double xbins[]

◆ main()

int main ( int  argc,
char *  argv[] 
)

===============================================================================================================================================================================================


variant2: for each run define phi-averaged A for normalization channel (Dref,16) and then, divide Rijk on it, i.e. get RRijk




















































































eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=29 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=28

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:





Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:





Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:





Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:


CALO JETS


PF JETS

Definition at line 19 of file offsetStack.cc.

References dir2webdir::argc, cmsBatch::argv, c, gather_cfg::cout, timingPdfMaker::file1, edmOneToOneComparison::file2, getHists(), h, label, HLT_2022v14_cff::label1, HLT_2022v14_cff::label2, alignmentValidation::outdir, alignCSCRings::r, setStack(), setStyle(), split(), submitPVValidationJobs::text, and trigObjTnPSource_cfi::var.

19  {
20  if (argc < 5) {
21  std::cout << "Please provide a label:filename, variable, deltaR value, and an out directory." << std::endl;
22  std::cout << "You may also include a second file at the end." << std::endl;
23  std::cout << "Example: offsetStack label1:file1.root npv 0.4 plots" << std::endl;
24  std::cout << "Example: offsetStack label1:file1.root npv 0.4 plots label2:file2.root" << std::endl;
25  return -1;
26  }
27 
28  TString label1, fname1;
29  split(argv[1], label1, fname1);
30  TString label = label1;
31 
32  TString var = argv[2];
33  float r = std::stof(argv[3]);
34  TString outdir = argv[4];
35 
36  TFile* file1 = TFile::Open(fname1);
37  if (!file1) {
38  std::cout << "Invalid file1: " << fname1 << std::endl;
39  return -1;
40  }
41 
42  TH1F* h = (TH1F*)file1->FindObjectAny(var);
43  if (!h) {
44  std::cout << "Could not find " + var + " hist" << std::endl;
45  return -1;
46  }
47  int avg = h->GetMean() + 0.5;
48 
49  std::map<TString, TH1D*> hists1 = {{"chm", 0}, {"chu", 0}, {"nh", 0}, {"ne", 0}, {"hfh", 0}, {"hfe", 0}, {"lep", 0}};
50  if (!getHists(hists1, file1, var, avg, r))
51  return -1;
52 
53  setStyle();
54  TCanvas c("c", "c", 600, 600);
55 
56  THStack* stack1 = new THStack(
57  "stack1", Form(";#eta;<Offset Energy_{T}(#pi%.1f^{2})>/<%s> [GeV]", r, var == "npv" ? "N_{PV}" : "#mu"));
58  setStack(stack1, hists1);
59  stack1->Draw("hist");
60  TString legPF = "F";
61 
62  TLegend* leg = new TLegend(.4, .67, .65, .92);
63 
64  //file2 included//
65  if (argc > 5) {
66  TString label2, fname2;
67  split(argv[5], label2, fname2);
68 
69  TFile* file2 = TFile::Open(fname2);
70  if (!file2) {
71  std::cout << "Invalid file2: " << fname2 << std::endl;
72  return -1;
73  }
74 
75  TH1F* h2 = (TH1F*)file2->FindObjectAny(var);
76  if (!h2) {
77  std::cout << "Could not find " + var + " hist in file2" << std::endl;
78  return -1;
79  }
80  int avg2 = h2->GetMean() + 0.5;
81 
82  std::map<TString, TH1D*> hists2 = hists1;
83  if (!getHists(hists2, file2, var, avg2, r))
84  return -1;
85 
86  THStack* stack2 = new THStack("stack2", "stack2");
87  setStack(stack2, hists2);
88  stack2->Draw("samepe");
89 
90  legPF = "PF";
91  leg->SetHeader(Form("#bf{Markers: %s, Histograms: %s}", label2.Data(), label1.Data()));
92  label = label1 + "_vs_" + label2;
93 
94  //Draw Markers for EM Deposits and Hadronic Deposits in two separate regions//
95  TH1D* hfe_clone = (TH1D*)hists2["hfe"]->Clone("hfe_clone");
96  TH1D* hfh_clone = (TH1D*)hists2["hfh"]->Clone("hfh_clone");
97 
98  THStack* cloneStack = new THStack("cloneStack", "cloneStack");
99  cloneStack->Add(hists2["ne"]);
100  cloneStack->Add(hfe_clone);
101  cloneStack->Add(hists2["nh"]);
102  cloneStack->Add(hfh_clone);
103  cloneStack->Draw("samepe");
104 
105  hists2["ne"]->SetAxisRange(-2.9, 2.9);
106  hists2["hfe"]->SetAxisRange(-5, -2.6);
107  hists2["nh"]->SetAxisRange(-2.9, 2.9);
108  hists2["hfh"]->SetAxisRange(-5, -2.6);
109  hists2["chu"]->SetAxisRange(-2.9, 2.9);
110  hists2["chm"]->SetAxisRange(-2.9, 2.9);
111 
112  hfe_clone->SetAxisRange(2.6, 5);
113  hfh_clone->SetAxisRange(2.6, 5);
114  }
115 
116  leg->SetBorderSize(0);
117  leg->SetFillColor(0);
118  leg->SetFillStyle(0);
119  leg->SetTextSize(0.04);
120  leg->SetTextFont(42);
121 
122  leg->AddEntry(hists1["ne"], "Photons", legPF);
123  leg->AddEntry(hists1["hfe"], "EM Deposits", legPF);
124  leg->AddEntry(hists1["nh"], "Neutral Hadrons", legPF);
125  leg->AddEntry(hists1["hfh"], "Hadronic Deposits", legPF);
126  leg->AddEntry(hists1["chu"], "Unassoc. Charged Hadrons", legPF);
127  leg->AddEntry(hists1["chm"], "Assoc. Charged Hadrons", legPF);
128 
129  leg->Draw();
130 
131  TLatex text;
132  text.SetNDC();
133 
134  text.SetTextSize(0.065);
135  text.SetTextFont(61);
136  text.DrawLatex(0.2, 0.87, "CMS");
137 
138  text.SetTextSize(0.045);
139  text.SetTextFont(42);
140  text.DrawLatex(1 - label.Length() / 41., 0.96, label);
141 
142  c.Print(outdir + "/stack_" + label + ".pdf");
143 }
void setStack(THStack *&stack, std::map< TString, TH1D *> &hists)
Definition: offsetStack.cc:187
char const * label
void split(const TString &str, TString &sub1, TString &sub2)
Definition: offsetStack.cc:217
bool getHists(std::map< TString, TH1D *> &hists, TFile *&file, TString var, int var_val, float r)
Definition: offsetStack.cc:145
void setStyle()
Definition: offsetStack.cc:165
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ setStack()

void setStack ( THStack *&  stack,
std::map< TString, TH1D *> &  hists 
)

Definition at line 187 of file offsetStack.cc.

References compare::hists, and svgfig::stack.

Referenced by main().

187  {
188  stack->Add(hists["ne"]);
189  stack->Add(hists["hfe"]);
190  stack->Add(hists["nh"]);
191  stack->Add(hists["hfh"]);
192  stack->Add(hists["chu"]);
193  stack->Add(hists["chm"]);
194 
195  hists["ne"]->SetMarkerStyle(kMultiply);
196  hists["hfe"]->SetMarkerStyle(kOpenStar);
197  hists["nh"]->SetMarkerStyle(kOpenDiamond);
198  hists["hfh"]->SetMarkerStyle(kOpenTriangleUp);
199  hists["chu"]->SetMarkerStyle(kOpenCircle);
200  hists["chm"]->SetMarkerStyle(kOpenCircle);
201 
202  hists["ne"]->SetFillColor(kBlue);
203  hists["hfe"]->SetFillColor(kViolet + 2);
204  hists["nh"]->SetFillColor(kGreen);
205  hists["hfh"]->SetFillColor(kPink + 6);
206  hists["chu"]->SetFillColor(kRed - 9);
207  hists["chm"]->SetFillColor(kRed);
208 
209  hists["ne"]->SetLineColor(kBlack);
210  hists["hfe"]->SetLineColor(kBlack);
211  hists["nh"]->SetLineColor(kBlack);
212  hists["hfh"]->SetLineColor(kBlack);
213  hists["chu"]->SetLineColor(kBlack);
214  hists["chm"]->SetLineColor(kBlack);
215 }
stack
Definition: svgfig.py:559

◆ setStyle()

void setStyle ( )

set the style for the printout

Definition at line 165 of file offsetStack.cc.

Referenced by main().

165  {
166  gStyle->SetPadTopMargin(0.05);
167  gStyle->SetPadBottomMargin(0.1);
168  gStyle->SetPadLeftMargin(0.16);
169  gStyle->SetPadRightMargin(0.02);
170 
171  gStyle->SetOptStat(0);
172  gStyle->SetOptTitle(0);
173 
174  gStyle->SetTitleFont(42, "XYZ");
175  gStyle->SetTitleSize(0.05, "XYZ");
176  gStyle->SetTitleXOffset(0.9);
177  gStyle->SetTitleYOffset(1.4);
178 
179  gStyle->SetLabelFont(42, "XYZ");
180  gStyle->SetLabelOffset(0.007, "XYZ");
181  gStyle->SetLabelSize(0.04, "XYZ");
182 
183  gStyle->SetPadTickX(1);
184  gStyle->SetPadTickY(1);
185 }

◆ split()

void split ( const TString &  str,
TString &  sub1,
TString &  sub2 
)

Definition at line 217 of file offsetStack.cc.

References str.

Referenced by main().

217  {
218  int pos = str.First(':');
219  sub1 = str(0, pos);
220  sub2 = str(pos + 1, str.Length());
221 }
#define str(s)