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
31 changes: 31 additions & 0 deletions DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "GPUCommonDef.h"
#include "GPUCommonRtypes.h"
#include "DataFormatsTRD/Constants.h"

namespace o2
{
Expand Down Expand Up @@ -155,10 +156,40 @@ class Tracklet64
ClassDefNV(Tracklet64, 1);
};

GPUdi() float Tracklet64::getUncalibratedY() const
{
int padLocalBin = getPosition();
int padLocal = 0;
if (padLocalBin & (1 << (constants::NBITSTRKLPOS - 1))) {
padLocal = -((~(padLocalBin - 1)) & ((1 << constants::NBITSTRKLPOS) - 1));
} else {
padLocal = padLocalBin & ((1 << constants::NBITSTRKLPOS) - 1);
}
int mcmCol = (getMCM() % constants::NMCMROBINCOL) + constants::NMCMROBINCOL * (getROB() % 2);
float offset = -63.f + ((float)constants::NCOLMCM) * mcmCol;
float padWidth = 0.635f + 0.03f * (getDetector() % constants::NLAYER);
return (offset + padLocal * constants::GRANULARITYTRKLPOS) * padWidth;
}

GPUdi() float Tracklet64::getUncalibratedDy(float nTbDrift) const
{
float dy;
int dyLocalBin = getSlope();
if (dyLocalBin & (1 << (constants::NBITSTRKLSLOPE - 1))) {
dy = (~(dyLocalBin - 1)) & ((1 << constants::NBITSTRKLSLOPE) - 1);
dy *= -1.f;
} else {
dy = dyLocalBin & ((1 << constants::NBITSTRKLSLOPE) - 1);
}
float padWidth = 0.635f + 0.03f * (getDetector() % constants::NLAYER);
return dy * constants::GRANULARITYTRKLSLOPE * padWidth * nTbDrift;
}

#ifndef GPUCA_GPUCODE_DEVICE
std::ostream& operator<<(std::ostream& stream, const Tracklet64& trg);
#endif // GPUCA_GPUCODE_DEVICE

} //namespace trd
} //namespace o2

#endif
29 changes: 0 additions & 29 deletions DataFormats/Detectors/TRD/src/Tracklet64.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,6 @@ namespace trd

using namespace constants;

GPUd() float Tracklet64::getUncalibratedY() const
{
int padLocalBin = getPosition();
int padLocal = 0;
if (padLocalBin & (1 << (NBITSTRKLPOS - 1))) {
padLocal = -((~(padLocalBin - 1)) & ((1 << NBITSTRKLPOS) - 1));
} else {
padLocal = padLocalBin & ((1 << NBITSTRKLPOS) - 1);
}
int mcmCol = (getMCM() % NMCMROBINCOL) + NMCMROBINCOL * (getROB() % 2);
float offset = -63.f + ((float)NCOLMCM) * mcmCol;
float padWidth = 0.635f + 0.03f * (getDetector() % NLAYER);
return (offset + padLocal * GRANULARITYTRKLPOS) * padWidth;
}

GPUd() float Tracklet64::getUncalibratedDy(float nTbDrift) const
{
float dy;
int dyLocalBin = getSlope();
if (dyLocalBin & (1 << (NBITSTRKLSLOPE - 1))) {
dy = (~(dyLocalBin - 1)) & ((1 << NBITSTRKLSLOPE) - 1);
dy *= -1.f;
} else {
dy = dyLocalBin & ((1 << NBITSTRKLSLOPE) - 1);
}
float padWidth = 0.635f + 0.03f * (getDetector() % NLAYER);
return dy * GRANULARITYTRKLSLOPE * padWidth * nTbDrift;
}

