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 // rev.  aug 30 2001 lena: added genId and ct.
003 //
004 
005 // String Header First  --
006 //------------------------
007 #include <string>
008 using std::string;
009 #include <string.h>
010 
011 //-----------------------
012 // This Class's Header --
013 //-----------------------
014 #include "generatorMods/PythiaModule.hh"
015 #include "pythia_i/Pythia.hh"
016 #include "stdhep_i/CdfHepevt.hh"
017 
018 //---------------
019 // C++ Headers -- MUST use defects !!!!
020 //---------------
021 #include <iostream>
022 #include <iomanip>
023 using std::cout;
024 using std::endl;
025 using std::setw;
026 
027 //-------------------------------
028 // Collaborating Class Headers --
029 //-------------------------------
030 #include "AbsEnv/AbsEnv.hh"
031 #include "stdhep_i/CdfHepevt.hh"
032 
033 // Access to STDHEP LUNs
034 //#include "stdlun.h"
035 
036 //-----------------------------------------------------------------------
037 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
038 //-----------------------------------------------------------------------
039 
040 const char* PythiaModule::genId="Pythia";
041 
042 //----------------
043 // Constructors --
044 //----------------
045 
046 PythiaModule::PythiaModule() : 
047   AbsGenModule( PythiaModule::genId, 
048                 "AC++ Pythia module"),
049   _pythiaMenu( new PythiaMenu( this, 0, "PythiaMenu") )
050 {
051 
052   _initializeTalkTo();
053 }
054 
055 //--------------
056 // Destructor --
057 //--------------
058 
059 PythiaModule::~PythiaModule()
060 {
061   delete _pythiaMenu;
062 }
063 
064 AppResult PythiaModule::genBeginRun(AbsEvent* aRun) {
065   return AppResult::OK;
066 }
067 
068 AppResult PythiaModule::genBeginJob() {
069 
070   Pythia* pythia = Pythia::Instance(); 
071   
072   if(Pythia::Instance()->pydat3().lenMdme() == 8000 && 
073      Pythia::Instance()->pypars().mstp(182) < 200) {
074     errlog(ELfatal,"[PYTHIA_VERS_ERRO]")
075       << "PythiaModule: Common blocks are incorrect for Pythia version,"
076       << "please delete binaries, setup lund v6_203 (or later) and rebuild." 
077       << endmsg;
078   }
079   // set longer lived Ks and lambdas stable to be decayed in detector
080   int index;
081   int massCode[] = {310,3112,3122,3222,3312,3322,3334};
082   for (int i = 0; i<7; i++) {
083     index = Pythia::Instance()->Pycomp(&massCode[i]);
084     Pythia::Instance()->pydat3().mdcy(index,1) = 0;
085   }
086   std::cout<< "PythiaModule: Please note the following long lived strange " 
087            << "particles have been" << std::endl;
088   std::cout<< "              set stable and cannot be set to decay"<<std::endl;
089   std::cout<< "              K_0S, Lambda, Sigma, Xi and Omega." <<std::endl;
090   
091   // Prevent pile-up
092   if (pythia->pypars().mstp(131)) {
093     pythia->pypars().mstp(131)=0;
094     ERRLOG(ELerror,"[PYTHIA_NO_PILEUP]")
095       << "PythiaModule: Pile up selected but is not currently supported, "
096       << "now turned off"
097       << endmsg;
098   }
099   // Allow Pythia to mix B0 mesons, should be off to let EvtGen do this
100   if (_pythiaMenu->allowBMixing()) {    
101     ERRLOG(ELsuccess,"[PYTHIA_DCYTBL_R")
102       << "PythiaModule: B-Bbar mixing is enabled though this will "
103       << "conflict with EvtGen if used" << endmsg;
104   } else { 
105     if( pythia->pydat1().mstj(26) != 0)    
106       ERRLOG(ELwarning,"[PYTHIA_BMIXOF_R]")
107         << "PythiaModule: B-Bbar mixing is disabled and should " 
108         << "be done using EvtGen"  << endmsg; 
109     pythia->pydat1().mstj(26)=0;    
110   }
111   // Read a decay table:
112   std::string fileMode = _pythiaMenu->decayFileMode();
113   std::string fileName = _pythiaMenu->decayFile();
114   if (!fileName.empty()) {
115     if (fileMode=="READ" || fileMode=="read") {
116       int mode=_pythiaMenu->decayTableMode();
117       int lun=37;
118       if (pythia->Opdcay(fileName,&lun,"R")) {
119         ERRLOG(ELerror,"[PYTHIA_NO_DCYTBL]")
120           << "PythiaModule: decay table file " 
121           << "\"" << fileName << "\"\n"
122           << "cannot be opened for read!" << endmsg;
123       } else {
124       pythia->Pyupda(&mode,&lun);
125       pythia->Cldcay(&lun);
126       ERRLOG(ELsuccess,"[PYTHIA_DCYTBL_R")
127         << "PythiaModule: read decay table file "
128         << "\"" << fileName << "\"" << endmsg;
129       }
130     }
131   } 
132   // if non zero value of mstp(142) set up weighting
133   if(pythia->pypars().mstp(142)) {
134     double expwt = _pythiaMenu->expWeight();
135     int param = _pythiaMenu->weightParam();
136     pythia->Pyevwt(&param, &expwt);
137   }
138   std::string frame  = _pythiaMenu->frame();
139   std::string target = _pythiaMenu->getTarget();
140   double winval = _pythiaMenu->win();
141   int minlist   = _pythiaMenu->initlistlevel();
142   pythia->pysubs().msel() = _pythiaMenu->msel();
143   //  pythia->pydatr().mrpy(1) = _pythiaMenu->randomseed();
144   std::string pygiveFile = _pythiaMenu->pygiveFile();
145   if(pygiveFile.size()) 
146     {
147       std::cout << "Pygive file  " << pygiveFile << std::endl;
148       pythia->Pygive(pygiveFile);
149     } 
150    // Underlying Event and Min Bias tunings
151   if (_pythiaMenu->tuneUE() > 0 ) {
152     if( pythia->pypars().mstp(181)==6 && pythia->pypars().mstp(182) > 404 ){
153       pythia->Pytune(_pythiaMenu->tuneUE());
154     } else {
155       ERRLOG(ELerror,"[PYTHIA_NO_TUNEUE]")
156           << "PythiaModule: Pytune called, " 
157           << "please upgrade to version 6.405 or later" << endmsg;
158     }
159   }
160   pythia->Pyinit(frame,target,&winval );
161   pythia->setEvents(0);
162   pythia->setEventListLevel(minlist);
163   pythia->Pylist(&minlist);
164 
165   // Write a new decay table:
166   if (!fileName.empty()) {
167     if (fileMode=="WRITE" || fileMode=="write") {
168       int mode=1;
169       int lun=37;
170       if (pythia->Opdcay(fileName,&lun,"W")) {
171         ERRLOG(ELerror,"[PYTHIA_NO_DCYTBL]")
172           << "PythiaModule: decay table file " 
173           << "\"" << fileName << "\"\n"
174           << "cannot be opened for write!" << endmsg;
175       } else {
176         pythia->Pyupda(&mode,&lun);
177         pythia->Cldcay(&lun);
178         ERRLOG(ELsuccess,"[PYTHIA_DCYTBL_W]")
179           << "PythiaModule: wrote decay table file "
180           << "\"" << fileName << "\"" << endmsg;
181       }
182     }
183   }
184   pythia->setFirstListEvent( _pythiaMenu->firstlistevent() );
185   pythia->setLastListEvent ( _pythiaMenu->lastlistevent() );
186   pythia->setEventListLevel(_pythiaMenu->eventlistlevel());
187   std::cout << " Event list level " 
188             << _pythiaMenu->eventlistlevel()
189             << std::endl;
190 
191   return AppResult::OK;
192 }
193 
194 int PythiaModule::callGenerator(AbsEvent* anEvent) {
195     
196   Pythia* pythia = Pythia::Instance();
197 
198   // Generate the event
199   pythia->Pyevnt();
200   bool eventList = ( pythia->events() >= pythia->FirstListEvent() && 
201                      pythia->events() <= pythia->LastListEvent() );
202 
203   if (_pythiaMenu->selectPdg()!=0) {
204     int code = _pythiaMenu->selectPdg();
205     int icount = 0;
206     while(pythia->findPdgCode(&code)==false) {
207       if ( verbose() ) {
208         if (++icount%100==0 && eventList) std::cout << name() << "::callGenerator generated " << icount << std::endl;
209       }
210        pythia->Pyevnt();
211     }
212   }
213 
214   // Update our event counter 
215   pythia->addEvent();  // See if we are supposed to list this event  
216   int mevlist= pythia->EventListLevel();
217   // edit the event if needed
218   int medit = _pythiaMenu->pyeditAction();
219   if( medit >= 0 ) pythia->Pyedit(&medit);
220   if ( eventList ) {
221     std::cout << "PYEVNT event no. " << pythia->events() 
222               <<" level " << mevlist;
223     if( medit >= 0 ) std::cout << " after PYEDIT action = " << medit; 
224     std::cout << std::endl;
225     pythia->Pylist(&mevlist); // List this event if required
226   }
227   
228   return 0;  
229 }
230  
231 void PythiaModule::fillHepevt() {
232 
233   Pythia* pythia = Pythia::Instance();
234   // Tell lunhep to convert from PYJETS to HEPEVT
235   int mconv=1;                          
236   // Do the conversion
237   pythia->Lunhep(&mconv); // Use STDHEP translation routine 1999/01/27 CG
238   CdfHepevt::Instance()->HepevtPtr()->NEVHEP = pythia->events();
239 
240 // fill in some HEPEV4 info, courtesy of Dmitri Tsybychev
241   CdfHepevt::Instance()->Hepev4Ptr()->SCALELH[5] =
242 pythia->pypars().pari(17);
243 
244   CdfHepevt::Instance()->Hepev4Ptr()->EVENTWEIGHTLH=
245 pythia->pypars().pari(10);
246 //dt.end
247 
248 }
249 
250 AppResult PythiaModule::genEndRun(AbsEvent* aRun) {
251   Pythia* pythia = Pythia::Instance();
252   int mstat = _pythiaMenu->statlistlevel();
253   cout << "Call PYSTAT at endRun" << endl;
254   pythia->Pystat(&mstat);
255 
256   return AppResult::OK;
257 }
258 
259 AppResult PythiaModule::genEndJob() {
260   Pythia* pythia = Pythia::Instance();
261   int mstat = _pythiaMenu->statlistlevel();
262   cout << "Call PYSTAT at endJob" << endl;
263   pythia->Pystat(&mstat);
264 
265   return AppResult::OK;
266 }
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 

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