CMS 3D CMS Logo

OmtfEleIndex.h
Go to the documentation of this file.
1 #ifndef EventFilter_L1TRawToDigi_Omtf_EleIndex_H
2 #define EventFilter_L1TRawToDigi_Omtf_EleIndex_H
3 
4 #include <cstdint>
5 #include <string>
6 #include <ostream>
7 
8 namespace omtf {
9 class EleIndex {
10 public:
11  EleIndex() : packed_(0) {}
12  EleIndex(const std::string & board, unsigned int link) {
13  unsigned int fed = 0;
14  if (board.substr(4,1)=="n") fed = 1380; else if (board.substr(4,1)=="p") fed = 1381;
15  unsigned int amc = std::stoi( board.substr(5,1) );
16  packed_ = fed*1000+amc*100+link;
17  }
18  EleIndex(unsigned int fed, unsigned int amc, unsigned int link) { packed_ = fed*1000+amc*100+link; }
19  unsigned int fed() const { return packed_/1000; }
20  unsigned int amc() const { return ( (packed_ /100) %10); }
21  unsigned int link() const { return packed_ % 100; }
22  friend std::ostream & operator<< (std::ostream &out, const EleIndex &o) {
23  out << "OMTF";
24  if (o.fed()==1380) out <<"n";
25  if (o.fed()==1381) out <<"p";
26  out << o.amc();
27  out <<" (fed: "<<o.fed()<<"), ln: " << o.link();
28  return out;
29  }
30  inline bool operator< (const EleIndex& o) const { return this->packed_ < o.packed_; }
31 
32 private:
33  uint32_t packed_;
34 
35 };
36 
37 } //namespace imtf
38 #endif
39 
EleIndex(const std::string &board, unsigned int link)
Definition: OmtfEleIndex.h:12
friend std::ostream & operator<<(std::ostream &out, const EleIndex &o)
Definition: OmtfEleIndex.h:22
unsigned int fed() const
Definition: OmtfEleIndex.h:19
bool operator<(const EleIndex &o) const
Definition: OmtfEleIndex.h:30
EleIndex(unsigned int fed, unsigned int amc, unsigned int link)
Definition: OmtfEleIndex.h:18
unsigned int amc() const
Definition: OmtfEleIndex.h:20
unsigned int link() const
Definition: OmtfEleIndex.h:21
Definition: AMCSpec.h:8
uint32_t packed_
Definition: OmtfEleIndex.h:33