-
Notifications
You must be signed in to change notification settings - Fork 485
Cholmcc generators #11913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Cholmcc generators #11913
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a911276
Introduce pre-defined keys for MC event header info
cholmcc dadc5c6
Export _full_ header information to MC event header
cholmcc 2f36720
Full header read-in and external program
cholmcc ae319c5
New generator GeneratorTParticle
cholmcc 0558c4b
Please consider the following formatting changes
alibuild a94f5f1
Merge pull request #1 from alibuild/alibot-cleanup-11913
cholmcc 2e413a3
Fixes for copyright stuff - sigh!
cholmcc 3d657ef
One more comment
cholmcc f423011
Please consider the following formatting changes
alibuild 7313685
Merge pull request #2 from alibuild/alibot-cleanup-11913
cholmcc 233e2e0
Whitespace
cholmcc d65a0c9
untabify
cholmcc ee59676
Merge branch 'AliceO2Group:dev' into cholmcc_generatos
cholmcc 6f6f2c3
Added documentation
cholmcc 05ad595
Changed key prefix
cholmcc 5115a6e
Add new sub-dirs
cholmcc 595d843
Formatting fixes
cholmcc 4715d37
Renamed _script_ (not macro) to end in .macro (sigh)
cholmcc 0434a6e
Renamed _script_ (not macro) to end in .macro (sigh)
cholmcc e1db4b0
Fix formatting
cholmcc eb308c0
Fix formatting
cholmcc 67e5ba9
Fix formatting
cholmcc f27aaf8
Fix formatting
cholmcc 5b62d47
Fix formatting - that checker is ridiculously pedantic about things a…
cholmcc 43ea6d4
Stupid annoying formatting checker - it is really f**cking ridiculous…
cholmcc 73c7490
Undo last faulty commit and fix formatting
cholmcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| // 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_GENERATORTPARTICLE_H_ | ||
| #define ALICEO2_GENERATORTPARTICLE_H_ | ||
| #include <FairGenerator.h> | ||
| #include <Generators/Generator.h> | ||
| #include <list> | ||
|
|
||
| // Forward decls | ||
| class TChain; | ||
| class TParticle; | ||
| class TClonesArray; | ||
|
|
||
| namespace o2 | ||
| { | ||
| 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") | ||
| { | ||
| } | ||
| /** 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; | ||
|
|
||
| /** 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; | ||
|
|
||
| /** 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; | ||
|
|
||
| void waitForData(); | ||
|
|
||
| ClassDefOverride(GeneratorTParticle, 1); | ||
| }; | ||
| } // namespace eventgen | ||
| } // namespace o2 | ||
| #endif | ||
| // Local Variables: | ||
| // mode: C++ | ||
| // End: | ||
| // | ||
| // EOF | ||
| // | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // 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_GENERATORTPARTICLEPARAM_H_ | ||
| #define ALICEO2_EVENTGEN_GENERATORTPARTICLEPARAM_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 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, "GeneratorTParticle"); | ||
| }; | ||
| } // end namespace eventgen | ||
| } // end namespace o2 | ||
|
|
||
| #endif // ALICEO2_EVENTGEN_GENERATORHEPMCPARAM_H_ | ||
| // Local Variables: | ||
| // mode: C++ | ||
| // End: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit unsure about this one: We already have a generator "GeneratorFromFile" which reads TParticles from a Run2 - like ROOT file.
A quick check if we still need this one would good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a difference between the
GeneratorFromFileandGeneratorTParticle, mainly in thatGeneratorTParticleTChainof filesTTree, unlikeGeneratorFromFilewhich assumes there's oneTTreefor each event in theTDirectorynamedEvent<_event-no_>in the single input file.As such, the two classes
GeneratorFromFileand `GeneratorTParticle serves different needsGeneratorFromFileis designed to read from an AliROOTKinematics.rootfileGeneratorTParticleis designed to read from a general ROOT event tree, for example produced by aTGenerator.Hope that clarifies the differences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and another difference. Using the key
progCmd, one could execute aTGeneratoras a background process. Say we have the scriptMyEG.Cand a simple script like
myeg.shthen one can do
which means all the old
AliGeneratorscan be used more or less directly :-)