Skip to content

Commit b3ab80e

Browse files
committed
Interface and params for AEGIS Cosmics generator
1 parent c702fb4 commit b3ab80e

8 files changed

Lines changed: 211 additions & 2 deletions

File tree

Generators/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ o2_add_library(Generators
3232
src/TriggerParticleParam.cxx
3333
src/BoxGunParam.cxx
3434
src/QEDGenParam.cxx
35+
src/GenCosmicsParam.cxx
3536
src/GeneratorFactory.cxx
3637
$<$<BOOL:${pythia6_FOUND}>:src/GeneratorPythia6.cxx>
3738
$<$<BOOL:${pythia6_FOUND}>:src/GeneratorPythia6Param.cxx>
@@ -70,7 +71,8 @@ set(headers
7071
include/Generators/TriggerParticleParam.h
7172
include/Generators/ConfigurationMacroHelper.h
7273
include/Generators/BoxGunParam.h
73-
include/Generators/QEDGenParam.h)
74+
include/Generators/QEDGenParam.h
75+
include/Generators/GenCosmicsParam.h)
7476

7577
if (pythia6_FOUND)
7678
list(APPEND headers include/Generators/GeneratorPythia6.h
@@ -107,6 +109,11 @@ if(doBuildSimulation)
107109
PUBLIC_LINK_LIBRARIES O2::Generators
108110
O2::SimConfig
109111
LABELS generators)
112+
113+
o2_add_test_root_macro(share/external/GenCosmicsLoader.C
114+
PUBLIC_LINK_LIBRARIES O2::Generators
115+
O2::SimConfig
116+
LABELS generators)
110117
endif()
111118

