I’m trying to draw an 2D histogram from a TTree and I would like to select names of materials, which is a branch containing char.
I’ve tried using:
tree->Draw(“Conductivity:Temp”,“Material.compare(‘ARMCO Iron RRR~13’)”)
But then it does not select the ‘ARMCO Iron RRR~13’ only, it actually draws the data from all the Materials in the tree.
Is there a way I can select on strings?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
I think this mean that TTree::Draw does not calculate correct the selection.
Check the result of:
tree->Scan("Material.compare(‘ARMCO Iron RRR~13’)")
tree->Scan("Material.compare(\"ARMCO Iron RRR~13\")")
Thanks for your answer. That does not seem to make a difference, they both result in all entries being displayed.
I have a small working example here:
TH2F* get2DHisto (const char* file, const char* material, const char* property)
TTree* myTree = new TTree();
myTree->Draw(Form("%s:Temp", property), Form("Material.compare('%s')", material) );
TH2F* returnHist = (TH2F*)gPad->GetPrimitive("Graph");
}//end TTree readFileToTree
const char* fName = "TwoMetals";
TH2F* thermalConductivity = get2DHisto(fName, "Beryllium", "Conductivity");
And a small version of the file, with only two metals can be found here:
I can’t upload it here because csv is not allowed.
I see the Material is a C-string column. In this case you need:
myTree->Draw(Form("%s:Temp", property), Form("strstr(Material,\"%s\")", material) );
PS. Strangely TTree::Draw seems to simply ignore what is written after the work Material in your original version.
Thank you very much, that was the solution
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.