CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DataFormats/L1Trigger/src/L1DataEmulDigi.cc

Go to the documentation of this file.
00001 #include "DataFormats/L1Trigger/interface/L1DataEmulDigi.h"
00002 #include <iomanip>
00003 
00004 bool L1DataEmulDigi::empty() const {
00005   if(m_sid == m_null  || m_cid == m_null ) 
00006     return true;
00007   bool val = true;
00008   for(int i=0; i<2; i++) 
00009     val &= ( m_location[i]==m_null );
00010   return val;
00011 }
00012 
00013 int L1DataEmulDigi::reset() {
00014   m_null = -99;
00015   m_sid = m_null; 
00016   m_cid = m_null;
00017   for(int i=0; i<3; i++) 
00018     m_location[i]=m_null;
00019   m_type = m_null; 
00020   std::fill(m_data,m_data+sizeof(m_data)/sizeof(m_data[0]),0);
00021   std::fill(m_rank,m_rank+sizeof(m_rank)/sizeof(m_rank[0]),m_null);
00022   L1MonitorDigi def;
00023   m_DEpair[0]=def;   m_DEpair[1]=def;
00024   return m_null;
00025 }
00026 
00027 L1DataEmulDigi::L1DataEmulDigi() {
00028   reset();
00029 }
00030 
00031 L1DataEmulDigi::L1DataEmulDigi( int sid, int cid, double x1, double x2, double x3, int n) {
00032   reset();
00033   m_sid = sid; m_cid = cid;
00034   m_location[0]=x1; m_location[1]=x2; m_location[2]=x3;
00035   m_type = n; 
00036 }
00037 
00038 L1DataEmulDigi::L1DataEmulDigi( int sid, int cid, double x1, double x2, double x3, int n,
00039                                 unsigned int dw, unsigned int ew, float dr, float er, 
00040                                 L1MonitorDigi dm, L1MonitorDigi em) {
00041   reset();
00042   m_sid = sid; m_cid = cid;
00043   m_location[0]=x1; m_location[1]=x2; m_location[2]=x3;
00044   m_type = n; 
00045   m_data  [0]=dw; m_data  [1]=ew;
00046   m_rank  [0]=dr; m_rank  [1]=er;
00047   m_DEpair[0]=dm; m_DEpair[1]=em;
00048 }
00049 
00050 L1DataEmulDigi::~L1DataEmulDigi() {}
00051 
00052 std::ostream& operator<<(std::ostream& s, const L1DataEmulDigi& de) {
00053     unsigned word[2];
00054     float rankarr[2];
00055     de.data(word);
00056     de.rank(rankarr);
00057     s << "DEdigi"
00058       << " subsystem: "  << std::setw(2) << de.sid()
00059       << " (cid."        << std::setw(2) << de.cid() << ")"
00060       << " location: " 
00061       << "(" << std::setw(5) << std::setprecision(2) << de.x1() 
00062       << "," << std::setw(5) << std::setprecision(2) << de.x2() 
00063       << "," << std::setw(5) << std::setprecision(2) << de.x3() << ")"
00064       << " type: " << de.type()
00065       << std::hex << std::setfill('0')
00066       << " dword:0x" << std::setw(8)<< word[0]
00067       << " eword:0x" << std::setw(8)<< word[1]
00068       << std::dec << std::setfill(' ')
00069       << " rank:"
00070       << "(" << std::setw(5) << std::setprecision(2) << rankarr[0] 
00071       << "," << std::setw(5) << std::setprecision(2) << rankarr[1] << ")";
00072     return s;
00073 }
00074 
00075 GltDEDigi::GltDEDigi() {
00076   this->reset();
00077 }
00078 
00079 void GltDEDigi::reset() {
00080   const int w64 = 64; 
00081   for(int j=0; j<2; j++) {
00082     globalDBit[j]=false;
00083     gltDecBits[j].reserve(w64*2);
00084     gltTchBits[j].reserve(w64  );
00085     for(int i=0; i<w64; i++) {
00086       gltDecBits[j][i]    =false;  
00087       gltDecBits[j][i+w64]=false;  
00088       gltTchBits[j][i]    =false;
00089     }
00090   }
00091 }
00092 
00093 GltDEDigi::GltDEDigi(bool glbit[], GltBits dbits[], GltBits tbits[]) {
00094   this->set(glbit, dbits, tbits);
00095 }
00096 
00097 void GltDEDigi::set(bool glbit[], GltBits dbits[], GltBits tbits[]) {
00098   for(int i=0; i<2; i++) {
00099     globalDBit[i]=glbit[i];
00100     gltDecBits[i]=dbits[i];
00101     gltTchBits[i]=tbits[i];
00102   }
00103 }
00104 
00105 std::ostream& operator<<(std::ostream& s, const GltDEDigi& glt) {
00106   GltDEDigi::GltBits dbits[2], tbits[2];
00107   bool glbit[2];
00108   for(int i=0; i<2; i++) {
00109     glbit[i]=glt.globalDBit[i];
00110     dbits[i]=glt.gltDecBits[i];
00111     tbits[i]=glt.gltTchBits[i];
00112   }
00113   s << "GT DEdigi"
00114     << " decision: "
00115     << glbit[0];
00116   if(glbit[0]!=glbit[1])
00117     s << "(data), " << glbit[1] << "(emul)";
00118   s << "\n data dec-word: ";
00119   for(GltDEDigi::GltBits::const_iterator i=dbits[0].begin();
00120       i!=dbits[0].end(); i++)  s<<*i; 
00121   s << "\n emul dec-word: ";
00122   for(GltDEDigi::GltBits::const_iterator i=dbits[1].begin();
00123       i!=dbits[1].end(); i++)  s<<*i; 
00124   s << "\n data techical: ";
00125   for(GltDEDigi::GltBits::const_iterator i=tbits[0].begin();
00126       i!=tbits[0].end(); i++)  s<<*i; 
00127   s << "\n emul technical: ";
00128   for(GltDEDigi::GltBits::const_iterator i=tbits[1].begin();
00129       i!=tbits[1].end(); i++)  s<<*i; 
00130   return s;
00131 }