BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
Control/BesServices/BesServices-00-00-11/BesServices/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 "BesKernel/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
31
32template <class TYPE> class SvcFactory;
33
34class BesRndmGenSvc : virtual public IBesRndmGenSvc,
35 virtual public IIncidentListener,
36 public Service
37{
38public:
39 /// Interface to the CLHEP engine
40 //@{
41 CLHEP::HepRandomEngine* GetEngine ( const std::string& StreamName );
42 void CreateStream ( long seed, const std::string& StreamName );
43 //@{
44
45 /// CLHEP engines typedefs:
46 //typedef std::map<std::string, CLHEP::RanecuEngine*> engineMap;
47 typedef std::map<std::string, CLHEP::RanluxEngine*> engineMap;
48 typedef engineMap::iterator engineIter;
49 typedef engineMap::const_iterator engineConstIter;
50 typedef engineMap::value_type engineValType;
51
52 engineConstIter begin (void) const;
53 engineConstIter end (void) const;
54 unsigned int number_of_streams (void) const;
55
56 //caogf for random seed
57 void setGenseed(long i) { genSeed = i; }
58 long getGenseed() { return genSeed; }
59
60 /// Print methods
61 void print ( const std::string& StreamName );
62 void print ( void );
63
64 ///set the seeds for an engine. First param will usually be the event number
65 CLHEP::HepRandomEngine* setOnDefinedSeeds (int EventNumber,
66 const std::string& StreamName);
67
68 /// Gaudi Service Implementation
69 //@{
70 StatusCode initialize();
71 StatusCode finalize();
72 virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
73 //@}
74
75 /// IIncidentListener implementation. Handles EndEvent incident
76 void handle(const Incident&);
77
78
79private:
80 /// Service Properties
81 typedef std::vector< std::string > VStrings;
82 VStrings m_streams_seeds;
83
84 /// Random engine copy (for output to a file)
85 std::map<std::string, std::vector<long int> > m_engines_copy;
86
87 bool m_read_from_file;
88 std::string m_file_to_read;
89 std::string ofile;
90 long genSeed; //caogf for random seed
91 engineMap* m_engines;
92
93 /// Default seed values
94 //@{
95 long m_default_seed;
96 long m_EVTGEN_default_seed;
97 long m_PYTHIA_default_seed;
98 long m_HERWIG_default_seed;
99 long m_LUNDCRM_default_seed;
100 long m_SIM_default_seed;
101 long m_MIX_default_seed;
102 long m_KKMC_default_seed;
103 std::string m_StreamName;
104 std::string Stream_EVTGEN;
105 std::string Stream_PYTHIA;
106 std::string Stream_HERWIG;
107 std::string Stream_LUNDCRM;
108 std::string Stream_SIM;
109 std::string Stream_MIX;
110 std::string Stream_KKMC;
111 //@}
112
113 void SetStreamSeeds ( const std::string& StreamName );
114
115protected:
116
117 friend class SvcFactory<BesRndmGenSvc>;
118
119 // Standard Constructor
120 BesRndmGenSvc(const std::string& name, ISvcLocator* svc);
121
122 // Standard Destructor
123 virtual ~BesRndmGenSvc();
124
125};
126
129{ return m_engines->begin(); }
130
133{ return m_engines->end(); }
134
135inline unsigned int
137{ return m_engines->size(); }
138
139#endif // BESRNDMGENSVC_H
140
141
StatusCode initialize()
Gaudi Service Implementation.
void print(void)
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:
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
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.
manage multiple CLHEP random engines as named streams