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
387 changes: 187 additions & 200 deletions DataFormats/Detectors/TOF/include/DataFormatsTOF/RawDataFormat.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -126,32 +126,31 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
auto useMC = !cfgc.options().get<bool>("disable-mc");
auto useCCDB = cfgc.options().get<bool>("use-ccdb");

if(clusterinput){
if (clusterinput) {
LOG(INFO) << "Insert TOF Cluster Reader";
specs.emplace_back(o2::tof::getClusterReaderSpec(useMC));
}
else if (!rawinput) {
} else if (!rawinput) {
// TOF clusterizer
LOG(INFO) << "Insert TOF Digit reader from file";
specs.emplace_back(o2::tof::getDigitReaderSpec(useMC));

if(writeraw){
if (writeraw) {
LOG(INFO) << "Insert TOF Raw writer";
specs.emplace_back(o2::tof::getTOFRawWriterSpec());
}
} else {
LOG(INFO) << "Insert TOF Raw Reader";
specs.emplace_back(o2::tof::getRawReaderSpec());
useMC=0;
useMC = 0;

if(writedigit){
if (writedigit) {
// add TOF digit writer without mc labels
LOG(INFO) << "Insert TOF Digit Writer";
specs.emplace_back(o2::tof::getTOFDigitWriterSpec(0));
}
}

if(! clusterinput && writecluster){
if (!clusterinput && writecluster) {
LOG(INFO) << "Insert TOF Clusterizer";
specs.emplace_back(o2::tof::getTOFClusterizerSpec(useMC, useCCDB));
if (writecluster) {
Expand Down
26 changes: 13 additions & 13 deletions Detectors/TOF/base/include/TOFBase/Digit.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Digit
public:
Digit() = default;

Digit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t label = -1, Int_t triggerorbit=0, Int_t triggerbunch=0);
Digit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t label = -1, Int_t triggerorbit = 0, Int_t triggerbunch = 0);
~Digit() = default;

/// Get global ordering key made of
Expand Down Expand Up @@ -78,11 +78,10 @@ class Digit
void setIsProblematic(bool flag) { mIsProblematic = flag; }
bool isProblematic() const { return mIsProblematic; }

void setTriggerOrbit(int value) {mTriggerOrbit = value;}
int getTriggerOrbit() const {return mTriggerOrbit;}
void setTriggerBunch(int value) {mTriggerBunch = value;}
int getTriggerBunch() const {return mTriggerBunch;}

void setTriggerOrbit(int value) { mTriggerOrbit = value; }
int getTriggerOrbit() const { return mTriggerOrbit; }
void setTriggerBunch(int value) { mTriggerBunch = value; }
int getTriggerBunch() const { return mTriggerBunch; }

private:
friend class boost::serialization::access;
Expand All @@ -96,35 +95,36 @@ class Digit
Int_t mElectronIndex; //!/< index in electronic format
Double_t mCalibratedTime; //!< time of the digits after calibration (not persistent; it will be filled during clusterization)
Bool_t mIsProblematic = false; //!< flag to tell whether the channel of the digit was problemati; not persistent; default = ok
Int_t mTriggerOrbit = 0; //!< orbit id of trigger event
Int_t mTriggerBunch = 0; //!< bunch id of trigger event
Int_t mTriggerOrbit = 0; //!< orbit id of trigger event
Int_t mTriggerBunch = 0; //!< bunch id of trigger event

ClassDefNV(Digit, 1);
};

std::ostream& operator<<(std::ostream& stream, const Digit& dig);

struct ReadoutWindowData {
// 1st entry and number of entries in the full vector of digits
// 1st entry and number of entries in the full vector of digits
// for given trigger (or BC or RO frame)
int firstEntry;
int nEntries;
gsl::span<const Digit> getBunchChannelData(const gsl::span<const Digit> tfdata) const
{
// extract the span of channel data for this readout window from the whole TF data
if(!nEntries) return gsl::span<const Digit>(nullptr, nEntries);
if (!nEntries)
return gsl::span<const Digit>(nullptr, nEntries);
return gsl::span<const Digit>(&tfdata[firstEntry], nEntries);
}

ReadoutWindowData() = default;
ReadoutWindowData(int first, int ne)
{
firstEntry = first;
nEntries = ne ;
nEntries = ne;
}

int first() const {return firstEntry;}
int size() const {return nEntries;}
int first() const { return firstEntry; }
int size() const { return nEntries; }

ClassDefNV(ReadoutWindowData, 1);
};
Expand Down
8 changes: 4 additions & 4 deletions Detectors/TOF/base/include/TOFBase/Geo.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Geo

static constexpr Float_t TDCBIN = o2::constants::lhc::LHCBunchSpacingNS * 1E3 / 1024; ///< TDC bin width [ps]
static constexpr Float_t NTDCBIN_PER_PS = 1. / TDCBIN; ///< number of TDC bins in 1 ns
static constexpr Int_t RATIO_TOT_TDC_BIN = 2; // ratio between TDC and TOT bin sizes
static constexpr Int_t RATIO_TOT_TDC_BIN = 2; // ratio between TDC and TOT bin sizes
static constexpr Float_t TOTBIN = TDCBIN * RATIO_TOT_TDC_BIN; // time-over-threshold bin width [ps]
static constexpr Float_t TOTBIN_NS = TOTBIN * 1E-3; // time-over-threshold bin width [ns]
static constexpr Float_t NTOTBIN_PER_NS = 1000. / TOTBIN; // number of time-over-threshold bin in 1 ns
Expand All @@ -120,10 +120,10 @@ class Geo
static constexpr double BC_IN_WINDOW_INV = 1. / BC_IN_WINDOW;
static constexpr Double_t READOUTWINDOW_INV = 1. / READOUTWINDOW; // Readout window (ns)

static constexpr Int_t READOUTWINDOW_IN_BC = BC_IN_ORBIT / NWINDOW_IN_ORBIT; // round down in case
static constexpr Int_t READOUTWINDOW_IN_BC = BC_IN_ORBIT / NWINDOW_IN_ORBIT; // round down in case
static constexpr Int_t LATENCYWINDOW_IN_BC = 1400; // Latency window in BC (larger than 1/3 orbit 1188 BC)
static constexpr Int_t MATCHINGWINDOW_IN_BC = 1200; // Latency window in BC (larger than 1/3 orbit 1188 BC)
static constexpr Int_t OVERLAP_IN_BC = MATCHINGWINDOW_IN_BC - READOUTWINDOW_IN_BC; // overlap between two readout window in BC
static constexpr Int_t OVERLAP_IN_BC = MATCHINGWINDOW_IN_BC - READOUTWINDOW_IN_BC; // overlap between two readout window in BC
static constexpr Double_t LATENCYWINDOW = LATENCYWINDOW_IN_BC * o2::constants::lhc::LHCBunchSpacingNS; // Latency window in ns
static constexpr Double_t MATCHINGWINDOW = MATCHINGWINDOW_IN_BC * o2::constants::lhc::LHCBunchSpacingNS; // Matching window in ns
static constexpr Double_t WINDOWOVERLAP = MATCHINGWINDOW - READOUTWINDOW; // overlap between two consecutive matchingwindow
Expand Down Expand Up @@ -269,7 +269,7 @@ class Geo
static Int_t getChainFromECH(int ech) { return (ech % 256) >> 7; }
static Int_t getTDCFromECH(int ech) { return (ech % 128) >> 3; }
static Int_t getTDCChFromECH(int ech) { return (ech % 8); }
static Int_t getECHFromIndexes(int crate, int trm, int chain, int tdc, int chan) { return (crate << 12) + ((trm-3) << 8) + (chain << 7) + (tdc << 3) + chan; }
static Int_t getECHFromIndexes(int crate, int trm, int chain, int tdc, int chan) { return (crate << 12) + ((trm - 3) << 8) + (chain << 7) + (tdc << 3) + chan; }
static Int_t getECHFromCH(int chan) { return CHAN_TO_ELCHAN[chan]; }
static Int_t getCHFromECH(int echan) { return ELCHAN_TO_CHAN[echan]; }

Expand Down
2 changes: 1 addition & 1 deletion Detectors/TOF/base/include/TOFBase/Strip.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Strip
/// reset points container
o2::tof::Digit* findDigit(ULong64_t key);

Int_t addDigit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t lbl=0, int triggerorbit=0, int triggerbunch=0); // returns the MC label
Int_t addDigit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t lbl = 0, int triggerorbit = 0, int triggerbunch = 0); // returns the MC label

void fillOutputContainer(std::vector<o2::tof::Digit>& digits);

Expand Down
13 changes: 7 additions & 6 deletions Detectors/TOF/base/include/TOFBase/WindowFiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class WindowFiller

void fillOutputContainer(std::vector<Digit>& digits);
void flushOutputContainer(std::vector<Digit>& digits); // flush all residual buffered data
void setContinuous(bool value=true) {mContinuous=value;}
bool isContinuous() const {return mContinuous;}
void setContinuous(bool value = true) { mContinuous = value; }
bool isContinuous() const { return mContinuous; }

void resizeVectorFutureDigit(int size) {mFutureDigits.resize(size);}
void resizeVectorFutureDigit(int size) { mFutureDigits.resize(size); }

protected:
// info TOF timewindow
Expand Down Expand Up @@ -71,15 +71,16 @@ class WindowFiller
// arrays with digit and MCLabels out of the current readout windows (stored to fill future readout window)
std::vector<Digit> mFutureDigits;

void fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t triggerorbit=0, Int_t triggerbunch=0);
void fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t triggerorbit = 0, Int_t triggerbunch = 0);
// void fillDigitsInStrip(std::vector<Strip>* strips, o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mcTruthContainer, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID);

