Skip to content
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

Added alien path compatibility, Phi rotation and event pool randomisation to GenO2Kine #13571

Merged
merged 22 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c45b477
Implemented flag for .root kinematics input
jackal1-66 Oct 7, 2024
45be6ac
Event pooling with order randomisation of tree entries
jackal1-66 Oct 17, 2024
8621151
Added rng seed flag
jackal1-66 Oct 18, 2024
8749040
Added possibility of random rotation of Phi in event pool
jackal1-66 Oct 18, 2024
b70c6c8
Added GRID kine input compatibility
jackal1-66 Oct 21, 2024
3abdf90
Merge branch 'AliceO2Group:dev' into eventpool1
jackal1-66 Oct 21, 2024
ce45b43
Introduction of GeneratorHybrid class for multiple generators configu…
jackal1-66 Oct 24, 2024
d3ffd4d
Merge branch 'eventpool1' of https://github.com/jackal1-66/AliceO2 in…
jackal1-66 Oct 24, 2024
c96cdea
Merge branch 'AliceO2Group:dev' into eventpool1
jackal1-66 Oct 24, 2024
8e3a4ad
Implemented configurations and fractions parameters for hybrid generator
jackal1-66 Oct 25, 2024
76291b0
Merge branch 'AliceO2Group:dev' into eventpool
jackal1-66 Oct 29, 2024
640f076
Merge branch 'AliceO2Group:dev' into eventpool1
jackal1-66 Oct 29, 2024
3391bcc
Added features to use alien path, phi rotation and event randomisation
jackal1-66 Oct 29, 2024
3a8dc30
Removal of unused implementation attempt
jackal1-66 Oct 29, 2024
d8e70e1
Deleted feature for RUN2 based generator
jackal1-66 Oct 29, 2024
c9a5dad
Merge branch 'AliceO2Group:dev' into eventpool
jackal1-66 Oct 30, 2024
ab696dd
Merge branch 'AliceO2Group:dev' into eventpool1
jackal1-66 Oct 30, 2024
2d3b692
Merge branch 'eventpool1' into eventpool
jackal1-66 Oct 30, 2024
335f4c9
Revert "Add SMatrixGPU compatibility to trackParCov (#13602)"
jackal1-66 Oct 30, 2024
983ce32
Revert "Merge branch 'eventpool1' into eventpool"
jackal1-66 Oct 30, 2024
b465c39
Reapply "Add SMatrixGPU compatibility to trackParCov (#13602)"
jackal1-66 Oct 30, 2024
84619f1
Better rotation handling
jackal1-66 Oct 30, 2024
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
6 changes: 6 additions & 0 deletions Generators/include/Generators/GeneratorFromFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "FairGenerator.h"
#include "Generators/Generator.h"
#include <TRandom3.h>
#include <TGrid.h>

class TBranch;
class TFile;
Expand Down Expand Up @@ -94,6 +96,10 @@ class GeneratorFromO2Kine : public o2::eventgen::Generator
bool mSkipNonTrackable = true; //! whether to pass non-trackable (decayed particles) to the MC stack
bool mContinueMode = false; //! whether we want to continue simulation of previously inhibited tracks
bool mRoundRobin = false; //! whether we want to take events from file in a round robin fashion
bool mRandomize = false; //! whether we want to randomize the order of events in the input file
unsigned int mRngSeed = 0; //! randomizer seed, 0 for random value
bool mRandomPhi = false; //! whether we want to randomize the phi angle of the particles
TGrid* mAlienInstance = nullptr; // a cached connection to TGrid (needed for Alien locations)

std::unique_ptr<o2::dataformats::MCEventHeader> mOrigMCEventHeader; //! the MC event header of the original file

Expand Down
5 changes: 4 additions & 1 deletion Generators/include/Generators/GeneratorFromO2KineParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ namespace eventgen
/**
** a parameter class/struct to keep the settings of
** the FromO2Kine event generator and
** allow the user to modify them
** allow the user to modify them
**/

struct GeneratorFromO2KineParam : public o2::conf::ConfigurableParamHelper<GeneratorFromO2KineParam> {
bool skipNonTrackable = true;
bool continueMode = false;
bool roundRobin = false; // read events with period boundary conditions
bool randomize = false; // randomize the order of events
unsigned int rngseed = 0; // randomizer seed, 0 for random value
bool randomphi = false; // randomize phi angle
std::string fileName = ""; // filename to read from - takes precedence over SimConfig if given
O2ParamDef(GeneratorFromO2KineParam, "GeneratorFromO2Kine");
};
Expand Down
34 changes: 34 additions & 0 deletions Generators/src/GeneratorFromFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ GeneratorFromO2Kine::GeneratorFromO2Kine(const char* name)
setPositionUnit(1.);
setTimeUnit(1.);

if (strncmp(name, "alien:/", 7) == 0) {
mAlienInstance = TGrid::Connect("alien");
if (!mAlienInstance) {
LOG(fatal) << "Could not connect to alien, did you check the alien token?";
return;
}
}
mEventFile = TFile::Open(name);
if (mEventFile == nullptr) {
LOG(fatal) << "EventFile " << name << " not found";
Expand Down Expand Up @@ -210,6 +217,12 @@ bool GeneratorFromO2Kine::Init()
mSkipNonTrackable = param.skipNonTrackable;
mContinueMode = param.continueMode;
mRoundRobin = param.roundRobin;
mRandomize = param.randomize;
mRngSeed = param.rngseed;
mRandomPhi = param.randomphi;
if (mRandomize) {
gRandom->SetSeed(mRngSeed);
}

return true;
}
Expand All @@ -229,6 +242,18 @@ bool GeneratorFromO2Kine::importParticles()
// It might need some adjustment to make it work with secondaries or to continue
// from a kinematics snapshot

// Randomize the order of events in the input file
if (mRandomize) {
mEventCounter = gRandom->Integer(mEventsAvailable);
}

double dPhi = 0.;
// Phi rotation
if (mRandomPhi) {
dPhi = gRandom->Uniform(2 * TMath::Pi());
LOG(info) << "Rotating phi by " << dPhi;
}

if (mEventCounter < mEventsAvailable) {
int particlecounter = 0;

Expand All @@ -253,6 +278,15 @@ bool GeneratorFromO2Kine::importParticles()
auto pdg = t.GetPdgCode();
auto px = t.Px();
auto py = t.Py();
if (mRandomPhi) {
// transformation applied through rotation matrix
auto cos = TMath::Cos(dPhi);
auto sin = TMath::Sin(dPhi);
auto newPx = px * cos - py * sin;
auto newPy = px * sin + py * cos;
px = newPx;
py = newPy;
}
jackal1-66 marked this conversation as resolved.
Show resolved Hide resolved
auto pz = t.Pz();
auto vx = t.Vx();
auto vy = t.Vy();
Expand Down
Loading