#include #include #include #include #include #include using namespace std; void read(string infile); int main() { read("CampioneIgnotoBanana900.root"); return 0; } void read(string infile) { //TApplication *a = new TApplication("a", 0, 0); TH1F *h0 = new TH1F("h0", "h0 ", 2048, 0, 2048); TH1F *h1 = new TH1F("h1", "h1 ", 2048, 0, 2048); TH1F *h2 = new TH1F("h2", "h2 ", 2048, 0, 2048); TH1F *h3 = new TH1F("h3", "h3 ", 2048, 0, 2048); TFile *fin = new TFile(infile.c_str(), "READ"); TTree *pjmca = (TTree*)fin->Get("pjmca"); float ch1, ch2, ch3, ch0, temp, ene; pjmca->SetBranchAddress("ch0", &ch0); pjmca->SetBranchAddress("ch1", &ch1); pjmca->SetBranchAddress("ch2", &ch2); pjmca->SetBranchAddress("ch3", &ch3); int nentries = pjmca->GetEntries(); for (int i = 0; iGetEntry(i); h0->Fill(ch0); h1->Fill(ch1); h2->Fill(ch2); //h3->Fill(ch3); } fin->Close(); TFile * newfile = new TFile("prova.root", "RECREATE"); h0->Write(); h1->Write(); h2->Write(); h3->Write(); }