-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathGeneratorPythia6.cxx
More file actions
108 lines (88 loc) · 3.08 KB
/
GeneratorPythia6.cxx
File metadata and controls
108 lines (88 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// 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 R+Preghenella - January 2020
#include "Generators/GeneratorPythia6.h"
#include "FairLogger.h"
#include "FairPrimaryGenerator.h"
#include <iostream>
#include <iomanip>
#include "TPythia6.h"
namespace o2
{
namespace eventgen
{
/*****************************************************************/
/*****************************************************************/
GeneratorPythia6::GeneratorPythia6() : GeneratorTGenerator("ALICEo2", "ALICEo2 Pythia6 Generator")
{
/** default constructor **/
setTGenerator(TPythia6::Instance());
mInterface = reinterpret_cast<void*>(TPythia6::Instance());
mInterfaceName = "pythia6";
}
/*****************************************************************/
GeneratorPythia6::GeneratorPythia6(const Char_t* name, const Char_t* title) : GeneratorTGenerator(name, title)
{
/** constructor **/
setTGenerator(TPythia6::Instance());
mInterface = reinterpret_cast<void*>(TPythia6::Instance());
mInterfaceName = "pythia6";
}
/*****************************************************************/
Bool_t GeneratorPythia6::Init()
{
/** init **/
/** init base class **/
Generator::Init();
/** configuration file **/
if (!mConfig.empty()) {
std::ifstream fin(mConfig.c_str());
if (!fin.is_open()) {
LOG(fatal) << "cannot open configuration file: " << mConfig;
return kFALSE;
}
/** process configuration file **/
std::string whitespace = " \t\f\v\n\r";
std::string comment = "#";
for (std::string line; getline(fin, line);) {
/** remove comments **/
line = line.substr(0, line.find_first_of(comment));
if (line.size() == 0) {
continue;
}
/** remove leading/trailing whitespaces **/
const auto line_begin = line.find_first_not_of(whitespace);
const auto line_end = line.find_last_not_of(whitespace);
if (line_begin == std::string::npos ||
line_end == std::string::npos) {
continue;
}
const auto line_range = line_end - line_begin + 1;
line = line.substr(line_begin, line_range);
if (line.size() == 0) {
continue;
}
/** process command **/
readString(line.c_str());
}
fin.close();
}
/** tune **/
TPythia6::Instance()->Pytune(mTune);
/** initialize **/
TPythia6::Instance()->Initialize(mFrame.c_str(), mBeam.c_str(), mTarget.c_str(), mWin);
/** success **/
return kTRUE;
}
/*****************************************************************/
/*****************************************************************/
} /* namespace eventgen */
} /* namespace o2 */