Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:05

0001 #include "L1Trigger/TrackFindingTracklet/interface/TrackletProjectionsMemory.h"
0002 #include "L1Trigger/TrackFindingTracklet/interface/Tracklet.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include <iomanip>
0005 #include <filesystem>
0006 
0007 using namespace std;
0008 using namespace trklet;
0009 
0010 TrackletProjectionsMemory::TrackletProjectionsMemory(string name, Settings const& settings)
0011     : MemoryBase(name, settings) {
0012   size_t pos = find_nth(name, 0, "_", 1);
0013   assert(pos != string::npos);
0014   initLayerDisk(pos + 1, layer_, disk_);
0015   hasProj_ = false;
0016 }
0017 
0018 void TrackletProjectionsMemory::addProj(Tracklet* tracklet) {
0019   if (layer_ != 0 && disk_ == 0)
0020     assert(tracklet->validProj(layer_ - 1));
0021   if (layer_ == 0 && disk_ != 0)
0022     assert(tracklet->validProj(N_LAYER + abs(disk_) - 1));
0023   if (layer_ != 0 && disk_ != 0)
0024     assert(tracklet->validProj(layer_ - 1) || tracklet->validProj(N_LAYER + abs(disk_) - 1));
0025 
0026   for (auto& itracklet : tracklets_) {
0027     if (itracklet == tracklet) {
0028       edm::LogPrint("Tracklet") << "Adding same tracklet " << tracklet << " twice in " << getName();
0029     }
0030     assert(itracklet != tracklet);
0031   }
0032 
0033   hasProj_ = true;
0034   tracklets_.push_back(tracklet);
0035 }
0036 
0037 void TrackletProjectionsMemory::clean() { tracklets_.clear(); }
0038 
0039 void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) {
0040   iSector_ = iSector;
0041   const string dirTP = settings_.memPath() + "TrackletProjections/";
0042 
0043   std::ostringstream oss;
0044   oss << dirTP << "TrackletProjections_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
0045       << ".dat";
0046   auto const& fname = oss.str();
0047 
0048   openfile(out_, first, dirTP, fname, __FILE__, __LINE__);
0049 
0050   out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
0051 
0052   for (unsigned int j = 0; j < tracklets_.size(); j++) {
0053     string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_ - 1)) ? tracklets_[j]->trackletprojstrlayer(layer_)
0054                                                                        : tracklets_[j]->trackletprojstrdisk(disk_);
0055     out_ << hexstr(j) << " " << proj << "  " << trklet::hexFormat(proj) << endl;
0056   }
0057   out_.close();
0058 
0059   bx_++;
0060   event_++;
0061   if (bx_ > 7)
0062     bx_ = 0;
0063 }