File indexing completed on 2025-08-05 08:15:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "PHGenIntegralv1.h"
0012
0013 #include <phool/PHObject.h> // for PHObject
0014
0015 #include <cstdlib>
0016 #include <iostream>
0017
0018 using namespace std;
0019
0020 PHGenIntegralv1::PHGenIntegralv1()
0021 : m_NProcessedEvent(0)
0022 , m_NGeneratorAcceptedEvent(0)
0023 , m_IntegratedLumi(0.)
0024 , m_SumOfWeight(0.)
0025 , m_Description("Source Not Provided")
0026 {}
0027
0028 PHGenIntegralv1::PHGenIntegralv1(const std::string& description)
0029 : m_NProcessedEvent(0)
0030 , m_NGeneratorAcceptedEvent(0)
0031 , m_IntegratedLumi(0.)
0032 , m_SumOfWeight(0.)
0033 , m_Description(description)
0034 {}
0035
0036 void PHGenIntegralv1::identify(ostream& os) const
0037 {
0038 os << "PHGenIntegralv1::identify: " << get_Description() << endl
0039 << " N_Generator_Accepted_Event = " << get_N_Generator_Accepted_Event() << " @ " << get_CrossSection_Generator_Accepted_Event() << " pb" << endl
0040 << " N_Processed_Event = " << get_N_Processed_Event() << " @ " << get_CrossSection_Processed_Event() << " pb" << endl
0041 << " Sum_Of_Weight = " << get_Sum_Of_Weight() << endl
0042 << " Integrated_Lumi = " << get_Integrated_Lumi() << " pb^-1" << endl;
0043 }
0044
0045 void PHGenIntegralv1::Reset()
0046 {
0047 m_NProcessedEvent = 0;
0048 m_NGeneratorAcceptedEvent = 0;
0049 m_IntegratedLumi = 0;
0050 m_SumOfWeight = 0;
0051 m_Description = "Source Not Provided";
0052 }
0053
0054 int PHGenIntegralv1::Integrate(PHObject* incoming_object)
0055 {
0056 const PHGenIntegral* in_gen = dynamic_cast<const PHGenIntegral*>(incoming_object);
0057
0058 if (!in_gen)
0059 {
0060 cout << "PHGenIntegralv1::Integrate - Fatal Error - "
0061 << "input object is not a PHGenIntegral: ";
0062 incoming_object->identify();
0063
0064 exit(EXIT_FAILURE);
0065 }
0066
0067 if (m_IntegratedLumi == 0 and m_NProcessedEvent == 0)
0068 {
0069 m_Description = in_gen->get_Description();
0070 }
0071 else if (m_Description != in_gen->get_Description())
0072 {
0073 m_Description = m_Description + ", and " + in_gen->get_Description();
0074 }
0075
0076 m_NProcessedEvent += in_gen->get_N_Processed_Event();
0077 m_NGeneratorAcceptedEvent += in_gen->get_N_Generator_Accepted_Event();
0078 m_IntegratedLumi += in_gen->get_Integrated_Lumi();
0079 m_SumOfWeight += in_gen->get_Sum_Of_Weight();
0080
0081 return m_NProcessedEvent;
0082 }
0083
0084 void PHGenIntegralv1::CopyFrom(const PHObject* incoming_object)
0085 {
0086 const PHGenIntegral* in_gen = dynamic_cast<const PHGenIntegral*>(incoming_object);
0087
0088 if (!in_gen)
0089 {
0090 cout << "PHGenIntegralv1::CopyFrom - Fatal Error - "
0091 << "input object is not a PHGenIntegral: ";
0092 incoming_object->identify();
0093
0094 exit(EXIT_FAILURE);
0095 }
0096
0097 m_NProcessedEvent = in_gen->get_N_Processed_Event();
0098 m_NGeneratorAcceptedEvent = in_gen->get_N_Generator_Accepted_Event();
0099 m_IntegratedLumi = in_gen->get_Integrated_Lumi();
0100 m_SumOfWeight = in_gen->get_Sum_Of_Weight();
0101 m_Description = in_gen->get_Description();
0102 }