I’m trying to draw a branch with specific cuts to be able to show ‘efficiency’ for a specific ID. When drawing my tree, I hope to draw the efficiency for a specific ID by summing the total that have a “pass” branch set to true over all entries that match the given ID. However, TTree:Draw()
seems to ignore the second Sum$
special function when I use it. A code snippet is provided below that I created to illustrate my issue.
void temp(){
TCanvas *c = new TCanvas("c", "Histogram Canvas");
Bool_t pass;
Int_t run;
Int_t ID; //Here ID is a stand-in for a specific chamber.
TTree *tree = new TTree("EffTree", "EffTree");
tree->Branch("Pass", &pass, "Pass/O");
tree->Branch("ID", &ID, "ID/I");
tree->Branch("Run", &run, "Run/I");
run = 5;
ID = 1;
for (int i=0; i<100; i++){
pass = (i<25);
tree->Fill();
} // Only 25/100 entries have pass=true.
tree->Draw("Run", "Sum$(Pass && ID == 1)", "TEXT"); //This fills Run 5 with 25.
c->Print("pass.pdf");
tree->Draw("Run", "Sum$(ID==1)", "TEXT"); // This fills Run 5 with 100.
c->Print("total.pdf");
// I expect this to fill Run 5 with (number passed)/(total with that ID) = 25/100 = 0.25.
tree->Draw("Run", "Sum$(Pass && ID == 1)/Sum$(ID==1)", "TEXT");
c->Print("eff.pdf");
c->Close();
}
As my comments above show, I expect the third plot I create to print the efficiency (or total passed entries over total entries). However, the third plot is always identical to the first plot. The selection seems to ignore the second Sum$
entirely. Replacing the second Sum$
with 100.0
works perfectly, so I am not sure why it is not working here.
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.26/06
Platform: macosx64