FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixed of FDD digit2raw and digit writer/reader by mbroz84 · Pull Request #5617 · AliceO2Group/AliceO2 · GitHub

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

Filter by extension

Filter by extension .cxx  (7) .h  (7) .txt  (2) All 3 file types selected
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ namespace fdd

struct ChannelData {

int mPMNumber = -1; // PhotoMultiplier number (0 to 16)
float mTime = -1024; // Time of Flight
short mChargeADC = -1024; // ADC sample
short mFEEBits = 0; //Bit information from FEE
uint8_t mPMNumber = -1; // PhotoMultiplier number (0 to 16)
int16_t mTime = -1024; // Time of Flight
int16_t mChargeADC = -1024; // ADC sample
uint8_t mFEEBits = 0; //Bit information from FEE
enum Flags { Integrator = 0x1 << 0,
DoubleEvent = 0x1 << 1,
Event1TimeLost = 0x1 << 2,
Expand All @@ -40,11 +40,11 @@ struct ChannelData {
TimeLost = 0x1 << 8 };

ChannelData() = default;
ChannelData(int channel, float time, short adc, short bits) : mPMNumber(channel), mTime(time), mChargeADC(adc), mFEEBits(bits) {}
ChannelData(uint8_t channel, int time, int adc, uint8_t bits) : mPMNumber(channel), mTime(time), mChargeADC(adc), mFEEBits(bits) {}

void print() const;

ClassDefNV(ChannelData, 2);
ClassDefNV(ChannelData, 3);
};
} // namespace fdd
} // namespace o2
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ struct Triggers {
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
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 = -1024; // average time A side
int16_t timeC = -1024; // average time 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)
{
Expand All @@ -51,12 +51,19 @@ struct Triggers {
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 = -1;
amplA = amplC = -1024;
timeA = timeC = -1024;
nChanA = nChanC = 0;
amplA = amplC = 0;
timeA = timeC = 0;
}
Triggers getTriggers();

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ constexpr short Ntriggers = 5;
constexpr float IntTimeRes = 0.4;
constexpr float PhotoCathodeEfficiency = 0.18;
constexpr float ChargePerADC = 0.6e-12;
constexpr float PMTransitTime = 6.0; // PM response time (corresponds to 1.9 ns rise time)
constexpr float PMTransparency = 0.25; // Transparency of the first dynode of the PM
constexpr float PMNbOfSecElec = 6.0; // Number of secondary electrons emitted from first dynode (per ph.e.)
constexpr float TimePerTDC = 1. / 0.01302; // time conversion from ns to TDC channels
constexpr float PMTransitTime = 6.0; // PM response time (corresponds to 1.9 ns rise time)
constexpr float PMTransparency = 0.25; // Transparency of the first dynode of the PM
constexpr float PMNbOfSecElec = 6.0; // Number of secondary electrons emitted from first dynode (per ph.e.)

constexpr int NTimeBinsPerBC = 256; // number of samples per BC

Expand Down
18 changes: 9 additions & 9 deletions Detectors/FIT/FDD/reconstruction/src/ReadRaw.cxx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,24 @@ void ReadRaw::readRawData(const LookUpTable& lut)
for (int i = 0; i < eventHeader.nGBTWords; ++i) {
mRawFileIn.read(reinterpret_cast<char*>(&eventData[2 * i]), o2::fdd::EventData::PayloadSizeFirstWord);
posPayload += o2::fdd::EventData::PayloadSizeFirstWord;
chData = {Short_t(lut.getChannel(link, int(eventData[2 * i].channelID))),
Float_t(eventData[2 * i].time),
Short_t(eventData[2 * i].charge), 0};
chData = {static_cast<uint8_t>(lut.getChannel(link, int(eventData[2 * i].channelID))),
int(eventData[2 * i].time),
int(eventData[2 * i].charge), 0};
mDigitAccum[intrec].emplace_back(chData);
LOG(DEBUG) << " Read 1st half-word: (PMchannel, globalChannel, Q, T, posPayload) = "
<< std::setw(3) << int(eventData[2 * i].channelID)
<< std::setw(4) << lut.getChannel(link, int(eventData[2 * i].channelID))
<< std::setw(5) << int(eventData[2 * i].charge)
<< std::setw(5) << float(eventData[2 * i].time)
<< std::setw(5) << int(eventData[2 * i].time)
<< std::setw(5) << posPayload;

Short_t channelIdFirstHalfWord = chData.mPMNumber;

mRawFileIn.read(reinterpret_cast<char*>(&eventData[2 * i + 1]), EventData::PayloadSizeSecondWord);
posPayload += o2::fdd::EventData::PayloadSizeSecondWord;
chData = {Short_t(lut.getChannel(link, (eventData[2 * i + 1].channelID))),
Float_t(eventData[2 * i + 1].time),
Short_t(eventData[2 * i + 1].charge), 0};
chData = {static_cast<uint8_t>(lut.getChannel(link, int(eventData[2 * i + 1].channelID))),
int(eventData[2 * i + 1].time),
int(eventData[2 * i + 1].charge), 0};
if (chData.mPMNumber <= channelIdFirstHalfWord) {
// Don't save the second half-word if it is only filled with zeroes (empty-data)
// TODO: Verify if it works correctly with real data from readout
Expand All @@ -109,7 +109,7 @@ void ReadRaw::readRawData(const LookUpTable& lut)
<< std::setw(3) << int(eventData[2 * i + 1].channelID)
<< std::setw(4) << lut.getChannel(link, int(eventData[2 * i + 1].channelID))
<< std::setw(5) << int(eventData[2 * i + 1].charge)
<< std::setw(5) << float(eventData[2 * i + 1].time)
<< std::setw(5) << int(eventData[2 * i + 1].time)
<< std::setw(5) << posPayload;
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ void ReadRaw::writeDigits(const std::string& outputDigitsFilePath)
size_t nStored = 0;
size_t first = chDataVecTree.size();
for (auto& sec : digit.second) {
chDataVecTree.emplace_back(int(sec.mPMNumber), float(sec.mTime), short(sec.mChargeADC), short(0));
chDataVecTree.emplace_back(sec.mPMNumber, sec.mTime, sec.mChargeADC, sec.mFEEBits);
nStored++;
}
chBcVecTree.emplace_back(first, nStored, digit.first, Triggers());
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Digits2Raw
void makeGBTHeader(EventHeader& eventHeader, int link, o2::InteractionRecord const& mIntRecord);
void fillSecondHalfWordAndAddData(int iChannelPerLink, int prevPmLink, const o2::InteractionRecord& ir);
RawEventData mRawEventData;
o2::fdd::Triggers mTriggers;
o2::raw::RawFileWriter mWriter{"FDD"};
bool mOutputPerLink = false;
/////////////////////////////////////////////////
Expand Down
30 changes: 20 additions & 10 deletions Detectors/FIT/FDD/simulation/src/Digitizer.cxx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Digitizer::process(const std::vector<o2::fdd::Hit>& hits,
std::sort(sorted_hits.begin(), sorted_hits.end(), [](o2::fdd::Hit const& a, o2::fdd::Hit const& b) {
return a.GetTrackID() < b.GetTrackID();
});
LOG(INFO) << "Pulse";
//LOG(INFO) << "Pulse";
//Conversion of hits to the analogue pulse shape
for (auto& hit : sorted_hits) {
if (hit.GetTime() > 20e3) {
Expand Down Expand Up @@ -191,18 +191,24 @@ void Digitizer::storeBC(const BCCache& bc,
{
//LOG(INFO) << "Storing BC " << bc;

int first = digitsCh.size();
int first = digitsCh.size(), nStored = 0;
for (int ic = 0; ic < Nchannels; ic++) {
digitsCh.emplace_back(ic, simulateTimeCFD(bc.pulse[ic]), integrateCharge(bc.pulse[ic]), 0);
float chargeADC = integrateCharge(bc.pulse[ic]);
if (chargeADC != 0) {
digitsCh.emplace_back(ic, int(simulateTimeCFD(bc.pulse[ic])), int(chargeADC), std::rand() % (1 << 8));
nStored++;
}
}
//bc.print();

int nBC = digitsBC.size();
digitsBC.emplace_back(first, 16, bc, mTriggers);
digitsTrig.emplace_back(bc, 0, 0, 0, 0, 0);
if (nStored != 0) {
int nBC = digitsBC.size();
digitsBC.emplace_back(first, nStored, bc, mTriggers);
digitsTrig.emplace_back(bc, 0, 0, 0, 0, 0);

for (const auto& lbl : bc.labels) {
labels.addElement(nBC, lbl);
for (const auto& lbl : bc.labels) {
labels.addElement(nBC, lbl);
}
}
}

Expand All @@ -214,7 +220,10 @@ float Digitizer::integrateCharge(const ChannelBCDataF& pulse)
//pulse[iBin] /= ChargePerADC;
chargeADC += pulse[iBin];
}
//saturation if(chargeADC > )chargeADC = ;
//saturation
if (chargeADC > 4095) {
chargeADC = 4095;
}

//LOG(INFO) <<" Charge " << chargeADC;
return std::lround(chargeADC);
Expand All @@ -241,7 +250,8 @@ float Digitizer::simulateTimeCFD(const ChannelBCDataF& pulse)
}
}
//LOG(INFO) <<" Time " << timeCFD;
return timeCFD;
timeCFD *= TimePerTDC; //ns -> counts
return std::lround(timeCFD);
}
//_____________________________________________________________________________
o2::fdd::Digitizer::BCCache& Digitizer::setBCCache(const o2::InteractionRecord& ir)
Expand Down
72 changes: 52 additions & 20 deletions Detectors/FIT/FDD/simulation/src/Digits2Raw.cxx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,23 @@ void Digits2Raw::convertDigits(o2::fdd::Digit bcdigits, gsl::span<const ChannelD
iChannelPerLink = 0;
prevPmLink = nLinkPm;
}
if (pmchannels[ich].mChargeADC != 0) {
LOG(DEBUG) << " Store data for channel: " << ich << " PmLink = " << nLinkPm << " ";
auto& newData = mRawEventData.mEventData[iChannelPerLink];
newData.charge = pmchannels[ich].mChargeADC;
newData.time = pmchannels[ich].mTime;
newData.generateFlags();
newData.channelID = lut.getModChannel(pmchannels[ich].mPMNumber);
iChannelPerLink++;
}
LOG(DEBUG) << " Store data for channel: " << ich << " PmLink = " << nLinkPm << " ";
auto& newData = mRawEventData.mEventData[iChannelPerLink];
newData.charge = pmchannels[ich].mChargeADC;
newData.time = pmchannels[ich].mTime;

newData.numberADC = bool(pmchannels[ich].mFEEBits & ChannelData::Integrator);
newData.isDoubleEvent = bool(pmchannels[ich].mFEEBits & ChannelData::DoubleEvent);
newData.is1TimeLostEvent = bool(pmchannels[ich].mFEEBits & ChannelData::Event1TimeLost);
newData.is2TimeLostEvent = bool(pmchannels[ich].mFEEBits & ChannelData::Event2TimeLost);
newData.isADCinGate = bool(pmchannels[ich].mFEEBits & ChannelData::AdcInGate);
newData.isTimeInfoLate = bool(pmchannels[ich].mFEEBits & ChannelData::TimeTooLate);
newData.isAmpHigh = bool(pmchannels[ich].mFEEBits & ChannelData::AmpTooHigh);
newData.isEventInTVDC = bool(pmchannels[ich].mFEEBits & ChannelData::EventInTrigger);
newData.isTimeInfoLost = bool(pmchannels[ich].mFEEBits & ChannelData::TimeLost);

newData.channelID = lut.getModChannel(pmchannels[ich].mPMNumber);
iChannelPerLink++;
if (ich == nch - 1) {
fillSecondHalfWordAndAddData(iChannelPerLink, prevPmLink, intRecord);
}
Expand All @@ -119,17 +127,41 @@ void Digits2Raw::convertDigits(o2::fdd::Digit bcdigits, gsl::span<const ChannelD
makeGBTHeader(mRawEventData.mEventHeader, sTcmLink, intRecord);
mRawEventData.mEventHeader.nGBTWords = 1;
auto& tcmdata = mRawEventData.mTCMdata;
tcmdata.vertex = 1;
tcmdata.orA = 1;
tcmdata.orC = 0;
tcmdata.sCen = 0;
tcmdata.cen = 0;
tcmdata.nChanA = 0;
tcmdata.nChanC = 0;
tcmdata.amplA = 0;
tcmdata.amplC = 0;
tcmdata.timeA = 0;
tcmdata.timeC = 0;
mTriggers = bcdigits.mTriggers;

float ampA = mTriggers.amplA;
float ampC = mTriggers.amplC;
if (ampA > 131071) {
ampA = 131071; //2^17
}
if (ampC > 131071) {
ampC = 131071; //2^17
}
tcmdata.vertex = mTriggers.getVertex();
tcmdata.orA = mTriggers.getOrA();
tcmdata.orC = mTriggers.getOrC();
tcmdata.sCen = mTriggers.getSCen();
tcmdata.cen = mTriggers.getCen();
tcmdata.nChanA = mTriggers.nChanA;
tcmdata.nChanC = mTriggers.nChanC;
tcmdata.amplA = ampA;
tcmdata.amplC = ampC;
tcmdata.timeA = mTriggers.timeA;
tcmdata.timeC = mTriggers.timeC;
LOG(DEBUG) << " TCM triggers read "
<< " time A " << mTriggers.timeA << " time C " << mTriggers.timeC
<< " amp A " << ampA << " amp C " << ampC
<< " N A " << int(mTriggers.nChanA) << " N C " << int(mTriggers.nChanC)
<< " trig "
<< " ver " << mTriggers.getVertex() << " A " << mTriggers.getOrA() << " C " << mTriggers.getOrC();

LOG(DEBUG) << "TCMdata"
<< " time A " << tcmdata.timeA << " time C " << tcmdata.timeC
<< " amp A " << tcmdata.amplA << " amp C " << tcmdata.amplC
<< " N A " << int(tcmdata.nChanA) << " N C " << int(tcmdata.nChanC)
<< " trig "
<< " ver " << tcmdata.vertex << " A " << tcmdata.orA << " C " << tcmdata.orC
<< " size " << sizeof(tcmdata);

auto data = mRawEventData.to_vector(kTRUE); //for tcm module
uint32_t linkId = uint32_t(sTcmLink);
Expand Down
1 change: 0 additions & 1 deletion Detectors/FIT/FDD/workflow/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

o2_add_library(FDDWorkflow
SOURCES src/DigitReaderSpec.cxx
src/DigitWriterSpec.cxx
src/EntropyEncoderSpec.cxx
src/EntropyDecoderSpec.cxx
src/RecoWorkflow.cxx
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ class DigitReader : public Task
void run(ProcessingContext& pc) final;

private:
bool mUseMC = true; // use MC truth
bool mTrigInp = true; // read trigger inputs
bool mUseMC = true; // use MC truth
o2::header::DataOrigin mOrigin = o2::header::gDataOriginFDD;

std::string mInputFileName = "";
std::string mDigitTreeName = "o2sim";
std::string mDigitBCBranchName = "FDDDigit";
std::string mDigitChBranchName = "FDDDigitCh";
std::string mTriggerBranchName = "TRIGGERINPUT";
std::string mDigitMCTruthBranchName = "FDDDigitLabels";
};

Expand Down
Loading

Back | FazBrowse Home | New Git URL