CMS 3D CMS Logo

FullMatchMemory.cc
Go to the documentation of this file.
5 #include <iomanip>
7 
8 using namespace std;
9 using namespace trklet;
10 
11 FullMatchMemory::FullMatchMemory(string name, Settings const& settings, unsigned int iSector)
12  : MemoryBase(name, settings, iSector) {
13  size_t pos = find_nth(name, 0, "_", 1);
14  assert(pos != string::npos);
16 }
17 
18 void FullMatchMemory::addMatch(Tracklet* tracklet, const Stub* stub) {
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 }
40 
42  std::ostringstream oss;
43  oss << "../data/MemPrints/Matches/FullMatches_" << getName() << "_" << std::setfill('0') << std::setw(2)
44  << (iSector_ + 1) << ".dat";
45  auto const& fname = oss.str();
46 
47  if (first) {
48  bx_ = 0;
49  event_ = 1;
50  out_.open(fname.c_str());
51  } else
52  out_.open(fname.c_str(), std::ofstream::app);
53 
54  out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
55 
56  for (unsigned int j = 0; j < matches_.size(); j++) {
57  string match = (layer_ > 0) ? matches_[j].first->fullmatchstr(layer_) : matches_[j].first->fullmatchdiskstr(disk_);
58  out_ << "0x";
59  out_ << std::setfill('0') << std::setw(2);
60  out_ << hex << j << dec;
61  out_ << " " << match << " " << trklet::hexFormat(match) << endl;
62  }
63  out_.close();
64 
65  bx_++;
66  event_++;
67  if (bx_ > 7)
68  bx_ = 0;
69 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
L1TStub.h
trklet::FullMatchMemory::disk_
int disk_
Definition: FullMatchMemory.h:42
MessageLogger.h
trklet::Settings::doKF
bool doKF() const
Definition: Settings.h:199
trklet::FullMatchMemory::writeMC
void writeMC(bool first)
Definition: FullMatchMemory.cc:41
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:108
pos
Definition: PixelAliasList.h:18
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
trklet::Settings
Definition: Settings.h:26
cms::cuda::assert
assert(be >=bs)
trklet::MemoryBase::event_
int event_
Definition: MemoryBase.h:48
trklet::FullMatchMemory::addMatch
void addMatch(Tracklet *tracklet, const Stub *stub)
Definition: FullMatchMemory.cc:18
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:17
FullMatchMemory.h
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::MemoryBase::bx_
int bx_
Definition: MemoryBase.h:47
dqmdumpme.first
first
Definition: dqmdumpme.py:55
trklet::Tracklet
Definition: Tracklet.h:28
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::Stub
Definition: Stub.h:16
trklet::Settings::doMultipleMatches
bool doMultipleMatches() const
Definition: Settings.h:200
trklet::MemoryBase
Definition: MemoryBase.h:13
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
Definition: AllProjectionsMemory.h:9
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
std
Definition: JetResolutionObject.h:76
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
trklet::FullMatchMemory::matches_
std::vector< std::pair< Tracklet *, const Stub * > > matches_
Definition: FullMatchMemory.h:39
Stub.h
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
Tracklet.h
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44