Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:27:52

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 plotElastic()
0010 {
0011   gROOT->Reset();
0012 
0013   gStyle->SetOptStat(0);
0014   gStyle->SetOptTitle(0);
0015   gStyle->SetCanvasColor(0);
0016   gStyle->SetPadColor(0);
0017   gStyle->SetFrameFillColor(0);
0018   gStyle->SetPadGridX(false);
0019   gStyle->SetPadGridY(false);
0020   gStyle->SetGridColor(kGray+1);
0021   gStyle->SetLabelFont(42, "XYZ");
0022   gStyle->SetTitleFont(42, "XYZ");
0023   gStyle->SetLabelSize(0.045, "XYZ");
0024   gStyle->SetTitleSize(0.05, "XYZ");
0025   gStyle->SetTitleOffset(1.2, "Y");
0026   gStyle->SetPadTickX(1);
0027   gStyle->SetPadTickY(1);
0028   gStyle->SetLineWidth(2);
0029   gStyle->SetMarkerStyle(20);
0030   gStyle->SetMarkerSize(1.2);
0031   gStyle->SetLegendBorderSize(0);
0032   gStyle->SetLegendFont(42);
0033   gStyle->SetOptStat(000000);
0034 
0035   TCanvas* c1 = new TCanvas ("c1","",20,20,1500,500);
0036   c1->Divide(3,1);
0037 
0038   TFile* f = new TFile("dna.root");
0039 
0040   TNtuple* ntuple2;
0041   ntuple2 = (TNtuple*)f->Get("step");
0042   bool rowWise2 = true;
0043   TBranch* eventBranch2 = ntuple2->FindBranch("row_wise_branch");
0044   if ( ! eventBranch2 ) rowWise2 = false;
0045 
0046   // Cosine plot
0047 
0048   c1->cd(1);
0049   gPad->SetLogy();
0050 
0051   ntuple2->SetFillStyle(1001);
0052   ntuple2->SetFillColor(2);
0053   ntuple2->Draw
0054    ("(cosTheta)","parentID==0&&trackID==1&&stepID==1","");
0055 
0056   TH1* hist = (TH1*)gPad->GetPrimitive("htemp");
0057   hist->GetXaxis()->SetLabelSize(0.03);
0058   hist->GetYaxis()->SetLabelSize(0.03);
0059   hist->GetXaxis()->SetTitleSize(0.03);
0060   hist->GetYaxis()->SetTitleSize(0.03);
0061   hist->GetXaxis()->SetTitleOffset(1.4);
0062   hist->GetYaxis()->SetTitleOffset(1.8);
0063   hist->GetXaxis()->CenterTitle();
0064   hist->GetYaxis()->CenterTitle();
0065   hist->GetXaxis()->SetTitle("cos(#theta)");
0066   hist->GetYaxis()->SetTitle("");
0067   gPad->SetLogy();
0068   gPad->SetTicks(1, 1);
0069   gPad->Modified();
0070 
0071   // Solid angle (Omega) plot
0072   // (as in dsigma/dOmega vs Omega diff. cross section plots)
0073 
0074   c1->cd(2);
0075   gPad->SetLogy();
0076   ntuple2->Draw
0077    ("2*3.1415926535*(1-cosTheta)","parentID==0&&trackID==1&&stepID==1","");
0078 
0079   TH1* hist2 = (TH1*)gPad->GetPrimitive("htemp");
0080   hist2->GetXaxis()->SetLabelSize(0.03);
0081   hist2->GetYaxis()->SetLabelSize(0.03);
0082   hist2->GetXaxis()->SetTitleSize(0.03);
0083   hist2->GetYaxis()->SetTitleSize(0.03);
0084   hist2->GetXaxis()->SetTitleOffset(1.4);
0085   hist2->GetYaxis()->SetTitleOffset(1.8);
0086   hist2->GetXaxis()->CenterTitle();
0087   hist2->GetYaxis()->CenterTitle();
0088   hist2->GetXaxis()->SetTitle("Solid angle (sr)");
0089   hist2->GetYaxis()->SetTitle("");
0090   gPad->SetLogy();
0091   gPad->SetTicks(1, 1);
0092   gPad->Modified();
0093 
0094   // Angle plot
0095 
0096   c1->cd(3);
0097   gPad->SetLogy();
0098   ntuple2->Draw
0099    ("acos(cosTheta)*180/3.14159","parentID==0&&trackID==1&&stepID==1","");
0100 
0101   TH1* hist3 = (TH1*)gPad->GetPrimitive("htemp");
0102   hist3->GetXaxis()->SetLabelSize(0.03);
0103   hist3->GetYaxis()->SetLabelSize(0.03);
0104   hist3->GetXaxis()->SetTitleSize(0.03);
0105   hist3->GetYaxis()->SetTitleSize(0.03);
0106   hist3->GetXaxis()->SetTitleOffset(1.4);
0107   hist3->GetYaxis()->SetTitleOffset(1.8);
0108   hist3->GetXaxis()->CenterTitle();
0109   hist3->GetYaxis()->CenterTitle();
0110   hist3->GetYaxis()->SetTitle("");
0111   hist3->GetXaxis()->SetTitle("Angle (deg)");
0112   gPad->SetLogy();
0113   gPad->SetTicks(1, 1);
0114   gPad->Modified();
0115 }
0116 
0117 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address) {
0118   TLeaf* leaf = ntuple->FindLeaf(name);
0119   if ( ! leaf ) {
0120     std::cerr << "Error in <SetLeafAddress>: unknown leaf --> " << name << std::endl;
0121     return;
0122   }
0123   leaf->SetAddress(address);
0124 }