Problem in projecting 2D histogram

Dear Rooters,
Hi !
I have a 2D histogram ‘hxy’, for which I want to project the Y axis (in second pad) corresponding to the X axis bin range from ‘1700 to 1702’ with the following script -
%%%%%%%%%%%%%%%%%%%%%%%%%%

[code]{
//
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
//%%%%%%%%%%%%%%%%% Root 2D Histograms to be Analysed %%%%%%%%%%%%%%%%%%%%%%%//

TString f12U = “Umat_G12_56CoFe_IPAC_r1.root”; TString h12U = “2UG12”;

//%%%%%%%%%%%%%%%%%%%%% Gamma # 1,2 (847 keV) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
//
TCanvas C1 = new TCanvas(“C1”,“Fitting canvas”,10,10,1400,1200);
C1->Divide(1,2);
//
C1->cd(1);
TFile
f1 = TFile::Open( f12U.Data(), “READ” );
TH2F hxy = (TH2F)f1->FindObjectAny(h12U.Data());
//
TH1D *px = hxy->ProjectionX();
px->Draw();
px->SetLineWidth(2.0);
//
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
//
C1->cd(2);
TH1D *h1= hxy->ProjectionY(“Peak”,1700,1702);

h1->Draw();
h1->SetLineColor(kRed);
h1->SetLineWidth(2.0);
//
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

When I do it for individual bins of X-axis (i.e. for bin 1700, 1701 & 1702)
The number of entries in the ‘h1’ (projected Y) histogram are the following -

for bin 1700 of X-axis = 2748861
1701 = 2746779
1702 = 2744624

BUT when I used the above script to do it in one go, then number of entries in ‘h1’ are 1.009153e+07,
which is of course much higher than what it should have been ( the sum of above three numbers, i.e. 8240264).

Is there something wrong in the script above ??
Please suggest me.
Also I noticed that these entries in ‘h1’ (i.e. 1.009153e+07) are the same as in ‘projected X’ (which is the complete projection without any condition) projected in the first pad of the canvas.
Is there any upper limit on the no. of entries in a histogram ??
If yes then please tell me how to increase that.

I am using root 5.21/04 version on my Linux machine.
The data file is very big (2.5 GB) & it is not possible to attach it with the mail.
Please suggest me as soon as possible.
Thanks
[/code]

Could you extract your histogram hxy in a separate file and post it?

Rene

Hi !
Yes I did, But the histogram file - “Umat_G12_56CoFe_IPAC_r1.root” is of size 8.2 MB and therefore exceeds the limit of 2MB allowed for an attachment in the talk forum.

Please suggest me if there are other ways ?

Thanks.

Could you post your file in a public readable area? afs, http?

Rene

Hi !
I am sending the file ‘Umat_G12_56CoFe_IPAC_r1.root’ & the script file ‘test.C’ to your email address (cylab123@yahoo.co.in)

Thanks

I did not receive anything from you so far

Rene

Hi !
I sent you the files in the attachment, soon after I wrote you but the mail returned back quoting ‘attchment too big’ . Anyway now I have sent them again (with a small but identical data root file).

Interestingly I noticed that when I do -

TH1D *h1= hxy->ProjectionY(“Peak”,1690);

The total statistics in the ‘projected Y’ histogram ‘h1’ (i.e. no. of entries) = 4252195 which looks OK to me.
On the other hand when I do -

TH1D *h1= hxy->ProjectionY(“Peak”,1690, 1690);

I get the no. of entries in ‘h1’ as = 3116
Also when I do -

TH1D *h1= hxy->ProjectionY(“Peak”,1,1690);

I get the total number of entries as = 1.076335e+07

I do not know which of them is correct.
Please suggest.

Thanks

Your 2d histogram has many under/overflows. When you project, you get these under/overflow included depending how you call the Projection functions. See doc

Rene

Hi !
I have seen the documentation. it says that everything lower then the ‘xmin.’ is put as underflow & more than ‘xmax.’ as overflow, so whatever the valiues of ‘xmin’ & ‘xmax’ the underflow & overflow events will be there if I am not covering the complete range of data histogram ? So why there is difference in the statistics when I do -

TH1D *h1= hxy->ProjectionY(“Peak”,1690);
or
TH1D *h1= hxy->ProjectionY(“Peak”,1690,1700);

Is there some way by which I can disbale the events in the underflow/overflow while making projections?

Please specifically tell me - Which of the above two projections is correct ?

Also one more thik to ask -
I am making the 2D histogram ‘hxy’ between variables "X’ & "Y’ applying two different curts. The cuts are such that - ‘Cut 1’ is valid only for variable 'X & ‘Cut 2’ only to variable ‘Y’[b] . Also there are some events in data, when both variables ‘X’ & ‘Y’ are present for condition ‘Cut1’ and also similar situation for ‘Cut2’. I want to include those events in the histogram when either ‘X’ or ‘Y’ or both were present for an event. To achieve this , I am making the histogram ‘hxy’ with the following command -

TREE->Draw(“X:Y>>hxy”, Cut1||Cut2);
Please tell me if it is the right way to do this ??

Thanks [/b][/u]

TREE->Draw("X:Y>>hxy", Cut1||Cut2); This sounds about right. However you said [quote] Also there are some events in data, when both variables ‘X’ & ‘Y’ are present[/quote] which might mean that X or Y are sometime not “present” in the event; if this is true and depending on what it actually means (i.e. are X or Y vectors or something like that), “Cut1||Cut2” would be 'negative/invalid" when X or Y are absent (even if the remaining one is passing the cut).

Cheers,
Philippe.