#ifndef GPUCA_GPUCODE_DEVICE
void Tracklet64::printStream(std::ostream& stream) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace trd
class TRDDigitReaderSpec : public o2::framework::Task
{
public:
TRDDigitReaderSpec(int channels) : mChannels(channels){};
TRDDigitReaderSpec(int channels, bool useMC) : mChannels(channels), mUseMC(useMC) {}
~TRDDigitReaderSpec() override = default;
void init(o2::framework::InitContext& ic) override;
void run(o2::framework::ProcessingContext& pc) override;
Expand All @@ -39,6 +39,7 @@ class TRDDigitReaderSpec : public o2::framework::Task
int mState = 0;
bool mUseRun2 = false;
int mChannels;
bool mUseMC = false;
std::unique_ptr<TFile> mFile = nullptr;
//std::unique_ptr<TTree> DPLTree;
std::string mInputFileName = "";
Expand All @@ -48,7 +49,7 @@ class TRDDigitReaderSpec : public o2::framework::Task
std::string mMCLabelsBranchName = "TRDMCLabels";
};

o2::framework::DataProcessorSpec getTRDDigitReaderSpec(int channels);
o2::framework::DataProcessorSpec getTRDDigitReaderSpec(int channels, bool useMC);

} // end namespace trd
} // end namespace o2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace o2
namespace trd
{

o2::framework::DataProcessorSpec getTRDTrackletWriterSpec();
o2::framework::DataProcessorSpec getTRDTrackletWriterSpec(bool useMC);

} // end namespace trd
} // end namespace o2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TRDDPLTrapSimulatorTask : public o2::framework::Task
{

public:
TRDDPLTrapSimulatorTask() = default;
TRDDPLTrapSimulatorTask(bool useMC) : mUseMC(useMC) {}

void init(o2::framework::InitContext& ic) override;
void run(o2::framework::ProcessingContext& pc) override;
Expand All @@ -46,6 +46,7 @@ class TRDDPLTrapSimulatorTask : public o2::framework::Task
unsigned long mRunNumber = 297595; //run number to anchor simulation to.
int mShowTrackletStats = 1; // show some statistics for each run
bool mEnableOnlineGainCorrection{false};
bool mUseMC{false}; // whether or not to use MC labels
bool mEnableTrapConfigDump{false};
bool mShareDigitsManually{true}; // duplicate digits connected to shared pads if digitizer did not do so
std::string mTrapConfigName; // the name of the config to be used.
Expand All @@ -57,10 +58,10 @@ class TRDDPLTrapSimulatorTask : public o2::framework::Task
void loadTrapConfig();
void loadDefaultTrapConfig();
void setOnlineGainTables();
void processTRAPchips(int currDetector, int& nTrackletsInTrigRec, std::vector<Tracklet64>& trapTrackletsAccum, o2::dataformats::MCTruthContainer<o2::MCCompLabel>& trackletMCLabels, const o2::dataformats::ConstMCTruthContainer<o2::MCCompLabel>& digitMCLabels);
void processTRAPchips(int currDetector, int& nTrackletsInTrigRec, std::vector<Tracklet64>& trapTrackletsAccum, o2::dataformats::MCTruthContainer<o2::MCCompLabel>& lblTracklets, const o2::dataformats::ConstMCTruthContainer<o2::MCCompLabel>* lblDigits);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't lblTracklets become a pointer as well?

};

o2::framework::DataProcessorSpec getTRDTrapSimulatorSpec();
o2::framework::DataProcessorSpec getTRDTrapSimulatorSpec(bool useMC);

} // end namespace trd
} // end namespace o2
Expand Down
30 changes: 17 additions & 13 deletions Detectors/TRD/workflow/src/TRDDigitReaderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ void TRDDigitReaderSpec::run(ProcessingContext& pc)
};
getFromBranch(mDigitBranchName.c_str(), (void**)&digits);
getFromBranch(mTriggerRecordBranchName.c_str(), (void**)&triggerRecords);
getFromBranch(mMCLabelsBranchName.c_str(), (void**)&ioLabels);
if (mUseMC) {
getFromBranch(mMCLabelsBranchName.c_str(), (void**)&ioLabels);
// publish labels in shared memory
auto& sharedlabels = pc.outputs().make<o2::dataformats::ConstMCTruthContainer<o2::trd::MCLabel>>(Output{"TRD", "LABELS", 0, Lifetime::Timeframe});
ioLabels->copyandflatten(sharedlabels);
LOG(info) << "TRDDigitReader labels size (in bytes) = " << sharedlabels.size();
}

