Skip to content

Commit f6643be

Browse files
New task for dndeta MFT standalone (#500)
1 parent 454b053 commit f6643be

3 files changed

Lines changed: 178 additions & 102 deletions

File tree

PWGMM/Tasks/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ o2physics_add_dpl_workflow(dndeta
1919
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
2020
COMPONENT_NAME Analysis)
2121

22-
o2physics_add_dpl_workflow(analyse-mft-tracks
23-
SOURCES analyse-mft-tracks.cxx
22+
o2physics_add_dpl_workflow(dndeta-mft
23+
SOURCES dndeta-mft.cxx
2424
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
2525
COMPONENT_NAME Analysis)
2626

PWGMM/Tasks/analyse-mft-tracks.cxx

Lines changed: 0 additions & 100 deletions
This file was deleted.

PWGMM/Tasks/dndeta-mft.cxx

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// Copyright 2019-2020 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+
#include <cmath>
13+
#include "Framework/Configurable.h"
14+
#include "Framework/AnalysisTask.h"
15+
#include "Framework/AnalysisDataModel.h"
16+
#include "Framework/ASoAHelpers.h"
17+
#include "Framework/RuntimeError.h"
18+
#include "Framework/runDataProcessing.h"
19+
20+
#include "ReconstructionDataFormats/GlobalTrackID.h"
21+
#include "Common/DataModel/Multiplicity.h"
22+
#include "Common/DataModel/EventSelection.h"
23+
#include "Common/DataModel/Centrality.h"
24+
#include "Common/DataModel/TrackSelectionTables.h"
25+
#include "CommonConstants/MathConstants.h"
26+
#include "TDatabasePDG.h"
27+
#include "MathUtils/Utils.h"
28+
29+
using namespace o2;
30+
using namespace o2::framework;
31+
using namespace o2::framework::expressions;
32+
33+
struct PseudorapidityDensityMFT {
34+
Service<TDatabasePDG> pdg;
35+
36+
Configurable<bool> useEvSel{"useEvSel", true, "use event selection"};
37+
38+
HistogramRegistry registry{
39+
"registry",
40+
{
41+
{"EventsNtrkZvtx", "; N_{trk}; Z_{vtx}; events", {HistType::kTH2F, {{301, -0.5, 300.5}, {201, -20.1, 20.1}}}}, //
42+
{"TracksEtaZvtx", "; #eta; Z_{vtx}; tracks", {HistType::kTH2F, {{35, -4.5, -1.}, {201, -20.1, 20.1}}}}, //
43+
{"TracksPhiEta", "; #varphi; #eta; tracks", {HistType::kTH2F, {{600, 0, 2 * M_PI}, {35, -4.5, -1.}}}}, //
44+
{"EventSelection", ";status;events", {HistType::kTH1F, {{7, 0.5, 7.5}}}} //
45+
} //
46+
};
47+
48+
void init(InitContext&)
49+
{
50+
auto hstat = registry.get<TH1>(HIST("EventSelection"));
51+
auto* x = hstat->GetXaxis();
52+
x->SetBinLabel(1, "All");
53+
x->SetBinLabel(2, "Selected");
54+
x->SetBinLabel(3, "Selected INEL>0");
55+
x->SetBinLabel(4, "Rejected");
56+
x->SetBinLabel(5, "Good BCs");
57+
x->SetBinLabel(6, "BCs with collisions");
58+
x->SetBinLabel(7, "BCs with pile-up/splitting");
59+
60+
if (doprocessGen) {
61+
registry.add({"EventsNtrkZvtxGen", "; N_{trk}; Z_{vtx}; events", {HistType::kTH2F, {{301, -0.5, 300.5}, {201, -20.1, 20.1}}}});
62+
registry.add({"TracksEtaZvtxGen", "; #eta; Z_{vtx}; tracks", {HistType::kTH2F, {{21, -2.1, 2.1}, {201, -20.1, 20.1}}}});
63+
registry.add({"TracksPhiEtaGen", "; #varphi; #eta; tracks", {HistType::kTH2F, {{600, 0, 2 * M_PI}, {21, -2.1, 2.1}}}});
64+
registry.add({"EventEfficiency", "; status; events", {HistType::kTH1F, {{5, 0.5, 5.5}}}});
65+
registry.add({"NotFoundEventZvtx", " ; Z_{vtx}", {HistType::kTH1F, {{201, -20.1, 20.1}}}});
66+
67+
auto heff = registry.get<TH1>(HIST("EventEfficiency"));
68+
x = heff->GetXaxis();
69+
x->SetBinLabel(1, "Generated");
70+
x->SetBinLabel(2, "Generated INEL>0");
71+
x->SetBinLabel(3, "Reconstructed");
72+
x->SetBinLabel(4, "Selected");
73+
x->SetBinLabel(5, "Selected INEL>0");
74+
}
75+
}
76+
77+
using FullBCs = soa::Join<aod::BCsWithTimestamps, aod::BcSels>;
78+
void processTagging(FullBCs const& bcs, soa::Join<aod::Collisions, aod::EvSels> const& collisions)
79+
{
80+
std::vector<typename std::decay_t<decltype(collisions)>::iterator> cols;
81+
for (auto& bc : bcs) {
82+
if (!useEvSel || (useEvSel && ((bc.selection()[aod::EventSelectionFlags::kIsBBT0A] & bc.selection()[aod::EventSelectionFlags::kIsBBT0C]) != 0))) {
83+
registry.fill(HIST("EventSelection"), 5.);
84+
cols.clear();
85+
for (auto& collision : collisions) {
86+
if (collision.has_foundBC()) {
87+
if (collision.foundBCId() == bc.globalIndex()) {
88+
cols.emplace_back(collision);
89+
}
90+
} else if (collision.bcId() == bc.globalIndex()) {
91+
cols.emplace_back(collision);
92+
}
93+
}
94+
LOGP(debug, "BC {} has {} collisions", bc.globalBC(), cols.size());
95+
if (!cols.empty()) {
96+
registry.fill(HIST("EventSelection"), 6.);
97+
if (cols.size() > 1) {
98+
registry.fill(HIST("EventSelection"), 7.);
99+
}
100+
}
101+
}
102+
}
103+
}
104+
105+
PROCESS_SWITCH(PseudorapidityDensityMFT, processTagging, "Collect event sample stats", true);
106+
107+
void process(soa::Join<aod::Collisions, aod::EvSels>::iterator const& collision, aod::MFTTracks const& tracks)
108+
{
109+
registry.fill(HIST("EventSelection"), 1.);
110+
if (!useEvSel || (useEvSel && collision.sel8())) {
111+
registry.fill(HIST("EventSelection"), 2.);
112+
auto z = collision.posZ();
113+
114+
auto groupedTracks = tracks.sliceBy(o2::aod::fwdtrack::collisionId, collision.globalIndex());
115+
116+
registry.fill(HIST("EventsNtrkZvtx"), groupedTracks.size(), z);
117+
for (auto& track : tracks) {
118+
registry.fill(HIST("TracksEtaZvtx"), track.eta(), z);
119+
float phi = track.phi();
120+
o2::math_utils::bringTo02Pi(phi);
121+
registry.fill(HIST("TracksPhiEta"), phi, track.eta());
122+
}
123+
} else {
124+
registry.fill(HIST("EventSelection"), 4.);
125+
}
126+
}
127+
128+
using Particles = aod::McParticles;
129+
expressions::Filter primaries = (aod::mcparticle::flags & (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary) == (uint8_t)o2::aod::mcparticle::enums::PhysicalPrimary;
130+
131+
void processGen(aod::McCollisions::iterator const& mcCollision, o2::soa::SmallGroups<soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels>> const& collisions, soa::Filtered<Particles> const& particles, aod::MFTTracks const& tracks)
132+
{
133+
134+
registry.fill(HIST("EventEfficiency"), 1.);
135+
136+
bool atLeastOne = false;
137+
138+
LOGP(debug, "MC col {} has {} reco cols", mcCollision.globalIndex(), collisions.size());
139+
for (auto& collision : collisions) {
140+
registry.fill(HIST("EventEfficiency"), 3.);
141+
if (!useEvSel || (useEvSel && collision.sel8())) {
142+
atLeastOne = true;
143+
auto groupedTracks = tracks.sliceBy(o2::aod::fwdtrack::collisionId, collision.globalIndex());
144+
145+
registry.fill(HIST("EventEfficiency"), 4.);
146+
147+
registry.fill(HIST("EventsNtrkZvtxGen"), groupedTracks.size(), collision.posZ());
148+
}
149+
}
150+
if (collisions.size() == 0) {
151+
registry.fill(HIST("NotFoundEventZvtx"), mcCollision.posZ());
152+
}
153+
for (auto& particle : particles) {
154+
auto p = pdg->GetParticle(particle.pdgCode());
155+
auto charge = 0;
156+
if (p != nullptr) {
157+
charge = (int)p->Charge();
158+
}
159+
if (charge != 0) {
160+
161+
if (atLeastOne) {
162+
registry.fill(HIST("TracksEtaZvtxGen"), particle.eta(), mcCollision.posZ());
163+
}
164+
registry.fill(HIST("TracksPhiEtaGen"), particle.phi(), particle.eta());
165+
}
166+
}
167+
}
168+
169+
PROCESS_SWITCH(PseudorapidityDensityMFT, processGen, "Process generator-level info", false);
170+
};
171+
172+
WorkflowSpec
173+
defineDataProcessing(ConfigContext const& cfgc)
174+
{
175+
return WorkflowSpec{adaptAnalysisTask<PseudorapidityDensityMFT>(cfgc)};
176+
}

0 commit comments

Comments
 (0)