Skip to content

Commit bfea7de

Browse files
committed
Adding configurable keys
1 parent a2eae50 commit bfea7de

5 files changed

Lines changed: 80 additions & 40 deletions

File tree

‎Detectors/ITSMFT/ITS/postprocessing/studies/include/ITSStudies/ITSStudiesConfigParam.h‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ struct AnomalyStudyParamConfig : public o2::conf::ConfigurableParamHelper<Anomal
9494
O2ParamDef(AnomalyStudyParamConfig, "AnomalyStudyParam");
9595
};
9696

97+
struct ITSBeamBackgroundStudyParamConfig : public o2::conf::ConfigurableParamHelper<ITSBeamBackgroundStudyParamConfig> {
98+
int dumpEveryTF = 5; // <= 0: write only at end of stream
99+
int skimmedOnlyAfterTF = 150; // TF threshold above which only the skimmed output file is written
100+
bool saveClusterParameters = true; // Write per-cluster coordinates, size and row/column spans
101+
102+
O2ParamDef(ITSBeamBackgroundStudyParamConfig, "ITSBeamBackgroundStudyParam");
103+
};
104+
97105
struct ITSEfficiencyParamConfig : public o2::conf::ConfigurableParamHelper<ITSEfficiencyParamConfig> {
98106
std::string outFileName = "ITS_efficiencyStudy.root";
99107
double b = 0; // Solenoid field in kG (+/-)
@@ -115,4 +123,4 @@ struct ITSImpactParameterParamConfig : public o2::conf::ConfigurableParamHelper<
115123
} // namespace its
116124
} // namespace o2
117125

118-
#endif
126+
#endif

‎Detectors/ITSMFT/ITS/postprocessing/studies/src/ITSBeamBackgroundStudy.cxx‎

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "ITSStudies/ITSBeamBackgroundStudy.h"
13+
#include "ITSStudies/ITSStudiesConfigParam.h"
1314
#include "DataFormatsGlobalTracking/RecoContainer.h"
1415
#include "DetectorsBase/GRPGeomHelper.h"
1516
#include "DataFormatsParameters/GRPObject.h"
@@ -26,6 +27,7 @@
2627
#include <algorithm>
2728
#include <limits>
2829
#include <cmath>
30+
#include <cstdint>
2931

3032
#include <TTree.h>
3133
#include <TH2.h>
@@ -95,8 +97,9 @@ class ITSBeamBackgroundStudy : public Task
9597
int targetClusterMinCol = 128; // definition of anomalous cluster
9698
int targetClusterMaxRow = 29; // definition of anomalous cluster
9799

98-
int mDumpEveryTF = 5; // use -1 to save only at the end
99-
int mSkimmedOnlyAfterTF = 150;
100+
int mDumpEveryTF = ITSBeamBackgroundStudyParamConfig::Instance().dumpEveryTF;
101+
int mSkimmedOnlyAfterTF = ITSBeamBackgroundStudyParamConfig::Instance().skimmedOnlyAfterTF;
102+
bool mSaveClusterParameters = ITSBeamBackgroundStudyParamConfig::Instance().saveClusterParameters;
100103
std::string mOutputChip = "chipevents";
101104
std::string mOutoutChipSkim = "chipeventstarget";
102105

@@ -131,8 +134,10 @@ class ITSBeamBackgroundStudy : public Task
131134
void ITSBeamBackgroundStudy::updateTimeDependentParams(ProcessingContext& pc)
132135
{
133136
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
134-
mGeom = o2::its::GeometryTGeo::Instance();
135-
mGeom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
137+
if (mSaveClusterParameters) {
138+
mGeom = o2::its::GeometryTGeo::Instance();
139+
mGeom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
140+
}
136141
}
137142

