Skip to content

Commit

Permalink
[FIT] Separate Trigger class and make it common for FT0, FV0 and FDD
Browse files Browse the repository at this point in the history
  • Loading branch information
mslupeck authored Apr 14, 2022
1 parent c395f95 commit 9cccd10
Show file tree
Hide file tree
Showing 32 changed files with 435 additions and 498 deletions.
3 changes: 2 additions & 1 deletion DataFormats/Detectors/FIT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

add_subdirectory(common)
add_subdirectory(FDD)
add_subdirectory(FT0)
add_subdirectory(FV0)
add_subdirectory(common)

29 changes: 15 additions & 14 deletions DataFormats/Detectors/FIT/FDD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
# or submit itself to any jurisdiction.

o2_add_library(DataFormatsFDD
SOURCES src/RawEventData.cxx
src/CTF.cxx
PUBLIC_LINK_LIBRARIES O2::FDDBase
O2::DataFormatsFIT
O2::CommonDataFormat
O2::SimulationDataFormat)
SOURCES src/RawEventData.cxx
src/CTF.cxx
PUBLIC_LINK_LIBRARIES O2::FDDBase
O2::DataFormatsFIT
O2::SimulationDataFormat
O2::CommonDataFormat
)

o2_target_root_dictionary(DataFormatsFDD
HEADERS include/DataFormatsFDD/Digit.h
include/DataFormatsFDD/ChannelData.h
include/DataFormatsFDD/RecPoint.h
include/DataFormatsFDD/MCLabel.h
include/DataFormatsFDD/Hit.h
include/DataFormatsFDD/RawEventData.h
include/DataFormatsFDD/LookUpTable.h
include/DataFormatsFDD/CTF.h)
HEADERS include/DataFormatsFDD/ChannelData.h
include/DataFormatsFDD/Digit.h
include/DataFormatsFDD/MCLabel.h
include/DataFormatsFDD/Hit.h
include/DataFormatsFDD/RecPoint.h
include/DataFormatsFDD/RawEventData.h
include/DataFormatsFDD/LookUpTable.h
include/DataFormatsFDD/CTF.h)
65 changes: 6 additions & 59 deletions DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/Digit.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,76 +12,23 @@
#ifndef ALICEO2_FDD_DIGIT_H
#define ALICEO2_FDD_DIGIT_H

#include "CommonDataFormat/RangeReference.h"
#include "CommonDataFormat/InteractionRecord.h"
#include "CommonDataFormat/RangeReference.h"
#include "CommonDataFormat/TimeStamp.h"
#include "DataFormatsFDD/ChannelData.h"
#include <Framework/Logger.h>
#include <iosfwd>
#include "DataFormatsFIT/Triggers.h"
#include <Rtypes.h>
#include <gsl/span>
#include <bitset>
#include <iostream>
#include <tuple>

