Class Reference for E1039 Core & Analysis Software
AnaSimRunInfo.cc
Go to the documentation of this file.
1 #include <sstream>
5 #include <phool/getClass.h>
6 #include "AnaSimRunInfo.h"
7 using namespace std;
8 
9 AnaSimRunInfo::AnaSimRunInfo(const char* fn_lumi_tot, const char* fn_lumi_info, const char* fn_lumi_list)
10  : SubsysReco("AnaSimRunInfo")
11  , m_fn_lumi_tot (fn_lumi_tot )
12  , m_fn_lumi_info(fn_lumi_info)
13  , m_fn_lumi_list(fn_lumi_list)
14  , lumi_inte_tot(0)
15  , n_evt_gen_tot(0)
16  , n_evt_pro_tot(0)
17  , n_run (0)
18 {
19  ;
20 }
21 
23 {
24  if (m_fn_lumi_list.length() > 0) ofs_lumi_list.open(m_fn_lumi_list.c_str());
26 }
27 
33 {
34  mi_evt = findNode::getClass<SQEvent >(topNode, "SQEvent");
35  mi_gen_inte = findNode::getClass<PHGenIntegral>(topNode, "PHGenIntegral");
36  if (!mi_evt || !mi_gen_inte) return Fun4AllReturnCodes::ABORTEVENT;
38 }
39 
45 {
46  static int run_id_pre = -1;
47  static int evt_id_pre = -1;
48  int run_id = mi_evt->get_run_id();
49  int evt_id = mi_evt->get_event_id();
50  if (run_id != run_id_pre || evt_id < evt_id_pre) {
51  double lumi_inte = mi_gen_inte->get_Integrated_Lumi();
52  long n_evt_gen = mi_gen_inte->get_N_Generator_Accepted_Event();
53  long n_evt_pro = mi_gen_inte->get_N_Processed_Event();
54  if (Verbosity() > 0) {
55  cout << "AnaSimRunInfo: Integrated luminosity = " << lumi_inte << " /pb\n"
56  << " N of generator-accepted events = " << n_evt_gen << "\n"
57  << " N of processed events = " << n_evt_pro << endl;
58  }
59  if (ofs_lumi_list.is_open()) ofs_lumi_list << lumi_inte << "\t" << n_evt_gen << "\t" << n_evt_pro << "\n";
60  lumi_inte_tot += lumi_inte;
61  n_evt_gen_tot += n_evt_gen;
62  n_evt_pro_tot += n_evt_pro;
63  n_run++;
64  }
65  run_id_pre = run_id;
66  evt_id_pre = evt_id;
68 }
69 
71 {
72  if (ofs_lumi_list.is_open()) ofs_lumi_list.close();
73 
74  ostringstream oss;
75  oss << "Integrated luminosity = " << lumi_inte_tot << " /pb\n"
76  << "N of generator-accepted events = " << n_evt_gen_tot << "\n"
77  << "N of processed events = " << n_evt_pro_tot << "\n"
78  << "N of input runs = " << n_run << endl;
79  if (Verbosity() > 0) {
80  cout << "AnaSimRunInfo::End():\n"
81  << oss.str();
82  }
83 
84  if (m_fn_lumi_info.length() > 0) {
85  ofstream ofs(m_fn_lumi_info);
86  ofs << oss.str();
87  ofs.close();
88  }
89 
90  ofstream ofs(m_fn_lumi_tot);
91  ofs << lumi_inte_tot << "\n";
92  ofs.close();
93 
95 }
AnaSimRunInfo(const char *fn_lumi_tot="lumi_tot.txt", const char *fn_lumi_info="lumi_info.txt", const char *fn_lumi_list="lumi_list.txt")
Definition: AnaSimRunInfo.cc:9
int InitRun(PHCompositeNode *topNode)
int Init(PHCompositeNode *topNode)
int process_event(PHCompositeNode *topNode)
int End(PHCompositeNode *topNode)
Called at the end of all processing.
virtual int Verbosity() const
Gets the verbosity of this module.
Definition: Fun4AllBase.h:64
virtual ULong64_t get_N_Processed_Event() const
Number of processed events in the Fun4All cycles.
Definition: PHGenIntegral.h:49
virtual ULong64_t get_N_Generator_Accepted_Event() const
Number of accepted events in the event generator. This can be higher than fNProcessedEvent depending ...
Definition: PHGenIntegral.h:38
virtual Double_t get_Integrated_Lumi() const
Integrated luminosity in pb^-1.
Definition: PHGenIntegral.h:27
virtual int get_run_id() const =0
Return the run ID.
virtual int get_event_id() const =0
Return the event ID, which is unique per run.