Skip to content

Commit f41f921

Browse files
authored
[PWGUD] Add collision-associated FIT bit mapping (#18221)
1 parent 1a0eaf7 commit f41f921

7 files changed

Lines changed: 316 additions & 116 deletions

File tree

‎PWGUD/Core/UDHelpers.h‎

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,14 @@ bool cleanFDD(T& bc, float maxFITtime, float limitA, float limitC)
425425
// lims[4]: FDDC
426426

427427
template <typename T>
428-
bool cleanFIT(T& bc, float maxFITtime, std::vector<float> lims)
428+
bool cleanFIT(T& bc, float maxFITtime, std::vector<float> const& lims)
429429
{
430430
return cleanFV0(bc, maxFITtime, lims[0]) &&
431431
cleanFT0(bc, maxFITtime, lims[1], lims[2]) &&
432432
cleanFDD(bc, maxFITtime, lims[3], lims[4]);
433433
}
434434
template <typename T>
435-
bool cleanFITCollision(T& col, float maxFITtime, std::vector<float> lims)
435+
bool cleanFITCollision(T& col, float maxFITtime, std::vector<float> const& lims)
436436
{
437437
bool isCleanFV0 = true;
438438
if (col.has_foundFV0()) {
@@ -453,7 +453,7 @@ bool cleanFITCollision(T& col, float maxFITtime, std::vector<float> lims)
453453

454454
// -----------------------------------------------------------------------------
455455
template <typename T>
456-
bool cleanFITA(T& bc, float maxFITtime, std::vector<float> lims)
456+
bool cleanFITA(T& bc, float maxFITtime, std::vector<float> const& lims)
457457
{
458458
return cleanFV0(bc, maxFITtime, lims[0]) &&
459459
cleanFT0A(bc, maxFITtime, lims[1]) &&
@@ -462,7 +462,7 @@ bool cleanFITA(T& bc, float maxFITtime, std::vector<float> lims)
462462

463463
// -----------------------------------------------------------------------------
464464
template <typename T>
465-
bool cleanFITC(T& bc, float maxFITtime, std::vector<float> lims)
465+
bool cleanFITC(T& bc, float maxFITtime, std::vector<float> const& lims)
466466
{
467467
return cleanFT0C(bc, maxFITtime, lims[2]) &&
468468
cleanFDDC(bc, maxFITtime, lims[4]);
@@ -506,7 +506,7 @@ bool TCE(T& bc)
506506

507507
// -----------------------------------------------------------------------------
508508
template <typename T>
509-
bool TOR(T& bc, float maxFITtime, std::vector<float> lims)
509+
bool TOR(T& bc, float maxFITtime, std::vector<float> const& lims)
510510
{
511511
auto torA = !cleanFT0A(bc, maxFITtime, lims[1]);
512512
auto torC = !cleanFT0C(bc, maxFITtime, lims[2]);
@@ -565,27 +565,48 @@ inline void buildFT0FV0Words(TFT0 const& ft0, TFV0A const& fv0a,
565565
constexpr int kFV0Offset = 208;
566566

567567
auto ampsA = ft0.amplitudeA();
568-
const int nA = std::min<int>(ampsA.size(), 96);
568+
auto chanA = ft0.channelA();
569+
const int nA = std::min<int>(ampsA.size(), chanA.size());
569570
for (int i = 0; i < nA; ++i) {
570571
const auto a = ampsA[i];
571-
setBit(thr1, kFT0AOffset + i, a >= thr1_FT0A);
572-
setBit(thr2, kFT0AOffset + i, a >= thr2_FT0A);
572+
const int c = chanA[i];
573+
574+
if (c < 0 || c >= 96) {
575+
continue;
576+
}
577+
578+
setBit(thr1, kFT0AOffset + c, a >= thr1_FT0A);
579+
setBit(thr2, kFT0AOffset + c, a >= thr2_FT0A);
573580
}
574581

575582
auto ampsC = ft0.amplitudeC();
576-
const int nC = std::min<int>(ampsC.size(), 112);
583+
auto chanC = ft0.channelC();
584+
const int nC = std::min<int>(ampsC.size(), chanC.size());
577585
for (int i = 0; i < nC; ++i) {
578586
const auto a = ampsC[i];
579-
setBit(thr1, kFT0COffset + i, a >= thr1_FT0C);
580-
setBit(thr2, kFT0COffset + i, a >= thr2_FT0C);
587+
const int c = chanC[i];
588+
589+
if (c < 0 || c >= 112) {
590+
continue;
591+
}
592+
593+
setBit(thr1, kFT0COffset + c, a >= thr1_FT0C);
594+
setBit(thr2, kFT0COffset + c, a >= thr2_FT0C);
581595
}
582596

583597
auto ampsV = fv0a.amplitude();
584-
const int nV = std::min<int>(ampsV.size(), 48);
598+
auto chanV = fv0a.channel();
599+
const int nV = std::min<int>(ampsV.size(), chanV.size());
585600
for (int i = 0; i < nV; ++i) {
586601
const auto a = ampsV[i];
587-
setBit(thr1, kFV0Offset + i, a >= thr1_FV0A);
588-
setBit(thr2, kFV0Offset + i, a >= thr2_FV0A);
602+
const int c = chanV[i];
603+
604+
if (c < 0 || c >= 48) {
605+
continue;
606+
}
607+
608+
setBit(thr1, kFV0Offset + c, a >= thr1_FV0A);
609+
setBit(thr2, kFV0Offset + c, a >= thr2_FV0A);
589610
}
590611
}
591612

@@ -777,24 +798,15 @@ template <typename T>
777798
bool goodCollision(T const& coll, DGCutparHolder const& diffCuts)
778799
// Return true if collision is accepted according to user-chosen rules from event selection task
779800
{
780-
bool accepted = true;
781-
std::vector<int> sels = diffCuts.collisionSel();
782-
if (sels[0])
783-
accepted = accepted && cutNoTimeFrameBorder(coll);
784-
if (sels[1])
785-
accepted = accepted && cutNoSameBunchPileup(coll);
786-
if (sels[2])
787-
accepted = accepted && cutNoITSROFrameBorder(coll);
788-
if (sels[3])
789-
accepted = accepted && cutIsGoodZvtxFT0vsPV(coll);
790-
if (sels[4])
791-
accepted = accepted && cutIsVertexITSTPC(coll);
792-
if (sels[5])
793-
accepted = accepted && cutIsVertexTRDmatched(coll);
794-
if (sels[6])
795-
accepted = accepted && cutIsVertexTOFmatched(coll);
796-
797-
return accepted;
801+
auto const sels = diffCuts.collisionSel();
802+
803+
return (!sels[0] || cutNoTimeFrameBorder(coll)) &&
804+
(!sels[1] || cutNoSameBunchPileup(coll)) &&
805+
(!sels[2] || cutNoITSROFrameBorder(coll)) &&
806+
(!sels[3] || cutIsGoodZvtxFT0vsPV(coll)) &&
807+
(!sels[4] || cutIsVertexITSTPC(coll)) &&
808+
(!sels[5] || cutIsVertexTRDmatched(coll)) &&
809+
(!sels[6] || cutIsVertexTOFmatched(coll));
798810
}
799811

800812
// -----------------------------------------------------------------------------

‎PWGUD/DataModel/UDTables.h‎

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,28 +410,43 @@ DECLARE_SOA_TABLE(UDTracksLabels, "AOD", "UDTRACKLABEL",
410410

411411
namespace udcollfitbits
412412
{
413+
DECLARE_SOA_INDEX_COLUMN(UDCollision, udCollision); /// Link to the UDCOLLISION table
414+
413415
DECLARE_SOA_COLUMN(Thr1W0, thr1W0, uint64_t); /// 1 MIP thresholds for FT0A ch 0 - ch 63
414-
DECLARE_SOA_COLUMN(Thr1W1, thr1W1, uint64_t); /// 1 MIP thresholds for FT0A ch 64 - ch 96 & FT0C ch 0 - ch 31
415-
DECLARE_SOA_COLUMN(Thr1W2, thr1W2, uint64_t); /// 1 MIP thresholds for FT0C ch 32 - ch 96
416-
DECLARE_SOA_COLUMN(Thr1W3, thr1W3, uint64_t); /// 1 MIP thresholds for FT0C ch 97 - 112 & FV0 0 - 47
416+
DECLARE_SOA_COLUMN(Thr1W1, thr1W1, uint64_t); /// 1 MIP thresholds for FT0A ch 64 - ch 95 & FT0C ch 0 - ch 31
417+
DECLARE_SOA_COLUMN(Thr1W2, thr1W2, uint64_t); /// 1 MIP thresholds for FT0C ch 32 - ch 95
418+
DECLARE_SOA_COLUMN(Thr1W3, thr1W3, uint64_t); /// 1 MIP thresholds for FT0C ch 96 - 111 & FV0 0 - 47
417419

418420
DECLARE_SOA_COLUMN(Thr2W0, thr2W0, uint64_t); /// 2 MIP thresholds for FT0A ch 0 - ch 63
419-
DECLARE_SOA_COLUMN(Thr2W1, thr2W1, uint64_t); /// 2 MIP thresholds for FT0A ch 63 - ch 96 & FT0C ch 0 - ch 31
420-
DECLARE_SOA_COLUMN(Thr2W2, thr2W2, uint64_t); /// 2 MIP thresholds for FT0C ch 32 - ch 96
421-
DECLARE_SOA_COLUMN(Thr2W3, thr2W3, uint64_t); /// 2 MIP thresholds for FT0C ch 97 - 112 & FV0 0 - 47
421+
DECLARE_SOA_COLUMN(Thr2W1, thr2W1, uint64_t); /// 2 MIP thresholds for FT0A ch 64 - ch 95 & FT0C ch 0 - ch 31
422+
DECLARE_SOA_COLUMN(Thr2W2, thr2W2, uint64_t); /// 2 MIP thresholds for FT0C ch 32 - ch 95
423+
DECLARE_SOA_COLUMN(Thr2W3, thr2W3, uint64_t); /// 2 MIP thresholds for FT0C ch 96 - 111 & FV0 0 - 47
422424
} // namespace udcollfitbits
423425

424-
DECLARE_SOA_TABLE(UDCollisionFITBits, "AOD", "UDCOLLFITBITS",
426+
DECLARE_SOA_TABLE(UDCollisionFITBits_000, "AOD", "UDCOLLFITBITS",
425427
o2::soa::Index<>,
426-
udcollfitbits::Thr1W0, /// 1 MIP thresholds for FT0A ch 0 - ch 63
427-
udcollfitbits::Thr1W1, /// 1 MIP thresholds for FT0A ch 63 - ch 96 & FT0C ch 0 - ch 31
428-
udcollfitbits::Thr1W2, /// 1 MIP thresholds for FT0C ch 32 - ch 96
429-
udcollfitbits::Thr1W3, /// 1 MIP thresholds for FT0C ch 97 - 112 & FV0 0 - 47
430-
udcollfitbits::Thr2W0, /// 2 MIP thresholds for FT0A ch 0 - ch 63
431-
udcollfitbits::Thr2W1, /// 2 MIP thresholds for FT0A ch 63 - ch 96 & FT0C ch 0 - ch 31
432-
udcollfitbits::Thr2W2, /// 2 MIP thresholds for FT0C ch 32 - ch 96
433-
udcollfitbits::Thr2W3 /// 2 MIP thresholds for FT0C ch 97 - 112 & FV0 0 - 47
434-
);
428+
udcollfitbits::Thr1W0,
429+
udcollfitbits::Thr1W1,
430+
udcollfitbits::Thr1W2,
431+
udcollfitbits::Thr1W3,
432+
udcollfitbits::Thr2W0,
433+
udcollfitbits::Thr2W1,
434+
udcollfitbits::Thr2W2,
435+
udcollfitbits::Thr2W3);
436+
437+
DECLARE_SOA_TABLE_VERSIONED(UDCollisionFITBits_001, "AOD", "UDCOLLFITBITS", 1,
438+
o2::soa::Index<>,
439+
udcollfitbits::UDCollisionId,
440+
udcollfitbits::Thr1W0,
441+
udcollfitbits::Thr1W1,
442+
udcollfitbits::Thr1W2,
443+
udcollfitbits::Thr1W3,
444+
udcollfitbits::Thr2W0,
445+
udcollfitbits::Thr2W1,
446+
udcollfitbits::Thr2W2,
447+
udcollfitbits::Thr2W3);
448+
449+
using UDCollisionFITBits = UDCollisionFITBits_001;
435450

436451
using UDTrack = UDTracks::iterator;
437452
using UDTrackCov = UDTracksCov::iterator;

‎PWGUD/TableProducer/Converters/CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ o2physics_add_dpl_workflow(collisions-converter
1919
SOURCES UDCollisionsConverter.cxx
2020
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
2121
COMPONENT_NAME Analysis)
22+
o2physics_add_dpl_workflow(collision-fit-bits-converter
23+
SOURCES UDCollisionFITBitsConverter.cxx
24+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
25+
COMPONENT_NAME Analysis)
2226

2327
o2physics_add_dpl_workflow(collisionselextras-converter
2428
SOURCES UDCollisionSelExtrasConverter.cxx
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
13+
/// \file UDCollisionFITBitsConverter.cxx
14+
/// \brief Converts UDCollisionFITBits from version 000 to 001
15+
///
16+
/// The legacy table was written with exactly one FIT-bit row for every
17+
/// UDCollision, in identical row order. Therefore row i of
18+
/// UDCollisionFITBits_000 belongs to row i of UDCollisions. Because the
19+
/// legacy table does not store this association explicitly, the converter
20+
/// materialises it by writing the FIT-bit row's global index as
21+
/// UDCollisionId. The eight packed FIT-bit words are copied unchanged.
22+
///
23+
/// Executable: o2-analysis-ud-collision-fit-bits-converter
24+
///
25+
/// \author Sandor Lokos, sandor.lokos@cern.ch
26+
27+
#include "PWGUD/DataModel/UDTables.h"
28+
29+
#include <Framework/AnalysisHelpers.h>
30+
#include <Framework/AnalysisTask.h>
31+
#include <Framework/runDataProcessing.h>
32+
33+
using namespace o2;
34+
using namespace o2::framework;
35+
36+
struct UDCollisionFITBitsConverter {
37+
Produces<aod::UDCollisionFITBits_001> outputFITBits;
38+
39+
void process(aod::UDCollisionFITBits_000 const& legacyFITBits)
40+
{
41+
outputFITBits.reserve(legacyFITBits.size());
42+
43+
for (const auto& bits : legacyFITBits) {
44+
outputFITBits(bits.globalIndex(),
45+
bits.thr1W0(),
46+
bits.thr1W1(),
47+
bits.thr1W2(),
48+
bits.thr1W3(),
49+
bits.thr2W0(),
50+
bits.thr2W1(),
51+
bits.thr2W2(),
52+
bits.thr2W3());
53+
}
54+
}
55+
};
56+
57+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
58+
{
59+
return WorkflowSpec{
60+
adaptAnalysisTask<UDCollisionFITBitsConverter>(cfgc)};
61+
}

‎PWGUD/TableProducer/SGCandProducer.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ struct SGCandProducer {
351351
fitCuts.thr2_FV0A());
352352
}
353353

354-
outputFITBits(w1[0], w1[1], w1[2], w1[3],
354+
outputFITBits(outputCollisions.lastIndex(),
355+
w1[0], w1[1], w1[2], w1[3],
355356
w2[0], w2[1], w2[2], w2[3]);
356357

357358
if (newbc.has_zdc()) {

‎PWGUD/Tasks/sgFITAnalyzer.cxx‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -778,36 +778,36 @@ struct SGFITAnalyzer {
778778
avPtPVa += track.pt();
779779
vecEtaPVa.push_back(vtrk.Eta());
780780
registry.get<TH1>(HIST("tracks/etaApv"))->Fill(vtrk.Eta(), 1.);
781-
if (!an)
781+
if (!an) {
782782
registry.get<TH1>(HIST("tracks/eta2Apv"))->Fill(vtrk.Eta(), 1.);
783-
if (!an)
784783
z0pva++;
785-
else if (an == 4)
784+
} else if (an == 4) {
786785
z1pva++;
786+
}
787787
}
788788
if (truegapSide == 1) {
789789
pvc++;
790790
avPtPVc += track.pt();
791791
vecEtaPVc.push_back(vtrk.Eta());
792792
registry.get<TH1>(HIST("tracks/etaCpv"))->Fill(vtrk.Eta(), 1.);
793-
if (!cn)
793+
if (!cn) {
794794
registry.get<TH1>(HIST("tracks/eta2Cpv"))->Fill(vtrk.Eta(), 1.);
795-
if (!cn)
796795
z0pvc++;
797-
else if (cn == 4)
796+
} else if (cn == 4) {
798797
z1pvc++;
798+
}
799799
}
800800
if (truegapSide == 2) {
801801
pvac++;
802802
avPtPVac += track.pt();
803803
vecEtaPVac.push_back(vtrk.Eta());
804804
registry.get<TH1>(HIST("tracks/etaACpv"))->Fill(vtrk.Eta(), 1.);
805-
if (!an && !cn)
805+
if (!an && !cn) {
806806
registry.get<TH1>(HIST("tracks/eta2ACpv"))->Fill(vtrk.Eta(), 1.);
807-
if (!an && !cn)
808807
z0pvac++;
809-
else if (an >= 3 && cn >= 3)
808+
} else if (an >= 3 && cn >= 3) {
810809
z1pvac++;
810+
}
811811
}
812812
registry.get<TH2>(HIST("tracks/TPCSignalvspPVC"))->Fill(vtrk.Mag(), signalTPC, 1.);
813813
registry.get<TH2>(HIST("tracks/TOFSignalvspPVC"))->Fill(vtrk.Mag(), signalTOF, 1.);

0 commit comments

Comments
 (0)