Skip to content

Conversation

@anthoak13
Copy link
Member

No description provided.

const std::vector<AtHit::MCSimPoint> &GetMCSimPointArray() const { return fMCSimPointArray; }

static Bool_t SortHit(const AtHit &lhs, const AtHit &rhs) { return lhs.GetPadNum() < rhs.GetPadNum(); }
static Bool_t SortHit(const AtHit &lhs, const AtHit &rhs) { return lhs.GetPadNum() > rhs.GetPadNum(); }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be reverted and a function like

static Bool_t SortHitReverse(const AtHit &lhs, const AtHit &rhs) { return lhs.GetPadNum() > rhs.GetPadNum(); }

added


std::vector<AtHit> GetHitArrayObject() { return ContainerManip::GetObjectVector(fHitArray); }
// const std::vector<AtHit> &GetHitArrayConst() const { return fHitArray; }
//const std::vector<AtHit> &GetHitArrayConst() const { return fHitArray; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will probably fail the linter (clang-format)

std::cout << cYELLOW << " - Material : " << mat->GetName() << cNORMAL << "\n";
}

*/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yassid Will this break things for experiments? I'm not that familiar with the GenFit code.

try {

for (auto iStep = 0; iStep < 200; ++iStep) {
for (auto iStep = 0; iStep < 600; ++iStep) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yassid Same questions on this bit. I image this should track teach hit cluster for the backwards propogation to smooth?

Comment on lines +51 to +72
track.SortHitArrayTime();
auto &hitArray = track.GetHitArray();
size_t numHits = hitArray.size();
size_t numHitsToUse;
if (numHits >= 50)
numHitsToUse = numHits * 10 / 10; // 50% of the hits

if (numHits < 50)
numHitsToUse = numHits;

std::sort(hitArray.begin(), hitArray.end(), [](const std::unique_ptr<AtHit> &a, const std::unique_ptr<AtHit> &b) {
return a->GetTimeStamp() > b->GetTimeStamp();
});

std::vector<std::unique_ptr<AtHit>> first20PercentHits;
first20PercentHits.reserve(numHitsToUse);

for (size_t i = 0; i < numHitsToUse; ++i) {
first20PercentHits.push_back(std::make_unique<AtHit>(*hitArray[i]));
}

auto circularTracks = RansacSmoothRadius.Solve(ContainerManip::GetConstPointerVector(first20PercentHits)) // Only part of the spiral is used
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be added as a flag in the class. Something like bool fFitPercentage so the old behavior is preserved for those that rely on it.

Comment on lines +181 to +242
for (auto &track : tracks) {
if (track.GetHitArray().size() > 0)
SetTrackInitialParameters(track);
//retEvent->AddTrack(std::move(track));
}

bool kMergeTracks = false;

std::vector<AtTrack> mergedTracks;
if(tracks.size() > 2){

//const double tolerance = 2.0;
std::vector<bool> processed(tracks.size(), false);

for(Int_t numtr = 0; numtr < tracks.size(); numtr++){
std::cout << "Theta " << tracks.at(numtr).GetGeoTheta() << std::endl;
if (processed[numtr]) continue;

auto track0 = tracks.at(numtr);
auto hitArray0 = track0.GetHitArrayObject();
auto theta0 = track0.GetGeoTheta();

AtTrack newTrack;

for(auto &hit : hitArray0){
newTrack.AddHit(hit);

}

if (numtr + 1 < tracks.size()) {

for (size_t tr = numtr + 1; tr < tracks.size(); ++tr) {
if (processed[tr]) continue;

auto track = tracks.at(tr);
auto hitArray = track.GetHitArrayObject();
auto theta = track.GetGeoTheta();

if (std::abs((theta0 * TMath::RadToDeg()) - (theta * TMath::RadToDeg())) <= tolerance) {
for(auto &hit : hitArray){
newTrack.AddHit(hit);

}
processed[tr] = true;
}

}
}

processed[numtr] = true;
fTrackTransformer->ClusterizeSmooth3D(newTrack, fClusterRadius, fClusterDistance);
mergedTracks.push_back(newTrack);

}

kMergeTracks = true;
}

if(kMergeTracks){
std::swap(tracks, mergedTracks);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Track merging should be controlled by a run-time flag. Changes to core classes like this should retain the old behavior by default (or it could break code for others)

Comment on lines +258 to +371
//First try of merging tracks
/* bool kMergeTracks = false;
if(tracks.size() > 2){
const double tolerance = 2.0;
std::vector<bool> processed(tracks.size(), false);
for(Int_t numtr = 0; numtr < tracks.size(); numtr++){
std::cout << "Theta " << tracks.at(numtr).GetGeoTheta() << std::endl;
if (processed[numtr]) continue;
auto track0 = tracks.at(numtr);
auto hitArray0 = track0.GetHitArrayObject();
auto theta0 = track0.GetGeoTheta();
AtTrack newTrack;
for(auto &hit : hitArray0){
newTrack.AddHit(hit);
}
if (numtr + 1 < tracks.size()) {
for (size_t tr = numtr + 1; tr < tracks.size(); ++tr) {
if (processed[tr]) continue;
auto track = tracks.at(tr);
auto hitArray = track.GetHitArrayObject();
auto theta = track.GetGeoTheta();
if (std::abs((theta0 * TMath::RadToDeg()) - (theta * TMath::RadToDeg())) <= tolerance) {
for(auto &hit : hitArray){
newTrack.AddHit(hit);
}
processed[tr] = true;
}
}
}
processed[numtr] = true;
//fTrackTransformer->ClusterizeSmooth3D(newTrack, fClusterRadius, fClusterDistance);
mergedTracks.push_back(newTrack);
}
kMergeTracks = true;
}
if(kMergeTracks){
std::swap(tracks, mergedTracks);
}
*/

/*
auto sp = std::unique_ptr<AtTrack[]>(new AtTrack[tracks.size()]);
for (auto iTrack = 0; iTrack < tracks.size(); ++iTrack) {
sp[iTrack] = tracks.at(iTrack);
candTrackPool.push_back(std::move(&sp[iTrack]));
}
std::vector<AtTrack *> candToMergePool;
AtTrackFinder merger;
for (auto itA = candTrackPool.begin(); itA != candTrackPool.end(); ++itA) {
if(candTrackPool.size() == 0) break;
AtTrack *trA = *(itA);
if(candTrackPool.size() == 1){
mergedTrackPool.push_back(*trA);
break;
}
candToMergePool.clear();
auto itB = std::copy_if(itA + 1, candTrackPool.end(), std::back_inserter(candToMergePool),
[&trA, this](AtTrack *track) { return SameTrack(trA, track); });
std::cout << "candToMergePool size after copy_if: " << candToMergePool.size() << std::endl;
if (candToMergePool.size() > 0) { // Merge if matches are found
candToMergePool.push_back(trA);
Bool_t merged = merger.MergeTracks(&candToMergePool, &mergedTrackPool, fEnableSingleVertexTrack, fClusterRadius,
fClusterSize);
std::cout << "Merged: " << merged << std::endl;
std::cout << "candTrackPool size before erase: " << candTrackPool.size() << std::endl;
itA = candTrackPool.erase(std::remove_if(itA, candTrackPool.end(),
[&trA, this](AtTrack *track) { return SameTrack(trA, track); }),
candTrackPool.end());
} else {
mergedTrackPool.push_back(*trA);
itA = candTrackPool.erase(itA); // Erase the track from the pool
}
}
std::swap(tracks, mergedTrackPool);
candToMergePool.clear();
candTrackPool.clear();
//mergedTrackPool.clear();
/* for (auto &track : tracks) {
if (track.GetHitArray().size() > 0)
SetTrackInitialParameters(track);
retEvent->AddTrack(std::move(track));
}*/
//std::cout << "Number of tracks: " << tracks.size() << std::endl;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code (should live in commit history, not in source file)

Comment on lines +16 to +17
class PointCloud;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not necessary to forward declare since the class is defined in the included header?

Comment on lines +17 to +18
//#include <iostream>
//#include "orthogonallsq.h"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if commented

Comment on lines +154 to +158
double x = pos.X();
double y = pos.Y();
if ((x * x + y * y) <= (30.0 * 30.0)) {
continue; // Skip this hit if it is within the 3 cm radius
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified default behavior in way that would break others code. Replace with a parameter in the header. Something like

double fMinRadius
```

These lines of code can then become
```cpp
if (pos.Rho() < fMinRadius)
continue;
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants