Skip to content

Commit c8f257f

Browse files
shahor02chiarazampolli
authored andcommitted
Propagate ITS UPC mode flag to matching AOD BCs and collisions (#13416)
* Use enums to set the UPC/Std ITS mode flags * Propagate ITS UPC mode modified flag to final PVs * Propagate ITS UPC mode flag to matching AOD BCs (cherry picked from commit 7a6665b)
1 parent e735e35 commit c8f257f

File tree

8 files changed

+99
-12
lines changed

8 files changed

+99
-12
lines changed

DataFormats/Detectors/ITSMFT/common/include/DataFormatsITSMFT/ROFRecord.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class ROFRecord
3131
{
3232

3333
public:
34+
enum { VtxStdMode = 0,
35+
VtxUPCMode = 1 };
3436
using EvIdx = o2::dataformats::RangeReference<int, int>;
3537
using BCData = o2::InteractionRecord;
3638
using ROFtype = unsigned int;

DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Vertex : public VertexBase
124124
using ushort = unsigned short;
125125
enum Flags : ushort {
126126
TimeValidated = 0x1 << 0, // Flag that the vertex was validated by external time measurement (e.g. FIT)
127+
UPCMode = 0x1 << 1, // vertex is found in the UPC mode ITS ROF
127128
FlagsMask = 0xffff
128129
};
129130

Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ class AODProducerWorkflowDPL : public Task
624624

625625
std::uint64_t fillBCSlice(int (&slice)[2], double tmin, double tmax, const std::map<uint64_t, int>& bcsMap) const;
626626

627+
std::vector<uint8_t> fillBCFlags(const o2::globaltracking::RecoContainer& data, std::map<uint64_t, int>& bcsMap) const;
628+
627629
// helper for tpc clusters
628630
void countTPCClusters(const o2::globaltracking::RecoContainer& data);
629631

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
17971797
using namespace o2::aodhelpers;
17981798

17991799
auto bcCursor = createTableCursor<o2::aod::BCs>(pc);
1800+
auto bcFlagsCursor = createTableCursor<o2::aod::BCFlags>(pc);
18001801
auto cascadesCursor = createTableCursor<o2::aod::Cascades>(pc);
18011802
auto collisionsCursor = createTableCursor<o2::aod::Collisions>(pc);
18021803
auto decay3BodyCursor = createTableCursor<o2::aod::Decay3Bodys>(pc);
@@ -2220,6 +2221,13 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
22202221

22212222
bcToClassMask.clear();
22222223

2224+
// filling BC flags table:
2225+
auto bcFlags = fillBCFlags(recoData, bcsMap);
2226+
bcFlagsCursor.reserve(bcFlags.size());
2227+
for (auto f : bcFlags) {
2228+
bcFlagsCursor(f);
2229+
}
2230+
22232231
// fill cpvcluster table
22242232
if (mInputSources[GIndex::CPV]) {
22252233
float posX, posZ;
@@ -2884,6 +2892,36 @@ std::uint64_t AODProducerWorkflowDPL::fillBCSlice(int (&slice)[2], double tmin,
28842892
return bcOfTimeRef;
28852893
}
28862894

2895+
std::vector<uint8_t> AODProducerWorkflowDPL::fillBCFlags(const o2::globaltracking::RecoContainer& data, std::map<uint64_t, int>& bcsMap) const
2896+
{
2897+
std::vector<uint8_t> flags(bcsMap.size());
2898+
2899+
// flag BCs belonging to UPC mode ITS ROFs
2900+
auto bcIt = bcsMap.begin();
2901+
auto itsrofs = data.getITSTracksROFRecords();
2902+
auto lROF = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance().roFrameLengthInBC;
2903+
auto bROF = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance().roFrameBiasInBC;
2904+
for (auto& rof : itsrofs) {
2905+
if (!rof.getFlag(o2::itsmft::ROFRecord::VtxUPCMode)) {
2906+
continue;
2907+
}
2908+
uint64_t globalBC0 = rof.getBCData().toLong() + bROF, globalBC1 = globalBC0 + lROF - 1;
2909+
// BCs are sorted, iterate until the start of ROF
2910+
while (bcIt != bcsMap.end()) {
2911+
if (bcIt->first < globalBC0) {
2912+
++bcIt;
2913+
continue;
2914+
}
2915+
if (bcIt->first > globalBC1) {
2916+
break;
2917+
}
2918+
flags[bcIt->second] |= o2::aod::bc::ITSUPCMode;
2919+
++bcIt;
2920+
}
2921+
}
2922+
return flags;
2923+
}
2924+
28872925
void AODProducerWorkflowDPL::endOfStream(EndOfStreamContext& /*ec*/)
28882926
{
28892927
LOGF(info, "aod producer dpl total timing: Cpu: %.3e Real: %.3e s in %d slots",
@@ -2945,6 +2983,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
29452983

29462984
std::vector<OutputSpec> outputs{
29472985
OutputForTable<BCs>::spec(),
2986+
OutputForTable<BCFlags>::spec(),
29482987
OutputForTable<Cascades>::spec(),
29492988
OutputForTable<Collisions>::spec(),
29502989
OutputForTable<Decay3Bodys>::spec(),

Detectors/GlobalTrackingWorkflow/src/PrimaryVertexingSpec.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,34 @@ void PrimaryVertexingSpec::run(ProcessingContext& pc)
150150
}
151151
}
152152
mVertexer.process(tracks, gids, ft0Data, vertices, vertexTrackIDs, v2tRefs, tracksMCInfo, lblVtx);
153+
154+
// flag vertices using UPC ITS mode
155+
auto itsrofs = recoData.getITSTracksROFRecords();
156+
std::vector<bool> itsTrUPC(recoData.getITSTracks().size());
157+
for (auto& rof : itsrofs) {
158+
if (rof.getFlag(o2::itsmft::ROFRecord::VtxUPCMode)) {
159+
for (int i = rof.getFirstEntry(); i < rof.getFirstEntry() + rof.getNEntries(); i++) {
160+
itsTrUPC[i] = true;
161+
}
162+
}
163+
}
164+
int nv = vertices.size();
165+
for (int iv = 0; iv < nv; iv++) {
166+
int idMin = v2tRefs[iv].getFirstEntry(), idMax = idMin + v2tRefs[iv].getEntries();
167+
int nits = 0, nitsUPC = 0;
168+
for (int id = idMin; id < idMax; id++) {
169+
auto gid = recoData.getITSContributorGID(vertexTrackIDs[id]);
170+
if (gid.getSource() == GIndex::ITS) {
171+
nits++;
172+
if (itsTrUPC[gid.getIndex()]) {
173+
nitsUPC++;
174+
}
175+
}
176+
}
177+
if (nitsUPC > nits / 2) {
178+
vertices[iv].setFlags(PVertex::UPCMode);
179+
}
180+
}
153181
}
154182

155183
pc.outputs().snapshot(Output{"GLO", "PVTX", 0}, vertices);

Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,21 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc)
201201
if (mIsMC) {
202202
vMCRecInfo = mTimeFrame->getPrimaryVerticesMCRecInfo(iRof);
203203
}
204-
if (o2::its::TrackerParamConfig::Instance().doUPCIteration && (vtxSpan.size() && vtxSpan[0].getFlags() == 1)) { // at least one vertex in this ROF and it is from second vertex iteration
205-
LOGP(debug, "ROF {} rejected as vertices are from the UPC iteration", iRof);
206-
processUPCMask[iRof] = true;
207-
cutUPCVertex++;
204+
if (o2::its::TrackerParamConfig::Instance().doUPCIteration) {
205+
if (vtxSpan.size()) {
206+
if (vtxSpan[0].isFlagSet(Vertex::UPCMode) == 1) { // at least one vertex in this ROF and it is from second vertex iteration
207+
LOGP(debug, "ROF {} rejected as vertices are from the UPC iteration", iRof);
208+
processUPCMask[iRof] = true;
209+
cutUPCVertex++;
210+
vtxROF.setFlag(o2::itsmft::ROFRecord::VtxUPCMode);
211+
} else { // in all cases except if as standard mode vertex was found, the ROF was processed with UPC settings
212+
vtxROF.setFlag(o2::itsmft::ROFRecord::VtxStdMode);
213+
}
214+
} else {
215+
vtxROF.setFlag(o2::itsmft::ROFRecord::VtxUPCMode);
216+
}
217+
} else {
218+
vtxROF.setFlag(o2::itsmft::ROFRecord::VtxStdMode);
208219
}
209220
vtxROF.setNEntries(vtxSpan.size());
210221
bool selROF = vtxSpan.size() == 0;
@@ -219,11 +230,6 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc)
219230
allVerticesLabels.push_back(vMCRecInfo[iV].first);
220231
allVerticesPurities.push_back(vMCRecInfo[iV].second);
221232
}
222-
if (v.isFlagSet(2)) { // Vertex is reconstructed in a second iteration
223-
vtxROF.setFlag(2); // flag that at least one vertex is from the second iteration
224-
} else {
225-
vtxROF.setFlag(1); // flag that at least one vertex is from the first iteration
226-
}
227233
}
228234
if (processingMask[iRof] && !selROF) { // passed selection in clusters and not in vertex multiplicity
229235
LOGP(info, "ROF {} rejected by the vertex multiplicity selection [{},{}]", iRof, multEstConf.cutMultVtxLow, multEstConf.cutMultVtxHigh);
@@ -292,7 +298,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc)
292298
int offset = -tracksROF.getFirstEntry(); // cluster entry!!!
293299
tracksROF.setFirstEntry(first);
294300
tracksROF.setNEntries(number);
295-
tracksROF.setFlags(number ? vtxROF.getFlags() : 0); // copies 0xffffffff if cosmics
301+
tracksROF.setFlags(vtxROF.getFlags()); // copies 0xffffffff if cosmics
296302
if (processingMask[iROF]) {
297303
irFrames.emplace_back(tracksROF.getBCData(), tracksROF.getBCData() + nBCPerTF - 1).info = tracks.size();
298304
}
@@ -388,4 +394,4 @@ void ITSTrackingInterface::setTraitsFromProvider(VertexerTraits* vertexerTraits,
388394
template void ITSTrackingInterface::run<true>(framework::ProcessingContext& pc);
389395
template void ITSTrackingInterface::run<false>(framework::ProcessingContext& pc);
390396
} // namespace its
391-
} // namespace o2
397+
} // namespace o2

Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ void VertexerTraits::computeVertices(const int iteration)
517517
mTimeFrame->getTrackletClusters(rofId)[iCluster].getSize(), // Contributors
518518
mTimeFrame->getTrackletClusters(rofId)[iCluster].getAvgDistance2()); // In place of chi2
519519

520-
vertices.back().setFlags(iteration + 1);
520+
if (iteration) {
521+
vertices.back().setFlags(Vertex::UPCMode);
522+
}
521523
vertices.back().setTimeStamp(mTimeFrame->getTrackletClusters(rofId)[iCluster].getROF());
522524
if (mTimeFrame->hasMCinformation()) {
523525
std::vector<o2::MCCompLabel> labels;

Framework/Core/include/Framework/DataTypes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
#include <cstdint>
1717
#include <limits>
1818

19+
namespace o2::aod::bc
20+
{
21+
enum BCFlags : uint8_t {
22+
ITSUPCMode = 0x1
23+
};
24+
}
25+
1926
namespace o2::aod::collision
2027
{
2128
enum CollisionFlagsRun2 : uint16_t {

0 commit comments

Comments
 (0)