Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DT] Position fix and new filter to TPs from Phase2 L1T emulator #44924

Merged
merged 11 commits into from
Sep 3, 2024
8 changes: 5 additions & 3 deletions L1Trigger/DTTriggerPhase2/interface/GlobalCoordsObtainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ 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> phi;
std::map<int, lut_value> phib;
};

Expand All @@ -58,6 +56,10 @@ class GlobalCoordsObtainer {
void generate_luts();
std::vector<double> get_global_coordinates(uint32_t, int, int, int);

edm::FileInPath maxdrift_filename_;
int maxdriftinfo_[5][4][14];
int max_drift_tdc = -1;

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
Expand Down
84 changes: 84 additions & 0 deletions L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#ifndef Phase2L1Trigger_DTTrigger_MPCoincidenceFilter_h
#define Phase2L1Trigger_DTTrigger_MPCoincidenceFilter_h

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

#include <iostream>
#include <fstream>

// ===============================================================================
// Previous definitions and declarations
// ===============================================================================

// ===============================================================================
// Class declarations
// ===============================================================================

class MPCoincidenceFilter : public MPFilter {
public:
// Constructors and destructor
MPCoincidenceFilter(const edm::ParameterSet &pset);
~MPCoincidenceFilter() override = default;

// Main methods
void initialise(const edm::EventSetup &iEventSetup) override;
void run(edm::Event &iEvent,
const edm::EventSetup &iEventSetup,
std::vector<cmsdt::metaPrimitive> &inMPath,
std::vector<cmsdt::metaPrimitive> &outMPath) override{};
void run(edm::Event &iEvent,
const edm::EventSetup &iEventSetup,
std::vector<cmsdt::metaPrimitive> &allMPaths,
std::vector<cmsdt::metaPrimitive> &inMPaths,
std::vector<cmsdt::metaPrimitive> &outMPaths) override;
void run(edm::Event &iEvent,
const edm::EventSetup &iEventSetup,
MuonPathPtrs &inMPath,
MuonPathPtrs &outMPath) override{};

void finish() override;

// Other public methods

// Public attributes

std::map<std::string, float> mphi_mean{{"wh-2ch1", 1.0}, {"wh-1ch1", 0.9}, {"wh0ch1", -0.3}, {"wh1ch1", 0.9},
{"wh2ch1", 1.0}, {"wh-2ch2", 1.4}, {"wh-1ch2", -0.4}, {"wh0ch2", -0.3},
{"wh1ch2", -0.4}, {"wh2ch2", 1.5}, {"wh-2ch3", -0.1}, {"wh-1ch3", -0.2},
{"wh0ch3", -0.1}, {"wh1ch3", -0.3}, {"wh2ch3", -0.4}, {"wh-2ch4", -1.0},
{"wh-1ch4", -1.1}, {"wh0ch4", -1.0}, {"wh1ch4", -1.1}, {"wh2ch4", -0.8}};

std::map<std::string, float> mphi_width{{"wh-2ch1", 7.2}, {"wh-1ch1", 7.0}, {"wh0ch1", 11.2}, {"wh1ch1", 7.4},
{"wh2ch1", 7.1}, {"wh-2ch2", 6.6}, {"wh-1ch2", 8.5}, {"wh0ch2", 11.1},
{"wh1ch2", 8.5}, {"wh2ch2", 6.5}, {"wh-2ch3", 8.0}, {"wh-1ch3", 9.2},
{"wh0ch3", 11.2}, {"wh1ch3", 9.1}, {"wh2ch3", 7.8}, {"wh-2ch4", 8.0},
{"wh-1ch4", 9.6}, {"wh0ch4", 11.8}, {"wh1ch4", 9.3}, {"wh2ch4", 7.7}};

std::map<std::string, float> mth_mean{{"wh-2ch1", -17.4}, {"wh-1ch1", -9.5}, {"wh0ch1", -0.8}, {"wh1ch1", -9.8},
{"wh2ch1", -17.1}, {"wh-2ch2", -18.9}, {"wh-1ch2", -6.6}, {"wh0ch2", 0.5},
{"wh1ch2", -6.8}, {"wh2ch2", -19.2}, {"wh-2ch3", -16.3}, {"wh-1ch3", -3.2},
{"wh0ch3", 1.9}, {"wh1ch3", -3.6}, {"wh2ch3", -17.5}, {"wh-2ch4", 0.0},
{"wh-1ch4", 0.0}, {"wh0ch4", 0.0}, {"wh1ch4", 0.0}, {"wh2ch4", 0.0}};

std::map<std::string, float> mth_width{{"wh-2ch1", 33.5}, {"wh-1ch1", 12.6}, {"wh0ch1", 10.1}, {"wh1ch1", 14.4},
{"wh2ch1", 44.8}, {"wh-2ch2", 23.0}, {"wh-1ch2", 13.2}, {"wh0ch2", 11.6},
{"wh1ch2", 14.0}, {"wh2ch2", 25.6}, {"wh-2ch3", 22.5}, {"wh-1ch3", 13.8},
{"wh0ch3", 13.9}, {"wh1ch3", 14.2}, {"wh2ch3", 24.2}, {"wh-2ch4", 9.4},
{"wh-1ch4", 9.4}, {"wh0ch4", 9.4}, {"wh1ch4", 9.4}, {"wh2ch4", 9.4}};

private:
// Private methods
std::vector<cmsdt::metaPrimitive> filter(std::vector<cmsdt::metaPrimitive> inMPs,
std::vector<cmsdt::metaPrimitive> allMPs,
int co_option,
int co_quality,
double shift_back);

// Private attributes
const bool debug_;
int co_option_;
int co_quality_;
int scenario_;
};

#endif
22 changes: 11 additions & 11 deletions L1Trigger/DTTriggerPhase2/interface/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,20 +424,20 @@ namespace cmsdt {
* 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 X_SIZE = 17;
constexpr int TANPSI_SIZE = 14;
constexpr double PHI_SIZE = 1. / 131072; //pow(2,17) //1 rad range, 17 bits
constexpr double PHIB_SIZE = 4. / 8192; //pow(2,13) //4 rad range, 13 bits

constexpr int PHI_LUT_ADDR_WIDTH = 12;
constexpr int PHI_B_SHL_BITS = 7;
constexpr int PHI_MULT_SHR_BITS = 10;
constexpr int PHI_LUT_A_BITS = 12;
constexpr int PHI_LUT_B_BITS = 20;
constexpr int PHI_LUT_ADDR_WIDTH = 11;
constexpr int PHI_B_SHL_BITS = 5;
constexpr int PHI_MULT_SHR_BITS = 9;
constexpr int PHI_LUT_A_BITS = 11;
constexpr int PHI_LUT_B_BITS = 21;

constexpr int PHIB_LUT_ADDR_WIDTH = 9;
constexpr int PHIB_B_SHL_BITS = 7;
constexpr int PHIB_MULT_SHR_BITS = 10;
constexpr int PHIB_B_SHL_BITS = 6;
constexpr int PHIB_MULT_SHR_BITS = 9;
constexpr int PHIB_LUT_A_BITS = 10;
constexpr int PHIB_LUT_B_BITS = 16;

Expand Down
46 changes: 43 additions & 3 deletions L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "L1Trigger/DTTriggerPhase2/interface/MPFilter.h"
#include "L1Trigger/DTTriggerPhase2/interface/MPSLFilter.h"
#include "L1Trigger/DTTriggerPhase2/interface/MPCorFilter.h"
#include "L1Trigger/DTTriggerPhase2/interface/MPCoincidenceFilter.h"
#include "L1Trigger/DTTriggerPhase2/interface/MPQualityEnhancerFilter.h"
#include "L1Trigger/DTTriggerPhase2/interface/MPRedundantFilter.h"
#include "L1Trigger/DTTriggerPhase2/interface/MPCleanHitsFilter.h"
Expand Down Expand Up @@ -135,6 +136,8 @@ class DTTrigPhase2Prod : public edm::stream::EDProducer<> {
double dT0_correlate_TP_;
int scenario_;
int df_extended_;
int co_option_; //coincidence
int co_quality_;
int max_index_;

bool output_mixer_;
Expand Down Expand Up @@ -162,6 +165,7 @@ class DTTrigPhase2Prod : public edm::stream::EDProducer<> {
std::unique_ptr<MuonPathAnalyzer> mpathassociator_;
std::unique_ptr<MuonPathConfirmator> mpathconfirmator_;
std::unique_ptr<MPFilter> mpathcorfilter_;
std::unique_ptr<MPFilter> mpathcoifilter_;
std::shared_ptr<GlobalCoordsObtainer> globalcoordsobtainer_;

// Buffering
Expand Down Expand Up @@ -204,6 +208,8 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)
scenario_ = pset.getParameter<int>("scenario");

df_extended_ = pset.getParameter<int>("df_extended");
co_option_ = pset.getParameter<int>("co_option");
co_quality_ = pset.getParameter<int>("co_quality");
max_index_ = pset.getParameter<int>("max_primitives") - 1;

dtDigisToken_ = consumes<DTDigiCollection>(pset.getParameter<edm::InputTag>("digiTag"));
Expand Down Expand Up @@ -261,6 +267,7 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)
mpathconfirmator_ = std::make_unique<MuonPathConfirmator>(pset, consumesColl);
mpathassociator_ = std::make_unique<MuonPathCorFitter>(pset, consumesColl, globalcoordsobtainer_);
mpathcorfilter_ = std::make_unique<MPCorFilter>(pset);
mpathcoifilter_ = std::make_unique<MPCoincidenceFilter>(pset);
rpc_integrator_ = std::make_unique<RPCIntegrator>(pset, consumesColl);

dtGeomH = esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
Expand All @@ -285,6 +292,7 @@ void DTTrigPhase2Prod::beginRun(edm::Run const& iRun, const edm::EventSetup& iEv
mpathhitsfilter_->initialise(iEventSetup);
mpathassociator_->initialise(iEventSetup); // Associator object initialisation
mpathcorfilter_->initialise(iEventSetup);
mpathcoifilter_->initialise(iEventSetup);

if (auto geom = iEventSetup.getHandle(dtGeomH)) {
dtGeo_ = &(*geom);
Expand Down Expand Up @@ -818,6 +826,36 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {
correlatedMetaPrimitives.clear();
filteredMetaPrimitives.clear();

// Coincidence (co) filter

std::vector<metaPrimitive> allMetaPrimitives;
for (auto& ch_filtcorrelatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
for (const auto& metaPrimitiveIt : ch_filtcorrelatedMetaPrimitives.second) {
allMetaPrimitives.push_back(metaPrimitiveIt);
}
}

std::map<int, std::vector<metaPrimitive>> coMetaPrimitives;
if (algo_ == Standard) {
for (auto& ch_filtcorrelatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
if (!skip_processing_)
mpathcoifilter_->run(iEvent,
iEventSetup,
allMetaPrimitives,
filtCorrelatedMetaPrimitives[ch_filtcorrelatedMetaPrimitives.first],
coMetaPrimitives[ch_filtcorrelatedMetaPrimitives.first]);
else {
for (auto& mp : ch_filtcorrelatedMetaPrimitives.second) {
coMetaPrimitives[ch_filtcorrelatedMetaPrimitives.first].push_back(mp);
}
}
}
}

allMetaPrimitives.clear();

/////////////

double shift_back = 0;
if (scenario_ == MC) //scope for MC
shift_back = 400;
Expand All @@ -830,7 +868,7 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {
if (useRPC_) {
rpc_integrator_->initialise(iEventSetup, shift_back);
rpc_integrator_->prepareMetaPrimitives(rpcRecHits);
for (auto& ch_correlatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
for (auto& ch_correlatedMetaPrimitives : coMetaPrimitives) {
rpc_integrator_->matchWithDTAndUseRPCTime(ch_correlatedMetaPrimitives.second); // Probably this is a FIXME
}
rpc_integrator_->makeRPCOnlySegments();
Expand All @@ -846,11 +884,11 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {

// Assigning index value
if (!skip_processing_)
for (auto& ch_correlatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
for (auto& ch_correlatedMetaPrimitives : coMetaPrimitives) {
assignIndex(ch_correlatedMetaPrimitives.second);
}

for (auto& ch_correlatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
for (auto& ch_correlatedMetaPrimitives : coMetaPrimitives) {
for (const auto& metaPrimitiveIt : ch_correlatedMetaPrimitives.second) {
DTChamberId chId(metaPrimitiveIt.rawId);
DTSuperLayerId slId(metaPrimitiveIt.rawId);
Expand Down Expand Up @@ -1253,6 +1291,8 @@ void DTTrigPhase2Prod::fillDescriptions(edm::ConfigurationDescriptions& descript
desc.add<double>("minx_match_2digis", 1.0);
desc.add<int>("scenario", 0);
desc.add<int>("df_extended", 0);
desc.add<int>("co_option", 0);
desc.add<int>("co_quality", 0);
desc.add<int>("max_primitives", 999);
desc.add<bool>("output_mixer", false);
desc.add<bool>("output_latpredictor", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
minx_match_2digis = cms.double(1.),
scenario = cms.int32(0), #0 for mc, 1 for data, 2 for slice test
df_extended = cms.int32(0), # DF: 0 for standard, 1 for extended, 2 for both
co_option = cms.int32(1), # coincidence w.r.t. : -1 = off, 0 = co all, 1 = co phi, 2 = co theta
co_quality = cms.int32(1), # quality cut (>X) for coincidence TP
max_primitives = cms.int32(999),

output_mixer = cms.bool(False),
Expand All @@ -40,9 +42,8 @@
lut_2sl = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/fitterlut_2sl.dat'),
shift_filename = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/wire_rawId_x.txt'),
shift_theta_filename = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/theta_shift.txt'),
maxdrift_filename = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/drift_time_per_chamber.txt'),
maxdrift_filename = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/simple_vdrift.txt'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these files already committed or in a PR somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global_coords_filename = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/global_coord_perp_x_phi0.txt'),
laterality_filename = cms.FileInPath('L1Trigger/DTTriggerPhase2/data/lat_predictions.dat'),
algo = cms.int32(0), # 0 = STD gr., 2 = Hough transform, 1 = PseudoBayes Approach

minHits4Fit = cms.int32(3),
Expand Down
Loading