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
21 changes: 21 additions & 0 deletions DataFormats/Detectors/FIT/FDD/include/DataFormatsFDD/Digit.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace fdd
class ChannelData;

struct Triggers {
enum { bitA,
bitC,
bitVertex,
bitCen,
bitSCen };
uint8_t triggersignals = 0; // FDD trigger signals
int8_t nChanA = -1; // number of fired channels A side
int8_t nChanC = -1; // number of fired channels A side
Expand Down Expand Up @@ -58,6 +63,22 @@ struct Triggers {
ClassDefNV(Triggers, 1);
};

struct DetTrigInput {
o2::InteractionRecord mIntRecord; // bc/orbit of the intpur
std::bitset<5> mInputs; // pattern of inputs.
DetTrigInput() = default;
DetTrigInput(const o2::InteractionRecord& iRec, Bool_t isA, Bool_t isC, Bool_t isVrtx, Bool_t isCnt, Bool_t isSCnt)
: mIntRecord(iRec),
mInputs((isA << Triggers::bitA) |
(isC << Triggers::bitC) |
(isVrtx << Triggers::bitVertex) |
(isCnt << Triggers::bitCen) |
(isSCnt << Triggers::bitSCen))
{
}
ClassDefNV(DetTrigInput, 1);
};

struct Digit {
o2::dataformats::RangeRefComp<5> ref;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class LookUpTable
}
}

static o2::fdd::LookUpTable linear()
{
return o2::fdd::LookUpTable{1};
}

private:
std::vector<Topo> mTopoVector; // iterator of each vector element gives the global channel number
std::vector<int> mInvTopo; // each element is an iterator of mTopoVector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define ALICEO2_FDD_RAWEVENTDATA_H_

