Skip to content

Commit b850928

Browse files
committed
Make box particle gun configurable
The box event generator is now configurable which is convenient for testing/scanning simulation with various particle types and energies.
1 parent b3df11d commit b850928

5 files changed

Lines changed: 70 additions & 8 deletions

File tree

Generators/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ set(SRCS
1717
src/PDG.cxx
1818
src/PrimaryGenerator.cxx
1919
src/InteractionDiamondParam.cxx
20+
src/BoxGunParam.cxx
2021
)
2122
set(HEADERS
2223
include/${MODULE_NAME}/Generator.h
@@ -26,7 +27,8 @@ set(HEADERS
2627
include/${MODULE_NAME}/PDG.h
2728
include/${MODULE_NAME}/PrimaryGenerator.h
2829
include/${MODULE_NAME}/InteractionDiamondParam.h
29-
)
30+
include/${MODULE_NAME}/BoxGunParam.h
31+
)
3032
if (HAVESIMULATION)
3133
set(HEADERS ${HEADERS}
3234
include/${MODULE_NAME}/GeneratorFactory.h
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \author S+Wenzel - May 2019
12+
13+
#ifndef ALICEO2_EVENTGEN_GUNPARAM_H_
14+
#define ALICEO2_EVENTGEN_GUNPARAM_H_
15+
16+
#include "SimConfig/ConfigurableParam.h"
17+
#include "SimConfig/ConfigurableParamHelper.h"
18+
19+
namespace o2
20+
{
21+
namespace eventgen
22+
{
23+
24+
/**
25+
** A parameter class/struct holding values for
26+
** the box/gun generator. Allows for quick runtime configurability
27+
** of particle type, energy, direction, etc.
28+
**/
29+
struct BoxGunParam : public o2::conf::ConfigurableParamHelper<BoxGunParam> {
30+
int pdg = 13; // which particle (default proton?); could make this an enum
31+
int number = 10; // how many particles
32+
double eta[2] = { -1, 1 }; // eta range
33+
double prange[2] = { 0.1, 5 }; // energy range min, max in GeV
34+
double phirange[2] = { 0., 360. }; // phi range
35+
bool debug = false; // whether to print out produced particles
36+
O2ParamDef(BoxGunParam, "BoxGun");
37+
};
38+
39+
} // end namespace eventgen
40+
} // end namespace o2
41+
42+
#endif // ALICEO2_EVENTGEN_INTERACTIONDIAMONDPARAM_H_

Generators/src/BoxGunParam.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#include "Generators/BoxGunParam.h"
12+
O2ParamImpl(o2::eventgen::BoxGunParam);

Generators/src/GeneratorFactory.cxx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <SimConfig/SimConfig.h>
1919
#include <Generators/GeneratorFromFile.h>
2020
#include <Generators/Pythia8Generator.h>
21+
#include <Generators/BoxGunParam.h>
2122
#include "TROOT.h"
2223
#include "TSystem.h"
2324
#include "TGlobal.h"
@@ -38,13 +39,16 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
3839
}
3940
auto genconfig = conf.getGenerator();
4041
if (genconfig.compare("boxgen") == 0) {
41-
// a simple "box" generator
42-
LOG(INFO) << "Init box generator";
43-
auto boxGen = new FairBoxGenerator(211, 10); /*protons*/
44-
boxGen->SetEtaRange(-0.9, 0.9);
45-
boxGen->SetPRange(0.1, 5);
46-
boxGen->SetPhiRange(0., 360.);
47-
boxGen->SetDebug(kTRUE);
42+
// a simple "box" generator configurable via BoxGunparam
43+
auto& boxparam = BoxGunParam::Instance();
44+
LOG(INFO) << "Init box generator with following parameters";
45+
LOG(INFO) << boxparam;
46+
auto boxGen = new FairBoxGenerator(boxparam.pdg, boxparam.number);
47+
boxGen->SetEtaRange(boxparam.eta[0], boxparam.eta[1]);
48+
boxGen->SetPRange(boxparam.prange[0], boxparam.prange[1]);
49+
boxGen->SetPhiRange(boxparam.phirange[0], boxparam.phirange[1]);
50+
boxGen->SetDebug(boxparam.debug);
51+
4852
primGen->AddGenerator(boxGen);
4953
} else if (genconfig.compare("fwmugen") == 0) {
5054
// a simple "box" generator for forward muons

Generators/src/GeneratorsLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@
3636
#pragma link C++ class o2::eventgen::PrimaryGenerator + ;
3737
#pragma link C++ class o2::eventgen::InteractionDiamondParam + ;
3838
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::InteractionDiamondParam> + ;
39+
#pragma link C++ class o2::eventgen::BoxGunParam + ;
40+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::BoxGunParam> + ;
3941

4042
#endif

0 commit comments

Comments
 (0)