LCOV - code coverage report
Current view: top level - TEvtGen/EvtGenExternal - EvtExternalGenFactory.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 50 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 10 0.0 %

          Line data    Source code
       1             : //--------------------------------------------------------------------------
       2             : //
       3             : // Environment:
       4             : //      This software is part of the EvtGen package. If you use all or part
       5             : //      of it, please give an appropriate acknowledgement.
       6             : //
       7             : // Copyright Information: See EvtGen/COPYRIGHT
       8             : //      Copyright (C) 2011      University of Warwick, UK
       9             : //
      10             : // Module: EvtExternalGenFactory
      11             : //
      12             : // Description: A factory type method to create engines for external physics
      13             : // generators like Pythia.
      14             : //
      15             : // Modification history:
      16             : //
      17             : //    John Back       April 2011            Module created
      18             : //
      19             : //------------------------------------------------------------------------------
      20             : //
      21             : 
      22             : #include "EvtGenBase/EvtPatches.hh"
      23             : #include "EvtGenBase/EvtReport.hh"
      24             : #include "EvtGenExternal/EvtExternalGenFactory.hh"
      25             : 
      26             : #ifdef EVTGEN_PYTHIA
      27             : #include "EvtGenExternal/EvtPythiaEngine.hh"
      28             : #endif
      29             : 
      30             : #ifdef EVTGEN_PHOTOS
      31             : #include "EvtGenExternal/EvtPhotosEngine.hh"
      32             : #endif
      33             : 
      34             : #ifdef EVTGEN_TAUOLA
      35             : #include "EvtGenExternal/EvtTauolaEngine.hh"
      36             : #endif
      37             : 
      38             : #include <iostream>
      39             : using std::endl;
      40             : 
      41           0 : EvtExternalGenFactory::EvtExternalGenFactory() {
      42             : 
      43           0 :   _extGenMap.clear();
      44             : 
      45           0 : }
      46             : 
      47           0 : EvtExternalGenFactory::~EvtExternalGenFactory() {
      48             : 
      49           0 :   ExtGenMap::iterator iter;
      50           0 :   for (iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter) {
      51             : 
      52           0 :     EvtAbsExternalGen* theGenerator = iter->second;
      53           0 :     delete theGenerator;
      54             : 
      55             :   }
      56             :   
      57           0 :   _extGenMap.clear();
      58             : 
      59           0 : }
      60             : 
      61             : EvtExternalGenFactory* EvtExternalGenFactory::getInstance() {
      62             : 
      63             :   static EvtExternalGenFactory* theFactory = 0;
      64             :   
      65           0 :   if (theFactory == 0) {
      66           0 :     theFactory = new EvtExternalGenFactory();
      67           0 :   }
      68             : 
      69           0 :   return theFactory;
      70             : 
      71             : }
      72             : 
      73             : void EvtExternalGenFactory::definePythiaGenerator(std::string xmlDir, 
      74             :                                                   bool convertPhysCodes,
      75             :                                                   bool useEvtGenRandom) {
      76             : 
      77             :   // Only define the generator if we have the external ifdef variable set
      78             : #ifdef EVTGEN_PYTHIA
      79             : 
      80           0 :   int genId = EvtExternalGenFactory::PythiaGenId;
      81             : 
      82           0 :   report(Severity::Info,"EvtGen")<<"Defining EvtPythiaEngine: data tables defined in "
      83           0 :                        <<xmlDir<<endl;
      84             : 
      85           0 :   if (convertPhysCodes == true) {
      86           0 :     report(Severity::Info,"EvtGen")<<"Pythia 6 codes in decay files will be converted to Pythia 8 codes"<<endl;
      87           0 :   } else {
      88           0 :     report(Severity::Info,"EvtGen")<<"Pythia 8 codes need to be used in decay files"<<endl;
      89             :   }
      90             : 
      91           0 :   if (useEvtGenRandom == true) {
      92           0 :     report(Severity::Info,"EvtGen")<<"Using EvtGen random engine for Pythia 8 as well"<<endl;
      93           0 :   }
      94             : 
      95           0 :   EvtAbsExternalGen* pythiaGenerator = new EvtPythiaEngine(xmlDir, convertPhysCodes, useEvtGenRandom);
      96           0 :   _extGenMap[genId] = pythiaGenerator;
      97             : 
      98             : #endif
      99             : 
     100           0 : }
     101             : 
     102             : void EvtExternalGenFactory::definePhotosGenerator(std::string photonType, bool useEvtGenRandom) {
     103             : 
     104             : #ifdef EVTGEN_PHOTOS
     105             : 
     106           0 :   int genId = EvtExternalGenFactory::PhotosGenId;
     107           0 :   report(Severity::Info,"EvtGen")<<"Defining EvtPhotosEngine using photonType = "<<photonType<<endl;
     108           0 :   EvtAbsExternalGen* photosGenerator = new EvtPhotosEngine(photonType, useEvtGenRandom);
     109           0 :   _extGenMap[genId] = photosGenerator;
     110             : 
     111             : #endif
     112             : 
     113           0 : }
     114             : 
     115             : void EvtExternalGenFactory::defineTauolaGenerator(bool useEvtGenRandom) {
     116             : 
     117             : #ifdef EVTGEN_TAUOLA
     118             : 
     119           0 :   int genId = EvtExternalGenFactory::TauolaGenId;
     120           0 :   report(Severity::Info,"EvtGen")<<"Defining EvtTauolaEngine."<<endl;
     121           0 :   EvtAbsExternalGen* tauolaGenerator = new EvtTauolaEngine(useEvtGenRandom);
     122           0 :   _extGenMap[genId] = tauolaGenerator;
     123             : 
     124             : #endif
     125             : 
     126           0 : }
     127             : 
     128             : EvtAbsExternalGen* EvtExternalGenFactory::getGenerator(int genId) {
     129             : 
     130             :   EvtAbsExternalGen* theGenerator(0);
     131             : 
     132           0 :   ExtGenMap::iterator iter;
     133             : 
     134           0 :   if ((iter = _extGenMap.find(genId)) != _extGenMap.end()) {
     135             : 
     136             :     // Retrieve the external generator engine
     137           0 :     theGenerator = iter->second;
     138             : 
     139           0 :   }
     140             : 
     141           0 :   return theGenerator;
     142             : 
     143           0 : }
     144             : 
     145             : void EvtExternalGenFactory::initialiseAllGenerators() {
     146             : 
     147           0 :   ExtGenMap::iterator iter;
     148           0 :   for (iter = _extGenMap.begin(); iter != _extGenMap.end(); ++iter) {
     149             : 
     150           0 :     EvtAbsExternalGen* theGenerator = iter->second;
     151           0 :     if (theGenerator != 0) {
     152           0 :       theGenerator->initialise();
     153           0 :     }
     154             : 
     155             :   }
     156             :   
     157           0 : }

Generated by: LCOV version 1.11