Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ struct AlmiraParam : public o2::conf::ConfigurableParamHelper<AlmiraParam> {
static constexpr int kDefROFLengthInBC = 16; ///< default ROF length in BC (16 clock cycles of 1 BC for VD)

int roFrameLengthInBCPerLayer[kNLayers] = {0}; ///< ROF length in BC per layer
float strobeDelayPerLayer[kNLayers] = {0}; ///< strobe delay in ns per layer
float strobeLengthContPerLayer[kNLayers] = {0}; ///< strobe length in ns per layer
int roFrameBiasInBCPerLayer[kNLayers] = {0}; ///< ROF start bias in BC per layer
int roFrameDelayInBCPerLayer[kNLayers] = {0}; ///< extra ROF delay in BC per layer
float clockPeriodPerLayer[kNLayers] = {0}; ///< ALMIRA clock period in ns per layer (timestamp fine granularity), 0 = default (1 BC VD, 4 BC ML/OT/disks)
Expand Down Expand Up @@ -84,8 +82,6 @@ struct AlmiraParam : public o2::conf::ConfigurableParamHelper<AlmiraParam> {
return kDefROFLengthInBC;
}
}
float getStrobeDelay(int layer) const { return strobeDelayPerLayer[layer]; }
float getStrobeLengthCont(int layer) const { return strobeLengthContPerLayer[layer]; }
int getROFBiasInBC(int layer) const { return roFrameBiasInBCPerLayer[layer]; }
int getROFDelayInBC(int layer) const { return roFrameDelayInBCPerLayer[layer]; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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.

/// \file AlmiraSignal.h
/// \brief Charge dependence of the ALMIRA pixel front-end signal: time walk and time over threshold

#ifndef ALICEO2_TRKFT3_ALMIRASIGNAL_H
#define ALICEO2_TRKFT3_ALMIRASIGNAL_H

#include <cmath>
#include <cstdio>

namespace o2
{
namespace trkft3
{

/// @class AlmiraSignal
/// @brief Time walk and time over threshold of the ALMIRA pixel front-end as a function of the collected charge.
/// Both are parametrised as f(Q) = a * (1 - exp(-Q / b)) + c, with Q the collected charge in electrons.
/// The fit parameters are kept in seconds (as in the original fit), the getters return ns.
class AlmiraSignal
{
public:
/// time walk: delay of the leading edge wrt the charge arrival, in ns
float getTimeWalk(float nEle) const { return eval(nEle, TWa, TWb, TWc); }
/// time over threshold, in ns
float getToT(float nEle) const { return eval(nEle, ToTa, ToTb, ToTc); }

void print() const
{
printf(" f(Q) = a * (1 - exp(-Q / b)) + c, Q in electrons\n");
printf(" time walk : a = %.3e s, b = %.3e e, c = %.3e s\n", TWa, TWb, TWc);
printf(" time over threshold: a = %.3e s, b = %.3e e, c = %.3e s\n", ToTa, ToTb, ToTc);
}

private:
static float eval(float nEle, float a, float b, float c) { return (a * (1.f - std::exp(-nEle / b)) + c) * kSecToNS; }

static constexpr float kSecToNS = 1.e9f;

// parametrization parameters
static constexpr float TWa = -8.51e-07f; ///< s (± 2.56e-08)
static constexpr float TWb = 7.35e+01f; ///< electrons (± 1.67e+00)
static constexpr float TWc = 8.94e-07f; ///< s (± 2.61e-08)
static constexpr float ToTa = 1.17e-05f; ///< s (± 2.68e-08)
static constexpr float ToTb = 9.44e+02f; ///< electrons (± 6.06e+00)
static constexpr float ToTc = -3.15e-08f; ///< s (± 1.57e-08)
};

} // namespace trkft3
} // namespace o2

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@
#include "TRKFT3Simulation/DigiParams.h"
#include <fairlogger/Logger.h>
#include <TRandom.h>
#include <unordered_map>
#include <vector>

namespace o2::trkft3
{

/// State of the analog signal of a pixel, surviving the flush of the ROFs (edge detection)
struct PixelState {
double tStart = 0.; ///< signal start (first contribution), absolute time in ns
double tEnd = 0.; ///< tStart + ToT(charge), absolute time in ns
int charge = 0; ///< total charge of the signal (N electrons)
std::vector<o2::MCCompLabel> labels; ///< labels of the contributions up to the threshold crossing
uint32_t lastDigitROF = ~0u; ///< ROF of the last digit written (one digit per pixel per ROF)
bool pending = false; ///< a digit is waiting to be written in a later ROF
uint32_t pendingROF = 0; ///< ROF of the pending digit (ROF of its leading edge)
float pendingToA = 0.f; ///< leading edge of the pending digit w.r.t. pendingROF start (ns)
int pendingCharge = 0; ///< charge of the pending digit
};

/// @class ChipDigitsContainer
/// @brief Container for simulated points connected to a given chip

Expand All @@ -45,8 +60,9 @@ class ChipDigitsContainer

o2::trkft3::PreDigit* findDigit(ULong64_t key);
void addDigit(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col, int charge, o2::MCCompLabel lbl, float toa = 0.f);
void addContribution(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col, int charge, o2::MCCompLabel lbl, float toa, std::vector<o2::trkft3::PreDigitContribution>& extra);
template <int DetID>
void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer, float rofLengthNS);
void addNoise(UInt_t rof, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer, float rofLengthNS, std::vector<o2::trkft3::PreDigitContribution>& extra);

/// Get global ordering key made of readout frame, column and row
static ULong64_t getOrderingKey(UInt_t roframe, UShort_t row, UShort_t col)
Expand All @@ -57,12 +73,17 @@ class ChipDigitsContainer
bool isDisabled() const { return mDisabled; }
void disable(bool v) { mDisabled = v; }

std::unordered_map<uint32_t, PixelState>& getPixelStates() { return mPixelStates; }
/// Key of the pixel in the pixel state map
static uint32_t getPixelKey(UShort_t row, UShort_t col) { return (static_cast<uint32_t>(col) << 16) | row; }

protected:
UShort_t mChipIndex = 0; ///< chip index
bool mDisabled = false;
const o2::itsmft::NoiseMap* mNoiseMap = nullptr;
const o2::itsmft::NoiseMap* mDeadChanMap = nullptr;
std::map<ULong64_t, o2::trkft3::PreDigit> mDigits; ///< Map of fired pixels, possibly in multiple frames
std::map<ULong64_t, o2::trkft3::PreDigit> mDigits; ///< Map of fired pixels, possibly in multiple frames
std::unordered_map<uint32_t, PixelState> mPixelStates; //! pixel signal states, surviving the flush

ClassDefNV(ChipDigitsContainer, 2);
};
Expand All @@ -82,10 +103,28 @@ inline void ChipDigitsContainer::addDigit(ULong64_t key, UInt_t roframe, UShort_
mDigits.emplace(key, o2::trkft3::PreDigit(roframe, row, col, charge, lbl, toa));
}

