CDF II
CDF KITS
source navigation ]
diff markup ]
identifier search ]
freetext search ]
file search ]
 
Architecture: i386 ]
Version: 4.10.4 ] [ 4.10.5 ] [ 4.8.4 ] [ 4.8.4l3s ] [ 4.8.5 ] [ 4.9.0 ] [ 4.9.1 ] [ 4.9.1.hpt3 ] [ 4.9.1hpt3 ] [ 4.9.1top1 ] [ 5.0.0 ] [ 5.1.0 ] [ 5.1.0beamonly ] [ 5.1.1 ] [ 5.2.0 ] [ 5.3.0 ] [ 5.3.1 ] [ 5.3.1dsp ] [ 5.3.3 ] [ 5.3.3_nt ] [ 5.3.4 ] [ 6.1.1 ] [ 6.1.1b ] [ 6.1.2 ] [ 6.1.3 ] [ 6.1.4 ] [ 6.1.4int3 ] [ 6.1.4mc ] [ 6.1.4mc_a ] [ 6.1.6 ] [ development ]

001 //***************************************************************************
002 //* W. H. Bell ************ Feb 15, 2001 ************************************
003 //* A module to allow HEPG Bank production from Pythia & EvtGen or EvtGen.  *
004 //***************************************************************************/
005 // rev: March 22 2003 RJT:  Rename decayBuBdBs --> decayBMeson
006 //                          add decayBBaryon.
007 // rev: April 1st 2002 fkw: got rid of CdfHepEvt, fixe typo in talk-to
008 //                          Paricles are now Particles
009 // 
010 // rev: dec 07 2001 lena: inherited AbsDecpackModule; 
011 //                        replaced CdfHepEvt by CdfHepevt;
012 
013 #include "generatorMods/EvtGenMod.hh"
014 #include "EvtGenBase/EvtRandomEngine.hh"
015 
016 // CLHEP Random Number headers
017 #include "r_n/CdfRn.hh"
018 #include "CLHEP/config/CLHEP.h"
019 #include "CLHEP/Random/RandomEngine.h"
020 #include "CLHEP/Vector/LorentzRotation.h"
021 
022 #include "AbsEnv/AbsEnv.hh"
023 #include "SimulationObjects/HEPG_StorableBank.hh"
024 #include "Edm/Handle.hh"
025 #include "Edm/ConstHandle.hh"
026 #include "Edm/EventRecord.hh"
027 
028 #include "stdhep_i/CdfHepEvt.hh"  // <= to be fixed
029 
030 #include <string>
031 #include <assert.h>
032 #include <time.h>
033 #include <iostream>
034 #include <cstdlib>
035 
036 const char* EvtGenMod::genId="EvtGen";
037 
038 //fkw October 13th, 2002
039 //define class for generating random nubers
040 //The purpose of this class is to wrap an EvtRandomEngine
041 //around Elena's way of organizing random engines in CdfRn.
042 //As a result, the EvtGen code does not need to be changed
043 //and nevertheless it uses Elena's mechanism for keeping
044 //track of random numbers.
045 //The pointer to an instance of this class is made a member function
046 //of EvtGenMod because I wasn't sure if that's required to not
047 //drop it out of scope.
048 //fkw October 13th, 2002
049 class EvtCLHEPRandomEngine:public EvtRandomEngine{
050 public:
051   double random();
052   EvtCLHEPRandomEngine(long seed1, long seed2);
053 private:
054   HepRandomEngine* _engine;
055 };
056 
057 double EvtCLHEPRandomEngine::random(){
058   return _engine->flat();
059 }
060 
061 //constructor:
062 EvtCLHEPRandomEngine::EvtCLHEPRandomEngine(long seed1, long seed2) {
063    CdfRn* rn = CdfRn::Instance();
064    rn->SetEngineSeeds(seed1, seed2, EvtGenMod::genId);
065    _engine = CdfRn::Instance()->GetEngine(EvtGenMod::genId);
066 }
067 
068 //----------------
069 // Constructors --
070 //----------------
071 
072 //fkw 4/6/2001 Kai 4.0 does not allow strings to be initialized with NULL.
073 //             I therefore had to initialize _useUserDecayFile with "dummy"
074 EvtGenMod::EvtGenMod() : 
075   AbsDecpackModule(EvtGenMod::genId,"AC++ EvtGen module"),
076       _useRootParticle("UseRootParticle",this,false),
077       _rootParticlePx("RootParticlePx",this,0.0),
078       _rootParticlePy("RootParticlePy",this,0.0),
079       _rootParticlePz("RootParticlePz",this,0.0),
080       _rootParticleHepID("RootParticleHepID",this,0),
081       _useUserDecayFile("UseUserDecayFile",this,false),
082       _userDecayFile("UserDecayFile",this,"dummy"),
083       _adjustCPAsymm("AdjustCPAsymm",this,false),
084       _decayPromptCharm("DecayPromptCharm",this,false),
085       _decayBMeson("DecayBMeson",this,true),
086       _decayBBaryon("DecayBBaryon",this,true),
087       _randomSeed1("RandomSeed1",this,0),
088       _randomSeed2("RandomSeed2",this,0)
089 {
090   _eventCount = 0;
091   _generator = NULL;
092   _myevtgenInterface = NULL;
093   _myRandomEngine = NULL;
094   _initializeTalkTo();
095 }
096 
097 //--------------
098 // Destructor --
099 //--------------
100 
101 EvtGenMod::~EvtGenMod()
102 {
103 }
104 
105 //--------------
106 // Operations --
107 //--------------
108 
109 AppResult EvtGenMod::genBeginJob()
110 {  
111   char *decay_file, *pdt_table;
112   std::string filename;
113 
114   _myRandomEngine=new EvtCLHEPRandomEngine(_randomSeed1.value(), _randomSeed2.value());
115 
116   // Initialise EvtGen: reads decay file and properties file.
117   if((decay_file = getenv("EVTGEN_DECAY_FILE"))==NULL) {
118     ERRLOG(ELfatal,"[EVTGEN_NO_DCYTBL]")
119       << "EvtGenModule: EVTGEN_DECAY_FILE not set"
120       << endmsg;
121   }
122   else if((pdt_table = getenv("EVTGEN_PDT_TABLE"))==NULL) {
123     ERRLOG(ELfatal,"[EVTGEN_NO_DCYTBL]")
124       << "EvtGenModule: EVTGEN_PDT_TABLE not set"
125       << endmsg;
126   }
127   else {
128     _generator = new EvtGen(decay_file,pdt_table,_myRandomEngine);
129     
130     filename = _userDecayFile.value();
131     if(_useUserDecayFile.value()) { 
132       _generator->readUDecay(filename.c_str());
133     }
134 
135     _myevtgenInterface = new EvtGenInterface(_generator,_adjustCPAsymm.value(),_verbose.value(), _decayBMeson.value(), _decayBBaryon.value(), _decayPromptCharm.value());
136   }
137   return AppResult::OK;
138 }
139 
140 int  EvtGenMod::callGenerator(AbsEvent* anEvent)
141 {
142   //CdfHepEvt hepevt;   // <= to be fixed
143   //hepevt.init();     //  <= to be fixed
144 
145   _eventCount++;
146   double p[3];
147   int errorFlag;
148 
149   if (_verbose.value())
150     std::cout << "=========== begining event # " << _eventCount << std::endl;
151   
152   if(_useRootParticle.value()) {
153     if( _eventCount < 3 && _eventCount > 0) 
154       std::cout <<  name() << "Using root particle\n";
155     p[0]=_rootParticlePx.value();
156     p[1]=_rootParticlePy.value();
157     p[2]=_rootParticlePz.value();
158     //errorFlag = _myevtgenInterface->DecayRoot(&hepevt,_rootParticleHepID.value(),p);
159     errorFlag = _myevtgenInterface->DecayRoot(_rootParticleHepID.value(),p);
160   }
161   else {
162     if( _eventCount < 3 && _eventCount > 0) 
163       std::cout <<  name() << "Finding B Mesons and about to enter DecayAll\n";
164     //errorFlag = _myevtgenInterface->DecayAll(&hepevt);
165     errorFlag = _myevtgenInterface->DecayAll();
166   }
167 
168   return 1;
169 }
170 
171 AppResult EvtGenMod::genEndJob()
172 {
173   if(_generator != NULL)
174     delete _generator;
175   if(_myevtgenInterface != NULL)
176     delete _myevtgenInterface;
177  
178   return AppResult::OK;
179 }
180 
181 AppResult EvtGenMod::genBeginRun( AbsEvent* anEvent )
182 {
183   return AppResult::OK;
184 }
185 
186 AppResult EvtGenMod::genEndRun( AbsEvent* anEvent )
187 {
188   return AppResult::OK;
189 }
190 
191 
192 
193 
194 /**************************************************************************/
195 
196 void EvtGenMod::_initializeTalkTo() {
197   _useRootParticle.addDescription("\t\tSelect root particle (T) or read HepEvt (F)");
198   _rootParticleHepID.addDescription("\t\tUses standard PDG particle codes");
199   _adjustCPAsymm.addDescription("\t\tAccount for integrated probability of B mixing;\n\t\tUsed to generate CP violation.\n\t\t Default = false");
200   _decayPromptCharm.addDescription("\t\tDecay prompt charm from hard scatter generator\n\t\t Default = false");
201   _decayBMeson.addDescription("Decay B mesons from hard scatter generator\n\t\t Default = true\t\t");
202   _decayBBaryon.addDescription("Decay B baryons from hard scatter generator\n\t\t Default = true\t\t");
203   commands()->append(&_useRootParticle);
204   commands()->append(&_rootParticlePx);
205   commands()->append(&_rootParticlePy);
206   commands()->append(&_rootParticlePz);
207   commands()->append(&_rootParticleHepID);
208   commands()->append(&_useUserDecayFile);
209   commands()->append(&_userDecayFile);
210   commands()->append(&_adjustCPAsymm);
211   commands()->append(&_decayPromptCharm);
212   commands()->append(&_decayBMeson);
213   commands()->append(&_decayBBaryon);
214   commands()->append(&_randomSeed1);
215   commands()->append(&_randomSeed2);
216 }
217 
218 

source navigation ] diff markup ] identifier search ] freetext search ] file search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!

Send problems or questions to cdfcode@fnal.gov