CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TMuonBarrelParamsESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: L1TMuonBarrelParamsESProducer
4 //
5 // Original Author: Giannis Flouris
6 // Created:
7 //
8 //
9 
10 
11 // system include files
12 #include <memory>
13 #include "boost/shared_ptr.hpp"
14 
15 // user include files
20 
24 
28 
33 
35 
36 // class declaration
37 //
38 typedef std::map<short, short, std::less<short> > LUT;
39 
41  public:
44  int load_pt(std::vector<LUT>& , std::vector<int>&, unsigned short int, std::string);
45  int load_phi(std::vector<LUT>& , unsigned short int, unsigned short int, std::string);
46  int load_ext(std::vector<L1TMuonBarrelParams::LUTParams::extLUT>&, unsigned short int, unsigned short int );
47  //void print(std::vector<LUT>& , std::vector<int>& ) const;
48  typedef boost::shared_ptr<L1TMuonBarrelParams> ReturnType;
49 
51  private:
52  //L1TMuonBarrelParams m_params;
54 };
55 
56 //
57 // constants, enums and typedefs
58 //
59 
60 //
61 // static data member definitions
62 //
63 
64 //
65 // constructors and destructor
66 //
68 {
70  //the following line is needed to tell the framework what
71  // data is being produced
72  setWhatProduced(this);
73  // Firmware version
74  unsigned fwVersion = iConfig.getParameter<unsigned>("fwVersion");
75  std::string AssLUTpath = iConfig.getParameter<std::string>("AssLUTPath");
76  //m_params.setAssLUTPath(AssLUTpath);
77 
78  // int PT_Assignment_nbits_Phi = iConfig.getParameter<int>("PT_Assignment_nbits_Phi");
79  // int PT_Assignment_nbits_PhiB = iConfig.getParameter<int>("PT_Assignment_nbits_PhiB");
80  // int PHI_Assignment_nbits_Phi = iConfig.getParameter<int>("PHI_Assignment_nbits_Phi");
81  // int PHI_Assignment_nbits_PhiB = iConfig.getParameter<int>("PHI_Assignment_nbits_PhiB");
82  // int Extrapolation_nbits_Phi = iConfig.getParameter<int>("Extrapolation_nbits_Phi");
83  // int Extrapolation_nbits_PhiB = iConfig.getParameter<int>("Extrapolation_nbits_PhiB");
84  // int BX_min = iConfig.getParameter<int>("BX_min");
85  // int BX_max = iConfig.getParameter<int>("BX_max");
86  // int Extrapolation_Filter = iConfig.getParameter<int>("Extrapolation_Filter");
87  // int OutOfTime_Filter_Window = iConfig.getParameter<int>("OutOfTime_Filter_Window");
88  // bool OutOfTime_Filter = iConfig.getParameter<bool>("OutOfTime_Filter");
89  // bool Open_LUTs = iConfig.getParameter<bool>("Open_LUTs");
90  // bool EtaTrackFinder = iConfig.getParameter<bool>("EtaTrackFinder");
91  // bool Extrapolation_21 = iConfig.getParameter<bool>("Extrapolation_21");
92  bool configFromXML = iConfig.getParameter<bool>("configFromXML");
93  // bool DisableNewAlgo = iConfig.getParameter<bool>("DisableNewAlgo");
94 
95  std::map<std::string, int> allInts;
96  std::map<std::string, bool> allBools;
97  std::map<std::string, std::vector<std::string> > allMasks;
98 
99  allInts["PT_Assignment_nbits_Phi"] = iConfig.getParameter<int>("PT_Assignment_nbits_Phi");
100  allInts["PT_Assignment_nbits_PhiB"] = iConfig.getParameter<int>("PT_Assignment_nbits_PhiB");
101  allInts["PHI_Assignment_nbits_Phi"] = iConfig.getParameter<int>("PHI_Assignment_nbits_Phi");
102  allInts["PHI_Assignment_nbits_PhiB"] = iConfig.getParameter<int>("PHI_Assignment_nbits_PhiB");
103  allInts["Extrapolation_nbits_Phi"] = iConfig.getParameter<int>("Extrapolation_nbits_Phi");
104  allInts["Extrapolation_nbits_PhiB"] = iConfig.getParameter<int>("Extrapolation_nbits_PhiB");
105  allInts["BX_min"] = iConfig.getParameter<int>("BX_min");
106  allInts["BX_max"] = iConfig.getParameter<int>("BX_max");
107  allInts["Extrapolation_Filter"] = iConfig.getParameter<int>("Extrapolation_Filter");
108  allInts["OutOfTime_Filter_Window"] = iConfig.getParameter<int>("OutOfTime_Filter_Window");
109  allBools["OutOfTime_Filter"] = iConfig.getParameter<bool>("OutOfTime_Filter");
110  allBools["Open_LUTs"] = iConfig.getParameter<bool>("Open_LUTs");
111  allBools["EtaTrackFinder"] = iConfig.getParameter<bool>("EtaTrackFinder");
112  allBools["Extrapolation_21"] = iConfig.getParameter<bool>("Extrapolation_21");
113  allBools["configFromXML"] = iConfig.getParameter<bool>("configFromXML");
114  allBools["DisableNewAlgo"] = iConfig.getParameter<bool>("DisableNewAlgo");
115 
116  allMasks["mask_phtf_st1"] = iConfig.getParameter< std::vector <string> >("mask_phtf_st1");
117  allMasks["mask_phtf_st2"] = iConfig.getParameter< std::vector <string> >("mask_phtf_st2");
118  allMasks["mask_phtf_st3"] = iConfig.getParameter< std::vector <string> >("mask_phtf_st3");
119  allMasks["mask_phtf_st4"] = iConfig.getParameter< std::vector <string> >("mask_phtf_st4");
120 
121  allMasks["mask_ettf_st1"] = iConfig.getParameter< std::vector <string> >("mask_ettf_st1");
122  allMasks["mask_ettf_st2"] = iConfig.getParameter< std::vector <string> >("mask_ettf_st2");
123  allMasks["mask_ettf_st3"] = iConfig.getParameter< std::vector <string> >("mask_ettf_st3");
124 
125 /*
126  m_params.set_PT_Assignment_nbits_Phi(PT_Assignment_nbits_Phi);
127  m_params.set_PT_Assignment_nbits_PhiB(PT_Assignment_nbits_PhiB);
128  m_params.set_PHI_Assignment_nbits_Phi(PHI_Assignment_nbits_Phi);
129  m_params.set_PHI_Assignment_nbits_PhiB(PHI_Assignment_nbits_PhiB);
130  m_params.set_Extrapolation_nbits_Phi(Extrapolation_nbits_Phi);
131  m_params.set_Extrapolation_nbits_PhiB(Extrapolation_nbits_PhiB);
132  m_params.set_BX_min(BX_min);
133  m_params.set_BX_max(BX_max);
134  m_params.set_Extrapolation_Filter(Extrapolation_Filter);
135  m_params.set_OutOfTime_Filter_Window(OutOfTime_Filter_Window);
136  m_params.set_OutOfTime_Filter(OutOfTime_Filter);
137  m_params.set_Open_LUTs(Open_LUTs);
138  m_params.set_EtaTrackFinder(EtaTrackFinder);
139  m_params.set_Extrapolation_21(Extrapolation_21);
140  m_params.setFwVersion(fwVersion);
141  m_params.set_DisableNewAlgo(DisableNewAlgo);
142 
143 
145  std::vector<LUT> pta_lut(0); pta_lut.reserve(19);
146  std::vector<int> pta_threshold(6); pta_threshold.reserve(9);
147  if ( load_pt(pta_lut,pta_threshold, PT_Assignment_nbits_Phi, AssLUTpath) != 0 ) {
148  cout << "Can not open files to load pt-assignment look-up tables for L1TMuonBarrelTrackProducer!" << endl;
149  }
150  m_params.setpta_lut(pta_lut);
151  m_params.setpta_threshold(pta_threshold);
152 
154  std::vector<LUT> phi_lut(0); phi_lut.reserve(2);
155  if ( load_phi(phi_lut, PHI_Assignment_nbits_Phi, PHI_Assignment_nbits_PhiB, AssLUTpath) != 0 ) {
156  cout << "Can not open files to load phi-assignment look-up tables for L1TMuonBarrelTrackProducer!" << endl;
157  }
158  m_params.setphi_lut(phi_lut);
159 
160 
161 
162 
163  m_params.l1mudttfparams.reset();
164 
165  std::vector <std::string> mask_phtf_st1 = iConfig.getParameter< std::vector <string> >("mask_phtf_st1");
166  std::vector <std::string> mask_phtf_st2 = iConfig.getParameter< std::vector <string> >("mask_phtf_st2");
167  std::vector <std::string> mask_phtf_st3 = iConfig.getParameter< std::vector <string> >("mask_phtf_st3");
168  std::vector <std::string> mask_phtf_st4 = iConfig.getParameter< std::vector <string> >("mask_phtf_st4");
169 
170  std::vector <std::string> mask_ettf_st1 = iConfig.getParameter< std::vector <string> >("mask_ettf_st1");
171  std::vector <std::string> mask_ettf_st2 = iConfig.getParameter< std::vector <string> >("mask_ettf_st2");
172  std::vector <std::string> mask_ettf_st3 = iConfig.getParameter< std::vector <string> >("mask_ettf_st3");
173 
174  for( int wh=-3; wh<4; wh++ ) {
175  int sec = 0;
176  for(char& c : mask_phtf_st1[wh+3]) {
177  int mask = c - '0';
178  m_params.l1mudttfmasks.set_inrec_chdis_st1(wh,sec,mask);
179  sec++;
180  }
181  sec = 0;
182  for(char& c : mask_phtf_st2[wh+3]) {
183  int mask = c - '0';
184  m_params.l1mudttfmasks.set_inrec_chdis_st2(wh,sec,mask);
185  sec++;
186  }
187  sec = 0;
188  for(char& c : mask_phtf_st3[wh+3]) {
189  int mask = c - '0';
190  m_params.l1mudttfmasks.set_inrec_chdis_st3(wh,sec,mask);
191  sec++;
192  }
193  sec = 0;
194  for(char& c : mask_phtf_st4[wh+3]) {
195  int mask = c - '0';
196  m_params.l1mudttfmasks.set_inrec_chdis_st4(wh,sec,mask);
197  sec++;
198  }
199  sec = 0;
200  for(char& c : mask_ettf_st1[wh+3]) {
201  int mask = c - '0';
202  m_params.l1mudttfmasks.set_etsoc_chdis_st1(wh,sec,mask);
203  sec++;
204  }
205  sec = 0;
206  for(char& c : mask_ettf_st2[wh+3]) {
207  int mask = c - '0';
208  m_params.l1mudttfmasks.set_etsoc_chdis_st2(wh,sec,mask);
209  sec++;
210  }
211  sec = 0;
212  for(char& c : mask_ettf_st3[wh+3]) {
213  int mask = c - '0';
214  m_params.l1mudttfmasks.set_etsoc_chdis_st3(wh,sec,mask);
215  //Not used in BMTF - mask
216  m_params.l1mudttfmasks.set_inrec_chdis_csc(wh,sec,true);
217  sec++;
218  }
219 
220  }
221 
222 
224  std::vector<L1TMuonBarrelParams::LUTParams::extLUT> ext_lut(0); ext_lut.reserve(12);
225  if ( load_ext(ext_lut, PHI_Assignment_nbits_Phi, PHI_Assignment_nbits_PhiB) != 0 ) {
226  cout << "Can not open files to load extrapolation look-up tables for L1TMuonBarrelTrackProducer!" << endl;
227  }
228  m_params.setext_lut(ext_lut);
229 
230  //m_params.l1mudttfextlut.load();
231 
232  */
233 
234  m_params_helper.configFromPy(allInts, allBools, allMasks, fwVersion, AssLUTpath);
235  if(configFromXML){
236  cout<<"Configuring BMTF Emulator from xml files.\n";
237  edm::FileInPath hwXmlFile(iConfig.getParameter<std::string>("hwXmlFile"));
238  edm::FileInPath topCfgXmlFile(iConfig.getParameter<std::string>("topCfgXmlFile"));
239  std::string xmlCfgKey = iConfig.getParameter<std::string>("xmlCfgKey");
240 
241  l1t::TrigSystem trgSys;
242  trgSys.configureSystemFromFiles(hwXmlFile.fullPath(),topCfgXmlFile.fullPath(),xmlCfgKey);
243 
244  /* std::map<std::string, std::string> procRole = trgSys.getProcRole();
245 
246  for(auto it_proc=procRole.begin(); it_proc!=procRole.end(); it_proc++ ){
247 
248  std::string procId = it_proc->first;
249 
250  std::map<std::string, l1t::Setting> settings = trgSys.getSettings(procId);
251  std::vector<l1t::TableRow> tRow = settings["regTable"].getTableRows();
252  for(auto it=tRow.begin(); it!=tRow.end(); it++)
253  {
254  if (it->getRowValue<std::string>("register_path").find("open_lut") != std::string::npos){
255  //std::cout << "Value is: " << it->getRowValue<bool>("register_value") << std::endl;
256  m_params.set_Open_LUTs(it->getRowValue<bool>("register_value"));
257  }
258  if (it->getRowValue<std::string>("register_path").find("sel_21") != std::string::npos){
259  //std::cout << "Value is: " << it->getRowValue<bool>("register_value") << std::endl;
260  m_params.set_Extrapolation_21(it->getRowValue<bool>("register_value"));
261  }
262 
263  if (it->getRowValue<std::string>("register_path").find("dis_newalgo") != std::string::npos){
264  //std::cout << "Value is: " << it->getRowValue<int>("register_value") << std::endl;
265  //int fwv = (it->getRowValue<int>("register_value")==1) ? 1 : 2;
266  //m_params.setFwVersion(fwv);
267  bool disnewalgo = (it->getRowValue<int>("register_value")==1);
268  m_params.set_DisableNewAlgo(disnewalgo);
269  }
270 
271  string masks[5] = {"mask_ctrl_N2", "mask_ctrl_N1", "mask_ctrl_0", "mask_ctrl_P1", "mask_ctrl_P2"};
272 
273  for(int m=0; m<5; m++){
274 
275  if (it->getRowValue<std::string>("register_path").find(masks[m]) != std::string::npos){
276  string mask_ctrl = it->getRowValue<string>("register_value");
277  const char *hexstring = mask_ctrl.c_str();
279  int mask = (int)strtol((hexstring+7), NULL, 16);
280  int mask_all = (int)strtol((hexstring), NULL, 16);
282  if(!( mask_all==0x111111 || mask_all==0x222222 || mask_all==0x333333 || mask_all==0x444444 ||
283  mask_all==0x555555 || mask_all==0x666666 || mask_all==0x777777) )
284  cerr<<"BMTF: Cannot re-emulate properly. Individual link masking cannot be handled."<<endl;
285 
286  if((mask&1)>0) {
287  for(int sec=0; sec<12; sec++){
288  if(masks[m]=="mask_ctrl_N2"){
289  m_params.l1mudttfmasks.set_inrec_chdis_st1(-3,sec,true);
290  m_params.l1mudttfmasks.set_etsoc_chdis_st1(-3,sec,true);
291  }
292  if(masks[m]=="mask_ctrl_N1"){
293  m_params.l1mudttfmasks.set_inrec_chdis_st1(-2,sec,true);
294  m_params.l1mudttfmasks.set_etsoc_chdis_st1(-2,sec,true);
295  }
296 
297  if(masks[m]=="mask_ctrl_0"){
298  m_params.l1mudttfmasks.set_inrec_chdis_st1(-1,sec,true);
299  m_params.l1mudttfmasks.set_inrec_chdis_st1(1,sec,true);
300  m_params.l1mudttfmasks.set_etsoc_chdis_st1(-1,sec,true);
301  m_params.l1mudttfmasks.set_etsoc_chdis_st1(1,sec,true);
302  }
303  if(masks[m]=="mask_ctrl_P1"){
304  m_params.l1mudttfmasks.set_inrec_chdis_st1(2,sec,true);
305  m_params.l1mudttfmasks.set_etsoc_chdis_st1(2,sec,true);
306  }
307  if(masks[m]=="mask_ctrl_P2"){
308  m_params.l1mudttfmasks.set_inrec_chdis_st1(3,sec,true);
309  m_params.l1mudttfmasks.set_etsoc_chdis_st1(3,sec,true);
310  }
311  }
312 
313  }
314 
315  if((mask&2)>0) {
316  for(int sec=0; sec<12; sec++){
317  if(masks[m]=="mask_ctrl_N2"){
318  m_params.l1mudttfmasks.set_inrec_chdis_st2(-3,sec,true);
319  m_params.l1mudttfmasks.set_etsoc_chdis_st2(-3,sec,true);
320  }
321  if(masks[m]=="mask_ctrl_N1"){
322  m_params.l1mudttfmasks.set_inrec_chdis_st2(-2,sec,true);
323  m_params.l1mudttfmasks.set_etsoc_chdis_st2(-2,sec,true);
324  }
325 
326  if(masks[m]=="mask_ctrl_0"){
327  m_params.l1mudttfmasks.set_inrec_chdis_st2(-1,sec,true);
328  m_params.l1mudttfmasks.set_inrec_chdis_st2(1,sec,true);
329  m_params.l1mudttfmasks.set_etsoc_chdis_st2(-1,sec,true);
330  m_params.l1mudttfmasks.set_etsoc_chdis_st2(1,sec,true);
331  }
332  if(masks[m]=="mask_ctrl_P1"){
333  m_params.l1mudttfmasks.set_inrec_chdis_st2(2,sec,true);
334  m_params.l1mudttfmasks.set_etsoc_chdis_st2(2,sec,true);
335  }
336  if(masks[m]=="mask_ctrl_P2"){
337  m_params.l1mudttfmasks.set_inrec_chdis_st2(3,sec,true);
338  m_params.l1mudttfmasks.set_etsoc_chdis_st2(3,sec,true);
339  }
340  }
341  }
342 
343  if((mask&4)>0) {
344  for(int sec=0; sec<12; sec++){
345  if(masks[m]=="mask_ctrl_N2"){
346  m_params.l1mudttfmasks.set_inrec_chdis_st3(-3,sec,true);
347  m_params.l1mudttfmasks.set_etsoc_chdis_st3(-3,sec,true);
348  }
349  if(masks[m]=="mask_ctrl_N1"){
350  m_params.l1mudttfmasks.set_inrec_chdis_st3(-2,sec,true);
351  m_params.l1mudttfmasks.set_etsoc_chdis_st3(-2,sec,true);
352  }
353 
354  if(masks[m]=="mask_ctrl_0"){
355  m_params.l1mudttfmasks.set_inrec_chdis_st3(-1,sec,true);
356  m_params.l1mudttfmasks.set_inrec_chdis_st3(1,sec,true);
357  m_params.l1mudttfmasks.set_etsoc_chdis_st3(-1,sec,true);
358  m_params.l1mudttfmasks.set_etsoc_chdis_st3(1,sec,true);
359  }
360  if(masks[m]=="mask_ctrl_P1"){
361  m_params.l1mudttfmasks.set_inrec_chdis_st3(2,sec,true);
362  m_params.l1mudttfmasks.set_etsoc_chdis_st3(2,sec,true);
363  }
364  if(masks[m]=="mask_ctrl_P2"){
365  m_params.l1mudttfmasks.set_inrec_chdis_st3(3,sec,true);
366  m_params.l1mudttfmasks.set_etsoc_chdis_st3(3,sec,true);
367  }
368  }
369  }
370 
371  if((mask&8)>0) {
372  for(int sec=0; sec<12; sec++){
373  if(masks[m]=="mask_ctrl_N2"){
374  m_params.l1mudttfmasks.set_inrec_chdis_st4(-3,sec,true);
375  }
376  if(masks[m]=="mask_ctrl_N1"){
377  m_params.l1mudttfmasks.set_inrec_chdis_st4(-2,sec,true);
378  }
379 
380  if(masks[m]=="mask_ctrl_0"){
381  m_params.l1mudttfmasks.set_inrec_chdis_st4(-1,sec,true);
382  m_params.l1mudttfmasks.set_inrec_chdis_st4(1,sec,true);
383  }
384  if(masks[m]=="mask_ctrl_P1"){
385  m_params.l1mudttfmasks.set_inrec_chdis_st4(2,sec,true);
386  }
387  if(masks[m]=="mask_ctrl_P2"){
388  m_params.l1mudttfmasks.set_inrec_chdis_st4(3,sec,true);
389  }
390  }
391  }
392  }///if register path
393  }///for masks
394  }///for it tRow
395  }///for it procRole */
397  }
398  //m_params = cast_to_L1TMuonBarrelParams((L1TMuonBarrelParams_PUBLIC)m_params_helper);
399 
400 
401 }
402 
403 
405 {
406 
407 }
408 
409 /*int L1TMuonBarrelParamsESProducer::load_pt(std::vector<LUT>& pta_lut,
410  std::vector<int>& pta_threshold,
411  unsigned short int nbitphi,
412  std::string AssLUTpath
413  ){
414 
415 
416 // maximal number of pt assignment methods
417 const int MAX_PTASSMETH = 19;
418 const int MAX_PTASSMETHA = 12;
419 
420 // pt assignment methods
421 enum PtAssMethod { PT12L, PT12H, PT13L, PT13H, PT14L, PT14H,
422  PT23L, PT23H, PT24L, PT24H, PT34L, PT34H,
423  PB12H, PB13H, PB14H, PB21H, PB23H, PB24H, PB34H,
424  NODEF };
425 
426  // get directory name
427  string pta_str = "";
428  // precision : in the look-up tables the following precision is used :
429  // phi ...12 bits (address) and pt ...5 bits
430  // now convert phi and phib to the required precision
431  int nbit_phi = nbitphi;
432  int sh_phi = 12 - nbit_phi;
433 
434  // loop over all pt-assignment methods
435  for ( int pam = 0; pam < MAX_PTASSMETH; pam++ ) {
436  switch ( pam ) {
437  case PT12L : { pta_str = "pta12l"; break; }
438  case PT12H : { pta_str = "pta12h"; break; }
439  case PT13L : { pta_str = "pta13l"; break; }
440  case PT13H : { pta_str = "pta13h"; break; }
441  case PT14L : { pta_str = "pta14l"; break; }
442  case PT14H : { pta_str = "pta14h"; break; }
443  case PT23L : { pta_str = "pta23l"; break; }
444  case PT23H : { pta_str = "pta23h"; break; }
445  case PT24L : { pta_str = "pta24l"; break; }
446  case PT24H : { pta_str = "pta24h"; break; }
447  case PT34L : { pta_str = "pta34l"; break; }
448  case PT34H : { pta_str = "pta34h"; break; }
449  case PB12H : { pta_str = "ptb12h_Feb2016"; break; }
450  case PB13H : { pta_str = "ptb13h_Feb2016"; break; }
451  case PB14H : { pta_str = "ptb14h_Feb2016"; break; }
452  case PB21H : { pta_str = "ptb21h_Feb2016"; break; }
453  case PB23H : { pta_str = "ptb23h_Feb2016"; break; }
454  case PB24H : { pta_str = "ptb24h_Feb2016"; break; }
455  case PB34H : { pta_str = "ptb34h_Feb2016"; break; }
456 
457  }
458 
459  // assemble file name
460  string lutpath = AssLUTpath;
461  edm::FileInPath lut_f = edm::FileInPath(string(lutpath + pta_str + ".lut"));
462  string pta_file = lut_f.fullPath();
463 
464  // open file
465  L1TriggerLutFile file(pta_file);
466  if ( file.open() != 0 ) return -1;
467 
468  // get the right shift factor
469  int shift = sh_phi;
470  int adr_old = -2048 >> shift;
471  if (pam >= MAX_PTASSMETHA) adr_old = -512 >> shift;
472 
473  LUT tmplut;
474 
475  int number = -1;
476  int sum_pt = 0;
477 
478  if ( file.good() ) {
479  int threshold = file.readInteger();
480  pta_threshold[pam/2] = threshold;
481  }
482 
483  // read values and shift to correct precision
484  while ( file.good() ) {
485 
486  int adr = (file.readInteger()) >> shift;
487  int pt = file.readInteger();
488 
489  number++;
490  //cout<<pam<<" "<<number<<" "<<MAX_PTASSMETHA<<endl;
491  if ( adr != adr_old ) {
492  assert(number);
493  tmplut.insert(make_pair( adr_old, (sum_pt/number) ));
494 
495  adr_old = adr;
496  number = 0;
497  sum_pt = 0;
498  }
499 
500  sum_pt += pt;
501 
502  if ( !file.good() ) file.close();
503 
504  }
505 
506  file.close();
507  pta_lut.push_back(tmplut);
508  }
509  return 0;
510 
511 }
512 
513 
514 
515 
516 int L1TMuonBarrelParamsESProducer::load_phi(std::vector<LUT>& phi_lut,
517  unsigned short int nbit_phi,
518  unsigned short int nbit_phib,
519  std::string AssLUTpath
520  ) {
521 
522 
523  // precision : in the look-up tables the following precision is used :
524  // address (phib) ...10 bits, phi ... 12 bits
525 
526  int sh_phi = 12 - nbit_phi;
527  int sh_phib = 10 - nbit_phib;
528 
529  string phi_str;
530  // loop over all phi-assignment methods
531  for ( int idx = 0; idx < 2; idx++ ) {
532  switch ( idx ) {
533  case 0 : { phi_str = "phi12"; break; }
534  case 1 : { phi_str = "phi42"; break; }
535  }
536 
537  // assemble file name
538  edm::FileInPath lut_f = edm::FileInPath(string(AssLUTpath + phi_str + ".lut"));
539  string phi_file = lut_f.fullPath();
540 
541  // open file
542  L1TriggerLutFile file(phi_file);
543  if ( file.open() != 0 ) return -1;
544 
545  LUT tmplut;
546 
547  int number = -1;
548  int adr_old = -512 >> sh_phib;
549  int sum_phi = 0;
550 
551  // read values
552  while ( file.good() ) {
553 
554  int adr = (file.readInteger()) >> sh_phib;
555  int phi = file.readInteger();
556 
557  number++;
558 
559  if ( adr != adr_old ) {
560  assert(number);
561  tmplut.insert(make_pair( adr_old, ((sum_phi/number) >> sh_phi) ));
562 
563  adr_old = adr;
564  number = 0;
565  sum_phi = 0;
566  }
567 
568  sum_phi += phi;
569 
570  if ( !file.good() ) file.close();
571 
572  }
573 
574  file.close();
575  phi_lut.push_back(tmplut);
576  }
577  return 0;
578 
579 }
580 
581 
582 int L1TMuonBarrelParamsESProducer::getPtLutThreshold(int pta_ind, std::vector<int>& pta_threshold) const {
583 
584  if ( pta_ind >= 0 && pta_ind < 13/2 ) {
585  return pta_threshold[pta_ind];
586  }
587  else {
588  cerr << "PtaLut::getPtLutThreshold : can not find threshold " << pta_ind << endl;
589  return 0;
590  }
591 
592 }
593 
594 */
595 
596 
597 
598 
599 //
600 // load extrapolation look-up tables
601 //
602 /*
603 int L1TMuonBarrelParamsESProducer::load_ext(std::vector<L1TMuonBarrelParams::LUTParams::extLUT>& ext_lut,
604  unsigned short int nbit_phi,
605  unsigned short int nbit_phib) {
606 
607  //max. number of Extrapolations
608  const int MAX_EXT = 12;
609 
610  // extrapolation types
611  enum Extrapolation { EX12, EX13, EX14, EX21, EX23, EX24, EX34,
612  EX15, EX16, EX25, EX26, EX56 };
613 
614  // get directory name
615  string defaultPath = "L1Trigger/L1TMuon/data/bmtf_luts/";
616  string ext_dir = "LUTs_Ext/";
617  string ext_str = "";
618 
619  // precision : in the look-up tables the following precision is used :
620  // phi ...12 bits (low, high), phib ...10 bits (address)
621  // now convert phi and phib to the required precision
622 
623  int sh_phi = 12 - nbit_phi;
624  int sh_phib = 10 - nbit_phib;
625 
626  // loop over all extrapolations
627  for ( int ext = 0; ext < MAX_EXT; ext++ ) {
628  switch (ext) {
629  case EX12 : ext_str = "ext12"; break;
630  case EX13 : ext_str = "ext13"; break;
631  case EX14 : ext_str = "ext14"; break;
632  case EX21 : ext_str = "ext21"; break;
633  case EX23 : ext_str = "ext23"; break;
634  case EX24 : ext_str = "ext24"; break;
635  case EX34 : ext_str = "ext34"; break;
636  case EX15 : ext_str = "ext15"; break;
637  case EX16 : ext_str = "ext16"; break;
638  case EX25 : ext_str = "ext25"; break;
639  case EX26 : ext_str = "ext26"; break;
640  case EX56 : ext_str = "ext56"; break;
641  }
642 
643  // assemble file name
644  edm::FileInPath lut_f = edm::FileInPath(string(defaultPath + ext_dir + ext_str + ".lut"));
645  string ext_file = lut_f.fullPath();
646 
647  // open file
648  L1TriggerLutFile file(ext_file);
649  if ( file.open() != 0 ) return -1;
650  // if ( L1MuDTTFConfig::Debug(1) ) cout << "Reading file : "
651  // << file.getName() << endl;
652 
653  L1TMuonBarrelParams::LUTParams::extLUT tmplut;
654 
655  int number = -1;
656  int adr_old = -512 >> sh_phib;
657  int sum_low = 0;
658  int sum_high = 0;
659 
660  // read values and shift to correct precision
661  while ( file.good() ) {
662 
663  int adr = ( file.readInteger() ) >> sh_phib; // address (phib)
664  int low = ( file.readInteger() ); // low value (phi)
665  int high = ( file.readInteger() ); // high value (phi)
666 
667  number++;
668 
669  if ( adr != adr_old ) {
670 
671  tmplut.low[adr_old] = sum_low >> sh_phi;
672  tmplut.high[adr_old] = sum_high >> sh_phi;
673 
674  adr_old = adr;
675  number = 0;
676  sum_low = 0;
677  sum_high = 0;
678 
679  }
680 
681  if (number == 0) sum_low = low;
682  if (number == 0) sum_high = high;
683 
684  if ( !file.good() ) file.close();
685  }
686 
687  file.close();
688  ext_lut.push_back(tmplut);
689  }
690  return 0;
691 
692 }
693 
694 
695 //
696 // member functions
697 //
698 */
699 // ------------ method called to produce the data ------------
702 {
703  using namespace edm::es;
704  boost::shared_ptr<L1TMuonBarrelParams> pBMTFParams;
705 
706  //MTFParams = boost::shared_ptr<L1TMuonBarrelParams>(new L1TMuonBarrelParams(m_params));
707  pBMTFParams = boost::shared_ptr<L1TMuonBarrelParams>(new L1TMuonBarrelParams(m_params_helper));
708  return pBMTFParams;
709 }
710 
711 //define this as a plug-in
T getParameter(std::string const &) const
void configFromDB(l1t::TrigSystem &trgSys)
int load_phi(std::vector< LUT > &, unsigned short int, unsigned short int, std::string)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void configureSystemFromFiles(const std::string &hwCfgFile, const std::string &topCfgFile, const std::string &key)
Definition: TrigSystem.cc:19
L1TMuonBarrelParamsESProducer(const edm::ParameterSet &)
boost::shared_ptr< L1TMuonBarrelParams > ReturnType
int load_pt(std::vector< LUT > &, std::vector< int > &, unsigned short int, std::string)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void configFromPy(std::map< std::string, int > &allInts, std::map< std::string, bool > &allBools, std::map< std::string, std::vector< std::string > > allMasks, unsigned int fwVersion, const std::string &AssLUTpath)
ReturnType produce(const L1TMuonBarrelParamsRcd &)
tuple cout
Definition: gather_cfg.py:145
std::string fullPath() const
Definition: FileInPath.cc:184
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:32
int load_ext(std::vector< L1TMuonBarrelParams::LUTParams::extLUT > &, unsigned short int, unsigned short int)