File indexing completed on 2023-03-17 11:13:49
0001 #include "L1Trigger/TrackFindingTracklet/interface/CandidateMatchMemory.h"
0002 #include "L1Trigger/TrackFindingTracklet/interface/Settings.h"
0003 #include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h"
0004 #include "L1Trigger/TrackFindingTracklet/interface/Stub.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007
0008 #include <iomanip>
0009 #include <filesystem>
0010
0011 using namespace std;
0012 using namespace trklet;
0013
0014 CandidateMatchMemory::CandidateMatchMemory(string name, Settings const& settings) : MemoryBase(name, settings) {}
0015
0016 void CandidateMatchMemory::addMatch(std::pair<Tracklet*, int> tracklet, const Stub* stub) {
0017 std::pair<std::pair<Tracklet*, int>, const Stub*> tmp(tracklet, stub);
0018
0019
0020 for (auto& match : matches_) {
0021 if (tracklet.first->TCID() < match.first.first->TCID()) {
0022 throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " In " << getName() << " adding tracklet "
0023 << tracklet.first << " with lower TCID : " << tracklet.first->TCID()
0024 << " than earlier TCID " << match.first.first->TCID();
0025 }
0026 }
0027 matches_.push_back(tmp);
0028 }
0029
0030 void CandidateMatchMemory::writeCM(bool first, unsigned int iSector) {
0031 iSector_ = iSector;
0032 const string dirM = settings_.memPath() + "Matches/";
0033
0034 std::ostringstream oss;
0035 oss << dirM << "CandidateMatches_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
0036 << ".dat";
0037 auto const& fname = oss.str();
0038
0039 openfile(out_, first, dirM, fname, __FILE__, __LINE__);
0040
0041 out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
0042
0043 for (unsigned int j = 0; j < matches_.size(); j++) {
0044 string stubid = matches_[j].second->stubindex().str();
0045 int projindex = matches_[j].first.second;
0046 FPGAWord tmp;
0047 if (projindex >= (1 << 7)) {
0048 projindex = (1 << 7) - 1;
0049 }
0050 tmp.set(projindex, 7, true, __LINE__, __FILE__);
0051 out_ << hexstr(j) << " " << tmp.str() << "|" << stubid << " " << trklet::hexFormat(tmp.str() + stubid) << endl;
0052 }
0053 out_.close();
0054
0055 bx_++;
0056 event_++;
0057 if (bx_ > 7)
0058 bx_ = 0;
0059 }