Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:19:29

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