File indexing completed on 2024-04-06 12:26:32
0001 #include "TH1F.h"
0002 #include "TCanvas.h"
0003 #include "TObject.h"
0004 #include "TFile.h"
0005 #include "TPaveStats.h"
0006 #include "TGraphErrors.h"
0007 #include "TGaxis.h"
0008 #include "TROOT.h"
0009 #include "TF1.h"
0010 #include "TLegend.h"
0011 #include "TKey.h"
0012 #include "TClass.h"
0013 #include "iostream"
0014 #include "vector"
0015 #include "math.h"
0016 #include "map"
0017
0018 void displayBaselineMacro_2types(TString file, const int limit = 20) {
0019 TFile* f;
0020 TString BaseDir;
0021 TString dir[6];
0022 TString fullPath, title, subDet, genSubDet;
0023 TCanvas* C;
0024 C = new TCanvas();
0025 f = new TFile(file);
0026
0027
0028 dir[0] = "baselineAna/ProcessedRawDigis";
0029 dir[1] = "baselineAna/Baseline";
0030 dir[2] = "baselineAna/Clusters";
0031 dir[3] = "baselineAna/RawDigis";
0032 dir[4] = "moddedbaselineAna/Baseline";
0033 dir[5] = "moddedbaselineAna/Clusters";
0034 f->cd();
0035
0036
0037 f->cd(dir[0]);
0038
0039 TIter nextkey(gDirectory->GetListOfKeys());
0040 TKey* key;
0041 int objcounter = 1;
0042 int histolimit = 0;
0043 while ((key = (TKey*)nextkey())) {
0044 if (histolimit < limit) {
0045 histolimit++;
0046 std::cout << histolimit << " " << limit << std::endl;
0047 TObject* obj = key->ReadObj();
0048
0049 if (obj->IsA()->InheritsFrom("TH1")) {
0050 std::cout << "Found object n: " << objcounter << " Name: " << obj->GetName() << " Title: " << obj->GetTitle()
0051 << std::endl;
0052 ++objcounter;
0053
0054
0055
0056 C->Clear();
0057 TH1F* h = (TH1F*)key->ReadObj();
0058
0059
0060
0061
0062 h->SetLineColor(kBlack);
0063 h->SetLineWidth(1);
0064 h->SetXTitle("StripNumber");
0065 h->SetYTitle("Charge (ADC counts)");
0066 h->Draw("hist p l");
0067 h->SetStats(0);
0068
0069
0070 f->cd();
0071
0072 TH1F* hb = (TH1F*)f->Get(dir[1] + "/" + obj->GetName());
0073
0074 if (hb != 0) {
0075 hb->SetLineWidth(2);
0076 hb->SetLineStyle(1);
0077 hb->SetLineColor(kRed);
0078
0079 hb->Draw("hist p l same");
0080 }
0081
0082 f->cd();
0083
0084 TH1F* hc = (TH1F*)f->Get(dir[2] + "/" + obj->GetName());
0085 TH1F* offset = (TH1F*)hc->Clone("offset");
0086 offset->Reset();
0087 for (int i = 0; i < offset->GetSize(); i++)
0088 offset->SetBinContent(i, -300);
0089 hc->Add(offset);
0090 if (hc != 0) {
0091 hc->SetLineWidth(1);
0092 hc->SetLineStyle(1);
0093 hc->SetLineColor(kViolet);
0094
0095 hc->Draw("hist p l same");
0096 }
0097 TH1F* hd = (TH1F*)f->Get(dir[3] + "/" + obj->GetName());
0098
0099 if (hd != 0) {
0100 hd->SetLineWidth(1);
0101 hd->SetLineStyle(1);
0102 hd->SetLineColor(kGray);
0103 hd->SetMarkerColor(kGray);
0104
0105 hd->Draw("hist p l same");
0106 h->Draw("hist p l same");
0107 hb->Draw("hist p l same");
0108 hc->Draw("hist p l same");
0109 }
0110
0111 TH1F* he = (TH1F*)f->Get(dir[4] + "/" + obj->GetName());
0112 if (he != 0) {
0113 he->SetLineWidth(2);
0114 he->SetLineStyle(2);
0115 he->SetMarkerSize(-1);
0116 he->SetLineColor(kGreen);
0117
0118 he->Draw("hist l same");
0119 }
0120
0121 TH1F* hf = (TH1F*)f->Get(dir[5] + "/" + obj->GetName());
0122 TH1F* offset2 = (TH1F*)hf->Clone("offset2");
0123 offset2->Reset();
0124 for (int i = 0; i < offset2->GetSize(); i++)
0125 offset2->SetBinContent(i, -300);
0126 hf->Add(offset2);
0127 if (hf != 0) {
0128 hf->SetLineWidth(1);
0129 hf->SetLineStyle(1);
0130 hf->SetMarkerSize(-1);
0131 hf->SetLineColor(kBlue);
0132
0133 hf->Draw("hist l same");
0134 }
0135
0136
0137
0138
0139
0140 C->Update();
0141
0142
0143
0144 C->SaveAs(TString("img/") + obj->GetName() + TString(".png"));
0145 }
0146 }
0147 }
0148 }
0149
0150 void displayClusters(TString file) {
0151 TFile* f = new TFile(file, "read");
0152 TH1F* h1[5];
0153 TH1F* h2[5];
0154 h1[0] = (TH1F*)f->Get("baselineAna/ClusterMult");
0155 h2[0] = (TH1F*)f->Get("moddedbaselineAna/ClusterMult");
0156 h1[1] = (TH1F*)f->Get("baselineAna/ClusterCharge");
0157 h2[1] = (TH1F*)f->Get("moddedbaselineAna/ClusterCharge");
0158 h1[2] = (TH1F*)f->Get("baselineAna/ClusterWidth");
0159 h2[2] = (TH1F*)f->Get("moddedbaselineAna/ClusterWidth");
0160
0161 TCanvas* c1 = new TCanvas("c1", "c1", 800, 800);
0162 h1[0]->SetLineColor(kRed);
0163 h2[0]->SetLineColor(kBlue);
0164 h1[0]->GetYaxis()->SetTitle("nEvents");
0165 h1[0]->GetXaxis()->SetTitle("nClusters");
0166 c1->SetLogx();
0167
0168 h1[0]->SetStats(0);
0169 h1[0]->Draw();
0170 h2[0]->Draw("same");
0171 c1->SaveAs("img/ClusterMultComparison.png");
0172 c1->SaveAs("img/ClusterMultComparison.pdf");
0173
0174 c1->Clear();
0175 h1[1]->SetLineColor(kRed);
0176 h2[1]->SetLineColor(kBlue);
0177 h2[1]->GetYaxis()->SetTitle("nClusters");
0178 h2[1]->GetXaxis()->SetTitle("Cluster Charge");
0179 h2[1]->GetXaxis()->SetRangeUser(0, 10000);
0180 c1->SetLogy();
0181 h2[1]->SetStats(0);
0182 h2[1]->Draw();
0183 h1[1]->Draw("same");
0184 c1->SaveAs("img/ClusterChargeComparison.png");
0185 c1->SaveAs("img/ClusterChargeComparison.pdf");
0186
0187 c1->Clear();
0188 h1[2]->SetLineColor(kRed);
0189 h2[2]->SetLineColor(kBlue);
0190 h2[2]->GetYaxis()->SetTitle("nClusters");
0191 h2[2]->GetXaxis()->SetTitle("Cluster Width");
0192 h2[2]->GetXaxis()->SetRangeUser(0, 80);
0193 c1->SetLogx(0);
0194 h2[2]->SetStats(0);
0195 h2[2]->Draw();
0196 h1[2]->Draw("same");
0197 c1->SaveAs("img/ClusterWidthComparison.png");
0198 c1->SaveAs("img/ClusterWidthComparison.pdf");
0199 }