Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/TrackFindingTracklet/interface/InputRouter.h"
0002 #include "L1Trigger/TrackFindingTracklet/interface/Settings.h"
0003 #include "L1Trigger/TrackFindingTracklet/interface/Globals.h"
0004 #include "L1Trigger/TrackFindingTracklet/interface/Stub.h"
0005 #include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h"
0006 #include "L1Trigger/TrackFindingTracklet/interface/InputLinkMemory.h"
0007 #include "L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h"
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 
0012 using namespace std;
0013 using namespace trklet;
0014 
0015 InputRouter::InputRouter(string name, Settings const& settings, Globals* global)
0016     : ProcessBase(name, settings, global) {}
0017 
0018 void InputRouter::addOutput(MemoryBase* memory, string output) {
0019   if (settings_.writetrace()) {
0020     edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
0021                                  << output;
0022   }
0023 
0024   if (output == "stubout") {
0025     InputLinkMemory* tmp = dynamic_cast<InputLinkMemory*>(memory);
0026     assert(tmp != nullptr);
0027     unsigned int layerdisk = tmp->getName()[4] - '1';
0028     if (tmp->getName()[3] == 'D') {
0029       layerdisk += N_LAYER;
0030     }
0031     assert(layerdisk < N_LAYER + N_DISK);
0032     unsigned int phireg = tmp->getName()[8] - 'A';
0033     std::pair<unsigned int, unsigned int> layerphireg(layerdisk, phireg);
0034     irstubs_.emplace_back(layerphireg, tmp);
0035     return;
0036   }
0037 
0038   throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output;
0039 }
0040 
0041 void InputRouter::addInput(MemoryBase* memory, string input) {
0042   if (settings_.writetrace()) {
0043     edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
0044                                  << input;
0045   }
0046   if (input == "stubin") {
0047     dtcstubs_ = dynamic_cast<DTCLinkMemory*>(memory);
0048     assert(dtcstubs_ != nullptr);
0049     return;
0050   }
0051   throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input;
0052 }
0053 
0054 void InputRouter::execute() {
0055   for (unsigned int i = 0; i < settings_.maxStep("IR"); i++) {
0056     if (i >= dtcstubs_->nStubs()) {
0057       break;
0058     }
0059 
0060     Stub* stub = dtcstubs_->getStub(i);
0061 
0062     unsigned int layerdisk = stub->l1tstub()->layerdisk();
0063 
0064     FPGAWord iphi = stub->phicorr();
0065     unsigned int iphipos = iphi.value() >> (iphi.nbits() - settings_.nbitsallstubs(layerdisk));
0066 
0067     std::pair<unsigned int, unsigned int> layerphireg(layerdisk, iphipos);
0068 
0069     //Fill inner allstubs memories - in HLS this is the same write to multiple memories
0070     int iadd = 0;
0071     for (auto& irstubmem : irstubs_) {
0072       if (layerphireg == irstubmem.first) {
0073         irstubmem.second->addStub(stub);
0074         iadd++;
0075       }
0076     }
0077     assert(iadd == 1);
0078   }
0079 }