BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtModel.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtModel.cc
12//
13// Description:
14//
15// Modification history:
16//
17// RYD September 25, 1996 Module created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtModel.hh"
22#include "EvtDecayBase.hh"
23#include "EvtDecayParm.hh"
24#include "EvtPDL.hh"
25#include "EvtParser.hh"
26#include "EvtParticle.hh"
28#include "EvtPatches.hh"
29#include "EvtRandom.hh"
30#include "EvtReport.hh"
31#include <assert.h>
32#include <ctype.h>
33#include <fstream>
34#include <iomanip>
35#include <iostream>
36#include <stdlib.h>
37#include <string>
38using std::fstream;
39
40EvtModel* EvtModel::_instance = 0;
41
42EvtModel::EvtModel() {}
43
44EvtDecayBase* EvtModel::getFcn( std::string model_name ) {
45
46 EvtDecayBase* model = 0;
47 if ( _modelNameHash.find( model_name ) != _modelNameHash.end() )
48 { model = _modelNameHash[model_name]; }
49
50 if ( model == 0 )
51 {
52 report( ERROR, "EvtGen" ) << "Did not find the right model:" << model_name.c_str() << "\n";
53 return 0;
54 }
55
56 return model->clone();
57}
58
59void EvtModel::Register( EvtDecayBase* prototype ) {
60
61 std::string modelName;
62 prototype->getName( modelName );
63
64 _modelNameHash[modelName] = prototype;
65
66 std::string commandName = prototype->commandName();
67
68 if ( commandName != "" )
69 {
70
71 // report(DEBUG,"EvtGen") << "Adding command:"<<commandName<<endl;
72
73 _commandNameHash[commandName] = prototype;
74 }
75}
76
77int EvtModel::isModel( std::string model_name ) {
78
79 if ( _modelNameHash.find( model_name ) != _modelNameHash.end() ) { return 1; }
80 return 0;
81}
82
83int EvtModel::isCommand( std::string cmd ) {
84
85 if ( _commandNameHash.find( cmd ) != _commandNameHash.end() ) { return 1; }
86 return 0;
87}
88
89void EvtModel::storeCommand( std::string cmd, std::string cnfgstr ) {
90
91 EvtDecayBase* model = 0;
92 if ( _commandNameHash.find( cmd ) != _commandNameHash.end() )
93 { model = _commandNameHash[cmd]; }
94
95 assert( model != 0 );
96
97 model->command( cnfgstr );
98}
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
virtual EvtDecayBase * clone()=0
virtual void getName(std::string &name)=0
virtual void command(std::string cmd)
virtual std::string commandName()
EvtDecayBase * getFcn(std::string model_name)
Definition EvtModel.cc:44
void storeCommand(std::string cmd, std::string cnfgstr)
Definition EvtModel.cc:89
void Register(EvtDecayBase *prototype)
Definition EvtModel.cc:59
int isModel(std::string name)
Definition EvtModel.cc:77
int isCommand(std::string cmd)
Definition EvtModel.cc:83