Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "CondFormats/L1TObjects/interface/L1MuDTPtaLut.h"
00022
00023
00024
00025
00026
00027 #include <iostream>
00028 #include <ostream>
00029 #include <iomanip>
00030 #include <string>
00031 #include <cstdlib>
00032
00033
00034
00035
00036
00037 #include "FWCore/ParameterSet/interface/FileInPath.h"
00038 #include "CondFormats/L1TObjects/interface/DTTFBitArray.h"
00039 #include "CondFormats/L1TObjects/interface/L1MuDTAssParam.h"
00040 #include "CondFormats/L1TObjects/interface/L1TriggerLutFile.h"
00041
00042 using namespace std;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 L1MuDTPtaLut::L1MuDTPtaLut() :
00053 pta_lut(0),
00054 pta_threshold(MAX_PTASSMETH/2) {
00055
00056 pta_lut.reserve(MAX_PTASSMETH);
00057 pta_threshold.reserve(MAX_PTASSMETH/2);
00058 setPrecision();
00059
00060
00061
00062
00063
00064
00065
00066 }
00067
00068
00069
00070
00071
00072
00073 L1MuDTPtaLut::~L1MuDTPtaLut() {
00074
00075 vector<LUT>::iterator iter;
00076 for ( iter = pta_lut.begin(); iter != pta_lut.end(); iter++ ) {
00077 (*iter).clear();
00078 }
00079
00080 pta_lut.clear();
00081 pta_threshold.clear();
00082
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 void L1MuDTPtaLut::reset() {
00094
00095 pta_lut.clear();
00096 pta_threshold.clear();
00097
00098 }
00099
00100
00101
00102
00103
00104 int L1MuDTPtaLut::load() {
00105
00106
00107 string defaultPath = "L1TriggerConfig/DTTrackFinder/parameters/";
00108 string pta_dir = "L1TriggerData/DTTrackFinder/Ass/";
00109 string pta_str = "";
00110
00111
00112
00113
00114
00115 int sh_phi = 12 - nbit_phi;
00116
00117
00118 for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) {
00119 switch ( pam ) {
00120 case PT12L : { pta_str = "pta12l"; break; }
00121 case PT12H : { pta_str = "pta12h"; break; }
00122 case PT13L : { pta_str = "pta13l"; break; }
00123 case PT13H : { pta_str = "pta13h"; break; }
00124 case PT14L : { pta_str = "pta14l"; break; }
00125 case PT14H : { pta_str = "pta14h"; break; }
00126 case PT23L : { pta_str = "pta23l"; break; }
00127 case PT23H : { pta_str = "pta23h"; break; }
00128 case PT24L : { pta_str = "pta24l"; break; }
00129 case PT24H : { pta_str = "pta24h"; break; }
00130 case PT34L : { pta_str = "pta34l"; break; }
00131 case PT34H : { pta_str = "pta34h"; break; }
00132 case PT12LO : { pta_str = "pta12l_ovl"; break; }
00133 case PT12HO : { pta_str = "pta12h_ovl"; break; }
00134 case PT13LO : { pta_str = "pta13l_ovl"; break; }
00135 case PT13HO : { pta_str = "pta13h_ovl"; break; }
00136 case PT14LO : { pta_str = "pta14l_ovl"; break; }
00137 case PT14HO : { pta_str = "pta14h_ovl"; break; }
00138 case PT23LO : { pta_str = "pta23l_ovl"; break; }
00139 case PT23HO : { pta_str = "pta23h_ovl"; break; }
00140 case PT24LO : { pta_str = "pta24l_ovl"; break; }
00141 case PT24HO : { pta_str = "pta24h_ovl"; break; }
00142 case PT34LO : { pta_str = "pta34l_ovl"; break; }
00143 case PT34HO : { pta_str = "pta34h_ovl"; break; }
00144 case PT15LO : { pta_str = "pta15l_ovl"; break; }
00145 case PT15HO : { pta_str = "pta15h_ovl"; break; }
00146 case PT25LO : { pta_str = "pta25l_ovl"; break; }
00147 case PT25HO : { pta_str = "pta25h_ovl"; break; }
00148 }
00149
00150
00151 edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + pta_dir + pta_str + ".lut"));
00152 string pta_file = lut_f.fullPath();
00153
00154
00155 L1TriggerLutFile file(pta_file);
00156 if ( file.open() != 0 ) return -1;
00157
00158
00159
00160
00161 int shift = sh_phi;
00162 int adr_old = -2048 >> shift;
00163
00164 LUT tmplut;
00165
00166 int number = -1;
00167 int sum_pt = 0;
00168
00169 if ( file.good() ) {
00170 int threshold = file.readInteger();
00171 pta_threshold[pam/2] = threshold;
00172 }
00173
00174
00175 while ( file.good() ) {
00176
00177 int adr = (file.readInteger()) >> shift;
00178 int pt = file.readInteger();
00179
00180 number++;
00181
00182 if ( adr != adr_old ) {
00183 tmplut.insert(make_pair( adr_old, (sum_pt/number) ));
00184
00185 adr_old = adr;
00186 number = 0;
00187 sum_pt = 0;
00188 }
00189
00190 sum_pt += pt;
00191
00192 if ( !file.good() ) file.close();
00193
00194 }
00195
00196 file.close();
00197 pta_lut.push_back(tmplut);
00198 }
00199 return 0;
00200
00201 }
00202
00203
00204
00205
00206
00207 void L1MuDTPtaLut::print() const {
00208
00209 cout << endl;
00210 cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
00211 cout << "=====================================================" << endl;
00212 cout << endl;
00213 cout << "Precision : " << endl;
00214 cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
00215
00216
00217 for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) {
00218
00219 cout << endl;
00220 cout << "Pt-Assignment Method : " << static_cast<PtAssMethod>(pam) << endl;
00221 cout << "============================" << endl;
00222 cout << endl;
00223
00224 cout << "\t Threshold : " << getPtLutThreshold(pam/2) << endl << endl;
00225
00226 int maxbits = nbit_phi;
00227
00228 cout << " address";
00229 for ( int i = 0; i < maxbits; i++ ) cout << ' ';
00230 cout << " value" << endl;
00231 for ( int i = 0; i < maxbits; i++ ) cout << '-';
00232 cout << "-------------------------" << endl;
00233
00234 LUT::const_iterator iter = pta_lut[pam].begin();
00235 while ( iter != pta_lut[pam].end() ) {
00236 int address = (*iter).first;
00237 int value = (*iter).second;
00238
00239 DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
00240 DTTFBitArray<5> b_value(static_cast<unsigned>(abs(value)));
00241
00242 if ( address < 0 ) b_address.twoComplement();
00243
00244 cout.setf(ios::right,ios::adjustfield);
00245 cout << " " << setbase(10) << setw(5) << address << " (";
00246 for ( int i = maxbits-1; i >= 0; i-- ) cout << b_address[i];
00247 cout << ") " << setw(3) << value << " (";
00248 b_value.print();
00249 cout << ")" << endl;
00250
00251 iter++;
00252 }
00253
00254 }
00255
00256 cout << endl;
00257
00258 }
00259
00260
00261
00262
00263
00264 int L1MuDTPtaLut::getPt(int pta_ind, int address) const {
00265
00266 LUT::const_iterator iter = pta_lut[pta_ind].find(address);
00267 if ( iter != pta_lut[pta_ind].end() ) {
00268 return (*iter).second;
00269 }
00270 else {
00271 cerr << "PtaLut::getPt : can not find address " << address << endl;
00272 return 0;
00273 }
00274
00275 }
00276
00277
00278
00279
00280
00281 int L1MuDTPtaLut::getPtLutThreshold(int pta_ind) const {
00282
00283 if ( pta_ind >= 0 && pta_ind < MAX_PTASSMETH/2 ) {
00284 return pta_threshold[pta_ind];
00285 }
00286 else {
00287 cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
00288 return 0;
00289 }
00290
00291 }
00292
00293
00294
00295
00296
00297 void L1MuDTPtaLut::setPrecision() {
00298
00299 nbit_phi = 12;
00300
00301 }