Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 }
0016 
0017 void TrackletProjectionsMemory::addProj(Tracklet* tracklet) {
0018   if (layer_ != 0 && disk_ == 0)
0019     assert(tracklet->validProj(layer_ - 1));
0020   if (layer_ == 0 && disk_ != 0)
0021     assert(tracklet->validProj(N_LAYER + abs(disk_) - 1));
0022   if (layer_ != 0 && disk_ != 0)
0023     assert(tracklet->validProj(layer_ - 1) || tracklet->validProj(N_LAYER + abs(disk_) - 1));
0024 
0025   for (auto& itracklet : tracklets_) {
0026     if (itracklet == tracklet) {
0027       edm::LogPrint("Tracklet") << "Adding same tracklet " << tracklet << " twice in " << getName();
0028     }
0029     assert(itracklet != tracklet);
0030   }
0031 
0032   tracklets_.push_back(tracklet);
0033 }
0034 
0035 void TrackletProjectionsMemory::clean() { tracklets_.clear(); }
0036 
0037 void TrackletProjectionsMemory::writeTPROJ(bool first, unsigned int iSector) {
0038   iSector_ = iSector;
0039   const string dirTP = settings_.memPath() + "TrackletProjections/";
0040 
0041   std::ostringstream oss;
0042   oss << dirTP << "TrackletProjections_" << getName() << "_" << std::setfill('0') << std::setw(2) << (iSector_ + 1)
0043       << ".dat";
0044   auto const& fname = oss.str();
0045 
0046   openfile(out_, first, dirTP, fname, __FILE__, __LINE__);
0047 
0048   out_ << "BX = " << (bitset<3>)bx_ << " Event : " << event_ << endl;
0049 
0050   for (unsigned int j = 0; j < tracklets_.size(); j++) {
0051     string proj = (layer_ > 0 && tracklets_[j]->validProj(layer_ - 1)) ? tracklets_[j]->trackletprojstrlayer(layer_)
0052                                                                        : tracklets_[j]->trackletprojstrdisk(disk_);
0053     out_ << "0x";
0054     out_ << std::setfill('0') << std::setw(2);
0055     out_ << hex << j << dec;
0056     out_ << " " << proj << "  " << trklet::hexFormat(proj) << endl;
0057   }
0058   out_.close();
0059 
0060   bx_++;
0061   event_++;
0062   if (bx_ > 7)
0063     bx_ = 0;
0064 }