138143
void ITSBeamBackgroundStudy::init(InitContext& ic)
@@ -151,6 +156,7 @@ void ITSBeamBackgroundStudy::init(InitContext& ic)
151156
void ITSBeamBackgroundStudy::prepareOutput()
152157
{
153158
LOGP(info, "Setting up trees and histograms. They will be dumped on file every {} TFs", mDumpEveryTF);
159+
LOGP(info, "Skimmed-only output after TF {}; saving cluster parameters: {}", mSkimmedOnlyAfterTF, mSaveClusterParameters);
154160

155161
TimeWindowCut = new TH1F("ZDC bkg region", "ZNAr, ZNCr, -ZNAl, -ZNCl", 8, 0, 8);
156162
TimeWindowCut->SetBinContent(1, TimeWindowZNAr.first);
@@ -186,12 +192,14 @@ void ITSBeamBackgroundStudy::prepareOutput()
186192
ITSChipEvtTree->Branch("bc", &Tbc, "bc/I");
187193
ITSChipEvtTree->Branch("chip", &Tchip, "chip/I");
188194
ITSChipEvtTree->Branch("phi", &Tphi, "phi/D");
189-
ITSChipEvtTree->Branch("cluster_phi", &TclusterPhi);
190-
ITSChipEvtTree->Branch("cluster_r", &TclusterR);
191-
ITSChipEvtTree->Branch("cluster_z", &TclusterZ);
192-
ITSChipEvtTree->Branch("cluster_size", &TclusterSize);
193-
ITSChipEvtTree->Branch("cluster_colspan", &TclusterColSpan);
194-
ITSChipEvtTree->Branch("cluster_rowspan", &TclusterRowSpan);
195+
if (mSaveClusterParameters) {
196+
ITSChipEvtTree->Branch("cluster_phi", &TclusterPhi);
197+
ITSChipEvtTree->Branch("cluster_r", &TclusterR);
198+
ITSChipEvtTree->Branch("cluster_z", &TclusterZ);
199+
ITSChipEvtTree->Branch("cluster_size", &TclusterSize);
200+
ITSChipEvtTree->Branch("cluster_colspan", &TclusterColSpan);
201+
ITSChipEvtTree->Branch("cluster_rowspan", &TclusterRowSpan);
202+
}
195203
ITSChipEvtTree->Branch("zdctag", &TZDCtag, "zdctag/I");
196204
ITSChipEvtTree->Branch("nhit", &Tnhit, "nhit/I");
197205
ITSChipEvtTree->Branch("nhit_no1pix", &Tnhit_no1pix, "nhit_no1pix/I");
@@ -560,23 +568,24 @@ void ITSBeamBackgroundStudy::process(o2::globaltracking::RecoContainer& recoData
560568
if (newchip) {
561569
MAPsize[chipid] = std::vector<int>{};
562570
MAPcols[chipid] = std::vector<int>{};
563-
MAProws[chipid] = std::vector<int>{};
564571
MAPntarget[chipid] = 0;
565572
MAPcoo_mincol[chipid] = coo_col;
566573
MAPcoo_maxcol[chipid] = coo_col + colspan;
567574
}
568575

569576
MAPsize[chipid].push_back(npix);
570577
MAPcols[chipid].push_back(colspan);
571-
MAProws[chipid].push_back(rowspan);
572-
// Grouped topologies store a rounded COG in the compact cluster; invalid
573-
// pattern IDs store the bounding-box corner instead.
574-
const auto pattID = compClus.getPatternID();
575-
auto local = pattID == o2::itsmft::CompCluster::InvalidPatternID
576-
? mDict->getClusterCoordinates<float>(compClus, patti, false)
577-
: (mDict->isGroup(pattID) ? mDict->getClusterCoordinates<float>(compClus, patti)
578-
: mDict->getClusterCoordinates<float>(compClus));
579-
MAPcoordinates[chipid].push_back(mGeom->getMatrixL2G(chipid)(local));
578+
if (mSaveClusterParameters) {
579+
MAProws[chipid].push_back(rowspan);
580+
// Grouped topologies store a rounded COG in the compact cluster; invalid
581+
// pattern IDs store the bounding-box corner instead.
582+
const auto pattID = compClus.getPatternID();
583+
auto local = pattID == o2::itsmft::CompCluster::InvalidPatternID
584+
? mDict->getClusterCoordinates<float>(compClus, patti, false)
585+
: (mDict->isGroup(pattID) ? mDict->getClusterCoordinates<float>(compClus, patti)
586+
: mDict->getClusterCoordinates<float>(compClus));
587+
MAPcoordinates[chipid].push_back(mGeom->getMatrixL2G(chipid)(local));
588+
}
580589
if (colspan >= targetClusterMinCol && rowspan <= targetClusterMaxRow) {
581590
// Anomalous cluster found
582591
MAPntarget[chipid] += 1;
@@ -587,7 +596,7 @@ void ITSBeamBackgroundStudy::process(o2::globaltracking::RecoContainer& recoData
587596

588597
} // end of loop over clusters in rof
589598

590-
if (ntarget_in_rof == 0 && mTFn > mSkimmedOnlyAfterTF + 2) { // extra 2 to avoid edge effects?
599+
if (ntarget_in_rof == 0 && static_cast<int64_t>(mTFn) > static_cast<int64_t>(mSkimmedOnlyAfterTF) + 2) { // extra 2 to avoid edge effects?
591600
// do not need extra computations for this rof since it will not be saved in any case
592601
continue;
593602
}
@@ -615,16 +624,18 @@ void ITSBeamBackgroundStudy::process(o2::globaltracking::RecoContainer& recoData
615624
Tphi = ChipToPhi(ic);
616625

617626
Tnclus = MAPsize[ic].size();
618-
TclusterSize = MAPsize[ic]; // Save before sorting the sizes for the summaries.
619-
TclusterColSpan = MAPcols[ic];
620-
TclusterRowSpan = MAProws[ic];
621-
TclusterPhi.clear();
622-
TclusterR.clear();
623-
TclusterZ.clear();
624-
for (const auto& global : MAPcoordinates[ic]) {
625-
TclusterPhi.push_back(std::atan2(global.Y(), global.X()));
626-
TclusterR.push_back(std::hypot(global.X(), global.Y()));
627-
TclusterZ.push_back(global.Z());
627+
if (mSaveClusterParameters) {
628+
TclusterSize = MAPsize[ic]; // Save before sorting the sizes for the summaries.
629+
TclusterColSpan = MAPcols[ic];
630+
TclusterRowSpan = MAProws[ic];
631+
TclusterPhi.clear();
632+
TclusterR.clear();
633+
TclusterZ.clear();
634+
for (const auto& global : MAPcoordinates[ic]) {
635+
TclusterPhi.push_back(std::atan2(global.Y(), global.X()));
636+
TclusterR.push_back(std::hypot(global.X(), global.Y()));
637+
TclusterZ.push_back(global.Z());
638+
}
628639
}
629640
Tmincol = MAPcoo_mincol[ic];
630641
Tmaxcol = MAPcoo_maxcol[ic];
@@ -741,12 +752,15 @@ DataProcessorSpec getITSBeamBackgroundStudy(mask_t srcTracksMask, mask_t srcClus
741752

742753
dataRequest->requestTracks(srcTracksMask, useMC);
743754

744-
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
745-
true, // GRPECS=true
746-
false, // GRPLHCIF
747-
false, // GRPMagField
748-
false, // askMatLUT
749-
o2::base::GRPGeomRequest::Aligned, // geometry
755+
const auto geometry = ITSBeamBackgroundStudyParamConfig::Instance().saveClusterParameters
756+
? o2::base::GRPGeomRequest::Aligned
757+
: o2::base::GRPGeomRequest::None;
758+
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
759+
true, // GRPECS=true
760+
false, // GRPLHCIF
761+
false, // GRPMagField
762+
false, // askMatLUT
763+
geometry,
750764
dataRequest->inputs,
751765
true);
752766
return DataProcessorSpec{

‎Detectors/ITSMFT/ITS/postprocessing/studies/src/ITSStudiesConfigParam.cxx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ static auto& sPIDStudyParamITS = o2::its::study::PIDStudyParamConfig::Instance()
2222
static auto& sCheckTracksParamsITS = o2::its::study::ITSCheckTracksParamConfig::Instance();
2323
static auto& sImpactParameterParamsITS = o2::its::study::ITSImpactParameterParamConfig::Instance();
2424
static auto& sAnomalyStudy = o2::its::study::AnomalyStudyParamConfig::Instance();
25+
static auto& sBeamBackgroundStudy = o2::its::study::ITSBeamBackgroundStudyParamConfig::Instance();
2526
static auto& sEfficiencyParamsITS = o2::its::study::ITSEfficiencyParamConfig::Instance();
2627

2728
O2ParamImpl(o2::its::study::ITSAvgClusSizeParamConfig);
2829
O2ParamImpl(o2::its::study::PIDStudyParamConfig);
2930
O2ParamImpl(o2::its::study::ITSCheckTracksParamConfig);
3031
O2ParamImpl(o2::its::study::ITSImpactParameterParamConfig);
3132
O2ParamImpl(o2::its::study::AnomalyStudyParamConfig);
33+
O2ParamImpl(o2::its::study::ITSBeamBackgroundStudyParamConfig);
3234
O2ParamImpl(o2::its::study::ITSEfficiencyParamConfig);
3335

3436
} // namespace study

‎Detectors/ITSMFT/ITS/postprocessing/studies/src/ITSStudiesLinkDef.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
#pragma link C++ class o2::its::study::PIDStudyParamConfig + ;
2020
#pragma link C++ class o2::its::study::ITSImpactParameterParamConfig + ;
2121
#pragma link C++ class o2::its::study::AnomalyStudyParamConfig + ;
22+
#pragma link C++ class o2::its::study::ITSBeamBackgroundStudyParamConfig + ;
2223
#pragma link C++ class o2::its::study::ITSEfficiencyParamConfig + ;
2324
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::ITSAvgClusSizeParamConfig> + ;
2425
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::PIDStudyParamConfig> + ;
2526
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::ITSCheckTracksParamConfig> + ;
2627
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::ITSImpactParameterParamConfig> + ;
2728
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::AnomalyStudyParamConfig> + ;
29+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::ITSBeamBackgroundStudyParamConfig> + ;
2830
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::its::study::ITSEfficiencyParamConfig> + ;
2931
#pragma link C++ function o2::its::studies::makeLogBinning + ;
3032

31-
#endif
33+
#endif

‎Detectors/ITSMFT/ITS/postprocessing/workflow/standalone-postprocessing-workflow.cxx‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "ITSStudies/PIDStudy.h"
2525
#include "ITSStudies/AnomalyStudy.h"
2626
#include "ITSStudies/ITSBeamBackgroundStudy.h"
27+
#include "ITSStudies/ITSStudiesConfigParam.h"
2728
#include "ITSStudies/Efficiency.h"
2829
#include "ITSStudies/TrackCheck.h"
2930
#include "ITSStudies/TrackExtension.h"
@@ -41,6 +42,19 @@ void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
4142
// we need to add workflow options before including Framework/runDataProcessing
4243
void customize(std::vector<ConfigParamSpec>& workflowOptions)
4344
{
45+
const auto& beamParams = o2::its::study::ITSBeamBackgroundStudyParamConfig::Instance();
46+
const std::string configHelp =
47+
"Semicolon-separated key=value strings. ITS beam-background study parameters:\n"
48+
"Key prefix: ITSBeamBackgroundStudyParam.\n"
49+
"dumpEveryTF=<int> (default: " +
50+
std::to_string(beamParams.dumpEveryTF) +
51+
"): dump ROOT files every N TFs; <= 0 writes only at end of stream.\n"
52+
"skimmedOnlyAfterTF=<int> (default: " +
53+
std::to_string(beamParams.skimmedOnlyAfterTF) +
54+
"): TF threshold above which only the skimmed output file is written.\n"
55+
"saveClusterParameters=<true|false> (default: " +
56+
(beamParams.saveClusterParameters ? "true" : "false") +
57+
"): save cluster phi, r, z, size, colspan and rowspan vectors in output trees.";
4458
// option allowing to set parameters
4559
std::vector<o2::framework::ConfigParamSpec> options{
4660
{"input-from-upstream", VariantType::Bool, false, {"read clusters from the clusterer"}},
@@ -56,7 +70,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
5670
{"its-beambkg-study", VariantType::Bool, false, {"Perform the ITS beam background study"}},
5771
{"track-extension-study", VariantType::Bool, false, {"Perform the track extension study"}},
5872
{"efficiency-study", VariantType::Bool, false, {"Perform the efficiency study"}},
59-
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}};
73+
{"configKeyValues", VariantType::String, "", {configHelp}}};
6074
o2::itsmft::DPLAlpideParamInitializer::addITSConfigOption(options);
6175
// o2::raw::HBFUtilsInitializer::addConfigOption(options, "o2_tfidinfo.root");
6276
std::swap(workflowOptions, options);

0 commit comments

Comments
 (0)