{ // >> example1.C // takes a dipole sample and a nominal z-expansion sample // and plots histograms of Q2 to compare // gStyle->SetOptStat(0); //< remove statistics box // import the gst files and the weight file // TFile* f1 = TFile::Open("gntp.1.gst.root"); //< zexp file TFile* f2 = TFile::Open("gntp.ma135.gst.root"); //< dipole file // extract the trees from the files // TTree* t1 = (TTree*) f1->Get("gst"); //< GENIE summary tree TTree* t2 = (TTree*) f2->Get("gst"); //< to find this, try f1->ls() // create histograms to fill // int nbins=8; //< number of bins in histograms TH1F* hz = new TH1F("hz","",nbins,0,1); //< bins in range (0,1), zexp sample TH1F* hd = new TH1F("hd","",nbins,0,1); //< to hold dipole hz->Sumw2(); hd->Sumw2(); // create objects to hold data when loading // double q2z; double q2d; // set trees to point to data objects // > now when GetEntry is called, it puts the data in the variables below // t1->SetBranchAddress("Q2",&q2z); t2->SetBranchAddress("Q2",&q2d); // loop over and read the trees // for(int i=0;iGetEntries();i++){ t1->GetEntry(i); t2->GetEntry(i); // fill the histograms with the data hz->Fill(q2z); hd->Fill(q2d); } // create canvas to plot on // TCanvas* c1 = new TCanvas("c1",""); // plot the histograms // hz->GetXaxis()->SetTitle("Q^{2}"); hz->SetLineColor(kRed); //< zexp is red hz->Draw(""); hd->SetLineColor(kBlue); //< dipole is blue hd->Draw("psame"); }