Home | News | Documentation | Download

Difference between arrays


#1

Hi, I plotted an array setting 4 conditiions in this way:

t->Draw( TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a), TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub) );

Moreover, I plotted the same data adding a fifth condition in this way.

t->Draw( TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a), TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub,a, e, p15sub, csig, p25sub) );

Now I need to delete from the sample having the 4 condition, the sub-sample having 5 conditions. Then I wrote:

t->Draw( (TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a), TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub))   -   (TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a), TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub,a, e, p15sub, csig, p25sub)));

What I mean, is to delete from the sample having 4 conditions, the data having one condition more.
When I run Root, I get this error

How should I do, what I need?


ROOT Version: 5.34/38
Platform: Windows
Compiler: Not Provided



#2

I have no idea what you want but maybe this is it:

TString what = TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a);
TCut cut1 = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub).Data();
TCut cut2 = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub,a, e, p15sub, csig, p25sub).Data();
t->Draw(what, cut1 && !cut2);

#3

Thank you wile! it was that I want!


#5

Hi @Wile_E_Coyote, following your reply, I made 1D plot about an array Calo_EnDep in this way

TCanvas *c20 = new TCanvas("c20",canvtitle,1280,1024);
			c20->Divide (2,2);
			TCut cut1 = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub).Data();
			TCut cut2 = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub,a, e, p15sub, csig, p25sub).Data();
			TCut cut3 = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) && TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, b, p1, csig, p2, a, c, p13sub, csig, p23sub,a, d, p14sub, csig, p24sub,a, e2, p15sub2, csig, p25sub2).Data();
 			c20->cd(1);
 			t->SetLineColor(kBlue);
 			TString henea4substringcut = TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a);
			t->Draw(henea4substringcut, cut1 && !cut2 && !cut3);
			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
			t->GetHistogram()->SetTitle(cdenenamea);
 			TH1F *henea4subcut = (TH1F*)gPad->GetPrimitive("htemp"); 
			henea4subcut->GetXaxis()->SetTitle(cdeneXnameab); 
			henea4subcut->GetYaxis()->SetTitle(cdeneYnameab);
			henea4subcut->GetYaxis()->SetTitleSize(c2_YTitleSize);
			henea4subcut->GetYaxis()->SetTitleFont(c2_YTitleFont);
			henea4subcut->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
			henea4subcut->GetYaxis()->SetLabelFont(c2_YLabelFont); 
			henea4subcut->GetYaxis()->SetLabelSize(c2_YLabelSize);
			henea4subcut->GetXaxis()->SetTitleSize(c2_XTitleSize);
			henea4subcut->GetXaxis()->SetTitleFont(c2_XTitleFont);
			henea4subcut->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
			henea4subcut->GetXaxis()->SetLabelFont(c2_XLabelFont); 
			henea4subcut->GetXaxis()->SetLabelSize(c2_XLabelSize);
			henea4subcut->SetFillColorAlpha(kBlue, heneabfillcolor);
			henea4subcut->Draw(); 	
			henea4subcut->SetName(heneabname);
			//henea->GetXaxis()->SetRangeUser(c2_XSetRangem,c2_XSetRangeMa);
   			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn

Should it also possible to make a 2D plot of 2 arrays?
I mean to plot a TH2F having on x-axis a culomn of the Calo_EnDep [a] array and on y-axis one other culomn Calo_EnDep[b]…then I would define for example:

TString heneasubstringcutrelab = TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", a);
TString henebsubstringcutrelab = TString::Format("Calo_EnDep[%d] >> htemp(5000., 0., 5000.)", b);

then to plot them in a 2D plot setting the condition
cut1 yes
cut2 no (discard)
cut3 no (discard)

just like in the 1D plot

t->Draw(henea4substringcut, cut1 && !cut2 && !cut3);

Thank you


#6

Try:

TString what = TString::Format("Calo_EnDep[%d] : Calo_EnDep[%d] >> htemp(100, 0., 5000., 100, 0., 5000.)", b, a);
t->Draw(what, cut1 && !cut2 && !cut3);

#7

Hi @Wile_E_Coyote thank you for your reply. Your code works, I get the plot just writing

