Skip to content
Snippets Groups Projects
shms_tracking_efficiency.cxx 1.47 KiB
Newer Older
  • Learn to ignore specific revisions
  • #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";
    
    
    Sylvester Joosten's avatar
    Sylvester Joosten committed
    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();
    
    
    Sylvester Joosten's avatar
    Sylvester Joosten committed
      const double tracking_efficiency = double(*n_did) / *n_should;
    
    
      // That's all we need to do! Let's print our results to the terminal
    
    Sylvester Joosten's avatar
    Sylvester Joosten committed
      std::cout << "\n----------------------------------------------\n"
                << "Our estimated tracking efficiency for run " << run << " is "
    
    Sylvester Joosten's avatar
    Sylvester Joosten committed
                << tracking_efficiency * 100 << "%\n"
    
    Sylvester Joosten's avatar
    Sylvester Joosten committed
                << "(we found " << *n_did << " tracks out of " << *n_should << ")"
    
    Sylvester Joosten's avatar
    Sylvester Joosten committed
                << std::endl;
    
    
      // That's all!
      return 0;
    }