diff --git a/Detectors/GLOQC/CMakeLists.txt b/Detectors/GLOQC/CMakeLists.txt index 1aca89fee1579..cdb307a6515c8 100644 --- a/Detectors/GLOQC/CMakeLists.txt +++ b/Detectors/GLOQC/CMakeLists.txt @@ -15,18 +15,7 @@ o2_add_library(GLOQC SOURCES src/MatchITSTPCQC.cxx src/ITSTPCMatchingQCParams.cxx - PUBLIC_LINK_LIBRARIES O2::Framework - O2::DataFormatsTPC - O2::DataFormatsITS - O2::SimConfig - O2::DataFormatsGlobalTracking - O2::MathUtils - O2::SimulationDataFormat - O2::ReconstructionDataFormats - O2::Steer - O2::GlobalTracking - O2::DCAFitter - O2::DetectorsVertexing) + PUBLIC_LINK_LIBRARIES O2::DetectorsVertexing) o2_target_root_dictionary(GLOQC HEADERS include/GLOQC/MatchITSTPCQC.h diff --git a/Detectors/GLOQC/include/GLOQC/MatchITSTPCQC.h b/Detectors/GLOQC/include/GLOQC/MatchITSTPCQC.h index 47261886da279..ca4d2678722c6 100644 --- a/Detectors/GLOQC/include/GLOQC/MatchITSTPCQC.h +++ b/Detectors/GLOQC/include/GLOQC/MatchITSTPCQC.h @@ -130,7 +130,7 @@ class MatchITSTPCQC TH1D* getHisto1OverPtPhysPrimDen(matchType m) const { return m1OverPtPhysPrimDen[m]; } TEfficiency* getFractionITSTPCmatchPhysPrim1OverPt(matchType m) const { return mFractionITSTPCmatchPhysPrim1OverPt[m]; } - TH1F* getHistoK0Mass() const { return mK0Mass; } + TH2F* getHistoK0MassVsPt() const { return mK0MassVsPt; } void getHistos(TObjArray& objar); @@ -227,10 +227,12 @@ class MatchITSTPCQC publisher->startPublishing(mDCArVsPtNum); publisher->startPublishing(mDCArVsPtDen); publisher->startPublishing(mFractionITSTPCmatchDCArVsPt); - publisher->startPublishing(mK0Mass); + if (mDoK0QC) { + publisher->startPublishing(mK0MassVsPt); + } } - void setSources(GID::mask_t src) { mSrc = src; } + void setTrkSources(GID::mask_t src) { mSrc = src; } void setUseTrkPID(bool b) { mUseTrkPID = b; } bool getUseTrkPID() const { return mUseTrkPID; } void setUseMC(bool b) { mUseMC = b; } @@ -271,8 +273,9 @@ class MatchITSTPCQC private: std::shared_ptr mDataRequest; o2::globaltracking::RecoContainer mRecoCont; + std::string mRequestedSources = "ITS,TPC,ITS-TPC"; GID::mask_t mSrc = GID::getSourcesMask("ITS,TPC,ITS-TPC"); - GID::mask_t mAllowedSources = GID::getSourcesMask("ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF"); + GID::mask_t mAllowedSources = GID::getSourcesMask("all"); // TPC gsl::span mTPCTracks; // ITS @@ -387,7 +390,7 @@ class MatchITSTPCQC // for V0s o2::vertexing::DCAFitterN<2> mFitterV0; - TH1F* mK0Mass = nullptr; + TH2F* mK0MassVsPt = nullptr; bool mDoK0QC = false; // whether to fill the K0 QC plot(s) float mCutK0Mass = 0.05; // cut on the difference between the K0 mass and the PDG mass bool mRefit = false; // whether to refit or not diff --git a/Detectors/GLOQC/src/MatchITSTPCQC.cxx b/Detectors/GLOQC/src/MatchITSTPCQC.cxx index 61ad6d181eee1..f810a5d2d4ef2 100644 --- a/Detectors/GLOQC/src/MatchITSTPCQC.cxx +++ b/Detectors/GLOQC/src/MatchITSTPCQC.cxx @@ -86,21 +86,19 @@ void MatchITSTPCQC::deleteHistograms() delete mChi2VsPtDen[i]; delete mFractionITSTPCmatchChi2VsPt[i]; - if (mUseTrkPID) { // Vs Tracking PID hypothesis - for (int j = 0; j < o2::track::PID::NIDs; ++j) { - // Pt - delete mPtNumVsTrkPID[i][j]; - delete mPtDenVsTrkPID[i][j]; - delete mFractionITSTPCmatchPtVsTrkPID[i][j]; - // Phi - delete mPhiNumVsTrkPID[i][j]; - delete mPhiDenVsTrkPID[i][j]; - delete mFractionITSTPCmatchPhiVsTrkPID[i][j]; - // Eta - delete mEtaNumVsTrkPID[i][j]; - delete mEtaDenVsTrkPID[i][j]; - delete mFractionITSTPCmatchEtaVsTrkPID[i][j]; - } + for (int j = 0; j < o2::track::PID::NIDs; ++j) { + // Pt + delete mPtNumVsTrkPID[i][j]; + delete mPtDenVsTrkPID[i][j]; + delete mFractionITSTPCmatchPtVsTrkPID[i][j]; + // Phi + delete mPhiNumVsTrkPID[i][j]; + delete mPhiDenVsTrkPID[i][j]; + delete mFractionITSTPCmatchPhiVsTrkPID[i][j]; + // Eta + delete mEtaNumVsTrkPID[i][j]; + delete mEtaDenVsTrkPID[i][j]; + delete mFractionITSTPCmatchEtaVsTrkPID[i][j]; } // 1/Pt @@ -126,9 +124,7 @@ void MatchITSTPCQC::deleteHistograms() delete mFractionITSTPCmatchDCArVsPt; // K0 - if (mDoK0QC) { - delete mK0Mass; - } + delete mK0MassVsPt; } //__________________________________________________________ @@ -209,7 +205,7 @@ void MatchITSTPCQC::reset() // K0 if (mDoK0QC) { - mK0Mass->Reset(); + mK0MassVsPt->Reset(); } } @@ -381,7 +377,7 @@ bool MatchITSTPCQC::init() if (mDoK0QC) { // V0s - mK0Mass = new TH1F("mK0Mass", "K0 invariant mass", 100, 0.3, 0.7); + mK0MassVsPt = new TH2F("mK0MassVsPt", "K0 invariant mass vs Pt", 100, 0.3, 0.7, 100, 0.f, 20.f); } return true; @@ -394,9 +390,6 @@ void MatchITSTPCQC::initDataRequest() // initialize data request, if it was not already done - if (mDoK0QC) { - mSrc = GID::getSourcesMask("ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF"); - } mSrc &= mAllowedSources; if (mSrc[GID::Source::ITSTPC] == 0 || mSrc[GID::Source::TPC] == 0 || mSrc[GID::Source::ITS] == 0) { @@ -404,9 +397,7 @@ void MatchITSTPCQC::initDataRequest() } mDataRequest = std::make_shared(); - LOG(info) << "Requesting tracks..."; mDataRequest->requestTracks(mSrc, mUseMC); - LOG(info) << "... done requesting tracks"; if (mDoK0QC) { mDataRequest->requestPrimaryVertices(mUseMC); mDataRequest->requestSecondaryVertices(mUseMC); @@ -418,8 +409,6 @@ void MatchITSTPCQC::initDataRequest() void MatchITSTPCQC::run(o2::framework::ProcessingContext& ctx) { - LOG(info) << "Starting"; - // Getting the B field mBz = o2::base::Propagator::Instance()->getNominalBz(); @@ -905,7 +894,7 @@ void MatchITSTPCQC::run(o2::framework::ProcessingContext& ctx) if (mDoK0QC) { // now doing K0S - const auto pvertices = ctx.inputs().get>("pvtx"); + const auto pvertices = mRecoCont.getPrimaryVertices(); LOG(info) << "Found " << pvertices.size() << " primary vertices"; auto v0IDs = mRecoCont.getV0sIdx(); @@ -959,13 +948,16 @@ bool MatchITSTPCQC::processV0(int iv, o2::globaltracking::RecoContainer& recoDat if (mCutK0Mass > 0 && std::abs(std::sqrt(v0sel.calcMass2AsK0()) - 0.497) > mCutK0Mass) { return false; } - mK0Mass->Fill(std::sqrt(v0sel.calcMass2AsK0())); + mK0MassVsPt->Fill(std::sqrt(v0sel.calcMass2AsK0()), v0sel.getPt()); return true; } //__________________________________________________________ bool MatchITSTPCQC::refitV0(const o2::dataformats::V0Index& id, o2::dataformats::V0& v0, o2::globaltracking::RecoContainer& recoData) { + if (!recoData.isTrackSourceLoaded(id.getProngID(0).getSource()) || !recoData.isTrackSourceLoaded(id.getProngID(1).getSource())) { + return false; + } auto seedP = recoData.getTrackParam(id.getProngID(0)); auto seedN = recoData.getTrackParam(id.getProngID(1)); bool isTPConly = (id.getProngID(0).getSource() == o2::dataformats::GlobalTrackID::TPC) || (id.getProngID(1).getSource() == o2::dataformats::GlobalTrackID::TPC); @@ -1232,5 +1224,5 @@ void MatchITSTPCQC::getHistos(TObjArray& objar) objar.Add(mFractionITSTPCmatchDCArVsPt); // V0 - objar.Add(mK0Mass); + objar.Add(mK0MassVsPt); } diff --git a/Detectors/GlobalTrackingWorkflow/qc/CMakeLists.txt b/Detectors/GlobalTrackingWorkflow/qc/CMakeLists.txt index 45a66f8ce5b82..cca69282d20cf 100644 --- a/Detectors/GlobalTrackingWorkflow/qc/CMakeLists.txt +++ b/Detectors/GlobalTrackingWorkflow/qc/CMakeLists.txt @@ -17,7 +17,7 @@ o2_add_library(GlobalTrackingWorkflowQC O2::GLOQC ) -o2_add_executable(match-qc +o2_add_executable(matching-qc COMPONENT_NAME itstpc SOURCES src/itstpc-matching-qc-workflow.cxx PUBLIC_LINK_LIBRARIES O2::GlobalTrackingWorkflowQC diff --git a/Detectors/GlobalTrackingWorkflow/qc/include/GlobalTrackingWorkflowQC/ITSTPCMatchingQCSpec.h b/Detectors/GlobalTrackingWorkflow/qc/include/GlobalTrackingWorkflowQC/ITSTPCMatchingQCSpec.h index 1d76add46839a..6ffd38c8a1c1b 100644 --- a/Detectors/GlobalTrackingWorkflow/qc/include/GlobalTrackingWorkflowQC/ITSTPCMatchingQCSpec.h +++ b/Detectors/GlobalTrackingWorkflow/qc/include/GlobalTrackingWorkflowQC/ITSTPCMatchingQCSpec.h @@ -29,7 +29,7 @@ namespace globaltracking class ITSTPCMatchingQCDevice : public Task { public: - ITSTPCMatchingQCDevice(std::shared_ptr dr, std::shared_ptr req, bool useMC, bool doK0QC) : mDataRequest(dr), mCCDBRequest(req), mUseMC(useMC), mDoK0QC(doK0QC){}; + ITSTPCMatchingQCDevice(std::shared_ptr dr, std::shared_ptr req, bool useMC, bool doK0QC, std::string trkSources) : mDataRequest(dr), mCCDBRequest(req), mUseMC(useMC), mDoK0QC(doK0QC), mTrkSources(trkSources){}; void init(o2::framework::InitContext& ic) final; void run(o2::framework::ProcessingContext& pc) final; void endOfStream(o2::framework::EndOfStreamContext& ec) final; @@ -42,13 +42,14 @@ class ITSTPCMatchingQCDevice : public Task std::shared_ptr mCCDBRequest; bool mUseMC = true; bool mDoK0QC = true; + std::string mTrkSources = "ITS,TPC,ITS-TPC"; }; } // namespace globaltracking namespace framework { -DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC); +DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC, std::string trkSources); } // namespace framework } // namespace o2 diff --git a/Detectors/GlobalTrackingWorkflow/qc/src/ITSTPCMatchingQCSpec.cxx b/Detectors/GlobalTrackingWorkflow/qc/src/ITSTPCMatchingQCSpec.cxx index 9452c945435d9..f1de9698d9e70 100644 --- a/Detectors/GlobalTrackingWorkflow/qc/src/ITSTPCMatchingQCSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/qc/src/ITSTPCMatchingQCSpec.cxx @@ -18,7 +18,8 @@ #include "GLOQC/ITSTPCMatchingQCParams.h" #include "DataFormatsGlobalTracking/RecoContainer.h" #include "DetectorsBase/Propagator.h" - +#include "DetectorsVertexing/SVertexerParams.h" +#include "Framework/CCDBParamSpec.h" #include "CommonUtils/NameConf.h" #include @@ -34,8 +35,8 @@ void ITSTPCMatchingQCDevice::init(InitContext& /*ic*/) const o2::gloqc::ITSTPCMatchingQCParams& params = o2::gloqc::ITSTPCMatchingQCParams::Instance(); mMatchITSTPCQC = std::make_unique(); - mMatchITSTPCQC->init(); mMatchITSTPCQC->setDataRequest(mDataRequest); + mMatchITSTPCQC->setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(mTrkSources)); mMatchITSTPCQC->setPtCut(params.minPtCut); mMatchITSTPCQC->setEtaCut(params.etaCut); mMatchITSTPCQC->setMinNTPCClustersCut(params.minNTPCClustersCut); @@ -50,6 +51,7 @@ void ITSTPCMatchingQCDevice::init(InitContext& /*ic*/) if (mDoK0QC) { mMatchITSTPCQC->setDoK0QC(mDoK0QC); } + mMatchITSTPCQC->init(); } //_____________________________________________________________ @@ -57,6 +59,11 @@ void ITSTPCMatchingQCDevice::init(InitContext& /*ic*/) void ITSTPCMatchingQCDevice::run(o2::framework::ProcessingContext& pc) { o2::base::GRPGeomHelper::instance().checkUpdates(pc); + static bool wasSVParamInitialized = false; + if (!wasSVParamInitialized) { + pc.inputs().get("SVParam"); + wasSVParamInitialized = true; + } mMatchITSTPCQC->run(pc); } @@ -92,6 +99,10 @@ void ITSTPCMatchingQCDevice::finaliseCCDB(ConcreteDataMatcher& matcher, void* ob if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) { return; } + if (matcher == ConcreteDataMatcher("GLO", "SVPARAM", 0)) { + LOG(info) << "SVertexer Params updated from ccdb - but it should not happen... PLEASE CHECK"; + return; + } } } // namespace globaltracking @@ -99,14 +110,18 @@ namespace framework { using GID = o2::dataformats::GlobalTrackID; -DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC) +DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC, std::string trkSources) { std::vector outputs; outputs.emplace_back("GLO", "ITSTPCMATCHQC", 0, Lifetime::Sporadic); auto dataRequest = std::make_shared(); - GID::mask_t mSrc = GID::getSourcesMask("TPC,ITS-TPC"); - dataRequest->requestTracks(mSrc, useMC); + GID::mask_t srcMask = GID::getSourcesMask(trkSources); + dataRequest->requestTracks(srcMask, useMC); + if (doK0QC) { + dataRequest->requestPrimaryVertices(useMC); + dataRequest->requestSecondaryVertices(useMC); + } auto ccdbRequest = std::make_shared(false, // orbitResetTime false, // GRPECS=true false, // GRPLHCIF @@ -114,12 +129,14 @@ DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC) false, // askMatLUT o2::base::GRPGeomRequest::None, // geometry dataRequest->inputs); + + dataRequest->inputs.emplace_back("SVParam", "GLO", "SVPARAM", 0, Lifetime::Condition, ccdbParamSpec("GLO/Config/SVertexerParam")); return DataProcessorSpec{ - "itstpc-matching-qc", - dataRequest->inputs, - outputs, - AlgorithmSpec{adaptFromTask(dataRequest, ccdbRequest, useMC, doK0QC)}, - Options{{}}}; + .name = "itstpc-matching-qc", + .inputs = dataRequest->inputs, + .outputs = outputs, + .algorithm = AlgorithmSpec{adaptFromTask(dataRequest, ccdbRequest, useMC, doK0QC, trkSources)}, + }; } } // namespace framework diff --git a/Detectors/GlobalTrackingWorkflow/qc/src/itstpc-matching-qc-workflow.cxx b/Detectors/GlobalTrackingWorkflow/qc/src/itstpc-matching-qc-workflow.cxx index 8ed9774a38b1a..e3107bedbf1d4 100644 --- a/Detectors/GlobalTrackingWorkflow/qc/src/itstpc-matching-qc-workflow.cxx +++ b/Detectors/GlobalTrackingWorkflow/qc/src/itstpc-matching-qc-workflow.cxx @@ -22,6 +22,7 @@ void customize(std::vector& workflowOptions) std::vector options{ {"disable-mc", o2::framework::VariantType::Bool, false, {"disable use of MC information even if available"}}, {"disable-k0-qc", o2::framework::VariantType::Bool, false, {"disable K0 QC"}}, + {"track-sources", o2::framework::VariantType::String, "ITS,TPC,ITS-TPC", {"comma-separated list of track sources to use"}}, {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}}; std::swap(workflowOptions, options); } @@ -34,14 +35,14 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) { // Update the (declared) parameters if changed from the command line o2::conf::ConfigurableParam::updateFromString(configcontext.options().get("configKeyValues")); - // write the configuration used for the workflow - o2::conf::ConfigurableParam::writeINI("o2-itstpc-matching-qc.ini"); LOG(info) << "ITSTPC matching QC: disable-mc = " << configcontext.options().get("disable-mc"); auto useMC = !configcontext.options().get("disable-mc"); LOG(info) << "ITSTPC matching QC: disable-k0-qc = " << configcontext.options().get("disable-k0-qc"); auto doK0QC = !configcontext.options().get("disable-k0-qc"); + LOG(info) << "ITSTPC matching QC: track-sources = " << configcontext.options().get("track-sources"); + std::string trkSources = configcontext.options().get("track-sources"); WorkflowSpec specs; - specs.emplace_back(getITSTPCMatchingQCDevice(useMC, doK0QC)); + specs.emplace_back(getITSTPCMatchingQCDevice(useMC, doK0QC, trkSources)); return specs; }