00001 00011 #include <DataFormats/CSCDigi/interface/CSCCLCTDigi.h> 00012 00013 #include <iomanip> 00014 00015 using namespace std; 00016 00018 CSCCLCTDigi::CSCCLCTDigi(const int valid, const int quality, const int pattern, 00019 const int striptype, const int bend, const int strip, 00020 const int cfeb, const int bx, const int trknmb) { 00021 valid_ = valid; 00022 quality_ = quality; 00023 pattern_ = pattern; 00024 striptype_ = striptype; 00025 bend_ = bend; 00026 strip_ = strip; 00027 cfeb_ = cfeb; 00028 bx_ = bx; 00029 trknmb_ = trknmb; 00030 } 00031 00033 CSCCLCTDigi::CSCCLCTDigi () { 00034 clear(); // set contents to zero 00035 } 00036 00038 void CSCCLCTDigi::clear() { 00039 valid_ = 0; 00040 quality_ = 0; 00041 pattern_ = 0; 00042 striptype_ = 0; 00043 bend_ = 0; 00044 strip_ = 0; 00045 cfeb_ = 0; 00046 bx_ = 0; 00047 trknmb_ = 0; 00048 fullbx_ = 0; 00049 } 00050 00051 bool CSCCLCTDigi::operator > (const CSCCLCTDigi& rhs) const { 00052 bool returnValue = false; 00053 /* The quality value for the cathodeLCT is different than for the 00054 anodeLCT. Remember that for the anodeLCT, the more layers that were 00055 hit the higher the quality. For the cathodeLCT there is a pattern 00056 assignment given. This is based on the range of strips hit and 00057 the number of layers. The hits on the strips are divided into 00058 high Pt (transverse momentum) and low Pt. A half strip pattern check 00059 is used for high Pt; and a di-strip pattern is used for low Pt. 00060 The order of quality from highest to lowest is 6/6 halfstrip, 00061 5/6 halfstrip, 6/6 distrip, 4/6 halfstrip, 5/6 distrip, 4/6 distrip. 00062 (see CSCCathodeLCTProcessor for further details.) -JM 00063 */ 00064 int quality = getQuality(); 00065 int rhsQuality = rhs.getQuality(); 00066 int stripType = getStripType(); 00067 int rhsStripType = rhs.getStripType(); 00068 00069 #ifdef TB 00070 // Test beams' implementation. 00071 #ifdef TBs 00072 // This algo below was used in 2003 and 2004 test beams, but not in MTCC. 00073 if (stripType == rhsStripType) { // both di-strip or half-strip 00074 if (quality > rhsQuality) {returnValue = true;} 00075 #ifdef LATER 00076 else if (quality == rhsQuality) { 00077 // The rest SEEMS NOT TO BE USED at the moment. Brian's comment: 00078 // "There is a bug in the TMB firmware in terms of swapping the lcts." 00079 // In the case of identical quality, select higher pattern. 00080 int pattern = getPattern(); 00081 int rhsPattern = rhs.getPattern(); 00082 if (pattern > rhsPattern) {returnValue = true;} 00083 else if (pattern == rhsPattern) { 00084 // In the case of identical pattern, select lower key strip number. 00085 if (getKeyStrip() < rhs.getKeyStrip()) {returnValue = true;} 00086 } 00087 } 00088 #endif 00089 } 00090 else if (stripType > rhsStripType) { 00091 // Always select half-strip pattern over di-strip pattern. 00092 returnValue = true; 00093 } 00094 #else 00095 // MTCC variant. 00096 if (quality > rhsQuality) {returnValue = true;} 00097 #endif 00098 00099 #else 00100 // Hack to preserve old behaviour; needs to be clarified. 00101 quality -= 3; 00102 rhsQuality -= 3; 00103 if (quality < 0 || rhsQuality < 0) { 00104 std::cout << " +++ CSCCLCTDigi, overloaded > : undefined qualities " 00105 << quality << " " << rhsQuality << " ... Do nothing +++" 00106 << std::endl; 00107 return returnValue; 00108 } 00109 // Default ORCA option. 00110 if (stripType == rhsStripType) { // both di-strip or half-strip 00111 if (quality > rhsQuality) {returnValue = true;} 00112 else if (quality == rhsQuality) { 00113 // In the case of cathode LCTs with identical quality, the lower 00114 // strip number is selected. 00115 if (getKeyStrip() < rhs.getKeyStrip()) {returnValue = true;} 00116 } 00117 } 00118 else if (stripType > rhsStripType) { // halfstrip, distrip 00119 // 5/6, 6/6 halfstrip better than all but 6/6 distrip: 00120 // If halfstrip quality is 2 or 3, it beats all distrip qualities. 00121 // If halfstrip quality is 1, it beats everything except 00122 // distrip quality or 3. 00123 if (quality >= rhsQuality - 1) {returnValue = true;} 00124 } 00125 else if (stripType < rhsStripType) { // distrip, halfstrip 00126 // If distrip quality is 3, it beats a halfstrip quality of 1. 00127 if (quality - 1 > rhsQuality) {returnValue = true;} 00128 } 00129 #endif 00130 00131 return returnValue; 00132 } 00133 00134 bool CSCCLCTDigi::operator == (const CSCCLCTDigi& rhs) const { 00135 bool returnValue = false; 00136 00137 // Exact equality. 00138 if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && 00139 getPattern() == rhs.getPattern() && getKeyStrip()== rhs.getKeyStrip()&& 00140 getStripType() == rhs.getStripType() && getBend() == getBend() && 00141 getBX() == rhs.getBX()) { 00142 returnValue = true; 00143 } 00144 else { 00145 int stripType = getStripType(); 00146 int rhsStripType = rhs.getStripType(); 00147 00148 // Note: if both muons are either high and low pT, then there's the chance 00149 // that one of them is at exactly the strip of the other. Don't 00150 // want to chuck out muons that way! 00151 // The numbering is not obvious because of the 'staggering' on each of the 00152 // layers. When the staggering is completely understood, this algorithm 00153 // should be re-checked for consistency. -JM 00154 if (stripType != rhsStripType) { 00155 if (abs(getKeyStrip() - rhs.getKeyStrip()) < 5) { 00156 returnValue = true; 00157 } 00158 } 00159 } 00160 return returnValue; 00161 } 00162 00163 bool CSCCLCTDigi::operator != (const CSCCLCTDigi& rhs) const { 00164 bool returnValue = false; 00165 // Check exact equality. 00166 if (isValid() != rhs.isValid() || getQuality() != rhs.getQuality() || 00167 getPattern() != rhs.getPattern() || getKeyStrip()!= rhs.getKeyStrip()|| 00168 getStripType() != rhs.getStripType() || getBend() != getBend() || 00169 getBX() != rhs.getBX()) { 00170 returnValue = true; 00171 } 00172 return returnValue; 00173 } 00174 00176 void CSCCLCTDigi::print() const { 00177 if (isValid()) { 00178 char stripType = (getStripType() == 0) ? 'D' : 'H'; 00179 char bend = (getBend() == 0) ? 'L' : 'R'; 00180 00181 std::cout << " CSC CLCT #" << setw(1) << getTrknmb() 00182 << ": Valid = " << setw(1) << isValid() 00183 << " Key Strip = " << setw(3) << getKeyStrip() 00184 << " Strip = " << setw(2) << getStrip() 00185 << " Quality = " << setw(1) << getQuality() 00186 << " Pattern = " << setw(1) << getPattern() 00187 << " Bend = " << setw(1) << bend 00188 << " Strip type = " << setw(1) << stripType 00189 << " CFEB ID = " << setw(1) << getCFEB() 00190 << " BX = " << setw(1) << getBX() << std::endl; 00191 } 00192 else { 00193 std::cout << "Not a valid Cathode LCT." << std::endl; 00194 } 00195 }