Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a911276
Introduce pre-defined keys for MC event header info
cholmcc Sep 19, 2023
dadc5c6
Export _full_ header information to MC event header
cholmcc Sep 19, 2023
2f36720
Full header read-in and external program
cholmcc Sep 19, 2023
ae319c5
New generator GeneratorTParticle
cholmcc Sep 19, 2023
0558c4b
Please consider the following formatting changes
alibuild Sep 19, 2023
a94f5f1
Merge pull request #1 from alibuild/alibot-cleanup-11913
cholmcc Sep 19, 2023
2e413a3
Fixes for copyright stuff - sigh!
cholmcc Sep 19, 2023
3d657ef
One more comment
cholmcc Sep 19, 2023
f423011
Please consider the following formatting changes
alibuild Sep 19, 2023
7313685
Merge pull request #2 from alibuild/alibot-cleanup-11913
cholmcc Sep 19, 2023
233e2e0
Whitespace
cholmcc Sep 19, 2023
d65a0c9
untabify
cholmcc Sep 19, 2023
ee59676
Merge branch 'AliceO2Group:dev' into cholmcc_generatos
cholmcc Oct 6, 2023
6f6f2c3
Added documentation
cholmcc Oct 6, 2023
9ccc1b2
Refactoring to HepMC and TParticle Generators
cholmcc Oct 6, 2023
05ad595
Changed key prefix
cholmcc Oct 6, 2023
5115a6e
Add new sub-dirs
cholmcc Oct 6, 2023
b465869
Merged changes from previous branch
cholmcc Oct 6, 2023
fa6ae4e
Undo adding AODToHepMC
cholmcc Oct 6, 2023
72b3a9d
Undo bad commit - these changes are needed but should be in different MR
cholmcc Oct 6, 2023
595d843
Formatting fixes
cholmcc Oct 6, 2023
4715d37
Renamed _script_ (not macro) to end in .macro (sigh)
cholmcc Oct 6, 2023
0434a6e
Renamed _script_ (not macro) to end in .macro (sigh)
cholmcc Oct 6, 2023
da870b3
Merge branch 'cholmcc_generatos' into cholmcc_generators_more
cholmcc Oct 6, 2023
e1db4b0
Fix formatting
cholmcc Oct 6, 2023
eb308c0
Fix formatting
cholmcc Oct 6, 2023
a7eae2e
Merge branch 'cholmcc_generatos' into cholmcc_generators_more
cholmcc Oct 6, 2023
67e5ba9
Fix formatting
cholmcc Oct 6, 2023
c57c89f
Merge branch 'cholmcc_generatos' into cholmcc_generators_more
cholmcc Oct 6, 2023
101de15
Fix formatting - that checker is ridiculously pedantic about things a…
cholmcc Oct 6, 2023
f27aaf8
Fix formatting
cholmcc Oct 6, 2023
5b62d47
Fix formatting - that checker is ridiculously pedantic about things a…
cholmcc Oct 6, 2023
3e73db3
Merge branch 'cholmcc_generatos' into cholmcc_generators_more
cholmcc Oct 6, 2023
43ea6d4
Stupid annoying formatting checker - it is really f**cking ridiculous…
cholmcc Oct 6, 2023
73c7490
Undo last faulty commit and fix formatting
cholmcc Oct 6, 2023
e0b2dde
Merge branch 'cholmcc_generatos' into cholmcc_generators_more
cholmcc Oct 6, 2023
4040aaf
Fix whitespace - these changes is so messed up
cholmcc Oct 6, 2023
9e90dd5
Update run/SimExamples/HepMC/child.sh
cholmcc Oct 6, 2023
fba7f8c
Update Generators/src/GeneratorFileOrCmd.cxx
ktf Oct 9, 2023
634f5f9
Fix test case and other similar fixes
cholmcc Oct 9, 2023
bd03ecd
Formatting fixes and bring docs into Sync
cholmcc Oct 9, 2023
f714d3a
Fixed example for new keys
cholmcc Oct 9, 2023
a8ded64
Fix whitespace - not even my edit
cholmcc Oct 9, 2023
330feea
Merge branch 'AliceO2Group:dev' into cholmcc_generators_more
cholmcc Oct 9, 2023
52a953f
Back-ward compatibility and Namespace change
cholmcc Oct 14, 2023
353068e
Fix for test
cholmcc Oct 16, 2023
209b453
Fix braces
cholmcc Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,67 @@ namespace dataformats

