greetings;
I hope you’re doing well, I encountered a problem with plotting from a text file as shown below (code). the text file contains 3 columns: x, dose 1, dose 2, and I want to draw the difference between (dose1 and dose2) can someone help:
@couet @Axel
TString doseFileSim = "differenceDose.txt";
TNtuple *TNtupleSim = new TNtuple("ntuple1","dose from simulation file", "iX:doseSans:doseAvec");
cout << "Reading from file \" " << doseFileSim << "\" ... ";
Long64_t nlines = TNtupleSim -> ReadFile(doseFileSim, "iX:doseSans:doseAvec");
if (nlines <=0){cout << "Error: Check \"" << doseFileSim << "\"\n"; return;}
printf("%lld Experimental points found\n", nlines);
Float_t iX, doseSans,doseAvec;
TNtupleSim -> SetBranchAddress("iX", &iX);
TNtupleSim -> SetBranchAddress("doseSans", &doseSans);
TNtupleSim -> SetBranchAddress("doseSans", &doseSans);
Int_t nentries = (Int_t)TNtupleSim -> GetEntries();
TNtupleSim -> GetEntry(0);
Float_t maxDose = 0, depthSim = 0, slength = lengthBox/nentries;
vector <Float_t> vec_doseSans,vec_doseAvec, vec_iX;
//------------------------------------------------------------------------deleted----------------------------------
for (Int_t l = 0; l<nentries; l++)
{
TNtupleSim -> GetEntry(l);
vec_iX.push_back(depthSim);
vec_doseSans.push_back(doseSans);
//vec_iX.push_back(depthSim);
vec_doseAvec.push_back(doseAvec);
depthSim += slength;
}
//----------------------------------------------------------------------deleted------------------------------------
TNtupleSim -> Reset();
//---------------------------------------------------------------------deleted-----------------------------------------
for (Int_t l = 0; l<nentries; l++){
iX = vec_iX[l];
doseSans = ((vec_doseAvec[l]-vec_doseSans[l])/(vec_doseSans[l]))*(-100);
TNtupleSim -> Fill(iX,0,0,doseSans);
}
//---------------------------------------------------
TCanvas *c1 = new TCanvas ("c1","c1",200,10,600,400);
TNtupleSim-> SetMarkerStyle(20);
TNtupleSim -> SetMarkerColor(4);
TNtupleSim -> SetMarkerSize(0.7);
//------------------------------------
TNtupleSim -> Draw("doseSans:iX","","");