Skip to content

Commit

Permalink
Common: save only non-empty BCs, add BC flags creator (AliceO2Group#7678
Browse files Browse the repository at this point in the history
)

* Common: save only non-empty BCs, add BC flags creator

* Please consider the following formatting changes (#344)

* Update multiplicityExtraTable.cxx

---------

Co-authored-by: ALICE Builder <[email protected]>
  • Loading branch information
ddobrigk and alibuild authored Sep 13, 2024
1 parent ef8ad84 commit e6f21ac
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Common/TableProducer/Converters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ o2physics_add_dpl_workflow(bc-converter
PUBLIC_LINK_LIBRARIES O2::Framework
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(bc-flags-creator
SOURCES bcFlagsCreator.cxx
PUBLIC_LINK_LIBRARIES O2::Framework
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(calo-label-converter
SOURCES caloLabelConverter.cxx
PUBLIC_LINK_LIBRARIES
Expand Down
36 changes: 36 additions & 0 deletions Common/TableProducer/Converters/bcFlagsCreator.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.
#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"

using namespace o2;
using namespace o2::framework;

// Creates an empty BCFlags for data that doesn't have it to be used seamlessly
// n.b. this will overwrite existing BCFlags, to be discussed if data in mixed condition
struct bcFlagsCreator {
Produces<aod::BCFlags> bcFlags;

void process(aod::BCs const& bcTable)
{
for (auto& bc : bcTable) {
bcFlags(0);
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<bcFlagsCreator>(cfgc),
};
}
17 changes: 17 additions & 0 deletions Common/TableProducer/multiplicityExtraTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct MultiplicityExtraTable {
// Allow for downscaling of BC table for less space use in derived data
Configurable<float> bcDownscaleFactor{"bcDownscaleFactor", 2, "Downscale factor for BC table (0: save nothing, 1: save all)"};
Configurable<float> minFT0CforBCTable{"minFT0CforBCTable", 25.0f, "Minimum FT0C amplitude to fill BC table to reduce data"};
Configurable<bool> saveOnlyBCsWithCollisions{"saveOnlyBCsWithCollisions", true, "save only BCs with collisions in them"};

// needed for downscale
unsigned int randomSeed = 0;
Expand Down Expand Up @@ -66,13 +67,24 @@ struct MultiplicityExtraTable {
{
//+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+
// determine saved BCs and corresponding new BC table index
std::vector<int> bcHasCollision(bcs.size());
std::vector<int> newBCindex(bcs.size());
std::vector<int> bc2multArray(bcs.size());
int atIndex = 0;
for (const auto& bc : bcs) {
bcHasCollision[bc.globalIndex()] = false;
newBCindex[bc.globalIndex()] = -1;
bc2multArray[bc.globalIndex()] = -1;
}

//+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+
// tag BCs that have a collision (from evsel foundBC)
for (const auto& collision : collisions) {
bcHasCollision[collision.foundBCId()] = true;
}
//+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+

for (const auto& bc : bcs) {
// downscale if requested to do so
if (bcDownscaleFactor < 1.f && (static_cast<float>(rand_r(&randomSeed)) / static_cast<float>(RAND_MAX)) > bcDownscaleFactor) {
continue;
Expand All @@ -91,6 +103,11 @@ struct MultiplicityExtraTable {
if (multFT0C < minFT0CforBCTable) {
continue; // skip this event
}

if (saveOnlyBCsWithCollisions && !bcHasCollision[bc.globalIndex()]) {
continue; // skip if no collision is assigned to this BC (from evSel assignment)
}

newBCindex[bc.globalIndex()] = atIndex++;
}
//+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+-<*>-+
Expand Down

0 comments on commit e6f21ac

Please sign in to comment.