Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:30

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   //Check for consistency
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();  // stub ID
0045     int projindex = matches_[j].first.second;               // Allproj index
0046     FPGAWord tmp;
0047     if (projindex >= (1 << 7)) {
0048       projindex = (1 << 7) - 1;
0049     }
0050     tmp.set(projindex, 7, true, __LINE__, __FILE__);
0051     out_ << "0x";
0052     out_ << std::setfill('0') << std::setw(2);
0053     out_ << hex << j << dec;
0054     out_ << " " << tmp.str() << "|" << stubid << " " << trklet::hexFormat(tmp.str() + stubid) << endl;
0055   }
0056   out_.close();
0057 
0058   bx_++;
0059   event_++;
0060   if (bx_ > 7)
0061     bx_ = 0;
0062 }