class GeneratorHeader;

/** Common keys for information in MC event header */
struct MCInfoKeys {
/** @{
@name HepMC3 heavy-ion fields */
static constexpr const char* impactParameter = "Bimpact";
static constexpr const char* nPart = "Npart";
static constexpr const char* nPartProjectile = "Npart_proj";
static constexpr const char* nPartTarget = "Npart_targ";
static constexpr const char* nColl = "Ncoll";
static constexpr const char* nCollHard = "Ncoll_hard";
static constexpr const char* nCollNNWounded = "NColl_NNw";
static constexpr const char* nCollNWoundedN = "NColl_NwN";
static constexpr const char* nCollNWoundedNwounded = "NColl_NwNW";
static constexpr const char* planeAngle = "eventPsi";
static constexpr const char* sigmaInelNN = "sigmaInelNN";
static constexpr const char* centrality = "centrality";
static constexpr const char* nSpecProjectileProton = "Nspec_proj_p";
static constexpr const char* nSpecProjectileNeutron = "Nspec_proj_n";
static constexpr const char* nSpecTargetProton = "Nspec_targ_p";
static constexpr const char* nSpecTargetNeutron = "Nspec_targ_n";
/** @} */
/** @{
@name HepMC3 PDF information

In principle a header can have many of these. In that case,
each set should be prefixed with "_<X>" where "<X>" is a
serial number.
*/
static constexpr const char* pdfParton1Id = "pdf_parton_1_id";
static constexpr const char* pdfParton2Id = "pdf_parton_2_id";
static constexpr const char* pdfX1 = "pdf_x1";
static constexpr const char* pdfX2 = "pdf_x2";
static constexpr const char* pdfScale = "pdf_scale";
static constexpr const char* pdfXF1 = "pdf_par_x1";
static constexpr const char* pdfXF2 = "pdf_par_x2";
static constexpr const char* pdfCode1 = "pdf_lhc_1_id";
static constexpr const char* pdfCode2 = "pdf_lhc_2_id";
/** @} */
/** @{
@name HepMC3 cross-section information

In principle we can have one cross section per weight. In that
case, each should be post-fixed by "_<X>" where "<X>" is a
serial number. These should then matcht possible names of
weights.
*/
static constexpr const char* acceptedEvents = "accepted_events";
static constexpr const char* attemptedEvents = "attempted_events";
static constexpr const char* xSection = "cross_section";
static constexpr const char* xSectionError = "cross_section_error";
/** @} */
/** @{
@name Common fields */
static constexpr const char* generator = "generator";
static constexpr const char* generatorVersion = "version";
static constexpr const char* processName = "processName";
static constexpr const char* processCode = "processCode";
static constexpr const char* weight = "weight";
/** @} */
};

/*****************************************************************/
/*****************************************************************/

