CMS 3D CMS Logo

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

#include <StubPairsMemory.h>

Inheritance diagram for trklet::StubPairsMemory:
trklet::MemoryBase

Public Member Functions

void addStubPair (const VMStubTE &stub1, const VMStubTE &stub2, const unsigned index=0, const std::string &tedName="")
 
void clean () override
 
unsigned getIndex (const unsigned i) const
 
const std::string & getTEDName (const unsigned i) const
 
const VMStubTEgetVMStub1 (unsigned int i) const
 
const VMStubTEgetVMStub2 (unsigned int i) const
 
unsigned int nStubPairs () const
 
 StubPairsMemory (std::string name, Settings const &settings, unsigned int iSector)
 
void writeSP (bool first)
 
 ~StubPairsMemory () 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< unsigned > indices_
 
std::vector< std::pair< const VMStubTE, const VMStubTE > > stubs_
 
std::vector< std::string > tedNames_
 

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 13 of file StubPairsMemory.h.

Constructor & Destructor Documentation

◆ StubPairsMemory()

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

Definition at line 9 of file StubPairsMemory.cc.

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

◆ ~StubPairsMemory()

trklet::StubPairsMemory::~StubPairsMemory ( )
overridedefault

Member Function Documentation

◆ addStubPair()

void trklet::StubPairsMemory::addStubPair ( const VMStubTE stub1,
const VMStubTE stub2,
const unsigned  index = 0,
const std::string &  tedName = "" 
)
inline

Definition at line 19 of file StubPairsMemory.h.

22  {
23  stubs_.emplace_back(stub1, stub2);
24  indices_.push_back(index);
25  tedNames_.push_back(tedName);
26  }

References indices_, stubs_, and tedNames_.

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

◆ clean()

void trklet::StubPairsMemory::clean ( )
inlineoverridevirtual

Implements trklet::MemoryBase.

Definition at line 36 of file StubPairsMemory.h.

36  {
37  stubs_.clear();
38  indices_.clear();
39  tedNames_.clear();
40  }

References indices_, stubs_, and tedNames_.

◆ getIndex()

unsigned trklet::StubPairsMemory::getIndex ( const unsigned  i) const
inline

Definition at line 33 of file StubPairsMemory.h.

33 { return indices_.at(i); }

References mps_fire::i, and indices_.

◆ getTEDName()

const std::string& trklet::StubPairsMemory::getTEDName ( const unsigned  i) const
inline

Definition at line 34 of file StubPairsMemory.h.

34 { return tedNames_.at(i); }

References mps_fire::i, and tedNames_.

◆ getVMStub1()

const VMStubTE& trklet::StubPairsMemory::getVMStub1 ( unsigned int  i) const
inline

Definition at line 30 of file StubPairsMemory.h.

30 { return stubs_[i].first; }

References mps_fire::i, and stubs_.

◆ getVMStub2()

const VMStubTE& trklet::StubPairsMemory::getVMStub2 ( unsigned int  i) const
inline

Definition at line 31 of file StubPairsMemory.h.

31 { return stubs_[i].second; }

References mps_fire::i, and stubs_.

◆ nStubPairs()

unsigned int trklet::StubPairsMemory::nStubPairs ( ) const
inline

Definition at line 28 of file StubPairsMemory.h.

28 { return stubs_.size(); }

References stubs_.

◆ writeSP()

void StubPairsMemory::writeSP ( bool  first)

Definition at line 12 of file StubPairsMemory.cc.

12  {
13  const string dirSP = settings_.memPath() + "StubPairs/";
14 
15  std::ostringstream oss;
16  oss << dirSP << "StubPairs_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1) << ".dat";
17  auto const& fname = oss.str();
18 
19  if (first) {
20  bx_ = 0;
21  event_ = 1;
22 
23  if (not std::filesystem::exists(dirSP)) {
24  int fail = system((string("mkdir -p ") + dirSP).c_str());
25  if (fail)
26  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirSP;
27  }
28  out_.open(fname);
29  if (out_.fail())
30  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
31 
32  } else
33  out_.open(fname, std::ofstream::app);
34 
35  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
36 
37  for (unsigned int j = 0; j < stubs_.size(); j++) {
38  string stub1index = stubs_[j].first.stub()->stubindex().str();
39  string stub2index = stubs_[j].second.stub()->stubindex().str();
40  out_ << "0x";
41  out_ << std::setfill('0') << std::setw(2);
42  out_ << hex << j << dec;
43  out_ << " " << stub1index << "|" << stub2index << " " << trklet::hexFormat(stub1index + stub2index) << endl;
44  }
45  out_.close();
46 
47  bx_++;
48  event_++;
49  if (bx_ > 7)
50  bx_ = 0;
51 }

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

Member Data Documentation

◆ indices_

std::vector<unsigned> trklet::StubPairsMemory::indices_
private

Definition at line 47 of file StubPairsMemory.h.

Referenced by addStubPair(), clean(), and getIndex().

◆ stubs_

std::vector<std::pair<const VMStubTE, const VMStubTE> > trklet::StubPairsMemory::stubs_
private

Definition at line 45 of file StubPairsMemory.h.

Referenced by addStubPair(), clean(), getVMStub1(), getVMStub2(), nStubPairs(), and writeSP().

◆ tedNames_

std::vector<std::string> trklet::StubPairsMemory::tedNames_
private

Definition at line 48 of file StubPairsMemory.h.

Referenced by addStubPair(), clean(), and getTEDName().

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
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::StubPairsMemory::indices_
std::vector< unsigned > indices_
Definition: StubPairsMemory.h:47
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
trklet::StubPairsMemory::stubs_
std::vector< std::pair< const VMStubTE, const VMStubTE > > stubs_
Definition: StubPairsMemory.h:45
trklet::StubPairsMemory::tedNames_
std::vector< std::string > tedNames_
Definition: StubPairsMemory.h:48
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
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
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::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44