Skip to content

Commit d477eed

Browse files
committed
Optionally postpocess histoManagers before drawing
1 parent cc6e4ae commit d477eed

3 files changed

Lines changed: 59 additions & 38 deletions

File tree

Detectors/GlobalTrackingWorkflow/study/include/GlobalTrackingStudy/CheckResidSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace o2::checkresid
2020
{
2121
/// create a processor spec
22-
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly);
22+
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly, bool postProcOnly);
2323

2424
} // namespace o2::checkresid
2525

Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ using timeEst = o2::dataformats::TimeStampWithError<float, float>;
7575
class CheckResidSpec : public Task
7676
{
7777
public:
78-
CheckResidSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool drawOnly)
79-
: mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(src), mDrawOnly(drawOnly)
78+
CheckResidSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool drawOnly, bool postProcOnly)
79+
: mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(src), mDrawOnly(drawOnly), mPostProcOnly(postProcOnly)
8080
{
8181
}
8282
~CheckResidSpec() final = default;
@@ -110,6 +110,7 @@ class CheckResidSpec : public Task
110110
GTrackID::mask_t mTracksSrc{};
111111

112112
bool mDrawOnly = false;
113+
bool mPostProcOnly = false;
113114
bool mDraw = false;
114115
bool mFillHistos = true;
115116
bool mFillTree = true;
@@ -179,8 +180,17 @@ void CheckResidSpec::init(InitContext& ic)
179180

180181
void CheckResidSpec::run(ProcessingContext& pc)
181182
{
183+
bool quit = false;
184+
if (mPostProcOnly) {
185+
186+
postProcessHistos();
187+
quit = true;
188+
}
182189
if (mDrawOnly) {
183190
drawHistos();
191+
quit = true;
192+
}
193+
if (quit) {
184194
pc.services().get<ControlService>().endOfStream();
185195
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
186196
return;
@@ -689,43 +699,53 @@ void CheckResidSpec::bookHistos()
689699
void CheckResidSpec::postProcessHistos()
690700
{
691701
printf("Fitting histos\n");
702+
if (!mHMan) {
703+
if (mHManV.empty()) {
704+
LOGP(warn, "nothing to process");
705+
return;
706+
}
707+
mHMan = mHManV[0].get();
708+
}
692709
const auto& params = o2::checkresid::CheckResidConfig::Instance();
693710
auto gs = new TF1("gs", "gaus", -1, 1);
711+
int maxH = mPostProcOnly ? mHManV.size() : 1;
694712
TObjArray arr;
695-
auto* histm = mHMan;
696-
auto fitSlices = [&](int id) {
697-
auto h2 = histm->getHisto2F(id);
698-
if (!h2 || h2->GetEntries() < params.minHistoStat2Fit) {
699-
return;
700-
}
701-
h2->FitSlicesY(gs, 0, -1, 0, "QNR", &arr);
702-
arr.SetOwner(true);
703-
TH1* hmean = (TH1*)arr.RemoveAt(1);
704-
if (hmean) {
705-
hmean->SetTitle(Form("<%s>", h2->GetTitle()));
706-
histm->addHisto(hmean, id + 1);
707-
}
708-
TH1* hsig = (TH1*)arr.RemoveAt(2);
709-
if (hsig) {
710-
hsig->SetTitle(Form("#sigma(%s)", h2->GetTitle()));
711-
histm->addHisto(hsig, id + 2);
712-
}
713-
};
714-
for (int ioffs = 0; ioffs <= 3; ioffs++) { // vs phi, Z, pT, tgl
715-
int offs = ioffs * 1000;
716-
for (int iht = 0; iht < 2; iht++) { // resid, pull
717-
int offsV = iht == 0 ? 0 : 5;
718-
for (int il = 0; il < 8; il++) {
719-
for (int iyz = 0; iyz < 2; iyz++) {
720-
fitSlices(il * 10 + iyz * 100 + offsV + offs);
721-
}
713+
for (int ihm = 0; ihm < maxH; ihm++) {
714+
auto* histm = mHManV[ihm].get();
715+
auto fitSlices = [&](int id) {
716+
auto h2 = histm->getHisto2F(id);
717+
if (!h2 || h2->GetEntries() < params.minHistoStat2Fit) {
718+
return;
719+
}
720+
h2->FitSlicesY(gs, 0, -1, 0, "QNR", &arr);
721+
arr.SetOwner(true);
722+
TH1* hmean = (TH1*)arr.RemoveAt(1);
723+
if (hmean) {
724+
hmean->SetTitle(Form("<%s>", h2->GetTitle()));
725+
histm->addHisto(hmean, id + 1);
726+
}
727+
TH1* hsig = (TH1*)arr.RemoveAt(2);
728+
if (hsig) {
729+
hsig->SetTitle(Form("#sigma(%s)", h2->GetTitle()));
730+
histm->addHisto(hsig, id + 2);
722731
}
723-
for (int ip = 0; ip < 5; ip++) {
724-
fitSlices(10000 + ip * 10 + offsV + offs);
732+
};
733+
for (int ioffs = 0; ioffs <= 3; ioffs++) { // vs phi, Z, pT, tgl
734+
int offs = ioffs * 1000;
735+
for (int iht = 0; iht < 2; iht++) { // resid, pull
736+
int offsV = iht == 0 ? 0 : 5;
737+
for (int il = 0; il < 8; il++) {
738+
for (int iyz = 0; iyz < 2; iyz++) {
739+
fitSlices(il * 10 + iyz * 100 + offsV + offs);
740+
}
741+
}
742+
for (int ip = 0; ip < 5; ip++) {
743+
fitSlices(10000 + ip * 10 + offsV + offs);
744+
}
725745
}
726746
}
747+
histm->write();
727748
}
728-
histm->write();
729749
delete gs;
730750
}
731751

@@ -922,11 +942,11 @@ void CheckResidSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
922942
}
923943
}
924944

925-
DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly)
945+
DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly, bool postProcOnly)
926946
{
927947
std::vector<OutputSpec> outputs;
928948
auto dataRequest = std::make_shared<DataRequest>();
929-
if (!drawOnly) {
949+
if (!drawOnly && !postProcOnly) {
930950
bool useMC = false;
931951
dataRequest->requestTracks(srcTracks, useMC);
932952
dataRequest->requestClusters(srcClusters, useMC);
@@ -954,7 +974,7 @@ DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t
954974
"check-resid",
955975
dataRequest->inputs,
956976
outputs,
957-
AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly)},
977+
AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly, postProcOnly)},
958978
opts};
959979
}
960980