TCanvas *c25 = new TCanvas("c25",canvtitle,1280,1024);
 			t->SetLineColor(kBlue);
 			TString henecdsubstringcutrel = TString::Format("Calo_EnDep[%d] :  Calo_EnDep[%d]>> htemp(4500., 0., 4500.)", c,d);
 			t->Draw(henecdsubstringcutrel, cut1 && !cut2 && !cut3);

but it looks like having problem because:

  1. If I add the code
TH2F *henecdsubstringcutrelTHF = (TH2F*)gPad->GetPrimitive("htemp"); 
			henecdsubstringcutrelTHF->GetXaxis()->SetTitle(cdeneXnameab); 
			henecdsubstringcutrelTHF->GetYaxis()->SetTitle(cdeneXnameab);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleSize(c2_YTitleSize);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleFont(c2_YTitleFont);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelFont(c2_YLabelFont); 
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelSize(c2_YLabelSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleSize(c2_XTitleSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleFont(c2_XTitleFont);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelFont(c2_XLabelFont); 
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelSize(c2_XLabelSize);
			henecdsubstringcutrelTHF->SetMarkerColor(kBlue);
			henecdsubstringcutrelTHF->Draw(); 	
			henecdsubstringcutrelTHF->SetName(heneabname);
			//henea->GetXaxis()->SetRangeUser(c2_XSetRangem,c2_XSetRangeMa);
   			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
   			TLegend* leghenecdsubstringcutrelTHF = new TLegend(0.65, 0.7, .75, .75);
   			leghenecdsubstringcutrelTHF->SetHeader("Legend");
			leghenecdsubstringcutrelTHF->SetNColumns(1);
			leghenecdsubstringcutrelTHF->AddEntry(leghenecdsubstringcutrelTHF, "Data", "l");
			leghenecdsubstringcutrelTHF->Draw(); 
			gPad->Update();
			TPaveStats *statsghenecdsubstringcutrelTHF = (TPaveStats*)henecdsubstringcutrelTHF->GetListOfFunctions()->FindObject("stats");
			statsghenecdsubstringcutrelTHF->SetTextColor(kBlue);
			statsghenecdsubstringcutrelTHF->SetX1NDC(0.80); statsghenecdsubstringcutrelTHF->SetX2NDC(0.98);
			statsghenecdsubstringcutrelTHF->SetY1NDC(0.77); statsghenecdsubstringcutrelTHF->SetY2NDC(0.92)
			gPad->Update();

I get the error due to the TStats:

  1. If I don’t add the TStats, I don’t get any error, but the plot is white and ROOT doesn’t add my personal title of the plot

It’s strange, because I use these codes in other plots from tree (but in TH1F typology)

  1. Lastly,I would like to plot using the “COLZ” typology then I tried to write
TString henecdsubstringcutrel = TString::Format("Calo_EnDep[%d] :  Calo_EnDep[%d]>> htemp(4500., 0., 4500.)", c,d);
 			t->Draw("COLZ",henecdsubstringcutrel, cut1 && !cut2 && !cut3);

but I get error

Thank you


#8

See how I defined “htemp” (for the 2D case) in my previous post above.


#9

Hi @Wile_E_Coyote, you are right…I forgot to write the bin number and the range for the y-axis…anyway, even if now I replaced

TString henecdsubstringcutrel = TString::Format("Calo_EnDep[%d] :  Calo_EnDep[%d]>> htemp(4500., 0., 4500.)", c,d);

with

TString henecdsubstringcutrel = TString::Format("Calo_EnDep[%d] :  Calo_EnDep[%d]>> htemp(4500., 0., 4500.,1800.,0.,1800)", c,d);

I get the same problems explained in my previous post…


#10

@couet It seems that ROOT does not create the “stats” box for the 2D case when the “htemp” is created by the “Draw”.
So, if you want it, you will need to create the histogram in advance:

TH2F *htemp = new TH2F("htemp", "", 100, 0., 5000., 100, 0., 5000.);
TString what = TString::Format("Calo_EnDep[%d] : Calo_EnDep[%d] >> htemp", b, a);
t->Draw(what, cut1 && !cut2 && !cut3);

#11

Hi @Wile_E_Coyote, I wrote:

	TCanvas *c25 = new TCanvas("c25",canvtitle,1280,1024);
			TH2F *htemp2 = new TH2F("htemp2", "", 4500., 0., 4500., 1800, 0., 1800.);
 			t->SetLineColor(kBlue);
 			TString henecdsubstringcutrel = TString::Format("Calo_EnDep[%d] :  Calo_EnDep[%d]>> htemp2", c,d);
 			t->Draw(henecdsubstringcutrel, cut1 && !cut2 && !cut3);
			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
			t->GetHistogram()->SetTitle(cdhenecdsubstringcutrelTHFname);
 			TH2F *henecdsubstringcutrelTHF = (TH2F*)gPad->GetPrimitive("htemp"); 
			henecdsubstringcutrelTHF->GetXaxis()->SetTitle(cdeneXnameab); 
			henecdsubstringcutrelTHF->GetYaxis()->SetTitle(cdeneXnameab);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleSize(c2_YTitleSize);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleFont(c2_YTitleFont);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelFont(c2_YLabelFont); 
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelSize(c2_YLabelSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleSize(c2_XTitleSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleFont(c2_XTitleFont);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelFont(c2_XLabelFont); 
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelSize(c2_XLabelSize);
			henecdsubstringcutrelTHF->SetMarkerColor(kBlue);
			henecdsubstringcutrelTHF->Draw(); 	
			henecdsubstringcutrelTHF->SetName(heneabname);
			//henea->GetXaxis()->SetRangeUser(c2_XSetRangem,c2_XSetRangeMa);
   			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
   			TLegend* leghenecdsubstringcutrelTHF = new TLegend(0.65, 0.7, .75, .75);
   			leghenecdsubstringcutrelTHF->SetHeader("Legend");
			leghenecdsubstringcutrelTHF->SetNColumns(1);
			leghenecdsubstringcutrelTHF->AddEntry(leghenecdsubstringcutrelTHF, "Data", "l");
			leghenecdsubstringcutrelTHF->Draw(); 
			gPad->Update();
			TPaveStats *statsghenecdsubstringcutrelTHF = (TPaveStats*)henecdsubstringcutrelTHF->GetListOfFunctions()->FindObject("stats");
			statsghenecdsubstringcutrelTHF->SetTextColor(kBlue);
			statsghenecdsubstringcutrelTHF->SetX1NDC(0.80); statsghenecdsubstringcutrelTHF->SetX2NDC(0.98);
			statsghenecdsubstringcutrelTHF->SetY1NDC(0.77); statsghenecdsubstringcutrelTHF->SetY2NDC(0.92)
			gPad->Update();
			c25->Print(myplothenecdsubstringcutrelTHF);

but now I get the error

where the line 2684 is

henecdsubstringcutrelTHF->GetXaxis()->SetTitle(cdeneXnameab); 

It looks like a big problem to plot a 2D plot by using arrays of a tree…
Can’t be possible to fill a new TH2F by using the 2 arrays and later just to draw the TH2F instead of the tree?


#12

Hi @Wile_E_Coyote, I tried to fill a 2D histogram in this way

TCanvas *c25 = new TCanvas("c25",canvtitle,1280,1024);
			//TH2F *htemp2 = new TH2F("htemp2", "", 4500., 0., 4500., 1800, 0., 1800.);
 			//t->SetLineColor(kBlue);
 			TH2F *henecdsubstringcutrelTHF = new TH2F("henecdsubstringcutrelTHF", "", 4500., 0., 4500., 1800, 0., 1800.);
 			int entries=t->getEntry();
 			for (int ient=0;ient<entries;++ient){
 				henecdsubstringcutrelTHF->Fill((Form("Calo_EnDep[%d]",c)),(Form("Calo_EnDep[%d]",d)));
			 }
			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
		//	t->GetHistogram()->SetTitle(cdhenecdsubstringcutrelTHFname);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitle(cdeneXnameab); 
			henecdsubstringcutrelTHF->GetYaxis()->SetTitle(cdeneXnameab);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleSize(c2_YTitleSize);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleFont(c2_YTitleFont);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelFont(c2_YLabelFont); 
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelSize(c2_YLabelSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleSize(c2_XTitleSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleFont(c2_XTitleFont);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelFont(c2_XLabelFont); 
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelSize(c2_XLabelSize);
			henecdsubstringcutrelTHF->SetMarkerColor(kBlue);
			henecdsubstringcutrelTHF->Draw(); 	
			henecdsubstringcutrelTHF->SetName(heneabname);
			//henea->GetXaxis()->SetRangeUser(c2_XSetRangem,c2_XSetRangeMa);
   			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
   			TLegend* leghenecdsubstringcutrelTHF = new TLegend(0.65, 0.7, .75, .75);
   			leghenecdsubstringcutrelTHF->SetHeader("Legend");
			leghenecdsubstringcutrelTHF->SetNColumns(1);
			leghenecdsubstringcutrelTHF->AddEntry(leghenecdsubstringcutrelTHF, "Data", "l");
			leghenecdsubstringcutrelTHF->Draw(); 
			gPad->Update();
			TPaveStats *statsghenecdsubstringcutrelTHF = (TPaveStats*)henecdsubstringcutrelTHF->GetListOfFunctions()->FindObject("stats");
			statsghenecdsubstringcutrelTHF->SetTextColor(kBlue);
			statsghenecdsubstringcutrelTHF->SetX1NDC(0.80); statsghenecdsubstringcutrelTHF->SetX2NDC(0.98);
			statsghenecdsubstringcutrelTHF->SetY1NDC(0.77); statsghenecdsubstringcutrelTHF->SetY2NDC(0.92)
			gPad->Update();
			c25->Print(myplothenecdsubstringcutrelTHF);

but I get this error

the line 2679 is

	int entries=t->getEntry();

#13

If you name your histogram "henecdsubstringcutrelTHF", then use "Calo_EnDep[%d] : Calo_EnDep[%d] >> henecdsubstringcutrelTHF".


#14

Hi @Wile_E_Coyote, thank you for your reply. I’m no ture if I understood what you mean…anyway I wrote this:

TCanvas *c25 = new TCanvas("c25",canvtitle,1280,1024);
			//TH2F *htemp2 = new TH2F("htemp2", "", 4500., 0., 4500., 1800, 0., 1800.);
 			//t->SetLineColor(kBlue);
 			TH2F *henecdsubstringcutrelTHF = new TH2F("henecdsubstringcutrelTHF", "", 4500., 0., 4500., 1800, 0., 1800.);
 			int entries=t->getEntry();
 			for (int ient=0;ient<entries;++ient){
 				henecdsubstringcutrelTHF->Fill("Calo_EnDep[%d] :  Calo_EnDep[%d]>> henecdsubstringcutrelTHF", c,d);
			 }
			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
		//	t->GetHistogram()->SetTitle(cdhenecdsubstringcutrelTHFname);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitle(cdeneXnameab); 
			henecdsubstringcutrelTHF->GetYaxis()->SetTitle(cdeneXnameab);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleSize(c2_YTitleSize);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleFont(c2_YTitleFont);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelFont(c2_YLabelFont); 
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelSize(c2_YLabelSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleSize(c2_XTitleSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleFont(c2_XTitleFont);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelFont(c2_XLabelFont); 
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelSize(c2_XLabelSize);
			henecdsubstringcutrelTHF->SetMarkerColor(kBlue);
			henecdsubstringcutrelTHF->Draw(); 	
			henecdsubstringcutrelTHF->SetName(heneabname);
			//henea->GetXaxis()->SetRangeUser(c2_XSetRangem,c2_XSetRangeMa);
   			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
   			TLegend* leghenecdsubstringcutrelTHF = new TLegend(0.65, 0.7, .75, .75);
   			leghenecdsubstringcutrelTHF->SetHeader("Legend");
			leghenecdsubstringcutrelTHF->SetNColumns(1);
			leghenecdsubstringcutrelTHF->AddEntry(leghenecdsubstringcutrelTHF, "Data", "l");
			leghenecdsubstringcutrelTHF->Draw(); 
			gPad->Update();
			TPaveStats *statsghenecdsubstringcutrelTHF = (TPaveStats*)henecdsubstringcutrelTHF->GetListOfFunctions()->FindObject("stats");
			statsghenecdsubstringcutrelTHF->SetTextColor(kBlue);
			statsghenecdsubstringcutrelTHF->SetX1NDC(0.80); statsghenecdsubstringcutrelTHF->SetX2NDC(0.98);
			statsghenecdsubstringcutrelTHF->SetY1NDC(0.77); statsghenecdsubstringcutrelTHF->SetY2NDC(0.92)
			gPad->Update();
			c25->Print(myplothenecdsubstringcutrelTHF);

but I get this error

The line 2679 is

int entries=t->getEntry();

#15
TH2F *henecdsubstringcutrelTHF = new TH2F("henecdsubstringcutrelTHF", "", 4500, 0., 4500., 1800, 0., 1800.);
TString what = TString::Format("Calo_EnDep[%d] : Calo_EnDep[%d] >> henecdsubstringcutrelTHF", d, c);
t->Draw(what, cut1 && !cut2 && !cut3);

#16

Hi @Wile_E_Coyote than you again…but I think it’s what I did 2 days ago (read my message number 10)

this one

but as you can see reading the message, I also got error…


#17

I you use your own "henecdsubstringcutrelTHF" when Draw()'ing, the "htemp" will not be created at all.


#18

Hi @Wile_E_Coyote, then I wrote:

TCanvas *c25 = new TCanvas("c25",canvtitle,1280,1024);
 			TH2F *henecdsubstringcutrelTHF = new TH2F("henecdsubstringcutrelTHF", "", 4500, 0., 4500., 1800, 0., 1800.);
			TString what = TString::Format("Calo_EnDep[%d] : Calo_EnDep[%d] >> henecdsubstringcutrelTHFh", d, c);
			t->Draw(what, cut1 && !cut2 && !cut3);
			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
			henecdsubstringcutrelTHF->SetTitle(cdhenecdsubstringcutrelTHFname);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitle(cdeneXnameab); 
			henecdsubstringcutrelTHF->GetYaxis()->SetTitle(cdeneXnameab);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleSize(c2_YTitleSize);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleFont(c2_YTitleFont);
			henecdsubstringcutrelTHF->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelFont(c2_YLabelFont); 
			henecdsubstringcutrelTHF->GetYaxis()->SetLabelSize(c2_YLabelSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleSize(c2_XTitleSize);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleFont(c2_XTitleFont);
			henecdsubstringcutrelTHF->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelFont(c2_XLabelFont); 
			henecdsubstringcutrelTHF->GetXaxis()->SetLabelSize(c2_XLabelSize);
			henecdsubstringcutrelTHF->SetMarkerColor(kBlue);
			henecdsubstringcutrelTHF->Draw("COLZ"); 	
			henecdsubstringcutrelTHF->SetName(heneabname);
			//henea->GetXaxis()->SetRangeUser(c2_XSetRangem,c2_XSetRangeMa);
   			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
   			TLegend* leghenecdsubstringcutrelTHF = new TLegend(0.65, 0.7, .75, .75);
   			leghenecdsubstringcutrelTHF->SetHeader("Legend");
			leghenecdsubstringcutrelTHF->SetNColumns(1);
			leghenecdsubstringcutrelTHF->AddEntry(leghenecdsubstringcutrelTHF, "Data", "l");
			leghenecdsubstringcutrelTHF->Draw(); 
			gPad->Update();
			TPaveStats *statsghenecdsubstringcutrelTHF = (TPaveStats*)henecdsubstringcutrelTHF->GetListOfFunctions()->FindObject("stats");
			statsghenecdsubstringcutrelTHF->SetTextColor(kBlue);
			statsghenecdsubstringcutrelTHF->SetX1NDC(0.80); statsghenecdsubstringcutrelTHF->SetX2NDC(0.98);
			statsghenecdsubstringcutrelTHF->SetY1NDC(0.77); statsghenecdsubstringcutrelTHF->SetY2NDC(0.92);
			gPad->Update();
			c25->Print(myplothenecdsubstringcutrelTHF);

I don’t get any error, but I get an empty plot


#19

Try first without any cuts and then e.g. add them one by one.


#20

Hi @Wile_E_Coyote Thank you for all the time you are spending for me. I replaced

t->Draw(what, cut1 && !cut2 && !cut3);

with

t->Draw(what);

but I also get an empty plot.

Anyway, running the macro, I see on the screen that ROOT fill the histogram (I see black point on the screen), but at the end, it replace the plot with an empty plot. Then I think it happens when ROOT run this line

henecdsubstringcutrelTHF->Draw("COLZ"); 

it looks like that when it run that line, it make a new empty histogram (but it doesn’t happen with TH1F plots, just with TH2F)


Problem with 2D plot values
#21

And what is the “h” in the end of the “... >> henecdsubstringcutrelTHFh” string supposed to do?