CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc

Go to the documentation of this file.
00001 
00002 #include "GeneratorInterface/ExternalDecays/interface/ExternalDecayDriver.h"
00003 
00004 #include "GeneratorInterface/ExternalDecays/interface/EvtGenInterface.h"
00005 #include "GeneratorInterface/ExternalDecays/interface/TauolaInterface.h"
00006 #include "GeneratorInterface/ExternalDecays/interface/PhotosInterface.h"
00007 
00008 #include "GeneratorInterface/ExternalDecays/interface/DecayRandomEngine.h"
00009 
00010 #include "HepMC/GenEvent.h"
00011 
00012 #include "FWCore/ServiceRegistry/interface/Service.h"
00013 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00014 #include "FWCore/Utilities/interface/Exception.h"
00015 
00016 using namespace gen;
00017 using namespace edm;
00018 
00019 CLHEP::HepRandomEngine* decayRandomEngine;
00020 
00021 ExternalDecayDriver::ExternalDecayDriver( const ParameterSet& pset )
00022    : fIsInitialized(false),
00023      fTauolaInterface(0),
00024      fEvtGenInterface(0),
00025      fPhotosInterface(0)
00026 {
00027     
00028     std::vector<std::string> extGenNames =
00029        pset.getParameter< std::vector<std::string> >("parameterSets");
00030 
00031     Service<RandomNumberGenerator> rng;
00032     if(!rng.isAvailable()) {
00033        throw cms::Exception("Configuration")
00034        << "The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
00035           "which appears to be absent.  Please add that service to your configuration\n"
00036           "or remove the modules that require it." << std::endl;
00037     } 
00038     decayRandomEngine = &rng->getEngine();   
00039     
00040     for (unsigned int ip=0; ip<extGenNames.size(); ++ip )
00041     {
00042       std::string curSet = extGenNames[ip];
00043       if ( curSet == "EvtGen" )
00044       {
00045          fEvtGenInterface = new gen::EvtGenInterface(pset.getUntrackedParameter< ParameterSet >(curSet));
00046       }
00047       else if ( curSet == "Tauola" )
00048       {
00049          // this is for old tauola27 (+pretauola)
00050          //
00051          // --> fTauolaInterface = new gen::TauolaInterface(pset.getUntrackedParameter< ParameterSet >(curSet));
00052          //
00053          // for tauola++, here it should be something like:
00054          //
00055          fTauolaInterface = TauolaInterface::getInstance();
00056          fTauolaInterface->setPSet( pset.getUntrackedParameter< ParameterSet >(curSet) );
00057          fPhotosInterface = new gen::PhotosInterface();
00058          fPhotosInterface->configureOnlyFor( 15 );
00059          fPhotosInterface->avoidTauLeptonicDecays();
00060       }
00061       else if ( curSet == "Photos" )
00062       {
00063          if ( !fPhotosInterface ) fPhotosInterface = new gen::PhotosInterface();
00064       }
00065 
00066     }
00067 
00068 }
00069 
00070 ExternalDecayDriver::~ExternalDecayDriver()
00071 {
00072    if ( fEvtGenInterface ) delete fEvtGenInterface;
00073    if ( fTauolaInterface ) delete fTauolaInterface;
00074    if ( fPhotosInterface ) delete fPhotosInterface;
00075 }
00076 
00077 HepMC::GenEvent* ExternalDecayDriver::decay( HepMC::GenEvent* evt )
00078 {
00079    
00080    if ( !fIsInitialized ) return evt;
00081    
00082    if ( fEvtGenInterface )
00083    {  
00084       evt = fEvtGenInterface->decay( evt ); 
00085       if ( !evt ) return 0;
00086    }
00087 
00088    if ( fTauolaInterface ) 
00089    {
00090       evt = fTauolaInterface->decay( evt ); 
00091       if ( !evt ) return 0;
00092    }
00093    
00094    if ( fPhotosInterface )
00095    {
00096       evt = fPhotosInterface->apply( evt );
00097       if ( !evt ) return 0;
00098    }
00099          
00100    return evt;
00101 }
00102 
00103 void ExternalDecayDriver::init( const edm::EventSetup& es )
00104 {
00105 
00106    if ( fIsInitialized ) return;
00107    
00108    if ( fTauolaInterface ) 
00109    {
00110       fTauolaInterface->init( es );
00111       for ( std::vector<int>::const_iterator i=fTauolaInterface->operatesOnParticles().begin();
00112             i!=fTauolaInterface->operatesOnParticles().end(); i++ ) 
00113                fPDGs.push_back( *i );
00114    }
00115    
00116    if ( fEvtGenInterface ) 
00117    {
00118       fEvtGenInterface->init();
00119       for ( std::vector<int>::const_iterator i=fEvtGenInterface->operatesOnParticles().begin();
00120             i!=fEvtGenInterface->operatesOnParticles().end(); i++ )
00121                fPDGs.push_back( *i );
00122    }
00123    
00124 
00125    if ( fPhotosInterface )
00126    {
00127       fPhotosInterface->init();
00128 //   for tauola++ 
00129       if ( fPhotosInterface )
00130       {
00131          for ( unsigned int iss=0; iss<fPhotosInterface->specialSettings().size(); iss++ )
00132          {
00133             fSpecialSettings.push_back( fPhotosInterface->specialSettings()[iss] );
00134          }
00135       }
00136    }
00137    
00138 // this is specific to old tauola27 only, because it calls up photos automatically
00139 //
00140 //
00141 //   if ( fTauolaInterface )
00142 //   {
00143 //      // override !
00144 //      fSpecialSettings.clear();
00145 //      fSpecialSettings.push_back( "QED-brem-off:15" );
00146 //   }
00147    
00148    fIsInitialized = true;
00149    
00150    return;
00151 }
00152 
00153 void ExternalDecayDriver::statistics() const
00154 {
00155    if ( fTauolaInterface ) fTauolaInterface->statistics();
00156    // similar for EvtGen and/or Photos, if needs be
00157    return;
00158 }