Skip to content

Commit 7fe123e

Browse files
nstrangmNicolas Strangmann
andauthored
[PWGEM/PhotonMeson] Add task for on-the-fly MC generator studies (#11217)
Co-authored-by: Nicolas Strangmann <nicolas.strangmann@.cern.ch>
1 parent 7f231fd commit 7fe123e

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

PWGEM/PhotonMeson/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ o2physics_add_dpl_workflow(emc-bc-wise-pi0
2929
PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::AnalysisCore
3030
COMPONENT_NAME Analysis)
3131

32+
o2physics_add_dpl_workflow(mc-generator-studies
33+
SOURCES mcGeneratorStudies.cxx
34+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
35+
COMPONENT_NAME Analysis)
36+
3237
o2physics_add_dpl_workflow(pcm-qc
3338
SOURCES pcmQC.cxx
3439
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2019-2024 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
/// \file mcGeneratorStudies.cxx
13+
///
14+
/// \brief Task that produces the generated pT spectrum of a given particle for MC studies based on on the fly MC simulations
15+
///
16+
/// \author Nicolas Strangmann (nicolas.strangmann@cern.ch) - Goethe University Frankfurt
17+
///
18+
19+
#include "Framework/runDataProcessing.h"
20+
#include "Framework/AnalysisTask.h"
21+
#include "Framework/AnalysisDataModel.h"
22+
#include "Framework/ASoA.h"
23+
#include "Framework/HistogramRegistry.h"
24+
25+
#include "TDatabasePDG.h"
26+
27+
using namespace o2;
28+
using namespace o2::framework;
29+
30+
struct MCGeneratorStudies {
31+
HistogramRegistry mHistManager{"MCGeneratorStudyHistograms"};
32+
Configurable<int> cfgSelectedParticleCode{"cfgSelectedParticleCode", 111, "PDG code of the particle to be investigated"};
33+
Configurable<float> cfgMaxZVertex{"cfgMaxZVertex", 10, "Maximum absolute z-vertex distance (cm)"};
34+
expressions::Filter zVertexFilter = aod::mccollision::posZ < cfgMaxZVertex && aod::mccollision::posZ > -cfgMaxZVertex;
35+
36+
void init(InitContext const&) { mHistManager.add("YieldVsNParticles", "pT of selected particles in all MC collisions vs number of all generated particles in event;#bf{#it{p}_{T} (GeV/#it{c})};#bf{#it{N} (Multiplicity)};#bf{#it{N}}", HistType::kTH2F, {{200, 0, 20}, {1000, 0, 10000}}); }
37+
38+
void process(soa::Filtered<aod::McCollisions>::iterator const&, aod::McParticles const& mcParticles)
39+
{
40+
int nParticles = mcParticles.size();
41+
for (auto& mcParticle : mcParticles) {
42+
if (mcParticle.pdgCode() == cfgSelectedParticleCode && std::abs(mcParticle.y()) < 0.8f)
43+
mHistManager.fill(HIST("YieldVsNParticles"), mcParticle.pt(), nParticles);
44+
}
45+
}
46+
};
47+
48+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<MCGeneratorStudies>(cfgc, TaskName{"mc-generator-studies"})}; }

0 commit comments

Comments
 (0)