Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-18 09:16:46

0001 // $Id: $                                                                                             
0002 
0003 /*!
0004  * \file ExampleAnalysisModulePlot.C
0005  * \brief // this macro is part of analysis tutorial: https://wiki.bnl.gov/sPHENIX/index.php/2017_calorimeter_beam_test/Tutorial#Level_2:_formal_analysis_via_analysis_module
0006  * \author Jin Huang <jhuang@bnl.gov>
0007  * \version $Revision:   $
0008  * \date $Date: $
0009  */
0010 
0011 #include <cmath>
0012 #include <TFile.h>
0013 #include <TString.h>
0014 #include <TLine.h>
0015 #include <TTree.h>
0016 #include <TLatex.h>
0017 #include <TGraphErrors.h>
0018 #include <cassert>
0019 using namespace std;
0020 
0021 void
0022 ExampleAnalysisModulePlot(
0023 
0024 )
0025 {
0026   // assuming you compiled the analysis module defined in ../ExampleAnalysisModule/
0027   gSystem->Load("libProto3_ExampleAnalysisModule.so");
0028 
0029   // assuming you already run Fun4All_TestBeam_ExampleAnalysisModule.C
0030   TFile * file = TFile::Open("ExampleAnalysis.root");
0031 
0032   // Now you have a TTree called T accessible in your command line. Nevertheless, let's get it to use programtically.
0033   assert(file);
0034   TTree* T = (TTree *) file->GetObjectChecked("T", "TTree");
0035   assert(T);
0036 
0037   // internal plots in analysis module checking events and cuts
0038   TH1F* hNormalization = (TH1F *) file->GetObjectChecked("hNormalization",
0039       "TH1F");
0040   assert(hNormalization);
0041 
0042   // internal plots in analysis module checking cherenkov signals
0043   TH2F* hCheck_Cherenkov = (TH2F *) file->GetObjectChecked("hCheck_Cherenkov",
0044       "TH2F");
0045   assert(hCheck_Cherenkov);
0046 
0047   // Now make the plots
0048   TText * t;
0049   TCanvas *c1 = new TCanvas("ExampleAnalysisModulePlot",
0050       "ExampleAnalysisModulePlot", 1200, 1000);
0051   c1->Divide(2, 2);
0052   int idx = 1;
0053   TPad * p;
0054 
0055   c1->Update();
0056   p = (TPad *) c1->cd(idx++);
0057   p->SetLogy();
0058 
0059   hNormalization->Draw();
0060 
0061   c1->Update();
0062   p = (TPad *) c1->cd(idx++);
0063   p->SetLogz();
0064 
0065   hCheck_Cherenkov->Draw("colz");
0066 
0067   c1->Update();
0068   p = (TPad *) c1->cd(idx++);
0069   p->SetLogy();
0070 
0071   T->Draw("clus_5x5_CEMC.sum_E>>hEnergy_Sum_CEMC(400,0,20)", "info.good_anti_e",
0072       "");
0073   T->Draw("clus_5x5_CEMC.sum_E>>hEnergy_Sum_CEMC_C(400,0,20)", "info.good_e",
0074       "same");
0075   hEnergy_Sum_CEMC->SetTitle(
0076       "EMCal 5x5 cluster, anti-e cut (blue) and electron cut (green);EMCal 5x5 cluster Energy (GeV)");
0077   hEnergy_Sum_CEMC_C->SetLineColor(kGreen + 2);
0078   hEnergy_Sum_CEMC_C->SetFillColor(kGreen);
0079 
0080   c1->Update();
0081   p = (TPad *) c1->cd(idx++);
0082   p->SetLogy();
0083 
0084   T->Draw(
0085       "info.sum_E_CEMC + info.sum_E_HCAL_IN + info.sum_E_HCAL_OUT>>hEnergy_Sum(400,0,20)",
0086       "info.good_anti_e", "");
0087   hEnergy_Sum->SetTitle(
0088       "All three calorimeter energy with anti-e cut (hadron + muon);Energy Sum (GeV)");
0089 
0090 }
0091