Hello everyone,
So, I’m trying to fit a set of data, but before I do this, I need to substract the histogram from 1.
For example, this is how my definition looks like N = 1 - G, where G is a histogram I aready created(no issues with that.)
Now, I will like to subtract histogram G from 1. Any help?
This is what I have tried so far and I feel like it’s not the best way to do;
auto Lab =new TH1F("Lab",
"All events: Lab vs. Time; Time in seconds; Lab",
1000,
0,
50);
ifstream inp; float x;
inp.open("Lab1.txt");
for (int i=1; i<=1000; i++) {
inp >> x;
Lab->SetBinContent(i,x);
}
Lab->Add(G , -1);
Thanks
couet
2
This does: Lab = Lab - G
is it what you want ?
Hello Couet,
Yes, Lab = Lab - G is what I want, Lab is an arbitrary number of say 1 or 100.
In the Lab1.txt, I just filled the arbitrary number of about 1000 entries.
Is there any way to substracting arbitrary numbers from Histogram taking into account all the bins?
Thanks.
couet
4
No, Lab
is an histogram (see help)
Okay, but please, how can I do something of say 1 - X, where X is the histogram?
couet
6
See the various Add methods
Axel
7
Sorry for the late reply! You should be able to use this:
hist->Scale(-1);
TH1 one("one","1");
hist->Add(one);
system
Closed
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.