# Gauss Generation Tools, Base Classes and Interfaces
# Opened MRs
## In Gaussino:
- [!151: Restructuring production interfaces](https://gitlab.cern.ch/Gaussino/Gaussino/-/merge_requests/151)
- [!138: Updating Pythia8Production with new generator interfaces](https://gitlab.cern.ch/Gaussino/Gaussino/-/merge_requests/138)
- [!136: New Sampling tool interface, sampling generator components, and PileupTool for rare processes](https://gitlab.cern.ch/Gaussino/Gaussino/-/merge_requests/136)
- [!133: Implementing Madgraph in Gaussino](https://gitlab.cern.ch/Gaussino/Gaussino/-/merge_requests/133)
- [!147: Updating generation Configurables](https://gitlab.cern.ch/Gaussino/Gaussino/-/merge_requests/147)
## In Gauss
- [!994: Dependencies and Configurable options for Madgraph in Futurev5](https://gitlab.cern.ch/lhcb/Gauss/-/merge_requests/994
)
## How to test:
- Need to integrate all of the MRs above (both in Gaussino and Gauss) and run Gauss (for example from a stack setup) with an option file to test, e.g., the generation of events of type 42912009
```
Gauss/run gaudirun.py test-options.py
```
```python=
# test-options.py
from Configurables import Gauss, GaussGeneration
from Gaudi.Configuration import importOptions
from Gauss.Configuration import *
genAlgName="Generation"
Gauss().FirstEventNumber = 1
Gauss().RunNumber = 1082
Gauss().EvtMax = 5
from Configurables import Generation
Gauss().Phases = ["Generator", "GenToMCTree"]
Gauss().OutputType = "RGEN"
Generation(genAlgName).EventType = 42912009
GaussGeneration().SampleGenerationTool = "Special"
GaussGeneration().SeedingToolName = "SeedingTool"
GaussGeneration().ProductionTool = "ProductionWithHardME"
GaussGeneration().ProductionToolOpts = {"HardProdTool": "MadgraphProduction", "ShowerTool": "Pythia8Production"}
GaussGeneration().PileUpTool = "FixedLuminosityForRareProcessWithSvc"
GaussGeneration().Commands = ["generate p p > mu+ mu- b b~ [QCD]", " set mll_sf 40"]
importOptions("$GAUSSOPTS/General/2018.py")
importOptions("$GAUSSOPTS/General/Debug.py")
```
# Gauss Generation Tools, Base Classes and Interfaces
- [Old UML Diagram of Gauss Generation](https://cernbox.cern.ch/s/B5VGRwNQa8X4Ahb)
- [New UML Diagram](https://cernbox.cern.ch/s/P4bm1jC6ob506Ck)
- [Schematic of suggested generation interfaces by Phil](https://cernbox.cern.ch/s/kVSW0C0c8Onn8D1)
---
## New Production Interfaces in Gaussino:
- ### `IHardProdTool`
- generateHardScattering or matrix element (JobID, EvtNr) -> HepMC
- ### `IShoweringTool` (Parton shower + Underlying event) and (Hadronization + non-perturbative)
- updateEvent(JobID, EvtNr, inputEvent) -> HepMC
- ### New `IProdTool` interface (replacing `IProductionTool`)
- generateEvent(JobID, EvtNr) -> HepMC
- #### Namespace for interfaces -> Gsino
- #### New class for linking hard process tools with showering -> `ProductionWithHardME`
- #### New sampling tool interface `ISamplingTool` to adapt it to the new interfaces, and used for implementing the new Special sample generator tool
---
# Previous Situation
## Abstract Interfaces for Generation Steps
1. Determine number of pileup interactions -> **IPileupTool**
2. Produce pp collisions -> **ISampleGeneratioTool**
a. Determine beam momenta -> **IBeamTool**
b. Generate pp collision -> **IProductionTool**
c. Decay all particles produced -> **IDecayTool**
d. Smearing -> **IVertexSmearingTool**
## [ISampleGenerationTool](https://gitlab.cern.ch/Gaussino/Gaussino/-/blob/master/Gen/GenInterfaces/include/GenInterfaces/ISampleGenerationTool.h)
- Abstract interface to generation of event samples. Concrete tools implement the algorithms used to generate the various event types generated in LHCb (Minimum bias, inclusive, signal with repeated hadronization, ...)
- Inherits from IAlgTool
- **Parameters**
- *int* nPileUp: Number of pile-up event to generate for this event.
- *HepMC3::GenEventPtrs* theEvents: Container of the generated pile-up interactions.
- *LHCb::GenCollisions* theCollisions: Container of the hard process information for each pile-up interaction.
- IProductionTool * m_productionTool
- IDecayTool * m_decayTool
- IGenCutTool * m_cutTool
- ICounterLogFile * m_xmlLogTool
- std::string m_productionToolName
- std::string m_decayToolName
- std::string m_cutToolName
- **Methods**
- *bool* generate (nPileup, theEvents, theCollisions, engine)
- *void* printCounters()
## [ExternalGenerator](https://gitlab.cern.ch/Gaussino/Gaussino/-/blob/master/Gen/Generators/include/Generators/ExternalGenerator.h)
- Base class for sample generation tools which use external generators (Pythia, Herwig, ...) This class provides common utility functions which can be used to generate samples of events of various types.
- inherits from GaudiTool and ISampleGenerationTool
- **Parameters**
- typedef std::vector< HepMC::GenParticle * > ParticleVector
- std::set< int > PIDs
- std::vector< std::string > CommandVector
- theEvent (HepMC event which contains the particles to decay. The event is updated with the resulting decay trees.)
- **Methods**
- *StatusCode* decayHeavyParticles(theEvent, theQuark, engine)
- *bool* checkPresence(pidList, theEvent, particleList)
- *void* revertEvent (theEvent)
- *void* prepareInteraction(theEvents, theCollisions, theGenEvents, theGenCollisions)
## [IProductionTool](https://gitlab.cern.ch/Gaussino/Gaussino/-/blob/master/Gen/GenInterfaces/include/GenInterfaces/IProductionTool.h)
- Abstract interface to production generators (inherited by all generator production classes)
- Inherits from IAlgTool
- **Parameters**
- theEvent Event generated by the production generator (HepMC::GenEvent)
- theInfo Informations about the hard process of the generated interaction (LHCb::GenCollision)
-
- **Methods**
- *StatusCode* generateEvent(theEvent, theInfo)
- *void* setStable(LHCb::ParticleProperty)
- *void* UpdateParticleProperties(LHCb::ParticleProperty)
- *void* turnOnFragmentation()
- *void* turnOffFragmentation()
- *StatusCode* hadronize(theEvent, theInfo)
- *void* savePartonEvent(theEvent)
- *void* retrievePartonEvent(theEvent)
- *void* printRunningCondition()
- *bool* isSpecialParticle(LHCb::ParticleProperty)
- *StatusCode* setupForcedFragmentation(thePdgId)
- *StatusCode* initializeGenerator()
---
## [LbPythia8](https://gitlab.cern.ch/Gaussino/Gaussino/-/tree/master/Gen/LbPythia8)
### - PythiaProduction class
- Production tool of events using pythia8
- Inherits from GaudiTool, IProductionTool
- **Members**
- Pythia8::Pythia* m_pythia
- std::vector <Pythia8::UserHooks*> m_hooks (User hooks to veto events)
- Pythia8::LHAup* m_lhaup (User specified hard process)
- Pythia8::Event m_event (the Pythia 8 event record)
- IBeamTool* m_beamTool
- BeamToolForPythia8* m_pythiaBeamTool
- GaudiRandomForPythia8* m_randomEngine
- int m_nEvents
- **Properties**
- m_beamToolName
- m_userSettings
- m_hookSettings
- m_tuningFile
- m_validateHEPECT
- m_listAllParticles
- m_checkParticleProperties
- m_showwBanner
- m_xmlLogTool
- **Inherits all methods in IProductionTool**
- **Methods not from IProductionTool**
- *StatusCode* Initialize()
- *StatusCode* InitializeGenerator()
- *StatusCode* finalize()
- *StatusCode* toHepMC(theEvent, theCollision)
### - PythiaBeamTool & GaudiRandomForPythia8 Classes
- Random Generator to interface Gaudi Random Generator to Pythia
---
## [LbHard](https://gitlab.cern.ch/lhcb/Gauss/-/tree/master/Gen/LbHard) (as in Gauss sim 10)
### - HardProduction class
- Production tool base class for hard process generators
- Inherits from GaudiTool and IProductionTool
- In the Hard methods it decides whether to use hard process generator + General purpose generator or only general purpose generator
- **Members**
- PythiaProduction8 *m_pythia8
- int m_nEvents
- IProductionTool *m_shower
- IProductionTool *m_hard
- IBeamTool *m_beamTool
- **Inherits all methods from IProductionTool**
- **Methods**
- *StatusCode* Initialize()
- *StatusCode* InitializeGenerator()
- *StatusCode* finalize()
- **Hard process methods**
- *StatusCode* hardInitialize()
- *StatusCode* hardFinalize()
- *void* hardSetStable(ParticleProperty)
- *void* hardUpdateParticleProperties(ParticleProperty)
- *void* hardPrintRunningConditions()
- *bool* hardIsSpecialParticle(ParticleProperty)
---
## [LbMadgraph](https://gitlab.cern.ch/lhcb/Gauss/-/tree/master/Gen/LbMadgraph) (as in Gauss sim10)
### - LHAMadgraph class
- Derived class from Pythia::LHAupMadgraph that generates events with Madgraph
- Reads from LHE file output
### - MadgraphProduction class
- Production tool to generate events with Madgraph
- Utilizes LHAupMadgraph class from Pythia8
- Inherits from LbHard/HardProduction class
- Uses instances of LHAMadgraph for hard process generation and Pythia8 for showering
- **Members**
- IRndmGenSvc *m_randSvc (Random number service)
- Pythia8::LHAupMadgraph *m_madgraph (The Madgraph LHAup object)
- int m_seed
- int m_events (Number of events per Madgraph run)
- int m_jets (Number of fixed order jets)
- std::vector<std::string> m_pdf (Default PDF commands)
- int m_eventType (Event type)
- bool m_genGridpack (Gridpack generation flag)
- **Properties**
- IProductionTool
- m_events
- m_jets
- m_pdf
- m_eventType
- m_genGridpack
- **Methods from HardProduction**
- *StatusCode* HardInitialize()
- *StatusCode* finalize()
- **Methods from IProductionTool**
- *StatusCode* generateEvent(theEvent, theCollision)