//C++ includes #include //ROOT includes #include "TCanvas.h" #include "TStyle.h" #include "TH1D.h" #include "TFile.h" #include "TTree.h" using namespace std; int main(int argc, char *argv[]) { if(argc<2) { cout << "Not enough arguments! Stop run. " << endl; return -1; } /* we're going to make a histogram, and set some parameters about it's X and Y axes */ TH1D *nuflavorint_hist = new TH1D("nuflavorint", "",3,1,4); nuflavorint_hist->SetTitle("Neutrino Flavors"); nuflavorint_hist->GetXaxis()->SetTitle("Neutrino Flavors (1=e, 2=muon, 3=tau)"); nuflavorint_hist->GetYaxis()->SetTitle("Weigthed Fraction of Total Detected Events"); nuflavorint_hist->GetXaxis()->SetTitleOffset(1.2); nuflavorint_hist->GetYaxis()->SetTitleOffset(1.2); nuflavorint_hist->GetXaxis()->CenterTitle(); nuflavorint_hist->GetYaxis()->CenterTitle(); for(int i=1; i < argc; i++) { // loop over the input files //now we are going to load the icefinal.root file and draw in the "passing_events" tree, which stores info string readfile = string(argv[i]); TFile *AnitaFile = new TFile(( readfile ).c_str()); cout << "AnitaFile" << endl; TTree *passing_events = (TTree*)AnitaFile->Get("passing_events"); cout << "Reading AnitaFile..." << endl; //declare three variables we are going to use later int num_pass; // number of entries (ultra-neutrinos); double weight; // weight of neutrino counts; int nuflavorint; // neutrino flavors; num_pass = passing_events->GetEntries(); cout << "num_pass is " << num_pass << endl; /*PRIMARIES VARIABLES*/ //set the "branch" of the tree which stores specific pieces of information passing_events->SetBranchAddress("weight", &weight); passing_events->SetBranchAddress("nuflavor", &nuflavorint); //loop over all the events in the tree for (int k=0; k <=num_pass; k++) { passing_events->GetEvent(k); nuflavorint_hist->Fill(nuflavorint, weight); //fill the histogram with this value and this weight } // CLOSE FOR LOOP OVER NUMBER OF EVENTS } // CLOSE FOR LOOP OVER NUMBER OF INPUT FILES //set up some parameters to make things loo pretty gStyle->SetHistFillColor(0); gStyle->SetHistFillStyle(1); gStyle->SetHistLineColor(1); gStyle->SetHistLineStyle(0); gStyle->SetHistLineWidth(2.5); //Setup plot Style //make a "canvas" to draw on TCanvas *c4 = new TCanvas("c4", "nuflavorint", 1100,850); gStyle->SetOptTitle(1); gStyle->SetStatX(0.33); gStyle->SetStatY(0.87); nuflavorint_hist->Draw("HIST"); //draw on it //Save Plots //make the line thicker and then save the result gStyle->SetHistLineWidth(9); c4->SaveAs("nuflavorint.png"); gStyle->SetHistLineWidth(2); c4->SaveAs("nuflavorint.pdf"); delete c4; //clean up return 0; //return successfully }