CMS 3D CMS Logo

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

#include <TrackletParametersMemory.h>

Inheritance diagram for trklet::TrackletParametersMemory:
trklet::MemoryBase

Public Member Functions

void addTracklet (Tracklet *tracklet)
 
void clean () override
 
TrackletgetTracklet (unsigned int i)
 
unsigned int nTracklets () const
 
 TrackletParametersMemory (std::string name, Settings const &settings, unsigned int iSector)
 
void writeMatches (Globals *globals, int &matchesL1, int &matchesL3, int &matchesL5)
 
void writeTPAR (bool first)
 
 ~TrackletParametersMemory () 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< Tracklet * > tracklets_
 

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 TrackletParametersMemory.h.

Constructor & Destructor Documentation

◆ TrackletParametersMemory()

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

Definition at line 11 of file TrackletParametersMemory.cc.

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

◆ ~TrackletParametersMemory()

trklet::TrackletParametersMemory::~TrackletParametersMemory ( )
overridedefault

Member Function Documentation

◆ addTracklet()

void trklet::TrackletParametersMemory::addTracklet ( Tracklet tracklet)
inline

◆ clean()

void TrackletParametersMemory::clean ( )
overridevirtual

Implements trklet::MemoryBase.

Definition at line 14 of file TrackletParametersMemory.cc.

14  {
15  for (auto& tracklet : tracklets_) {
16  delete tracklet;
17  }
18  tracklets_.clear();
19 }

References tracklets_.

◆ getTracklet()

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

Definition at line 27 of file TrackletParametersMemory.h.

27 { return tracklets_[i]; }

References mps_fire::i, and tracklets_.

◆ nTracklets()

unsigned int trklet::TrackletParametersMemory::nTracklets ( ) const
inline

◆ writeMatches()

void TrackletParametersMemory::writeMatches ( Globals globals,
int &  matchesL1,
int &  matchesL3,
int &  matchesL5 
)

Definition at line 21 of file TrackletParametersMemory.cc.

21  {
22  ofstream& out = globals->ofstream("nmatches.txt");
23  for (auto& tracklet : tracklets_) {
24  if ((tracklet->nMatches() + tracklet->nMatchesDisk()) > 0) {
25  if (tracklet->layer() == 1)
26  matchesL1++;
27  if (tracklet->layer() == 3)
28  matchesL3++;
29  if (tracklet->layer() == 5)
30  matchesL5++;
31  }
32  out << tracklet->layer() << " " << tracklet->disk() << " " << tracklet->nMatches() << " "
33  << tracklet->nMatchesDisk() << endl;
34  }
35 }

References trklet::Globals::ofstream(), MillePedeFileConverter_cfg::out, and tracklets_.

◆ writeTPAR()

void TrackletParametersMemory::writeTPAR ( bool  first)

Definition at line 37 of file TrackletParametersMemory.cc.

37  {
38  const string dirTP = settings_.memPath() + "TrackletParameters/";
39 
40  std::ostringstream oss;
41  oss << dirTP << "TrackletParameters_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
42  << ".dat";
43  auto const& fname = oss.str();
44 
45  if (first) {
46  bx_ = 0;
47  event_ = 1;
48 
49  if (not std::filesystem::exists(dirTP)) {
50  int fail = system((string("mkdir -p ") + dirTP).c_str());
51  if (fail)
52  throw cms::Exception("BadDir") << __FILE__ << " " << __LINE__ << " could not create directory " << dirTP;
53  }
54  out_.open(fname);
55  if (out_.fail())
56  throw cms::Exception("BadFile") << __FILE__ << " " << __LINE__ << " could not create file " << fname;
57 
58  } else
59  out_.open(fname, std::ofstream::app);
60 
61  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
62 
63  for (unsigned int j = 0; j < tracklets_.size(); j++) {
64  string tpar = tracklets_[j]->trackletparstr();
65  out_ << "0x";
66  out_ << std::setfill('0') << std::setw(2);
67  out_ << hex << j << dec;
68  out_ << " " << tpar << " " << trklet::hexFormat(tpar) << 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, trklet::Settings::memPath(), trklet::MemoryBase::out_, trklet::MemoryBase::settings_, and tracklets_.

Member Data Documentation

◆ tracklets_

std::vector<Tracklet *> trklet::TrackletParametersMemory::tracklets_
private
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
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
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
trklet::Globals::ofstream
std::ofstream & ofstream(std::string fname)
Definition: Globals.cc:44
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
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::TrackletParametersMemory::tracklets_
std::vector< Tracklet * > tracklets_
Definition: TrackletParametersMemory.h:36
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44