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

Extending SeedingHitSet & SeedGeneratorFromProtoTracksEDProducer #36184

Merged
merged 3 commits into from
Jan 25, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
namespace {
void fillNtuplets(RegionsSeedingHitSets::RegionFiller& seedingHitSetsFiller, const OrderedHitSeeds& quadruplets) {
for (const auto& quad : quadruplets) {
seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
if (quad.size() == 3)
seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2]);
if (quad.size() == 4)
seedingHitSetsFiller.emplace_back(quad[0], quad[1], quad[2], quad[3]);
}
}
} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <vector>

using namespace edm;
Expand Down Expand Up @@ -140,12 +139,10 @@ void SeedGeneratorFromProtoTracksEDProducer::produce(edm::Event& ev, const edm::
GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);

seedCreator_.init(region, es, nullptr);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had mistakenly removed the seed initialization.

seedCreator_.makeSeed(
*result,
SeedingHitSet(hits[0],
hits[1],
hits.size() > 2 ? hits[2] : SeedingHitSet::nullPtr(),
(includeFourthHit_ && hits.size() > 3) ? hits[3] : SeedingHitSet::nullPtr()));
if (hits.size() > 3 and not includeFourthHit_)
seedCreator_.makeSeed(*result, {hits[0], hits[1], hits[2]});
else
seedCreator_.makeSeed(*result, hits);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
#include "FWCore/Utilities/interface/Visibility.h"

#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
#include "SeedFromConsecutiveHitsCreator.h"

#include <string>

class dso_hidden SeedGeneratorFromProtoTracksEDProducer : public edm::stream::EDProducer<> {
public:
SeedGeneratorFromProtoTracksEDProducer(const edm::ParameterSet& cfg);
Expand Down
49 changes: 26 additions & 23 deletions RecoTracker/TkSeedingLayers/interface/SeedingHitSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#define TkSeedingLayers_SeedingHitSet_H

#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <vector>
#include <algorithm>

class SeedingHitSet {
public:
Expand All @@ -11,40 +15,39 @@ class SeedingHitSet {

static ConstRecHitPointer nullPtr() { return nullptr; }

SeedingHitSet() { theRecHits[0] = theRecHits[1] = theRecHits[2] = theRecHits[3] = nullptr; }
SeedingHitSet() = default;

SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two) : theRecHits({one, two}) { setSize(); }

SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two)
// : theRecHits{{one,two,ConstRecHitPointer()}}
{
theRecHits[0] = one;
theRecHits[1] = two;
theRecHits[2] = theRecHits[3] = nullptr;
}
SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two, ConstRecHitPointer three)
// : theRecHits{{one,two,three}},
{
theRecHits[0] = one;
theRecHits[1] = two;
theRecHits[2] = three;
theRecHits[3] = nullptr;
: theRecHits({one, two, three}) {
setSize();
}

SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two, ConstRecHitPointer three, ConstRecHitPointer four) {
theRecHits[0] = one;
theRecHits[1] = two;
theRecHits[2] = three;
theRecHits[3] = four;
SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two, ConstRecHitPointer three, ConstRecHitPointer four)
: theRecHits({one, two, three, four}) {
setSize();
}

ConstRecHitPointer const *data() const { return theRecHits; }
SeedingHitSet(const std::vector<ConstRecHitPointer> &hits) : theRecHits(hits) { setSize(); }

unsigned int size() const { return theRecHits[3] ? 4 : (theRecHits[2] ? 3 : (theRecHits[1] ? 2 : 0)); }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@slava77 theSize is set to 0 for one hit case to mimic the behavior here where 0th hit is not even checked. Intuitively, I think that the logic here was: if a SeedingHitSet has only one valid hit it's not a proper set. Then I don't know how much this is actually used. There are some places where changing this would change the behavior (see e.g. here). But most probably these occurrences are protected in other ways before. Nevertheless I would leave it as it is.

ConstRecHitPointer const *data() const { return theRecHits.data(); }

unsigned int size() const { return theSize; }

ConstRecHitPointer get(unsigned int i) const { return theRecHits[i]; }
ConstRecHitPointer operator[](unsigned int i) const { return theRecHits[i]; }

private:
ConstRecHitPointer theRecHits[4];
protected:
std::vector<ConstRecHitPointer> theRecHits;
unsigned int theSize = 0;

void setSize() {
theSize = 0;
while (theRecHits[++theSize] and theSize < theRecHits.size())
;
theSize = theSize > 1 ? theSize : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

please clarify why one-hit case is set to theSize of 0?

}
};

#endif