// publish labels in shared memory
auto& sharedlabels = pc.outputs().make<o2::dataformats::ConstMCTruthContainer<o2::trd::MCLabel>>(Output{"TRD", "LABELS", 0, Lifetime::Timeframe});
ioLabels->copyandflatten(sharedlabels);
pc.outputs().snapshot(Output{"TRD", "DIGITS", 0, Lifetime::Timeframe}, *digits);
pc.outputs().snapshot(Output{"TRD", "TRGRDIG", 0, Lifetime::Timeframe}, *triggerRecords);
LOG(info) << "TRDDigitReader digits size=" << digits->size() << " triggerrecords size=" << triggerRecords->size() << " mc labels size (in bytes) = " << sharedlabels.size();
LOG(info) << "TRDDigitReader digits size=" << digits->size() << " triggerrecords size=" << triggerRecords->size();
}
//delete DPLTree; // next line will delete the pointer as well.
mFile->Close();
Expand All @@ -115,17 +118,18 @@ void TRDDigitReaderSpec::run(ProcessingContext& pc)
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
}

DataProcessorSpec getTRDDigitReaderSpec(int channels)
DataProcessorSpec getTRDDigitReaderSpec(int channels, bool useMC)
{

std::vector<OutputSpec> outputs;
outputs.emplace_back("TRD", "DIGITS", 0, Lifetime::Timeframe);
outputs.emplace_back("TRD", "TRGRDIG", 0, Lifetime::Timeframe);
if (useMC) {
outputs.emplace_back("TRD", "LABELS", 0, Lifetime::Timeframe);
}
return DataProcessorSpec{"TRDDIGITREADER",
Inputs{},
Outputs{
OutputSpec{"TRD", "DIGITS", 0, Lifetime::Timeframe},
OutputSpec{"TRD", "TRGRDIG", 0, Lifetime::Timeframe},
OutputSpec{"TRD", "LABELS", 0, Lifetime::Timeframe}},
// outputs,
AlgorithmSpec{adaptFromTask<TRDDigitReaderSpec>(channels)},
outputs,
AlgorithmSpec{adaptFromTask<TRDDigitReaderSpec>(channels, useMC)},
Options{
{"digitsfile", VariantType::String, "trddigits.root", {"Input data file containing run3 digitizer going into Trap Simulator"}},
{"run2digitsfile", VariantType::String, "run2digits.root", {"Input data file containing run2 digitis going into Trap Simulator"}}}};
Expand Down
4 changes: 2 additions & 2 deletions Detectors/TRD/workflow/src/TRDTrackletWriterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace trd
template <typename T>
using BranchDefinition = framework::MakeRootTreeWriterSpec::BranchDefinition<T>;

o2::framework::DataProcessorSpec getTRDTrackletWriterSpec()
o2::framework::DataProcessorSpec getTRDTrackletWriterSpec(bool useMC)
{
// using InputSpec = framework::InputSpec;
using MakeRootTreeWriterSpec = framework::MakeRootTreeWriterSpec;
Expand All @@ -52,7 +52,7 @@ o2::framework::DataProcessorSpec getTRDTrackletWriterSpec()
"trdtracklets.root",
"o2sim",
BranchDefinition<std::vector<o2::trd::Tracklet64>>{InputSpec{"tracklets", "TRD", "TRACKLETS"}, "Tracklet"},
BranchDefinition<o2::dataformats::MCTruthContainer<o2::trd::MCLabel>>{InputSpec{"trklabels", "TRD", "TRKLABELS"}, "TRKLabels"},
BranchDefinition<o2::dataformats::MCTruthContainer<o2::trd::MCLabel>>{InputSpec{"trklabels", "TRD", "TRKLABELS"}, "TRKLabels", (useMC ? 1 : 0), "TRKLABELS"},
BranchDefinition<std::vector<o2::trd::TriggerRecord>>{InputSpec{"tracklettrigs", "TRD", "TRKTRGRD"}, "TrackTrg"})();
};

Expand Down
Loading