-
Notifications
You must be signed in to change notification settings - Fork 644
Expand file tree
/
Copy pathjetMatchingMC.h
More file actions
108 lines (89 loc) · 6.23 KB
/
jetMatchingMC.h
File metadata and controls
108 lines (89 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file jetmatchingmc.cxx
/// \brief matching detector level and generator level jets
///
/// \author Raymond Ehlers <raymond.ehlers@cern.ch>, ORNL
/// \author Jochen Klein <jochen.klein@cern.ch>
/// \author Aimeric Lanodu <aimeric.landou@cern.ch>
/// \author Nima Zardoshti <nima.zardoshti@cern.ch>
#ifndef PWGJE_TABLEPRODUCER_MATCHING_JETMATCHINGMC_H_
#define PWGJE_TABLEPRODUCER_MATCHING_JETMATCHINGMC_H_
#include "PWGJE/Core/JetMatchingUtilities.h"
#include "PWGJE/DataModel/Jet.h"
#include "PWGJE/DataModel/JetReducedData.h"
#include <Framework/ASoA.h>
#include <Framework/AnalysisHelpers.h>
#include <Framework/Configurable.h>
#include <Framework/InitContext.h>
#include <Framework/Logger.h>
#include <vector>
template <typename JetsBase, typename JetsTag, typename JetsBasetoTagMatchingTable, typename JetsTagtoBaseMatchingTable, typename CandidatesBase, typename CandidatesTag, typename ClustersBase>
struct JetMatchingMc {
o2::framework::Configurable<bool> doMatchingGeo{"doMatchingGeo", true, "Enable geometric matching"};
o2::framework::Configurable<bool> doMatchingPt{"doMatchingPt", true, "Enable pt matching"};
o2::framework::Configurable<bool> doMatchingHf{"doMatchingHf", false, "Enable HF matching"};
o2::framework::Configurable<std::vector<double>> jetRadiiForMatchingDistance{"jetRadiiForMatchingDistance", {0.2, 0.3, 0.4, 0.5, 0.6}, "Jet R values for per-R matching distance"};
o2::framework::Configurable<std::vector<double>> maxMatchingDistancePerJetR{"maxMatchingDistancePerJetR", {0.12, 0.18, 0.24, 0.30, 0.36}, "Max matching distance (0.6*R, see ALICE-AN-852) for each R in jetRadiiForMatchingDistance"};
o2::framework::Configurable<float> minPtFraction{"minPtFraction", 0.5f, "Minimum pt fraction for pt matching"};
o2::framework::Produces<JetsBasetoTagMatchingTable> jetsBasetoTagMatchingTable;
o2::framework::Produces<JetsTagtoBaseMatchingTable> jetsTagtoBaseMatchingTable;
// preslicing jet collections, only for Mc-based collection
static constexpr bool jetsBaseIsMc = o2::soa::relatedByIndex<o2::aod::JetMcCollisions, JetsBase>();
static constexpr bool jetsTagIsMc = o2::soa::relatedByIndex<o2::aod::JetMcCollisions, JetsTag>();
o2::framework::Preslice<JetsBase> baseJetsPerCollision = jetsBaseIsMc ? o2::aod::jet::mcCollisionId : o2::aod::jet::collisionId;
o2::framework::Preslice<JetsTag> tagJetsPerCollision = jetsTagIsMc ? o2::aod::jet::mcCollisionId : o2::aod::jet::collisionId;
o2::framework::PresliceUnsorted<o2::aod::JetCollisionsMCD> CollisionsPerMcCollision = o2::aod::jmccollisionlb::mcCollisionId;
void init(o2::framework::InitContext const&)
{
if (jetRadiiForMatchingDistance->empty() || maxMatchingDistancePerJetR->empty()) {
LOGP(fatal, "jetRadiiForMatchingDistance and maxMatchingDistancePerJetR must not be empty");
}
if (jetRadiiForMatchingDistance->size() != maxMatchingDistancePerJetR->size()) {
LOGP(fatal, "jetRadiiForMatchingDistance and maxMatchingDistancePerJetR must have the same number of entries");
}
}
void processJets(o2::aod::JetMcCollisions const& mcCollisions, o2::aod::JetCollisionsMCD const& collisions,
JetsBase const& jetsBase, JetsTag const& jetsTag,
o2::aod::JetTracksMCD const& tracks,
ClustersBase const& clusters,
o2::aod::JetParticles const& particles,
CandidatesBase const& candidatesBase,
CandidatesTag const& candidatesTag)
{
// initialise objects used to store the matching index arrays (array in case a mcCollision is split) before filling the matching tables
std::vector<std::vector<int>> jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF;
std::vector<std::vector<int>> jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF;
// waiting for framework fix to make sliced collection of same type as original collection:
jetsBasetoTagMatchingGeo.assign(jetsBase.size(), {});
jetsBasetoTagMatchingPt.assign(jetsBase.size(), {});
jetsBasetoTagMatchingHF.assign(jetsBase.size(), {});
jetsTagtoBaseMatchingGeo.assign(jetsTag.size(), {});
jetsTagtoBaseMatchingPt.assign(jetsTag.size(), {});
jetsTagtoBaseMatchingHF.assign(jetsTag.size(), {});
for (const auto& mcCollision : mcCollisions) {
const auto collisionsPerMcColl = collisions.sliceBy(CollisionsPerMcCollision, mcCollision.globalIndex());
for (const auto& collision : collisionsPerMcColl) {
const auto jetsBasePerColl = jetsBase.sliceBy(baseJetsPerCollision, jetsBaseIsMc ? mcCollision.globalIndex() : collision.globalIndex());
const auto jetsTagPerColl = jetsTag.sliceBy(tagJetsPerCollision, jetsTagIsMc ? mcCollision.globalIndex() : collision.globalIndex());
jetmatchingutilities::doAllMatching<jetsBaseIsMc, jetsTagIsMc>(jetsBasePerColl, jetsTagPerColl, jetsBasetoTagMatchingGeo, jetsBasetoTagMatchingPt, jetsBasetoTagMatchingHF, jetsTagtoBaseMatchingGeo, jetsTagtoBaseMatchingPt, jetsTagtoBaseMatchingHF, candidatesBase, tracks, clusters, candidatesTag, particles, particles, doMatchingGeo, doMatchingHf, doMatchingPt, minPtFraction, jetRadiiForMatchingDistance, maxMatchingDistancePerJetR);
}
}
for (auto i = 0; i < jetsBase.size(); ++i) {
jetsBasetoTagMatchingTable(jetsBasetoTagMatchingGeo[i], jetsBasetoTagMatchingPt[i], jetsBasetoTagMatchingHF[i]); // is (and needs to) be filled in order
}
for (auto i = 0; i < jetsTag.size(); i++) {
jetsTagtoBaseMatchingTable(jetsTagtoBaseMatchingGeo[i], jetsTagtoBaseMatchingPt[i], jetsTagtoBaseMatchingHF[i]); // is (and needs to) be filled in order
}
}
PROCESS_SWITCH(JetMatchingMc, processJets, "Perform jet matching", true);
};
#endif // PWGJE_TABLEPRODUCER_MATCHING_JETMATCHINGMC_H_