Hey everyone,
I have a root tree with a fairly complicated structure. The root tree comprises of several branches that has multiple leafs that are usually arrays. So here is a an example in PyRoot:
taTree.GetEntry(1)
taTree.stpln.ig
<cppyy.gbl.std.vector<int> object at 0x277476d8>
print(taTree.stpln.ig)
[1,0,1,0,1,1,1,0,1,-2,-2,-2,-2,-2,1,0,1,0,0]
Now my problem is that I want to cut out events in profile plot that have too many “-2’s” in this array. I have created a function below that does just that:
Int_t event_saturation_cut(vector<int> tubeArray, Int_t saturation_limit)
{
Double_t nentries = tubeArray.size();
Double_t saturation_count = 0.0;
for(Int_t i = 0;i < nentries;i++)
{
if (tubeArray[i] == -2)
{
saturation_count += 1.0;
}
}
Double_t saturation_percent = saturation_count / nentries;
Double_t saturation_plimit = saturation_limit / 100.;
if (saturation_percent <= saturation_plimit)
{
return 1;
}
return 0;
}
It works outside the draw function just fine! But when I try to draw the profile with this cut I get an error:
taTree.Draw("(log((missing_E_corr(prfc->eng[6]))/mc04->energy)):log10(mc04-energy)","event_saturation_cut(stpln.ig,20) == 1","prof")
Error in <TTreeFormula::Compile>: Bad numerical expression : "event_saturation_cut(stpln.ig,20)"
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {(log((missing_E_corr(prfc-eng[6]))/mc04->energy)):log10(mc04->energy),event_saturation_cut(stpln.ig,20) == 1}
Any ideas on why this isn’t working? Also how exactly are the cuts applied? I couldn’t find out exactly how in the documentation of the draw function. Strangely enough this works:
taTree.Draw("(log((missing_E_corr(prfc->eng[6]))/mc04->energy)):log10(mc04->energy)","stpln.ig == 1 ","prof")
But I am unsure on how to interpret it since I don’t understand how root is implementing the cut.
Any help would be great!
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.22.02
Platform: Ubuntu 18
Compiler: Not Provided