I’m really glad to start ROOT learning. Would anyone be kind enough to help a beginner ?
Well, i have two plot that i could draw them successfully. Next i draw them at ones Canvas using “same”. Okay, Now i’m looking for the cross point. I mean somewhere that the first signal cross the second one. The crossing coordinate is my interest.
@couet // Thanks a lot for answering. Actually its two digitized signals that i saved the digitized data in a txt file. the txt file consisting a numbers that correspond to ADC heights. look at this :
void intersect() {
auto Plot1 = new TGraph("Output1.txt");
auto Plot2 = new TGraph("Output2.txt");
Plot2->Draw("AL");
Plot1->Draw("L");
double min = 33000;
double max = 35000;
double d = 1.;
double eps = 1.;
for (double s=min; s<max; s=s+d) {
if (TMath::Abs(Plot2->Eval(s)-Plot1->Eval(s)) < eps) {
printf("Plot1 and Plot2 might intersect at (%g, %g)\n",s,Plot2->Eval(s));
}
}
}
the execution of this macro gives:
$ root intersect.C
------------------------------------------------------------
| Welcome to ROOT 6.17/01 https://root.cern |
| (c) 1995-2019, The ROOT Team |
| Built for macosx64 on Apr 29 2019, 11:02:08 |
| From heads/master@v6-16-00-rc1-1795-ga98d98cf5b |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0]
Processing intersect.C...
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
Plot1 and Plot2 might intersect at (34284, 15)
Plot1 and Plot2 might intersect at (34285, 16)
root [1]
It seems your graphs have an invalid number of points… so the graph are not created properly… It might be that the txt files are not found… Can you send the beginning of the log ? … Just after .x intersect.C ?
@couet // Omg, unbelievable…
You know, when i run ROOT and then command .x fileopen.c and in the next when root object browser opened and i choose intersect.c it work correctly !!!
in contrast, when i just drag intersect and put on root icon, its going to error !!! cant understand whats wrong. both way are the same.
Could the reason be this that i using old version of ROOT ?
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 5.34/36 5 April 2016 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
ROOT 5.34/36 (v5-34-36@v5-34-36, Apr 05 2016, 10:25:45 on win32)
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Look at your browser… the macro intersect.C and the two txt file are in the same directory. When you run “.x intersect.C” from the root prompt you must first cd to that directory before starting root.
@couet // Thanks a lot for your guidance. I do anything u said but, i encounter with the same error as i showed before. At last i could not grasp whats wrong, however, The only way to run intersect.c here, is that open it with ROOT " filebrowser.C ".