Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:44

0001 #include "GeneratorInterface/ExternalDecays/interface/ConcurrentExternalDecayDriver.h"
0002 
0003 #include "GeneratorInterface/Core/interface/FortranInstance.h"
0004 #include "GeneratorInterface/EvtGenInterface/interface/EvtGenFactory.h"
0005 #include "GeneratorInterface/EvtGenInterface/interface/EvtGenInterfaceBase.h"
0006 #include "GeneratorInterface/TauolaInterface/interface/TauolaFactory.h"
0007 #include "GeneratorInterface/TauolaInterface/interface/TauolaInterfaceBase.h"
0008 #include "GeneratorInterface/PhotosInterface/interface/PhotosFactory.h"
0009 #include "GeneratorInterface/PhotosInterface/interface/PhotosInterfaceBase.h"
0010 #include "HepMC/GenEvent.h"
0011 #include "FWCore/Concurrency/interface/SharedResourceNames.h"
0012 // LHE Run
0013 #include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h"
0014 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
0015 
0016 // LHE Event
0017 #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
0018 #include "GeneratorInterface/LHEInterface/interface/LHEEvent.h"
0019 
0020 using namespace gen;
0021 using namespace edm;
0022 
0023 ConcurrentExternalDecayDriver::ConcurrentExternalDecayDriver(const ParameterSet& pset) : fIsInitialized(false) {
0024   std::vector<std::string> extGenNames = pset.getParameter<std::vector<std::string> >("parameterSets");
0025 
0026   for (unsigned int ip = 0; ip < extGenNames.size(); ++ip) {
0027     std::string curSet = extGenNames[ip];
0028     throw cms::Exception("ThreadUnsafeDecayer") << "The decayer " << curSet << " is not thread-friendly.";
0029     /*
0030     if (curSet == "EvtGen") {
0031       fEvtGenInterface = std::unique_ptr<EvtGenInterfaceBase>(
0032           EvtGenFactory::get()->create("EvtGen", pset.getUntrackedParameter<ParameterSet>(curSet)));
0033       exSharedResources.emplace_back(edm::SharedResourceNames::kEvtGen);
0034       exSharedResources.emplace_back(edm::SharedResourceNames::kPythia6);
0035       exSharedResources.emplace_back(gen::FortranInstance::kFortranInstance);
0036     } else if (curSet == "EvtGen1" || curSet == "EvtGen130") {
0037       fEvtGenInterface = std::unique_ptr<EvtGenInterfaceBase>(
0038           EvtGenFactory::get()->create("EvtGen130", pset.getUntrackedParameter<ParameterSet>(curSet)));
0039       exSharedResources.emplace_back(edm::SharedResourceNames::kEvtGen);
0040       exSharedResources.emplace_back(edm::SharedResourceNames::kPythia8);
0041       exSharedResources.emplace_back(edm::SharedResourceNames::kTauola);
0042       exSharedResources.emplace_back(edm::SharedResourceNames::kPhotos);
0043       exSharedResources.emplace_back(gen::FortranInstance::kFortranInstance);
0044     } else if (curSet == "Tauola" || curSet == "Tauolapp" || curSet == "Tauolapp114") {
0045       fTauolaInterface = std::unique_ptr<TauolaInterfaceBase>(
0046           TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter<ParameterSet>(curSet)));
0047       fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(
0048           PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter<ParameterSet>(curSet)));
0049       fPhotosInterface->configureOnlyFor(15);
0050       fPhotosInterface->avoidTauLeptonicDecays();
0051       exSharedResources.emplace_back(edm::SharedResourceNames::kTauola);
0052       exSharedResources.emplace_back(edm::SharedResourceNames::kPhotos);
0053     } else if (curSet == "Photos" || curSet == "Photos2155") {
0054       if (!fPhotosInterface) {
0055         fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(
0056             PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter<ParameterSet>(curSet)));
0057         exSharedResources.emplace_back(edm::SharedResourceNames::kPhotos);
0058       }
0059     } else if (curSet == "Photospp" || curSet == "Photospp356") {
0060       if (!fPhotosInterface) {
0061         fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(
0062             PhotosFactory::get()->create("Photospp356", pset.getUntrackedParameter<ParameterSet>(curSet)));
0063         exSharedResources.emplace_back(edm::SharedResourceNames::kPhotos);
0064       }
0065     }
0066     */
0067   }
0068 }
0069 
0070 ConcurrentExternalDecayDriver::~ConcurrentExternalDecayDriver() = default;
0071 
0072 HepMC::GenEvent* ConcurrentExternalDecayDriver::decay(HepMC::GenEvent* evt, lhef::LHEEvent* lheEvent) {
0073   /*  if (fTauolaInterface)
0074       fTauolaInterface->SetLHE(lheEvent); */
0075   return decay(evt);
0076 }
0077 
0078 HepMC::GenEvent* ConcurrentExternalDecayDriver::decay(HepMC::GenEvent* evt) {
0079   if (!fIsInitialized)
0080     return evt;
0081   /*
0082   if (fEvtGenInterface) {
0083     evt = fEvtGenInterface->decay(evt);
0084     if (!evt)
0085       return nullptr;
0086   }
0087 
0088   if (fTauolaInterface) {
0089     evt = fTauolaInterface->decay(evt);
0090     if (!evt)
0091       return nullptr;
0092   }
0093 
0094   if (fPhotosInterface) {
0095     evt = fPhotosInterface->apply(evt);
0096     if (!evt)
0097       return nullptr;
0098   }
0099   */
0100   return evt;
0101 }
0102 
0103 void ConcurrentExternalDecayDriver::init(const edm::EventSetup& es) {
0104   if (fIsInitialized)
0105     return;
0106   /*
0107   if (fTauolaInterface) {
0108     fTauolaInterface->init(es);
0109     for (std::vector<int>::const_iterator i = fTauolaInterface->operatesOnParticles().begin();
0110          i != fTauolaInterface->operatesOnParticles().end();
0111          i++)
0112       fPDGs.push_back(*i);
0113   }
0114 
0115   if (fEvtGenInterface) {
0116     fEvtGenInterface->init();
0117     for (std::vector<int>::const_iterator i = fEvtGenInterface->operatesOnParticles().begin();
0118          i != fEvtGenInterface->operatesOnParticles().end();
0119          i++)
0120       fPDGs.push_back(*i);
0121     for (unsigned int iss = 0; iss < fEvtGenInterface->specialSettings().size(); iss++) {
0122       fSpecialSettings.push_back(fEvtGenInterface->specialSettings()[iss]);
0123     }
0124   }
0125 
0126   if (fPhotosInterface) {
0127     fPhotosInterface->init();
0128     //   for tauola++
0129     if (fPhotosInterface) {
0130       for (unsigned int iss = 0; iss < fPhotosInterface->specialSettings().size(); iss++) {
0131         fSpecialSettings.push_back(fPhotosInterface->specialSettings()[iss]);
0132       }
0133     }
0134   }
0135   */
0136 
0137   fIsInitialized = true;
0138 
0139   return;
0140 }
0141 
0142 void ConcurrentExternalDecayDriver::statistics() const {
0143   /*  if (fTauolaInterface)
0144     fTauolaInterface->statistics();
0145   if (fPhotosInterface)
0146     fPhotosInterface->statistics();
0147   */
0148   // similar for EvtGen if needed
0149   return;
0150 }
0151 
0152 void ConcurrentExternalDecayDriver::setRandomEngine(CLHEP::HepRandomEngine* v) {
0153   /*
0154   if (fTauolaInterface)
0155     fTauolaInterface->setRandomEngine(v);
0156   if (fEvtGenInterface)
0157     fEvtGenInterface->setRandomEngine(v);
0158   if (fPhotosInterface)
0159     fPhotosInterface->setRandomEngine(v);
0160   */
0161 }