Hello all,
I am working with a root file that is full of TH1Ds and TCanvas and I am interested in pulling a line of data from the TCanvas (which is two TPaveText blocks and I am interested in the text on the second) I have been able to get the specific line I need (which appears as this
Text X=0.000000 Y=0.000000 Text=#bullet #bf{#chi^{2}} : 11.8172 Font=0 Size=0.000000 Color=0 Align=0
)
which I can get as a TLatex but I’m unable to do anything with it (specifically pull the number 11.8172 from it which I was planning to by getting rid of everything from the : and before and after the “Font”)
Is there a way to get the line as a string or anything else that can be edited or maybe an better way to pull text from the TPaveText? I know ROOT isn’t meant to read from a TPaveText blocks and alike but theres about 9 Canvas’ I need to pull from per 5 root files and I don’t want to have to manually write it all in.
This is the code I am using to get the line but if you have any better code to get what I need please share.
TFile* rootFile = TFile::Open("myFile.root");
TList* histgrms = rootFile->GetListOfKeys();
for(int i=0; i<histgrms->GetEntries();i++){
TKey* currHistgrm = (TKey*) histgrms->At(i);
std::string histgrmName = currHistgrm->GetName();
std::string search = "_settings";
if (!std::equal(search.rbegin(), search.rend(), histgrmName.rbegin())) {
continue;
}
TObject* myObj = rootFile->Get(histgrmName.c_str());
if (!(myObj->IsA() == TCanvas::Class())) {
std::cout<<currHistgrm->IsA();
continue;
}
TCanvas* myCan = (TCanvas*) myObj->Clone((histgrmName+"_"+"mine").c_str());
TPaveText* myPave = (TPaveText*) myCan->GetListOfPrimitives()->Last()->Clone((histgrmName+"_"+"mine").c_str());
myPave->GetLineWith("chi")->Print();
myPave->GetLineWith("chi")->IsA()->Print();
myPave->IsA()->Print();
ROOT Version: 6.12/06