Loop to get the average

Hi
att an example, please check carefully - if possible together
with colleges familiar with this subject - if this is really what
you need / want.

Otto
f2.C (923 Bytes)

thanks so much @OSchaile :slight_smile: i will study the code tomorrow. i saw that the average was not a continuous curve, nevertheless, it worked :slight_smile:

regards,
jaybee

I have some trivial questions?

        static Int_t nf = 10;
        auto can = new TCanvas("c1", "c1", 800,500);
        gStyle->SetOptStat(0);
        auto hh = new TH1F("hh", "Averaging functions", 100,0,10);
...
        avg->Draw("* same");

in the code, what does “static”, “auto” and the “*” before “same” mean?

regards,
jaybee

Hi,
for “static” and “auto” you should look in c++ textbooks
e.g.
https://www.studytonight.com/cpp/static-keyword.php
https://www.bogotobogo.com/cplusplus/C11/C11_Type_Inference_auto_range_based_for_loop.php

In fact in the macro f2.C “static” is used badly, it should be:

const Int_t nf = 10;

since it is used in fp[nf]
for “*” see
https://root.cern/doc/master/classTGraphPainter.html
"A Star is plotted at each point "

Otto

it seems i cannot change the marker size and color.

why is dy = 10.0/npoints? is that because there were 10 functions generated? :slight_smile:

for this part of the code, i do not get the significance of 0.5, why such?

for (Int_t i=0; i<nop; i++){
                             x = dy*i + 0.5*dy;
                             avg->SetPoint(i, x, 0.0);
                            }

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.