CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/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          fTauolaInterface = new gen::TauolaInterface(pset.getUntrackedParameter< ParameterSet >(curSet));
00050          //
00051          // in the future, here it should be something like:
00052          //
00053          // fTauolaInterface = TauolaInterface::getInstance();
00054          // fTauolaInterface->setPSet( pset.getUntrackedParameter< ParameterSet >(curSet) );
00055          // fPhotosInterface = new gen::PhotosInterface();
00056          // fPhotosInterface->avoidTauLeptonicDecays();
00057       }
00058       else if ( curSet == "Photos" )
00059       {
00060          if ( !fPhotosInterface ) fPhotosInterface = new gen::PhotosInterface();
00061       }
00062 
00063     }
00064 
00065 }
00066 
00067 ExternalDecayDriver::~ExternalDecayDriver()
00068 {
00069    if ( fEvtGenInterface ) delete fEvtGenInterface;
00070    if ( fTauolaInterface ) delete fTauolaInterface;
00071    if ( fPhotosInterface ) delete fPhotosInterface;
00072 }
00073 
00074 HepMC::GenEvent* ExternalDecayDriver::decay( HepMC::GenEvent* evt )
00075 {
00076    
00077    if ( !fIsInitialized ) return evt;
00078    
00079    if ( fEvtGenInterface )
00080    {  
00081       evt = fEvtGenInterface->decay( evt ); 
00082       if ( !evt ) return 0;
00083    }
00084 
00085    if ( fTauolaInterface ) 
00086    {
00087       evt = fTauolaInterface->decay( evt ); 
00088       if ( !evt ) return 0;
00089    }
00090    
00091 
00092    if ( fPhotosInterface )
00093    {
00094       evt = fPhotosInterface->apply( evt );
00095       if ( !evt ) return 0;
00096    }
00097 
00098          
00099    return evt;
00100 }
00101 
00102 void ExternalDecayDriver::init( const edm::EventSetup& es )
00103 {
00104 
00105    if ( fIsInitialized ) return;
00106    
00107    if ( fTauolaInterface ) 
00108    {
00109       fTauolaInterface->init( es );
00110       for ( std::vector<int>::const_iterator i=fTauolaInterface->operatesOnParticles().begin();
00111             i!=fTauolaInterface->operatesOnParticles().end(); i++ ) 
00112                fPDGs.push_back( *i );
00113    }
00114    
00115    if ( fEvtGenInterface ) 
00116    {
00117       fEvtGenInterface->init();
00118       for ( std::vector<int>::const_iterator i=fEvtGenInterface->operatesOnParticles().begin();
00119             i!=fEvtGenInterface->operatesOnParticles().end(); i++ )
00120                fPDGs.push_back( *i );
00121    }
00122    
00123 
00124    if ( fPhotosInterface )
00125    {
00126       fPhotosInterface->init();
00127 /*   will fix shortly, for future tauola++
00128       if ( fPhotosInterface )
00129       {
00130          for ( unsigned int iss=0; iss<fPhotosInterface->specialSettings().size(); iss++ )
00131          {
00132             fSpecialSettings.push_back( fPhotosInterface->specialSettings()[iss]; )
00133          }
00134       }
00135 */
00136    }
00137    
00138    // now do special settings
00139 
00140    // This is TEMPORARY THING, until we switch to tauola++ !!!
00141    
00142    if ( fPhotosInterface )
00143    {
00144       fSpecialSettings.push_back( "QED-brem-off:all" );
00145    }
00146    if ( fTauolaInterface )
00147    {
00148       // override !
00149       fSpecialSettings.clear();
00150       fSpecialSettings.push_back( "QED-brem-off:15" );
00151    }
00152    
00153    fIsInitialized = true;
00154    
00155    return;
00156 }
00157 
00158 void ExternalDecayDriver::statistics() const
00159 {
00160    if ( fTauolaInterface ) fTauolaInterface->statistics();
00161    // similar for EvtGen and/or Photos, if needs be
00162    return;
00163 }