void DrawClovers(const char* filename = "outputs/Nov14_17_19.root", Bool_t drawCrystals = 1) { TFile* file = TFile::Open(filename); if (!file || file->IsZombie()) { std::cerr << "Error: Could not open file " << filename << std::endl; return; } const int nCanvases = 11; const int nPerCanvas = 6; // ROOT color codes: Blue=4, Black=1, Green=3, Red=2, Violet=6 const int colors[nPerCanvas] = {4, 1, 3, 2, 6, 30}; if (drawCrystals == true){ for (int i = 0; i < nCanvases; ++i) { TString canvasName = Form("canvas%d", i); TCanvas* c = new TCanvas(canvasName, canvasName, 1200, 800); c->Divide(1, nPerCanvas); for (int j = 0; j < nPerCanvas; ++j) { c->cd(j + 1); TH1F* hist = nullptr; TString histName; if (j < 4) { int index = i * 4 + j; histName = Form("CompSupCalGeEnergy%02d", index); } else if (j==5) { histName = Form("AddBackGeEnergy%02d", i); }else{ histName = Form("SummedCloverCalGeEnergy%02d", i); } std::cout << "Trying to load histogram: " << histName << std::endl; hist = dynamic_cast(file->Get(histName)); if (hist) { hist->SetTitle(histName); // Optional hist->SetLineColor(colors[j]); hist->Draw(); } else { std::cerr << "Missing histogram: " << histName << std::endl; } } c->Update(); } }else{ const int nPerCanvas2 = 2; const int colors2[nPerCanvas2] = {6, 30}; for (int i = 0; i < nCanvases; ++i) { TString canvasName = Form("canvas%d", i); TCanvas* c = new TCanvas(canvasName, canvasName, 1200, 800); c->Divide(1, nPerCanvas2); for (int j = 0; j < nPerCanvas2; ++j) { c->cd(j + 1); TH1F* hist = nullptr; TString histName; if (j == 0) { histName = Form("SummedCloverCalGeEnergy%02d", i); }else{ histName = Form("AddBackGeEnergy%02d", i); } std::cout << "Trying to load histogram: " << histName << std::endl; hist = dynamic_cast(file->Get(histName)); if (hist) { hist->SetTitle(histName); // Optional hist->SetLineColor(colors2[j]); hist->Draw(); } else { std::cerr << "Missing histogram: " << histName << std::endl; } } c->Update(); } } }