CMS 3D CMS Logo

ExternalDecayDriver.cc
Go to the documentation of this file.
2 
10 #include "HepMC/GenEvent.h"
12 // LHE Run
15 
16 // LHE Event
19 
20 using namespace gen;
21 using namespace edm;
22 
23 CLHEP::HepRandomEngine* decayRandomEngine = nullptr;
24 
25 
27  : fIsInitialized(false)
28 {
29  std::vector<std::string> extGenNames =
30  pset.getParameter< std::vector<std::string> >("parameterSets");
31 
32  for (unsigned int ip=0; ip<extGenNames.size(); ++ip ) {
33  std::string curSet = extGenNames[ip];
34  if ( curSet == "EvtGen") {
35  fEvtGenInterface = std::unique_ptr<EvtGenInterfaceBase>(EvtGenFactory::get()->create("EvtGen", pset.getUntrackedParameter< ParameterSet >(curSet)));
39  }
40  else if( curSet == "EvtGen1" || curSet == "EvtGen130" ) {
41  fEvtGenInterface = std::unique_ptr<EvtGenInterfaceBase>(EvtGenFactory::get()->create("EvtGen130", pset.getUntrackedParameter< ParameterSet >(curSet)));
47  }
48  else if ( curSet == "Tauola" || curSet == "Tauolapp" || curSet == "Tauolapp114" ) {
49  fTauolaInterface = std::unique_ptr<TauolaInterfaceBase>(TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter< ParameterSet >(curSet)));
50  fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter< ParameterSet >(curSet)));
51  fPhotosInterface->configureOnlyFor( 15 );
52  fPhotosInterface->avoidTauLeptonicDecays();
55  }
56  else if ( curSet == "Photos" || curSet == "Photos2155" ) {
57  if ( !fPhotosInterface ) {
58  fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter< ParameterSet>(curSet)));
60  }
61  }
62  else if (curSet == "Photospp" || curSet == "Photospp356" ) {
63  if ( !fPhotosInterface ) {
64  fPhotosInterface = std::unique_ptr<PhotosInterfaceBase>(PhotosFactory::get()->create("Photospp356", pset.getUntrackedParameter< ParameterSet>(curSet)));
66  }
67  }
68  }
69 }
70 
72 
74  if(fTauolaInterface) fTauolaInterface->SetLHE(lheEvent);
75  return decay(evt);
76 }
77 
78 
80 {
81  if ( !fIsInitialized ) return evt;
82 
83  if ( fEvtGenInterface ) {
84  evt = fEvtGenInterface->decay( evt );
85  if ( !evt ) return nullptr;
86  }
87 
88  if ( fTauolaInterface ) {
89  evt = fTauolaInterface->decay( evt );
90  if ( !evt ) return nullptr;
91  }
92 
93  if ( fPhotosInterface ) {
94  evt = fPhotosInterface->apply( evt );
95  if ( !evt ) return nullptr;
96  }
97 
98  return evt;
99 }
100 
101 
103 {
104  if ( fIsInitialized ) return;
105 
106  if ( fTauolaInterface ) {
107  fTauolaInterface->init( es );
108  for ( std::vector<int>::const_iterator i=fTauolaInterface->operatesOnParticles().begin();
109  i!=fTauolaInterface->operatesOnParticles().end(); i++ )
110  fPDGs.push_back( *i );
111  }
112 
113  if ( fEvtGenInterface ) {
114  fEvtGenInterface->init();
115  for ( std::vector<int>::const_iterator i=fEvtGenInterface->operatesOnParticles().begin();
116  i!=fEvtGenInterface->operatesOnParticles().end(); i++ )
117  fPDGs.push_back( *i );
118  for ( unsigned int iss=0; iss<fEvtGenInterface->specialSettings().size(); iss++ ) {
119  fSpecialSettings.push_back( fEvtGenInterface->specialSettings()[iss] );
120  }
121 
122  }
123 
124  if ( fPhotosInterface ) {
125  fPhotosInterface->init();
126  // for tauola++
127  if ( fPhotosInterface ) {
128  for ( unsigned int iss=0; iss<fPhotosInterface->specialSettings().size(); iss++ ){
129  fSpecialSettings.push_back( fPhotosInterface->specialSettings()[iss] );
130  }
131  }
132  }
133 
134  fIsInitialized = true;
135 
136  return;
137 }
138 
139 
141 {
142  if ( fTauolaInterface ) fTauolaInterface->statistics();
143  if ( fPhotosInterface ) fPhotosInterface->statistics();
144  // similar for EvtGen if needed
145  return;
146 }
147 
148 
149 void ExternalDecayDriver::setRandomEngine(CLHEP::HepRandomEngine* v)
150 {
152  if ( fTauolaInterface ) fTauolaInterface->setRandomEngine(v);
153  if ( fEvtGenInterface ) fEvtGenInterface->setRandomEngine(v);
154  if ( fPhotosInterface ) fPhotosInterface->setRandomEngine(v);
155 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CLHEP::HepRandomEngine * decayRandomEngine
std::unique_ptr< PhotosInterfaceBase > fPhotosInterface
static const std::string kTauola
static const std::string kPhotos
double v[5][pyjets_maxn]
void init(const edm::EventSetup &)
static const std::string kPythia6
static const std::string kEvtGen
std::vector< std::string > exSharedResources
std::unique_ptr< EvtGenInterfaceBase > fEvtGenInterface
std::vector< std::string > fSpecialSettings
std::unique_ptr< TauolaInterfaceBase > fTauolaInterface
static const std::string kFortranInstance
HepMC::GenEvent * decay(HepMC::GenEvent *evt)
ExternalDecayDriver(const edm::ParameterSet &)
HLT enums.
static const std::string kPythia8
void setRandomEngine(CLHEP::HepRandomEngine *)
T get(const Candidate &c)
Definition: component.h:55