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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace o2::checkresid
{
/// create a processor spec
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly);
o2::framework::DataProcessorSpec getCheckResidSpec(o2::dataformats::GlobalTrackID::mask_t srcTracks, o2::dataformats::GlobalTrackID::mask_t srcClus, bool drawOnly, bool postProcOnly);

} // namespace o2::checkresid

Expand Down
90 changes: 55 additions & 35 deletions Detectors/GlobalTrackingWorkflow/study/src/CheckResidSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ using timeEst = o2::dataformats::TimeStampWithError<float, float>;
class CheckResidSpec : public Task
{
public:
CheckResidSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool drawOnly)
: mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(src), mDrawOnly(drawOnly)
CheckResidSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, GTrackID::mask_t src, bool drawOnly, bool postProcOnly)
: mDataRequest(dr), mGGCCDBRequest(gr), mTracksSrc(src), mDrawOnly(drawOnly), mPostProcOnly(postProcOnly)
{
}
~CheckResidSpec() final = default;
Expand Down Expand Up @@ -110,6 +110,7 @@ class CheckResidSpec : public Task
GTrackID::mask_t mTracksSrc{};

bool mDrawOnly = false;
bool mPostProcOnly = false;
bool mDraw = false;
bool mFillHistos = true;
bool mFillTree = true;
Expand Down Expand Up @@ -179,8 +180,17 @@ void CheckResidSpec::init(InitContext& ic)

void CheckResidSpec::run(ProcessingContext& pc)
{
bool quit = false;
if (mPostProcOnly) {

postProcessHistos();
quit = true;
}
if (mDrawOnly) {
drawHistos();
quit = true;
}
if (quit) {
pc.services().get<ControlService>().endOfStream();
pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
return;
Expand Down Expand Up @@ -689,43 +699,53 @@ void CheckResidSpec::bookHistos()
void CheckResidSpec::postProcessHistos()
{
printf("Fitting histos\n");
if (!mHMan) {
if (mHManV.empty()) {
LOGP(warn, "nothing to process");
return;
}
mHMan = mHManV[0].get();
}
const auto& params = o2::checkresid::CheckResidConfig::Instance();
auto gs = new TF1("gs", "gaus", -1, 1);
int maxH = mPostProcOnly ? mHManV.size() : 1;
TObjArray arr;
auto* histm = mHMan;
auto fitSlices = [&](int id) {
auto h2 = histm->getHisto2F(id);
if (!h2 || h2->GetEntries() < params.minHistoStat2Fit) {
return;
}
h2->FitSlicesY(gs, 0, -1, 0, "QNR", &arr);
arr.SetOwner(true);
TH1* hmean = (TH1*)arr.RemoveAt(1);
if (hmean) {
hmean->SetTitle(Form("<%s>", h2->GetTitle()));
histm->addHisto(hmean, id + 1);
}
TH1* hsig = (TH1*)arr.RemoveAt(2);
if (hsig) {
hsig->SetTitle(Form("#sigma(%s)", h2->GetTitle()));
histm->addHisto(hsig, id + 2);
}
};
for (int ioffs = 0; ioffs <= 3; ioffs++) { // vs phi, Z, pT, tgl
int offs = ioffs * 1000;
for (int iht = 0; iht < 2; iht++) { // resid, pull
int offsV = iht == 0 ? 0 : 5;
for (int il = 0; il < 8; il++) {
for (int iyz = 0; iyz < 2; iyz++) {
fitSlices(il * 10 + iyz * 100 + offsV + offs);
}
for (int ihm = 0; ihm < maxH; ihm++) {
auto* histm = mHManV[ihm].get();
auto fitSlices = [&](int id) {
auto h2 = histm->getHisto2F(id);
if (!h2 || h2->GetEntries() < params.minHistoStat2Fit) {
return;
}
h2->FitSlicesY(gs, 0, -1, 0, "QNR", &arr);
arr.SetOwner(true);
TH1* hmean = (TH1*)arr.RemoveAt(1);
if (hmean) {
hmean->SetTitle(Form("<%s>", h2->GetTitle()));
histm->addHisto(hmean, id + 1);
}
TH1* hsig = (TH1*)arr.RemoveAt(2);
if (hsig) {
hsig->SetTitle(Form("#sigma(%s)", h2->GetTitle()));
histm->addHisto(hsig, id + 2);
}
for (int ip = 0; ip < 5; ip++) {
fitSlices(10000 + ip * 10 + offsV + offs);
};
for (int ioffs = 0; ioffs <= 3; ioffs++) { // vs phi, Z, pT, tgl
int offs = ioffs * 1000;
for (int iht = 0; iht < 2; iht++) { // resid, pull
int offsV = iht == 0 ? 0 : 5;
for (int il = 0; il < 8; il++) {
for (int iyz = 0; iyz < 2; iyz++) {
fitSlices(il * 10 + iyz * 100 + offsV + offs);
}
}
for (int ip = 0; ip < 5; ip++) {
fitSlices(10000 + ip * 10 + offsV + offs);
}
}
}
histm->write();
}
histm->write();
delete gs;
}

Expand Down Expand Up @@ -922,11 +942,11 @@ void CheckResidSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
}
}

DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly)
DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t srcClusters, bool drawOnly, bool postProcOnly)
{
std::vector<OutputSpec> outputs;
auto dataRequest = std::make_shared<DataRequest>();
if (!drawOnly) {
if (!drawOnly && !postProcOnly) {
bool useMC = false;
dataRequest->requestTracks(srcTracks, useMC);
dataRequest->requestClusters(srcClusters, useMC);
Expand Down Expand Up @@ -954,7 +974,7 @@ DataProcessorSpec getCheckResidSpec(GTrackID::mask_t srcTracks, GTrackID::mask_t
"check-resid",
dataRequest->inputs,
outputs,
AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly)},
AlgorithmSpec{adaptFromTask<CheckResidSpec>(dataRequest, ggRequest, srcTracks, drawOnly, postProcOnly)},
opts};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
// option allowing to set parameters
std::vector<o2::framework::ConfigParamSpec> options{
{"draw-external-only", VariantType::Bool, false, {"just draw content of comma-separated list of histomanagers from checkresid.ext_hm_list"}},
{"postproc-external-only", VariantType::Bool, false, {"just post-process raw content of comma-separated list of histomanagers from checkresid.ext_hm_list"}},
{"track-sources", VariantType::String, std::string{GID::ALL}, {"comma-separated list of track sources to use"}},
{"cluster-sources", VariantType::String, "ITS", {"comma-separated list of cluster sources to use"}},
{"disable-root-input", VariantType::Bool, false, {"disable root-files input reader"}},
Expand All @@ -57,7 +58,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
WorkflowSpec specs;

bool drawOnly = configcontext.options().get<bool>("draw-external-only");

bool postProcOnly = configcontext.options().get<bool>("postproc-external-only");
GID::mask_t allowedSourcesTrc = GID::getSourcesMask("ITS,TPC,ITS-TPC,ITS-TPC-TRD,ITS-TPC-TOF,ITS-TPC-TRD-TOF");
GID::mask_t allowedSourcesClus = GID::getSourcesMask("ITS");

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

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