Skip to content

Commit

Permalink
Changes after checks and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimeleonh committed Mar 22, 2021
1 parent 424e38f commit 693e765
Show file tree
Hide file tree
Showing 9 changed files with 2,188 additions and 729 deletions.
3 changes: 1 addition & 2 deletions DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTThDigi.h
Expand Up @@ -6,8 +6,7 @@ class L1Phase2MuDTThDigi {
// Constructors
L1Phase2MuDTThDigi();

L1Phase2MuDTThDigi(
int bx, int wh, int sc, int st, int z, int k, int qual, int idx, int t0, int chi2, int rpc = -10);
L1Phase2MuDTThDigi(int bx, int wh, int sc, int st, int z, int k, int qual, int idx, int t0, int chi2, int rpc = -10);

// Operations
int bxNum() const;
Expand Down
30 changes: 13 additions & 17 deletions L1Trigger/DTTriggerPhase2/interface/GlobalCoordsObtainer.h
Expand Up @@ -16,10 +16,9 @@

#include "L1Trigger/DTTriggerPhase2/interface/constants.h"

#include <iostream>
#include <cmath>
#include <fstream>
#include <math.h>

#include <iostream>

// ===============================================================================
// Previous definitions and declarations
Expand All @@ -31,14 +30,14 @@ struct lut_value {
};

struct lut_group {
std::map <int, lut_value> phic;
std::map <int, lut_value> phi1;
std::map <int, lut_value> phi3;
std::map <int, lut_value> phib;
std::map<int, lut_value> phic;
std::map<int, lut_value> phi1;
std::map<int, lut_value> phi3;
std::map<int, lut_value> phib;
};

struct global_constant_per_sl {
double perp;
double perp;
double x_phi0;
};

Expand All @@ -48,7 +47,6 @@ struct global_constant {
global_constant_per_sl sl3;
};


// ===============================================================================
// Class declarations
// ===============================================================================
Expand All @@ -58,22 +56,20 @@ class GlobalCoordsObtainer {
GlobalCoordsObtainer(const edm::ParameterSet& pset);
~GlobalCoordsObtainer();

void generate_luts();
void generate_luts();
std::vector<double> get_global_coordinates(uint32_t, int, int, int);


private:
std::map<int, lut_value> calc_atan_lut(int, int, double, double, double, int, int, int, int, int);
// utilities to go to and from 2 complement
int to_two_comp(int val, int size) {
if (val >= 0) return val;
if (val >= 0)
return val;
return std::pow(2, size) + val;
}

int from_two_comp(int val, int size) {
return val - ((2 * val) & (1 << size));
}


int from_two_comp(int val, int size) { return val - ((2 * val) & (1 << size)); }

// attributes
bool cmssw_for_global_;
edm::FileInPath global_coords_filename_;
Expand Down
28 changes: 18 additions & 10 deletions L1Trigger/DTTriggerPhase2/interface/MuonPathAnalyticAnalyzer.h
Expand Up @@ -21,7 +21,7 @@ struct CONSTANTS {
};

struct LATCOMB_CONSTANTS {
int latcomb;
int latcomb;
CONSTANTS constants;
};

Expand All @@ -42,8 +42,9 @@ struct CELL_VALID_LAYOUT_CONSTANTS {
class MuonPathAnalyticAnalyzer : public MuonPathAnalyzer {
public:
// Constructors and destructor
MuonPathAnalyticAnalyzer(const edm::ParameterSet &pset, edm::ConsumesCollector &iC,
std::shared_ptr<GlobalCoordsObtainer> & globalcoordsobtainer);
MuonPathAnalyticAnalyzer(const edm::ParameterSet &pset,
edm::ConsumesCollector &iC,
std::shared_ptr<GlobalCoordsObtainer> &globalcoordsobtainer);
~MuonPathAnalyticAnalyzer() override;

// Main methods
Expand Down Expand Up @@ -81,11 +82,19 @@ class MuonPathAnalyticAnalyzer : public MuonPathAnalyzer {
// Private methods
void analyze(MuonPathPtr &inMPath, std::vector<cmsdt::metaPrimitive> &metaPrimitives);
void fillLAYOUT_VALID_TO_LATCOMB_CONSTS_ENCODER();
void segment_fitter(DTSuperLayerId MuonPathSLId, int wires[4], int t0s[4], int valid[4], int reduced_times[4],
int cell_horiz_layout[4], LATCOMB_CONSTANTS latcomb_consts, int xwire_mm[4], int coarse_pos, int coarse_offset,
std::vector<cmsdt::metaPrimitive> &metaPrimitives);
void segment_fitter(DTSuperLayerId MuonPathSLId,
int wires[4],
int t0s[4],
int valid[4],
int reduced_times[4],
int cell_horiz_layout[4],
LATCOMB_CONSTANTS latcomb_consts,
int xwire_mm[4],
int coarse_pos,
int coarse_offset,
std::vector<cmsdt::metaPrimitive> &metaPrimitives);
int compute_parameter(MAGNITUDE constants, int t0s[4], int DIV_SHR_BITS, int INCREASED_RES);
std::vector <int> getLateralityCombination (int latcomb);
std::vector<int> getLateralityCombination(int latcomb);

// Private attributes

Expand All @@ -100,11 +109,10 @@ class MuonPathAnalyticAnalyzer : public MuonPathAnalyzer {
int cellLayout_[cmsdt::NUM_LAYERS];
bool cmssw_for_global_;
std::string geometry_tag_;
std::vector <CELL_VALID_LAYOUT_CONSTANTS> LAYOUT_VALID_TO_LATCOMB_CONSTS_ENCODER;
std::vector<CELL_VALID_LAYOUT_CONSTANTS> LAYOUT_VALID_TO_LATCOMB_CONSTS_ENCODER;

// global coordinates
std::shared_ptr<GlobalCoordsObtainer> globalcoordsobtainer_;

};

#endif
7 changes: 4 additions & 3 deletions L1Trigger/DTTriggerPhase2/interface/MuonPathAssociator.h
Expand Up @@ -35,8 +35,9 @@
class MuonPathAssociator {
public:
// Constructors and destructor
MuonPathAssociator(const edm::ParameterSet &pset, edm::ConsumesCollector &iC,
std::shared_ptr<GlobalCoordsObtainer> & globalcoordsobtainer);
MuonPathAssociator(const edm::ParameterSet &pset,
edm::ConsumesCollector &iC,
std::shared_ptr<GlobalCoordsObtainer> &globalcoordsobtainer);
~MuonPathAssociator();

// Main methods
Expand Down Expand Up @@ -88,7 +89,7 @@ class MuonPathAssociator {
//shift
edm::FileInPath shift_filename_;
std::map<int, float> shiftinfo_;

// global coordinates
std::shared_ptr<GlobalCoordsObtainer> globalcoordsobtainer_;
};
Expand Down
25 changes: 12 additions & 13 deletions L1Trigger/DTTriggerPhase2/interface/constants.h
Expand Up @@ -182,17 +182,17 @@ namespace cmsdt {
// In mm / ns (velocidad de deriva)
constexpr float DRIFT_SPEED = 0.0542;
// With 4 bits for the decimal part
constexpr int DRIFT_SPEED_X4 = 889; // 55.5 * 2 ** 4
constexpr int DRIFT_SPEED_X4 = 889; // 55.5 * 2 ** 4

// distance between SLs, cm
constexpr float VERT_PHI1_PHI3 = 23.5;

// inverse of the distance between SLs, FW units
constexpr int VERT_PHI1_PHI3_INV = 558;
constexpr int VERT_PHI1_PHI3_INV = 558;

// distance between center of the chamber and each SL in mm, 2 bit precision for the decimal part
constexpr int CH_CENTER_TO_MID_SL_X2 = 470; // 117.5 * 2 ** 2
constexpr int CH_CENTER_TO_MID_SL_X2 = 470; // 117.5 * 2 ** 2

/*
This is the maximum value than internal time can take. This is because
internal time is cyclical due to the limited size of the time counters and
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace cmsdt {
constexpr int TDCTIME_REDUCED_SIZE = 10;
constexpr float ZRES_CONV = 65536. / 1500;
constexpr float KRES_CONV = 65536. / 2;

/*
* Size of pre-mixer buffers for DTPrimitives
*
Expand Down Expand Up @@ -261,28 +261,28 @@ namespace cmsdt {
constexpr int DIV_SHR_BITS_POS = 21;
constexpr int DIV_SHR_BITS_SLOPE = 21;
constexpr int DIV_SHR_BITS_SLOPE_XHH = 18;

constexpr int INCREASED_RES_T0 = 0;
constexpr int INCREASED_RES_POS = 4;
constexpr int INCREASED_RES_SLOPE = 12;
constexpr int INCREASED_RES_SLOPE_XHH = 4;

constexpr int INCREASED_RES_POS_POW = 16;
constexpr int INCREASED_RES_SLOPE_POW = 4096;

// Values to compute drift distances from drift times
constexpr int DTDD_PREADD = 9;
constexpr int DTDD_MULT = 445;
constexpr int DTDD_SHIFTR_BITS = 13;

/*
* Local to global coordinates transformation
*/

constexpr int X_SIZE = 18;
constexpr int TANPSI_SIZE = 15;
constexpr int PHI_SIZE = 17; // (1 / 2 ** 17)
constexpr int PHIB_SIZE = 11; // (2 ** 2) / (2 ** 13)
constexpr int TANPSI_SIZE = 15;
constexpr int PHI_SIZE = 17; // (1 / 2 ** 17)
constexpr int PHIB_SIZE = 11; // (2 ** 2) / (2 ** 13)

constexpr int PHI_LUT_ADDR_WIDTH = 12;
constexpr int PHI_B_SHL_BITS = 7;
Expand All @@ -298,7 +298,6 @@ namespace cmsdt {

constexpr int PHI_PHIB_RES_DIFF_BITS = 6;


} // namespace cmsdt

#endif
73 changes: 34 additions & 39 deletions L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc
Expand Up @@ -45,7 +45,6 @@
#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTThContainer.h"
#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTThDigi.h"


// DT trigger GeomUtils
#include "DQM/DTMonitorModule/interface/DTTrigGeomUtils.h"

Expand Down Expand Up @@ -168,7 +167,7 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)

debug_ = pset.getUntrackedParameter<bool>("debug");
dump_ = pset.getUntrackedParameter<bool>("dump");

do_correlation_ = pset.getParameter<bool>("do_correlation");
scenario_ = pset.getParameter<int>("scenario");

Expand All @@ -179,7 +178,7 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)

// Choosing grouping scheme:
algo_ = pset.getParameter<int>("algo");

// Local to global coordinates approach
cmssw_for_global_ = pset.getUntrackedParameter<bool>("cmssw_for_global", true);
geometry_tag_ = pset.getUntrackedParameter<std::string>("geometry_tag", "");
Expand Down Expand Up @@ -208,8 +207,6 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)
LogDebug("DTTrigPhase2Prod") << "DTp2:constructor: Full chamber analyzer";
mpathanalyzer_ = std::make_unique<MuonPathAnalyzerInChamber>(pset, consumesColl);
}



// Getting buffer option
activateBuffer_ = pset.getParameter<bool>("activateBuffer");
Expand Down Expand Up @@ -307,7 +304,7 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {
std::queue<std::pair<DTLayerId, DTDigi>> timequeue;

for (const auto& elem : tmpvec)
timequeue.emplace(std::move(elem));
timequeue.emplace(elem);
tmpvec.clear();

// Distribute the digis from the queue into supercells
Expand Down Expand Up @@ -534,39 +531,37 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {
if (debug_)
LogDebug("DTTrigPhase2Prod") << "pushing back phase-2 dataformat carlo-federica dataformat";


if(slId.superLayer()!=2){
//phiTP
outP2Ph.push_back(L1Phase2MuDTPhDigi(
(int)round(metaPrimitiveIt.t0 / (float)LHC_CLK_FREQ) - shift_back,
chId.wheel(), // uwh (m_wheel)
sectorTP, // usc (m_sector)
chId.station(), // ust (m_station)
sl, // ust (m_station)
(int)round(metaPrimitiveIt.phi * PHIRES_CONV), // uphi (_phiAngle)
(int)round(metaPrimitiveIt.phiB * PHIBRES_CONV), // uphib (m_phiBending)
metaPrimitiveIt.quality, // uqua (m_qualityCode)
metaPrimitiveIt.index, // uind (m_segmentIndex)
(int)round(metaPrimitiveIt.t0) - shift_back * LHC_CLK_FREQ, // ut0 (m_t0Segment)
(int)round(metaPrimitiveIt.chi2 * CHI2RES_CONV), // uchi2 (m_chi2Segment)
metaPrimitiveIt.rpcFlag // urpc (m_rpcFlag)
));
}else{
//thTP
outP2Th.push_back(L1Phase2MuDTThDigi(
(int)round(metaPrimitiveIt.t0 / (float)LHC_CLK_FREQ) - shift_back,
chId.wheel(), // uwh (m_wheel)
sectorTP, // usc (m_sector)
chId.station(), // ust (m_station)
(int)round(metaPrimitiveIt.phi * ZRES_CONV), // uz (m_zGlobal)
(int)round(metaPrimitiveIt.phiB * KRES_CONV), // uk (m_kSlope)
metaPrimitiveIt.quality, // uqua (m_qualityCode)
metaPrimitiveIt.index, // uind (m_segmentIndex)
(int)round(metaPrimitiveIt.t0) - shift_back * LHC_CLK_FREQ, // ut0 (m_t0Segment)
(int)round(metaPrimitiveIt.chi2 * CHI2RES_CONV), // uchi2 (m_chi2Segment)
metaPrimitiveIt.rpcFlag // urpc (m_rpcFlag)
));

if (slId.superLayer() != 2) {
//phiTP
outP2Ph.push_back(L1Phase2MuDTPhDigi(
(int)round(metaPrimitiveIt.t0 / (float)LHC_CLK_FREQ) - shift_back,
chId.wheel(), // uwh (m_wheel)
sectorTP, // usc (m_sector)
chId.station(), // ust (m_station)
sl, // ust (m_station)
(int)round(metaPrimitiveIt.phi * PHIRES_CONV), // uphi (_phiAngle)
(int)round(metaPrimitiveIt.phiB * PHIBRES_CONV), // uphib (m_phiBending)
metaPrimitiveIt.quality, // uqua (m_qualityCode)
metaPrimitiveIt.index, // uind (m_segmentIndex)
(int)round(metaPrimitiveIt.t0) - shift_back * LHC_CLK_FREQ, // ut0 (m_t0Segment)
(int)round(metaPrimitiveIt.chi2 * CHI2RES_CONV), // uchi2 (m_chi2Segment)
metaPrimitiveIt.rpcFlag // urpc (m_rpcFlag)
));
} else {
//thTP
outP2Th.push_back(L1Phase2MuDTThDigi(
(int)round(metaPrimitiveIt.t0 / (float)LHC_CLK_FREQ) - shift_back,
chId.wheel(), // uwh (m_wheel)
sectorTP, // usc (m_sector)
chId.station(), // ust (m_station)
(int)round(metaPrimitiveIt.phi * ZRES_CONV), // uz (m_zGlobal)
(int)round(metaPrimitiveIt.phiB * KRES_CONV), // uk (m_kSlope)
metaPrimitiveIt.quality, // uqua (m_qualityCode)
metaPrimitiveIt.index, // uind (m_segmentIndex)
(int)round(metaPrimitiveIt.t0) - shift_back * LHC_CLK_FREQ, // ut0 (m_t0Segment)
(int)round(metaPrimitiveIt.chi2 * CHI2RES_CONV), // uchi2 (m_chi2Segment)
metaPrimitiveIt.rpcFlag // urpc (m_rpcFlag)
));
}
}

Expand Down

0 comments on commit 693e765

Please sign in to comment.