Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
121 changes: 60 additions & 61 deletions DataFormats/simulation/include/SimulationDataFormat/MCEventHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,67 +27,66 @@ 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";
/** @} */

};
/** 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
3 changes: 2 additions & 1 deletion Generators/include/Generators/GeneratorHepMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class GeneratorHepMC : public Generator
void setProgCmd(std::string val) { mProgCmd = val; };
void setEventsToSkip(uint64_t val) { mEventsToSkip = val; };
void setNEvents(unsigned int val) { mNEvents = val; }

protected:
/** copy constructor **/
GeneratorHepMC(const GeneratorHepMC&);
Expand All @@ -80,7 +81,7 @@ class GeneratorHepMC : public Generator

/** methods that can be overridded **/
void updateHeader(o2::dataformats::MCEventHeader* eventHeader) override;

/** HepMC interface **/
std::ifstream mStream; //!
std::string mFileName;
Expand Down
2 changes: 1 addition & 1 deletion Generators/include/Generators/GeneratorHepMCParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace eventgen

struct GeneratorHepMCParam : public o2::conf::ConfigurableParamHelper<GeneratorHepMCParam> {
std::string fileName = "";
std::string progCmd = "";//Program command line to spawn, must write HepMC on stdout
std::string progCmd = ""; // Program command line to spawn, must write HepMC on stdout
int version = 2;
uint64_t eventsToSkip = 0;
O2ParamDef(GeneratorHepMCParam, "HepMC");
Expand Down
152 changes: 75 additions & 77 deletions Generators/include/Generators/GeneratorTParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,91 +27,89 @@ class TClonesArray;

namespace o2
{
namespace eventgen
namespace eventgen
{
/// A class that reads in particles of class @c TParticle from a
/// branch in a @c TChain.
///
/// Optionally, a program that generates such a @c TTree can be
/// spawn, and the @c TParticles written to a file from which this
/// object reads them in. This is done with
///
/// --configKeyValues "TParticle.progCmd=<eg program and options>"
///
/// which will execute the specified EG program with the given
/// options. The EG program _must_ support the command line options
///
/// -n NUMBER Number of events to generate
/// -o FILENAME Name of file to write to
///
/// The tree name and particle branch names can be configured.
///
/// --configKeyValues "TParticle.treeName=T,TParticle.branchName=P"
///
/// File(s) to read are also configurable
///
/// --configKeyValues "TParticle.fileNames=foo.root,bar.root"
///
class GeneratorTParticle : public Generator
{
public:
/** CTOR */
GeneratorTParticle() = default;
/** CTOR */
GeneratorTParticle(const std::string& name)
: Generator(name.c_str(), "ALICEo2 TParticle Generator")
{
/// A class that reads in particles of class @c TParticle from a
/// branch in a @c TChain.
///
/// Optionally, a program that generates such a @c TTree can be
/// spawn, and the @c TParticles written to a file from which this
/// object reads them in. This is done with
///
/// --configKeyValues "TParticle.progCmd=<eg program and options>"
///
/// which will execute the specified EG program with the given
/// options. The EG program _must_ support the command line options
///
/// -n NUMBER Number of events to generate
/// -o FILENAME Name of file to write to
///
/// The tree name and particle branch names can be configured.
///
/// --configKeyValues "TParticle.treeName=T,TParticle.branchName=P"
///
/// File(s) to read are also configurable
///
/// --configKeyValues "TParticle.fileNames=foo.root,bar.root"
///
class GeneratorTParticle : public Generator
{
public:
/** CTOR */
GeneratorTParticle() = default;
/** CTOR */
GeneratorTParticle(const std::string& name)
: Generator(name.c_str(),"ALICEo2 TParticle Generator")
{}
/** DTOR */
virtual ~GeneratorTParticle();
}
/** DTOR */
virtual ~GeneratorTParticle();

/** Initialize this generator. This will set up the chain.
Optionally, if a command line was specified by @c
TParticle.progCmd then that command line is executed in the
background and events are read from the output file of that
program */
Bool_t Init() override;
/** Initialize this generator. This will set up the chain.
Optionally, if a command line was specified by @c
TParticle.progCmd then that command line is executed in the
background and events are read from the output file of that
program */
Bool_t Init() override;

/** Read in the next entry from the chain. Returns false in
case of errors or no more entries to read. */
Bool_t generateEvent() override;
/** Read in the next entry from the chain. Returns false in
case of errors or no more entries to read. */
Bool_t generateEvent() override;

/** Import the read-in particles into the steer particle
stack */
Bool_t importParticles() override;
/** Import the read-in particles into the steer particle
stack */
Bool_t importParticles() override;

/** Set the names of files to read, separated by commas */
void setFileNames(const std::string& val);
/** Set the name of the tree in the files. The tree _must_
reside in the top-level directory of the files. */
void setTreeName(const std::string& val) { mTreeName = val; }
/** Set the branch name of the branch that holds a @c
TClonesArray of @c TParticle objects */
void setBranchName(const std::string& val) { mBranchName = val; }
/** Set child program command line to (optionally) execute */
void setProgCmd(const std::string& val) { mProgCmd = val; }
/** Set the number of events to generate. */
void setNEvents(unsigned int nev) { mNEvents = nev; }
protected:
std::string mTreeName = "T";
std::string mBranchName = "Particles";
std::string mProgCmd = "";
std::list<std::string> mFileNames;
unsigned int mNEvents = 0;
unsigned int mEntry = 0;
TChain* mChain;
TClonesArray* mTParticles;
/** Set the names of files to read, separated by commas */
void setFileNames(const std::string& val);
/** Set the name of the tree in the files. The tree _must_
reside in the top-level directory of the files. */
void setTreeName(const std::string& val) { mTreeName = val; }
/** Set the branch name of the branch that holds a @c
TClonesArray of @c TParticle objects */
void setBranchName(const std::string& val) { mBranchName = val; }
/** Set child program command line to (optionally) execute */
void setProgCmd(const std::string& val) { mProgCmd = val; }
/** Set the number of events to generate. */
void setNEvents(unsigned int nev) { mNEvents = nev; }

void waitForData();
protected:
std::string mTreeName = "T";
std::string mBranchName = "Particles";
std::string mProgCmd = "";
std::list<std::string> mFileNames;
unsigned int mNEvents = 0;
unsigned int mEntry = 0;
TChain* mChain;
TClonesArray* mTParticles;

ClassDefOverride(GeneratorTParticle,1);
};
}
}
void waitForData();

ClassDefOverride(GeneratorTParticle, 1);
};
} // namespace eventgen
} // namespace o2
#endif
//
// EOF
//




