CMS 3D CMS Logo

TrackPlots.cc
Go to the documentation of this file.
1 #include "TrackPlots.h"
2 #include <vector>
3 #include <string>
4 #include <map>
5 #include "TPad.h"
6 #include "TFile.h"
7 #include "TH2F.h"
8 #include "TH1F.h"
9 #include "TF1.h"
10 #include "TProfile2D.h"
12 #include "TCanvas.h"
13 #include "TSystem.h"
14 #include "TStyle.h"
15 
16 void TrackPlots(const char* fullname,
17  const char* module,
18  const char* label,
19  const char* postfix,
20  const char* shortname,
21  const char* outtrunk) {
22  char modfull[300];
23  sprintf(modfull, "%s%s", module, postfix);
24  char labfull[300];
25  sprintf(labfull, "%s%s", label, postfix);
26 
27  // char fullname[300];
28  // sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
29 
30  TFile ff(fullname);
31 
32  // Colliding events
33 
34  CommonAnalyzer castat(&ff, "", modfull);
35 
36  TH1F* ntrk = (TH1F*)castat.getObject("ntrk");
37  if (ntrk) {
38  ntrk->Draw();
39  std::string plotfilename;
40  plotfilename += outtrunk;
41  plotfilename += shortname;
42  plotfilename += "/ntrk_";
43  plotfilename += labfull;
44  plotfilename += "_";
45  plotfilename += shortname;
46  plotfilename += ".gif";
47  gPad->Print(plotfilename.c_str());
48  delete ntrk;
49  }
50  TH1F* pt = (TH1F*)castat.getObject("pt");
51  if (pt) {
52  pt->Draw();
53  std::string plotfilename;
54  plotfilename += outtrunk;
55  plotfilename += shortname;
56  plotfilename += "/pt_";
57  plotfilename += labfull;
58  plotfilename += "_";
59  plotfilename += shortname;
60  plotfilename += ".gif";
61  gPad->SetLogy(1);
62  gPad->Print(plotfilename.c_str());
63  gPad->SetLogy(0);
64  delete pt;
65  }
66  gStyle->SetOptStat(11);
67  TProfile2D* ptphieta = (TProfile2D*)castat.getObject("ptphivseta");
68  if (ptphieta) {
69  ptphieta->Draw("colz");
70  std::string plotfilename;
71  plotfilename += outtrunk;
72  plotfilename += shortname;
73  plotfilename += "/ptphieta_";
74  plotfilename += labfull;
75  plotfilename += "_";
76  plotfilename += shortname;
77  plotfilename += ".gif";
78  gPad->Print(plotfilename.c_str());
79  delete ptphieta;
80  }
81  gStyle->SetOptStat(1111);
82  TH1F* phi = (TH1F*)castat.getObject("phi");
83  if (phi) {
84  phi->Draw();
85  std::string plotfilename;
86  plotfilename += outtrunk;
87  plotfilename += shortname;
88  plotfilename += "/phi_";
89  plotfilename += labfull;
90  plotfilename += "_";
91  plotfilename += shortname;
92  plotfilename += ".gif";
93  gPad->Print(plotfilename.c_str());
94  delete phi;
95  }
96  TH1F* eta = (TH1F*)castat.getObject("eta");
97  if (eta) {
98  eta->Draw();
99  std::string plotfilename;
100  plotfilename += outtrunk;
101  plotfilename += shortname;
102  plotfilename += "/eta_";
103  plotfilename += labfull;
104  plotfilename += "_";
105  plotfilename += shortname;
106  plotfilename += ".gif";
107  gPad->Print(plotfilename.c_str());
108  delete eta;
109  }
110  gStyle->SetOptStat(11);
111  TH2F* phieta = (TH2F*)castat.getObject("phivseta");
112  if (phieta) {
113  phieta->Draw("colz");
114  std::string plotfilename;
115  plotfilename += outtrunk;
116  plotfilename += shortname;
117  plotfilename += "/phieta_";
118  plotfilename += labfull;
119  plotfilename += "_";
120  plotfilename += shortname;
121  plotfilename += ".gif";
122  gPad->Print(plotfilename.c_str());
123  delete phieta;
124  gStyle->SetOptStat(1111);
125  }
126  TH1F* nrhits = (TH1F*)castat.getObject("nrhits");
127  if (nrhits) {
128  nrhits->Draw();
129  std::string plotfilename;
130  plotfilename += outtrunk;
131  plotfilename += shortname;
132  plotfilename += "/nrhits_";
133  plotfilename += labfull;
134  plotfilename += "_";
135  plotfilename += shortname;
136  plotfilename += ".gif";
137  gPad->Print(plotfilename.c_str());
138  delete nrhits;
139  }
140  gStyle->SetOptStat(11);
141  TProfile2D* nhitphieta = (TProfile2D*)castat.getObject("nhitphivseta");
142  if (nhitphieta) {
143  nhitphieta->Draw("colz");
144  std::string plotfilename;
145  plotfilename += outtrunk;
146  plotfilename += shortname;
147  plotfilename += "/nhitphieta_";
148  plotfilename += labfull;
149  plotfilename += "_";
150  plotfilename += shortname;
151  plotfilename += ".gif";
152  gPad->Print(plotfilename.c_str());
153  delete nhitphieta;
154  }
155  gStyle->SetOptStat(1111);
156  TH1F* nlosthits = (TH1F*)castat.getObject("nlosthits");
157  if (nlosthits) {
158  nlosthits->Draw();
159  std::string plotfilename;
160  plotfilename += outtrunk;
161  plotfilename += shortname;
162  plotfilename += "/nlosthits_";
163  plotfilename += labfull;
164  plotfilename += "_";
165  plotfilename += shortname;
166  plotfilename += ".gif";
167  gPad->Print(plotfilename.c_str());
168  delete nlosthits;
169  }
170  TH1F* npixelhits = (TH1F*)castat.getObject("npixelhits");
171  if (npixelhits) {
172  npixelhits->Draw();
173  std::string plotfilename;
174  plotfilename += outtrunk;
175  plotfilename += shortname;
176  plotfilename += "/npixelhits_";
177  plotfilename += labfull;
178  plotfilename += "_";
179  plotfilename += shortname;
180  plotfilename += ".gif";
181  gPad->Print(plotfilename.c_str());
182  delete npixelhits;
183  }
184  TH1F* nstriphits = (TH1F*)castat.getObject("nstriphits");
185  if (nstriphits) {
186  nstriphits->Draw();
187  std::string plotfilename;
188  plotfilename += outtrunk;
189  plotfilename += shortname;
190  plotfilename += "/nstriphits_";
191  plotfilename += labfull;
192  plotfilename += "_";
193  plotfilename += shortname;
194  plotfilename += ".gif";
195  gPad->Print(plotfilename.c_str());
196  delete nstriphits;
197  }
198  TH1F* nrlayers = (TH1F*)castat.getObject("nlayers");
199  if (nrlayers) {
200  nrlayers->Draw();
201  std::string plotfilename;
202  plotfilename += outtrunk;
203  plotfilename += shortname;
204  plotfilename += "/nrlayers_";
205  plotfilename += labfull;
206  plotfilename += "_";
207  plotfilename += shortname;
208  plotfilename += ".gif";
209  gPad->Print(plotfilename.c_str());
210  delete nrlayers;
211  }
212  gStyle->SetOptStat(11);
213  TProfile2D* nlayerphieta = (TProfile2D*)castat.getObject("nlayerphivseta");
214  if (nlayerphieta) {
215  nlayerphieta->Draw("colz");
216  std::string plotfilename;
217  plotfilename += outtrunk;
218  plotfilename += shortname;
219  plotfilename += "/nlayerphieta_";
220  plotfilename += labfull;
221  plotfilename += "_";
222  plotfilename += shortname;
223  plotfilename += ".gif";
224  gPad->Print(plotfilename.c_str());
225  delete nlayerphieta;
226  }
227  gStyle->SetOptStat(1111);
228  TH1F* nlostlayers = (TH1F*)castat.getObject("nlostlayers");
229  if (nlostlayers) {
230  nlostlayers->Draw();
231  std::string plotfilename;
232  plotfilename += outtrunk;
233  plotfilename += shortname;
234  plotfilename += "/nlostlayers_";
235  plotfilename += labfull;
236  plotfilename += "_";
237  plotfilename += shortname;
238  plotfilename += ".gif";
239  gPad->Print(plotfilename.c_str());
240  delete nlostlayers;
241  }
242  TH1F* npixellayers = (TH1F*)castat.getObject("npixellayers");
243  if (npixellayers) {
244  npixellayers->Draw();
245  std::string plotfilename;
246  plotfilename += outtrunk;
247  plotfilename += shortname;
248  plotfilename += "/npixellayers_";
249  plotfilename += labfull;
250  plotfilename += "_";
251  plotfilename += shortname;
252  plotfilename += ".gif";
253  gPad->Print(plotfilename.c_str());
254  delete npixellayers;
255  }
256  TH1F* nstriplayers = (TH1F*)castat.getObject("nstriplayers");
257  if (nstriplayers) {
258  nstriplayers->Draw();
259  std::string plotfilename;
260  plotfilename += outtrunk;
261  plotfilename += shortname;
262  plotfilename += "/nstriplayers_";
263  plotfilename += labfull;
264  plotfilename += "_";
265  plotfilename += shortname;
266  plotfilename += ".gif";
267  gPad->Print(plotfilename.c_str());
268  delete nstriplayers;
269  }
270  TH1F* hhpfrac = (TH1F*)castat.getObject("hhpfrac");
271  if (hhpfrac) {
272  hhpfrac->Draw();
273  std::string plotfilename;
274  plotfilename += outtrunk;
275  plotfilename += shortname;
276  plotfilename += "/hhpfrac_";
277  plotfilename += labfull;
278  plotfilename += "_";
279  plotfilename += shortname;
280  plotfilename += ".gif";
281  gPad->SetLogy(1);
282  gPad->Print(plotfilename.c_str());
283  gPad->SetLogy(0);
284  delete hhpfrac;
285  }
286  TH1F* halgo = (TH1F*)castat.getObject("algo");
287  if (halgo) {
288  halgo->Draw();
289  std::string plotfilename;
290  plotfilename += outtrunk;
291  plotfilename += shortname;
292  plotfilename += "/halgo_";
293  plotfilename += labfull;
294  plotfilename += "_";
295  plotfilename += shortname;
296  plotfilename += ".gif";
297  gPad->Print(plotfilename.c_str());
298  delete halgo;
299  }
300  gStyle->SetOptStat(111);
301  gStyle->SetOptFit(111);
302  TProfile* hntrkvslumi = (TProfile*)castat.getObject("ntrkvslumi");
303  if (hntrkvslumi && hntrkvslumi->GetEntries() > 0) {
304  // hntrkvslumi->Draw();
305  hntrkvslumi->Fit("pol2", "", "", 0.5, 3.0);
306  if (hntrkvslumi->GetFunction("pol2")) {
307  hntrkvslumi->GetFunction("pol2")->SetLineColor(kBlack);
308  hntrkvslumi->GetFunction("pol2")->SetLineWidth(1);
309  }
310  std::string plotfilename;
311  plotfilename += outtrunk;
312  plotfilename += shortname;
313  plotfilename += "/hntrkvslumi_";
314  plotfilename += labfull;
315  plotfilename += "_";
316  plotfilename += shortname;
317  plotfilename += ".gif";
318  gPad->Print(plotfilename.c_str());
319  }
320  gStyle->SetOptStat(1111);
321 
322  TH2D* hntrkvslumi2D = (TH2D*)castat.getObject("ntrkvslumi2D");
323  if (hntrkvslumi2D && hntrkvslumi2D->GetEntries() > 0) {
324  hntrkvslumi2D->Draw("colz");
325  if (hntrkvslumi) {
326  hntrkvslumi->SetMarkerStyle(20);
327  hntrkvslumi->SetMarkerSize(.3);
328  hntrkvslumi->Draw("same");
329  }
330  std::string plotfilename;
331  plotfilename += outtrunk;
332  plotfilename += shortname;
333  plotfilename += "/hntrkvslumi2D_";
334  plotfilename += labfull;
335  plotfilename += "_";
336  plotfilename += shortname;
337  plotfilename += ".gif";
338  gPad->SetLogz(1);
339  gPad->Print(plotfilename.c_str());
340  gPad->SetLogz(0);
341  delete hntrkvslumi2D;
342  }
343  delete hntrkvslumi;
344 }
TrackPlots.h
CommonAnalyzer.h
CommonAnalyzer::getObject
TObject * getObject(const char *name) const
Definition: CommonAnalyzer.cc:42
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
CommonAnalyzer
Definition: CommonAnalyzer.h:12
PVValHelper::eta
Definition: PVValidationHelpers.h:70
alignCSCRings.ff
ff
Definition: alignCSCRings.py:148
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PVValHelper::phi
Definition: PVValidationHelpers.h:69
TrackPlots
void TrackPlots(const char *fullname, const char *module, const char *label, const char *postfix, const char *shortname, const char *outtrunk)
Definition: TrackPlots.cc:16
label
const char * label
Definition: PFTauDecayModeTools.cc:11