112119
o2_add_test_root_macro(share/external/tgenerator.C
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
#ifndef ALICEO2_GENCOSMICSPARAM_H
12+
#define ALICEO2_GENCOSMICSPARAM_H
13+
14+
#include "CommonUtils/ConfigurableParam.h"
15+
#include "CommonUtils/ConfigurableParamHelper.h"
16+
17+
// @file GenCosmicsParam
18+
// @author ruben.shahoyan@cern.ch
19+
// @brief Parameters for cosmics generation
20+
21+
namespace o2
22+
{
23+
namespace eventgen
24+
{
25+
struct GenCosmicsParam : public o2::conf::ConfigurableParamHelper<GenCosmicsParam> {
26+
enum GenParamType : int { ParamMI,
27+
ParamACORDE,
28+
ParamTPC }; // source parameterizations
29+
enum AccType : int { ITS0,
30+
ITS1,
31+
ITS2,
32+
ITS3,
33+
ITS4,
34+
ITS5,
35+
ITS6,
36+
TPC,
37+
Custom };
38+
GenParamType param = ParamTPC;
39+
AccType accept = TPC;
40+
int nPart = 1; ///< number of particles per event
41+
int maxTrials = 10000000; ///< number of failed trials to abandon generation
42+
float maxAngle = 45.; ///< max angle wrt azimuth to generate (in degrees)
43+
float origin = 550.; ///< create particle at this radius
44+
float pmin = 0.5; ///< min total momentum
45+
float pmax = 100; ///< max total momentum
46+
float customAccX = 250; ///< require particle to pass within this |X| at Y=0 if AccType=custom is selected
47+
float customAccZ = 250; ///< require particle to pass within this |Z| at Y=0 if AccType=custom is selected
48+
49+
// boilerplate stuff + make principal key
50+
O2ParamDef(GenCosmicsParam, "cosmics");
51+
};
52+
53+
} // namespace eventgen
54+
} // namespace o2
55+
56+
#endif
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
//< Macro to run QED background generator, us it as e.g.
12+
//< o2-sim -n10000 -m PIPE ITS TPC -g extgen --extGenFile $O2_ROOT/share/Generators/external/GenCosmicsLoader.C
13+
14+
R__LOAD_LIBRARY(libGeneratorCosmics.so)
15+
16+
using namespace o2::eventgen;
17+
18+
o2::eventgen::GeneratorTGenerator* GenCosmics()
19+
{
20+
auto genCosm = new GeneratorCosmics();
21+
auto& cosmParam = GenCosmicsParam::Instance();
22+
23+
if (cosmParam.param == GenCosmicsParam::ParamMI) {
24+
genCosm->setParamMI();
25+
} else if (cosmParam.param == GenCosmicsParam::ParamACORDE) {
26+
genCosm->setParamACORDE();
27+
} else if (cosmParam.param == GenCosmicsParam::ParamTPC) {
28+
genCosm->setParamTPC();
29+
} else {
30+
LOG(FATAL) << "Unknown cosmics param type " << cosmParam.param;
31+
}
32+
33+
genCosm->setNPart(cosmParam.nPart);
34+
genCosm->setPRange(cosmParam.pmin, cosmParam.pmax);
35+
36+
switch (cosmParam.accept) {
37+
case GenCosmicsParam::ITS0:
38+
genCosm->requireITS0();
39+
break;
40+
case GenCosmicsParam::ITS1:
41+
genCosm->requireITS1();
42+
break;
43+
case GenCosmicsParam::ITS2:
44+
genCosm->requireITS2();
45+
break;
46+
case GenCosmicsParam::ITS3:
47+
genCosm->requireITS3();
48+
break;
49+
case GenCosmicsParam::ITS4:
50+
genCosm->requireITS4();
51+
break;
52+
case GenCosmicsParam::ITS5:
53+
genCosm->requireITS5();
54+
break;
55+
case GenCosmicsParam::ITS6:
56+
genCosm->requireITS6();
57+
break;
58+
case GenCosmicsParam::TPC:
59+
genCosm->requireTPC();
60+
break;
61+
case GenCosmicsParam::Custom:
62+
genCosm->requireXZAccepted(cosmParam.customAccX, cosmParam.customAccZ);
63+
break;
64+
default:
65+
LOG(FATAL) << "Unknown cosmics acceptance type " << cosmParam.accept;
66+
break;
67+
}
68+
69+
genCosm->Init();
70+
71+
// instance and configure TGenerator interface
72+
auto tgen = new o2::eventgen::GeneratorTGenerator();
73+
tgen->setMomentumUnit(1.); // [GeV/c]
74+
tgen->setEnergyUnit(1.); // [GeV/c]
75+
tgen->setPositionUnit(1.); // [cm]
76+
tgen->setTimeUnit(1.); // [s]
77+
tgen->setTGenerator(genCosm);
78+
fg = tgen;
79+
return tgen;
80+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
//< Loader macro to run QED background generator from QEDepem.C macro, use it as e.g.
12+
//< o2-sim -n10000 -m PIPE ITS TPC -g extgen --extGenFile $O2_ROOT/share/Generators/external/GenCosmicsLoader.C
13+
//< Generation options can be changed by providing --configKeyValues "cosmics.maxAngle=30.;cosmics.accept=ITS0" etc.
14+
//< See GenCosmicsParam for available options
15+
16+
#include <FairLogger.h>
17+
18+
FairGenerator* fg = nullptr;
19+
20+
FairGenerator* GenCosmicsLoader()
21+
{
22+
const TString macroName = "GenCosmics";
23+
gSystem->Load("libGeneratorCosmics.so");
24+
25+
// the path of the macro to load depends on where it was installed, we assume that its installation
26+
// directory is the same as of the loader macro
27+
std::ostringstream mstr;
28+
mstr << __FILE__;
29+
TString macroFullName = Form("%s/%s.C", gSystem->DirName(mstr.str().c_str()), macroName.Data());
30+
LOG(INFO) << "\nLoading " << macroFullName.Data() << "\n";
31+
32+
gROOT->LoadMacro(macroFullName.Data());
33+
gInterpreter->ProcessLine(Form("%s()", macroName.Data()));
34+
return fg;
35+
}

Generators/share/external/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
------------
99

1010

11-
## qedbkg.C
11+
## QEDLoader.C / QEDepem.C
1212

1313
- Invokes TGenEpEmv1 generator from [AEGIS](https://github.com/AliceO2Group/AEGIS) package for Pb-Pb &rarr; e+e- generation.
1414
+ optional parameters are rapidity and pT ranges to generate, can be provided as key/value option, e.g.
@@ -17,4 +17,16 @@ o2-sim -n 1000 -m PIPE ITS -g extgen --extGenFile $O2_ROOT/share/Generators/exte
1717
``
1818
The x-section of the process depends on the applied cuts, it is calculated on the fly and stored in the ``qedgenparam.ini`` file.
1919

20+
## GenCosmicsLoader.C / GenCosmics.C
21+
22+
- Invokes GenerateCosmics generators from [AEGIS](https://github.com/AliceO2Group/AEGIS) package.
23+
24+
``o2-sim -n1000 -m PIPE ITS TPC -g extgen --extGenFile $O2_ROOT/share/Generators/external/GenCosmicsLoader.C``
25+
26+
Generation options can be changed by providing ``--configKeyValues "cosmics.maxAngle=30.;cosmics.accept=ITS0"`` etc.
27+
For instance, to generate track defined at radius 500 cm, with maximal angle wrt the azimuth of 40 degress and passing via ITS layer 0 at Y=0:
28+
29+
``o2-sim -n100 -m PIPE ITS TPC --configKeyValues "cosmics.maxAngle=40.;cosmics.accept=ITS0;cosmics.origin=500" -g extgen --extGenFile $O2_ROOT/share/Generators/external/GenCosmicsLoader.C``
30+
31+
See GenCosmicsParam class for available options.
2032
------------

Generators/src/GenCosmicsParam.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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/GenCosmicsParam.h"
12+
13+
using namespace o2::eventgen;
14+
15+
O2ParamImpl(o2::eventgen::GenCosmicsParam);

Generators/src/GeneratorsLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@
5858
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::BoxGunParam > +;
5959
#pragma link C++ class o2::eventgen::QEDGenParam + ;
6060
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::QEDGenParam > +;
61+
#pragma link C++ class o2::eventgen::GenCosmicsParam + ;
62+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::GenCosmicsParam> + ;
6163

6264
#endif

cmake/O2RootMacroExclusionList.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST
4646
Detectors/TOF/prototyping/ConvertRun2CalibrationToO2.C
4747
Generators/share/external/hijing.C
4848
Generators/share/external/QEDepem.C
49+
Generators/share/external/GenCosmics.C
4950
macro/SetIncludePath.C
5051
macro/loadExtDepLib.C
5152
macro/load_all_libs.C
@@ -61,6 +62,7 @@ if(NOT BUILD_SIMULATION)
6162
o2_get_list_of_macros(${CMAKE_SOURCE_DIR}/Detectors/gconfig macros)
6263
list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST ${macros})
6364
list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST Generators/share/external/QEDLoader.C)
65+
list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST Generators/share/external/GenCosmicsLoader.C)
6466
list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST Generators/share/egconfig/pythia8_userhooks_charm.C)
6567
list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST Generators/share/external/trigger_mpi.C)
6668
endif()

0 commit comments

Comments
 (0)