Skip to content

Commit

Permalink
PWGJE: Adding a selected event counter for read collisions (AliceO2Gr…
Browse files Browse the repository at this point in the history
  • Loading branch information
nzardosh authored May 6, 2024
1 parent d300eb8 commit 2f5a617
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
3 changes: 3 additions & 0 deletions PWGJE/DataModel/JetReducedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ DECLARE_SOA_COLUMN(ChargedTriggerSel, chargedTriggerSel, uint8_t);
DECLARE_SOA_COLUMN(FullTriggerSel, fullTriggerSel, uint32_t);
DECLARE_SOA_COLUMN(ChargedHFTriggerSel, chargedHFTriggerSel, uint8_t);
DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector<int>);
DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector<int>);
DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector<int>);
} // namespace jcollision

Expand Down Expand Up @@ -138,10 +139,12 @@ DECLARE_SOA_TABLE(StoredJCollisionBCs, "AOD1", "JCOLLISIONBC",

DECLARE_SOA_TABLE(CollisionCounts, "AOD", "COLLCOUNT",
jcollision::ReadCounts,
jcollision::ReadSelectedCounts,
jcollision::WrittenCounts);

DECLARE_SOA_TABLE(StoredCollisionCounts, "AOD1", "COLLCOUNT",
jcollision::ReadCounts,
jcollision::ReadSelectedCounts,
jcollision::WrittenCounts,
o2::soa::Marker<1>);

Expand Down
4 changes: 4 additions & 0 deletions PWGJE/DataModel/JetReducedDataHF.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle);
namespace d0collisioncounter
{
DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector<int>);
DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector<int>);
DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector<int>);
} // namespace d0collisioncounter

