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 assert(number);
00184 tmplut.insert(make_pair( adr_old, (sum_pt/number) ));
00185
00186 adr_old = adr;
00187 number = 0;
00188 sum_pt = 0;
00189 }
00190
00191 sum_pt += pt;
00192
00193 if ( !file.good() ) file.close();
00194
00195 }
00196
00197 file.close();
00198 pta_lut.push_back(tmplut);
00199 }
00200 return 0;
00201
00202 }
00203
00204
00205
00206
00207
00208 void L1MuDTPtaLut::print() const {
00209
00210 cout << endl;
00211 cout << "L1 barrel Track Finder Pt-Assignment look-up tables :" << endl;
00212 cout << "=====================================================" << endl;
00213 cout << endl;
00214 cout << "Precision : " << endl;
00215 cout << '\t' << setw(2) << nbit_phi << " bits are used for phi " << endl;
00216
00217
00218 for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) {
00219
00220 cout << endl;
00221 cout << "Pt-Assignment Method : " << static_cast<PtAssMethod>(pam) << endl;
00222 cout << "============================" << endl;
00223 cout << endl;
00224
00225 cout << "\t Threshold : " << getPtLutThreshold(pam/2) << endl << endl;
00226
00227 int maxbits = nbit_phi;
00228
00229 cout << " address";
00230 for ( int i = 0; i < maxbits; i++ ) cout << ' ';
00231 cout << " value" << endl;
00232 for ( int i = 0; i < maxbits; i++ ) cout << '-';
00233 cout << "-------------------------" << endl;
00234
00235 LUT::const_iterator iter = pta_lut[pam].begin();
00236 while ( iter != pta_lut[pam].end() ) {
00237 int address = (*iter).first;
00238 int value = (*iter).second;
00239
00240 DTTFBitArray<12> b_address(static_cast<unsigned>(abs(address)));
00241 DTTFBitArray<5> b_value(static_cast<unsigned>(abs(value)));
00242
00243 if ( address < 0 ) b_address.twoComplement();
00244
00245 cout.setf(ios::right,ios::adjustfield);
00246 cout << " " << setbase(10) << setw(5) << address << " (";
00247 for ( int i = maxbits-1; i >= 0; i-- ) cout << b_address[i];
00248 cout << ") " << setw(3) << value << " (";
00249 b_value.print();
00250 cout << ")" << endl;
00251
00252 iter++;
00253 }
00254
00255 }
00256
00257 cout << endl;
00258
00259 }
00260
00261
00262
00263
00264
00265 int L1MuDTPtaLut::getPt(int pta_ind, int address) const {
00266
00267 LUT::const_iterator iter = pta_lut[pta_ind].find(address);
00268 if ( iter != pta_lut[pta_ind].end() ) {
00269 return (*iter).second;
00270 }
00271 else {
00272 cerr << "PtaLut::getPt : can not find address " << address << endl;
00273 return 0;
00274 }
00275
00276 }
00277
00278
00279
00280
00281
00282 int L1MuDTPtaLut::getPtLutThreshold(int pta_ind) const {
00283
00284 if ( pta_ind >= 0 && pta_ind < MAX_PTASSMETH/2 ) {
00285 return pta_threshold[pta_ind];
00286 }
00287 else {
00288 cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
00289 return 0;
00290 }
00291
00292 }
00293
00294
00295
00296
00297
00298 void L1MuDTPtaLut::setPrecision() {
00299
00300 nbit_phi = 12;
00301
00302 }