namespace o2
{
namespace fdd
{

class ChannelData;

struct Triggers {
enum { bitA,
bitC,
bitVertex,
bitCen,
bitSCen };
uint8_t triggersignals = 0; // FDD trigger signals
int8_t nChanA = 0; // number of fired channels A side
int8_t nChanC = 0; // number of fired channels A side
int32_t amplA = -1024; // sum amplitude A side
int32_t amplC = -1024; // sum amplitude C side
int16_t timeA = 0; // average time A side
int16_t timeC = 0; // average time C side
Triggers() = default;
Triggers(uint8_t signals, int8_t chanA, int8_t chanC, int32_t aamplA, int32_t aamplC, int16_t atimeA, int16_t atimeC)
{
triggersignals = signals;
nChanA = chanA;
nChanC = chanC;
amplA = aamplA;
amplC = aamplC;
timeA = atimeA;
timeC = atimeC;
}

bool getOrA() const { return (triggersignals & (1 << bitA)) != 0; }
bool getOrC() const { return (triggersignals & (1 << bitC)) != 0; }
bool getVertex() const { return (triggersignals & (1 << bitVertex)) != 0; }
bool getCen() const { return (triggersignals & (1 << bitCen)) != 0; }
bool getSCen() const { return (triggersignals & (1 << bitSCen)) != 0; }

void cleanTriggers()
{
triggersignals = 0;
nChanA = nChanC = 0;
amplA = amplC = 0;
timeA = timeC = 0;
}
Triggers getTriggers();
bool operator==(Triggers const& other) const
{
return std::tie(triggersignals, nChanA, nChanC, amplA, amplC, timeA, timeC) ==
std::tie(other.triggersignals, other.nChanA, other.nChanC, other.amplA, other.amplC, other.timeA, other.timeC);
}
void printLog() const
{
LOG(info) << "mTrigger: " << static_cast<uint16_t>(triggersignals);
LOG(info) << "nChanA: " << static_cast<uint16_t>(nChanA) << " | nChanC: " << static_cast<uint16_t>(nChanC);
LOG(info) << "amplA: " << amplA << " | amplC: " << amplC;
LOG(info) << "timeA: " << timeA << " | timeC: " << timeC;
}
ClassDefNV(Triggers, 1);
};
using Triggers = o2::fit::Triggers;

struct DetTrigInput {
static constexpr char sChannelNameDPL[] = "TRIGGERINPUT";
Expand All @@ -106,7 +53,7 @@ struct Digit {
static constexpr char sChannelNameDPL[] = "DIGITSBC";
static constexpr char sDigitName[] = "Digit";
static constexpr char sDigitBranchName[] = "FDDDigit";
o2::dataformats::RangeRefComp<5> ref;
o2::dataformats::RangeReference<int, int> ref{};
Triggers mTriggers; // pattern of triggers in this BC
o2::InteractionRecord mIntRecord; // Interaction record (orbit, bc)
Digit() = default;
Expand Down
2 changes: 0 additions & 2 deletions DataFormats/Detectors/FIT/FDD/src/DataFormatsFDDLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#pragma link C++ class o2::fdd::ChannelData + ;
#pragma link C++ class vector < o2::fdd::Digit> + ;
#pragma link C++ class vector < o2::fdd::ChannelData> + ;
#pragma link C++ class o2::fdd::Triggers + ;
#pragma link C++ class vector < o2::fdd::Triggers> + ;
#pragma link C++ class o2::fdd::DetTrigInput + ;
#pragma link C++ class vector < o2::fdd::DetTrigInput> + ;

Expand Down
47 changes: 24 additions & 23 deletions DataFormats/Detectors/FIT/FT0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,33 @@
# or submit itself to any jurisdiction.

o2_add_library(DataFormatsFT0
SOURCES src/Digit.cxx
SOURCES src/ChannelData.cxx
SOURCES src/RecPoints.cxx
SOURCES src/RawEventData.cxx
SOURCES src/CTF.cxx
SOURCES src/GlobalOffsetsCalibrationObject.cxx
SOURCES src/GlobalOffsetsContainer.cxx
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat
O2::Headers
src/Digit.cxx
src/RecPoints.cxx
src/RawEventData.cxx
src/CTF.cxx
src/GlobalOffsetsCalibrationObject.cxx
src/GlobalOffsetsContainer.cxx
PUBLIC_LINK_LIBRARIES O2::FT0Base
O2::DataFormatsFIT
O2::SimulationDataFormat
O2::CommonDataFormat
O2::Headers
O2::CCDB
O2::DetectorsCalibration
O2::FT0Base
O2::DataFormatsFIT
)
)

o2_target_root_dictionary(DataFormatsFT0
HEADERS include/DataFormatsFT0/Digit.h
include/DataFormatsFT0/ChannelData.h
include/DataFormatsFT0/RecPoints.h
include/DataFormatsFT0/MCLabel.h
include/DataFormatsFT0/HitType.h
include/DataFormatsFT0/RawEventData.h
include/DataFormatsFT0/LookUpTable.h
include/DataFormatsFT0/CTF.h
include/DataFormatsFT0/RecoCalibInfoObject.h
include/DataFormatsFT0/GlobalOffsetsInfoObject.h
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
include/DataFormatsFT0/GlobalOffsetsContainer.h)
HEADERS include/DataFormatsFT0/ChannelData.h
include/DataFormatsFT0/Digit.h
include/DataFormatsFT0/MCLabel.h
include/DataFormatsFT0/HitType.h
include/DataFormatsFT0/RecPoints.h
include/DataFormatsFT0/RawEventData.h
include/DataFormatsFT0/LookUpTable.h
include/DataFormatsFT0/CTF.h
include/DataFormatsFT0/RecoCalibInfoObject.h
include/DataFormatsFT0/GlobalOffsetsInfoObject.h
include/DataFormatsFT0/GlobalOffsetsCalibrationObject.h
include/DataFormatsFT0/GlobalOffsetsContainer.h
)
65 changes: 4 additions & 61 deletions DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/Digit.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,77 +20,19 @@
#include "CommonDataFormat/RangeReference.h"
#include "CommonDataFormat/TimeStamp.h"
#include "DataFormatsFT0/ChannelData.h"
#include "DataFormatsFIT/Triggers.h"
#include <Rtypes.h>
#include <gsl/span>
#include <bitset>
#include <iostream>

#include <tuple>

namespace o2
{
namespace ft0
{
class ChannelData;

struct Triggers {
enum { bitA,
bitC,
bitVertex,
bitCen,
bitSCen,
bitLaser };
uint8_t triggersignals = 0; // T0 trigger signals
int8_t nChanA = 0; // number of fired channels A side
int8_t nChanC = 0; // number of fired channels A side
int32_t amplA = -5000; // sum amplitude A side
int32_t amplC = -5000; // sum amplitude C side
int16_t timeA = -5000; // average time A side
int16_t timeC = -5000; // average time C side
Triggers() = default;
Triggers(uint8_t signals, int8_t chanA, int8_t chanC, int32_t aamplA, int32_t aamplC, int16_t atimeA, int16_t atimeC)
{
triggersignals = signals;
nChanA = chanA;
nChanC = chanC;
amplA = aamplA;
amplC = aamplC;
timeA = atimeA;
timeC = atimeC;
}
bool getOrA() const { return (triggersignals & (1 << bitA)) != 0; }
bool getOrC() const { return (triggersignals & (1 << bitC)) != 0; }
bool getVertex() const { return (triggersignals & (1 << bitVertex)) != 0; }
bool getCen() const { return (triggersignals & (1 << bitCen)) != 0; }
bool getSCen() const { return (triggersignals & (1 << bitSCen)) != 0; }
bool getLaserBit() const { return (triggersignals & (1 << bitLaser)) != 0; }

void setTriggers(Bool_t isA, Bool_t isC, Bool_t isVrtx, Bool_t isCnt, Bool_t isSCnt, int8_t chanA, int8_t chanC, int32_t aamplA,
int32_t aamplC, int16_t atimeA, int16_t atimeC, Bool_t isLaser = kFALSE)
{
triggersignals = (isA << bitA) | (isC << bitC) | (isVrtx << bitVertex) | (isCnt << bitCen) | (isSCnt << bitSCen) | (isLaser << bitLaser);
nChanA = chanA;
nChanC = chanC;
amplA = aamplA;
amplC = aamplC;
timeA = atimeA;
timeC = atimeC;
}
void cleanTriggers()
{
triggersignals = 0;
nChanA = nChanC = 0;
amplA = amplC = -5000;
timeA = timeC = -5000;
}
bool operator==(Triggers const& other) const
{
return std::tie(triggersignals, nChanA, nChanC, amplA, amplC, timeA, timeC) ==
std::tie(other.triggersignals, other.nChanA, other.nChanC, other.amplA, other.amplC, other.timeA, other.timeC);
}
void printLog() const;
ClassDefNV(Triggers, 3);
};
using Triggers = o2::fit::Triggers;

struct DetTrigInput {
static constexpr char sChannelNameDPL[] = "TRIGGERINPUT";
Expand Down Expand Up @@ -137,7 +79,7 @@ struct Digit {
uint16_t getBC() const { return mIntRecord.bc; }
Triggers getTriggers() const { return mTriggers; }
int getEventID() const { return mEventID; }
o2::InteractionRecord getIntRecord() const { return mIntRecord; };
const o2::InteractionRecord& getIntRecord() const { return mIntRecord; };
void setIntRecord(const o2::InteractionRecord& intRec) { mIntRecord = intRec; }
gsl::span<const ChannelData> getBunchChannelData(const gsl::span<const ChannelData> tfdata) const;
DetTrigInput makeTrgInput() const { return DetTrigInput{mIntRecord, mTriggers.getOrA(), mTriggers.getOrC(), mTriggers.getVertex(), mTriggers.getCen(), mTriggers.getSCen()}; }
Expand Down Expand Up @@ -172,6 +114,7 @@ struct TriggersExt {
void printLog() const;
ClassDefNV(TriggersExt, 2);
};

} // namespace ft0
} // namespace o2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RecPoints
o2::InteractionRecord mIntRecord; // Interaction record (orbit, bc)
RecPoints() = default;
RecPoints(const std::array<short, 4>& collisiontime,
int first, int ne, o2::InteractionRecord iRec, o2::ft0::Triggers chTrig)
int first, int ne, o2::InteractionRecord iRec, o2::fit::Triggers chTrig)
: mCollisionTime(collisiontime)
{
ref.setFirstEntry(first);
Expand All @@ -86,8 +86,8 @@ class RecPoints
short getVertex() const { return getCollisionTime(Vertex); }
void setVertex(short vertex) { mCollisionTime[Vertex] = vertex; }

o2::ft0::Triggers getTrigger() const { return mTriggers; }
void setTriggers(o2::ft0::Triggers trig) { mTriggers = trig; }
o2::fit::Triggers getTrigger() const { return mTriggers; }
void setTriggers(o2::fit::Triggers trig) { mTriggers = trig; }

o2::InteractionRecord getInteractionRecord() const { return mIntRecord; };

Expand All @@ -101,7 +101,7 @@ class RecPoints
sDummyCollissionTime,
sDummyCollissionTime,
sDummyCollissionTime};
o2::ft0::Triggers mTriggers; // pattern of triggers in this BC
o2::fit::Triggers mTriggers; // pattern of triggers in this BC

ClassDefNV(RecPoints, 3);
};
Expand Down
2 changes: 0 additions & 2 deletions DataFormats/Detectors/FIT/FT0/src/DataFormatsFT0LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

#pragma link C++ class o2::ft0::Digit + ;
#pragma link C++ class o2::ft0::ChannelData + ;
#pragma link C++ class o2::ft0::Triggers + ;
#pragma link C++ class o2::ft0::DetTrigInput + ;
#pragma link C++ class o2::ft0::TriggersExt + ;
#pragma link C++ class vector < o2::ft0::ChannelData> + ;
#pragma link C++ class vector < o2::ft0::Digit> + ;
#pragma link C++ class vector < o2::ft0::Triggers> + ;
#pragma link C++ class vector < o2::ft0::DetTrigInput> + ;
#pragma link C++ class vector < o2::ft0::TriggersExt> + ;

Expand Down
10 changes: 1 addition & 9 deletions DataFormats/Detectors/FIT/FT0/src/Digit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@

using namespace o2::ft0;

void Triggers::printLog() const
{
LOG(info) << "mTrigger: " << static_cast<uint16_t>(triggersignals);
LOG(info) << "nChanA: " << static_cast<uint16_t>(nChanA) << " | nChanC: " << static_cast<uint16_t>(nChanC);
LOG(info) << "amplA: " << amplA << " | amplC: " << amplC;
LOG(info) << "timeA: " << timeA << " | timeC: " << timeC;
}

gsl::span<const ChannelData> Digit::getBunchChannelData(const gsl::span<const ChannelData> tfdata) const
{
// extract the span of channel data for this bunch from the whole TF data
Expand All @@ -35,7 +27,7 @@ gsl::span<const ChannelData> Digit::getBunchChannelData(const gsl::span<const Ch
void Digit::printStream(std::ostream& stream) const
{
stream << "FT0 Digit: BC " << mIntRecord.bc << " orbit " << mIntRecord.orbit << std::endl;
stream << " A amp " << mTriggers.amplA << " C amp " << mTriggers.amplC << " time A " << mTriggers.timeA << " time C " << mTriggers.timeC << " signals " << int(mTriggers.triggersignals) << std::endl;
mTriggers.print(stream);
}

std::ostream& operator<<(std::ostream& stream, const Digit& digi)
Expand Down
Loading

0 comments on commit 9cccd10

Please sign in to comment.