Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:17

0001 #include "L1Trigger/L1TMuonBarrel/interface/L1TMuonBarrelParamsHelper.h"
0002 
0003 void L1TMuonBarrelParamsHelper::print(std::ostream& out) const {
0004   out << "L1 BMTF Parameters" << std::endl;
0005 
0006   out << "Firmware version: " << fwVersion_ << std::endl;
0007 }
0008 
0009 L1TMuonBarrelParamsHelper::L1TMuonBarrelParamsHelper(const L1TMuonBarrelParams& barrelParams)
0010     : L1TMuonBarrelParams(
0011           barrelParams)  //: L1TMuonBarrelParams_PUBLIC(cast_to_L1TMuonBarrelParams_PUBLIC(barrelParams)) //: m_params_helper(barrelParams)
0012 {
0013   //    if (pnodes_.size() != 2)
0014   //        pnodes_.resize(2);
0015 }
0016 
0017 void L1TMuonBarrelParamsHelper::configFromPy(std::map<std::string, int>& allInts,
0018                                              std::map<std::string, bool>& allBools,
0019                                              std::map<std::string, std::vector<std::string> > allMasks,
0020                                              unsigned int fwVersion,
0021                                              const std::string& AssLUTpath) {
0022   set_PT_Assignment_nbits_Phi(allInts["PT_Assignment_nbits_Phi"]);
0023   set_PT_Assignment_nbits_PhiB(allInts["PT_Assignment_nbits_PhiB"]);
0024   set_PHI_Assignment_nbits_Phi(allInts["PHI_Assignment_nbits_Phi"]);
0025   set_PHI_Assignment_nbits_PhiB(allInts["PHI_Assignment_nbits_PhiB"]);
0026   set_Extrapolation_nbits_Phi(allInts["Extrapolation_nbits_Phi"]);
0027   set_Extrapolation_nbits_PhiB(allInts["Extrapolation_nbits_PhiB"]);
0028   set_BX_min(allInts["BX_min"]);
0029   set_BX_max(allInts["BX_max"]);
0030   set_Extrapolation_Filter(allInts["Extrapolation_Filter"]);
0031   set_OutOfTime_Filter_Window(allInts["OutOfTime_Filter_Window"]);
0032   set_OutOfTime_Filter(allBools["OutOfTime_Filter"]);
0033   set_Open_LUTs(allBools["Open_LUTs"]);
0034   set_EtaTrackFinder(allBools["EtaTrackFinder"]);
0035   set_Extrapolation_21(allBools["Extrapolation_21"]);
0036   setFwVersion(fwVersion);
0037   set_DisableNewAlgo(allBools["DisableNewAlgo"]);
0038 
0039   setAssLUTPath(AssLUTpath);
0040   ///Read Pt assignment Luts
0041   std::vector<LUT> pta_lut(0);
0042   pta_lut.reserve(19);
0043   std::vector<int> pta_threshold(10);
0044   if (load_pt(pta_lut, pta_threshold, allInts["PT_Assignment_nbits_Phi"], AssLUTpath) != 0) {
0045     cout << "Can not open files to load pt-assignment look-up tables for L1TMuonBarrelTrackProducer!" << endl;
0046   }
0047   setpta_lut(pta_lut);
0048   setpta_threshold(pta_threshold);
0049 
0050   ///Read Phi assignment Luts
0051   std::vector<LUT> phi_lut(0);
0052   phi_lut.reserve(2);
0053   if (load_phi(phi_lut, allInts["PHI_Assignment_nbits_Phi"], allInts["PHI_Assignment_nbits_PhiB"], AssLUTpath) != 0) {
0054     cout << "Can not open files to load phi-assignment look-up tables for L1TMuonBarrelTrackProducer!" << endl;
0055   }
0056   setphi_lut(phi_lut);
0057 
0058   l1mudttfparams.reset();  //KK
0059   l1mudttfqualplut
0060       .load();  //KK: Do these LUTs ever change and is it safe to initialize it from the release files like that?
0061   l1mudttfetaplut.load();  //KK
0062   // the data members of the Helper class loaded above are transient, push those to the persistent storage of the base class:
0063   lutparams_.eta_lut_ = l1mudttfetaplut.m_lut;
0064   lutparams_.qp_lut_ = l1mudttfqualplut.m_lut;
0065 
0066   for (int wh = -3; wh < 4; wh++) {
0067     int sec = 0;
0068     for (char& c : allMasks["mask_phtf_st1"].at(wh + 3)) {
0069       int mask = c - '0';
0070       l1mudttfmasks.set_inrec_chdis_st1(wh, sec, mask);
0071       sec++;
0072     }
0073     sec = 0;
0074     for (char& c : allMasks["mask_phtf_st2"].at(wh + 3)) {
0075       int mask = c - '0';
0076       l1mudttfmasks.set_inrec_chdis_st2(wh, sec, mask);
0077       sec++;
0078     }
0079     sec = 0;
0080     for (char& c : allMasks["mask_phtf_st3"].at(wh + 3)) {
0081       int mask = c - '0';
0082       l1mudttfmasks.set_inrec_chdis_st3(wh, sec, mask);
0083       sec++;
0084     }
0085     sec = 0;
0086     for (char& c : allMasks["mask_phtf_st4"].at(wh + 3)) {
0087       int mask = c - '0';
0088       l1mudttfmasks.set_inrec_chdis_st4(wh, sec, mask);
0089       sec++;
0090     }
0091     sec = 0;
0092     for (char& c : allMasks["mask_ettf_st1"].at(wh + 3)) {
0093       int mask = c - '0';
0094       l1mudttfmasks.set_etsoc_chdis_st1(wh, sec, mask);
0095       sec++;
0096     }
0097     sec = 0;
0098     for (char& c : allMasks["mask_ettf_st2"].at(wh + 3)) {
0099       int mask = c - '0';
0100       l1mudttfmasks.set_etsoc_chdis_st2(wh, sec, mask);
0101       sec++;
0102     }
0103     sec = 0;
0104     for (char& c : allMasks["mask_ettf_st3"].at(wh + 3)) {
0105       int mask = c - '0';
0106       l1mudttfmasks.set_etsoc_chdis_st3(wh, sec, mask);
0107       //Not used in BMTF - mask
0108       l1mudttfmasks.set_inrec_chdis_csc(wh, sec, true);
0109       sec++;
0110     }
0111   }
0112 
0113   ///Read Extrapolation Luts
0114   std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut(0);
0115   ext_lut.reserve(12);
0116   if (load_ext(ext_lut, allInts["PHI_Assignment_nbits_Phi"], allInts["PHI_Assignment_nbits_PhiB"]) != 0) {
0117     cout << "Can not open files to load extrapolation look-up tables for L1TMuonBarrelTrackProducer!" << endl;
0118   }
0119   setext_lut(ext_lut);
0120 
0121   //l1mudttfextlut.load();
0122 }
0123 
0124 void L1TMuonBarrelParamsHelper::configFromDB(l1t::TriggerSystem& trgSys) {
0125   std::map<std::string, std::string> procRole = trgSys.getProcToRoleAssignment();
0126 
0127   //Cleaning the default masking from the prototype
0128   l1mudttfmasks.reset();
0129 
0130   for (auto it_proc = procRole.begin(); it_proc != procRole.end(); it_proc++) {
0131     std::string procId = it_proc->first;
0132 
0133     std::map<std::string, l1t::Parameter> settings = trgSys.getParameters(procId.c_str());
0134 
0135     std::vector<std::string> paths = settings["regTable"].getTableColumn<std::string>("register_path");
0136     std::vector<unsigned int> vals = settings["regTable"].getTableColumn<unsigned int>("register_value");
0137     for (unsigned int row = 0; row < paths.size(); row++) {
0138       if (paths[row].find("open_lut") != std::string::npos) {
0139         //std::cout << "Value is: " << vals[row] << std::endl;
0140         set_Open_LUTs(vals[row]);
0141       }
0142       if (paths[row].find("sel_21") != std::string::npos) {
0143         //std::cout << "Value is: " << vals[row] << std::endl;
0144         set_Extrapolation_21(vals[row]);
0145       }
0146 
0147       if (paths[row].find("dis_newalgo") != std::string::npos) {
0148         //std::cout << "Value is: " << vals[row] << std::endl;
0149         //int fwv = (vals[row]==1) ? 1 : 2;
0150         //setFwVersion(fwv);
0151         bool disnewalgo = (vals[row] == 1);
0152         set_DisableNewAlgo(disnewalgo);
0153       }
0154 
0155       string masks[5] = {"mask_ctrl_N2", "mask_ctrl_N1", "mask_ctrl_0", "mask_ctrl_P1", "mask_ctrl_P2"};
0156 
0157       for (int m = 0; m < 5; m++) {
0158         if (paths[row].find(masks[m]) != std::string::npos) {
0159           ///Converts the last bit to int
0160           int mask = 0x1 & vals[row];
0161           int mask_all = vals[row];
0162           ///All bits must be the same
0163           if (!(mask_all == 0x111111 || mask_all == 0x222222 || mask_all == 0x333333 || mask_all == 0x444444 ||
0164                 mask_all == 0x555555 || mask_all == 0x666666 || mask_all == 0x777777))
0165             cerr << "BMTF: Cannot re-emulate properly. Individual link masking cannot be handled." << endl;
0166 
0167           if ((mask & 1) > 0) {
0168             for (int sec = 0; sec < 12; sec++) {
0169               if (masks[m] == "mask_ctrl_N2") {
0170                 l1mudttfmasks.set_inrec_chdis_st1(-3, sec, true);
0171                 //l1mudttfmasks.set_etsoc_chdis_st1(-3,sec,true);
0172               }
0173               if (masks[m] == "mask_ctrl_N1") {
0174                 l1mudttfmasks.set_inrec_chdis_st1(-2, sec, true);
0175                 //l1mudttfmasks.set_etsoc_chdis_st1(-2,sec,true);
0176               }
0177 
0178               if (masks[m] == "mask_ctrl_0") {
0179                 l1mudttfmasks.set_inrec_chdis_st1(-1, sec, true);
0180                 l1mudttfmasks.set_inrec_chdis_st1(1, sec, true);
0181                 //l1mudttfmasks.set_etsoc_chdis_st1(-1,sec,true);
0182                 //l1mudttfmasks.set_etsoc_chdis_st1(1,sec,true);
0183               }
0184               if (masks[m] == "mask_ctrl_P1") {
0185                 l1mudttfmasks.set_inrec_chdis_st1(2, sec, true);
0186                 //l1mudttfmasks.set_etsoc_chdis_st1(2,sec,true);
0187               }
0188               if (masks[m] == "mask_ctrl_P2") {
0189                 l1mudttfmasks.set_inrec_chdis_st1(3, sec, true);
0190                 //l1mudttfmasks.set_etsoc_chdis_st1(3,sec,true);
0191               }
0192             }
0193           }
0194 
0195           if ((mask & 2) > 0) {
0196             for (int sec = 0; sec < 12; sec++) {
0197               if (masks[m] == "mask_ctrl_N2") {
0198                 l1mudttfmasks.set_inrec_chdis_st2(-3, sec, true);
0199                 //l1mudttfmasks.set_etsoc_chdis_st2(-3,sec,true);
0200               }
0201               if (masks[m] == "mask_ctrl_N1") {
0202                 l1mudttfmasks.set_inrec_chdis_st2(-2, sec, true);
0203                 //l1mudttfmasks.set_etsoc_chdis_st2(-2,sec,true);
0204               }
0205 
0206               if (masks[m] == "mask_ctrl_0") {
0207                 l1mudttfmasks.set_inrec_chdis_st2(-1, sec, true);
0208                 l1mudttfmasks.set_inrec_chdis_st2(1, sec, true);
0209                 //l1mudttfmasks.set_etsoc_chdis_st2(-1,sec,true);
0210                 //l1mudttfmasks.set_etsoc_chdis_st2(1,sec,true);
0211               }
0212               if (masks[m] == "mask_ctrl_P1") {
0213                 l1mudttfmasks.set_inrec_chdis_st2(2, sec, true);
0214                 //l1mudttfmasks.set_etsoc_chdis_st2(2,sec,true);
0215               }
0216               if (masks[m] == "mask_ctrl_P2") {
0217                 l1mudttfmasks.set_inrec_chdis_st2(3, sec, true);
0218                 //l1mudttfmasks.set_etsoc_chdis_st2(3,sec,true);
0219               }
0220             }
0221           }
0222 
0223           if ((mask & 4) > 0) {
0224             for (int sec = 0; sec < 12; sec++) {
0225               if (masks[m] == "mask_ctrl_N2") {
0226                 l1mudttfmasks.set_inrec_chdis_st3(-3, sec, true);
0227                 //l1mudttfmasks.set_etsoc_chdis_st3(-3,sec,true);
0228               }
0229               if (masks[m] == "mask_ctrl_N1") {
0230                 l1mudttfmasks.set_inrec_chdis_st3(-2, sec, true);
0231                 //l1mudttfmasks.set_etsoc_chdis_st3(-2,sec,true);
0232               }
0233 
0234               if (masks[m] == "mask_ctrl_0") {
0235                 l1mudttfmasks.set_inrec_chdis_st3(-1, sec, true);
0236                 l1mudttfmasks.set_inrec_chdis_st3(1, sec, true);
0237                 //l1mudttfmasks.set_etsoc_chdis_st3(-1,sec,true);
0238                 //l1mudttfmasks.set_etsoc_chdis_st3(1,sec,true);
0239               }
0240               if (masks[m] == "mask_ctrl_P1") {
0241                 l1mudttfmasks.set_inrec_chdis_st3(2, sec, true);
0242                 //l1mudttfmasks.set_etsoc_chdis_st3(2,sec,true);
0243               }
0244               if (masks[m] == "mask_ctrl_P2") {
0245                 l1mudttfmasks.set_inrec_chdis_st3(3, sec, true);
0246                 //l1mudttfmasks.set_etsoc_chdis_st3(3,sec,true);
0247               }
0248             }
0249           }
0250 
0251           if ((mask & 8) > 0) {
0252             for (int sec = 0; sec < 12; sec++) {
0253               if (masks[m] == "mask_ctrl_N2") {
0254                 l1mudttfmasks.set_inrec_chdis_st4(-3, sec, true);
0255               }
0256               if (masks[m] == "mask_ctrl_N1") {
0257                 l1mudttfmasks.set_inrec_chdis_st4(-2, sec, true);
0258               }
0259 
0260               if (masks[m] == "mask_ctrl_0") {
0261                 l1mudttfmasks.set_inrec_chdis_st4(-1, sec, true);
0262                 l1mudttfmasks.set_inrec_chdis_st4(1, sec, true);
0263               }
0264               if (masks[m] == "mask_ctrl_P1") {
0265                 l1mudttfmasks.set_inrec_chdis_st4(2, sec, true);
0266               }
0267               if (masks[m] == "mask_ctrl_P2") {
0268                 l1mudttfmasks.set_inrec_chdis_st4(3, sec, true);
0269               }
0270             }
0271           }
0272         }  ///if register path
0273       }    ///for masks
0274     }      ///for it tRow
0275   }        ///for it procRole
0276 }  ///if configDB
0277 
0278 int L1TMuonBarrelParamsHelper::load_pt(std::vector<LUT>& pta_lut,
0279                                        std::vector<int>& pta_threshold,
0280                                        unsigned short int nbitphi,
0281                                        std::string AssLUTpath) {
0282   // maximal number of pt assignment methods
0283   const int MAX_PTASSMETH = 19;
0284   const int MAX_PTASSMETHA = 12;
0285 
0286   // pt assignment methods
0287   enum PtAssMethod {
0288     PT12L,
0289     PT12H,
0290     PT13L,
0291     PT13H,
0292     PT14L,
0293     PT14H,
0294     PT23L,
0295     PT23H,
0296     PT24L,
0297     PT24H,
0298     PT34L,
0299     PT34H,
0300     PB12H,
0301     PB13H,
0302     PB14H,
0303     PB21H,
0304     PB23H,
0305     PB24H,
0306     PB34H,
0307     NODEF
0308   };
0309 
0310   // get directory name
0311   string pta_str = "";
0312   // precision : in the look-up tables the following precision is used :
0313   // phi ...12 bits (address) and  pt ...5 bits
0314   // now convert phi and phib to the required precision
0315   int nbit_phi = nbitphi;
0316   int sh_phi = 12 - nbit_phi;
0317 
0318   // loop over all pt-assignment methods
0319   for (int pam = 0; pam < MAX_PTASSMETH; pam++) {
0320     switch (pam) {
0321       case PT12L: {
0322         pta_str = "pta12l";
0323         break;
0324       }
0325       case PT12H: {
0326         pta_str = "pta12h";
0327         break;
0328       }
0329       case PT13L: {
0330         pta_str = "pta13l";
0331         break;
0332       }
0333       case PT13H: {
0334         pta_str = "pta13h";
0335         break;
0336       }
0337       case PT14L: {
0338         pta_str = "pta14l";
0339         break;
0340       }
0341       case PT14H: {
0342         pta_str = "pta14h";
0343         break;
0344       }
0345       case PT23L: {
0346         pta_str = "pta23l";
0347         break;
0348       }
0349       case PT23H: {
0350         pta_str = "pta23h";
0351         break;
0352       }
0353       case PT24L: {
0354         pta_str = "pta24l";
0355         break;
0356       }
0357       case PT24H: {
0358         pta_str = "pta24h";
0359         break;
0360       }
0361       case PT34L: {
0362         pta_str = "pta34l";
0363         break;
0364       }
0365       case PT34H: {
0366         pta_str = "pta34h";
0367         break;
0368       }
0369       case PB12H: {
0370         pta_str = "ptb12h_Feb2016";
0371         break;
0372       }
0373       case PB13H: {
0374         pta_str = "ptb13h_Feb2016";
0375         break;
0376       }
0377       case PB14H: {
0378         pta_str = "ptb14h_Feb2016";
0379         break;
0380       }
0381       case PB21H: {
0382         pta_str = "ptb21h_Feb2016";
0383         break;
0384       }
0385       case PB23H: {
0386         pta_str = "ptb23h_Feb2016";
0387         break;
0388       }
0389       case PB24H: {
0390         pta_str = "ptb24h_Feb2016";
0391         break;
0392       }
0393       case PB34H: {
0394         pta_str = "ptb34h_Feb2016";
0395         break;
0396       }
0397     }
0398 
0399     // assemble file name
0400     const string& lutpath = AssLUTpath;
0401     edm::FileInPath lut_f = edm::FileInPath(string(lutpath + pta_str + ".lut"));
0402     string pta_file = lut_f.fullPath();
0403 
0404     // open file
0405     L1TriggerLutFile file(pta_file);
0406     if (file.open() != 0)
0407       return -1;
0408 
0409     // get the right shift factor
0410     int shift = sh_phi;
0411     int adr_old = -2048 >> shift;
0412     if (pam >= MAX_PTASSMETHA)
0413       adr_old = -512 >> shift;
0414 
0415     LUT tmplut;
0416 
0417     int number = -1;
0418     int sum_pt = 0;
0419 
0420     if (file.good()) {
0421       int threshold = file.readInteger();
0422       pta_threshold[pam / 2] = threshold;
0423     }
0424 
0425     // read values and shift to correct precision
0426     while (file.good()) {
0427       int adr = (file.readInteger()) >> shift;
0428       int pt = file.readInteger();
0429 
0430       number++;
0431       //cout<<pam<<"    "<<number<<"   "<<MAX_PTASSMETHA<<endl;
0432       if (adr != adr_old) {
0433         assert(number);
0434         tmplut.insert(make_pair(adr_old, (sum_pt / number)));
0435 
0436         adr_old = adr;
0437         number = 0;
0438         sum_pt = 0;
0439       }
0440 
0441       sum_pt += pt;
0442 
0443       if (!file.good())
0444         file.close();
0445     }
0446 
0447     file.close();
0448     pta_lut.push_back(tmplut);
0449   }
0450   return 0;
0451 }
0452 
0453 int L1TMuonBarrelParamsHelper::load_phi(std::vector<LUT>& phi_lut,
0454                                         unsigned short int nbit_phi,
0455                                         unsigned short int nbit_phib,
0456                                         std::string AssLUTpath) {
0457   // precision : in the look-up tables the following precision is used :
0458   // address (phib) ...10 bits, phi ... 12 bits
0459 
0460   int sh_phi = 12 - nbit_phi;
0461   int sh_phib = 10 - nbit_phib;
0462 
0463   string phi_str;
0464   // loop over all phi-assignment methods
0465   for (int idx = 0; idx < 2; idx++) {
0466     switch (idx) {
0467       case 0: {
0468         phi_str = "phi12";
0469         break;
0470       }
0471       case 1: {
0472         phi_str = "phi42";
0473         break;
0474       }
0475     }
0476 
0477     // assemble file name
0478     edm::FileInPath lut_f = edm::FileInPath(string(AssLUTpath + phi_str + ".lut"));
0479     string phi_file = lut_f.fullPath();
0480 
0481     // open file
0482     L1TriggerLutFile file(phi_file);
0483     if (file.open() != 0)
0484       return -1;
0485 
0486     LUT tmplut;
0487 
0488     int number = -1;
0489     int adr_old = -512 >> sh_phib;
0490     int sum_phi = 0;
0491 
0492     // read values
0493     while (file.good()) {
0494       int adr = (file.readInteger()) >> sh_phib;
0495       int phi = file.readInteger();
0496 
0497       number++;
0498 
0499       if (adr != adr_old) {
0500         assert(number);
0501         tmplut.insert(make_pair(adr_old, ((sum_phi / number) >> sh_phi)));
0502 
0503         adr_old = adr;
0504         number = 0;
0505         sum_phi = 0;
0506       }
0507 
0508       sum_phi += phi;
0509 
0510       if (!file.good())
0511         file.close();
0512     }
0513 
0514     file.close();
0515     phi_lut.push_back(tmplut);
0516   }
0517   return 0;
0518 }
0519 
0520 /*
0521 int L1TMuonBarrelParamsESProducer::getPtLutThreshold(int pta_ind, std::vector<int>& pta_threshold) const {
0522 
0523   if ( pta_ind >= 0 && pta_ind < 13/2 ) {
0524     return pta_threshold[pta_ind];
0525   }
0526   else {
0527     cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
0528     return 0;
0529   }
0530 
0531 }
0532 
0533 */
0534 
0535 //
0536 // load extrapolation look-up tables
0537 //
0538 int L1TMuonBarrelParamsHelper::load_ext(std::vector<L1TMuonBarrelParams::LUTParams::extLUT>& ext_lut,
0539                                         unsigned short int nbit_phi,
0540                                         unsigned short int nbit_phib) {
0541   //max. number of Extrapolations
0542   const int MAX_EXT = 12;
0543 
0544   // extrapolation types
0545   enum Extrapolation { EX12, EX13, EX14, EX21, EX23, EX24, EX34, EX15, EX16, EX25, EX26, EX56 };
0546 
0547   // get directory name
0548   string defaultPath = "L1Trigger/L1TMuon/data/bmtf_luts/";
0549   string ext_dir = "LUTs_Ext/";
0550   string ext_str = "";
0551 
0552   // precision : in the look-up tables the following precision is used :
0553   // phi ...12 bits (low, high), phib ...10 bits (address)
0554   // now convert phi and phib to the required precision
0555 
0556   int sh_phi = 12 - nbit_phi;
0557   int sh_phib = 10 - nbit_phib;
0558 
0559   // loop over all extrapolations
0560   for (int ext = 0; ext < MAX_EXT; ext++) {
0561     switch (ext) {
0562       case EX12:
0563         ext_str = "ext12";
0564         break;
0565       case EX13:
0566         ext_str = "ext13";
0567         break;
0568       case EX14:
0569         ext_str = "ext14";
0570         break;
0571       case EX21:
0572         ext_str = "ext21";
0573         break;
0574       case EX23:
0575         ext_str = "ext23";
0576         break;
0577       case EX24:
0578         ext_str = "ext24";
0579         break;
0580       case EX34:
0581         ext_str = "ext34";
0582         break;
0583       case EX15:
0584         ext_str = "ext15";
0585         break;
0586       case EX16:
0587         ext_str = "ext16";
0588         break;
0589       case EX25:
0590         ext_str = "ext25";
0591         break;
0592       case EX26:
0593         ext_str = "ext26";
0594         break;
0595       case EX56:
0596         ext_str = "ext56";
0597         break;
0598     }
0599 
0600     // assemble file name
0601     edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + ext_dir + ext_str + ".lut"));
0602     string ext_file = lut_f.fullPath();
0603 
0604     // open file
0605     L1TriggerLutFile file(ext_file);
0606     if (file.open() != 0)
0607       return -1;
0608     //    if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
0609     //                                         << file.getName() << endl;
0610 
0611     L1TMuonBarrelParams::LUTParams::extLUT tmplut;
0612 
0613     int number = -1;
0614     int adr_old = -512 >> sh_phib;
0615     int sum_low = 0;
0616     int sum_high = 0;
0617 
0618     // read values and shift to correct precision
0619     while (file.good()) {
0620       int adr = (file.readInteger()) >> sh_phib;  // address (phib)
0621       int low = (file.readInteger());             // low value (phi)
0622       int high = (file.readInteger());            // high value (phi)
0623 
0624       number++;
0625 
0626       if (adr != adr_old) {
0627         tmplut.low[adr_old] = sum_low >> sh_phi;
0628         tmplut.high[adr_old] = sum_high >> sh_phi;
0629 
0630         adr_old = adr;
0631         number = 0;
0632         sum_low = 0;
0633         sum_high = 0;
0634       }
0635 
0636       if (number == 0)
0637         sum_low = low;
0638       if (number == 0)
0639         sum_high = high;
0640 
0641       if (!file.good())
0642         file.close();
0643     }
0644 
0645     file.close();
0646     ext_lut.push_back(tmplut);
0647   }
0648   return 0;
0649 }