Skip to content

Commit

Permalink
Merge branch 'AliceO2Group:dev' into new-detector4
Browse files Browse the repository at this point in the history
  • Loading branch information
pkurash authored Sep 14, 2024
2 parents 84943c2 + 18b692e commit d04a89c
Show file tree
Hide file tree
Showing 87 changed files with 2,166 additions and 1,833 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/datamodel-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
run: |
python3 -m pip install --user -U numpy nltk
python3 -m nltk.downloader -d ~/nltk_data punkt
python3 -m nltk.downloader -d ~/nltk_data punkt_tab
- name: Generate documentation
run: exec bash -exo pipefail O2/scripts/datamodel-doc/update-datamodel.sh
Expand All @@ -71,7 +72,7 @@ jobs:
# Send pull request
# We need to use "gh" ourselves because alisw/pull-request gets
# confused when multiple repos are checked out.
GH_TOKEN="$GITHUB_TOKEN" gh pr create -B master \
GH_TOKEN="$GITHUB_TOKEN" gh pr create -R AliceO2Group/analysis-framework -B master \
--no-maintainer-edit -t 'Automatic data model update' -b "This update \
to the data model documentation was automatically created from \
tonight's O2 dev branch." || true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class MatchGlobalFwd
std::vector<o2::mft::TrackMFT> mMFTMatchPlaneParams; ///< MFT track parameters at matching plane
std::vector<o2::track::TrackParCovFwd> mMCHMatchPlaneParams; ///< MCH track parameters at matching plane

std::map<int, std::vector<std::pair<int, int>>> mCandidates; ///< map each MCH track id to vector of best match candidates
std::map<int, std::vector<std::pair<float, int>>> mCandidates; ///< map each MCH track id to vector of best match candidates

const o2::itsmft::TopologyDictionary* mMFTDict{nullptr}; // cluster patterns dictionary
o2::itsmft::ChipMappingMFT mMFTMapping;
Expand Down
4 changes: 2 additions & 2 deletions Detectors/GlobalTracking/src/MatchGlobalFwd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ void MatchGlobalFwd::ROFMatch(int MFTROFId, int firstMCHROFId, int lastMCHROFId)
}
}

