CMS 3D CMS Logo

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

#include <CandidateMatchMemory.h>

Inheritance diagram for trklet::CandidateMatchMemory:
trklet::MemoryBase

Public Member Functions

void addMatch (std::pair< Tracklet *, int > tracklet, const Stub *stub)
 
 CandidateMatchMemory (std::string name, Settings const &settings, unsigned int iSector)
 
void clean () override
 
std::pair< std::pair< Tracklet *, int >, const Stub * > getMatch (unsigned int i)
 
unsigned int nMatches () const
 
void writeCM (bool first)
 
 ~CandidateMatchMemory () 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

std::vector< std::pair< std::pair< Tracklet *, int >, 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 CandidateMatchMemory.h.

Constructor & Destructor Documentation

◆ CandidateMatchMemory()

CandidateMatchMemory::CandidateMatchMemory ( std::string  name,
Settings const &  settings,
unsigned int  iSector 
)

Definition at line 14 of file CandidateMatchMemory.cc.

15  : MemoryBase(name, settings, iSector) {}

◆ ~CandidateMatchMemory()

trklet::CandidateMatchMemory::~CandidateMatchMemory ( )
overridedefault

Member Function Documentation

◆ addMatch()

void CandidateMatchMemory::addMatch ( std::pair< Tracklet *, int >  tracklet,
const Stub stub 
)

Definition at line 17 of file CandidateMatchMemory.cc.

17  {
18  std::pair<std::pair<Tracklet*, int>, const Stub*> tmp(tracklet, stub);
19 
20  //Check for consistency
21  for (auto& match : matches_) {
22  if (tracklet.first->TCID() < match.first.first->TCID()) {
23  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " In " << getName() << " adding tracklet "
24  << tracklet.first << " with lower TCID : " << tracklet.first->TCID()
25  << " than earlier TCID " << match.first.first->TCID();
26  }
27  }
28  matches_.push_back(tmp);
29 }

References Exception, trklet::MemoryBase::getName(), match(), matches_, and createJobs::tmp.

Referenced by trklet::MatchEngine::execute().

◆ clean()

void trklet::CandidateMatchMemory::clean ( )
inlineoverridevirtual

Implements trklet::MemoryBase.

Definition at line 29 of file CandidateMatchMemory.h.

29 { matches_.clear(); }

References matches_.

◆ getMatch()

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

Definition at line 27 of file CandidateMatchMemory.h.

27 { return matches_[i]; }

References mps_fire::i, and matches_.

◆ nMatches()

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

Definition at line 25 of file CandidateMatchMemory.h.

25 { return matches_.size(); }

References matches_.

◆ writeCM()

void CandidateMatchMemory::writeCM ( bool  first)

Definition at line 31 of file CandidateMatchMemory.cc.

31  {
32  const string dirM = settings_.memPath() + "Matches/";
33 
34  std::ostringstream oss;
35  oss << dirM << "CandidateMatches_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
36  << ".dat";
37  auto const& fname = oss.str();
38 
39  if (first) {
40  bx_ = 0;
41  event_ = 1;
42 
43  if (not std::filesystem::exists(dirM)) {
44  int fail = system((string("mkdir -p ") + dirM).c_str());
45  if (fail)
46  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirM;
47  }
48  out_.open(fname);
49  if (out_.fail())
50  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
51 
52  } else
53  out_.open(fname, std::ofstream::app);
54 
55  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
56 
57  for (unsigned int j = 0; j < matches_.size(); j++) {
58  string stubid = matches_[j].second->stubindex().str(); // stub ID
59  int projindex = matches_[j].first.second; // Allproj index
60  FPGAWord tmp;
61  if (projindex >= (1 << 7)) {
62  projindex = (1 << 7) - 1;
63  }
64  tmp.set(projindex, 7, true, __LINE__, __FILE__);
65  out_ << "0x";
66  out_ << std::setfill('0') << std::setw(2);
67  out_ << hex << j << dec;
68  out_ << " " << tmp.str() << "|" << stubid << " " << trklet::hexFormat(tmp.str() + stubid) << endl;
69  }
70  out_.close();
71 
72  bx_++;
73  event_++;
74  if (bx_ > 7)
75  bx_ = 0;
76 }

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

Member Data Documentation

◆ matches_

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

Definition at line 34 of file CandidateMatchMemory.h.

Referenced by addMatch(), clean(), getMatch(), nMatches(), and writeCM().

trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
mps_fire.i
i
Definition: mps_fire.py:428
trklet::Settings::memPath
std::string const & memPath() const
Definition: Settings.h:169
trklet::MemoryBase::event_
int event_
Definition: MemoryBase.h:48
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::Stub
Definition: Stub.h:16
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
trklet::FPGAWord
Definition: FPGAWord.h:9
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
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
trklet::CandidateMatchMemory::matches_
std::vector< std::pair< std::pair< Tracklet *, int >, const Stub * > > matches_
Definition: CandidateMatchMemory.h:34
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44