//_______________________________________________________________________
inline void ChipDigitsContainer::addContribution(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col, int charge, o2::MCCompLabel lbl, float toa, std::vector<o2::trkft3::PreDigitContribution>& extra)
{
// add a contribution to the pixel in the given ROF: the first one is stored in the PreDigit,
// the following ones at the end of its chain in the extra buffer of that ROF
auto* pd = findDigit(key);
if (!pd) {
addDigit(key, roframe, row, col, charge, lbl, toa);
return;
}
int* nxt = &pd->contrib.next; // "next" index of the last element of the chain
while (*nxt >= 0) {
nxt = &extra[*nxt].next;
}
*nxt = extra.size(); // index set before emplace_back, which may reallocate the vector
extra.emplace_back(lbl, toa, charge);
}

} // namespace o2::trkft3

template <int DetID>
void o2::trkft3::ChipDigitsContainer::addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer, float rofLengthNS)
void o2::trkft3::ChipDigitsContainer::addNoise(UInt_t rof, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer, float rofLengthNS, std::vector<o2::trkft3::PreDigitContribution>& extra)
{
UInt_t row = 0;
UInt_t col = 0;
Expand All @@ -107,24 +146,22 @@ void o2::trkft3::ChipDigitsContainer::addNoise(UInt_t rofMin, UInt_t rofMax, con

LOG(debug) << "Adding noise for chip " << mChipIndex << " with mean " << mean << " and charge " << nel;

for (UInt_t rof = rofMin; rof <= rofMax; rof++) {
nhits = gRandom->Poisson(mean);
for (Int_t i = 0; i < nhits; ++i) {
row = gRandom->Integer(maxRows);
col = gRandom->Integer(maxCols);
LOG(debug) << "Generated noise hit at ROF " << rof << ", row " << row << ", col " << col;
if (mNoiseMap && mNoiseMap->isNoisy(mChipIndex, row, col)) {
continue;
}
if (mDeadChanMap && mDeadChanMap->isNoisy(mChipIndex, row, col)) {
continue;
}
auto key = getOrderingKey(rof, row, col);
if (!findDigit(key)) {
float toa = gRandom->Uniform(0.f, rofLengthNS); // noise fires uniformly in the ROF
addDigit(key, rof, row, col, nel, o2::MCCompLabel(true), toa);
}
nhits = gRandom->Poisson(mean);
for (Int_t i = 0; i < nhits; ++i) {
row = gRandom->Integer(maxRows);
col = gRandom->Integer(maxCols);
LOG(debug) << "Generated noise hit at ROF " << rof << ", row " << row << ", col " << col;
if (mNoiseMap && mNoiseMap->isNoisy(mChipIndex, row, col)) {
continue;
}
if (mDeadChanMap && mDeadChanMap->isNoisy(mChipIndex, row, col)) {
continue;
}
auto key = getOrderingKey(rof, row, col);
// provisional noise model (to be revised with the ALMIRA noise model): noise hits are ordinary
// contributions with charge 1.1 x threshold, going through the same TW/ToT/pixel-state logic as particles
float toa = gRandom->Uniform(0.f, rofLengthNS); // noise arrives uniformly in the ROF
addContribution(key, rof, row, col, nel, o2::MCCompLabel(true), toa, extra);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper<DPLDigitizer

bool continuous = true; ///< flag for continuous simulation
float noisePerPixel = DEFNoisePerPixel(); ///< ALMIRA chips noise rate in hits/pixel/s
float strobeFlatTop = 20.; ///< strobe shape flat top
float strobeMaxRiseTime = 0.; ///< strobe max rise time
float strobeQRiseTime0 = 0.; ///< q @ which strobe rise time is 0

double timeOffset = 0.; ///< time offset (in seconds!) to calculate ROFrame from hit time
int chargeThreshold = 75; ///< charge threshold in Nelectrons
int minChargeToAccount = 7; ///< minimum charge contribution to account
int nSimSteps = 475; ///< number of steps in response simulation
float energyToNElectrons = 1. / 3.6e-9; // conversion of eloss to Nelectrons

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

#include <Rtypes.h>
#include "DetectorsCommonDataFormats/DetID.h"
#include "ITSMFTSimulation/AlpideSignalTrapezoid.h"
#include "ITSMFTSimulation/AlpideSimResponse.h"
#include "TRKBase/AlmiraParam.h"
#include "TRKFT3Simulation/AlmiraSignal.h"

////////////////////////////////////////////////////////////
// //
Expand Down Expand Up @@ -63,7 +63,6 @@ class DigiParams
{
static_assert(DetIDV == o2::detectors::DetID::TRK || DetIDV == o2::detectors::DetID::FT3, "only TRK and FT3 digit parameters are supported");

using SignalShape = o2::itsmft::AlpideSignalTrapezoid;
static constexpr size_t MaxLayers = detail::DigiParamsLayerTraits<DetIDV>::MaxLayers;

public:
Expand All @@ -82,12 +81,6 @@ class DigiParams
float getROFrameLength(int layer) const { return mROFrameLayerLength[layer]; }
float getROFrameLengthInv(int layer) const { return mROFrameLayerLengthInv[layer]; }

void setStrobeDelay(float ns, int layer) { mStrobeLayerDelay[layer] = ns; }
float getStrobeDelay(int layer) const { return mStrobeLayerDelay[layer]; }

void setStrobeLength(float ns, int layer) { mStrobeLayerLength[layer] = ns; }
float getStrobeLength(int layer) const { return mStrobeLayerLength[layer]; }

void setTimeOffset(double sec) { mTimeOffset = sec; }
double getTimeOffset() const { return mTimeOffset; }

Expand Down Expand Up @@ -117,8 +110,7 @@ class DigiParams
const o2::trkft3::ChipSimResponse* getResponse() const { return mResponse.get(); }
void setResponse(const o2::itsmft::AlpideSimResponse*);

const SignalShape& getSignalShape() const { return mSignalShape; }
SignalShape& getSignalShape() { return (SignalShape&)mSignalShape; }
const AlmiraSignal& getAlmiraSignal() const { return mAlmiraSignal; }

virtual void print() const;

Expand Down Expand Up @@ -153,10 +145,8 @@ class DigiParams
std::array<int, MaxLayers> mROFrameLayerLengthInBC; ///< staggering ROF length in BC for continuous mode per layer
std::array<int, MaxLayers> mROFrameLayerBiasInBC; ///< staggering ROF bias in BC for continuous mode per layer
std::array<float, MaxLayers> mROFrameLayerLength; ///< staggering ROF length in ns for continuous mode per layer
std::array<float, MaxLayers> mStrobeLayerLength; ///< staggering strobe length in ns per layer
std::array<float, MaxLayers> mStrobeLayerDelay; ///< staggering strobe delay in ns per layer

o2::itsmft::AlpideSignalTrapezoid mSignalShape; ///< signal timeshape parameterization
AlmiraSignal mAlmiraSignal; ///< ALMIRA front-end signal: time walk and time over threshold

std::unique_ptr<o2::trkft3::ChipSimResponse> mResponse; //!< pointer on external response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Digitizer
{
static_assert(DetID == o2::detectors::DetID::TRK || DetID == o2::detectors::DetID::FT3, "only TRK and FT3 digitizers are supported");
using GeometryTGeo = std::conditional_t<DetID == o2::detectors::DetID::TRK, o2::trk::GeometryTGeo, o2::ft3::GeometryTGeo>;
using ExtraDig = std::vector<trkft3::PreDigitLabelRef>; ///< container for extra contributions to PreDigits
using ExtraDig = std::vector<trkft3::PreDigitContribution>; ///< container for extra contributions to PreDigits

public:
void setDigits(std::vector<o2::trkft3::Digit>* dig) { mDigits = dig; }
Expand Down Expand Up @@ -72,6 +72,9 @@ class Digitizer
mNewROFrame = 0;
mROFsWrtFirstRO = 0;
mExtraBuff.clear();
for (auto& chip : mChips) {
chip.getPixelStates().clear(); // signal times are relative to the TF start: states do not survive a new TF
}
}

const o2::trkft3::DigiParams<DetID>& getDigitParams() const { return mParams; }
Expand All @@ -94,8 +97,10 @@ class Digitizer

private:
void processHit(const o2::trkft3::Hit& hit, uint32_t& maxFr, int evID, int srcID, int rofLayer, std::vector<float>& respMatrix);
void registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float toaInROF, int nROF,
void registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float toaInROF,
uint16_t row, uint16_t col, int nEle, o2::MCCompLabel& lbl, int layer);
void writeDigit(o2::trkft3::ChipDigitsContainer& chip, uint16_t row, uint16_t col, int charge, float toaInROF,
o2::trkft3::PixelState& state, int layer);

ExtraDig* getExtraDigBuffer(uint32_t roFrame)
{
Expand Down Expand Up @@ -157,6 +162,10 @@ class Digitizer

static constexpr float sec2ns = 1e9;

// edge-detection statistics of the layer, printed at the final flush (LOG(debug))
long mNDigits = 0;
long mNPreCharged = 0, mNLEAfterEnd = 0, mNSameROF = 0, mNMovedROF = 0, mNDeadTime = 0;

o2::trkft3::DigiParams<DetID> mParams; ///< digitization parameters
o2::InteractionTimeRecord mEventTime; ///< global event time and interaction record
o2::InteractionRecord mIRFirstSampledTF; ///< IR of the 1st sampled IR, noise-only ROFs will be inserted till this IR only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@
namespace o2::trkft3
{

// PreDigit is a contribution to the digit from a single hit which happen
// to be registered 1st in given chip row/column/roframe
// Eventual extra contributions will be registered as PreDigitExtra, pointed by
// the "next" index
// PreDigit: pixel row/column/roframe with at least one contribution (hit) in that ROF.
// Each contribution (label, arrival time, charge) is a PreDigitContribution; the first one
// is stored in the PreDigit, the others in a chain pointed by the "next" index.
// Contributions are kept separately (not summed) because, with edge detection, the digit is
// built at the flush by processing them in time order together with the pixel state.

// PreDigitExtra registers additional contributions to the same row/column/roframe
struct PreDigitLabelRef {
struct PreDigitContribution {
o2::MCCompLabel label; ///< hit label
float toa = 0.f; ///< arrival time w.r.t. ROF start (ns)
int charge = 0; ///< N electrons of this contribution
int next = -1; ///< eventual next contribution to the same pixel
PreDigitLabelRef(o2::MCCompLabel lbl = 0, int nxt = -1) : label(lbl), next(nxt) {}
PreDigitContribution(o2::MCCompLabel lbl = 0, float t = 0.f, int q = 0, int nxt = -1) : label(lbl), toa(t), charge(q), next(nxt) {}

ClassDefNV(PreDigitLabelRef, 1);
ClassDefNV(PreDigitContribution, 1);
};

struct PreDigit {
UShort_t row = 0; ///< Pixel index in X
UShort_t col = 0; ///< Pixel index in Z
UInt_t roFrame = 0; ///< Readout frame
int charge = 0; ///< N electrons
float toa = 0.f; ///< Time of arrival in ns (earliest contribution)
PreDigitLabelRef labelRef; ///< label and reference to the next one
UShort_t row = 0; ///< Pixel index in X
UShort_t col = 0; ///< Pixel index in Z
UInt_t roFrame = 0; ///< Readout frame
PreDigitContribution contrib; ///< first contribution and reference to the next one

PreDigit(UInt_t rf = 0, UShort_t rw = 0, UShort_t cl = 0, int nele = 0, o2::MCCompLabel lbl = 0, float t = 0.f)
: row(rw), col(cl), roFrame(rf), charge(nele), toa(t), labelRef(lbl) {}
: row(rw), col(cl), roFrame(rf), contrib(lbl, t, nele) {}

ClassDefNV(PreDigit, 1);
ClassDefNV(PreDigit, 2);
};

} // namespace o2::trkft3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ void DigiParams<DetIDV>::setNSimSteps(int v)
template <int DetIDV>
void DigiParams<DetIDV>::setChargeThreshold(int v, float frac2Account)
{
// set charge threshold for digits creation and its fraction to account
// contribution from single hit
// set charge threshold for digits creation and the minimum charge of a single
// contribution to be accounted (smaller ones are neglected even when summed)
mChargeThreshold = v;
mMinChargeToAccount = v * frac2Account;
if (mMinChargeToAccount < 0 || mMinChargeToAccount > mChargeThreshold) {
mMinChargeToAccount = mChargeThreshold;
}
LOG(info) << "Set charge threshold to " << mChargeThreshold
<< ", single hit will be accounted from " << mMinChargeToAccount
<< ", single contribution will be accounted from " << mMinChargeToAccount
<< " electrons";
}

Expand All @@ -77,8 +77,8 @@ void DigiParams<DetIDV>::print() const
}
}

printf("Charge time-response:\n");
mSignalShape.print();
printf("ALMIRA front-end signal:\n");
mAlmiraSignal.print();
}

template <int DetIDV>
Expand Down
Loading
Loading