#include"TFile.h"
#include"TTree.h"
#include"TH1.h"
#include"TH2.h"
#include "TF1.h"
#include"TCanvas.h"
#include "TStyle.h"
#include"TROOT.h"
#include "TPad.h"
#include "TAxis.h"
#include "Rtypes.h"
#include "TAttAxis.h"
#include "TPave.h"
#include "TText.h"
#include "TLine.h"
#include "TLatex.h"
#include "THStack.h"
#include "TMath.h"
#include "TGraph.h"
//C++ language
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
//const int T=50;
void SdcinandoutLocal()
{
gROOT->Reset();
gStyle->SetOptStat(111111);
gStyle->SetOptFit(11111111);
gStyle->SetPalette(1);
TFile *f[4];
f[0] = new TFile("KuramaTrack/KuramaTracking_00883.root");
f[1] = new TFile("KuramaTrack/KuramaTracking_00885.root");
f[2] = new TFile("KuramaTrack/KuramaTracking_00887.root");
f[3] = new TFile("KuramaTrack/KuramaTracking_00889.root");
TTree *tree[4];
tree[0]= (TTree*)f[0]->Get("kurama");
tree[1]= (TTree*)f[1]->Get("kurama");
tree[2]= (TTree*)f[2]->Get("kurama");
tree[3]= (TTree*)f[3]->Get("kurama");
Int_t nlSdcIn;//SDC1 is from 1 to 6, SSD from 7 to 14, SDC2,3 from 31 to 38
Int_t nlSdcOut;
vector<double> ResL1(20);
//double ResL1[6];
vector<double> ResL2;
vector<double> ResL3;
vector<double> ResL4;
vector<double> ResL5;
vector<double> ResL6;
vector<double> ResL7;
vector<double> ResL8;
vector<double> ResL9;
vector<double> ResL10;
vector<double> ResL11;
vector<double> ResL12;
vector<double> ResL13;
vector<double> ResL14;
vector<double> ResL31;
vector<double> ResL32;
vector<double> ResL33;
vector<double> ResL34;
vector<double> ResL35;
vector<double> ResL36;
vector<double> ResL37;
vector<double> ResL38;
Int_t ntSdcIn;
//for 883
tree[0]->SetBranchStatus("*",0);
tree[0]->SetBranchStatus("ResL1",1);
tree[0]->SetBranchStatus("ResL2",1);
tree[0]->SetBranchStatus("ResL3",1);
tree[0]->SetBranchStatus("ResL4",1);
tree[0]->SetBranchStatus("ResL5",1);
tree[0]->SetBranchStatus("ResL6",1);
tree[0]->SetBranchStatus("ResL7",1);
tree[0]->SetBranchStatus("ResL8",1);
tree[0]->SetBranchStatus("ResL9",1);
tree[0]->SetBranchStatus("ResL10",1);
tree[0]->SetBranchStatus("ResL11",1);
tree[0]->SetBranchStatus("ResL12",1);
tree[0]->SetBranchStatus("ResL13",1);
tree[0]->SetBranchStatus("ResL14",1);
tree[0]->SetBranchStatus("ResL31",1);
tree[0]->SetBranchStatus("ResL32",1);
tree[0]->SetBranchStatus("ResL33",1);
tree[0]->SetBranchStatus("ResL34",1);
tree[0]->SetBranchStatus("ResL35",1);
tree[0]->SetBranchStatus("ResL36",1);
tree[0]->SetBranchStatus("ResL37",1);
tree[0]->SetBranchStatus("ResL38",1);
tree[0]->SetBranchStatus("ntSdcIn",1);
tree[0]->SetBranchAddress("ResL1",&ResL1);
tree[0]->SetBranchAddress("ResL2",&ResL2);
tree[0]->SetBranchAddress("ResL3",&ResL3);
tree[0]->SetBranchAddress("ResL4",&ResL4);
tree[0]->SetBranchAddress("ResL5",&ResL5);
tree[0]->SetBranchAddress("ResL6",&ResL6);
tree[0]->SetBranchAddress("ResL7",&ResL7);
tree[0]->SetBranchAddress("ResL8",&ResL8);
tree[0]->SetBranchAddress("ResL9",&ResL9);
tree[0]->SetBranchAddress("ResL10",&ResL10);
tree[0]->SetBranchAddress("ResL11",&ResL11);
tree[0]->SetBranchAddress("ResL12",&ResL12);
tree[0]->SetBranchAddress("ResL13",&ResL13);
tree[0]->SetBranchAddress("ResL14",&ResL14);
tree[0]->SetBranchAddress("ResL31",&ResL31);
tree[0]->SetBranchAddress("ResL32",&ResL32);
tree[0]->SetBranchAddress("ResL33",&ResL33);
tree[0]->SetBranchAddress("ResL34",&ResL34);
tree[0]->SetBranchAddress("ResL35",&ResL35);
tree[0]->SetBranchAddress("ResL36",&ResL36);
tree[0]->SetBranchAddress("ResL37",&ResL37);
tree[0]->SetBranchAddress("ResL38",&ResL38);
tree[0]->SetBranchAddress("ntSdcIn",&ntSdcIn);
//for 885
tree[1]->SetBranchStatus("*",0);
tree[1]->SetBranchStatus("ResL1",1);
tree[1]->SetBranchStatus("ResL2",1);
tree[1]->SetBranchStatus("ResL3",1);
tree[1]->SetBranchStatus("ResL4",1);
tree[1]->SetBranchStatus("ResL5",1);
tree[1]->SetBranchStatus("ResL6",1);
tree[1]->SetBranchStatus("ResL7",1);
tree[1]->SetBranchStatus("ResL8",1);
tree[1]->SetBranchStatus("ResL9",1);
tree[1]->SetBranchStatus("ResL10",1);
tree[1]->SetBranchStatus("ResL11",1);
tree[1]->SetBranchStatus("ResL12",1);
tree[1]->SetBranchStatus("ResL13",1);
tree[1]->SetBranchStatus("ResL14",1);
tree[1]->SetBranchStatus("ResL31",1);
tree[1]->SetBranchStatus("ResL32",1);
tree[1]->SetBranchStatus("ResL33",1);
tree[1]->SetBranchStatus("ResL34",1);
tree[1]->SetBranchStatus("ResL35",1);
tree[1]->SetBranchStatus("ResL36",1);
tree[1]->SetBranchStatus("ResL37",1);
tree[1]->SetBranchStatus("ResL38",1);
tree[1]->SetBranchAddress("ResL1",&ResL1);
tree[1]->SetBranchAddress("ResL2",&ResL2);
tree[1]->SetBranchAddress("ResL3",&ResL3);
tree[1]->SetBranchAddress("ResL4",&ResL4);
tree[1]->SetBranchAddress("ResL5",&ResL5);
tree[1]->SetBranchAddress("ResL6",&ResL6);
tree[1]->SetBranchAddress("ResL7",&ResL7);
tree[1]->SetBranchAddress("ResL8",&ResL8);
tree[1]->SetBranchAddress("ResL9",&ResL9);
tree[1]->SetBranchAddress("ResL10",&ResL10);
tree[1]->SetBranchAddress("ResL11",&ResL11);
tree[1]->SetBranchAddress("ResL12",&ResL12);
tree[1]->SetBranchAddress("ResL13",&ResL13);
tree[1]->SetBranchAddress("ResL14",&ResL14);
tree[1]->SetBranchAddress("ResL31",&ResL31);
tree[1]->SetBranchAddress("ResL32",&ResL32);
tree[1]->SetBranchAddress("ResL33",&ResL33);
tree[1]->SetBranchAddress("ResL34",&ResL34);
tree[1]->SetBranchAddress("ResL35",&ResL35);
tree[1]->SetBranchAddress("ResL36",&ResL36);
tree[1]->SetBranchAddress("ResL37",&ResL37);
tree[1]->SetBranchAddress("ResL38",&ResL38);
//for 887
tree[2]->SetBranchStatus("*",0);
tree[2]->SetBranchStatus("ResL1",1);
tree[2]->SetBranchStatus("ResL2",1);
tree[2]->SetBranchStatus("ResL3",1);
tree[2]->SetBranchStatus("ResL4",1);
tree[2]->SetBranchStatus("ResL5",1);
tree[2]->SetBranchStatus("ResL6",1);
tree[2]->SetBranchStatus("ResL7",1);
tree[2]->SetBranchStatus("ResL8",1);
tree[2]->SetBranchStatus("ResL9",1);
tree[2]->SetBranchStatus("ResL10",1);
tree[2]->SetBranchStatus("ResL11",1);
tree[2]->SetBranchStatus("ResL12",1);
tree[2]->SetBranchStatus("ResL13",1);
tree[2]->SetBranchStatus("ResL14",1);
tree[2]->SetBranchStatus("ResL31",1);
tree[2]->SetBranchStatus("ResL32",1);
tree[2]->SetBranchStatus("ResL33",1);
tree[2]->SetBranchStatus("ResL34",1);
tree[2]->SetBranchStatus("ResL35",1);
tree[2]->SetBranchStatus("ResL36",1);
tree[2]->SetBranchStatus("ResL37",1);
tree[2]->SetBranchStatus("ResL38",1);
tree[2]->SetBranchAddress("ResL1",&ResL1);
tree[2]->SetBranchAddress("ResL2",&ResL2);
tree[2]->SetBranchAddress("ResL3",&ResL3);
tree[2]->SetBranchAddress("ResL4",&ResL4);
tree[2]->SetBranchAddress("ResL5",&ResL5);
tree[2]->SetBranchAddress("ResL6",&ResL6);
tree[2]->SetBranchAddress("ResL7",&ResL7);
tree[2]->SetBranchAddress("ResL8",&ResL8);
tree[2]->SetBranchAddress("ResL9",&ResL9);
tree[2]->SetBranchAddress("ResL10",&ResL10);
tree[2]->SetBranchAddress("ResL11",&ResL11);
tree[2]->SetBranchAddress("ResL12",&ResL12);
tree[2]->SetBranchAddress("ResL13",&ResL13);
tree[2]->SetBranchAddress("ResL14",&ResL14);
tree[2]->SetBranchAddress("ResL31",&ResL31);
tree[2]->SetBranchAddress("ResL32",&ResL32);
tree[2]->SetBranchAddress("ResL33",&ResL33);
tree[2]->SetBranchAddress("ResL34",&ResL34);
tree[2]->SetBranchAddress("ResL35",&ResL35);
tree[2]->SetBranchAddress("ResL36",&ResL36);
tree[2]->SetBranchAddress("ResL37",&ResL37);
tree[2]->SetBranchAddress("ResL38",&ResL38);
// for 889
tree[3]->SetBranchStatus("*",0);
tree[3]->SetBranchStatus("ResL1",1);
tree[3]->SetBranchStatus("ResL2",1);
tree[3]->SetBranchStatus("ResL3",1);
tree[3]->SetBranchStatus("ResL4",1);
tree[3]->SetBranchStatus("ResL5",1);
tree[3]->SetBranchStatus("ResL6",1);
tree[3]->SetBranchStatus("ResL7",1);
tree[3]->SetBranchStatus("ResL8",1);
tree[3]->SetBranchStatus("ResL9",1);
tree[3]->SetBranchStatus("ResL10",1);
tree[3]->SetBranchStatus("ResL11",1);
tree[3]->SetBranchStatus("ResL12",1);
tree[3]->SetBranchStatus("ResL13",1);
tree[3]->SetBranchStatus("ResL14",1);
tree[3]->SetBranchStatus("ResL31",1);
tree[3]->SetBranchStatus("ResL32",1);
tree[3]->SetBranchStatus("ResL33",1);
tree[3]->SetBranchStatus("ResL34",1);
tree[3]->SetBranchStatus("ResL35",1);
tree[3]->SetBranchStatus("ResL36",1);
tree[3]->SetBranchStatus("ResL37",1);
tree[3]->SetBranchStatus("ResL38",1);
tree[3]->SetBranchAddress("ResL1",&ResL1);
tree[3]->SetBranchAddress("ResL2",&ResL2);
tree[3]->SetBranchAddress("ResL3",&ResL3);
tree[3]->SetBranchAddress("ResL4",&ResL4);
tree[3]->SetBranchAddress("ResL5",&ResL5);
tree[3]->SetBranchAddress("ResL6",&ResL6);
tree[3]->SetBranchAddress("ResL7",&ResL7);
tree[3]->SetBranchAddress("ResL8",&ResL8);
tree[3]->SetBranchAddress("ResL9",&ResL9);
tree[3]->SetBranchAddress("ResL10",&ResL10);
tree[3]->SetBranchAddress("ResL11",&ResL11);
tree[3]->SetBranchAddress("ResL12",&ResL12);
tree[3]->SetBranchAddress("ResL13",&ResL13);
tree[3]->SetBranchAddress("ResL14",&ResL14);
tree[3]->SetBranchAddress("ResL31",&ResL31);
tree[3]->SetBranchAddress("ResL32",&ResL32);
tree[3]->SetBranchAddress("ResL33",&ResL33);
tree[3]->SetBranchAddress("ResL34",&ResL34);
tree[3]->SetBranchAddress("ResL35",&ResL35);
tree[3]->SetBranchAddress("ResL36",&ResL36);
tree[3]->SetBranchAddress("ResL37",&ResL37);
tree[3]->SetBranchAddress("ResL38",&ResL38);
Long64_t nentries = tree[0]->GetEntries();
TCanvas *c1 = new TCanvas("c1","c1",1000,800);
TCanvas *c2 = new TCanvas("c2","c2",1000,800);
TCanvas *c3 = new TCanvas("c3","c3",1000,800);
TCanvas *c4 = new TCanvas("c4","c4",1000,800);
c1->Divide(3,3);
c2->Divide(3,3);
c3->Divide(3,3);
c4->Divide(3,3);
TH1F *residual883_1 = new TH1F("","",100,-5,5);
TH1F *residual883_2 = new TH1F("","",100,-5,5);
TH1F *residual883_3 = new TH1F("","",100,-5,5);
TH1F *residual883_4 = new TH1F("","",100,-5,5);
TH1F *residual883_5 = new TH1F("","",100,-5,5);
TH1F *residual883_6 = new TH1F("","",100,-5,5);
for(int i=0;i<nentries;i++){
tree[0]->GetEntry(i);
for(int i=0;i<;i++){
residual883_1->Fill(ResL1[i]);
}
}
c1->cd(1)->SetGrid();
residual883_1->Draw();
}
Dear Axel,
Hello, please, help me. After running this code I got as below:
Error in <TTree::SetBranchAddress>: The address for "ResL1" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL2" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL3" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL4" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL5" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL6" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL7" should be the address of a pointer!
Error in <TTree::SetBranchAddress>: The address for "ResL8" should be the address of a pointer!
.......
So what should I do?