Detectors/GlobalTrackingWorkflow/study/src/check-resid-workflow.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
3838
// option allowing to set parameters
3939
std::vector<o2::framework::ConfigParamSpec> options{
4040
{"draw-external-only", VariantType::Bool, false, {"just draw content of comma-separated list of histomanagers from checkresid.ext_hm_list"}},
41+
{"postproc-external-only", VariantType::Bool, false, {"just post-process raw content of comma-separated list of histomanagers from checkresid.ext_hm_list"}},
4142
{"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of track sources to use"}},
4243
{"cluster-sources", VariantType::String, "ITS", {"comma-separated list of cluster sources to use"}},
4344
{"disable-root-input", VariantType::Bool, false, {"disable root-files input reader"}},
@@ -57,7 +58,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
5758
WorkflowSpec specs;
5859

5960
bool drawOnly = configcontext.options().get<bool>("draw-external-only");
60-
61+
bool postProcOnly = configcontext.options().get<bool>("postproc-external-only");
6162
GID::mask_t allowedSourcesTrc = GID::getSourcesMask("ITS,TPC,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF");
6263
GID::mask_t allowedSourcesClus = GID::getSourcesMask("ITS");
6364

@@ -74,7 +75,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
7475
allowedSourcesTrc = {};
7576
allowedSourcesClus = {};
7677
}
77-
specs.emplace_back(o2::checkresid::getCheckResidSpec(srcTrc, srcCls, drawOnly));
78+
specs.emplace_back(o2::checkresid::getCheckResidSpec(srcTrc, srcCls, drawOnly, postProcOnly));
7879

7980
// configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
8081
if (!drawOnly) {

0 commit comments

Comments
 (0)