Problem in drawing variable divided by some number

Dear Experts,

Bslxysig is variable in a root file(tree). I want to draw Bslxysig/1367.144. How to draw, could you please tell me? I have pasted the snippet of my code here.

``````TChain *ch = new TChain("tree");
TTree *tr1 = ch;
TH1F *h1 = new TH1F("h1", "K^{+} Transverse momentum",100,7.0,100.0);
tr1->Draw("(Blxysig/1367.144)>>h1");
``````

Thanks,
Deepak

``````tr1->Draw("(Blxysig/1367.144)>>h1");
``````

This is correct. The range along the X axis will be the one of `Blxysig/1367.144`

If you want to divide the distribution by 1000 you can fille the histogram h1 as you did and then divide h1 by 1000.

You can also try to put a weight of 0.001 … but that might not be what you want.

``````tr1->Draw("(Blxysig/1367.144)", "0.001", "hist");
``````
``````tr1->Draw("(Blxysig/1367.144)>>h1");
``````

is not working. It is giving empty canvas.

Thanks,
Deepak

Try (see the x-axis range of the drawn histogram and compare to your “h1”):

``````ch->Draw("Blxysig/1367.144"); // note: "ch", not "tr1"
``````

I tried this and it is giving same thing as before(empty canvas with no.of entries). there is no distribution. For comparing the x-axis range, I am fixing h1 as (7,100) and the plot shows x-axis range as (7,100).

Thanks,
Deepak

Try:

``````ch->Print();
std::cout << ch->GetEntries() << std::endl;
``````

It’s giving details(size,variablename) of all variables in that tree.

Thanks,
Deepak

Post the output here for inspection.

Here is the output.

``````Processing Bslxysig.cc...
******************************************************************************
*Chain   :tree      : /home/deepak/BsToPhiMuMu/MC/mumuphisel/cut1mcnogen/sel_BsToPhiMuMu_mumuphi_cut1_mc_nogen_mc.nogen_cut1_s0.root *
******************************************************************************
******************************************************************************
*Tree    :tree      : tree                                                   *
*Entries :  1000000 : Total =       181002935 bytes  File  Size =    2790382 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :Mumumass  : Mumumass/D                                             *
*Entries :  1000000 : Total  Size=    8044980 bytes  All baskets in memory   *
*............................................................................*
*Br    1 :Mumumasserr : Mumumasserr/D                                        *
*Entries :  1000000 : Total  Size=    8046498 bytes  All baskets in memory   *
*............................................................................*
*Br    2 :Phimass   : Phimass/D                                              *
*Entries :  1000000 : Total  Size=    8044474 bytes  All baskets in memory   *
*............................................................................*
*Br    3 :Kmpt      : Kmpt/D                                                 *
*Entries :  1000000 : Total  Size=    8042956 bytes  All baskets in memory   *
*............................................................................*
*Br    4 :Kppt      : Kppt/D                                                 *
*Entries :  1000000 : Total  Size=    8042956 bytes  All baskets in memory   *
*............................................................................*
*Br    5 :Kmtrkdcasigbs : Kmtrkdcasigbs/D                                    *
*Entries :  1000000 : Total  Size=    8047510 bytes  All baskets in memory   *
*............................................................................*
*Br    6 :Kptrkdcasigbs : Kptrkdcasigbs/D                                    *
*Entries :  1000000 : Total  Size=    8047510 bytes  All baskets in memory   *
*............................................................................*
*Br    7 :Bmass     : Bmass/D                                                *
*Entries :  1000000 : Total  Size=    8043462 bytes  All baskets in memory   *
*............................................................................*
*Br    8 :Bpt       : Bpt/D                                                  *
*Entries :  1000000 : Total  Size=    8042450 bytes  All baskets in memory   *
*............................................................................*
*Br    9 :Beta      : Beta/D                                                 *
*Entries :  1000000 : Total  Size=    8042956 bytes  All baskets in memory   *
*............................................................................*
*Br   10 :Bphi      : Bphi/D                                                 *
*Entries :  1000000 : Total  Size=    8042956 bytes  All baskets in memory   *
*............................................................................*
*Br   11 :Bvtxcl    : Bvtxcl/D                                               *
*Entries :  1000000 : Total  Size=    8043968 bytes  All baskets in memory   *
*............................................................................*
*Br   12 :Blxysig   : Blxysig/D                                              *
*Entries :  1000000 : Total  Size=    8044474 bytes  All baskets in memory   *
*............................................................................*
*Br   13 :Bcosalphabs : Bcosalphabs/D                                        *
*Entries :  1000000 : Total  Size=    8046498 bytes  All baskets in memory   *
*............................................................................*
*Br   14 :Bcosalphabs2d : Bcosalphabs2d/D                                    *
*Entries :  1000000 : Total  Size=    8047510 bytes  All baskets in memory   *
*............................................................................*
*Br   15 :Bctau     : Bctau/D                                                *
*Entries :  1000000 : Total  Size=    8043462 bytes  All baskets in memory   *
*............................................................................*
*Br   16 :Q2        : Q2/D                                                   *
*Entries :  1000000 : Total  Size=    8041944 bytes  All baskets in memory   *
*............................................................................*
*Br   17 :dimupt    : dimupt/D                                               *
*Entries :  1000000 : Total  Size=    8043968 bytes  All baskets in memory   *
*............................................................................*
*Br   18 :dimueta   : dimueta/D                                              *
*Entries :  1000000 : Total  Size=    8044474 bytes  All baskets in memory   *
*............................................................................*
*Br   19 :CosThetaL : CosThetaL/D                                            *
*Entries :  1000000 : Total  Size=    8045486 bytes  All baskets in memory   *
*............................................................................*
*Br   20 :CosThetaK : CosThetaK/D                                            *
*Entries :  1000000 : Total  Size=    8045486 bytes  All baskets in memory   *
*............................................................................*
*Br   21 :PhiAng    : PhiAng/D                                               *
*Entries :  1000000 : Total  Size=    8043968 bytes  All baskets in memory   *
*............................................................................*
*Br   22 :Triggers  : Triggers/I                                             *
*Entries :  1000000 : Total  Size=    4022722 bytes  All baskets in memory   *
*............................................................................*
******************************************************************************
``````

