Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:11:12

0001 #ifndef L1Trigger_DTTriggerPhase2_GlobalCoordsObtainer_h
0002 #define L1Trigger_DTTriggerPhase2_GlobalCoordsObtainer_h
0003 
0004 #include "FWCore/Utilities/interface/ESGetToken.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 #include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/Run.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 
0014 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0015 
0016 #include "L1Trigger/DTTriggerPhase2/interface/constants.h"
0017 
0018 #include <cmath>
0019 #include <fstream>
0020 #include <iostream>
0021 
0022 // ===============================================================================
0023 // Previous definitions and declarations
0024 // ===============================================================================
0025 
0026 struct lut_value {
0027   long int a;
0028   long int b;
0029 };
0030 
0031 struct lut_group {
0032   std::map<int, lut_value> phic;
0033   std::map<int, lut_value> phi1;
0034   std::map<int, lut_value> phi3;
0035   std::map<int, lut_value> phib;
0036 };
0037 
0038 struct global_constant_per_sl {
0039   double perp;
0040   double x_phi0;
0041 };
0042 
0043 struct global_constant {
0044   uint32_t chid;
0045   global_constant_per_sl sl1;
0046   global_constant_per_sl sl3;
0047 };
0048 
0049 // ===============================================================================
0050 // Class declarations
0051 // ===============================================================================
0052 
0053 class GlobalCoordsObtainer {
0054 public:
0055   GlobalCoordsObtainer(const edm::ParameterSet& pset);
0056   ~GlobalCoordsObtainer();
0057 
0058   void generate_luts();
0059   std::vector<double> get_global_coordinates(uint32_t, int, int, int);
0060 
0061 private:
0062   std::map<int, lut_value> calc_atan_lut(int, int, double, double, double, int, int, int, int, int);
0063   // utilities to go to and from 2 complement
0064   int to_two_comp(int val, int size) {
0065     if (val >= 0)
0066       return val;
0067     return std::pow(2, size) + val;
0068   }
0069 
0070   int from_two_comp(int val, int size) { return val - ((2 * val) & (1 << size)); }
0071 
0072   // attributes
0073   bool cmssw_for_global_;
0074   edm::FileInPath global_coords_filename_;
0075   std::vector<global_constant> global_constants;
0076   std::map<uint32_t, lut_group> luts;
0077 };
0078 
0079 #endif