Skip to content

Commit baaa0e6

Browse files
committed
and allow multiple configs for the fasttracker
1 parent db431c4 commit baaa0e6

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();
@@ -328,6 +327,31 @@ struct OnTheFlyTracker {
328327
histPointers.insert({histPath + "hSimMultiplicity", histos.add((histPath + "hSimMultiplicity").c_str(), "hSimMultiplicity", {kTH1D, {{axes.axisMultiplicity}}})});
329328
histPointers.insert({histPath + "hRecoMultiplicity", histos.add((histPath + "hRecoMultiplicity").c_str(), "hRecoMultiplicity", {kTH1D, {{axes.axisMultiplicity}}})});
330329

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

@@ -447,28 +471,7 @@ struct OnTheFlyTracker {
447471
// Set seed for TGenPhaseSpace
448472
rand.SetSeed(seed);
449473

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

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

554557
tracksAlice3.clear();
555558
ghostTracksAlice3.clear();
@@ -694,9 +697,9 @@ struct OnTheFlyTracker {
694697
nSiliconHits[i] = 0;
695698
nTPCHits[i] = 0;
696699
if (enableSecondarySmearing) {
697-
nHits[i] = fastTracker.FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i], dNdEta);
698-
nSiliconHits[i] = fastTracker.GetNSiliconPoints();
699-
nTPCHits[i] = fastTracker.GetNGasPoints();
700+
nHits[i] = fastTracker[icfg]->FastTrack(xiDaughterTrackParCovsPerfect[i], xiDaughterTrackParCovsTracked[i], dNdEta);
701+
nSiliconHits[i] = fastTracker[icfg]->GetNSiliconPoints();
702+
nTPCHits[i] = fastTracker[icfg]->GetNGasPoints();
700703

701704
if (nHits[i] < 0) { // QA
702705
histos.fill(HIST("hFastTrackerQA"), o2::math_utils::abs(nHits[i]));
@@ -707,8 +710,8 @@ struct OnTheFlyTracker {
707710
} else {
708711
continue; // extra sure
709712
}
710-
for (uint32_t ih = 0; ih < fastTracker.GetNHits(); ih++) {
711-
histos.fill(HIST("hFastTrackerHits"), fastTracker.GetHitZ(ih), std::hypot(fastTracker.GetHitX(ih), fastTracker.GetHitY(ih)));
713+
for (uint32_t ih = 0; ih < fastTracker[icfg]->GetNHits(); ih++) {
714+
histos.fill(HIST("hFastTrackerHits"), fastTracker[icfg]->GetHitZ(ih), std::hypot(fastTracker[icfg]->GetHitX(ih), fastTracker[icfg]->GetHitY(ih)));
712715
}
713716
} else {
714717
isReco[i] = true;
@@ -857,8 +860,8 @@ struct OnTheFlyTracker {
857860
if (cascadeDecaySettings.trackXi) {
858861
// optionally, add the points in the layers before the decay of the Xi
859862
// will back-track the perfect MC cascade to relevant layers, find hit, smear and add to smeared cascade
860-
for (int i = fastTracker.GetLayers().size() - 1; i >= 0; --i) {
861-
o2::fastsim::DetLayer layer = fastTracker.GetLayer(i);
863+
for (int i = fastTracker[icfg]->GetLayers().size() - 1; i >= 0; --i) {
864+
o2::fastsim::DetLayer layer = fastTracker[icfg]->GetLayer(i);
862865
if (layer.isInert()) {
863866
continue; // Not an active tracking layer
864867
}
@@ -928,6 +931,7 @@ struct OnTheFlyTracker {
928931
histos.fill(HIST("hMassLambda"), thisCascade.mLambda);
929932
histos.fill(HIST("hMassXi"), thisCascade.mXi);
930933
histos.fill(HIST("hFoundVsFindable"), thisCascade.findableClusters, thisCascade.foundClusters);
934+
getHist(TH1, histPath + "hMassXi")->Fill(thisCascade.mXi);
931935
}
932936

933937
// add this cascade to vector (will fill cursor later with collision ID)
@@ -945,7 +949,7 @@ struct OnTheFlyTracker {
945949

946950
bool reconstructed = true;
947951
if (enablePrimarySmearing && !fastPrimaryTrackerSettings.fastTrackPrimaries) {
948-
reconstructed = mSmearer[cfgId]->smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta);
952+
reconstructed = mSmearer[icfg]->smearTrack(trackParCov, mcParticle.pdgCode(), dNdEta);
949953
} else if (fastPrimaryTrackerSettings.fastTrackPrimaries) {
950954
o2::track::TrackParCov o2Track;
951955
o2::upgrade::convertMCParticleToO2Track(mcParticle, o2Track, pdgDB);
@@ -1039,9 +1043,6 @@ struct OnTheFlyTracker {
10391043
// *+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*+~+*
10401044

10411045
// debug / informational
1042-
// histos.fill(HIST("hSimMultiplicity"), multiplicityCounter);
1043-
// histos.fill(HIST("hRecoMultiplicity"), tracksAlice3.size());
1044-
// histos.fill(HIST("hPVz"), primaryVertex.getZ());
10451046
getHist(TH1, histPath + "hSimMultiplicity")->Fill(multiplicityCounter);
10461047
getHist(TH1, histPath + "hRecoMultiplicity")->Fill(tracksAlice3.size());
10471048
getHist(TH1, histPath + "hPVz")->Fill(primaryVertex.getZ());
@@ -1104,7 +1105,7 @@ struct OnTheFlyTracker {
11041105
tableTracksDCACov(dcaInfo.getSigmaY2(), dcaInfo.getSigmaZ2());
11051106
}
11061107
}
1107-
tableOTFLUTConfigId(cfgId);
1108+
tableOTFLUTConfigId(icfg);
11081109
tableStoredTracks(tableCollisions.lastIndex(), trackType, trackParCov.getX(), trackParCov.getAlpha(), trackParCov.getY(), trackParCov.getZ(), trackParCov.getSnp(), trackParCov.getTgl(), trackParCov.getQ2Pt());
11091110
tableTracksExtension(trackParCov.getPt(), trackParCov.getP(), trackParCov.getEta(), trackParCov.getPhi());
11101111

@@ -1199,18 +1200,15 @@ struct OnTheFlyTracker {
11991200
}
12001201

12011202
// do bookkeeping of fastTracker tracking
1202-
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker.GetCovMatNotOK());
1203-
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker.GetCovMatOK());
1203+
histos.fill(HIST("hCovMatOK"), 0.0f, fastTracker[icfg]->GetCovMatNotOK());
1204+
histos.fill(HIST("hCovMatOK"), 1.0f, fastTracker[icfg]->GetCovMatOK());
12041205
} // end process
12051206

12061207
void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles)
12071208
{
1208-
static int ievt = 0;
1209-
std::cout << "Proccesing event " << ievt << std::endl;
12101209
for (size_t icfg = 0; icfg < mSmearer.size(); ++icfg) {
12111210
processWithLUTs(mcCollision, mcParticles, static_cast<int>(icfg));
12121211
}
1213-
ievt++;
12141212
}
12151213
};
12161214

0 commit comments

Comments
 (0)