Skip to content

Commit e7101fa

Browse files
committed
and allow multiple configs for the fasttracker
1 parent 1547a51 commit e7101fa

File tree

2 files changed

+52
-53
lines changed

2 files changed

+52
-53
lines changed

ALICE3/Core/FastTracker.cxx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,12 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
442442
inputTrack.getXYZGlo(posIni);
443443
const float initialRadius = std::hypot(posIni[0], posIni[1]);
444444
const float kTrackingMargin = 0.1;
445-
const int kMaxNumberOfDetectors = 20;
446-
if (kMaxNumberOfDetectors < layers.size()) {
447-
LOG(fatal) << "Too many layers in FastTracker, increase kMaxNumberOfDetectors";
448-
return -1; // too many layers
449-
}
445+
446+
// Delphes sets this to 20, but does not count all points in the tpc as layers which we do here
447+
// Loop over all the added layers to prevent crash when adding the tpc
448+
// Should not affect efficiency calculation
449+
const int kMaxNumberOfDetectors = layers.size();
450+
450451
int firstActiveLayer = -1; // first layer that is not inert
451452
for (size_t i = 0; i < layers.size(); ++i) {
452453
if (!layers[i].isInert()) {
@@ -462,7 +463,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
462463
const bool applyAngularCorrection = true;
463464

464465
goodHitProbability.clear();
465-
for (int i = 0; i < kMaxNumberOfDetectors; ++i) {
466+
for (size_t i = 0; i < layers.size(); ++i) {
466467
goodHitProbability.push_back(-1.);
467468
}
468469
goodHitProbability[0] = 1.; // we use layer zero to accumulate
@@ -650,7 +651,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
650651

651652
// generate efficiency
652653
float eff = 1.;
653-
for (int i = 0; i < kMaxNumberOfDetectors; i++) {
654+
for (size_t i = 0; i < layers.size(); i++) {
654655
float iGoodHit = goodHitProbability[i];
655656
if (iGoodHit <= 0)
656657
continue;

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ struct OnTheFlyTracker {
9494
Configurable<float> maxEta{"maxEta", 1.5, "maximum eta to consider viable"};
9595
Configurable<float> multEtaRange{"multEtaRange", 0.8, "eta range to compute the multiplicity"};
9696
Configurable<float> minPt{"minPt", 0.1, "minimum pt to consider viable"};
97-
Configurable<bool> enableLUT{"enableLUT", false, "Enable track smearing"};
9897
Configurable<bool> enablePrimarySmearing{"enablePrimarySmearing", false, "Enable smearing of primary particles"};
9998
Configurable<bool> enableSecondarySmearing{"enableSecondarySmearing", false, "Enable smearing of weak decay daughters"};
10099
Configurable<bool> enableNucleiSmearing{"enableNucleiSmearing", false, "Enable smearing of nuclei"};
@@ -147,7 +146,7 @@ struct OnTheFlyTracker {
147146
Configurable<int> minSiliconHits{"minSiliconHits", 6, "minimum number of silicon hits to accept track"};
148147
Configurable<int> minSiliconHitsIfTPCUsed{"minSiliconHitsIfTPCUsed", 2, "minimum number of silicon hits to accept track in case TPC info is present"};
149148
Configurable<int> minTPCClusters{"minTPCClusters", 70, "minimum number of TPC hits necessary to consider minSiliconHitsIfTPCUsed"};
150-
Configurable<std::string> alice3geo{"alice3geo", "2", "0: ALICE 3 v1, 1: ALICE 3 v4, 2: ALICE 3 Sep 2025, or path to ccdb with a3 geo"};
149+
Configurable<std::vector<std::string>> alice3geo{"alice3geo", std::vector<std::string>{"2"}, "0: ALICE 3 v1, 1: ALICE 3 v4, 2: ALICE 3 Sep 2025, or path to ccdb with a3 geo (ccdb:Users/u/user/)"};
151150
Configurable<bool> applyZacceptance{"applyZacceptance", false, "apply z limits to detector layers or not"};
152151
Configurable<bool> applyMSCorrection{"applyMSCorrection", true, "apply ms corrections for secondaries or not"};
153152
Configurable<bool> applyElossCorrection{"applyElossCorrection", true, "apply eloss corrections for secondaries or not"};
@@ -181,7 +180,8 @@ struct OnTheFlyTracker {
181180
o2::vertexing::DCAFitterN<2> fitter;
182181

183182
// FastTracker machinery
184-
o2::fastsim::FastTracker fastTracker;
183+
// o2::fastsim::FastTracker fastTracker;
184+
std::vector<std::unique_ptr<o2::fastsim::FastTracker>> fastTracker;
185185
o2::fastsim::FastTracker fastPrimaryTracker;
186186

187187
// Class to hold the track information for the O2 vertexing
@@ -267,11 +267,10 @@ struct OnTheFlyTracker {
267267
static constexpr int kMaxLUTConfigs = 20;
268268
void init(o2::framework::InitContext&)
269269
{
270-
271270
ccdb->setURL("http://alice-ccdb.cern.ch");
272271
ccdb->setTimestamp(-1);
273272

274-
if (enableLUT) {
273+
if (enablePrimarySmearing) {
275274
auto loadLUT = [&](int icfg, int pdg, const std::vector<std::string>& tables) {
276275
const bool foundNewCfg = static_cast<size_t>(icfg) < tables.size();
277276
const std::string& lutFile = foundNewCfg ? tables[icfg] : tables.front();
@@ -330,6 +329,31 @@ struct OnTheFlyTracker {
330329
histPointers.insert({histPath + "hSimMultiplicity", histos.add((histPath + "hSimMultiplicity").c_str(), "hSimMultiplicity", {kTH1D, {{axes.axisMultiplicity}}})});
331330
histPointers.insert({histPath + "hRecoMultiplicity", histos.add((histPath + "hRecoMultiplicity").c_str(), "hRecoMultiplicity", {kTH1D, {{axes.axisMultiplicity}}})});
332331

332+
if (enableSecondarySmearing) {
333+
fastTracker.emplace_back(std::make_unique<o2::fastsim::FastTracker>());
334+
fastTracker[icfg]->SetMagneticField(magneticField);
335+
fastTracker[icfg]->SetApplyZacceptance(fastTrackerSettings.applyZacceptance);
336+
fastTracker[icfg]->SetApplyMSCorrection(fastTrackerSettings.applyMSCorrection);
337+
fastTracker[icfg]->SetApplyElossCorrection(fastTrackerSettings.applyElossCorrection);
338+
339+
if (fastTrackerSettings.alice3geo.value[icfg] == "0") {
340+
fastTracker[icfg]->AddSiliconALICE3v2(fastTrackerSettings.pixelRes);
341+
} else if (fastTrackerSettings.alice3geo.value[icfg] == "1") {
342+
fastTracker[icfg]->AddSiliconALICE3v4(fastTrackerSettings.pixelRes);
343+
fastTracker[icfg]->AddTPC(0.1, 0.1);
344+
} else if (fastTrackerSettings.alice3geo.value[icfg] == "2") {
345+
fastTracker[icfg]->AddSiliconALICE3(fastTrackerSettings.scaleVD, fastTrackerSettings.pixelRes);
346+
} else {
347+
fastTracker[icfg]->AddGenericDetector(fastTrackerSettings.alice3geo.value[icfg], ccdb.operator->());
348+
}
349+
350+
// print fastTracker settings
351+
fastTracker[icfg]->Print();
352+
histPointers.insert({histPath + "hMassXi", histos.add((histPath + "hMassXi").c_str(), "hMassXi", {kTH1D, {{axes.axisXiMass}}})});
353+
354+
}
355+
356+
333357
} // end config loop
334358
}
335359

@@ -449,28 +473,7 @@ struct OnTheFlyTracker {
449473
// Set seed for TGenPhaseSpace
450474
rand.SetSeed(seed);
451475

452-
// configure FastTracker
453-
if (enableSecondarySmearing) {
454-
fastTracker.SetMagneticField(magneticField);
455-
fastTracker.SetApplyZacceptance(fastTrackerSettings.applyZacceptance);
456-
fastTracker.SetApplyMSCorrection(fastTrackerSettings.applyMSCorrection);
457-
fastTracker.SetApplyElossCorrection(fastTrackerSettings.applyElossCorrection);
458-
459-
if (fastTrackerSettings.alice3geo.value == "0") {
460-
fastTracker.AddSiliconALICE3v2(fastTrackerSettings.pixelRes);
461-
} else if (fastTrackerSettings.alice3geo.value == "1") {
462-
fastTracker.AddSiliconALICE3v4(fastTrackerSettings.pixelRes);
463-
fastTracker.AddTPC(0.1, 0.1);
464-
} else if (fastTrackerSettings.alice3geo.value == "2") {
465-
fastTracker.AddSiliconALICE3(fastTrackerSettings.scaleVD, fastTrackerSettings.pixelRes);
466-
} else {
467-
fastTracker.AddGenericDetector(fastTrackerSettings.alice3geo, ccdb.operator->());
468-
}
469-
470-
// print fastTracker settings
471-
fastTracker.Print();
472-
}
473-
476+
// Configure FastTracker for primaries
474477
if (fastPrimaryTrackerSettings.fastTrackPrimaries) {
475478
fastPrimaryTracker.SetMagneticField(magneticField);
476479
fastPrimaryTracker.SetApplyZacceptance(fastPrimaryTrackerSettings.applyZacceptance);
@@ -548,10 +551,10 @@ struct OnTheFlyTracker {
548551
}
549552

550553
float dNdEta = 0.f; // Charged particle multiplicity to use in the efficiency evaluation
551-
void processWithLUTs(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, int const& cfgId)
554+
void processWithLUTs(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles, int const& icfg)
552555
{
553556
int lastTrackIndex = tableStoredTracksCov.lastIndex() + 1; // bookkeep the last added track
554-
const std::string histPath = "Configuration_" + std::to_string(cfgId) + "/";
557+
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
555558

556559
tracksAlice3.clear();
557560
ghostTracksAlice3.clear();
@@ -697,9 +700,9 @@ struct OnTheFlyTracker {
697700
nSiliconHits[i] = 0;
698701
nTPCHits[i] = 0;
699702
if (enableSecondarySmearing) {
700-
nHits[i] = fastTracker.FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i], dNdEta);
701-
nSiliconHits[i] = fastTracker.GetNSiliconPoints();
702-
nTPCHits[i] = fastTracker.GetNGasPoints();
703+
nHits[i] = fastTracker[icfg]->FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i], dNdEta);
704+
nSiliconHits[i] = fastTracker[icfg]->GetNSiliconPoints();
705+
nTPCHits[i] = fastTracker[icfg]->GetNGasPoints();
703706

704707
if (nHits[i] < 0) { // QA
705708
histos.fill(HIST("hFastTrackerQA"), o2::math_utils::abs(nHits[i]));
@@ -710,8 +713,8 @@ struct OnTheFlyTracker {
710713
} else {
711714
continue; // extra sure
712715
}
713-
for (uint32_t ih = 0; ih < fastTracker.GetNHits(); ih++) {
714-
histos.fill(HIST("hFastTrackerHits"), fastTracker.GetHitZ(ih), std::hypot(fastTracker.GetHitX(ih), fastTracker.GetHitY(ih)));
716+
for (uint32_t ih = 0; ih < fastTracker[icfg]->GetNHits(); ih++) {
717+
histos.fill(HIST("hFastTrackerHits"), fastTracker[icfg]->GetHitZ(ih), std::hypot(fastTracker[icfg]->GetHitX(ih), fastTracker[icfg]->GetHitY(ih)));
715718
}
716719
} else {
717720
isReco[i] = true;
@@ -860,8 +863,8 @@ struct OnTheFlyTracker {
860863
if (cascadeDecaySettings.trackXi) {
861864
// optionally, add the points in the layers before the decay of the Xi
862865
// will back-track the perfect MC cascade to relevant layers, find hit, smear and add to smeared cascade
863-
for (int i = fastTracker.GetLayers().size() - 1; i >= 0; --i) {
864-
o2::fastsim::DetLayer layer = fastTracker.GetLayer(i);
866+
for (int i = fastTracker[icfg]->GetLayers().size() - 1; i >= 0; --i) {
867+
o2::fastsim::DetLayer layer = fastTracker[icfg]->GetLayer(i);
865868
if (layer.isInert()) {
866869
continue; // Not an active tracking layer
867870
}
@@ -931,6 +934,7 @@ struct OnTheFlyTracker {
931934
histos.fill(HIST("hMassLambda"), thisCascade.mLambda);
932935
histos.fill(HIST("hMassXi"), thisCascade.mXi);
933936
histos.fill(HIST("hFoundVsFindable"), thisCascade.findableClusters, thisCascade.foundClusters);
937+
getHist(TH1, histPath + "hMassXi")->Fill(thisCascade.mXi);
934938
}
935939

936940
// add this cascade to vector (will fill cursor later with collision ID)
@@ -948,7 +952,7 @@ struct OnTheFlyTracker {
948952

949953
bool reconstructed = true;
950954
if (enablePrimarySmearing && !fastPrimaryTrackerSettings.fastTrackPrimaries) {
951-
reconstructed = mSmearer[cfgId]->smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta);
955+
reconstructed = mSmearer[icfg]->smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta);
952956
} else if (fastPrimaryTrackerSettings.fastTrackPrimaries) {
953957
o2::track::TrackParCov o2Track;
954958
o2::upgrade::convertMCParticleToO2Track(mcParticle, o2Track, pdgDB);
@@ -1042,9 +1046,6 @@ struct OnTheFlyTracker {
10421046
// *+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*
10431047

10441048
// debug / informational
1045-
// histos.fill(HIST("hSimMultiplicity"), multiplicityCounter);
1046-
// histos.fill(HIST("hRecoMultiplicity"), tracksAlice3.size());
1047-
// histos.fill(HIST("hPVz"), primaryVertex.getZ());
10481049
getHist(TH1, histPath + "hSimMultiplicity")->Fill(multiplicityCounter);
10491050
getHist(TH1, histPath + "hRecoMultiplicity")->Fill(tracksAlice3.size());
10501051
getHist(TH1, histPath + "hPVz")->Fill(primaryVertex.getZ());
@@ -1107,7 +1108,7 @@ struct OnTheFlyTracker {
11071108
tableTracksDCACov(dcaInfo.getSigmaY2(), dcaInfo.getSigmaZ2());
11081109
}
11091110
}
1110-
tableOTFLUTConfigId(cfgId);
1111+
tableOTFLUTConfigId(icfg);
11111112
tableStoredTracks(tableCollisions.lastIndex(), trackType, trackParCov.getX(), trackParCov.getAlpha(), trackParCov.getY(), trackParCov.getZ(), trackParCov.getSnp(), trackParCov.getTgl(), trackParCov.getQ2Pt());
11121113
tableTracksExtension(trackParCov.getPt(), trackParCov.getP(), trackParCov.getEta(), trackParCov.getPhi());
11131114

@@ -1202,18 +1203,15 @@ struct OnTheFlyTracker {
12021203
}
12031204

12041205
// do bookkeeping of fastTracker tracking
1205-
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.GetCovMatNotOK());
1206-
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.GetCovMatOK());
1206+
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker[icfg]->GetCovMatNotOK());
1207+
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker[icfg]->GetCovMatOK());
12071208
} // end process
12081209

12091210
void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles)
12101211
{
1211-
static int ievt = 0;
1212-
std::cout << "Proccesing event " << ievt << std::endl;
12131212
for (size_t icfg = 0; icfg < mSmearer.size(); ++icfg) {
12141213
processWithLUTs(mcCollision, mcParticles, static_cast<int>(icfg));
12151214
}
1216-
ievt++;
12171215
}
12181216
};
12191217

0 commit comments

Comments
 (0)