Expand Down
8 changes: 8 additions & 0 deletions Generators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ o2_add_library(Generators
src/GeneratorExternalParam.cxx
src/GeneratorFromFile.cxx
src/GeneratorFromO2KineParam.cxx
src/GeneratorFileOrCmd.cxx
src/GeneratorFileOrCmdParam.cxx
src/PrimaryGenerator.cxx
src/PrimaryGeneratorParam.cxx
src/TriggerExternalParam.cxx
Expand All @@ -38,6 +40,8 @@ o2_add_library(Generators
src/GenCosmicsParam.cxx
src/GeneratorFactory.cxx
src/GeneratorGeantinos.cxx
src/GeneratorTParticle.cxx
src/GeneratorTParticleParam.cxx
$<$<BOOL:${pythia6_FOUND}>:src/GeneratorPythia6.cxx>
$<$<BOOL:${pythia6_FOUND}>:src/GeneratorPythia6Param.cxx>
$<$<BOOL:${pythia_FOUND}>:src/GeneratorPythia8.cxx>
Expand Down Expand Up @@ -71,6 +75,8 @@ set(headers
include/Generators/GeneratorExternalParam.h
include/Generators/GeneratorFromFile.h
include/Generators/GeneratorFromO2KineParam.h
include/Generators/GeneratorFileOrCmd.h
include/Generators/GeneratorFileOrCmdParam.h
include/Generators/PrimaryGenerator.h
include/Generators/PrimaryGeneratorParam.h
include/Generators/TriggerExternalParam.h
Expand All @@ -79,6 +85,8 @@ set(headers
include/Generators/QEDGenParam.h
include/Generators/GenCosmicsParam.h
include/Generators/GeneratorGeantinos.h
include/Generators/GeneratorTParticle.h
include/Generators/GeneratorTParticleParam.h
)

if (pythia6_FOUND)
Expand Down
243 changes: 243 additions & 0 deletions Generators/include/Generators/GeneratorFileOrCmd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @author Christian Holm Christensen <cholm@nbi.dk>

#ifndef ALICEO2_EVENTGEN_GENERATORFILEORCMD_H_
#define ALICEO2_EVENTGEN_GENERATORFILEORCMD_H_
#include <Generators/GeneratorFileOrCmdParam.h>
#include <list>
#include <string>

namespace o2
{
namespace conf
{
class SimConfig;
}
namespace eventgen
{

/** Service class for either reading from a file or executing a
program writing to a specific file */
struct GeneratorFileOrCmd {
/**
* Configure the generator from parameters and the general
* simulation configuration. This is implemented as a member
* function so as to better facilitate changes. */
void setup(const GeneratorFileOrCmdParam& param,
const conf::SimConfig& config);
/**
* Set command to execute in bacground rather than reading from
* existing file(s)
*
* @param cmd Command line. Can include options for the program to
* execute, but should not include pipes.
*/
void setCmd(const std::string& cmd) { mCmd = cmd; }
/**
* Set the number of events that a background command should
* generate. This should come from @c SimConfig::getNEents.
*
* @param nev Number of events to generate. This is passed via @c
* mNEventsSwitch to the command line.
*/
void setNEvents(unsigned int nev) { mNEvents = nev; }
/**
* Set the random number seed that a background command should use.
* This should come from @c SimConfig::getStartSeed
*
* @param seed Random number seed. Will be passed to the
* commandline using the @c mSeedSwitch.
*/
void setSeed(unsigned long seed) { mSeed = seed; }
/**
* Set the maximum impact parameter to sample by a background
* command. This should come from @c SimConfig::getBMax()
*
* @param bmax Maximum impact parameter, in fm, to sample. This is
* passed to the command line via the @c mBmaxSwitch.
*/
void setBmax(float bmax) { mBmax = bmax; }
/**
* Set the file names to read from.
*
* @param filenames A comma seperated list of files to read from.
*/
void setFileNames(const std::string& filenames);
/**
* Set the output switch.
*
* @param opt Command line switch (e.g., @c -o) to specify output
* file name. */
void setOutputSwitch(const std::string& opt) { mOutputSwitch = opt; }
/**
* Set the seed switch.
*
* @param opt Command line switch (e.g., @c -s) to specify the
* random number seed to use when generating events.
*/
void setSeedSwitch(const std::string& opt) { mSeedSwitch = opt; }
/**
* Set the nevents switch.
*
* @param opt Command line switch (e.g., @c -n) to specify the
* number of events to generate.
*/
void setNEventsSwitch(const std::string& opt) { mNEventsSwitch = opt; }
/**
* Set the maximum impact parameter switch.
*
* @param opt Command line switch (e.g., @c -b) to specify the
* maximum impact parameter (in fm) to sample when generating
* events.
*/
void setBmaxSwitch(const std::string& opt) { mBmaxSwitch = opt; }
/**
* Set the background switch.
*
* @param opt Command line switch (e.g., @c &) to detach and send
* the event generator program into the background.
*/
void setBackgroundSwitch(const std::string& opt) { mBackgroundSwitch = opt; }
/** Set the wait time, in miliseconds, when waiting for data */
void setWait(int miliseconds = 500) { mWait = miliseconds; }

protected:
/**
* Format a command line using the set command line, option flags,
* and option values.
*
* @return formatted command line.
*/
virtual std::string makeCmdLine() const;
/**
* Execute a command line (presumably formatted by @c makeCmdLine).
* If the command failed to execute, then make it a fatal error.
*
* @param cmd Command line to execute, presumabley formatted by @c
* makeCmdLine.

* @return true if the background command line was executed, false
* otherwise.
*/
virtual bool executeCmdLine(const std::string& cmd) const;
/**
* Create a temporary file (and close it immediately). On success,
* the list of file names is cleared and the name of the temporary
* file set as the sole element in that list.
*
* @return true if the temporary file name was generated
* successfully.
*/
virtual bool makeTemp();
/**
* Remove the temporary file if it was set and it exists.
*
* @return true if the temporary file was removed.
*/
virtual bool removeTemp() const;
/**
* Make a fifo at the location of the first element of the list of
* file names (presumably a temporary file as created by
* makeTemp).
*
* @return true if the FIFo was made correctly
*/
virtual bool makeFifo() const;
/**
* Ensure that all files in the list of file names exists. If @e
* any of te file names point to a net resource (e.g., @c alien://or
* @c https://) then this member function should @e not be called
*
* The file names registered are replaced with their canonical path
* equivalents.
*
* @return true if all currently registered file names can be found.
*/
virtual bool ensureFiles();
/**
* Wait for data to be available in case we're executing a
* background command
*/
virtual void waitForData(const std::string& filename) const;
/**
* Possible command line to execute. The command executed must
* accept the switches defined below. Note if @c mOutputSwitch is
* set to @c ">", then the program @e must write data to standard
* output
*/
std::string mCmd = "";
/**
* List of file names to read. In case we're executing a command,
* then there will only be one file name in the list
*/
std::list<std::string> mFileNames;
/**
* Name of temporary file, if it was created.
*/
std::string mTemporary;
/**
* Number of events to generate in case we're executing a command.
* This is passed to the program via the switch @c
* mNEventsSwitch
*/
unsigned int mNEvents = 0;
/**
* Random number seed to use in case we're executing a command.
* This is passed to the program via the switch @c
* mSeedSwitch
*/
unsigned long mSeed = 0;
/**
* Maximum impact parameter to sample in case we're executing a
* command. IF negative, then it is not passed to the command.
* This is passed to the command via the switch @c mBmaxSwitch
*/
float mBmax = -1.f;
/**
* Switch to direct output to specified file. In case of a fifo,
* this should often be @c ">" - i.e., the standard output of the
* program is redirected to the fifo.
*/
std::string mOutputSwitch = ">";
/**
* The switch specify the random number seed to the program
* executed
*/
std::string mSeedSwitch = "-s";
/**
* The switch to specify the number of events to generate to the
* program being executed
*/
std::string mNEventsSwitch = "-n";
/**
* The switch to specify maximum impact parameter to sample by the
* program being executed.
*/
std::string mBmaxSwitch = "-b";
/**
* The "switch" to put the program being executed in the
* background.
*/
std::string mBackgroundSwitch = "&";
/**
* Time in miliseconds between each wait for data
*/
int mWait = 500;
};

} // namespace eventgen
} // namespace o2
#endif
// Local Variables:
// mode: C++
// End:
45 changes: 45 additions & 0 deletions Generators/include/Generators/GeneratorFileOrCmdParam.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2023-2099 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @author Christian Holm Christensen <cholm@nbi.dk>

#ifndef ALICEO2_EVENTGEN_GENERATORFILEORCMDPARAM_H_
#define ALICEO2_EVENTGEN_GENERATORFILEORCMDPARAM_H_

#include "CommonUtils/ConfigurableParam.h"
#include "CommonUtils/ConfigurableParamHelper.h"
#include <string>

namespace o2
{
namespace eventgen
{

/**
** a parameter class/struct to keep the settings of
** the Fileorcmd event generator and
** allow the user to modify them
**/
struct GeneratorFileOrCmdParam : public o2::conf::ConfigurableParamHelper<GeneratorFileOrCmdParam> {
std::string fileNames = "";
std::string cmd = ""; // Program command line to spawn
std::string outputSwitch = ">";
std::string seedSwitch = "-s";
std::string bMaxSwitch = "-b";
std::string nEventsSwitch = "-n";
std::string backgroundSwitch = "&";
O2ParamDef(GeneratorFileOrCmdParam, "GeneratorFileOrCmd");
};

} // end namespace eventgen
} // end namespace o2

#endif // ALICEO2_EVENTGEN_GENERATORFILEORCMDPARAM_H_
Loading