Expand All @@ -63,6 +64,7 @@ DECLARE_SOA_TABLE(StoredJD0PIds, "AOD1", "JD0PID",

DECLARE_SOA_TABLE(D0CollisionCounts, "AOD", "D0COLLCOUNT",
d0collisioncounter::ReadCounts,
d0collisioncounter::ReadSelectedCounts,
d0collisioncounter::WrittenCounts);

namespace jlcindices
Expand All @@ -78,6 +80,7 @@ DECLARE_SOA_INDEX_COLUMN(JMcParticle, mcParticle);
namespace lccollisioncounter
{
DECLARE_SOA_COLUMN(ReadCounts, readCounts, std::vector<int>);
DECLARE_SOA_COLUMN(ReadSelectedCounts, readSelectedCounts, std::vector<int>);
DECLARE_SOA_COLUMN(WrittenCounts, writtenCounts, std::vector<int>);
} // namespace lccollisioncounter

Expand Down Expand Up @@ -105,6 +108,7 @@ DECLARE_SOA_TABLE(StoredJLcPIds, "AOD1", "JLCPID",

DECLARE_SOA_TABLE(LcCollisionCounts, "AOD", "LcCOLLCOUNT",
lccollisioncounter::ReadCounts,
lccollisioncounter::ReadSelectedCounts,
lccollisioncounter::WrittenCounts);

} // namespace o2::aod
Expand Down
8 changes: 0 additions & 8 deletions PWGJE/TableProducer/jetderiveddataproducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ struct JetDerivedDataProducerTask {
{
}

void processCollisionCounts(aod::Collisions const&)
{
std::vector<int> readCounts = {0};
std::vector<int> writtenCounts = {0};
collisionCountsTable(readCounts, writtenCounts);
}
PROCESS_SWITCH(JetDerivedDataProducerTask, processCollisionCounts, "produces collision counting table", false);

void processBunchCrossings(soa::Join<aod::BCs, aod::Timestamps>::iterator const& bc)
{
jBCsTable(bc.runNumber(), bc.globalBC(), bc.timestamp());
Expand Down
15 changes: 14 additions & 1 deletion PWGJE/TableProducer/jetderiveddatawriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct JetDerivedDataWriter {
Configurable<bool> saveD0Table{"saveD0Table", false, "save the D0 table to the output"};
Configurable<bool> saveLcTable{"saveLcTable", false, "save the Lc table to the output"};

Configurable<std::string> eventSelectionForCounting{"eventSelectionForCounting", "sel8", "choose event selection for collision counter"};

Produces<aod::StoredCollisionCounts> storedCollisionCountsTable;
Produces<aod::StoredJDummys> storedJDummysTable;
Produces<aod::StoredJBCs> storedJBCsTable;
Expand Down Expand Up @@ -109,10 +111,12 @@ struct JetDerivedDataWriter {
uint32_t precisionPositionMask;
uint32_t precisionMomentumMask;

int eventSelection = -1;
void init(InitContext&)
{
precisionPositionMask = 0xFFFFFC00; // 13 bits
precisionMomentumMask = 0xFFFFFC00; // 13 bits this is currently keept at 13 bits wihich gives roughly a resolution of 1/8000. This can be increased to 15 bits if really needed
eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast<std::string>(eventSelectionForCounting));
}

bool acceptCollision(aod::JCollision const&)
Expand Down Expand Up @@ -189,33 +193,42 @@ struct JetDerivedDataWriter {
void processCollisionCounting(aod::JCollisions const& collisions, aod::CollisionCounts const& collisionCounts)
{
int readCollisionCounter = 0;
int readSelectedCollisionCounter = 0;
int writtenCollisionCounter = 0;
for (const auto& collision : collisions) {
readCollisionCounter++;
if (jetderiveddatautilities::selectCollision(collision, eventSelection)) {
readSelectedCollisionCounter++;
}
if (collisionFlag[collision.globalIndex()]) {
writtenCollisionCounter++;
}
}
std::vector<int> previousReadCounts;
std::vector<int> previousReadSelectedCounts;
std::vector<int> previousWrittenCounts;
int iPreviousDataFrame = 0;
for (const auto& collisionCount : collisionCounts) {
auto readCollisionCounterSpan = collisionCount.readCounts();
auto readSelectedCollisionCounterSpan = collisionCount.readSelectedCounts();
auto writtenCollisionCounterSpan = collisionCount.writtenCounts();
if (iPreviousDataFrame == 0) {
std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts));
std::copy(readSelectedCollisionCounterSpan.begin(), readSelectedCollisionCounterSpan.end(), std::back_inserter(previousReadSelectedCounts));
std::copy(writtenCollisionCounterSpan.begin(), writtenCollisionCounterSpan.end(), std::back_inserter(previousWrittenCounts));
} else {
for (unsigned int i = 0; i < previousReadCounts.size(); i++) {
previousReadCounts[i] += readCollisionCounterSpan[i];
previousReadSelectedCounts[i] += readSelectedCollisionCounterSpan[i];
previousWrittenCounts[i] += writtenCollisionCounterSpan[i];
}
}
iPreviousDataFrame++;
}
previousReadCounts.push_back(readCollisionCounter);
previousReadCounts.push_back(readSelectedCollisionCounter);
previousWrittenCounts.push_back(writtenCollisionCounter);
storedCollisionCountsTable(previousReadCounts, previousWrittenCounts);
storedCollisionCountsTable(previousReadCounts, previousReadSelectedCounts, previousWrittenCounts);
}
PROCESS_SWITCH(JetDerivedDataWriter, processCollisionCounting, "write out collision counting output table", false);

Expand Down
20 changes: 18 additions & 2 deletions PWGJE/Tasks/jetsubstructurehfoutput.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "PWGJE/DataModel/JetSubstructure.h"
#include "PWGJE/Core/JetFinder.h"
#include "PWGJE/Core/JetFindingUtilities.h"
#include "PWGJE/Core/JetDerivedDataUtilities.h"

using namespace o2;
using namespace o2::framework;
Expand Down Expand Up @@ -79,6 +80,8 @@ struct JetSubstructureHFOutputTask {
Configurable<float> trackEtaMin{"trackEtaMin", -0.9, "minimum track pseudorapidity"};
Configurable<float> trackEtaMax{"trackEtaMax", 0.9, "maximum track pseudorapidity"};

Configurable<std::string> eventSelectionForCounting{"eventSelectionForCounting", "sel8", "choose event selection for collision counter"};

std::map<int32_t, int32_t> candidateMapping;
std::map<int32_t, int32_t> candidateCollisionMapping;

Expand All @@ -91,9 +94,11 @@ struct JetSubstructureHFOutputTask {

std::vector<double> jetRadiiValues;

int eventSelection = -1;
void init(InitContext const&)
{
jetRadiiValues = (std::vector<double>)jetRadii;
eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast<std::string>(eventSelectionForCounting));
}

template <typename T, typename U, typename V, typename M>
Expand Down Expand Up @@ -262,28 +267,39 @@ struct JetSubstructureHFOutputTask {
void processCountCollisions(JetCollisions const& collisions, aod::CollisionCounts const& collisionCounts)
{
int readCollisionCounter = 0;
int readSelectedCollisionCounter = 0;
int writtenCollisionCounter = -1;
readCollisionCounter = collisions.size();
for (auto const& collision : collisions) {
readCollisionCounter++;
if (jetderiveddatautilities::selectCollision(collision, eventSelection)) {
readSelectedCollisionCounter++;
}
}
std::vector<int> previousReadCounts;
std::vector<int> previousReadSelectedCounts;
std::vector<int> previousWrittenCounts;
int iPreviousDataFrame = 0;
for (const auto& collisionCount : collisionCounts) {
auto readCollisionCounterSpan = collisionCount.readCounts();
auto readSelectedCollisionCounterSpan = collisionCount.readSelectedCounts();
auto writtenCollisionCounterSpan = collisionCount.writtenCounts();
if (iPreviousDataFrame == 0) {
std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts));
std::copy(readSelectedCollisionCounterSpan.begin(), readSelectedCollisionCounterSpan.end(), std::back_inserter(previousReadSelectedCounts));
std::copy(writtenCollisionCounterSpan.begin(), writtenCollisionCounterSpan.end(), std::back_inserter(previousWrittenCounts));
} else {
for (unsigned int i = 0; i < previousReadCounts.size(); i++) {
previousReadCounts[i] += readCollisionCounterSpan[i];
previousReadSelectedCounts[i] += readSelectedCollisionCounterSpan[i];
previousWrittenCounts[i] += writtenCollisionCounterSpan[i];
}
}
iPreviousDataFrame++;
}
previousReadCounts.push_back(readCollisionCounter);
previousReadSelectedCounts.push_back(readSelectedCollisionCounter);
previousWrittenCounts.push_back(writtenCollisionCounter);
storedCollisionCountsTable(previousReadCounts, previousWrittenCounts);
storedCollisionCountsTable(previousReadCounts, previousReadSelectedCounts, previousWrittenCounts);
}
PROCESS_SWITCH(JetSubstructureHFOutputTask, processCountCollisions, "process function that counts read in collisions", false);

Expand Down
20 changes: 18 additions & 2 deletions PWGJE/Tasks/jetsubstructureoutput.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "PWGJE/Core/JetFindingUtilities.h"
#include "PWGJE/DataModel/Jet.h"
#include "PWGJE/DataModel/JetSubstructure.h"
#include "PWGJE/Core/JetDerivedDataUtilities.h"

using namespace o2;
using namespace o2::framework;
Expand Down Expand Up @@ -68,16 +69,20 @@ struct JetSubstructureOutputTask {
Configurable<float> trackEtaMin{"trackEtaMin", -0.9, "minimum track pseudorapidity"};
Configurable<float> trackEtaMax{"trackEtaMax", 0.9, "maximum track pseudorapidity"};

Configurable<std::string> eventSelectionForCounting{"eventSelectionForCounting", "sel8", "choose event selection for collision counter"};

std::map<int32_t, int32_t> jetMappingData;
std::map<int32_t, int32_t> jetMappingDataSub;
std::map<int32_t, int32_t> jetMappingMCD;
std::map<int32_t, int32_t> jetMappingMCP;

std::vector<double> jetRadiiValues;

int eventSelection = -1;
void init(InitContext const&)
{
jetRadiiValues = (std::vector<double>)jetRadii;
eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast<std::string>(eventSelectionForCounting));
}

template <typename T, typename U, typename V>
Expand Down Expand Up @@ -181,28 +186,39 @@ struct JetSubstructureOutputTask {
void processCountCollisions(JetCollisions const& collisions, aod::CollisionCounts const& collisionCounts)
{
int readCollisionCounter = 0;
int readSelectedCollisionCounter = 0;
int writtenCollisionCounter = -1;
readCollisionCounter = collisions.size();
for (auto const& collision : collisions) {
readCollisionCounter++;
if (jetderiveddatautilities::selectCollision(collision, eventSelection)) {
readSelectedCollisionCounter++;
}
}
std::vector<int> previousReadCounts;
std::vector<int> previousReadSelectedCounts;
std::vector<int> previousWrittenCounts;
int iPreviousDataFrame = 0;
for (const auto& collisionCount : collisionCounts) {
auto readCollisionCounterSpan = collisionCount.readCounts();
auto readSelectedCollisionCounterSpan = collisionCount.readSelectedCounts();
auto writtenCollisionCounterSpan = collisionCount.writtenCounts();
if (iPreviousDataFrame == 0) {
std::copy(readCollisionCounterSpan.begin(), readCollisionCounterSpan.end(), std::back_inserter(previousReadCounts));
std::copy(readSelectedCollisionCounterSpan.begin(), readSelectedCollisionCounterSpan.end(), std::back_inserter(previousReadSelectedCounts));
std::copy(writtenCollisionCounterSpan.begin(), writtenCollisionCounterSpan.end(), std::back_inserter(previousWrittenCounts));
} else {
for (unsigned int i = 0; i < previousReadCounts.size(); i++) {
previousReadCounts[i] += readCollisionCounterSpan[i];
previousReadSelectedCounts[i] += readSelectedCollisionCounterSpan[i];
previousWrittenCounts[i] += writtenCollisionCounterSpan[i];
}
}
iPreviousDataFrame++;
}
previousReadCounts.push_back(readCollisionCounter);
previousReadSelectedCounts.push_back(readSelectedCollisionCounter);
previousWrittenCounts.push_back(writtenCollisionCounter);
storedCollisionCountsTable(previousReadCounts, previousWrittenCounts);
storedCollisionCountsTable(previousReadCounts, previousReadSelectedCounts, previousWrittenCounts);
}
PROCESS_SWITCH(JetSubstructureOutputTask, processCountCollisions, "process function that counts read in collisions", false);

Expand Down

0 comments on commit 2f5a617

Please sign in to comment.