Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/TrackFindingTracklet/interface/ProcessBase.h"
0002 #include "L1Trigger/TrackFindingTracklet/interface/MemoryBase.h"
0003 #include "L1Trigger/TrackFindingTracklet/interface/Settings.h"
0004 #include "L1Trigger/TrackFindingTracklet/interface/Globals.h"
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 
0009 #include <unordered_map>
0010 
0011 using namespace trklet;
0012 using namespace std;
0013 
0014 ProcessBase::ProcessBase(string name, Settings const& settings, Globals* global)
0015     : name_(name), settings_(settings), globals_(global) {}
0016 
0017 unsigned int ProcessBase::nbits(unsigned int power) {
0018   if (power == 2)
0019     return 1;
0020   if (power == 4)
0021     return 2;
0022   if (power == 8)
0023     return 3;
0024   if (power == 16)
0025     return 4;
0026   if (power == 32)
0027     return 5;
0028 
0029   throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << "nbits: power = " << power;
0030   return 0;
0031 }
0032 
0033 void ProcessBase::initLayerDisk(unsigned int pos, int& layer, int& disk) {
0034   string subname = name_.substr(pos, 2);
0035   layer = 0;
0036   disk = 0;
0037   if (subname.substr(0, 1) == "L")
0038     layer = stoi(subname.substr(1, 1));
0039   else if (subname.substr(0, 1) == "D")
0040     disk = stoi(subname.substr(1, 1));
0041   else
0042     throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " " << name_ << " subname = " << subname << " "
0043                                       << layer << " " << disk;
0044 }
0045 
0046 void ProcessBase::initLayerDisk(unsigned int pos, int& layer, int& disk, int& layerdisk) {
0047   initLayerDisk(pos, layer, disk);
0048 
0049   layerdisk = layer - 1;
0050   if (disk > 0)
0051     layerdisk = N_LAYER + disk - 1;
0052 }
0053 
0054 unsigned int ProcessBase::initLayerDisk(unsigned int pos) {
0055   int layer, disk;
0056   initLayerDisk(pos, layer, disk);
0057 
0058   if (disk > 0)
0059     return N_LAYER + disk - 1;
0060   return layer - 1;
0061 }
0062 
0063 void ProcessBase::initLayerDisksandISeed(unsigned int& layerdisk1, unsigned int& layerdisk2, unsigned int& iSeed) {
0064   layerdisk1 = 99;
0065   layerdisk2 = 99;
0066 
0067   if (name_.substr(0, 3) == "TE_") {
0068     if (name_[3] == 'L') {
0069       layerdisk1 = name_[4] - '1';
0070     } else if (name_[3] == 'D') {
0071       layerdisk1 = N_LAYER + name_[4] - '1';
0072     }
0073     if (name_[11] == 'L') {
0074       layerdisk2 = name_[12] - '1';
0075     } else if (name_[11] == 'D') {
0076       layerdisk2 = N_LAYER + name_[12] - '1';
0077     } else if (name_[12] == 'L') {
0078       layerdisk2 = name_[13] - '1';
0079     } else if (name_[12] == 'D') {
0080       layerdisk2 = N_LAYER + name_[13] - '1';
0081     }
0082   }
0083 
0084   if ((name_.substr(0, 3) == "TC_") || (name_.substr(0, 3) == "TP_")) {
0085     if (name_[3] == 'L') {
0086       layerdisk1 = name_[4] - '1';
0087     } else if (name_[3] == 'D') {
0088       layerdisk1 = N_LAYER + name_[4] - '1';
0089     }
0090     if (name_[5] == 'L') {
0091       layerdisk2 = name_[6] - '1';
0092     } else if (name_[5] == 'D') {
0093       layerdisk2 = N_LAYER + name_[6] - '1';
0094     }
0095   }
0096 
0097   if (layerdisk1 == LayerDisk::L1 && layerdisk2 == LayerDisk::L2)
0098     iSeed = Seed::L1L2;
0099   else if (layerdisk1 == LayerDisk::L2 && layerdisk2 == LayerDisk::L3)
0100     iSeed = Seed::L2L3;
0101   else if (layerdisk1 == LayerDisk::L3 && layerdisk2 == LayerDisk::L4)
0102     iSeed = Seed::L3L4;
0103   else if (layerdisk1 == LayerDisk::L5 && layerdisk2 == LayerDisk::L6)
0104     iSeed = Seed::L5L6;
0105   else if (layerdisk1 == LayerDisk::D1 && layerdisk2 == LayerDisk::D2)
0106     iSeed = Seed::D1D2;
0107   else if (layerdisk1 == LayerDisk::D3 && layerdisk2 == LayerDisk::D4)
0108     iSeed = Seed::D3D4;
0109   else if (layerdisk1 == LayerDisk::L1 && layerdisk2 == LayerDisk::D1)
0110     iSeed = Seed::L1D1;
0111   else if (layerdisk1 == LayerDisk::L2 && layerdisk2 == LayerDisk::D1)
0112     iSeed = Seed::L2D1;
0113   else {
0114     throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " layerdisk1 " << layerdisk1 << " layerdisk2 "
0115                                        << layerdisk2;
0116   }
0117 }
0118 
0119 unsigned int ProcessBase::getISeed(const std::string& name) {
0120   std::size_t pos = name.find('_');
0121   std::string name1 = name.substr(pos + 1);
0122   pos = name1.find('_');
0123   std::string name2 = name1.substr(0, pos);
0124 
0125   unordered_map<string, unsigned int> seedmap = {
0126       {"L1L2", 0},   {"L2L3", 1},   {"L3L4", 2},   {"L5L6", 3},   {"D1D2", 4},    {"D3D4", 5},   {"L1D1", 6},
0127       {"L2D1", 7},   {"L1L2XX", 0}, {"L2L3XX", 1}, {"L3L4XX", 2}, {"L5L6XX", 3},  {"D1D2XX", 4}, {"D3D4XX", 5},
0128       {"L1D1XX", 6}, {"L2D1XX", 7}, {"L3L4L2", 8}, {"L5L6L4", 9}, {"L2L3D1", 10}, {"D1D2L2", 11}};
0129   auto found = seedmap.find(name2);
0130   if (found != seedmap.end())
0131     return found->second;
0132 
0133   throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " " << getName() << " name name1 name2 " << name
0134                                      << " - " << name1 << " - " << name2;
0135   return 0;
0136 }