Skip to content

Commit d85253d

Browse files
preghenellasawenzel
authored andcommitted
CMD line configurable interaction diamond for vertex spread in simulation
1 parent bcab866 commit d85253d

File tree

8 files changed

+182
-2
lines changed

8 files changed

+182
-2
lines changed

Generators/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ set(SRCS
99
src/GeneratorFromFile.cxx
1010
src/Pythia6Generator.cxx
1111
src/PDG.cxx
12+
src/PrimaryGenerator.cxx
13+
src/InteractionDiamondParam.cxx
1214
)
1315
set(HEADERS
1416
include/${MODULE_NAME}/GeneratorFromFile.h
1517
include/${MODULE_NAME}/Pythia6Generator.h
1618
include/${MODULE_NAME}/PDG.h
19+
include/${MODULE_NAME}/PrimaryGenerator.h
20+
include/${MODULE_NAME}/InteractionDiamondParam.h
1721
)
1822
if (HAVESIMULATION)
1923
set(HEADERS ${HEADERS}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 R+Preghenella - October 2018
12+
13+
#ifndef ALICEO2_EVENTGEN_INTERACTIONDIAMONDPARAM_H_
14+
#define ALICEO2_EVENTGEN_INTERACTIONDIAMONDPARAM_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 to keep the settings of
26+
** the interaction diamond (position and width) and
27+
** allow the user to modify them
28+
**/
29+
30+
struct InteractionDiamondParam : public o2::conf::ConfigurableParamHelper<InteractionDiamondParam> {
31+
double position[3] = { 0., 0., 0. };
32+
double width[3] = { 0., 0., 0. };
33+
O2ParamDef(InteractionDiamondParam, "Diamond");
34+
};
35+
36+
} // end namespace eventgen
37+
} // end namespace o2
38+
39+
#endif // ALICEO2_EVENTGEN_INTERACTIONDIAMONDPARAM_H_
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 https://alice-o2.web.cern.ch/ 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 R+Preghenella - June 2017
12+
13+
#ifndef ALICEO2_EVENTGEN_PRIMARYGENERATOR_H_
14+
#define ALICEO2_EVENTGEN_PRIMARYGENERATOR_H_
15+
16+
#include "FairPrimaryGenerator.h"
17+
18+
namespace o2
19+
{
20+
namespace eventgen
21+
{
22+
23+
/**
24+
** custom primary generator in order to be able to deal with
25+
** specific O2 matters, like initialisation, generation, ...
26+
**/
27+
28+
class PrimaryGenerator : public FairPrimaryGenerator
29+
{
30+
31+
public:
32+
/** default constructor **/
33+
PrimaryGenerator() = default;
34+
/** destructor **/
35+
virtual ~PrimaryGenerator() = default;
36+
37+
/** initialize the generator **/
38+
virtual Bool_t Init() override;
39+
40+
protected:
41+
/** copy constructor **/
42+
PrimaryGenerator(const PrimaryGenerator&) = default;
43+
/** operator= **/
44+
PrimaryGenerator& operator=(const PrimaryGenerator&) = default;
45+
46+
/** set interaction diamond position **/
47+
void setInteractionDiamond(const Double_t* xyz, const Double_t* sigmaxyz);
48+
49+
ClassDefOverride(PrimaryGenerator, 1);
50+
51+
}; /** class PrimaryGenerator **/
52+
53+
/*****************************************************************/
54+
/*****************************************************************/
55+
56+
} /* namespace eventgen */
57+
} /* namespace o2 */
58+
59+
#endif /* ALICEO2_EVENTGEN_PRIMARYGENERATOR_H_ */

Generators/src/GeneratorsLinkDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
#pragma link C++ class o2::eventgen::GeneratorFromFile+;
3232
#pragma link C++ class o2::eventgen::GeneratorFactory+;
3333
#pragma link C++ class o2::PDG + ;
34+
#pragma link C++ class o2::eventgen::PrimaryGenerator + ;
35+
#pragma link C++ class o2::eventgen::InteractionDiamondParam + ;
36+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::InteractionDiamondParam> + ;
3437

3538
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 R+Preghenella - October 2018
12+
13+
#include "Generators/InteractionDiamondParam.h"
14+
O2ParamImpl(o2::eventgen::InteractionDiamondParam);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 R+Preghenella - June 2017
12+
13+
#include "Generators/PrimaryGenerator.h"
14+
#include "Generators/InteractionDiamondParam.h"
15+
#include "FairLogger.h"
16+
17+
namespace o2
18+
{
19+
namespace eventgen
20+
{
21+
22+
/*****************************************************************/
23+
24+
Bool_t PrimaryGenerator::Init()
25+
{
26+
/** init **/
27+
28+
/** retrieve and set interaction diamond **/
29+
auto diamond = InteractionDiamondParam::Instance();
30+
setInteractionDiamond(diamond.position, diamond.width);
31+
32+
/** base class init **/
33+
return FairPrimaryGenerator::Init();
34+
}
35+
36+
/*****************************************************************/
37+
38+
void PrimaryGenerator::setInteractionDiamond(const Double_t* xyz, const Double_t* sigmaxyz)
39+
{
40+
/** set interaction diamond **/
41+
42+
LOG(INFO) << "Setting interaction diamond: position = {"
43+
<< xyz[0] << "," << xyz[1] << "," << xyz[2] << "} cm";
44+
LOG(INFO) << "Setting interaction diamond: width = {"
45+
<< sigmaxyz[0] << "," << sigmaxyz[1] << "," << sigmaxyz[2] << "} cm";
46+
SetBeam(xyz[0], xyz[1], sigmaxyz[0], sigmaxyz[1]);
47+
SetTarget(xyz[2], sigmaxyz[2]);
48+
SmearVertexXY(false);
49+
SmearVertexZ(false);
50+
SmearGausVertexXY(true);
51+
SmearGausVertexZ(true);
52+
}
53+
54+
/*****************************************************************/
55+
/*****************************************************************/
56+
57+
} /* namespace eventgen */
58+
} /* namespace o2 */
59+
60+
ClassImp(o2::eventgen::PrimaryGenerator)

cmake/O2Dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ o2_define_bucket(
11731173
INCLUDE_DIRECTORIES
11741174
${ROOT_INCLUDE_DIR}
11751175
${FAIRROOT_INCLUDE_DIR}
1176+
${CMAKE_SOURCE_DIR}/Common/SimConfig/include
11761177
)
11771178

11781179
o2_define_bucket(

macro/o2sim.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "build_geometry.C"
1212
#if !defined(__CLING__) || defined(__ROOTCLING__)
13-
#include <FairPrimaryGenerator.h>
13+
#include <Generators/PrimaryGenerator.h>
1414
#include <Generators/GeneratorFactory.h>
1515
#include <Generators/PDG.h>
1616
#include <SimConfig/SimConfig.h>
@@ -68,7 +68,7 @@ FairRunSim* o2sim_init(bool asservice)
6868
build_geometry(run);
6969

7070
// setup generator
71-
auto primGen = new FairPrimaryGenerator();
71+
auto primGen = new o2::eventgen::PrimaryGenerator();
7272
if (!asservice) {
7373
o2::eventgen::GeneratorFactory::setPrimaryGenerator(confref, primGen);
7474
}

0 commit comments

Comments
 (0)