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
3 changes: 2 additions & 1 deletion Detectors/TRD/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ o2_add_library(TRDCalibration
O2::DetectorsCalibration
O2::MathUtils
O2::GPUTracking
O2::DetectorsDCS)
O2::DetectorsDCS
O2::FT0Reconstruction)

o2_target_root_dictionary(TRDCalibration
HEADERS include/TRDCalibration/TrackBasedCalib.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct TRDCalibParams : public o2::conf::ConfigurableParamHelper<TRDCalibParams>

// Creation of PH plots
float pileupCut = 0.7;
int digitsThreshold = 13;

// parameters related to noise calibration
size_t minNumberOfDigits = 1'000'000'000UL; ///< when reached, noise calibration will be finalized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "DataFormatsTRD/TrackTriggerRecord.h"
#include "DataFormatsTRD/PHData.h"
#include "TRDCalibration/CalibrationParams.h"
#include "DataFormatsFT0/RecPoints.h"
#include "ReconstructionDataFormats/GlobalTrackID.h"
#include "TFile.h"
#include "TTree.h"

Expand Down Expand Up @@ -52,6 +54,7 @@ class PulseHeight
void reset();

void setApplyShift(bool f) { mApplyShift = f; }
void setTrkMask(o2::dataformats::GlobalTrackID::mask_t trkMask) { mTrkMask = trkMask; }

/// Main processing function
void process();
Expand All @@ -75,6 +78,8 @@ class PulseHeight
gsl::span<const TriggerRecord> mTriggerRecords; ///< array of trigger records
gsl::span<const TrackTriggerRecord> mTrackTriggerRecordsTPCTRD; ///< array of track trigger records
gsl::span<const TrackTriggerRecord> mTrackTriggerRecordsITSTPCTRD; ///< array of track trigger records
gsl::span<const o2::ft0::RecPoints> mFT0RecPoints; ///< array of FT0 rec points
o2::dataformats::GlobalTrackID::mask_t mTrkMask; ///< seeding track sources (TPC, ITS-TPC, FT0)

// output
std::vector<PHData> mPHValues, *mPHValuesPtr{&mPHValues}; ///< vector of values used to fill the PH spectra per detector
Expand Down
41 changes: 37 additions & 4 deletions Detectors/TRD/calibration/src/PulseHeight.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "TRDCalibration/PulseHeight.h"
#include "DataFormatsTRD/Constants.h"
#include "DataFormatsGlobalTracking/RecoContainer.h"
#include "FT0Reconstruction/InteractionTag.h"
#include <fairlogger/Logger.h>

using namespace o2::trd;
Expand Down Expand Up @@ -71,6 +72,9 @@ void PulseHeight::setInput(const o2::globaltracking::RecoContainer& input, gsl::
mTriggerRecords = input.getTRDTriggerRecords();
mTrackTriggerRecordsTPCTRD = input.getTPCTRDTriggers();
mTrackTriggerRecordsITSTPCTRD = input.getITSTPCTRDTriggers();
if (mTrkMask[o2::dataformats::GlobalTrackID::FT0]) {
mFT0RecPoints = input.getFT0RecPoints();
}
mDigits = digits;
}

Expand All @@ -83,6 +87,9 @@ void PulseHeight::process()
}
size_t nTrkTrig[2] = {mTrackTriggerRecordsITSTPCTRD.size(), mTrackTriggerRecordsTPCTRD.size()};
int lastTrkTrig[2] = {0};

int currentFT0[2] = {0};

