Skip to content

Commit

Permalink
FIT: add RecPoint reader and writer workflows for FV0 and FDD
Browse files Browse the repository at this point in the history
The main purpose of the commit:
- Adding workflows for reading RecPoints for FV0 and FDD, these are needed for MC aQC

Secondary purposes that arose during development:
- ROOT macro for comparing two RecPoint files
- Workflows for writing RecPoints added for FT0, FV0 and FDD (i.e. simply standalone RecPoint writers, not related to reconstrucion)
- The two items above were needed to verify the new RecPoint reader workflows, namely by: reconstructing CTFs -> writing RecPoints to file -> Reading RecPoints from file -> Writing RecPoints to new file -> Comparing the two files
- Minor cosmetics (e.g. reordering of includes) and utility functions (print and == operator functions)
  • Loading branch information
andreasmolander committed Sep 4, 2024
1 parent 64c47f6 commit 768f585
Show file tree
Hide file tree
Showing 20 changed files with 494 additions and 36 deletions.
1 change: 1 addition & 0 deletions DataFormats/Detectors/FIT/FDD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

o2_add_library(DataFormatsFDD
SOURCES src/RawEventData.cxx
src/RecPoint.cxx
src/CTF.cxx
src/LookUpTable.cxx
PUBLIC_LINK_LIBRARIES O2::FDDBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file RecPoint.h
/// \file RecPoint.h
/// \brief Definition of the FDD RecPoint class

#ifndef ALICEO2_FDD_RECPOINT_H
#define ALICEO2_FDD_RECPOINT_H

Expand Down Expand Up @@ -42,6 +43,7 @@ struct ChannelDataFloat {
}

void print() const;
bool operator==(const ChannelDataFloat&) const = default;

ClassDefNV(ChannelDataFloat, 1);
};
Expand Down Expand Up @@ -80,6 +82,9 @@ class RecPoint
int getFirstEntry() const { return mRef.getFirstEntry(); }
int getEntriesInCurrentBC() const { return mRef.getEntries(); }

void print() const;
bool operator==(const RecPoint&) const = default;

private:
o2::dataformats::RangeReference<int, int> mRef;
o2::InteractionRecord mIntRecord;
Expand Down
33 changes: 33 additions & 0 deletions DataFormats/Detectors/FIT/FDD/src/RecPoint.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2019-2024 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.

/// \file RecPoint.cxx
/// \brief Implementation of the FDD RecPoint class
/// \author Andreas Molander [email protected]

#include "DataFormatsFDD/RecPoint.h"
#include "Framework/Logger.h"

using namespace o2::fdd;

void ChannelDataFloat::print() const
{
LOG(info) << "ChannelDataFloat data:";
LOG(info) << "Channel ID: " << mPMNumber << ", Time (ps): " << mTime << ", Charge (ADC): " << mChargeADC << ", QTC chain: " << adcId;
}

void RecPoint::print() const
{
LOG(info) << "RecPoint data:";
LOG(info) << "Collision times: A: " << getCollisionTimeA() << ", C: " << getCollisionTimeC();
LOG(info) << "Ref first: " << mRef.getFirstEntry() << ", Ref entries: " << mRef.getEntries();
LOG(info) << "Triggers: " << mTriggers.print();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct ChannelDataFloat {
}

void print() const;
bool operator==(const ChannelDataFloat&) const = default;

ClassDefNV(ChannelDataFloat, 1);
};
Expand Down Expand Up @@ -74,8 +75,6 @@ class RecPoints
}
~RecPoints() = default;

void print() const;

short getCollisionTime(int side) const { return mCollisionTime[side]; }
short getCollisionTimeMean() const { return getCollisionTime(TimeMean); }
short getCollisionTimeA() const { return getCollisionTime(TimeA); }
Expand All @@ -96,6 +95,9 @@ class RecPoints
gsl::span<const ChannelDataFloat> getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const;
short static constexpr sDummyCollissionTime = 32767;

void print() const;
bool operator==(const RecPoints&) const = default;

