Skip to content

Commit

Permalink
[FOCAL] Add stand-alone decoder of pad data
Browse files Browse the repository at this point in the history
  • Loading branch information
mfasDa committed Nov 4, 2022
1 parent 38d32b9 commit 29ae8cf
Show file tree
Hide file tree
Showing 12 changed files with 954 additions and 1 deletion.
1 change: 1 addition & 0 deletions DataFormats/Headers/include/Headers/DataHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ constexpr o2::header::DataOrigin gDataOriginTST{"TST"};
constexpr o2::header::DataOrigin gDataOriginACO{"ACO"}; // for bwd compatibility with DD

constexpr o2::header::DataOrigin gDataOriginIT3{"IT3"};
constexpr o2::header::DataOrigin gDataOriginFOC{"FOC"};
constexpr o2::header::DataOrigin gDataOriginTRK{"TRK"};
constexpr o2::header::DataOrigin gDataOriginFT3{"FT3"};
constexpr o2::header::DataOrigin gDataOriginFCT{"FCT"};
Expand Down
5 changes: 4 additions & 1 deletion Detectors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ add_subdirectory(MUON)

add_subdirectory(TPC)

add_subdirectory(FOCAL)

add_subdirectory(GlobalTracking)
add_subdirectory(GlobalTrackingWorkflow)
add_subdirectory(Vertexing)

if(BUILD_ANALYSIS)
add_subdirectory(AOD)
add_subdirectory(AOD)
endif()

add_subdirectory(Filtering)
Expand Down
12 changes: 12 additions & 0 deletions Detectors/FOCAL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.

add_subdirectory(reconstruction)
29 changes: 29 additions & 0 deletions Detectors/FOCAL/reconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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.

o2_add_library(FOCALReconstruction
SOURCES src/PadWord.cxx
src/PadData.cxx
src/PadDecoder.cxx
PUBLIC_LINK_LIBRARIES O2::Headers
AliceO2::InfoLogger
Microsoft.GSL::GSL)

o2_target_root_dictionary(
FOCALReconstruction
HEADERS include/FOCALReconstruction/PadData.h
include/FOCALReconstruction/PadDecoder.h
)

o2_add_executable(rawreader-pad-rootify
COMPONENT_NAME focal
PUBLIC_LINK_LIBRARIES O2::FOCALReconstruction O2::DetectorsRaw ROOT::RIO ROOT::Tree
SOURCES run/rawReaderPadRootify.cxx)
169 changes: 169 additions & 0 deletions Detectors/FOCAL/reconstruction/include/FOCALReconstruction/PadData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// 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 ALICEO2_FOCAL_PADDATA_H
#define ALICEO2_FOCAL_PADDATA_H

#include <array>
#include <exception>
#include <string>
#include <vector>

#include <gsl/span>

#include "Rtypes.h"

#include "FOCALReconstruction/PadWord.h"

