Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:58

0001 void test_number_of_hits(TString sim_file_name="sim.root") {
0002 
0003   // test requirements
0004   const Double_t expected_number_of_hits = 230.0;
0005   const Double_t allowed_deviation       = 15.0;
0006 
0007   // get average number of hits
0008   auto sim_file = new TFile(sim_file_name);
0009   auto t = (TTree*) sim_file->Get("EVENT");
0010   auto h = new TH1D("h","<hits>",500,0,1000);
0011   t->Project("h","@PFRICHHits.size()");
0012   auto ave_hits = h->GetMean();
0013 
0014   // check if this is the expected number of hits
0015   bool pass_test = abs(ave_hits - expected_number_of_hits) < allowed_deviation;
0016   std::cout << "TEST: " << (pass_test ? "passed" : "failed")
0017     << " with average number of hits = " << ave_hits
0018     << " (expected " << expected_number_of_hits
0019     << "+/-" << allowed_deviation << ")"
0020     << std::endl;
0021 }