Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider the following formatting changes to #13144 #91

Closed
wants to merge 4 commits into from
Closed
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
13 changes: 1 addition & 12 deletions Detectors/GLOQC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions Detectors/GLOQC/include/GLOQC/MatchITSTPCQC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -271,8 +273,9 @@ class MatchITSTPCQC
private:
std::shared_ptr<o2::globaltracking::DataRequest> 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<const o2::tpc::TrackTPC> mTPCTracks;
// ITS
Expand Down Expand Up @@ -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
Expand Down
52 changes: 22 additions & 30 deletions Detectors/GLOQC/src/MatchITSTPCQC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -126,9 +124,7 @@ void MatchITSTPCQC::deleteHistograms()
delete mFractionITSTPCmatchDCArVsPt;

// K0
if (mDoK0QC) {
delete mK0Mass;
}
delete mK0MassVsPt;
}

//__________________________________________________________
Expand Down Expand Up @@ -209,7 +205,7 @@ void MatchITSTPCQC::reset()

// K0
if (mDoK0QC) {
mK0Mass->Reset();
mK0MassVsPt->Reset();
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -394,19 +390,14 @@ 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) {
LOG(fatal) << "We cannot do ITSTPC QC, some sources are missing, check sources in " << mSrc;
}

mDataRequest = std::make_shared<o2::globaltracking::DataRequest>();
LOG(info) << "Requesting tracks...";
mDataRequest->requestTracks(mSrc, mUseMC);
LOG(info) << "... done requesting tracks";
if (mDoK0QC) {
mDataRequest->requestPrimaryVertices(mUseMC);
mDataRequest->requestSecondaryVertices(mUseMC);
Expand All @@ -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();

Expand Down Expand Up @@ -905,7 +894,7 @@ void MatchITSTPCQC::run(o2::framework::ProcessingContext& ctx)

if (mDoK0QC) {
// now doing K0S
const auto pvertices = ctx.inputs().get<gsl::span<o2::dataformats::PrimaryVertex>>("pvtx");
const auto pvertices = mRecoCont.getPrimaryVertices();
LOG(info) << "Found " << pvertices.size() << " primary vertices";

auto v0IDs = mRecoCont.getV0sIdx();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1232,5 +1224,5 @@ void MatchITSTPCQC::getHistos(TObjArray& objar)
objar.Add(mFractionITSTPCmatchDCArVsPt);

// V0
objar.Add(mK0Mass);
objar.Add(mK0MassVsPt);
}
2 changes: 1 addition & 1 deletion Detectors/GlobalTrackingWorkflow/qc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace globaltracking
class ITSTPCMatchingQCDevice : public Task
{
public:
ITSTPCMatchingQCDevice(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> req, bool useMC, bool doK0QC) : mDataRequest(dr), mCCDBRequest(req), mUseMC(useMC), mDoK0QC(doK0QC){};
ITSTPCMatchingQCDevice(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> 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;
Expand All @@ -42,13 +42,14 @@ class ITSTPCMatchingQCDevice : public Task
std::shared_ptr<o2::base::GRPGeomRequest> 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
Expand Down
37 changes: 27 additions & 10 deletions Detectors/GlobalTrackingWorkflow/qc/src/ITSTPCMatchingQCSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TFile.h>

Expand All @@ -34,8 +35,8 @@ void ITSTPCMatchingQCDevice::init(InitContext& /*ic*/)
const o2::gloqc::ITSTPCMatchingQCParams& params = o2::gloqc::ITSTPCMatchingQCParams::Instance();

mMatchITSTPCQC = std::make_unique<o2::gloqc::MatchITSTPCQC>();
mMatchITSTPCQC->init();
mMatchITSTPCQC->setDataRequest(mDataRequest);
mMatchITSTPCQC->setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(mTrkSources));
mMatchITSTPCQC->setPtCut(params.minPtCut);
mMatchITSTPCQC->setEtaCut(params.etaCut);
mMatchITSTPCQC->setMinNTPCClustersCut(params.minNTPCClustersCut);
Expand All @@ -50,13 +51,19 @@ void ITSTPCMatchingQCDevice::init(InitContext& /*ic*/)
if (mDoK0QC) {
mMatchITSTPCQC->setDoK0QC(mDoK0QC);
}
mMatchITSTPCQC->init();
}

//_____________________________________________________________

void ITSTPCMatchingQCDevice::run(o2::framework::ProcessingContext& pc)
{
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
static bool wasSVParamInitialized = false;
if (!wasSVParamInitialized) {
pc.inputs().get<o2::vertexing::SVertexerParams*>("SVParam");
wasSVParamInitialized = true;
}
mMatchITSTPCQC->run(pc);
}

Expand Down Expand Up @@ -92,34 +99,44 @@ 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

namespace framework
{
using GID = o2::dataformats::GlobalTrackID;

DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC)
DataProcessorSpec getITSTPCMatchingQCDevice(bool useMC, bool doK0QC, std::string trkSources)
{
std::vector<OutputSpec> outputs;
outputs.emplace_back("GLO", "ITSTPCMATCHQC", 0, Lifetime::Sporadic);

auto dataRequest = std::make_shared<o2::globaltracking::DataRequest>();
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<o2::base::GRPGeomRequest>(false, // orbitResetTime
false, // GRPECS=true
false, // GRPLHCIF
true, // GRPMagField
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<o2::globaltracking::ITSTPCMatchingQCDevice>(dataRequest, ccdbRequest, useMC, doK0QC)},
Options{{}}};
.name = "itstpc-matching-qc",
.inputs = dataRequest->inputs,
.outputs = outputs,
.algorithm = AlgorithmSpec{adaptFromTask<o2::globaltracking::ITSTPCMatchingQCDevice>(dataRequest, ccdbRequest, useMC, doK0QC, trkSources)},
};
}

} // namespace framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
std::vector<o2::framework::ConfigParamSpec> 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);
}
Expand All @@ -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<std::string>("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<std::string>("disable-mc");
auto useMC = !configcontext.options().get<bool>("disable-mc");
LOG(info) << "ITSTPC matching QC: disable-k0-qc = " << configcontext.options().get<std::string>("disable-k0-qc");
auto doK0QC = !configcontext.options().get<bool>("disable-k0-qc");
LOG(info) << "ITSTPC matching QC: track-sources = " << configcontext.options().get<std::string>("track-sources");
std::string trkSources = configcontext.options().get<std::string>("track-sources");

WorkflowSpec specs;
specs.emplace_back(getITSTPCMatchingQCDevice(useMC, doK0QC));
specs.emplace_back(getITSTPCMatchingQCDevice(useMC, doK0QC, trkSources));
return specs;
}
Loading