namespace o2::focal
{
class ASICData
{
public:
class IndexException : public std::exception
{
public:
IndexException() = default;
IndexException(int index, int maxindex) : std::exception(), mIndex(index), mMaxIndex(maxindex)
{
mMessage = "Invalid index " + std::to_string(mIndex) + ", max " + std::to_string(mMaxIndex);
}
~IndexException() noexcept final = default;

const char* what() const noexcept final
{
return mMessage.data();
}
int getIndex() const { return mIndex; }
int getMaxIndex() const { return mMaxIndex; }

private:
int mIndex;
int mMaxIndex;
std::string mMessage;
};

static constexpr int NCHANNELS = 72;
static constexpr int NHALVES = 2;

ASICData() = default;
ASICData(ASICHeader firstheader, ASICHeader secondheader);

void setFirstHeader(ASICHeader header) { setHeader(header, 0); }
void setSecondHeader(ASICHeader header) { setHeader(header, 1); }
void setHeader(ASICHeader header, int index);

void setChannel(ASICChannel data, int index);
void setChannels(const gsl::span<const ASICChannel> channels);

void setFirstCMN(ASICChannel data) { setCMN(data, 0); }
void setSecondCMN(ASICChannel data) { setCMN(data, 1); }
void setCMN(ASICChannel data, int index);
void setCMNs(const gsl::span<const ASICChannel> channels);

void setFirstCalib(ASICChannel data) { setCalib(data, 0); }
void setSecondCalib(ASICChannel data) { setCalib(data, 1); }
void setCalib(ASICChannel data, int index);
void setCalibs(const gsl::span<const ASICChannel> channels);

ASICHeader getFirstHeader() const { return getHeader(0); }
ASICHeader getSecondHeader() const { return getHeader(1); }
ASICHeader getHeader(int index) const;
gsl::span<const ASICHeader> getHeaders() const;

gsl::span<const ASICChannel> getChannels() const;
ASICChannel getChannel(int index) const;

ASICChannel getFirstCalib() const { return getCalib(0); }
ASICChannel getSecondCalib() const { return getCalib(1); }
ASICChannel getCalib(int index) const;
gsl::span<const ASICChannel> getCalibs() const;

ASICChannel getFirstCMN() const { return getCMN(0); }
ASICChannel getSecondCMN() const { return getCMN(1); }
ASICChannel getCMN(int index) const;
gsl::span<const ASICChannel> getCMNs() const;

void reset();

private:
std::array<ASICHeader, NHALVES> mHeaders;
std::array<ASICChannel, NCHANNELS> mChannels;
std::array<ASICChannel, NHALVES> mCalibChannels;
std::array<ASICChannel, NHALVES> mCMNChannels;

ClassDefNV(ASICData, 1);
};

class ASICContainer
{
public:
ASICContainer() = default;
~ASICContainer() = default;

const ASICData& getASIC() const { return mASIC; }
ASICData& getASIC() { return mASIC; }
gsl::span<const TriggerWord> getTriggerWords() const;
void appendTriggerWords(gsl::span<const TriggerWord> triggerwords);
void appendTriggerWord(TriggerWord triggerword);
void reset();

private:
ASICData mASIC;
std::vector<TriggerWord> mTriggerData;

ClassDefNV(ASICContainer, 1);
};

class PadData
{
public:
class IndexException : public std::exception
{
public:
IndexException() = default;
IndexException(int index, int maxindex) : std::exception(), mIndex(index), mMaxIndex(maxindex)
{
mMessage = "Invalid index " + std::to_string(mIndex) + ", max " + std::to_string(mMaxIndex);
}
~IndexException() noexcept final = default;
const char* what() const noexcept final
{
return mMessage.data();
}

int getIndex() const { return mIndex; }
int getMaxIndex() const { return mMaxIndex; }

private:
int mIndex;
int mMaxIndex;
std::string mMessage;
};
static constexpr int NASICS = 20;

PadData() = default;
~PadData() = default;

const ASICContainer& operator[](int index) const { return getDataForASIC(index); }
ASICContainer& operator[](int index) { return getDataForASIC(index); }

const ASICContainer& getDataForASIC(int index) const;
ASICContainer& getDataForASIC(int index);
void reset();

private:
std::array<ASICContainer, NASICS> mASICs;

ClassDefNV(PadData, 1);
};

} // namespace o2::focal
#endif // ALICEO2_FOCAL_PADDATA_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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 ALICEO2_FOCAL_PADDECODER_H
#define ALICEO2_FOCAL_PADDECODER_H

#include <array>
#include <vector>
#include <functional>
#include <cstdint>

#include "Rtypes.h"

#include <gsl/span>

#include "FOCALReconstruction/PadData.h"

namespace o2::focal
{
class PadDecoder
{
public:
PadDecoder() = default;
~PadDecoder() = default;

void setTriggerWinDur(int windur) { mWin_dur = windur; }

void reset();
void decodeEvent(gsl::span<const PadGBTWord> padpayload);
const PadData& getData() const { return mData; }

protected:
private:
int mWin_dur = 20;
PadData mData;

ClassDefNV(PadDecoder, 1);
};

} // namespace o2::focal

#endif // ALICEO2_FOCAL_PADDECODER_H
Loading

0 comments on commit 29ae8cf

Please sign in to comment.