Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Detectors/MUON/MCH/DigitFiltering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ o2_add_library(MCHDigitFiltering
SOURCES
src/DigitFilter.cxx
src/DigitFilterParam.cxx
src/DigitModifier.cxx
src/DigitModifierParam.cxx
src/DigitFilteringSpec.cxx
PUBLIC_LINK_LIBRARIES
O2::Framework
Expand All @@ -27,4 +29,4 @@ o2_add_executable(
COMPONENT_NAME mch
PUBLIC_LINK_LIBRARIES O2::MCHDigitFiltering)

o2_target_root_dictionary(MCHDigitFiltering HEADERS include/MCHDigitFiltering/DigitFilterParam.h)
o2_target_root_dictionary(MCHDigitFiltering HEADERS include/MCHDigitFiltering/DigitFilterParam.h include/MCHDigitFiltering/DigitModifierParam.h)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.

#ifndef O2_MCH_DIGITFILTERING_DIGITMODIFIER_H_
#define O2_MCH_DIGITFILTERING_DIGITMODIFIER_H_

#include "DataFormatsMCH/Digit.h"
#include <functional>

namespace o2::mch
{
typedef std::function<void(Digit&)> DigitModifier;

DigitModifier createDigitModifier(int runNumber,
bool updateST1,
bool updateST2);

} // namespace o2::mch

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.

#ifndef O2_MCH_DIGITFILTERING_DIGIT_MODIFIER_PARAM_H_
#define O2_MCH_DIGITFILTERING_DIGIT_MODIFIER_PARAM_H_

#include "CommonUtils/ConfigurableParam.h"
#include "CommonUtils/ConfigurableParamHelper.h"

namespace o2::mch
{

/**
* @class DigitModifierParam
* @brief Configurable parameters for the digit updating
*/
struct DigitModifierParam : public o2::conf::ConfigurableParamHelper<DigitModifierParam> {

bool updateST1 = false; ///< whether or not to modify ST1 digits
bool updateST2 = false; ///< whether or not to modify ST2 digits

O2ParamDef(DigitModifierParam, "MCHDigitModifier");
};

} // namespace o2::mch

#endif
36 changes: 32 additions & 4 deletions Detectors/MUON/MCH/DigitFiltering/src/DigitFilteringSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "MCHStatus/StatusMap.h"
#include "MCHDigitFiltering/DigitFilter.h"
#include "MCHDigitFiltering/DigitFilterParam.h"
#include "MCHDigitFiltering/DigitModifier.h"
#include "MCHDigitFiltering/DigitModifierParam.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include <fmt/format.h>
Expand All @@ -48,6 +50,10 @@ class DigitFilteringTask
mRejectBackground = DigitFilterParam::Instance().rejectBackground;
mStatusMask = DigitFilterParam::Instance().statusMask;
mTimeCalib = DigitFilterParam::Instance().timeOffset;

mUpdateDigitsST1 = DigitModifierParam::Instance().updateST1;
mUpdateDigitsST2 = DigitModifierParam::Instance().updateST2;

auto stop = [this]() {
LOG(info) << "digit filtering duration = "
<< std::chrono::duration<double, std::milli>(mElapsedTime).count() << " ms";
Expand Down Expand Up @@ -82,6 +88,11 @@ class DigitFilteringTask

auto tStart = std::chrono::high_resolution_clock::now();

const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
if (tinfo.runNumber != 0) {
mRunNumber = tinfo.runNumber;
}

if (mSanityCheck) {
LOGP(info, "performing sanity checks");
auto error = sanityCheck(iRofs, iDigits);
Expand All @@ -101,8 +112,12 @@ class DigitFilteringTask
auto oLabels = mUseMC ? &pc.outputs().make<MCTruthContainer<MCCompLabel>>(OutputRef{"labels"}) : nullptr;

if (!abort) {
bool selectSignal = false;

mDigitModifier = createDigitModifier(mRunNumber,
mUpdateDigitsST1,
mUpdateDigitsST2);

bool selectSignal = false;
mIsGoodDigit = createDigitFilter(mMinADC,
mRejectBackground,
selectSignal,
Expand All @@ -114,20 +129,29 @@ class DigitFilteringTask
// the clustering resolution will suffer.
// That's why we only apply the "reject background" filter, which
// is a loose background cut that does not penalize the signal

int cursor{0};
for (const auto& irof : iRofs) {
const auto digits = iDigits.subspan(irof.getFirstIdx(), irof.getNEntries());

// filter the digits from the current ROF
for (auto i = 0; i < digits.size(); i++) {
const auto& d = digits[i];
if (mIsGoodDigit(d)) {
oDigits.emplace_back(d);
auto digit = digits[i];

// modify the digit if needed
if (mDigitModifier) {
mDigitModifier(digit);
}

// check the digit quality
if (mIsGoodDigit(digit)) {
oDigits.emplace_back(digit);
if (iLabels) {
oLabels->addElements(oLabels->getIndexedSize(), iLabels->getLabels(i + irof.getFirstIdx()));
}
}
}

int nofGoodDigits = oDigits.size() - cursor;
if (nofGoodDigits > 0) {
// we create an ouput ROF only if at least one digit from
Expand Down Expand Up @@ -160,14 +184,18 @@ class DigitFilteringTask
}

private:
int mRunNumber{0};
bool mRejectBackground{false};
bool mSanityCheck{false};
bool mUseMC{false};
bool mUseStatusMap{false};
int mMinADC{1};
int32_t mTimeCalib{0};
uint32_t mStatusMask{0};
bool mUpdateDigitsST1{false};
bool mUpdateDigitsST2{false};
DigitFilter mIsGoodDigit;
DigitModifier mDigitModifier;
std::chrono::duration<double> mElapsedTime{};
};

Expand Down
Loading