00001 #include "EventFilter/CSCRawToDigi/interface/CSCTMBHeader2006.h"
00002 #include "EventFilter/CSCRawToDigi/interface/CSCDMBHeader.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004
00005 CSCTMBHeader2006::CSCTMBHeader2006()
00006 {
00007 bzero(data(), sizeInWords()*2);
00008 bits.nHeaderFrames = 26;
00009 bits.e0bline = 0x6E0B;
00010 bits.b0cline = 0x6B0C;
00011 bits.nTBins = 7;
00012 bits.nCFEBs = 5;
00013 }
00014
00015
00016 CSCTMBHeader2006::CSCTMBHeader2006(const unsigned short * buf)
00017 {
00018 memcpy(&bits, buf, sizeInWords()*2);
00019 }
00020
00021 void CSCTMBHeader2006::setEventInformation(const CSCDMBHeader & dmbHeader)
00022 {
00023 bits.cscID = dmbHeader.dmbID();
00024 bits.l1aNumber = dmbHeader.l1a();
00025 bits.bxnCount = dmbHeader.bxn();
00026 }
00027
00029 std::vector<CSCCLCTDigi> CSCTMBHeader2006::CLCTDigis(uint32_t idlayer)
00030 {
00031 std::vector<CSCCLCTDigi> result;
00034 int shape=0;
00035 int type=0;
00036
00037 if ( bits.firmRevCode < 3769 ) {
00038 shape = bits.clct0_shape;
00039 type = bits.clct0_strip_type;
00040 }else {
00041 shape = ( bits.clct0_strip_type<<3)+bits.clct0_shape;
00042 type = 1;
00043 }
00044 int strip = bits.clct0_key;
00045 int cfeb = (bits.clct0_cfeb_low)|(bits.clct0_cfeb_high<<1);
00046 int bend = bits.clct0_bend;
00047
00048
00049 CSCCLCTDigi digi0(bits.clct0_valid, bits.clct0_quality, shape,
00050 type, bend, strip, cfeb, bits.clct0_bxn, 1, bits.bxnPreTrigger);
00051
00052 result.push_back(digi0);
00053
00055 if ( bits.firmRevCode < 3769 ) {
00056 shape = bits.clct1_shape;
00057 type = bits.clct1_strip_type;
00058 } else {
00059 shape = (bits.clct1_strip_type<<3)+bits.clct1_shape;
00060 type = 1;
00061 }
00062
00063 strip = bits.clct1_key;
00064 cfeb = (bits.clct1_cfeb_low)|(bits.clct1_cfeb_high<<1);
00065 bend = bits.clct1_bend;
00066
00067 CSCCLCTDigi digi1(bits.clct1_valid, bits.clct1_quality, shape,
00068 type, bend, strip, cfeb, bits.clct1_bxn, 2, bits.bxnPreTrigger);
00069
00070 result.push_back(digi1);
00071 return result;
00072 }
00073
00075 std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader2006::CorrelatedLCTDigis(uint32_t idlayer) const
00076 {
00077 std::vector<CSCCorrelatedLCTDigi> result;
00079 int strip = bits.MPC_Muon0_halfstrip_clct_pattern;
00080
00081 CSCCorrelatedLCTDigi digi(1, bits.MPC_Muon0_vpf_, bits.MPC_Muon0_quality_,
00082 bits.MPC_Muon0_wire_, strip, bits.MPC_Muon0_clct_pattern_,
00083 bits.MPC_Muon0_bend_, bits.MPC_Muon0_bx_, 0,
00084 bits.MPC_Muon0_bc0_, bits.MPC_Muon0_SyncErr_,
00085 bits.MPC_Muon0_cscid_low | (bits.MPC_Muon0_cscid_bit4<<3) );
00086 result.push_back(digi);
00088 strip = bits.MPC_Muon1_halfstrip_clct_pattern;
00089
00090 digi = CSCCorrelatedLCTDigi(2, bits.MPC_Muon1_vpf_, bits.MPC_Muon1_quality_,
00091 bits.MPC_Muon1_wire_, strip, bits.MPC_Muon1_clct_pattern_,
00092 bits.MPC_Muon1_bend_, bits.MPC_Muon1_bx_, 0,
00093 bits.MPC_Muon1_bc0_, bits.MPC_Muon1_SyncErr_,
00094 bits.MPC_Muon1_cscid_low | (bits.MPC_Muon1_cscid_bit4<<3) );
00095 result.push_back(digi);
00096 return result;
00097 }
00098
00099 void
00100 CSCTMBHeader2006::addALCT0(const CSCALCTDigi & digi)
00101 {
00102 throw cms::Exception("In CSC TMBHeaderFormat 2006, ALCTs belong in ALCT header");
00103 }
00104
00105
00106 void
00107 CSCTMBHeader2006::addALCT1(const CSCALCTDigi & digi)
00108 {
00109 throw cms::Exception("In CSC TMBHeaderFormat 2006, ALCTs belong in ALCT header");
00110 }
00111
00112 void
00113 CSCTMBHeader2006::addCLCT0(const CSCCLCTDigi & digi)
00114 {
00115 int strip = digi.getStrip();
00116 int cfeb = digi.getCFEB();
00117 int bend = digi.getBend();
00118 int pattern = digi.getPattern();
00119
00120 bits.clct0_valid = digi.isValid();
00121 bits.clct0_quality = digi.getQuality();
00122 bits.clct0_shape = pattern;
00123 bits.clct0_strip_type = digi.getStripType();
00124 bits.clct0_bend = bend;
00125 bits.clct0_key = strip;
00126 bits.clct0_cfeb_low = (cfeb & 0x1);
00127 bits.clct0_cfeb_high = (cfeb>>1);
00128 bits.clct0_bxn = digi.getBX();
00129 bits.bxnPreTrigger = digi.getFullBX();
00130 }
00131
00132 void
00133 CSCTMBHeader2006::addCLCT1(const CSCCLCTDigi & digi)
00134 {
00135 int strip = digi.getStrip();
00136 int cfeb = digi.getCFEB();
00137 int bend = digi.getBend();
00138 int pattern = digi.getPattern();
00139
00140 bits.clct1_valid = digi.isValid();
00141 bits.clct1_quality = digi.getQuality();
00142 bits.clct1_shape = pattern;
00143 bits.clct1_strip_type = digi.getStripType();
00144 bits.clct1_bend = bend;
00145 bits.clct1_key = strip;
00146 bits.clct1_cfeb_low = (cfeb & 0x1);
00147 bits.clct1_cfeb_high = (cfeb>>1);
00148 bits.clct1_bxn = digi.getBX();
00149 bits.bxnPreTrigger = digi.getFullBX();
00150 }
00151
00152 void
00153 CSCTMBHeader2006::addCorrelatedLCT0(const CSCCorrelatedLCTDigi & digi)
00154 {
00155 int halfStrip = digi.getStrip();
00156
00157
00158 bits.MPC_Muon0_vpf_ = digi.isValid();
00159 bits.MPC_Muon0_wire_ = digi.getKeyWG();
00160 bits.MPC_Muon0_clct_pattern_ = digi.getPattern();
00161 bits.MPC_Muon0_quality_ = digi.getQuality();
00162 bits.MPC_Muon0_halfstrip_clct_pattern = halfStrip;
00163 bits.MPC_Muon0_bend_ = digi.getBend();
00164 bits.MPC_Muon0_SyncErr_ = digi.getSyncErr();
00165 bits.MPC_Muon0_bx_ = digi.getBX();
00166 bits.MPC_Muon0_bc0_ = digi.getBX0();
00167 bits.MPC_Muon0_cscid_low = digi.getCSCID() & 0x7;
00168 bits.MPC_Muon0_cscid_bit4 = (digi.getCSCID()>>3) & 0x1;
00169 }
00170
00171 void
00172 CSCTMBHeader2006::addCorrelatedLCT1(const CSCCorrelatedLCTDigi & digi)
00173 {
00174 int halfStrip = digi.getStrip();
00175
00176
00177 bits.MPC_Muon1_vpf_ = digi.isValid();
00178 bits.MPC_Muon1_wire_ = digi.getKeyWG();
00179 bits.MPC_Muon1_clct_pattern_ = digi.getPattern();
00180 bits.MPC_Muon1_quality_ = digi.getQuality();
00181 bits.MPC_Muon1_halfstrip_clct_pattern = halfStrip;
00182 bits.MPC_Muon1_bend_ = digi.getBend();
00183 bits.MPC_Muon1_SyncErr_ = digi.getSyncErr();
00184 bits.MPC_Muon1_bx_ = digi.getBX();
00185 bits.MPC_Muon1_bc0_ = digi.getBX0();
00186 bits.MPC_Muon1_cscid_low = digi.getCSCID() & 0x7;
00187 bits.MPC_Muon0_cscid_bit4 = (digi.getCSCID()>>3) & 0x1;
00188 }
00189
00190
00191 void CSCTMBHeader2006::print(std::ostream & os) const
00192 {
00193 os << "...............TMB Header.................." << "\n";
00194 os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
00195 os << std::dec << "fifoMode = " << bits.fifoMode
00196 << ", nTBins = " << bits.nTBins << "\n";
00197 os << "dumpCFEBs = " << bits.dumpCFEBs << ", nHeaderFrames = "
00198 << bits.nHeaderFrames << "\n";
00199 os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
00200 os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
00201 os << "preTrigTBins = " << bits.preTrigTBins << ", nCFEBs = "<< bits.nCFEBs<< "\n";
00202 os << "trigSourceVect = " << bits.trigSourceVect
00203 << ", activeCFEBs = " << bits.activeCFEBs << "\n";
00204 os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
00205 os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly
00206 << " clctOnly = " << bits.clctOnly
00207 << " alctMatchTime = " << bits.alctMatchTime << "\n";
00208 os << "hs_thresh = " << bits.hs_thresh << ", ds_thresh = " << bits.ds_thresh
00209 << "\n";
00210 os << ".clct0_key = " << bits.clct0_key << " clct0_shape = " << bits.clct0_shape
00211 << " clct0_quality = " << bits.clct0_quality << "\n";
00212 os << "r_buf_nbusy = " << bits.r_buf_nbusy << "\n";
00213 os << "Firmware Rev code " << bits.firmRevCode << "\n";
00214 os << "..................CLCT....................." << std::endl;
00215 }
00216
00217
00218
00219