30 changes: 14 additions & 16 deletions Generators/include/Generators/GeneratorTParticleParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// 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_GENERATORTPARTICLEPARAM_H_
#define ALICEO2_EVENTGEN_GENERATORTPARTICLEPARAM_H_
Expand All @@ -22,22 +22,20 @@

namespace o2
{
namespace eventgen
{
namespace eventgen
{

/**
a parameter class/struct to keep the settings of the TGenerator
event generator and allow the user to modify them */
struct GeneratorTParticleParam :
public o2::conf::ConfigurableParamHelper<GeneratorTParticleParam>
{
std::string treeName = "T";
std::string branchName = "Particles";
std::string fileNames = "tparticle.root";
std::string progCmd = "";
O2ParamDef(GeneratorTParticleParam, "TParticle");
};
} // end namespace eventgen
/**
a parameter class/struct to keep the settings of the TGenerator
event generator and allow the user to modify them */
struct GeneratorTParticleParam : public o2::conf::ConfigurableParamHelper<GeneratorTParticleParam> {
std::string treeName = "T";
std::string branchName = "Particles";
std::string fileNames = "tparticle.root";
std::string progCmd = "";
O2ParamDef(GeneratorTParticleParam, "TParticle");
};
} // end namespace eventgen
} // end namespace o2

#endif // ALICEO2_EVENTGEN_GENERATORHEPMCPARAM_H_
5 changes: 3 additions & 2 deletions Generators/src/GeneratorFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
if (o2PrimGen) {
o2PrimGen->setApplyVertex(false);
}
} LOG(info) << "using external O2 kinematics";
}
LOG(info) << "using external O2 kinematics";
} else if (genconfig.compare("tparticle") == 0) {
// External ROOT file(s) with tree of TParticle in clones array,
// or external program generating such a file
// or external program generating such a file
auto& param = GeneratorTParticleParam::Instance();
LOG(info) << "Init 'GeneratorTParticle' with the following parameters";
LOG(info) << param;
Expand Down
Loading