Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-04 04:35:14

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> phi;
0033   std::map<int, lut_value> phib;
0034 };
0035 
0036 struct global_constant_per_sl {
0037   double perp;
0038   double x_phi0;
0039 };
0040 
0041 struct global_constant {
0042   uint32_t chid;
0043   global_constant_per_sl sl1;
0044   global_constant_per_sl sl3;
0045 };
0046 
0047 // ===============================================================================
0048 // Class declarations
0049 // ===============================================================================
0050 
0051 class GlobalCoordsObtainer {
0052 public:
0053   GlobalCoordsObtainer(const edm::ParameterSet& pset);
0054   ~GlobalCoordsObtainer();
0055 
0056   void generate_luts();
0057   std::vector<double> get_global_coordinates(uint32_t, int, int, int);
0058 
0059   edm::FileInPath maxdrift_filename_;
0060   int maxdriftinfo_[5][4][14];
0061   int max_drift_tdc = -1;
0062 
0063 private:
0064   std::map<int, lut_value> calc_atan_lut(int, int, double, double, double, int, int, int, int, int);
0065   // utilities to go to and from 2 complement
0066   int to_two_comp(int val, int size) {
0067     if (val >= 0)
0068       return val;
0069     return std::pow(2, size) + val;
0070   }
0071 
0072   int from_two_comp(int val, int size) { return val - ((2 * val) & (1 << size)); }
0073 
0074   // attributes
0075   bool cmssw_for_global_;
0076   edm::FileInPath global_coords_filename_;
0077   std::vector<global_constant> global_constants;
0078   std::map<uint32_t, lut_group> luts;
0079 };
0080 
0081 #endif