File indexing completed on 2023-03-17 11:24:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <TCanvas.h>
0024 #include <TChain.h>
0025 #include <TFile.h>
0026 #include <TFitResult.h>
0027 #include <TFitResultPtr.h>
0028 #include <TGraphAsymmErrors.h>
0029 #include <TH1D.h>
0030 #include <TH2D.h>
0031 #include <TLegend.h>
0032 #include <TPaveStats.h>
0033 #include <TPaveText.h>
0034 #include <TProfile.h>
0035 #include <TROOT.h>
0036 #include <TStyle.h>
0037
0038 #include <fstream>
0039 #include <iomanip>
0040 #include <iostream>
0041 #include <string>
0042 #include <vector>
0043
0044 void makeLayerPlots(std::string fname = "hfnSimHitD94tt.root",
0045 int type = 0,
0046 int todomin = 0,
0047 int todomax = 7,
0048 std::string tag = "",
0049 std::string text = "",
0050 bool save = false) {
0051 std::string dirnm[3] = {"hgcalSimHitStudy", "hfnoseDigiStudy", "hfnoseRecHitStudy"};
0052 std::string units[3] = {" (mm)", " (cm)", " (cm)"};
0053 std::string titlx[3] = {"SimHit", "Digi", "RecHit"};
0054
0055 gStyle->SetCanvasBorderMode(0);
0056 gStyle->SetCanvasColor(kWhite);
0057 gStyle->SetPadColor(kWhite);
0058 gStyle->SetOptStat(0);
0059 if (type < 0 || type > 2)
0060 type = 0;
0061 TFile *file = new TFile(fname.c_str());
0062 if (file) {
0063 TDirectory *dir = (TDirectory *)file->FindObjectAny(dirnm[type].c_str());
0064 char cname[100], name[100], title[100], xtitl[100], ytitl[100];
0065 for (int i = todomin; i <= todomax; ++i) {
0066 if (i < 0) {
0067 sprintf(name, "RZ_HGCalHFNoseSensitive");
0068 sprintf(title, "%s (%s)", text.c_str(), titlx[type].c_str());
0069 sprintf(xtitl, "z %s", units[type].c_str());
0070 sprintf(ytitl, "R %s", units[type].c_str());
0071 } else {
0072 sprintf(name, "XY_L%d", i + 1);
0073 sprintf(title, "%s (Layer %d %s)", text.c_str(), i + 1, titlx[type].c_str());
0074 sprintf(xtitl, "x %s", units[type].c_str());
0075 sprintf(ytitl, "y %s", units[type].c_str());
0076 }
0077 TH2D *hist = (TH2D *)dir->FindObjectAny(name);
0078 std::cout << name << " read out at " << hist << std::endl;
0079 if (hist != nullptr) {
0080 sprintf(cname, "%s%s", name, tag.c_str());
0081 TCanvas *pad = new TCanvas(cname, cname, 500, 500);
0082 pad->SetRightMargin(0.10);
0083 pad->SetTopMargin(0.10);
0084 hist->GetYaxis()->SetTitleOffset(1.2);
0085 hist->GetYaxis()->SetTitle(ytitl);
0086 hist->GetXaxis()->SetTitle(xtitl);
0087 hist->SetTitle(title);
0088 if (i < 0 && type == 0)
0089 hist->GetXaxis()->SetNdivisions(5);
0090 hist->Draw("colz");
0091 pad->Modified();
0092 pad->Update();
0093 if (save) {
0094 sprintf(name, "c_%s.jpg", pad->GetName());
0095 pad->Print(name);
0096 }
0097 }
0098 }
0099 }
0100 }