34 lines
898 B
C
34 lines
898 B
C
#include "TFile.h"
|
|
#include "TTree.h"
|
|
#include "TGraph.h"
|
|
#include "TLegend.h"
|
|
#include "TCanvas.h"
|
|
#include "TH1D.h"
|
|
#include "TObjArray.h"
|
|
#include "TBranch.h"
|
|
#include <iostream>
|
|
|
|
void aarootscript() {
|
|
TFile *f = new TFile("SimAnasen1.root");
|
|
TTree *tree1 = (TTree*)f->Get("tree1");
|
|
TTree *tree2 = (TTree*)f->Get("tree2");
|
|
|
|
TTreeReader reader("tree");
|
|
TTreeReaderValue<double> branchValue(reader, "Tb");
|
|
double totalSum = 0;
|
|
while (reader.Next()) {
|
|
totalSum += *branchValue;
|
|
}
|
|
std::cout << "Total Sum: " << totalSum << std::endl;
|
|
|
|
TTreeReader reader2("tree2");
|
|
TTreeReaderValue<double> branchValue2(reader2, "Tb");
|
|
double totalSum2 = 0;
|
|
while (reader2.Next()) {
|
|
totalSum2 += *branchValue2;
|
|
}
|
|
std::cout << "Total Sum: " << totalSum2 << std::endl;
|
|
|
|
std::cout << "Difference: " << totalSum - totalSum2 << std::endl;
|
|
|
|
} |