Newer
Older
#include <ROOT/RDataFrame.hxx>
#include <TCanvas.h>
#include <TH1D.h>
#include <string>
// hard-coded replay dir.
const std::string kReplayDir =
"/volatile/hallc/c-polhe3/example_files/replay/full";
int shms_tracking_efficiency(int run = 7120, int nevents = 5000) {
ROOT::RDataFrame d{"T", Form("%s/shms_replay_production_0%i_%i.root",
kReplayDir.c_str(), run, nevents)};
// The tracking efficiency can be estamed by comparing the number of events
// that should have good tracks, to the number of events that actually have
// good tracks.
// Events that should have good tracks
auto d_should =
d.Filter("P.hod.goodscinhit==1")
.Filter("0.5 < P.hod.betanotrack && P.hod.betanotrack < 1.4")
.Filter("0.6 < P.cal.etotnorm && P.cal.etotnorm < 1.6")
.Filter("P.ngcer.npeSum > 0.5");
auto n_should = d_should.Count();
// Subset of events that actually have good tracks
auto d_did = d_should.Filter("P.dc.ntrack > 0");
auto n_did = d_did.Count();
const double tracking_efficiency = double(*n_did) / *n_should;
// That's all we need to do! Let's print our results to the terminal
std::cout << "\n----------------------------------------------\n"
<< "Our estimated tracking efficiency for run " << run << " is "
<< "(we found " << *n_did << " tracks out of " << *n_should << ")"
// That's all!
return 0;
}