for (const auto& trig : mTriggerRecords) {
if (trig.getNumberOfDigits() == 0) {
continue;
Expand All @@ -103,10 +110,26 @@ void PulseHeight::process()
++lastTrkTrig[iTrackType];
continue;
}
if ((*tracks)[trigTrack.getFirstTrack()].hasPileUpInfo() && (*tracks)[trigTrack.getFirstTrack()].getPileUpTimeShiftMUS() < mParams.pileupCut) {
// rejecting triggers which are close to other collisions (avoid pile-up)
// find closest interacting bc after the trigger record
uint8_t nClosestBC = 0;
if (mTrkMask[o2::dataformats::GlobalTrackID::FT0]) {
for (size_t ft0id = currentFT0[iTrackType]; ft0id < mFT0RecPoints.size(); ft0id++) {
const auto& f0rec = mFT0RecPoints[ft0id];
if (o2::ft0::InteractionTag::Instance().isSelected(f0rec)) {
int64_t bcdiff = f0rec.getInteractionRecord().differenceInBC(trigTrack.getBCData());
if (bcdiff > 0) {
nClosestBC = bcdiff;
currentFT0[iTrackType] = ft0id;
break;
}
}
}
}
if (((*tracks)[trigTrack.getFirstTrack()].getPileUpDistanceBwd() > 0) || ((!mTrkMask[o2::dataformats::GlobalTrackID::FT0] || mFT0RecPoints.size() == 0) && (*tracks)[trigTrack.getFirstTrack()].getPileUpTimeShiftMUS() < mParams.pileupCut) || (nClosestBC > 0 && nClosestBC * o2::constants::lhc::LHCBunchSpacingMUS < mParams.pileupCut)) {
// rejecting triggers with a collision closely after (needs the full colliding BC history because track only keeps the furthest BC within window)
// or with a collision before (avoid pile-up)
++lastTrkTrig[iTrackType];
LOGP(debug, "Rececting trigger due to pileup of {}", (*tracks)[trigTrack.getFirstTrack()].getPileUpTimeShiftMUS());
LOGP(debug, "Rejecting trigger due to pileup of {}", (*tracks)[trigTrack.getFirstTrack()].getPileUpTimeShiftMUS());
break;
}
for (int iTrk = trigTrack.getFirstTrack(); iTrk < trigTrack.getFirstTrack() + trigTrack.getNumberOfTracks(); iTrk++) {
Expand Down Expand Up @@ -137,7 +160,7 @@ void PulseHeight::findDigitsForTracklet(const Tracklet64& trklt, const TriggerRe
if (digit.isSharedDigit()) {
continue; // avoid double-counting of the same digit
}
if (digit.getDetector() != trkltDet || digit.getPadRow() != trklt.getPadRow() || digit.getPadCol() != trklt.getPadCol(mApplyShift)) {
if (digit.getDetector() != trkltDet || digit.getPadRow() != trklt.getPadRow() || digit.getPadCol() != trklt.getPadCol(false)) {
// for now we loose charge information from padrow-crossing tracklets (~15% of all tracklets)
continue;
}
Expand Down Expand Up @@ -167,6 +190,16 @@ void PulseHeight::findDigitsForTracklet(const Tracklet64& trklt, const TriggerRe
right = true;
}
if (nNeighbours > 0) {
// pile-up removal: if we have several consecutive digits with very small value for the first time bins, this is likely to come from pile-up
int nOverThreshold = 0;
for (int iTb = 0; iTb < ((int)(mParams.pileupCut * 10)); iTb++) {
if (digit.getADC()[iTb] > mParams.digitsThreshold) {
nOverThreshold++;
}
}
if (nOverThreshold <= 2) {
continue;
}
int digitTrackletDistance = 0;
auto adcSumMax = digit.getADCsum();
if (left && digitLeft->getADCsum() > adcSumMax) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace trd
class PuseHeightDevice : public o2::framework::Task
{
public:
PuseHeightDevice(std::shared_ptr<DataRequest> dr) : mDataRequest(dr) {}
PuseHeightDevice(std::shared_ptr<DataRequest> dr, o2::dataformats::GlobalTrackID::mask_t src) : mDataRequest(dr), mTrkMask(src) {}
void init(o2::framework::InitContext& ic) final
{
mPulseHeight = std::make_unique<PulseHeight>();
Expand All @@ -47,6 +47,7 @@ class PuseHeightDevice : public o2::framework::Task
// apply artificial pad shift in case non-ideal alignment is used to compensate for shift in current alignment from real data
mPulseHeight->setApplyShift(false);
}
mPulseHeight->setTrkMask(mTrkMask);
}

void run(o2::framework::ProcessingContext& pc) final
Expand Down Expand Up @@ -92,6 +93,7 @@ class PuseHeightDevice : public o2::framework::Task
std::shared_ptr<DataRequest> mDataRequest;
std::unique_ptr<o2::trd::PulseHeight> mPulseHeight;
bool mRunStopRequested = false; // flag that run was stopped (and the last output is sent)
o2::dataformats::GlobalTrackID::mask_t mTrkMask;
};

} // namespace trd
Expand Down Expand Up @@ -127,7 +129,7 @@ DataProcessorSpec getTRDPulseHeightSpec(GID::mask_t src, bool digitsFromReader)
"trd-pulseheight",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<o2::trd::PuseHeightDevice>(dataRequest)},
AlgorithmSpec{adaptFromTask<o2::trd::PuseHeightDevice>(dataRequest, src)},
Options{
{"enable-root-output", VariantType::Bool, false, {"output PH and debug data to root file"}}}};
}
Expand Down
Loading