Skip to content

Commit d0b646e

Browse files
committed
Import examples from O2 into O2DPG
1 parent 4acf74a commit d0b646e

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// configures a AliGenHijing class from AliRoot
2+
// usage: o2sim -g external --configKeyValues 'GeneratorExternal.fileName=hijing.C;GeneratorExternal.funcName="hijing(5020., 0., 20.)"'
3+
4+
/// \author R+Preghenella - October 2018
5+
6+
R__LOAD_LIBRARY(libTHijing)
7+
8+
FairGenerator*
9+
hijing(double energy = 5020., double bMin = 0., double bMax = 20.)
10+
{
11+
// instance and configure Hijing
12+
auto hij = new AliGenHijing(-1);
13+
hij->SetEnergyCMS(energy);
14+
hij->SetImpactParameterRange(bMin, bMax);
15+
hij->SetReferenceFrame("CMS");
16+
hij->SetProjectile("A", 208, 82);
17+
hij->SetTarget("A", 208, 82);
18+
hij->SetSpectators(0);
19+
hij->KeepFullEvent();
20+
hij->SetJetQuenching(0);
21+
hij->SetShadowing(1);
22+
hij->SetDecaysOff(1);
23+
hij->SetSelectAll(0);
24+
hij->SetPtHardMin(2.9);
25+
hij->Init();
26+
27+
// instance and configure TGenerator interface
28+
auto tgen = new o2::eventgen::GeneratorTGenerator();
29+
tgen->setMomentumUnit(1.); // [GeV/c]
30+
tgen->setEnergyUnit(1.); // [GeV/c]
31+
tgen->setPositionUnit(0.1); // [cm]
32+
tgen->setTimeUnit(3.3356410e-12); // [s]
33+
tgen->setTGenerator(hij->GetMC());
34+
return tgen;
35+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// configures a TPythia6 class
2+
// usage: o2sim -g external --configKeyValues 'GeneratorExternal.fileName=pythia6.C;GeneratorExternal.funcName="pythia6(14000., "pythia.settings")"'
3+
4+
/// \author R+Preghenella - October 2018
5+
6+
#if !defined(__CLING__) || defined(__ROOTCLING__)
7+
#include "TPythia6.h"
8+
#include "FairGenerator.h"
9+
#include "Generators/GeneratorTGenerator.h"
10+
#include <fstream>
11+
#include <iostream>
12+
#endif
13+
14+
R__LOAD_LIBRARY(libpythia6)
15+
16+
void configure(TPythia6* py6, const char* params);
17+
18+
FairGenerator*
19+
pythia6(double energy = 14000., const char* params = nullptr)
20+
{
21+
// instance and configure Pythia6
22+
auto py6 = TPythia6::Instance();
23+
if (params)
24+
configure(py6, params);
25+
py6->Initialize("CMS", "p", "p", energy);
26+
27+
// instance and configure TGenerator interface
28+
auto tgen = new o2::eventgen::GeneratorTGenerator();
29+
tgen->setMomentumUnit(1.); // [GeV/c]
30+
tgen->setEnergyUnit(1.); // [GeV/c]
31+
tgen->setPositionUnit(0.1); // [cm]
32+
tgen->setTimeUnit(3.3356410e-12); // [s]
33+
tgen->setTGenerator(py6);
34+
return tgen;
35+
}
36+
37+
void configure(TPythia6* py6, const char* params)
38+
{
39+
std::ifstream file(params);
40+
if (!file.is_open()) {
41+
std::cerr << "Cannot open configuration file: " << params << std::endl;
42+
return;
43+
};
44+
std::string line, command;
45+
while (std::getline(file, line)) {
46+
/** remove comments **/
47+
command = line.substr(0, line.find_first_of("#"));
48+
if (command.length() == 0)
49+
continue;
50+
py6->Pygive(command.c_str());
51+
}
52+
file.close();
53+
}

0 commit comments

Comments
 (0)