hello to all,
is there a possibility in ROOT allowed to give an exact value of an abscissa for example I want the value corresponding to Dose (80%) on the X axis, I can not determine this value from file.txt because the file contains about 50 Mo, more 850 000 line, for each point in x (-150 to 150) has many dose value, and i plot it by TProfile which takes the average dose value for each point of x and i get this curve, now i want to determine the exact value on the X axis corresponding to Dose = 80, Dose = 20?
TProfiles are binned, so how exact your results will be, depends on the binning.
As for the question, if the dose % is simply the value on the y axis, you can just loop over the bins and find the ones with contents equal to the dose you want, then print the corresopnding bin centre value; e.g.:
{
Int_t xmin=-4, xmax=4, Nx=100; // TProfile limits and number of bins, for x
TCanvas *c1 = new TCanvas("c1","Profile histogram example",200,10,700,500);
TProfile *hprof = new TProfile("hprof","Profile of pz versus px",Nx,xmin,xmax,0,20);
Float_t px, py, pz;
for ( Int_t i=0; i<25000; i++) {
gRandom->Rannor(px,py);
pz = px*px + py*py;
hprof->Fill(px,pz,1);
}
hprof->Draw();
TAxis *xaxis = hprof->GetXaxis();
Double_t x = 0, y = 0; // x- and y-axis values
Double_t tDose = 8; // target dose to look for
Double_t delta = 0.1; // we look for tDose +- delta
Double_t minD = tDose-delta, maxD = tDose+delta; // interval around the desired dose
for (Int_t i=1; i<=Nx; ++i) {
y = hprof->GetBinContent(i);
if (y>minD && y<maxD) {
x = xaxis->GetBinCenter(i);
cout << x << " " << y << endl; // print x value and dose
}
}
}
thank you very much Mr of your answer, it is a very good idea, I had to test this code, it works well, but when I apply on the file.txt it does not work! here is a small example of a file.txt to test this codedose80.C (1019 Bytes) test1.txt (210 Bytes)
It does work, but in your test1 file the closest to 80 that you have are 78 and 82.5, and the delta of 0.1 is not enough for this case. Here you would have to use delta = 2.1 or 2.6 to see some output. But for your larger dataset maybe try with delta = 1 and increase if needed until you see output.