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)
 
- 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 Skims_PA_cff::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:103
MemoryBase(std::string name, Settings const &settings)
Definition: MemoryBase.cc:13
assert(be >=bs)
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:19

◆ ~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(), match(), matches_, trklet::MemoryBase::settings_, trklet::Tracklet::TCID(), createJobs::tmp, and trklet::Tracklet::trackletIndex().

18  {
19  if (!settings_.doKF() || !settings_.doMultipleMatches()) { //When using KF we allow multiple matches
20  for (auto& match : matches_) {
21  if (match.first == tracklet) { //Better match, replace
22  match.second = stub;
23  return;
24  }
25  }
26  }
27  std::pair<Tracklet*, const Stub*> tmp(tracklet, stub);
28  //Check that we have the right TCID order
29  if (!matches_.empty()) {
30  if ((!settings_.doKF() && matches_[matches_.size() - 1].first->TCID() >= tracklet->TCID()) ||
31  (settings_.doKF() && matches_[matches_.size() - 1].first->TCID() > tracklet->TCID())) {
32  edm::LogPrint("Tracklet") << "Wrong TCID ordering in " << getName() << " : "
33  << matches_[matches_.size() - 1].first->TCID() << " " << tracklet->TCID() << " "
34  << matches_[matches_.size() - 1].first->trackletIndex() << " "
35  << tracklet->trackletIndex();
36  }
37  }
38  matches_.push_back(tmp);
39 }
std::vector< std::pair< Tracklet *, const Stub * > > matches_
int TCID() const
Definition: Tracklet.h:212
int trackletIndex() const
Definition: Tracklet.h:206
Settings const & settings_
Definition: MemoryBase.h:50
bool doMultipleMatches() const
Definition: Settings.h:241
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:240

◆ 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 41 of file FullMatchMemory.cc.

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

41  {
42  iSector_ = iSector;
43  const string dirM = settings_.memPath() + "Matches/";
44 
45  std::ostringstream oss;
46  oss << dirM << "FullMatches_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
47  auto const& fname = oss.str();
48 
49  openfile(out_, first, dirM, fname, __FILE__, __LINE__);
50 
51  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
52 
53  for (unsigned int j = 0; j < matches_.size(); j++) {
54  string match = (layer_ > 0) ? matches_[j].first->fullmatchstr(layer_) : matches_[j].first->fullmatchdiskstr(disk_);
55  out_ << "0x";
56  out_ << std::setfill('0') << std::setw(2);
57  out_ << hex << j << dec;
58  out_ << " " << match << " " << trklet::hexFormat(match) << endl;
59  }
60  out_.close();
61 
62  bx_++;
63  event_++;
64  if (bx_ > 7)
65  bx_ = 0;
66 }
unsigned int iSector_
Definition: MemoryBase.h:44
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:192
Settings const & settings_
Definition: MemoryBase.h:50
std::ofstream out_
Definition: MemoryBase.h:46
std::string const & getName() const
Definition: MemoryBase.h:19
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:139

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().