Hello there,
I was looking anywhere for solution, but I couldn’t find it.
I’ve got 2 .root files: one with TH2F histograms, second with TCutG cuts corresponding to these histograms. I need to cut data from histograms and then project them on axis. There are loads of them so I’m trying to do it automatically. To check if it works firstly I draw histogram with [cutg] option and it looks how it should. However, projection with [cutg] option results with all data being projected. What have I done wrong?
I’m using root 5.34
Here’s the code:
[code]void kalibracja()
{
gROOT->ProcessLine(".cd D:\mgr\kalibracja450\");
TFile *expData = new TFile(“450MeV_particles_residue_and_fast_slow_in_csi.root”,“READ”);
TFile *expCuts = new TFile(“cuts_particles_450MeV_garf.root”,“READ”);
int i=0;
int j=0;
char bufor[30];
if(expData->IsOpen() && expCuts->IsOpen())
{
for(i=0; i<4; i++)
for(j=0; j<24; j++)
{
TCanvas *kanwa = new TCanvas(“kanwa”);
kanwa->SetLogz();
TCutG *cutHis2A = new TCutG();
TH2F *expHis2 = new TH2F();
TH1D *expHisACut = new TH1D();
TH1D *expHisPCut = new TH1D();
sprintf(bufor, "co_csi_dsp_s_vs_f[%d][%d]",i,j);
expHis2 = (TH2F*)expData->Get(bufor);
expHis2->DrawCopy("colz");
sprintf(bufor, "a_%d_%d",i,j);
TCutG *cutHis2A = (TCutG*)expCuts->Get(bufor);
cutHis2A->SetName("cutHis2A");
expHis2->DrawCopy("colz [cutHis2A]");
sprintf(bufor, "a_exp_check_%d_%d.pdf",i,j);
kanwa->SaveAs(bufor);
expHisACut=expHis2->ProjectionY("projy", 0, -1, "[cutHis2A]");
expHisACut->SetStats(0);
expHisACut->Rebin(10);
expHisACut->DrawCopy("e");
sprintf(bufor, "a_exp_cut_proj_%d_%d.pdf",i,j);
kanwa->SaveAs(bufor);
delete expHisACut;
delete cutHis2A;
delete expHis2;
delete kanwa;
}
}
expData->Close();
expCuts->Close();
delete expData;
delete expCuts;
}[/code]
Thanks for your help in advance.