if constexpr (saveAllMode == SaveMode::kSaveNCandidates) { // In saveAllmode save all pairs to output container
if constexpr (saveAllMode == SaveMode::kSaveNCandidates) { // Save best N matching candidates
auto score = mMatchFunc(thisMCHTrack, thisMFTTrack);
std::pair<int, int> scoreID = {score, MFTId};
std::pair<float, int> scoreID = {score, MFTId};
mCandidates[MCHId].push_back(scoreID);
std::sort(mCandidates[MCHId].begin(), mCandidates[MCHId].end(), compare);
if (mCandidates[MCHId].size() > mNCandidates) {
Expand Down
1 change: 1 addition & 0 deletions Detectors/GlobalTracking/src/MatchTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ bool MatchTOF::prepareTPCData()
mTracksLblWork[sector][trkType::UNCONS].emplace_back(mTracksLblWork[sec][trkType::UNCONS][it]);
}
mLTinfos[sector][trkType::UNCONS].emplace_back(mLTinfos[sec][trkType::UNCONS][it]);
mVZtpcOnly[sector].push_back(mVZtpcOnly[sec][it]);
mTracksSectIndexCache[trkType::UNCONS][sector].push_back(itnew);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ namespace o2::trackstudy
struct MCTrackInfo {

inline float getMCTimeMUS() const { return bcInTF * o2::constants::lhc::LHCBunchSpacingMUS; }
inline bool hasITSHitOnLr(int i) const { return (pattITSCl & ((0x1 << i) & 0x7f)) != 0; }
int getNITSClusCont() const;
int getNITSClusForAB() const;
int getLowestITSLayer() const;
int getHighestITSLayer() const;

o2::track::TrackPar track{};
o2::MCCompLabel label{};
Expand All @@ -44,16 +49,33 @@ struct MCTrackInfo {
};

struct RecTrack {
enum FakeFlag {
FakeITS = 0x1 << 0,
FakeTPC = 0x1 << 1,
FakeTRD = 0x1 << 2,
FakeTOF = 0x1 << 3,
FakeITSTPC = 0x1 << 4,
FakeITSTPCTRD = 0x1 << 5,
FakeGLO = 0x1 << 7
};
o2::track::TrackParCov track{};
o2::dataformats::VtxTrackIndex gid{};
o2::dataformats::TimeStampWithError<float, float> ts{};
o2::MCEventLabel pvLabel{};
int pvID = -1;
short pvID = -1;
uint8_t flags = 0;
uint8_t nClITS = 0;
uint8_t nClTPC = 0;
uint8_t pattITS = 0;
int8_t lowestPadRow = -1;
bool isFake = false;

bool isFakeGLO() const { return flags & FakeGLO; }
bool isFakeITS() const { return flags & FakeITS; }
bool isFakeTPC() const { return flags & FakeTPC; }
bool isFakeTRD() const { return flags & FakeTRD; }
bool isFakeTOF() const { return flags & FakeTOF; }
bool isFakeITSTPC() const { return flags & FakeITSTPC; }

ClassDefNV(RecTrack, 1);
};

Expand All @@ -65,7 +87,10 @@ struct TrackFamily { // set of tracks related to the same MC label
int8_t entITS = -1;
int8_t entTPC = -1;
int8_t entITSTPC = -1;
int8_t entITSFound = -1; // ITS track for this MC track, regardless if it was matched to TPC of another track
int8_t flags = 0;
float tpcT0 = -999.;

bool contains(const o2::dataformats::VtxTrackIndex& ref) const
{
for (const auto& tr : recTracks) {
Expand All @@ -75,6 +100,11 @@ struct TrackFamily { // set of tracks related to the same MC label
}
return false;
}
const RecTrack& getTrackWithITS() const { return entITS < 0 ? dummyRecTrack : recTracks[entITS]; }
const RecTrack& getTrackWithTPC() const { return entTPC < 0 ? dummyRecTrack : recTracks[entTPC]; }
const RecTrack& getTrackWithITSTPC() const { return entITSTPC < 0 ? dummyRecTrack : recTracks[entITSTPC]; }
const RecTrack& getTrackWithITSFound() const { return entITSFound < 0 ? dummyRecTrack : recTracks[entITSFound]; }
static RecTrack dummyRecTrack; //

ClassDefNV(TrackFamily, 1);
};
Expand Down
67 changes: 57 additions & 10 deletions Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,28 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
trf.gid = vid; // account(iv, vid);
trf.pvID = pvID;
trf.pvLabel = pvLbl;
while (dm[DetID::ITS] && dm[DetID::TPC]) { // this track should have both ITS and TPC parts, if ITS was mismatched, fill it to its proper MC track slot
auto gidSet = recoData.getSingleDetectorRefs(vid);
if (!gidSet[GTrackID::ITS].isSourceSet()) {
break; // AB track, nothing to check
}
auto lblITS = recoData.getTrackMCLabel(gidSet[GTrackID::ITS]);
if (lblITS == trackFamily.mcTrackInfo.label) {
break; // correct match, no need for special treatment
}
const auto& trcITSF = recoData.getTrackParam(gidSet[GTrackID::ITS]);
if (trcITSF.getPt() < params.minPt || std::abs(trcITSF.getTgl()) > params.maxTgl) {
break; // ignore this track
}
auto entryOfFake = mSelMCTracks.find(lblITS);
if (entryOfFake == mSelMCTracks.end()) { // this MC track was not selected
break;
}
auto& trackFamilyOfFake = entryOfFake->second;
auto& trfOfFake = trackFamilyOfFake.recTracks.emplace_back();
trfOfFake.gid = gidSet[GTrackID::ITS]; // account(iv, vid);
break;
}
if (mVerbose > 1) {
LOGP(info, "Matched rec track {} to MC track {}", vid.asString(), entry->first.asString());
}
Expand Down Expand Up @@ -408,28 +430,49 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
int tcnt = 0;
for (auto& tref : tracks) {
if (tref.gid.isSourceSet()) {
auto gidSet = recoData.getSingleDetectorRefs(tref.gid);
tref.track = recoData.getTrackParam(tref.gid);
tref.isFake = recoData.getTrackMCLabel(tref.gid).isFake();
if (recoData.getTrackMCLabel(tref.gid).isFake()) {
tref.flags |= RecTrack::FakeGLO;
}
auto msk = tref.gid.getSourceDetectorsMask();
if (msk[DetID::ITS]) {
auto gidITS = recoData.getITSContributorGID(tref.gid);
tref.pattITS = getITSPatt(gidITS, tref.nClITS);
if (gidITS.getSource() == VTIndex::ITS && trackFam.entITS < 0) { // has ITS track rather than AB tracklet
trackFam.entITS = tcnt;
if (gidSet[GTrackID::ITS].isSourceSet()) { // has ITS track rather than AB tracklet
tref.pattITS = getITSPatt(gidSet[GTrackID::ITS], tref.nClITS);
if (trackFam.entITS < 0) {
trackFam.entITS = tcnt;
}
auto lblITS = recoData.getTrackMCLabel(gidSet[GTrackID::ITS]);
if (lblITS.isFake()) {
tref.flags |= RecTrack::FakeITS;
}
if (lblITS == trackFam.mcTrackInfo.label) {
trackFam.entITSFound = tcnt;
}
} else { // AB ITS tracklet
tref.pattITS = getITSPatt(gidSet[GTrackID::ITSAB], tref.nClITS);
if (recoData.getTrackMCLabel(gidSet[GTrackID::ITSAB]).isFake()) {
tref.flags |= RecTrack::FakeITS;
}
}
if (msk[DetID::TPC] && trackFam.entITSTPC < 0) { // has both ITS and TPC contribution
trackFam.entITSTPC = tcnt;
if (recoData.getTrackMCLabel(gidSet[GTrackID::ITSTPC]).isFake()) {
tref.flags |= RecTrack::FakeITSTPC;
}
}
}
if (msk[DetID::TPC]) {
auto gidTPC = recoData.getTPCContributorGID(tref.gid);
const auto& trtpc = recoData.getTPCTrack(gidTPC);
const auto& trtpc = recoData.getTPCTrack(gidSet[GTrackID::TPC]);
tref.nClTPC = trtpc.getNClusters();
tref.lowestPadRow = getLowestPadrow(trtpc);
if (trackFam.entTPC < 0) {
trackFam.entTPC = tcnt;
trackFam.tpcT0 = trtpc.getTime0();
}
if (recoData.getTrackMCLabel(gidSet[GTrackID::TPC]).isFake()) {
tref.flags |= RecTrack::FakeTPC;
}
}
float ts = 0, terr = 0;
if (tref.gid.getSource() != GTrackID::ITS) {
Expand Down Expand Up @@ -473,16 +516,20 @@ void TrackMCStudy::process(const o2::globaltracking::RecoContainer& recoData)
std::string decTreeName = fmt::format("dec{}", params.decayPDG[id]);
for (const auto& dec : mDecaysMaps[id]) {
decFam.clear();
bool skip = false;
for (int idd = dec.daughterFirst; idd <= dec.daughterLast; idd++) {
auto dtLbl = mDecProdLblPool[idd]; // daughter MC label
const auto& dtFamily = mSelMCTracks[dtLbl];
if (dtFamily.mcTrackInfo.pdgParent != dec.pdg) {
LOGP(error, "{}-th decay (pdg={}): {} in {}:{} range refers to MC track with pdgParent = {}", id, params.decayPDG[id], idd, dec.daughterFirst, dec.daughterLast, dtFamily.mcTrackInfo.pdgParent);
continue;
skip = true;
break;
}
decFam.push_back(dtFamily);
}
(*mDBGOut) << decTreeName.c_str() << "pdgPar=" << dec.pdg << "trPar=" << dec.parent << "prod=" << decFam << "\n";
if (!skip) {
(*mDBGOut) << decTreeName.c_str() << "pdgPar=" << dec.pdg << "trPar=" << dec.parent << "prod=" << decFam << "\n";
}
}
}

Expand Down Expand Up @@ -745,7 +792,7 @@ bool TrackMCStudy::addMCParticle(const MCTrack& mcPart, const o2::MCCompLabel& l
mcEntry.mcTrackInfo.occITS = mITSOcc[lb.getEventID()];
int moth = -1;
o2::MCCompLabel mclbPar;
if (!mcPart.isPrimary() && (moth = mcPart.getMotherTrackId()) >= 0) {
if ((moth = mcPart.getMotherTrackId()) >= 0) {
const auto& mcPartPar = mCurrMCTracks[moth];
mcEntry.mcTrackInfo.pdgParent = mcPartPar.GetPdgCode();
}
Expand Down
66 changes: 66 additions & 0 deletions Detectors/GlobalTrackingWorkflow/study/src/TrackMCStudyTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,69 @@
// or submit itself to any jurisdiction.

#include "GlobalTrackingStudy/TrackMCStudyTypes.h"

namespace o2::trackstudy
{

RecTrack TrackFamily::dummyRecTrack;

// get longest number of clusters on consecutive layers
int MCTrackInfo::getNITSClusCont() const
{
if (nITSCl < 2) {
return nITSCl;
}
int longest = 0, current = 0;
for (int i = 0; i < 7; i++) {
if (pattITSCl & (0x1 << i)) {
longest = ++current;
} else {
current = 0;
}
}
return longest;
}

// check how many clusters ITS-TPC afterburner could see (consecutively occupied layers starting from the last one)
int MCTrackInfo::getNITSClusForAB() const
{
int ncl = 0;
if (nITSCl) {
for (int i = 6; i > 2; i--) {
if (pattITSCl & (0x1 << i)) {
ncl++;
} else {
break;
}
}
}
return ncl;
}

// lowest ITS layer with cluster
int MCTrackInfo::getLowestITSLayer() const
{
if (nITSCl) {
for (int i = 0; i < 7; i++) {
if (pattITSCl & (0x1 << i)) {
return i;
}
}
}
return -1;
}

// highest ITS layer with cluster
int MCTrackInfo::getHighestITSLayer() const
{
if (nITSCl) {
for (int i = 7; i--;) {
if (pattITSCl & (0x1 << i)) {
return i;
}
}
}
return -1;
}

} // namespace o2::trackstudy
4 changes: 2 additions & 2 deletions Detectors/TPC/workflow/src/EntropyEncoderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void EntropyEncoderSpec::run(ProcessingContext& pc)
if (clusters.nTracks && clusters.solenoidBz != -1e6f && clusters.solenoidBz != mParam->bzkG) {
throw std::runtime_error("Configured solenoid Bz does not match value used for track model encoding");
}
if (clusters.nTracks && clusters.maxTimeBin != -1e6 && clusters.maxTimeBin != mParam->par.continuousMaxTimeBin) {
if (clusters.nTracks && clusters.maxTimeBin != -1e6 && clusters.maxTimeBin != mParam->continuousMaxTimeBin) {
throw std::runtime_error("Configured max time bin does not match value used for track model encoding");
}
mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
Expand All @@ -162,7 +162,7 @@ void EntropyEncoderSpec::run(ProcessingContext& pc)
const float totalT = std::max(mFastTransform->getMaxDriftTime(0), mFastTransform->getMaxDriftTime(GPUCA_NSLICES / 2));

unsigned int offset = 0, lasti = 0;
const unsigned int maxTime = (mParam->par.continuousMaxTimeBin + 1) * o2::tpc::ClusterNative::scaleTimePacked - 1;
const unsigned int maxTime = (mParam->continuousMaxTimeBin + 1) * o2::tpc::ClusterNative::scaleTimePacked - 1;
#ifdef WITH_OPENMP
#pragma omp parallel for firstprivate(offset, lasti) num_threads(mNThreads)
#endif
Expand Down
5 changes: 3 additions & 2 deletions Framework/AODMerger/src/aodStrainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ int main(int argc, char* argv[])
auto outputFile = TFile::Open(outputFileName.c_str(), "RECREATE", "", 505);
TDirectory* outputDir = nullptr;
TString line(inputAO2D.c_str());
if (line.BeginsWith("alien://")) {
TGrid::Connect("alien:");
if (line.BeginsWith("alien://") && !gGrid && !TGrid::Connect("alien:")) {
printf("Error: Could not connect to AliEn.\n");
return -1;
}
printf("Processing input file: %s\n", line.Data());
auto inputFile = TFile::Open(line);
Expand Down
8 changes: 4 additions & 4 deletions GPU/GPUTracking/Base/GPUParam.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void GPUParam::SetDefaults(float solenoidBz)
par.assumeConstantBz = false;
par.toyMCEventsFlag = false;
par.continuousTracking = false;
par.continuousMaxTimeBin = 0;
continuousMaxTimeBin = 0;
par.debugLevel = 0;
par.earlyTpcTransform = false;
}
Expand All @@ -131,7 +131,7 @@ void GPUParam::UpdateSettings(const GPUSettingsGRP* g, const GPUSettingsProcessi
par.assumeConstantBz = g->constBz;
par.toyMCEventsFlag = g->homemadeEvents;
par.continuousTracking = g->continuousMaxTimeBin != 0;
par.continuousMaxTimeBin = g->continuousMaxTimeBin == -1 ? GPUSettings::TPC_MAX_TF_TIME_BIN : g->continuousMaxTimeBin;
continuousMaxTimeBin = g->continuousMaxTimeBin == -1 ? GPUSettings::TPC_MAX_TF_TIME_BIN : g->continuousMaxTimeBin;
}
par.earlyTpcTransform = rec.tpc.forceEarlyTransform == -1 ? (!par.continuousTracking) : rec.tpc.forceEarlyTransform;
qptB5Scaler = CAMath::Abs(bzkG) > 0.1f ? CAMath::Abs(bzkG) / 5.006680f : 1.f; // Repeat here, since passing in g is optional
Expand All @@ -140,9 +140,9 @@ void GPUParam::UpdateSettings(const GPUSettingsGRP* g, const GPUSettingsProcessi
UpdateRun3ClusterErrors(p->param.tpcErrorParamY, p->param.tpcErrorParamZ);
}
if (w) {
par.dodEdx = w->steps.isSet(GPUDataTypes::RecoStep::TPCdEdx);
par.dodEdx = dodEdxDownscaled = w->steps.isSet(GPUDataTypes::RecoStep::TPCdEdx);
if (par.dodEdx && p && p->tpcDownscaledEdx != 0) {
par.dodEdx = (rand() % 100) < p->tpcDownscaledEdx;
dodEdxDownscaled = (rand() % 100) < p->tpcDownscaledEdx;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions GPU/GPUTracking/Base/GPUParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct GPUParam_t {
float bzCLight;
float qptB5Scaler;

signed char dodEdxDownscaled;
int continuousMaxTimeBin;

GPUTPCGeometry tpcGeometry; // TPC Geometry
GPUTPCGMPolynomialField polynomialField; // Polynomial approx. of magnetic field for TPC GM
const unsigned int* occupancyMap; // Ptr to TPC occupancy map
Expand Down
Loading

0 comments on commit d04a89c

Please sign in to comment.