00001 #include "EventFilter/CSCRawToDigi/interface/CSCTMBHeader2007_rev0x50c3.h"
00002 #include "EventFilter/CSCRawToDigi/interface/CSCDMBHeader.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004
00005 CSCTMBHeader2007_rev0x50c3::CSCTMBHeader2007_rev0x50c3()
00006 {
00007 bzero(data(), sizeInWords()*2);
00008 bits.nHeaderFrames = 42;
00009 bits.e0bline = 0x6E0B;
00010 bits.b0cline = 0xDB0C;
00011 bits.firmRevCode = 0x50c3;
00012 bits.nTBins = 12;
00013 bits.nCFEBs = 5;
00014 }
00015
00016
00017 CSCTMBHeader2007_rev0x50c3::CSCTMBHeader2007_rev0x50c3(const unsigned short * buf)
00018 {
00019 memcpy(data(), buf, sizeInWords()*2);
00020 }
00021
00022
00023 void CSCTMBHeader2007_rev0x50c3::setEventInformation(const CSCDMBHeader & dmbHeader)
00024 {
00025 bits.cscID = dmbHeader.dmbID();
00026 bits.l1aNumber = dmbHeader.l1a();
00027 bits.bxnCount = dmbHeader.bxn();
00028 }
00029
00031 std::vector<CSCCLCTDigi> CSCTMBHeader2007_rev0x50c3::CLCTDigis(uint32_t idlayer)
00032 {
00033 std::vector<CSCCLCTDigi> result;
00034 int halfstrip = bits.clct0_key_low + (bits.clct0_key_high << 7);
00035 int strip = halfstrip%32;
00036 int cfeb = halfstrip/32;
00037 int pattern = bits.clct0_shape;
00038 int bend = pattern &0x1;
00039
00040
00041 CSCCLCTDigi digi0(bits.clct0_valid, bits.clct0_quality,
00042 pattern, 1, bend, strip, cfeb, bits.clct_bxn, 1, bits.bxnPreTrigger);
00043
00044
00045 halfstrip = bits.clct1_key_low + (bits.clct1_key_high << 7);
00046 strip = halfstrip%32;
00047 cfeb = halfstrip/32;
00048 pattern = bits.clct1_shape;
00049 bend = pattern &0x1;
00050
00051
00052 CSCCLCTDigi digi1(bits.clct1_valid, bits.clct1_quality,
00053 pattern, 1, bend, strip, cfeb, bits.clct_bxn, 2, bits.bxnPreTrigger);
00054
00055 result.push_back(digi0);
00056 result.push_back(digi1);
00057 return result;
00058 }
00059
00061 std::vector<CSCCorrelatedLCTDigi>
00062 CSCTMBHeader2007_rev0x50c3::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_rev0x50c3::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_rev0x50c3::addALCT1(const CSCALCTDigi & digi)
00095 {
00096 throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
00097 }
00098
00099 void
00100 CSCTMBHeader2007_rev0x50c3::addCLCT0(const CSCCLCTDigi & digi)
00101 {
00102 int halfStrip = digi.getKeyStrip();
00103 int pattern = digi.getPattern();
00104
00105
00106 bits.clct0_valid = digi.isValid();
00107 bits.clct0_quality = digi.getQuality();
00108 bits.clct0_shape = pattern;
00109
00110 bits.clct0_key_low = halfStrip & (0x7F);
00111
00112 bits.clct0_key_high = (halfStrip >> 7) & (0x1);
00113 bits.clct_bxn = digi.getBX();
00114 bits.bxnPreTrigger = digi.getFullBX();
00115 }
00116
00117 void
00118 CSCTMBHeader2007_rev0x50c3::addCLCT1(const CSCCLCTDigi & digi)
00119 {
00120 int halfStrip = digi.getKeyStrip();
00121 int pattern = digi.getPattern();
00122
00123
00124 bits.clct1_valid = digi.isValid();
00125 bits.clct1_quality = digi.getQuality();
00126 bits.clct1_shape = pattern;
00127
00128 bits.clct1_key_low = halfStrip & (0x7F);
00129
00130 bits.clct1_key_high = (halfStrip >> 7) & (0x1);
00131
00132
00133
00134 bits.bxnPreTrigger = digi.getFullBX();
00135 }
00136
00137 void
00138 CSCTMBHeader2007_rev0x50c3::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_rev0x50c3::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_rev0x50c3::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
00196 os << " bits.clct0_shape = " << bits.clct0_shape
00197 << " clct0_quality = " << bits.clct0_quality << "\n";
00198
00199
00200 os << "..................CLCT....................." << "\n";
00201
00202 }
00203