File indexing completed on 2023-03-17 11:04:10
0001 #ifndef gen_FortranCallback_h
0002 #define gen_FortranCallback_h
0003
0004 #include "SimDataFormats/GeneratorProducts/interface/LHECommonBlocks.h"
0005
0006 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
0007 #include "GeneratorInterface/LHEInterface/interface/LHEEvent.h"
0008
0009 namespace HepMC {
0010 class GenEvent;
0011 }
0012
0013 namespace gen {
0014
0015 class FortranCallback {
0016 public:
0017 static FortranCallback* getInstance();
0018
0019
0020 void setLHERunInfo(lhef::LHERunInfo* lheri) { fRunBlock = lheri; }
0021 void setLHEEvent(lhef::LHEEvent* lhee) { fEventBlock = lhee; }
0022
0023 void resetIterationsPerEvent() { fIterationsPerEvent = 0; }
0024
0025 void fillHeader();
0026 void fillEvent();
0027
0028 int getIterationsPerEvent() const { return fIterationsPerEvent; }
0029
0030 private:
0031
0032
0033 FortranCallback();
0034
0035
0036
0037 lhef::LHERunInfo* fRunBlock;
0038 lhef::LHEEvent* fEventBlock;
0039 int fIterationsPerEvent;
0040
0041 static FortranCallback* fInstance;
0042 };
0043
0044
0045
0046 inline FortranCallback::FortranCallback()
0047
0048 : fRunBlock(nullptr), fEventBlock(nullptr), fIterationsPerEvent(0) {}
0049
0050 inline void FortranCallback::fillHeader() {
0051 if (fRunBlock == nullptr)
0052 return;
0053
0054
0055 const lhef::HEPRUP* heprup = fRunBlock->getHEPRUP();
0056
0057 lhef::CommonBlocks::fillHEPRUP(heprup);
0058
0059 return;
0060 }
0061
0062 inline void FortranCallback::fillEvent() {
0063
0064
0065
0066 if (fEventBlock == nullptr)
0067 return;
0068
0069 const lhef::HEPEUP* hepeup = fEventBlock->getHEPEUP();
0070
0071 if (fIterationsPerEvent++) {
0072 hepeup_.nup = 0;
0073 return;
0074 }
0075
0076 lhef::CommonBlocks::fillHEPEUP(hepeup);
0077
0078 return;
0079 }
0080
0081 }
0082
0083 #endif