]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGenBase/EvtModel.cxx
Removing the flat makefiles
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtModel.cxx
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/EvtDecayBase.hh"
33 #include "EvtGenBase/EvtParticleDecayList.hh"
34 #include "EvtGenBase/EvtParser.hh"
35 #include "EvtGenBase/EvtReport.hh"
36 #include <string>
37 using std::fstream;
38
39 EvtModel* EvtModel::_instance=0;
40
41 EvtModel::EvtModel() {
42
43 }
44
45 EvtDecayBase* EvtModel::getFcn(std::string model_name){
46
47   EvtDecayBase *model=0;
48   if ( _modelNameHash.find(model_name)!=_modelNameHash.end() ) {
49     model=_modelNameHash[model_name];
50   }
51
52   if (model==0){
53     report(ERROR,"EvtGen") << "Did not find the right model:"
54                            <<model_name.c_str()<<"\n";
55     return 0;
56   }
57
58   return model->clone();
59
60 }
61
62
63 void EvtModel::registerModel(EvtDecayBase* prototype){
64
65   std::string modelName= prototype->getName();
66
67   _modelNameHash[modelName]=prototype;
68
69   std::string commandName=prototype->commandName();
70   
71   if (commandName!=""){
72
73     _commandNameHash[commandName]=prototype;
74
75   }
76
77 }
78
79 int EvtModel::isModel(std::string model_name){
80
81   if ( _modelNameHash.find(model_name)!=_modelNameHash.end() ) {
82     return 1;
83   }
84   return 0;
85 }
86
87
88 int EvtModel::isCommand(std::string cmd){
89
90   if ( _commandNameHash.find(cmd)!=_commandNameHash.end() ) {
91     return 1;
92   }
93   return 0;
94 }
95
96 void EvtModel::storeCommand(std::string cmd,std::string cnfgstr){
97
98   EvtDecayBase *model=0;
99   if ( _commandNameHash.find(cmd)!=_commandNameHash.end() ) {
100     model=_commandNameHash[cmd];
101   }
102
103   assert(model!=0);
104
105   model->command(cnfgstr);
106
107 }
108
109
110
111