Skip to content

Commit 5defaad

Browse files
committed
Group refitted V0s per PV, add extra info
1 parent aa33d26 commit 5defaad

File tree

5 files changed

+161
-59
lines changed

5 files changed

+161
-59
lines changed

Detectors/GlobalTrackingWorkflow/study/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ o2_add_library(GlobalTrackingStudy
1919
src/TPCDataFilter.cxx
2020
src/ITSOffsStudy.cxx
2121
src/DumpTracks.cxx
22+
src/V0Ext.cxx
2223
PUBLIC_LINK_LIBRARIES O2::GlobalTracking
2324
O2::GlobalTrackingWorkflowReaders
2425
O2::GlobalTrackingWorkflowHelpers
@@ -27,6 +28,11 @@ o2_add_library(GlobalTrackingStudy
2728
O2::TPCWorkflow
2829
O2::SimulationDataFormat)
2930

31+
o2_target_root_dictionary(
32+
GlobalTrackingStudy
33+
HEADERS include/GlobalTrackingStudy/V0Ext.h
34+
)
35+
3036
o2_add_executable(study-workflow
3137
COMPONENT_NAME sv
3238
SOURCES src/sv-study-workflow.cxx
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
// class for extended V0 info (for debugging)
13+
14+
#ifndef ALICEO2_V0EXT_H
15+
#define ALICEO2_V0EXT_H
16+
17+
#include "ReconstructionDataFormats/V0.h"
18+
19+
namespace o2
20+
{
21+
namespace dataformats
22+
{
23+
24+
struct ProngInfoExt {
25+
o2::track::TrackParCov trackTPC;
26+
int nClTPC = 0;
27+
int nClITS = 0;
28+
int pattITS = 0;
29+
float chi2ITSTPC = 0.f;
30+
ClassDefNV(ProngInfoExt, 1);
31+
};
32+
33+
struct V0Ext {
34+
V0 v0;
35+
V0Index v0ID;
36+
std::array<ProngInfoExt, 2> prInfo{};
37+
const ProngInfoExt& getPrInfo(int i) const { return prInfo[i]; }
38+
ClassDefNV(V0Ext, 1);
39+
};
40+
41+
} // namespace dataformats
42+
} // namespace o2
43+
44+
#endif

Detectors/GlobalTrackingWorkflow/study/src/GlobalTrackingStudyLinkDef.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
#pragma link off all classes;
1616
#pragma link off all functions;
1717

18+
#pragma link C++ class o2::dataformats::ProngInfoExt + ;
19+
#pragma link C++ class o2::dataformats::V0Ext + ;
20+
#pragma link C++ class std::vector < o2::dataformats::ProngInfoExt> + ;
21+
#pragma link C++ class std::vector < o2::dataformats::V0Ext> + ;
22+
1823
#endif

Detectors/GlobalTrackingWorkflow/study/src/SVStudy.cxx

Lines changed: 92 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "Steer/MCKinematicsReader.h"
4343
#include "DCAFitter/DCAFitterN.h"
4444
#include "MathUtils/fit.h"
45+
#include "GlobalTrackingStudy/V0Ext.h"
4546

4647
namespace o2::svstudy
4748
{
@@ -70,6 +71,7 @@ class SVStudySpec : public Task
7071
void endOfStream(EndOfStreamContext& ec) final;
7172
void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) final;
7273
void process(o2::globaltracking::RecoContainer& recoData);
74+
o2::dataformats::V0Ext processV0(int iv, o2::globaltracking::RecoContainer& recoData);
7375

7476
private:
7577
void updateTimeDependentParams(ProcessingContext& pc);
@@ -78,7 +80,7 @@ class SVStudySpec : public Task
7880
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
7981
bool mUseMC{false}; ///< MC flag
8082
std::unique_ptr<o2::utils::TreeStreamRedirector> mDBGOut;
81-
bool mSelK0 = false;
83+
float mSelK0 = -1;
8284
bool mRefit = false;
8385
float mMaxEta = 0.8;
8486
float mBz = 0;
@@ -92,7 +94,7 @@ void SVStudySpec::init(InitContext& ic)
9294
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
9395
mDBGOut = std::make_unique<o2::utils::TreeStreamRedirector>("svStudy.root", "recreate");
9496
mRefit = ic.options().get<bool>("refit");
95-
mSelK0 = ic.options().get<bool>("sel-k0");
97+
mSelK0 = ic.options().get<float>("sel-k0");
9698
mMaxEta = ic.options().get<float>("max-eta");
9799
}
98100

@@ -132,77 +134,108 @@ void SVStudySpec::updateTimeDependentParams(ProcessingContext& pc)
132134
mFitterV0.setBz(mBz);
133135
}
134136

