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 {
25 }
26 
32 {
33  mi_evt = findNode::getClass<SQEvent >(topNode, "SQEvent");
34  mi_gen_inte = findNode::getClass<PHGenIntegral>(topNode, "PHGenIntegral");
35  if (mi_evt && mi_gen_inte) {
36  if (m_fn_lumi_list.length() > 0) ofs_lumi_list.open(m_fn_lumi_list.c_str());
37  } else {
38  cout << "AnaSimRunInfo will do nothing since cannot find SQEvent/PHGenIntegral." << endl;
39  }
41 }
42 
48 {
49  if (!mi_evt || !mi_gen_inte) return Fun4AllReturnCodes::EVENT_OK;
50 
51  static int run_id_pre = -1;
52  static int evt_id_pre = -1;
53  int run_id = mi_evt->get_run_id();
54  int evt_id = mi_evt->get_event_id();
55  if (run_id != run_id_pre || evt_id < evt_id_pre) {
56  double lumi_inte = mi_gen_inte->get_Integrated_Lumi();
57  long n_evt_gen = mi_gen_inte->get_N_Generator_Accepted_Event();
58  long n_evt_pro = mi_gen_inte->get_N_Processed_Event();
59  if (Verbosity() > 0) {
60  cout << "AnaSimRunInfo: Integrated luminosity = " << lumi_inte << " /pb\n"
61  << " N of generator-accepted events = " << n_evt_gen << "\n"
62  << " N of processed events = " << n_evt_pro << endl;
63  }
64  if (ofs_lumi_list.is_open()) ofs_lumi_list << lumi_inte << "\t" << n_evt_gen << "\t" << n_evt_pro << "\n";
65  lumi_inte_tot += lumi_inte;
66  n_evt_gen_tot += n_evt_gen;
67  n_evt_pro_tot += n_evt_pro;
68  n_run++;
69  }
70  run_id_pre = run_id;
71  evt_id_pre = evt_id;
73 }
74 
76 {
77  if (!mi_evt || !mi_gen_inte) return Fun4AllReturnCodes::EVENT_OK;
78 
79  if (ofs_lumi_list.is_open()) ofs_lumi_list.close();
80 
81  ostringstream oss;
82  oss << "Integrated luminosity = " << lumi_inte_tot << " /pb\n"
83  << "N of generator-accepted events = " << n_evt_gen_tot << "\n"
84  << "N of processed events = " << n_evt_pro_tot << "\n"
85  << "N of input runs = " << n_run << endl;
86  if (Verbosity() > 0) {
87  cout << "AnaSimRunInfo::End():\n"
88  << oss.str();
89  }
90 
91  if (m_fn_lumi_info.length() > 0) {
92  ofstream ofs(m_fn_lumi_info);
93  ofs << oss.str();
94  ofs.close();
95  }
96 
97  ofstream ofs(m_fn_lumi_tot);
98  ofs << lumi_inte_tot << "\n";
99  ofs.close();
100 
102 }
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.