Thanks,
Deepak

So, you should get histograms with 1000000 entries.
Try to print the first 10 entries (see what values you get):

``````ch->Scan("Blxysig", "", "", 10, 0);
``````

I am pasting the output.

`````` Processing Bslxysig.cc...
************************
*    Row   *   Blxysig *
************************
*        0 *         0 *
*        1 *         0 *
*        2 *         0 *
*        3 *         0 *
*        4 *         0 *
*        5 *         0 *
*        6 *         0 *
*        7 *         0 *
*        8 *         0 *
*        9 *         0 *
************************
Info in <TCanvas::Print>: file bslxysig.png has been created
``````

Well, try:

``````ch->Scan("Blxysig", "Blxysig != 0");
``````

It’s giving nonzero values as below.

``````Processing Bslxysig.cc...
************************
*    Row   *   Blxysig *
************************
*      297 * 91.087971 *
*      333 * 69.225149 *
*      480 * 72.621874 *
*      600 * 22.015388 *
*      793 * 166.70694 *
*      853 * 27.881502 *
*      919 * 21.451616 *
*     1088 * 29.436973 *
*     1144 * 22.077651 *
*     1507 * 24.498037 *
*     1597 * 12.849612 *
*     1780 * 30.894640 *
*     1783 * 12.644404 *
*     1791 * 42.579906 *
*     1901 * 33.359760 *
*     1947 * 17.262691 *
*     1962 * 79.138282 *
*     2008 * 14.660279 *
*     2072 * 37.603640 *
*     2186 * 42.417438 *
*     2222 * 41.521340 *
*     2386 * 93.572485 *
*     2804 * 27.309963 *
*     3026 * 131.57564 *
*     3545 * 15.305382 *
``````

Thanks,
Deepak

Try:

``````ch->Draw("Blxysig/1367.144", "Blxysig != 0");
``````

BTW. When you post “output” or “source code” here, do remember to enclose them into two lines which contain just three characters ``` (see how your posts have been edited above).

It’s giving the distribution as below.

Thanks,
Deepak

So, you should also get a correct plot with 1000000 entries when you try (just the first bin at x = 0 will be higher):

``````ch->Draw("Blxysig/1367.144");