CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
trklet::FullMatchMemory Class Reference

#include <FullMatchMemory.h>

Inheritance diagram for trklet::FullMatchMemory:
trklet::MemoryBase

Public Member Functions

void addMatch (Tracklet *tracklet, const Stub *stub)
 
void clean () override
 
int disk () const
 
 FullMatchMemory (std::string name, Settings const &settings)
 
std::pair< Tracklet *, const Stub * > getMatch (unsigned int i)
 
TrackletgetTracklet (unsigned int i)
 
int layer () const
 
unsigned int nMatches () const
 
void writeMC (bool first, unsigned int iSector)
 
 ~FullMatchMemory () override=default
 
- Public Member Functions inherited from trklet::MemoryBase
void findAndReplaceAll (std::string &data, std::string toSearch, std::string replaceStr)
 
std::string getLastPartOfName () const
 
std::string const & getName () const
 
void initLayerDisk (unsigned int pos, int &layer, int &disk)
 
unsigned int initLayerDisk (unsigned int pos)
 
void initSpecialSeeding (unsigned int pos, bool &overlap, bool &extra, bool &extended)
 
 MemoryBase (std::string name, Settings const &settings)
 
void openFile (bool first, std::string dirName, std::string filebase)
 
virtual ~MemoryBase ()=default
 

Private Attributes

int disk_
 
int layer_
 
std::vector< std::pair< Tracklet *, const Stub * > > matches_
 

Additional Inherited Members

