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

Add BeamSpot. #363

Merged
merged 1 commit into from
Oct 7, 2021
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
1 change: 1 addition & 0 deletions Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Event
int evtID_;

public:
BeamSpot beamSpot_; // XXXX Read/Write of BeamSpot + file-version bump or extra-section to be added.
std::vector<HitVec> layerHits_;
std::vector<std::vector<uint64_t> > layerHitMasks_;//aligned with layerHits_
MCHitInfoVec simHitsInfo_;
Expand Down
12 changes: 12 additions & 0 deletions Hit.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,5 +337,17 @@ struct DeadRegion
};
typedef std::vector<DeadRegion> DeadVec;

struct BeamSpot
{
float x = 0, y = 0, z = 0;
float sigmaZ = 5;
float beamWidthX = 5e-4, beamWidthY = 5e-4;
float dxdz = 0, dydz = 0;

BeamSpot() = default;
BeamSpot(float ix, float iy, float iz, float is, float ibx, float iby, float idxdz, float idydz) :
x(ix), y(iy), z(iz), sigmaZ(is), beamWidthX(ibx), beamWidthY(iby), dxdz(idxdz), dydz(idydz)
{}
};
} // end namespace mkfit
#endif
3 changes: 3 additions & 0 deletions mkFit/HitStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class EventOfHits
public:
std::vector<LayerOfHits> m_layers_of_hits;
int m_n_layers;
BeamSpot m_beam_spot;

public:
EventOfHits(const TrackerInfo &trk_inf);
Expand Down Expand Up @@ -311,6 +312,8 @@ class EventOfHits
m_layers_of_hits[layer].SuckInDeads(deadv);
}

void SetBeamSpot(const BeamSpot &bs) { m_beam_spot = bs; }

LayerOfHits& operator[](int i) { return m_layers_of_hits[i]; }
const LayerOfHits& operator[](int i) const { return m_layers_of_hits[i]; }
};
Expand Down
9 changes: 5 additions & 4 deletions mkFit/MkStdSeqs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace StdSeq {
// Hit processing
//=========================================================================

void LoadHits(Event &ev, EventOfHits &eoh)
void LoadHitsAndBeamSpot(Event &ev, EventOfHits &eoh)
Copy link
Collaborator

Choose a reason for hiding this comment

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

CMSSW is not using this part; Cmssw_LoadHits_Begin is used.
perhaps a separate method that can pass the beamspot is easier; it will be used as LoadDeads

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, cmssw will just call eoh.SetBeamSpot().
I thought it's cleaner to have a single method for standalone and rename it express intent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

{
eoh.Reset();

Expand All @@ -28,6 +28,7 @@ void LoadHits(Event &ev, EventOfHits &eoh)
eoh.SuckInHits(ilay, ev.layerHits_[ilay]);
}
});
eoh.SetBeamSpot(ev.beamSpot_);
}

void LoadDeads(EventOfHits &eoh, const std::vector<DeadVec>& deadvectors)
Expand Down Expand Up @@ -476,7 +477,7 @@ void quality_filter(TrackVec & tracks, const int nMinHits)
}), tracks.end());
}

void quality_filter_layers(TrackVec & tracks)
void quality_filter_layers(TrackVec & tracks, const BeamSpot &bspot)
{
tracks.erase(std::remove_if(tracks.begin(), tracks.end(), [](auto &trk) {
auto layers = trk.nUniqueLayers();
Expand Down Expand Up @@ -639,7 +640,7 @@ void find_duplicates_sharedhits_pixelseed(TrackVec &tracks, const float fraction
//
//=========================================================================

void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf)
void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf, const EventOfHits &eoh)
{
#ifdef DEBUG
std::cout<<" find_and_remove_duplicates: input track size " <<tracks.size()<<std::endl;
Expand All @@ -650,7 +651,7 @@ void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf)
}
else if(itconf.m_require_dupclean_tight)
{
if(itconf.m_track_algorithm==7) quality_filter_layers(tracks);
if(itconf.m_track_algorithm==7) quality_filter_layers(tracks, eoh.m_beam_spot);
find_duplicates_sharedhits_pixelseed(tracks, itconf.m_params.fracSharedHits, itconf.m_params.drth_central, itconf.m_params.drth_obarrel, itconf.m_params.drth_forward);
}
else
Expand Down
6 changes: 3 additions & 3 deletions mkFit/MkStdSeqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IterationConfig;

namespace StdSeq
{
void LoadHits(Event &ev, EventOfHits &eoh);
void LoadHitsAndBeamSpot(Event &ev, EventOfHits &eoh);

void LoadDeads(EventOfHits &eoh, const std::vector<DeadVec>& deadvectors);

Expand All @@ -35,7 +35,7 @@ namespace StdSeq
void find_duplicates_sharedhits(TrackVec &tracks, const float fraction);
void find_duplicates_sharedhits_pixelseed(TrackVec &tracks, const float fraction, const float drth_central, const float drth_obarrel, const float drth_forward);

void quality_filter_layers(TrackVec &tracks);
void quality_filter_layers(TrackVec &tracks, const BeamSpot &bspot);

template<class TRACK>
bool qfilter_n_hits(const TRACK &t, int nMinHits)
Expand All @@ -52,7 +52,7 @@ namespace StdSeq
}


void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf);
void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf, const EventOfHits &eoh);

} // namespace StdSeq

Expand Down
6 changes: 3 additions & 3 deletions mkFit/buildtestMPlex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ std::vector<double> runBtpCe_MultiIter(Event& ev, const EventOfHits &eoh, MkBuil

{
builder.export_tracks(tmp_tvec);
StdSeq::find_and_remove_duplicates(tmp_tvec, itconf);
StdSeq::find_and_remove_duplicates(tmp_tvec, itconf, eoh);
ev.candidateTracks_.reserve(ev.candidateTracks_.size() + tmp_tvec.size());
for (auto &&t : tmp_tvec) ev.candidateTracks_.emplace_back( std::move(t) );
tmp_tvec.clear();
Expand Down Expand Up @@ -557,7 +557,7 @@ std::vector<double> runBtpCe_MultiIter(Event& ev, const EventOfHits &eoh, MkBuil

builder.select_best_comb_cands(true); // true -> clear m_tracks as they were already filled once above

StdSeq::find_and_remove_duplicates(builder.ref_tracks_nc(), itconf);
StdSeq::find_and_remove_duplicates(builder.ref_tracks_nc(), itconf, eoh);
builder.export_tracks(ev.fitTracks_);
}

Expand Down Expand Up @@ -678,7 +678,7 @@ void run_OneIteration(const TrackerInfo& trackerInfo, const IterationConfig &itc

if (do_remove_duplicates)
{
StdSeq::find_and_remove_duplicates(out_tracks, itconf);
StdSeq::find_and_remove_duplicates(out_tracks, itconf, eoh);
}

builder.end_event();
Expand Down
2 changes: 1 addition & 1 deletion mkFit/mkFit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void test_standard()

// plex_tracks.resize(ev.simTracks_.size());

StdSeq::LoadHits(ev, eoh);
StdSeq::LoadHitsAndBeamSpot(ev, eoh);

std::vector<DeadVec> deadvectors(ev.layerHits_.size());
#include "deadmodules.h"
Expand Down