void checkIfReuseFutureDigits();
void checkIfReuseFutureDigitsRO();

void insertDigitInFuture(int digitInfo0, int digitInfo1, int digitInfo2, int digitInfo3, int lbl=0, int digitInfo4=0, int digitInfo5=0){
void insertDigitInFuture(int digitInfo0, int digitInfo1, int digitInfo2, int digitInfo3, int lbl = 0, int digitInfo4 = 0, int digitInfo5 = 0)
{
mFutureDigits.emplace_back(digitInfo0, digitInfo1, digitInfo2, digitInfo3, lbl, digitInfo4, digitInfo5);
mFutureToBeSorted=true;
mFutureToBeSorted = true;
}

bool isMergable(Digit digit1, Digit digit2)
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TOF/base/src/Geo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void Geo::getPos(Int_t* det, Float_t* pos)
if (mToBeIntit)
Init();

// printf("TOFDBG: %d, %d, %d, %d, %d -> %f %f %f\n", det[0], det[1], det[2], det[3], det[4], mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][0], mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][1], mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][2]);
// printf("TOFDBG: %d, %d, %d, %d, %d -> %f %f %f\n", det[0], det[1], det[2], det[3], det[4], mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][0], mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][1], mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][2]);
pos[0] = mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][0];
pos[1] = mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][1];
pos[2] = mPadPosition[det[0]][det[1]][det[2]][det[3]][det[4]][2];
Expand Down
95 changes: 48 additions & 47 deletions Detectors/TOF/base/src/WindowFiller.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void WindowFiller::fillOutputContainer(std::vector<Digit>& digits)
if (mContinuous) {
int first = mDigitsPerTimeFrame.size();
int ne = digits.size();
ReadoutWindowData info(first,ne);
if(digits.size())
ReadoutWindowData info(first, ne);
if (digits.size())
mDigitsPerTimeFrame.insert(mDigitsPerTimeFrame.end(), digits.begin(), digits.end());
mReadoutWindowData.push_back(info);
}
Expand All @@ -122,14 +122,14 @@ void WindowFiller::fillOutputContainer(std::vector<Digit>& digits)
void WindowFiller::flushOutputContainer(std::vector<Digit>& digits)
{ // flush all residual buffered data
// TO be implemented

printf("flushOutputContainer\n");
for (Int_t i = 0; i < MAXWINDOWS; i++){
int n=0;
for(int j=0; j < mStrips[i].size();j++)
for (Int_t i = 0; i < MAXWINDOWS; i++) {
int n = 0;
for (int j = 0; j < mStrips[i].size(); j++)
n += ((mStrips[i])[j]).getNumberOfDigits();

printf("ro #%d: digits = %d\n",i,n);
printf("ro #%d: digits = %d\n", i, n);
}

printf("Future digits = %d\n", mFutureDigits.size());
Expand All @@ -152,20 +152,20 @@ void WindowFiller::flushOutputContainer(std::vector<Digit>& digits)
for (Int_t i = 0; i < MAXWINDOWS; i++) {
fillOutputContainer(digits); // fill last readout windows
}

}
}
//______________________________________________________________________
void WindowFiller::checkIfReuseFutureDigits()
{
if(! mFutureDigits.size()) return;
if (!mFutureDigits.size())
return;

// check if digits stored very far in future match the new readout windows currently available
if(mFutureToBeSorted){
if (mFutureToBeSorted) {
// sort digit in descending BC order: kept last as first
std::sort(mFutureDigits.begin(), mFutureDigits.end(),
[](o2::tof::Digit a, o2::tof::Digit b) {return a.getBC() > b.getBC();});
mFutureToBeSorted=false;
[](o2::tof::Digit a, o2::tof::Digit b) { return a.getBC() > b.getBC(); });
mFutureToBeSorted = false;
}

int idigit = mFutureDigits.size() - 1;
Expand All @@ -174,38 +174,37 @@ void WindowFiller::checkIfReuseFutureDigits()

for (std::vector<Digit>::reverse_iterator digit = mFutureDigits.rbegin(); digit != mFutureDigits.rend(); ++digit) {

if(digit->getBC() > bclimit) break;
if (digit->getBC() > bclimit)
break;

double timestamp = digit->getBC() * Geo::BC_TIME + digit->getTDC() * Geo::TDCBIN * 1E-3; // in ns
int isnext = Int_t(timestamp * Geo::READOUTWINDOW_INV) - (mReadoutWindowCurrent + 1); // to be replaced with uncalibrated time
if (isnext < 0){ // we jump too ahead in future, digit will be not stored
double timestamp = digit->getBC() * Geo::BC_TIME + digit->getTDC() * Geo::TDCBIN * 1E-3; // in ns
int isnext = Int_t(timestamp * Geo::READOUTWINDOW_INV) - (mReadoutWindowCurrent + 1); // to be replaced with uncalibrated time

if (isnext < 0) { // we jump too ahead in future, digit will be not stored
LOG(INFO) << "Digit lost because we jump too ahead in future. Current RO window=" << isnext << "\n";

// remove digit from array in the future
int labelremoved = digit->getLabel();
mFutureDigits.erase(mFutureDigits.begin() + idigit);

idigit--;

continue;
}



if (isnext < MAXWINDOWS - 1) { // move from digit buffer array to the proper window
std::vector<Strip>* strips = mStripsCurrent;

if (isnext) {
strips = mStripsNext[isnext - 1];
strips = mStripsNext[isnext - 1];
}

fillDigitsInStrip(strips, digit->getChannel(), digit->getTDC(), digit->getTOT(), digit->getBC(), digit->getChannel() / Geo::NPADS);

// int labelremoved = digit->getLabel();
mFutureDigits.erase(mFutureDigits.begin() + idigit);

}
else{
} else {
bclimit = digit->getBC();
}
idigit--; // go back to the next position in the reverse iterator
Expand All @@ -214,18 +213,21 @@ void WindowFiller::checkIfReuseFutureDigits()
//______________________________________________________________________
void WindowFiller::checkIfReuseFutureDigitsRO() // the same but using readout info information from raw
{
if(! mFutureDigits.size()) return;
if (!mFutureDigits.size())
return;

// check if digits stored very far in future match the new readout windows currently available
if(mFutureToBeSorted){
if (mFutureToBeSorted) {
// sort digit in descending BC order: kept last as first
std::sort(mFutureDigits.begin(), mFutureDigits.end(),
[](o2::tof::Digit a, o2::tof::Digit b) {
if(a.getTriggerOrbit() != b.getTriggerOrbit()) return a.getTriggerOrbit() > b.getTriggerOrbit();
if(a.getTriggerBunch() != b.getTriggerBunch()) return a.getTriggerBunch() > b.getTriggerBunch();
return a.getBC() > b.getBC();
});
mFutureToBeSorted=false;
[](o2::tof::Digit a, o2::tof::Digit b) {
if (a.getTriggerOrbit() != b.getTriggerOrbit())
return a.getTriggerOrbit() > b.getTriggerOrbit();
if (a.getTriggerBunch() != b.getTriggerBunch())
return a.getTriggerBunch() > b.getTriggerBunch();
return a.getBC() > b.getBC();
});
mFutureToBeSorted = false;
}

int idigit = mFutureDigits.size() - 1;
Expand All @@ -234,40 +236,39 @@ void WindowFiller::checkIfReuseFutureDigitsRO() // the same but using readout in

for (std::vector<Digit>::reverse_iterator digit = mFutureDigits.rbegin(); digit != mFutureDigits.rend(); ++digit) {

int row = (digit->getTriggerOrbit() - mFirstOrbit) *Geo::BC_IN_ORBIT + (digit->getTriggerBunch() - mFirstBunch) + 100; // N bunch id of the trigger from timeframe start + 100 bunches
int row = (digit->getTriggerOrbit() - mFirstOrbit) * Geo::BC_IN_ORBIT + (digit->getTriggerBunch() - mFirstBunch) + 100; // N bunch id of the trigger from timeframe start + 100 bunches

row *= Geo::BC_IN_WINDOW_INV;

if(row > rolimit) break;
if (row > rolimit)
break;

int isnext = row - mReadoutWindowCurrent;
if (isnext < 0){ // we jump too ahead in future, digit will be not stored

if (isnext < 0) { // we jump too ahead in future, digit will be not stored
LOG(INFO) << "Digit lost because we jump too ahead in future. Current RO window=" << isnext << "\n";

// remove digit from array in the future
int labelremoved = digit->getLabel();
mFutureDigits.erase(mFutureDigits.begin() + idigit);

idigit--;

continue;
}



if (isnext < MAXWINDOWS - 1) { // move from digit buffer array to the proper window
std::vector<Strip>* strips = mStripsCurrent;

if (isnext) {
strips = mStripsNext[isnext - 1];
strips = mStripsNext[isnext - 1];
}

fillDigitsInStrip(strips, digit->getChannel(), digit->getTDC(), digit->getTOT(), digit->getBC(), digit->getChannel() / Geo::NPADS);

// int labelremoved = digit->getLabel();
mFutureDigits.erase(mFutureDigits.begin() + idigit);
}
else{
} else {
rolimit = row;
}
idigit--; // go back to the next position in the reverse iterator
Expand Down
4 changes: 2 additions & 2 deletions Detectors/TOF/calibration/include/TOFCalibration/CalibTOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class CalibTOF

// Data members

bool mInitDone = false; ///< flag init already done
bool mFillCCDB = false; ///< flag init already doneto decide whether to fill or not the CCDB
bool mInitDone = false; ///< flag init already done
bool mFillCCDB = false; ///< flag init already doneto decide whether to fill or not the CCDB
std::string mCCDBpath = "http://ccdb-test.cern.ch:8080"; ///< path to CCDB

///========== Parameters to be set externally, e.g. from CCDB ====================
Expand Down
Loading