BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEvtGen-00-04-08/src/EvtGen/EvtGenBase/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 "EvtGenBase/EvtPatches.hh"
22#include <iostream>
23#include <iomanip>
24#include <fstream>
25#include <ctype.h>
26#include <stdlib.h>
27#include <assert.h>
28#include "EvtGenBase/EvtParticle.hh"
29#include "EvtGenBase/EvtRandom.hh"
30#include "EvtGenBase/EvtModel.hh"
31#include "EvtGenBase/EvtPDL.hh"
32#include "EvtGenBase/EvtDecayParm.hh"
33#include "EvtGenBase/EvtDecayBase.hh"
34#include "EvtGenBase/EvtParticleDecayList.hh"
35#include "EvtGenBase/EvtParser.hh"
36#include "EvtGenBase/EvtReport.hh"
37#include <string>
38using std::fstream;
39
40EvtModel* EvtModel::_instance=0;
41
42EvtModel::EvtModel() {
43
44}
45
46EvtDecayBase* EvtModel::getFcn(std::string model_name){
47
48 EvtDecayBase *model=0;
49 if ( _modelNameHash.find(model_name)!=_modelNameHash.end() ) {
50 model=_modelNameHash[model_name];
51 }
52
53 if (model==0){
54 report(ERROR,"EvtGen") << "Did not find the right model:"
55 <<model_name.c_str()<<"\n";
56 return 0;
57 }
58
59 return model->clone();
60
61}
62
63
64void EvtModel::Register(EvtDecayBase* prototype){
65
66 std::string modelName;
67 prototype->getName(modelName);
68
69 _modelNameHash[modelName]=prototype;
70
71 std::string commandName=prototype->commandName();
72
73 if (commandName!=""){
74
75 //report(DEBUG,"EvtGen") << "Adding command:"<<commandName<<endl;
76
77 _commandNameHash[commandName]=prototype;
78
79 }
80
81}
82
83int EvtModel::isModel(std::string model_name){
84
85 if ( _modelNameHash.find(model_name)!=_modelNameHash.end() ) {
86 return 1;
87 }
88 return 0;
89}
90
91
92int EvtModel::isCommand(std::string cmd){
93
94 if ( _commandNameHash.find(cmd)!=_commandNameHash.end() ) {
95 return 1;
96 }
97 return 0;
98}
99
100void EvtModel::storeCommand(std::string cmd,std::string cnfgstr){
101
102 EvtDecayBase *model=0;
103 if ( _commandNameHash.find(cmd)!=_commandNameHash.end() ) {
104 model=_commandNameHash[cmd];
105 }
106
107 assert(model!=0);
108
109 model->command(cnfgstr);
110
111}
112
113
114
115
ostream & report(Severity severity, const char *facility)
virtual EvtDecayBase * clone()=0
virtual void getName(std::string &name)=0
EvtDecayBase * getFcn(std::string model_name)
void storeCommand(std::string cmd, std::string cnfgstr)