51 unsigned int mProcessEveryNthTF{1};
52 uint32_t mTFCounter{0};
55 uint64_t mFirstCreation{0};
56 uint64_t mLastCreation{0};
57 uint32_t mRunNumber{0};
58 int mMaxTFPerFile{-1};
59 std::string mOutputFileName;
60 bool mNewInterval{
true};
66 mOutputFileName = ic.
options().
get<std::string>(
"output-file-name");
67 mMaxTFPerFile = ic.
options().
get<
int>(
"max-tf-per-file");
69 mProcessEveryNthTF = ic.
options().
get<
int>(
"processEveryNthTF");
70 if (mProcessEveryNthTF <= 0) {
71 mProcessEveryNthTF = 1;
74 if (mProcessEveryNthTF > 1) {
75 std::mt19937 rng(std::time(
nullptr));
76 std::uniform_int_distribution<std::mt19937::result_type> dist(1, mProcessEveryNthTF);
77 mTFCounter = dist(rng);
78 LOGP(info,
"Skipping first {} TFs", mProcessEveryNthTF - mTFCounter);
84 if (mTFCounter++ % mProcessEveryNthTF) {
86 LOGP(info,
"Skipping TF {}", currentTF);
100 const auto& clustersInputs = getWorkflowTPCInput(pc);
101 const auto& clusterIndex = clustersInputs->clusterIndex;
103 for (
int sector = 0; sector <
MAXSECTOR; ++sector) {
106 for (
size_t icl = 0; icl < clusterIndex.nClusters[sector][
padrow]; ++icl) {
107 const auto& cl = clusterIndex.clusters[sector][
padrow][icl];
114 if ((mMaxTFPerFile > 0) && (mClusterQC.
getProcessedTFs() % mMaxTFPerFile) == 0) {
119void ClusterQCDevice::endInterval()
126 LOGP(info,
"End interval for run: {}, TFs: {} - {}, creation: {} - {}, processed TFs: {}",
127 mRunNumber, mFirstTF, mLastTF, mFirstCreation, mLastCreation, mClusterQC.
getProcessedTFs());
129 const auto outputFileName = fmt::format(fmt::runtime(mOutputFileName), fmt::arg(
"run", mRunNumber),
130 fmt::arg(
"firstTF", mFirstTF), fmt::arg(
"lastTF", mLastTF),
131 fmt::arg(
"firstCreation", mFirstCreation), fmt::arg(
"lastCreation", mLastCreation));
132 std::unique_ptr<TFile>
f(TFile::Open(outputFileName.data(),
"recreate"));
133 f->WriteObject(&mClusterQC,
"ClusterQC");
137 mRunNumber = mFirstTF = mLastTF = mFirstCreation = mLastCreation = 0;
143 LOG(info) <<
"Finalizig Cluster QC filter";
149 std::vector<InputSpec> inputs;
150 std::vector<OutputSpec> outputs;
158 adaptFromTask<ClusterQCDevice>(),
160 {
"output-file-name", VariantType::String,
"clusterQC_{run}_{firstCreation}_{lastCreation}_{firstTF}_{lastTF}.root", {
"name of the output file"}},
161 {
"processEveryNthTF", VariantType::Int, 1, {
"Using only a fraction of the data: 1: Use every TF, 10: Process only every tenth TF."}},
162 {
"max-tf-per-file", VariantType::Int, -1, {
"Number of TFs to process before a file is written. -1 = all"}},
Workflow to run clusterQC.
Helper class to obtain TPC clusters / digits / labels from DPL.
T get(const char *key) const
ConfigParamRegistry const & options()
void endOfStream(EndOfStreamContext &eos) final
void init(framework::InitContext &ic) final
void run(ProcessingContext &pc) final
bool processCluster(const T &cluster, const o2::tpc::Sector sector, const int row)
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
constexpr int MAXGLOBALPADROW
uint32_t getCurrentTF(o2::framework::ProcessingContext &pc)
uint64_t getRunNumber(o2::framework::ProcessingContext &pc)
uint64_t getCreationTime(o2::framework::ProcessingContext &pc)
Global TPC definitions and constants.
o2::framework::DataProcessorSpec getClusterQCSpec()
create a processor speco2::framework::DataProcessorSpec getClusterQCSpec();
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"