BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesRndmGenSvc.h
Go to the documentation of this file.
1#ifndef BESRNDMGENSVC_H
2#define BESRNDMGENSVC_H
3
4#ifndef _CPP_MAP
5# include <map>
6#endif
7
8// base classes
9#ifndef BESKERNEL_IBESRNDMGENSVC_H
10# include "BesRndmGenSvc/IBesRndmGenSvc.h"
11#endif
12#ifndef GAUDIKERNEL_IINCIDENTLISTENER_H
13# include "GaudiKernel/IIncidentListener.h"
14#endif
15#ifndef GAUDIKERNEL_SERVICE_H
16# include "GaudiKernel/Service.h"
17#endif
18
19#ifndef KERNEL_STATUSCODES_H
20# include "GaudiKernel/StatusCode.h"
21#endif
22
23// #include "IBesRndmGenSvc.h"
24#include "CLHEP/Random/RanecuEngine.h"
25#include "CLHEP/Random/RanluxEngine.h"
26
27class IAlgorithm;
28class ISvcLocator;
29class IIncident;
30
31template <class TYPE> class SvcFactory;
32
33class BesRndmGenSvc : public extends<Service, IBesRndmGenSvc>,
34 virtual public IIncidentListener
35// public Service
36{
37public:
38 /// Interface to the CLHEP engine
39 //@{
40 CLHEP::HepRandomEngine* GetEngine( const std::string& StreamName );
41 void CreateStream( long seed, const std::string& StreamName );
42 //@{
43
44 /// CLHEP engines typedefs:
45 // typedef std::map<std::string, CLHEP::RanecuEngine*> engineMap;
46 typedef std::map<std::string, CLHEP::RanluxEngine*> engineMap;
47 typedef engineMap::iterator engineIter;
48 typedef engineMap::const_iterator engineConstIter;
49 typedef engineMap::value_type engineValType;
50
51 engineConstIter begin( void ) const;
52 engineConstIter end( void ) const;
53 unsigned int number_of_streams( void ) const;
54
55 // caogf for random seed
56 void setGenseed( long i ) { genSeed = i; }
57 long getGenseed() { return genSeed; }
58
59 /// Print methods
60 void print( const std::string& StreamName );
61 void print( void );
62
63 /// set the seeds for an engine. First param will usually be the event number
64 CLHEP::HepRandomEngine* setOnDefinedSeeds( int EventNumber, const std::string& StreamName );
65
66 /// Gaudi Service Implementation
67 //@{
68 StatusCode initialize();
69 StatusCode finalize();
70 // virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
71 //@}
72
73 /// IIncidentListener implementation. Handles EndEvent incident
74 void handle( const Incident& );
75
76private:
77 /// Service Properties
78 typedef std::vector<std::string> VStrings;
79 VStrings m_streams_seeds;
80
81 /// Random engine copy (for output to a file)
82 std::map<std::string, std::vector<long int>> m_engines_copy;
83
84 bool m_read_from_file;
85 std::string m_file_to_read;
86 std::string ofile;
87 long genSeed; // caogf for random seed
88 engineMap* m_engines;
89
90 /// Default seed values
91 //@{
92 long m_default_seed;
93 long m_EVTGEN_default_seed;
94 long m_PYTHIA_default_seed;
95 long m_HERWIG_default_seed;
96 long m_LUNDCRM_default_seed;
97 long m_SIM_default_seed;
98 long m_MIX_default_seed;
99 long m_KKMC_default_seed;
100 std::string m_StreamName;
101 std::string Stream_EVTGEN;
102 std::string Stream_PYTHIA;
103 std::string Stream_HERWIG;
104 std::string Stream_LUNDCRM;
105 std::string Stream_SIM;
106 std::string Stream_MIX;
107 std::string Stream_KKMC;
108 //@}
109
110 void SetStreamSeeds( const std::string& StreamName );
111
112public:
113 friend class SvcFactory<BesRndmGenSvc>;
114
115 // Standard Constructor
116 BesRndmGenSvc( const std::string& name, ISvcLocator* svc );
117
118 // Standard Destructor
119 virtual ~BesRndmGenSvc();
120};
121
123 return m_engines->begin();
124}
125
127 return m_engines->end();
128}
129
130inline unsigned int BesRndmGenSvc::number_of_streams( void ) const {
131 return m_engines->size();
132}
133
134#endif // BESRNDMGENSVC_H
StatusCode initialize()
Gaudi Service Implementation.
BesRndmGenSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
void setGenseed(long i)
engineConstIter begin(void) const
CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)
Interface to the CLHEP engine.
void handle(const Incident &)
IIncidentListener implementation. Handles EndEvent incident.
void CreateStream(long seed, const std::string &StreamName)
StatusCode finalize()
std::map< std::string, CLHEP::RanluxEngine * > engineMap
CLHEP engines typedefs:
engineConstIter end(void) const
engineMap::const_iterator engineConstIter
CLHEP::HepRandomEngine * setOnDefinedSeeds(int EventNumber, const std::string &StreamName)
set the seeds for an engine. First param will usually be the event number
virtual ~BesRndmGenSvc()
Standard Destructor.
engineMap::value_type engineValType
unsigned int number_of_streams(void) const
engineMap::iterator engineIter
Forward and external declarations.