Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:10:14

0001 #ifndef SHERPA_Single_Events_Event_Handler_H
0002 #define SHERPA_Single_Events_Event_Handler_H
0003 
0004 #include <vector>
0005 #include <iostream>
0006 
0007 #include "SHERPA/Single_Events/Event_Phase_Handler.H"
0008 #include "SHERPA/Tools/Definitions.H"
0009 #include "ATOOLS/Math/Uncertain.H"
0010 #include "ATOOLS/Phys/Variations.H"
0011 #include "ATOOLS/Phys/Weights.H"
0012 
0013 namespace SHERPA {
0014   class Filter;
0015   
0016   typedef std::vector<Event_Phase_Handler *> Phase_List;
0017   typedef Phase_List::iterator Phase_Iterator;
0018 
0019   class Event_Handler {
0020   private:
0021 
0022     long int m_lastparticlecounter, m_lastblobcounter;
0023     double m_n, m_addn, m_maxweight;
0024     double m_mn;
0025     std::map<std::string,double> m_maxweights;
0026     int m_checkweight;
0027     size_t m_lastrss;
0028     int m_decayer;
0029 
0030     Phase_List        * p_phases;
0031     ATOOLS::Blob_List   m_blobs, m_sblobs;
0032     ATOOLS::Blob      * p_signal;
0033     Filter            * p_filter;
0034 
0035     const ATOOLS::Variations  * p_variations;
0036     ATOOLS::Weights_Map m_wgtmapsum, m_wgtmapsumsqr;
0037     ATOOLS::Weights_Map m_mwgtmapsum, m_mwgtmapsumsqr;
0038     
0039     void WriteRNGStatus(const std::string &file,
0040             const std::string &message) const;
0041 
0042     bool GenerateStandardPerturbativeEvent(eventtype::code & mode);
0043     bool GenerateMinimumBiasEvent(eventtype::code & mode);
0044     bool GenerateHadronDecayEvent(eventtype::code & mode);
0045     void InitialiseSeedBlob(ATOOLS::btp::code type,
0046                 ATOOLS::blob_status::code status);
0047     bool AnalyseEvent();
0048     bool WeightsAreGood(const ATOOLS::Weights_Map&);
0049     int  IterateEventPhases(eventtype::code & mode);
0050 
0051     void MPISync();
0052 
0053     // This entails costly operations and should not be done too often (e.g.
0054     // only after a successful run).
0055     void MPISyncXSAndErrMaps();
0056 
0057   public:
0058 
0059     Event_Handler();
0060     ~Event_Handler();
0061 
0062     void AddEventPhase(Event_Phase_Handler *);
0063     void EmptyEventPhases();
0064 
0065     void SetVariations(const ATOOLS::Variations * p) { p_variations = p; };
0066 
0067     void PrintGenericEventStructure();
0068 
0069     bool GenerateEvent(eventtype::code mode=eventtype::StandardPerturbative);
0070     void Reset();
0071     void ResetNonPerturbativePhases();
0072     void Finish();
0073 
0074     ATOOLS::Blob_List * GetBlobs() { return &m_blobs; }
0075 
0076     void SetFilter(Filter * filter) { p_filter = filter; }
0077     
0078     void PerformMemoryMonitoring();
0079 
0080     ATOOLS::Weights_Map TotalXS();
0081     ATOOLS::Weights_Map TotalErr();
0082     ATOOLS::Uncertain<double> TotalNominalXS();
0083     ATOOLS::Uncertain<double> TotalNominalXSMPI();
0084 
0085     // These are only valid after calling MPISyncXSAndErrMaps().
0086     ATOOLS::Weights_Map TotalXSMPI();
0087     ATOOLS::Weights_Map TotalErrMPI();
0088 
0089     std::string CurrentProcess() const;
0090 
0091   };
0092 
0093 
0094   /*!
0095     \file 
0096     \brief Contains the class SHERPA::Event_Handler
0097   */
0098 
0099   /*!
0100     \class Event_Handler
0101     \brief For the generation of single events.
0102     
0103     This class organizes and steers the generation of single events. The idea is the following: 
0104     In Sherpa, events are represented by blobs which contain a number of incoming and outgoing 
0105     particles that actually connect the blobs. The Event_Phase_Handler contained in the
0106     Event_Handler test - one by one - the list of blobs on whether they can treat any of them
0107     by inspecting the individual blobs type, its status and the like. By treating the blob
0108     in question, the blob and - potentially - the blob list gets modified. This is repeated
0109     until no Event_Phase_Handler can deal with any blob of the list. To clearly separate
0110     this treatment for the time being the Event_Phase_Handlers are divided into two types,
0111     (either "Perturbative" or "Hadronization") and the procedure outlined above is performed
0112     for the blobs of the perturbative kind first, before the phases of type "Hadronization" 
0113     take over. The different Event_Phases are filled in by the Sherpa class through the method 
0114     AddEventPhase (Event_Phase_Handler *), remember, this is the actual steering class.
0115   */ 
0116   /*!
0117     \var Phase_List * Event_Handler::p_phases
0118     The list of Event_Phase_Handlers. Through a typedef this list is realized by a vector from the
0119     standard library, the corresponding iterator is defined to be Phase_Iterator.
0120   */ 
0121   /*!
0122     \var ATOOLS::Blob_List Event_Handler::m_blobs
0123     The internal list of blobs constituting the event. This list is emptied before any new event
0124     is generated.
0125   */ 
0126   /*!
0127     \fn Event_Handler::Event_Handler()
0128     Instantiates the phase list.
0129   */ 
0130   /*!
0131     \fn Event_Handler::~Event_Handler()
0132     Deletes the phase list.
0133   */ 
0134   /*!
0135     \fn void Event_Handler::AddEventPhase(Event_Phase_Handler *)
0136     Checks if the particular Event_Phase has already been included. If so, it won't be added
0137     another time. in the way, Sherpa organizes event generation this would have no sense
0138     anyhow. 
0139   */ 
0140   /*!
0141     \fn void Event_Handler::EmptyEventPhases()
0142     Deletes all individual Event_Phase_Handlers and empties the list of event phases.
0143   */ 
0144   /*!
0145     \fn void Event_Handler::SetVariations()
0146     Set the Variations object for the entire event generation.
0147   */ 
0148   /*!
0149     \fn bool Event_Handler::GenerateEvent()
0150     Deletes all blobs that might have been produced but not deleted before. Then, a first
0151     empty blob is created of type "Signal Process". This blob is put into the blob list
0152     and the list is then dealt with by the event phases. In fact, the first blob will
0153     be filled by the SignalProcess phase which contains the matrix element generator.
0154     It is foreseen that pile-up is steered by generating a fluctuating number of
0155     further blobs of type, say "Minimum bias" that will then be filled by an anticipated
0156     PileUp Event_Phase_Handler. However, having filled the signal blob this method iterates 
0157     through all event phases of the type "Perturbative" until no blob inside the blob list 
0158     can be dealt with by any of them. If this is the case, the same procdure is
0159     repeated with the phases of type "Hadronization". 
0160   */ 
0161   /*!
0162     \fn void Event_Handler::PrintGenericEventStructure()
0163     Prints out all Event_Phase_Handlers used for event generation. This might give some
0164     idea of what to expect.
0165   */ 
0166 }
0167 #endif
0168