private:
std::array<short, 4> mCollisionTime = {sDummyCollissionTime,
sDummyCollissionTime,
Expand Down
15 changes: 12 additions & 3 deletions DataFormats/Detectors/FIT/FT0/src/RecPoints.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@

using namespace o2::ft0;

void ChannelDataFloat::print() const
{

printf(" ChID% d | CFDtime=%f | QTCampl=%f QTC chain %d\n", ChId, CFDTime, QTCAmpl, ChainQTC);
}

gsl::span<const ChannelDataFloat> RecPoints::getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const
{
// extract the span of channel data for this bunch from the whole TF data
return ref.getEntries() ? gsl::span<const ChannelDataFloat>(tfdata).subspan(ref.getFirstEntry(), ref.getEntries()) : gsl::span<const ChannelDataFloat>();
}

void ChannelDataFloat::print() const
void RecPoints::print() const
{

printf(" ChID% d | CFDtime=%f | QTCampl=%f QTC chain %d\n", ChId, CFDTime, QTCAmpl, ChainQTC);
LOG(info) << "RecPoint data:";
LOG(info) << "Collision times: mean: " << getCollisionTimeMean() << ", A: " << getCollisionTimeA() << ", C: " << getCollisionTimeC();
LOG(info) << "Vertex: " << getVertex();
LOG(info) << "Ref first: " << ref.getFirstEntry() << ", Ref entries: " << ref.getEntries();
LOG(info) << "Triggers: " << mTriggers.print();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct ChannelDataFloat {
}

void print() const;
bool operator==(const ChannelDataFloat&) const = default;

ClassDefNV(ChannelDataFloat, 1);
};
Expand Down Expand Up @@ -77,6 +78,9 @@ class RecPoints
gsl::span<const ChannelDataFloat> getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const;
short static constexpr sDummyCollissionTime = 32767;

void print() const;
bool operator==(const RecPoints&) const = default;

private:
o2::dataformats::RangeReference<int, int> mRef;
o2::InteractionRecord mIntRecord;
Expand Down
19 changes: 14 additions & 5 deletions DataFormats/Detectors/FIT/FV0/src/RecPoints.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@

using namespace o2::fv0;

gsl::span<const ChannelDataFloat> RecPoints::getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const
void ChannelDataFloat::print() const
{
// extract the span of channel data for this bunch from the whole TF data
return mRef.getEntries() ? gsl::span<const ChannelDataFloat>(tfdata).subspan(mRef.getFirstEntry(), mRef.getEntries()) : gsl::span<const ChannelDataFloat>();
printf(" Channel=%d | time=%f | charge=%f | adcId=%d\n", channel, time, charge, adcId);
}

void ChannelDataFloat::print() const
void RecPoints::print() const
{
printf(" Channel=%d | time=%f | charge=%f | adcId=%d\n", channel, time, charge, adcId);
printf("RecPoint data:");
printf("Collision times: first: %f, global mean: %f, selected mean: %f\n", getCollisionFirstTime(), getCollisionGlobalMeanTime(), getCollisionSelectedMeanTime());
printf("Ref first: %d, Ref entries: %d\n", mRef.getFirstEntry(), mRef.getEntries());
printf("Triggers: ");
mTriggers.print();
}

gsl::span<const ChannelDataFloat> RecPoints::getBunchChannelData(const gsl::span<const ChannelDataFloat> tfdata) const
{
// extract the span of channel data for this bunch from the whole TF data
return mRef.getEntries() ? gsl::span<const ChannelDataFloat>(tfdata).subspan(mRef.getFirstEntry(), mRef.getEntries()) : gsl::span<const ChannelDataFloat>();
}
10 changes: 10 additions & 0 deletions Detectors/FIT/FDD/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ o2_add_executable(flp-dpl-workflow
PUBLIC_LINK_LIBRARIES O2::FDDWorkflow O2::FDDRaw O2::FITWorkflow
TARGETVARNAME fddflpexe)

o2_add_executable(recpoints-reader-workflow
SOURCES src/recpoints-reader-workflow.cxx
COMPONENT_NAME fdd
PUBLIC_LINK_LIBRARIES O2::FDDWorkflow)

o2_add_executable(recpoints-writer-workflow
SOURCES src/recpoints-writer-workflow.cxx
COMPONENT_NAME fdd
PUBLIC_LINK_LIBRARIES O2::FDDWorkflow)

o2_add_executable(integrate-cluster-workflow
SOURCES src/cluster-integrator.cxx
COMPONENT_NAME fdd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace fdd
class RecPointReader : public Task
{
public:
RecPointReader(bool useMC = true);
RecPointReader(bool useMC = false);
~RecPointReader() override = default;
void init(InitContext& ic) final;
void run(ProcessingContext& pc) final;
Expand All @@ -42,7 +42,7 @@ class RecPointReader : public Task
std::unique_ptr<TFile> mFile;
std::unique_ptr<TTree> mTree;

bool mUseMC = true; // use MC truth
bool mUseMC = false; // use MC truth
o2::header::DataOrigin mOrigin = o2::header::gDataOriginFDD;

std::vector<o2::fdd::RecPoint>* mRecPoints = nullptr;
Expand Down
8 changes: 3 additions & 5 deletions Detectors/FIT/FDD/workflow/src/RecPointReaderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@

/// @file RecPointReaderSpec.cxx

#include <vector>

#include "TTree.h"

#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/ControlService.h"
#include "Framework/Logger.h"
#include "FDDWorkflow/RecPointReaderSpec.h"
#include "CommonUtils/NameConf.h"

#include <vector>

using namespace o2::framework;
using namespace o2::fdd;

Expand Down
57 changes: 57 additions & 0 deletions Detectors/FIT/FDD/workflow/src/recpoints-reader-workflow.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2019-2024 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.

/// \file recpoints-reader-workflow.cxx
/// \brief FDD RecPoints reader workflow
///
/// \author Andreas Molander [email protected]

#include "FDDWorkflow/RecPointReaderSpec.h"

#include "CommonUtils/ConfigurableParam.h"
#include "DetectorsRaw/HBFUtilsInitializer.h"
#include "Framework/CallbacksPolicy.h"
#include "Framework/ConfigParamSpec.h"
#include "Framework/Variant.h"

#include <vector>

using namespace o2::framework;

void customize(std::vector<CallbacksPolicy>& policies)
{
o2::raw::HBFUtilsInitializer::addNewTimeSliceCallback(policies);
}

// we need to add workflow options before including Framework/runDataProcessing
void customize(std::vector<ConfigParamSpec>& workflowOptions)
{
std::vector<ConfigParamSpec> options{
{"disable-mc", VariantType::Bool, false, {"disable MC propagation even if available"}},
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
o2::raw::HBFUtilsInitializer::addConfigOption(options);
std::swap(workflowOptions, options);
}

#include "Framework/runDataProcessing.h"

WorkflowSpec defineDataProcessing(const ConfigContext& ctx)
{
o2::conf::ConfigurableParam::updateFromString(ctx.options().get<std::string>("configKeyValues"));
bool disableMC = ctx.options().get<bool>("disable-mc");
WorkflowSpec specs;
DataProcessorSpec producer = o2::fdd::getFDDRecPointReaderSpec(!disableMC);
specs.push_back(producer);

// configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
o2::raw::HBFUtilsInitializer hbfIni(ctx, specs);
return specs;
}
47 changes: 47 additions & 0 deletions Detectors/FIT/FDD/workflow/src/recpoints-writer-workflow.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2019-2024 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.

/// \file recpoints-writer-workflow.cxx
/// \brief FDD RecPoints writer workflow
///
/// \author Andreas Molander [email protected]

#include "FDDWorkflow/RecPointWriterSpec.h"

#include "CommonUtils/ConfigurableParam.h"
#include "Framework/ConfigParamSpec.h"
#include "Framework/Variant.h"

#include <vector>

using namespace o2::framework;

// we need to add workflow options before including Framework/runDataProcessing
void customize(std::vector<ConfigParamSpec>& workflowOptions)
{
std::vector<ConfigParamSpec> options{
{"disable-mc", VariantType::Bool, false, {"disable MC propagation even if available"}},
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
workflowOptions.insert(workflowOptions.end(), options.begin(), options.end());
}

#include "Framework/runDataProcessing.h"

WorkflowSpec defineDataProcessing(const ConfigContext& ctx)
{
o2::conf::ConfigurableParam::updateFromString(ctx.options().get<std::string>("configKeyValues"));
bool disableMC = ctx.options().get<bool>("disable-mc");

WorkflowSpec specs;
DataProcessorSpec producer = o2::fdd::getFDDRecPointWriterSpec(!disableMC);
specs.push_back(producer);
return specs;
}
5 changes: 5 additions & 0 deletions Detectors/FIT/FT0/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ o2_add_executable(recpoints-reader-workflow
COMPONENT_NAME ft0
PUBLIC_LINK_LIBRARIES O2::FT0Workflow)

o2_add_executable(recpoints-writer-workflow
SOURCES src/recpoints-writer-workflow.cxx
COMPONENT_NAME ft0
PUBLIC_LINK_LIBRARIES O2::FT0Workflow)

o2_add_executable(integrate-cluster-workflow
SOURCES src/cluster-integrator.cxx
COMPONENT_NAME ft0
Expand Down
Loading

0 comments on commit 768f585

Please sign in to comment.