Hi friends,
Unfortunately, I have difficulties reading my tree and branches. What I wanna do is basically to read “previously created root file” where there is one tree name and, let’s say 2 branches in it. After ı read this, ı want to be able to draw anything from these raw branches. Later, after processing these data, let’s say we multiply the branch contents with 2, I want to be able to create another tree and branch names to be filled and drawn.
Even though, it sounds simple, I found th examples in ROOT manuals not so useful for myself. They are either too advance, or there are so much unnecessary complications in the code, they can’t keep it simple for G.S. for a start.
For a start, ı want anybody to tell me why his simple code doesn’t want to work, then I will post other part of the codes one by one to build up a healthy and useful conversation to all of us.
1part: HOW TO READ ,let’s say 2 root files which were created in a same manner with same tree and branch names?
Part of the code: ignore the uncommented parts. Thanks in advance.
#include <fstream>
#include <iostream>
#include "TAttMarker.h"
#include "TLegend.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TStyle.h"
#include "TF1.h"
#include "TChain.h"
#include "TTree.h"
#include "TH2F.h"
#include "TH1F.h"
#include "TRandom.h"
#include "TH1F.h"
#include "TApplication.h"
#include "TProfile.h"
#include <string>
#include "string.h"
using namespace std;
void testcode()
{
TCanvas*c1= new TCanvas("c1","Analysis",900,600);
c1->cd();
TChain *ch=new TChain("Analysed_Data");
ch->Add("~/Desktop/ilkeroutput/run07*.root");
if(!ch){ cout << "\nCould not open the file" <<endl; exit(-1); }
cout << " test 1 PASSED" << endl;
if (ch->IsZombie()) { cout << "Error opening file" << endl; exit(-1);}
cout << " test 2 PASSED" << endl;
ch->SetBranchStatus("*", 0);
ch->SetBranchStatus("TrifoilE", 1);
ch->SetBranchStatus("Theta_p", 1);
ch->SetBranchStatus("T_initial_p", 1);
gStyle->SetPalette(51);
gDirectory->Delete("*");
c1->SetLogz();
ch->Draw("T_initial_p:Theta_p>>h1(180,0,180,1000,0,20000)","TrifoilE>15000","colz");
//gDirectory->Delete("*");
//gStyle->SetOptStat(0);
//gStyle->SetOptTitle(0);
//gStyle->SetPalette(1); //51
//int UD1Fmult, UD1Fnum; float UD1Fenergy; double UD1Ftime;
/*
TFile *f1 = TFile::Open("/home/ic00025/Desktop/ilkeroutput/run07284.root","READ");
TCanvas*c1= new TCanvas("c1","Analysis",900,600);
c1->cd();
TTree *t1 = (TTree *)f1->FindObjectAny("Analysed_Data");
if(!f1){ cout << "\nCould not open the file" <<endl; exit(-1); }
cout << " test 1 PASSED" << endl;
if (f1->IsZombie()) { cout << "Error opening file" << endl; exit(-1);}
cout << " test 2 PASSED" << endl;
t1->SetBranchStatus("*", 0);
t1->SetBranchStatus("TrifoilE", 1);
t1->SetBranchStatus("Theta_p", 1);
//t1->Draw("Theta_p>>h1(180,0,180)","TrifoilE>15000","colz");
t1->Draw("Theta_p:Theta_p>>h1(180,0,180,180,0,180)","TrifoilE>15000","colz");
*/
}
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided