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