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, unsigned int iSector)
 
std::pair< Tracklet *, const Stub * > getMatch (unsigned int i)
 
TrackletgetTracklet (unsigned int i)
 
int layer () const
 
unsigned int nMatches () const
 
void writeMC (bool first)
 
 ~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
 
unsigned int initLayerDisk (unsigned int pos)
 
void initLayerDisk (unsigned int pos, int &layer, int &disk)
 
void initSpecialSeeding (unsigned int pos, bool &overlap, bool &extra, bool &extended)
 
 MemoryBase (std::string name, Settings const &settings, unsigned int iSector)
 
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,
unsigned int  iSector 
)

Definition at line 12 of file FullMatchMemory.cc.

13  : MemoryBase(name, settings, iSector) {
14  size_t pos = find_nth(name, 0, "_", 1);
15  assert(pos != string::npos);
17 }

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

◆ ~FullMatchMemory()

trklet::FullMatchMemory::~FullMatchMemory ( )
overridedefault

Member Function Documentation

◆ addMatch()

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

Definition at line 19 of file FullMatchMemory.cc.

19  {
20  if (!settings_.doKF() || !settings_.doMultipleMatches()) { //When using KF we allow multiple matches
21  for (auto& match : matches_) {
22  if (match.first == tracklet) { //Better match, replace
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 }

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

◆ clean()

void trklet::FullMatchMemory::clean ( )
inlineoverridevirtual

Implements trklet::MemoryBase.

Definition at line 31 of file FullMatchMemory.h.

31 { matches_.clear(); }

References matches_.

◆ disk()

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

Definition at line 36 of file FullMatchMemory.h.

36 { return disk_; }

References disk_.

◆ getMatch()

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

Definition at line 29 of file FullMatchMemory.h.

29 { return matches_[i]; }

References mps_fire::i, and matches_.

◆ getTracklet()

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

Definition at line 27 of file FullMatchMemory.h.

27 { return matches_[i].first; }

References mps_fire::i, and matches_.

◆ layer()

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

Definition at line 35 of file FullMatchMemory.h.

35 { return layer_; }

References layer_.

Referenced by geometryXMLparser.DTAlignable::index(), and geometryXMLparser.CSCAlignable::index().

◆ nMatches()

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

Definition at line 25 of file FullMatchMemory.h.

25 { return matches_.size(); }

References matches_.

◆ writeMC()

void FullMatchMemory::writeMC ( bool  first)

Definition at line 42 of file FullMatchMemory.cc.

42  {
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  if (first) {
50  bx_ = 0;
51  event_ = 1;
52 
53  if (not std::filesystem::exists(dirM)) {
54  int fail = system((string("mkdir -p ") + dirM).c_str());
55  if (fail)
56  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirM;
57  }
58  out_.open(fname);
59  if (out_.fail())
60  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
61 
62  } else
63  out_.open(fname, std::ofstream::app);
64 
65  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
66 
67  for (unsigned int j = 0; j < matches_.size(); j++) {
68  string match = (layer_ > 0) ? matches_[j].first->fullmatchstr(layer_) : matches_[j].first->fullmatchdiskstr(disk_);
69  out_ << "0x";
70  out_ << std::setfill('0') << std::setw(2);
71  out_ << hex << j << dec;
72  out_ << " " << match << " " << trklet::hexFormat(match) << endl;
73  }
74  out_.close();
75 
76  bx_++;
77  event_++;
78  if (bx_ > 7)
79  bx_ = 0;
80 }

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

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

trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
mps_fire.i
i
Definition: mps_fire.py:428
trklet::FullMatchMemory::disk_
int disk_
Definition: FullMatchMemory.h:42
trklet::Settings::doKF
bool doKF() const
Definition: Settings.h:217
trklet::MemoryBase::find_nth
static size_t find_nth(const std::string &haystack, size_t pos, const std::string &needle, size_t nth)
Definition: MemoryBase.cc:118
pos
Definition: PixelAliasList.h:18
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
trklet::Settings::memPath
std::string const & memPath() const
Definition: Settings.h:169
cms::cuda::assert
assert(be >=bs)
trklet::MemoryBase::event_
int event_
Definition: MemoryBase.h:48
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
trklet::MemoryBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:18
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::Tracklet::trackletIndex
int trackletIndex() const
Definition: Tracklet.h:494
trklet::FullMatchMemory::layer_
int layer_
Definition: FullMatchMemory.h:41
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::Settings::doMultipleMatches
bool doMultipleMatches() const
Definition: Settings.h:218
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
trklet::Tracklet::TCID
int TCID() const
Definition: Tracklet.h:500
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
trklet::MemoryBase::MemoryBase
MemoryBase(std::string name, Settings const &settings, unsigned int iSector)
Definition: MemoryBase.cc:12
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:15
cms::Exception
Definition: Exception.h:70
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
trklet::FullMatchMemory::matches_
std::vector< std::pair< Tracklet *, const Stub * > > matches_
Definition: FullMatchMemory.h:39
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44