#include "FDDBase/Constants.h"
#include "DataFormatsFDD/Digit.h"
#include "DataFormatsFDD/ChannelData.h"
#include "Headers/RAWDataHeader.h"
#include "DataFormatsFDD/LookUpTable.h"
Expand All @@ -31,21 +32,34 @@ namespace o2
namespace fdd
{
struct EventHeader {
static constexpr int PayloadSize = 16;
static constexpr size_t PayloadSize = 16; //should be equal to 10
static constexpr size_t PayloadPerGBTword = 16; //should be equal to 10
static constexpr int MinNelements = 1;
static constexpr int MaxNelements = 1;
union {
uint64_t word[2] = {};
struct {
uint64_t bc : 12;
uint64_t orbit : 32;
uint64_t reservedField1 : 20;
uint64_t phase : 3;
uint64_t errorPhase : 1;
uint64_t reservedField1 : 16;
uint64_t reservedField2 : 8;
uint64_t nGBTWords : 4;
uint64_t startDescriptor : 4;
uint64_t reservedField3 : 48;
};
};
InteractionRecord getIntRec() const { return InteractionRecord{(uint16_t)bc, (uint32_t)orbit}; }
};
struct EventData {
static constexpr size_t PayloadSize = 5;
static constexpr size_t PayloadPerGBTword = 10;
static constexpr int MinNelements = 1; //additional static field
static constexpr int MaxNelements = 12;
//
static constexpr int BitFlagPos = 25; // position of first bit flag(numberADC)

union {
uint64_t word = {0};
struct {
Expand Down Expand Up @@ -79,10 +93,17 @@ struct EventData {
isEventInTVDC = 1;
isTimeInfoLost = 0;
}
uint8_t getFlagWord() const
{
return uint8_t(word >> BitFlagPos);
}
};

struct TCMdata {
static constexpr int PayloadSize = 16;
static constexpr size_t PayloadSize = 16; //should be equal to 10
static constexpr size_t PayloadPerGBTword = 16; //should be equal to 10
static constexpr int MinNelements = 1;
static constexpr int MaxNelements = 1;
union {
uint64_t word[2] = {0};
struct {
Expand All @@ -101,6 +122,20 @@ struct TCMdata {
reservedField2 : 46;
};
};
void fillTrigger(Triggers& trg)
{
trg.triggersignals = ((bool)orA << Triggers::bitA) |
((bool)orC << Triggers::bitC) |
((bool)vertex << Triggers::bitVertex) |
((bool)cen << Triggers::bitCen) |
((bool)sCen << Triggers::bitSCen);
trg.nChanA = (int8_t)nChanA;
trg.nChanC = (int8_t)nChanC;
trg.amplA = (int32_t)amplA;
trg.amplC = (int32_t)amplC;
trg.timeA = (int16_t)timeA;
trg.timeC = (int16_t)timeC;
}
};

class RawEventData
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/Detectors/FIT/FDD/src/DataFormatsFDDLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#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> + ;

#pragma link C++ class o2::fdd::MCLabel + ;
#pragma link C++ class vector < o2::fdd::MCLabel> + ;
Expand Down
1 change: 1 addition & 0 deletions Detectors/FIT/FDD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# submit itself to any jurisdiction.

add_subdirectory(base)
add_subdirectory(raw)
add_subdirectory(simulation)
add_subdirectory(reconstruction)
add_subdirectory(workflow)
13 changes: 13 additions & 0 deletions Detectors/FIT/FDD/raw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Copyright CERN and copyright holders of ALICE O2.This software is distributed
#under the terms of the GNU General Public License v3(GPL Version 3), copied
#verbatim in the file "COPYING".
#
#See http: //alice-o2.web.cern.ch/license for full licensing information.
#
#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(FDDRaw
SOURCES src/DataBlockFDD.cxx src/DigitBlockFDD.cxx src/RawReaderFDDBase.cxx
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat O2::Headers O2::DataFormatsFDD O2::FITRaw)
88 changes: 88 additions & 0 deletions Detectors/FIT/FDD/raw/include/FDDRaw/DataBlockFDD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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 DataBlockFDD.h class for RAW data format data blocks at FDD
//
// Artur.Furs
// afurs@cern.ch
//

#ifndef ALICEO2_FIT_DATABLOCKFDD_H_
#define ALICEO2_FIT_DATABLOCKFDD_H_
#include <iostream>
#include <Rtypes.h>
#include <DataFormatsFDD/RawEventData.h>
#include <FITRaw/DataBlockBase.h>

#include <gsl/span>
#include <iostream>
#include <cassert>
using namespace o2::fit;
namespace o2
{
namespace fdd
{
using RawHeaderPM = o2::fdd::EventHeader;
using RawDataPM = o2::fdd::EventData;
using RawHeaderTCM = o2::fdd::EventHeader;
using RawDataTCM = o2::fdd::TCMdata;

using namespace std;

//FDD DATA BLOCK DEFINITIONS

//standard data block from PM
class DataBlockPM : public DataBlockBase<DataBlockPM, RawHeaderPM, RawDataPM>
{
public:
DataBlockPM() = default;
DataBlockPM(const DataBlockPM&) = default;
void deserialize(gsl::span<const uint8_t> srcBytes, size_t& srcByteShift)
{
DataBlockWrapper<RawHeaderPM>::deserialize(srcBytes, DataBlockWrapper<RawHeaderPM>::MaxNwords, srcByteShift);
DataBlockWrapper<RawDataPM>::deserialize(srcBytes, DataBlockWrapper<RawHeaderPM>::mData[0].nGBTWords, srcByteShift);
}
//Custom sanity checking for current deserialized block
// put here code for raw data checking
void sanityCheck(bool& flag)
{
if (DataBlockWrapper<RawDataPM>::mNelements == 0) {
flag = false;
return;
}
if (DataBlockWrapper<RawDataPM>::mNelements % 2 == 0 && DataBlockWrapper<RawDataPM>::mData[DataBlockWrapper<RawDataPM>::mNelements - 1].channelID == 0) {
DataBlockWrapper<RawDataPM>::mNelements--; //in case of half GBT-word filling
}
//TODO, Descriptor checking, Channel range
}
};

//standard data block from TCM
class DataBlockTCM : public DataBlockBase<DataBlockTCM, RawHeaderTCM, RawDataTCM>
{
public:
DataBlockTCM() = default;
DataBlockTCM(const DataBlockTCM&) = default;
void deserialize(gsl::span<const uint8_t> srcBytes, size_t& srcByteShift)
{
DataBlockWrapper<RawHeaderTCM>::deserialize(srcBytes, DataBlockWrapper<RawHeaderTCM>::MaxNwords, srcByteShift);
DataBlockWrapper<RawDataTCM>::deserialize(srcBytes, DataBlockWrapper<RawHeaderTCM>::mData[0].nGBTWords, srcByteShift);
}
//Custom sanity checking for current deserialized block
// put here code for raw data checking
void sanityCheck(bool& flag)
{
//TODO, Descriptor checking
}
};

} // namespace fdd
} // namespace o2
#endif
133 changes: 133 additions & 0 deletions Detectors/FIT/FDD/raw/include/FDDRaw/DigitBlockFDD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// 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 DigitBlockFDD.h class for proccessing RAW data into Digits
//
// Artur.Furs
// afurs@cern.ch
// TODO:
// traites for DataBlocks
// check if the EventID filling is correct

#ifndef ALICEO2_FIT_DIGITBLOCKFDD_H_
#define ALICEO2_FIT_DIGITBLOCKFDD_H_
#include <iostream>
#include <vector>
#include <algorithm>
#include <Rtypes.h>
#include "FDDRaw/DataBlockFDD.h"
#include "FITRaw/DigitBlockBase.h"

#include <CommonDataFormat/InteractionRecord.h>
#include "DataFormatsFDD/Digit.h"
#include "DataFormatsFDD/ChannelData.h"
#include "DataFormatsFDD/LookUpTable.h"

#include <boost/mpl/vector.hpp>
#include <boost/mpl/contains.hpp>

#include <gsl/span>

using namespace o2::fit;

namespace o2
{
namespace fdd
{
//Normal data taking mode
class DigitBlockFDD : public DigitBlockBase<DigitBlockFDD>
{
public:
typedef DigitBlockBase<DigitBlockFDD> DigitBlockBaseType;
DigitBlockFDD(o2::InteractionRecord intRec) { setIntRec(intRec); }
DigitBlockFDD() = default;
DigitBlockFDD(const DigitBlockFDD& other) = default;
~DigitBlockFDD() = default;
void setIntRec(o2::InteractionRecord intRec) { mDigit.mIntRecord = intRec; }
Digit mDigit;
std::vector<ChannelData> mVecChannelData;
static o2::fdd::LookUpTable sLookupTable;
static int sEventID;

template <class DataBlockType>
void processDigits(DataBlockType& dataBlock, int linkID)
{
if constexpr (std::is_same<DataBlockType, DataBlockPM>::value) { //Filling data from PM
for (int iEventData = 0; iEventData < dataBlock.DataBlockWrapper<RawDataPM>::mNelements; iEventData++) {
mVecChannelData.emplace_back(int(sLookupTable.getChannel(linkID, dataBlock.DataBlockWrapper<RawDataPM>::mData[iEventData].channelID)),
int(dataBlock.DataBlockWrapper<RawDataPM>::mData[iEventData].time),
int(dataBlock.DataBlockWrapper<RawDataPM>::mData[iEventData].charge),
dataBlock.DataBlockWrapper<RawDataPM>::mData[iEventData].getFlagWord());
}
} else if constexpr (std::is_same<DataBlockType, DataBlockTCM>::value) { //Filling data from TCM
dataBlock.DataBlockWrapper<RawDataTCM>::mData[0].fillTrigger(mDigit.mTriggers);
}
}
void getDigits(std::vector<Digit>& vecDigits, std::vector<ChannelData>& vecChannelData)
{
//last digit filling
mDigit.ref.set(vecChannelData.size(), mVecChannelData.size());
//mDigit.mEventID = sEventID;
//
vecDigits.push_back(std::move(mDigit));
std::move(mVecChannelData.begin(), mVecChannelData.end(), std::back_inserter(vecChannelData));
mVecChannelData.clear();

sEventID++; //Increasing static eventID. After each poping of the data, it will increase
}
void print() const
{
std::cout << "\n______________DIGIT DATA____________";
std::cout << std::hex;
std::cout << "\nBC: " << mDigit.mIntRecord.bc << "| ORBIT: " << mDigit.mIntRecord.orbit;
std::cout << "\nRef first: " << mDigit.ref.getFirstEntry() << "| Ref entries: " << mDigit.ref.getEntries();
std::cout << "\nmTrigger: " << static_cast<uint16_t>(mDigit.mTriggers.triggersignals);
std::cout << "\nnChanA: " << static_cast<uint16_t>(mDigit.mTriggers.nChanA) << " | nChanC: " << static_cast<uint16_t>(mDigit.mTriggers.nChanC);
std::cout << "\namplA: " << mDigit.mTriggers.amplA << " | amplC: " << mDigit.mTriggers.amplC;
std::cout << "\ntimeA: " << mDigit.mTriggers.timeA << " | timeC: " << mDigit.mTriggers.timeC;

std::cout << "\n______________CHANNEL DATA____________\n";
std::cout << "\nN channel: " << mVecChannelData.size();
for (const auto& chData : mVecChannelData) {
std::cout << "\nChId: " << static_cast<uint16_t>(chData.mPMNumber) << " | ChainQTC:" << static_cast<uint16_t>(chData.mFEEBits) << " | CFDTime: " << chData.mTime << " | QTCAmpl: " << chData.mChargeADC;
}
std::cout << std::dec;
std::cout << "\n";
LOG(INFO) << "______________________________________";
}

static void print(std::vector<Digit>& vecDigit, std::vector<ChannelData>& vecChannelData)
{
for (const auto& digit : vecDigit) {
std::cout << "\n______________DIGIT DATA____________";
std::cout << std::hex;
std::cout << "\nBC: " << digit.mIntRecord.bc << "| ORBIT: " << digit.mIntRecord.orbit << " | EventID: "
<< "digit.mEventID";
std::cout << "\nRef first: " << digit.ref.getFirstEntry() << "| Ref entries: " << digit.ref.getEntries();
std::cout << "\nmTrigger: " << static_cast<uint16_t>(digit.mTriggers.triggersignals);
std::cout << "\nnChanA: " << static_cast<uint16_t>(digit.mTriggers.nChanA) << " | nChanC: " << static_cast<uint16_t>(digit.mTriggers.nChanC);
std::cout << "\namplA: " << digit.mTriggers.amplA << " | amplC: " << digit.mTriggers.amplC;
std::cout << "\ntimeA: " << digit.mTriggers.timeA << " | timeC: " << digit.mTriggers.timeC;

std::cout << "\n______________CHANNEL DATA____________\n";
for (int iChData = digit.ref.getFirstEntry(); iChData < digit.ref.getFirstEntry() + digit.ref.getEntries(); iChData++) {

std::cout << "\nChId: " << static_cast<uint16_t>(vecChannelData[iChData].mPMNumber) << " | ChainQTC:" << static_cast<uint16_t>(vecChannelData[iChData].mFEEBits)
<< " | CFDTime: " << vecChannelData[iChData].mTime << " | QTCAmpl: " << vecChannelData[iChData].mChargeADC;
}
std::cout << std::dec;
std::cout << "\n______________________________________\n";
}
}
};

} // namespace fdd
} // namespace o2
#endif
Loading