Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8310193
Settings.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
Settings.h
View Options
//==============================================================================
// Settings.h
//
// Copyright (C) 2010-2013 Tobias Toll and Thomas Ullrich
//
// This file is part of Sartre version: 1.1
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation.
// This program is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of
// merchantability or fitness for a particular purpose. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Author: Thomas Ullrich
// Last update:
// $Date: 2013-05-29 21:26:19 +0100 (Wed, 29 May 2013) $
// $Author: thomas.ullrich@bnl.gov $
//==============================================================================
#ifndef Settings_h
#define Settings_h
#include
<iostream>
#include
<string>
#include
<vector>
#include
<map>
#include
"TDatabasePDG.h"
#include
"TRandom3.h"
using
namespace
std
;
class
TParticlePDG
;
class
SettingsParameterBase
{
public
:
virtual
~
SettingsParameterBase
()
{}
public
:
string
name
;
};
template
<
typename
T
>
class
SettingsParameter
:
public
SettingsParameterBase
{
public
:
T
*
address
;
T
defaultValue
;
};
class
Settings
{
public
:
Settings
();
virtual
~
Settings
();
bool
readSettingsFromFile
(
const
char
*
);
virtual
bool
list
(
ostream
&
=
cout
);
TParticlePDG
*
lookupPDG
(
int
)
const
;
string
particleName
(
int
pdgID
);
static
TRandom3
*
randomGenerator
();
unsigned
int
seed
()
const
;
void
setSeed
(
unsigned
int
);
int
userInt
()
const
;
double
userDouble
()
const
;
string
userString
()
const
;
void
setUserInt
(
int
);
void
setUserDouble
(
double
);
void
setUserString
(
const
string
&
);
protected
:
template
<
typename
T
>
void
registerParameter
(
T
*
,
const
char
*
,
T
);
virtual
void
consolidateSettings
()
=
0
;
protected
:
vector
<
SettingsParameterBase
*>
mRegisteredParameters
;
static
TRandom3
mRandomGenerator
;
unsigned
int
mSeed
;
private
:
string
mRuncard
;
vector
<
string
>
mLines
;
TDatabasePDG
*
mPDG
;
map
<
int
,
string
>
mPeriodicTable
;
int
mUserInt
;
double
mUserDouble
;
string
mUserString
;
};
template
<
typename
T
>
void
Settings
::
registerParameter
(
T
*
var
,
const
char
*
name
,
T
def
)
{
SettingsParameter
<
T
>*
sv
=
new
SettingsParameter
<
T
>
;
sv
->
address
=
var
;
sv
->
name
=
name
;
sv
->
defaultValue
=
def
;
*
var
=
def
;
mRegisteredParameters
.
push_back
(
sv
);
}
inline
TRandom3
*
Settings
::
randomGenerator
()
{
return
&
mRandomGenerator
;}
#endif
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sat, Dec 21, 5:38 PM (12 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4003612
Default Alt Text
Settings.h (3 KB)
Attached To
rSARTRESVN sartresvn
Event Timeline
Log In to Comment