135-
void SVStudySpec::process(o2::globaltracking::RecoContainer& recoData)
137+
o2::dataformats::V0Ext SVStudySpec::processV0(int iv, o2::globaltracking::RecoContainer& recoData)
136138
{
139+
o2::dataformats::V0Ext v0ext;
140+
auto invalidate = [&v0ext]() { v0ext.v0ID.setVertexID(-1); };
141+
137142
auto v0s = recoData.getV0s();
138143
auto v0IDs = recoData.getV0sIdx();
139-
bool refit = mRefit || (v0s.size() < v0IDs.size());
140-
int nv0 = v0IDs.size();
141-
o2::dataformats::V0 v0ref;
142-
o2::track::TrackParCov dummyTr{};
143-
const o2::track::TrackParCov* tpcTracks[2] = {&dummyTr, &dummyTr};
144-
int nclTPC[2] = {0, 0}, nclITS[2] = {0, 0}, itsPatt[2] = {0, 0};
145-
float chi2ITSTPC[2] = {-1., -1.};
146144
static int tfID = 0;
147145

148-
for (int iv = 0; iv < nv0; iv++) {
149-
const auto& v0id = v0IDs[iv];
150-
if (mRefit && !refitV0(v0id, v0ref, recoData)) {
151-
continue;
152-
}
153-
const auto& v0 = mRefit ? v0ref : v0s[iv];
154-
if (mMaxEta < std::abs(v0.getEta())) {
155-
continue;
156-
}
157-
if (mSelK0 && std::abs(std::sqrt(v0.calcMass2AsK0()) - 0.497) > 0.1) {
158-
continue;
146+
const auto& v0id = v0IDs[iv];
147+
if (mRefit && !refitV0(v0id, v0ext.v0, recoData)) {
148+
invalidate();
149+
return v0ext;
150+
}
151+
const auto& v0sel = mRefit ? v0ext.v0 : v0s[iv];
152+
if (mMaxEta < std::abs(v0sel.getEta())) {
153+
invalidate();
154+
return v0ext;
155+
}
156+
if (mSelK0 > 0 && std::abs(std::sqrt(v0sel.calcMass2AsK0()) - 0.497) > mSelK0) {
157+
invalidate();
158+
return v0ext;
159+
}
160+
v0ext.v0ID = v0id;
161+
for (int ip = 0; ip < 2; ip++) {
162+
auto& prInfo = v0ext.prInfo[ip];
163+
auto gid = v0ext.v0ID.getProngID(ip);
164+
auto gidset = recoData.getSingleDetectorRefs(gid);
165+
// get TPC tracks, if any
166+
if (gidset[GTrackID::TPC].isSourceSet()) {
167+
const auto& tpcTr = recoData.getTPCTrack(gidset[GTrackID::TPC]);
168+
prInfo.trackTPC = tpcTr;
169+
prInfo.nClTPC = tpcTr.getNClusters();
159170
}
160-
for (int ip = 0; ip < 2; ip++) {
161-
auto gid = v0id.getProngID(ip);
162-
auto gidset = recoData.getSingleDetectorRefs(gid);
163-
// get TPC tracks, if any
164-
tpcTracks[ip] = &dummyTr;
165-
nclTPC[ip] = 0;
166-
if (gidset[GTrackID::TPC].isSourceSet()) {
167-
const auto& tpcTr = recoData.getTPCTrack(gidset[GTrackID::TPC]);
168-
tpcTracks[ip] = &tpcTr;
169-
nclTPC[ip] = tpcTr.getNClusters();
170-
}
171-
// get ITS tracks, if any
172-
nclITS[ip] = itsPatt[ip] = 0;
173-
if (gid.includesDet(DetID::ITS)) {
174-
auto gidITS = recoData.getITSContributorGID(gid);
175-
if (gidset[GTrackID::ITS].isSourceSet()) {
176-
const auto& itsTr = recoData.getITSTrack(recoData.getITSContributorGID(gid));
177-
nclITS[ip] = itsTr.getNClusters();
178-
for (int il = 0; il < 7; il++) {
179-
if (itsTr.hasHitOnLayer(il)) {
180-
itsPatt[ip] |= 0x1 << il;
181-
}
171+
// get ITS tracks, if any
172+
if (gid.includesDet(DetID::ITS)) {
173+
auto gidITS = recoData.getITSContributorGID(gid);
174+
if (gidset[GTrackID::ITS].isSourceSet()) {
175+
const auto& itsTr = recoData.getITSTrack(recoData.getITSContributorGID(gid));
176+
prInfo.nClITS = itsTr.getNClusters();
177+
for (int il = 0; il < 7; il++) {
178+
if (itsTr.hasHitOnLayer(il)) {
179+
prInfo.pattITS |= 0x1 << il;
182180
}
183-
} else {
184-
const auto& itsTrf = recoData.getITSABRefs()[gidset[GTrackID::ITSAB]];
185-
nclITS[ip] = itsTrf.getNClusters();
186-
for (int il = 0; il < 7; il++) {
187-
if (itsTrf.hasHitOnLayer(il)) {
188-
itsPatt[ip] |= 0x1 << il;
189-
}
181+
}
182+
} else {
183+
const auto& itsTrf = recoData.getITSABRefs()[gidset[GTrackID::ITSAB]];
184+
prInfo.nClITS = itsTrf.getNClusters();
185+
for (int il = 0; il < 7; il++) {
186+
if (itsTrf.hasHitOnLayer(il)) {
187+
prInfo.pattITS |= 0x1 << il;
190188
}
191189
}
190+
prInfo.pattITS |= 0x1 << 31; // flag AB
192191
}
193192
if (gidset[GTrackID::ITSTPC].isSourceSet()) {
194193
auto mtc = recoData.getTPCITSTrack(gidset[GTrackID::ITSTPC]);
195-
chi2ITSTPC[ip] = mtc.getChi2Match();
194+
prInfo.chi2ITSTPC = mtc.getChi2Match();
195+
}
196+
}
197+
}
198+
return v0ext;
199+
}
200+
201+
void SVStudySpec::process(o2::globaltracking::RecoContainer& recoData)
202+
{
203+
auto v0IDs = recoData.getV0sIdx();
204+
auto nv0 = v0IDs.size();
205+
if (nv0 > recoData.getV0s().size()) {
206+
mRefit = true;
207+
}
208+
std::map<int, std::vector<int>> pv2sv;
209+
static int tfID = 0;
210+
for (int iv = 0; iv < nv0; iv++) {
211+
const auto v0id = v0IDs[iv];
212+
pv2sv[v0id.getVertexID()].push_back(iv);
213+
}
214+
std::vector<o2::dataformats::V0Ext> v0extVec;
215+
for (auto it : pv2sv) {
216+
int pvID = it.first;
217+
auto& vv = it.second;
218+
if (pvID < 0 || vv.size() == 0) {
219+
continue;
220+
}
221+
v0extVec.clear();
222+
for (int iv0 : vv) {
223+
auto v0ext = processV0(iv0, recoData);
224+
if (v0ext.v0ID.getVertexID() < 0) {
225+
continue;
196226
}
227+
v0extVec.push_back(v0ext);
228+
}
229+
if (v0extVec.size()) {
230+
const auto& pv = recoData.getPrimaryVertex(pvID);
231+
(*mDBGOut) << "v0"
232+
<< "orbit=" << recoData.startIR.orbit << "tfID=" << tfID
233+
<< "v0Ext=" << v0extVec
234+
<< "pv=" << pv
235+
<< "\n";
197236
}
198-
(*mDBGOut) << "tfinfo"
199-
<< "orbit=" << recoData.startIR.orbit << "tfID=" << tfID << "\n";
200-
(*mDBGOut) << "v0s"
201-
<< "v0=" << v0 << "v0ID=" << v0id << "tpc0=" << *tpcTracks[0] << "tpc1=" << *tpcTracks[1]
202-
<< "nclTPC0=" << nclTPC[0] << "nclTPC1=" << nclTPC[1] << "nclITS0=" << nclITS[0] << "nclITS1=" << nclITS[1] << "itsPatt0=" << itsPatt[0] << "itsPatt1=" << itsPatt[1]
203-
<< "chi2ITSTPC0=" << chi2ITSTPC[0] << "chi2ITSTPC1=" << chi2ITSTPC[1] << "\n";
237+
tfID++;
204238
}
205-
tfID++;
206239
}
207240

208241
bool SVStudySpec::refitV0(const V0ID& id, o2::dataformats::V0& v0, o2::globaltracking::RecoContainer& recoData)
@@ -286,7 +319,7 @@ DataProcessorSpec getSVStudySpec(GTrackID::mask_t srcTracks, bool useMC)
286319
AlgorithmSpec{adaptFromTask<SVStudySpec>(dataRequest, ggRequest, srcTracks, useMC)},
287320
Options{
288321
{"refit", VariantType::Bool, false, {"refit SVertices"}},
289-
{"sel-k0", VariantType::Bool, false, {"select K0s only"}},
322+
{"sel-k0", VariantType::Float, -1.f, {"If positive, select K0s with this mass margin"}},
290323
{"max-eta", VariantType::Float, 1.2f, {"Cut on track eta"}},
291324
}};
292325
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
// class for extended V0 info (for debugging)
13+
14+
#include "GlobalTrackingStudy/V0Ext.h"

0 commit comments

Comments
 (0)