Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:08

0001 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h"
0002 
0003 namespace {
0004   template <typename T>
0005   int sgn(T val) {
0006     return (T(0) < val) - (val < T(0));
0007   }
0008 }  // namespace
0009 
0010 OmtfName::OmtfName(unsigned int iProcesor, int endcap, const OMTFConfiguration* omtfConfig) {
0011   int iproc = (iProcesor < omtfConfig->nProcessors()) ? static_cast<int>(iProcesor) : -1;
0012   int position = (abs(endcap) == 1) ? endcap : 0;
0013   theBoard = static_cast<Board>(sgn(position) * (iproc + 1));
0014 }
0015 
0016 OmtfName::OmtfName(unsigned int iProcesor, l1t::tftype endcap, const OMTFConfiguration* omtfConfig) {
0017   int iproc = (iProcesor < omtfConfig->nProcessors()) ? static_cast<int>(iProcesor) : -1;
0018   int position = (endcap == l1t::omtf_pos) ? 1 : ((endcap == l1t::omtf_neg) ? -1 : 0);
0019   theBoard = static_cast<Board>(sgn(position) * (iproc + 1));
0020 }
0021 
0022 OmtfName::OmtfName(unsigned int iProcesor, const OMTFConfiguration* omtfConfig) {
0023   int board = 0;
0024   if (iProcesor < omtfConfig->nProcessors())  //OMTFn
0025     board = -iProcesor - 1;
0026   else  //OMTFp
0027     board = iProcesor - (omtfConfig->nProcessors() - 1);
0028   theBoard = static_cast<Board>(board);
0029 }
0030 
0031 OmtfName::OmtfName(const std::string& board) {
0032   if (board == "OMTFn1")
0033     theBoard = OMTFn1;
0034   else if (board == "OMTFn2")
0035     theBoard = OMTFn2;
0036   else if (board == "OMTFn3")
0037     theBoard = OMTFn3;
0038   else if (board == "OMTFn4")
0039     theBoard = OMTFn4;
0040   else if (board == "OMTFn5")
0041     theBoard = OMTFn5;
0042   else if (board == "OMTFn6")
0043     theBoard = OMTFn6;
0044   else if (board == "OMTFp1")
0045     theBoard = OMTFp1;
0046   else if (board == "OMTFp2")
0047     theBoard = OMTFp2;
0048   else if (board == "OMTFp3")
0049     theBoard = OMTFp3;
0050   else if (board == "OMTFp4")
0051     theBoard = OMTFp4;
0052   else if (board == "OMTFp5")
0053     theBoard = OMTFp5;
0054   else if (board == "OMTFp6")
0055     theBoard = OMTFp6;
0056   else
0057     theBoard = OMTFp6;
0058 }
0059 
0060 std::string OmtfName::name() const {
0061   switch (theBoard) {
0062     case (OMTFn1):
0063       return "OMTFn1";
0064     case (OMTFn2):
0065       return "OMTFn2";
0066     case (OMTFn3):
0067       return "OMTFn3";
0068     case (OMTFn4):
0069       return "OMTFn4";
0070     case (OMTFn5):
0071       return "OMTFn5";
0072     case (OMTFn6):
0073       return "OMTFn6";
0074     case (OMTFp1):
0075       return "OMTFp1";
0076     case (OMTFp2):
0077       return "OMTFp2";
0078     case (OMTFp3):
0079       return "OMTFp3";
0080     case (OMTFp4):
0081       return "OMTFp4";
0082     case (OMTFp5):
0083       return "OMTFp5";
0084     case (OMTFp6):
0085       return "OMTFp6";
0086     default:
0087       return "UNKNOWN";
0088   }
0089 }
0090 
0091 int OmtfName::position() const { return sgn(theBoard); }
0092 
0093 unsigned int OmtfName::processor() const { return abs(theBoard) - 1; }
0094 
0095 l1t::tftype OmtfName::tftype() const { return sgn(theBoard) > 0 ? l1t::omtf_pos : l1t::omtf_neg; }