CMS 3D CMS Logo

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