Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:28:06

0001 // *********************************************************************
0002 // To execute this macro under ROOT after your simulation ended,
0003 //   1 - launch ROOT (usually type 'root' at your machine's prompt)
0004 //   2 - type '.X plot.C' at the ROOT session prompt
0005 // *********************************************************************
0006 
0007 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address);
0008 
0009 void plot()
0010 {
0011   gROOT->Reset();
0012   gStyle->SetPalette(1);
0013   gROOT->SetStyle("Plain");
0014   TCanvas* c1 = new TCanvas ("c1","",20,20,500,500);
0015 
0016   c1->Divide(1,1);
0017 
0018   TFile* f = new TFile("spower.root");
0019 
0020   TNtuple* ntuple;
0021   ntuple = (TNtuple*)f->Get("track");
0022   bool rowWise = true;
0023   TBranch* eventBranch = ntuple->FindBranch("row_wise_branch");
0024   if ( ! eventBranch ) rowWise = false;
0025 
0026   c1->cd(1);
0027   gStyle->SetOptStat(000000);
0028   //gPad->SetLogx();
0029   gPad->SetLogy();
0030 
0031   ntuple->SetFillStyle(1001);
0032   ntuple->SetFillColor(2);
0033 
0034   TH1F *htmp = new TH1F("htmp", "Secondary electron energy distribution per incident primary", 100, 0, 1000);
0035 
0036   ntuple->Draw("kineticEnergy>>htmp","kineticEnergy<100000&&flagParticle==1","B");
0037 
0038   htmp->Scale (1./ntuple->GetEntries("trackID==1"));
0039   htmp->SetXTitle("Energy (eV)");
0040   htmp->Draw();
0041 }
0042 
0043 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address) {
0044   TLeaf* leaf = ntuple->FindLeaf(name);
0045   if ( ! leaf ) {
0046     std::cerr << "Error in <SetLeafAddress>: unknown leaf --> " << name << std::endl;
0047     return;
0048   }
0049   leaf->SetAddress(address);
0050 }