- Static Public Member Functions inherited from trklet::MemoryBase
static size_t find_nth (const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
 
static std::string hexstr (unsigned int index)
 
- Protected Attributes inherited from trklet::MemoryBase
int bx_
 
int event_
 
unsigned int iSector_
 
std::string name_
 
std::ofstream out_
 
Settings const & settings_
 

Detailed Description

Definition at line 17 of file FullMatchMemory.h.

Constructor & Destructor Documentation

◆ FullMatchMemory()

FullMatchMemory::FullMatchMemory ( std::string  name,
Settings const &  settings 
)

Definition at line 12 of file FullMatchMemory.cc.

References cms::cuda::assert(), disk_, trklet::MemoryBase::find_nth(), trklet::MemoryBase::initLayerDisk(), layer_, and mergeVDriftHistosByStation::name.

12  : MemoryBase(name, settings) {
13  size_t pos = find_nth(name, 0, "_", 1);
14  assert(pos != string::npos);
16 }
static size_t find_nth(const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
Definition: MemoryBase.cc:104
MemoryBase(std::string name, Settings const &settings)
Definition: MemoryBase.cc:14
assert(be >=bs)
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:20

◆ ~FullMatchMemory()

trklet::FullMatchMemory::~FullMatchMemory ( )
overridedefault

Member Function Documentation

◆ addMatch()

void FullMatchMemory::addMatch ( Tracklet tracklet,
const Stub stub 
)

Definition at line 18 of file FullMatchMemory.cc.

References trklet::Settings::doKF(), trklet::Settings::doMultipleMatches(), trklet::MemoryBase::getName(), matches_, trklet::MemoryBase::settings_, trklet::Tracklet::TCID(), createJobs::tmp, and trklet::Tracklet::trackletIndex().

18  {
20  // When allowing only one stub per track per layer (or no KF implying same).
21  for (auto& match : matches_) {
22  if (match.first == tracklet) { //Better match: replace existing one
23  match.second = stub;
24  return;
25  }
26  }
27  }
28  std::pair<Tracklet*, const Stub*> tmp(tracklet, stub);
29  //Check that we have the right TCID order
30  if (!matches_.empty()) {
31  if ((!settings_.doKF() && matches_[matches_.size() - 1].first->TCID() >= tracklet->TCID()) ||
32  (settings_.doKF() && matches_[matches_.size() - 1].first->TCID() > tracklet->TCID())) {
33  edm::LogPrint("Tracklet") << "Wrong TCID ordering in " << getName() << " : "
34  << matches_[matches_.size() - 1].first->TCID() << " " << tracklet->TCID() << " "
35  << matches_[matches_.size() - 1].first->trackletIndex() << " "
36  << tracklet->trackletIndex();
37  }
38  }
39  matches_.push_back(tmp);
40 }
std::vector< std::pair< Tracklet *, const Stub * > > matches_
int TCID() const
Definition: Tracklet.h:214
int trackletIndex() const
Definition: Tracklet.h:208
Settings const & settings_
Definition: MemoryBase.h:53
bool doMultipleMatches() const
Definition: Settings.h:254
std::string const & getName() const
Definition: MemoryBase.h:19
Log< level::Warning, true > LogPrint
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
tmp
align.sh
Definition: createJobs.py:716
bool doKF() const
Definition: Settings.h:253

◆ clean()

void trklet::FullMatchMemory::clean ( )
inlineoverridevirtual

Implements trklet::MemoryBase.

Definition at line 31 of file FullMatchMemory.h.

References matches_.

31 { matches_.clear(); }
std::vector< std::pair< Tracklet *, const Stub * > > matches_

◆ disk()

int trklet::FullMatchMemory::disk ( ) const
inline

Definition at line 36 of file FullMatchMemory.h.

References disk_.

36 { return disk_; }

◆ getMatch()

std::pair<Tracklet*, const Stub*> trklet::FullMatchMemory::getMatch ( unsigned int  i)
inline

Definition at line 29 of file FullMatchMemory.h.

References mps_fire::i, and matches_.

29 { return matches_[i]; }
std::vector< std::pair< Tracklet *, const Stub * > > matches_

◆ getTracklet()

Tracklet* trklet::FullMatchMemory::getTracklet ( unsigned int  i)
inline

Definition at line 27 of file FullMatchMemory.h.

References mps_fire::i, and matches_.

27 { return matches_[i].first; }
std::vector< std::pair< Tracklet *, const Stub * > > matches_

◆ layer()

int trklet::FullMatchMemory::layer ( ) const
inline

◆ nMatches()

unsigned int trklet::FullMatchMemory::nMatches ( ) const
inline

Definition at line 25 of file FullMatchMemory.h.

References matches_.

25 { return matches_.size(); }
std::vector< std::pair< Tracklet *, const Stub * > > matches_

◆ writeMC()

void FullMatchMemory::writeMC ( bool  first,
unsigned int  iSector 
)

Definition at line 42 of file FullMatchMemory.cc.

References trklet::MemoryBase::bx_, disk_, trklet::MemoryBase::event_, dqmdumpme::first, alignmentValidation::fname, trklet::MemoryBase::getName(), trklet::hexFormat(), trklet::MemoryBase::hexstr(), trklet::MemoryBase::iSector_, dqmiolumiharvest::j, layer_, matches_, trklet::Settings::memPath(), trklet::openfile(), trklet::MemoryBase::out_, and trklet::MemoryBase::settings_.

42  {
43  iSector_ = iSector;
44  const string dirM = settings_.memPath() + "Matches/";
45 
46  std::ostringstream oss;
47  oss << dirM << "FullMatches_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
48  auto const& fname = oss.str();
49 
50  openfile(out_, first, dirM, fname, __FILE__, __LINE__);
51 
52  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
53 
54  for (unsigned int j = 0; j < matches_.size(); j++) {
55  string match = (layer_ > 0) ? matches_[j].first->fullmatchstr(layer_) : matches_[j].first->fullmatchdiskstr(disk_);
56  out_ << hexstr(j) << " " << match << " " << trklet::hexFormat(match) << endl;
57  }
58  out_.close();
59 
60  bx_++;
61  event_++;
62  if (bx_ > 7)
63  bx_ = 0;
64 }
unsigned int iSector_
Definition: MemoryBase.h:47
std::vector< std::pair< Tracklet *, const Stub * > > matches_
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
std::string memPath() const
Definition: Settings.h:204
Settings const & settings_
Definition: MemoryBase.h:53
std::ofstream out_
Definition: MemoryBase.h:49
std::string const & getName() const
Definition: MemoryBase.h:19
static std::string hexstr(unsigned int index)
Definition: MemoryBase.cc:111
string fname
main script
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
Definition: Util.h:154

Member Data Documentation

◆ disk_

int trklet::FullMatchMemory::disk_
private

Definition at line 42 of file FullMatchMemory.h.

Referenced by disk(), FullMatchMemory(), and writeMC().

◆ layer_

int trklet::FullMatchMemory::layer_
private

Definition at line 41 of file FullMatchMemory.h.

Referenced by FullMatchMemory(), layer(), and writeMC().

◆ matches_

std::vector<std::pair<Tracklet*, const Stub*> > trklet::FullMatchMemory::matches_
private

Definition at line 39 of file FullMatchMemory.h.

Referenced by addMatch(), clean(), getMatch(), getTracklet(), nMatches(), and writeMC().