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

MatrixTransferStatic: move matrix configurations to config, implement OMD config for 130 GeV #1780

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 22 additions & 78 deletions src/algorithms/fardetectors/MatrixTransferStatic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ void eicrecon::MatrixTransferStatic::process(
const auto [mcparts, rechits] = input;
auto [outputParticles] = output;

std::vector<std::vector<double>> aX(m_cfg.aX);
std::vector<std::vector<double>> aY(m_cfg.aY);
std::vector<std::vector<double>> aX;
std::vector<std::vector<double>> aY;

//----- Define constants here ------
double aXinv[2][2] = {{0.0, 0.0},
{0.0, 0.0}};
double aYinv[2][2] = {{0.0, 0.0},
{0.0, 0.0}};

double nomMomentum = m_cfg.nomMomentum; //extract the nominal value first -- will be overwritten by MCParticle
double local_x_offset = m_cfg.local_x_offset;
double local_y_offset = m_cfg.local_y_offset;
double local_x_slope_offset = m_cfg.local_x_slope_offset;
double local_y_slope_offset = m_cfg.local_y_slope_offset;
double nomMomentum;
double local_x_offset;
double local_y_offset;
double local_x_slope_offset;
double local_y_slope_offset;

double numBeamProtons = 0;
double runningMomentum = 0.0;
Expand All @@ -70,80 +70,24 @@ void eicrecon::MatrixTransferStatic::process(
//This is a temporary solution to get the beam energy information
//needed to select the correct matrix

if(std::abs(275.0 - nomMomentum)/275.0 < nomMomentumError){

aX[0][0] = 3.251116; //a
aX[0][1] = 30.285734; //b
aX[1][0] = 0.186036375; //c
aX[1][1] = 0.196439472; //d

aY[0][0] = 0.4730500000; //a
aY[0][1] = 3.062999454; //b
aY[1][0] = 0.0204108951; //c
aY[1][1] = -0.139318692; //d

local_x_offset = -1209.29;//-0.339334; these are the local coordinate values
local_y_offset = 0.00132511;//-0.000299454;
local_x_slope_offset = -45.4772;//-0.219603248;
local_y_slope_offset = 0.000745498;//-0.000176128;

}
else if(std::abs(130.0 - nomMomentum)/130.0 < nomMomentumError){ //NOT TUNED -- just for testing purposes

aX[0][0] = 3.16912; //a
aX[0][1] = 22.4693; //b
aX[1][0] = 0.182402; //c
aX[1][1] = -0.218209; //d

aY[0][0] = 0.520743; //a
aY[0][1] = 3.17339; //b
aY[1][0] = 0.0222482; //c
aY[1][1] = -0.0923779; //d

local_x_offset = -1209.29;//-0.339334; these are the local coordinate values
local_y_offset = 0.00132511;//-0.000299454;
local_x_slope_offset = -45.4772;//-0.219603248;
local_y_slope_offset = 0.000745498;//-0.000176128;

}
else if(std::abs(100.0 - nomMomentum)/100.0 < nomMomentumError){

aX[0][0] = 3.152158; //a
aX[0][1] = 20.852072; //b
aX[1][0] = 0.181649517; //c
aX[1][1] = -0.303998487; //d

aY[0][0] = 0.5306100000; //a
aY[0][1] = 3.19623343; //b
aY[1][0] = 0.0226283320; //c
aY[1][1] = -0.082666019; //d

local_x_offset = -1209.27;//-0.329072;
local_y_offset = 0.00355218;//-0.00028343;
local_x_slope_offset = -45.4737;//-0.218525084;
local_y_slope_offset = 0.00204394;//-0.00015321;

}
else if(std::abs(41.0 - nomMomentum)/41.0 < nomMomentumError){

aX[0][0] = 3.135997; //a
aX[0][1] = 18.482273; //b
aX[1][0] = 0.176479921; //c
aX[1][1] = -0.497839483; //d

aY[0][0] = 0.4914400000; //a
aY[0][1] = 4.53857451; //b
aY[1][0] = 0.0179664765; //c
aY[1][1] = 0.004160679; //d
bool matrix_found = false;
for (const MatrixConfig& matrix_config : m_cfg.matrix_configs) {
if (std::abs(matrix_config.nomMomentum - nomMomentum) / matrix_config.nomMomentum < nomMomentumError) {
if (matrix_found) {
error("Conflicting matrix values matching momentum {}", nomMomentum);
}
matrix_found = true;

local_x_offset = -1209.22;//-0.283273;
local_y_offset = 0.00868737;//-0.00552451;
local_x_slope_offset = -45.4641;//-0.21174031;
local_y_slope_offset = 0.00498786;//-0.003212011;
aX = matrix_config.aX;
aY = matrix_config.aY;

local_x_offset = matrix_config.local_x_offset;
local_y_offset = matrix_config.local_y_offset;
local_x_slope_offset = matrix_config.local_x_slope_offset;
local_y_slope_offset = matrix_config.local_y_slope_offset;
}
}

else {
if (not matrix_found) {
error("MatrixTransferStatic:: No valid matrix found to match beam momentum!! Skipping!!");
return;
}
Expand Down
35 changes: 13 additions & 22 deletions src/algorithms/fardetectors/MatrixTransferStaticConfig.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2023, Simon Gardner
// Copyright (C) 2023 - 2025, Simon Gardner, Dmitry Kalinkin

#pragma once

namespace eicrecon {

struct MatrixConfig {
// Defaults here are for RPOTS
double nomMomentum;
std::vector<std::vector<double>> aX;
std::vector<std::vector<double>> aY;
double local_x_offset;
double local_y_offset;
double local_x_slope_offset;
double local_y_slope_offset;
};

struct MatrixTransferStaticConfig {

float partMass {0.938272};
float partCharge{1};
long long partPDG {2212};

// Defaults here are for RPOTS
double local_x_offset {0.0};
double local_y_offset {0.0};
double local_x_slope_offset{-0.00622147};
double local_y_slope_offset{-0.0451035};
double crossingAngle {0.025};
double nomMomentum {100.0};

//std::vector<std::vector<double>> aX = {{2.102403743, 29.11067626},
// {0.186640381, 0.192604619}};
//std::vector<std::vector<double>> aY = {{0.0000159900, 3.94082098},
// {0.0000079946, -0.1402995}};


//x_offset = 0.00979216;
//y_offset = -0.00778646;
//x_slope_offset = 0.004526961;
//y_slope_offset = -0.003907849;

std::vector<std::vector<double>> aX = {{2.03459216, 22.85780784},
{0.179641961, -0.306626961}};
std::vector<std::vector<double>> aY = {{0.38879, 3.71612646},
{0.022685, -0.003907849}};
std::vector<MatrixConfig> matrix_configs;

double hit1minZ{0};
double hit1maxZ{0};
Expand Down
45 changes: 28 additions & 17 deletions src/detectors/FOFFMTRK/FOFFMTRK.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void InitPlugin(JApplication *app) {
InitJANAPlugin(app);
using namespace eicrecon;

MatrixTransferStaticConfig recon_cfg;

//Digitized hits, especially for thresholds
app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
Expand Down Expand Up @@ -48,26 +47,38 @@ void InitPlugin(JApplication *app) {
app
));

//Static transport matrix for Off Momentum detectors
recon_cfg.aX = {{1.6248, 12.966293},
{0.1832, -2.8636535}};
recon_cfg.aY = {{0.0001674, -28.6003},
{0.0000837, -2.87985}};
app->Add(new JOmniFactoryGeneratorT<MatrixTransferStatic_factory>(
"ForwardOffMRecParticles", {"MCParticles", "ForwardOffMTrackerRecHits"},
{"ForwardOffMRecParticles"},
{
.matrix_configs = {{
.nomMomentum = 130.0,

recon_cfg.local_x_offset = -11.9872; // in mm --> this is from misalignment of the detector
recon_cfg.local_y_offset = -0.0146; // in mm --> this is from misalignment of the detector
recon_cfg.local_x_slope_offset = -14.75315; // in mrad
recon_cfg.local_y_slope_offset = -0.0073; // in mrad
recon_cfg.nomMomentum = 137.5; // in GEV --> exactly half of the top energy momentum (for proton spectators from deuteron breakup)
.aX =
{
{1.61591, 12.6786},
{0.184206, -2.907},
},

recon_cfg.hit1minZ = 22499.0;
recon_cfg.hit1maxZ = 22522.0;
recon_cfg.hit2minZ = 24499.0;
recon_cfg.hit2maxZ = 24522.0;
.aY =
{
{-0.789385, -28.5578},
{-0.0721796, -2.8763},
},

recon_cfg.readout = "ForwardOffMTrackerRecHits";
.local_x_offset = -881.631,
.local_y_offset = -0.00552173,
.local_x_slope_offset = -59.7386,
.local_y_slope_offset = -0.00360656,

app->Add(new JOmniFactoryGeneratorT<MatrixTransferStatic_factory>("ForwardOffMRecParticles",{"MCParticles","ForwardOffMTrackerRecHits"},{"ForwardOffMRecParticles"},recon_cfg,app));
}},
.hit1minZ = 22499.0,
.hit1maxZ = 22522.0,
.hit2minZ = 24499.0,
.hit2maxZ = 24522.0,

.readout = "ForwardOffMTrackerRecHits",
},
app));
}
}
108 changes: 92 additions & 16 deletions src/detectors/RPOTS/RPOTS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,102 @@ void InitPlugin(JApplication *app) {
));


//Static transport matrix for Roman Pots detectors
recon_cfg.aX = {{2.102403743, 29.11067626},
{0.186640381, 0.192604619}};
recon_cfg.aY = {{0.0000159900, 3.94082098},
{0.0000079946, -0.1402995}};
app->Add(new JOmniFactoryGeneratorT<MatrixTransferStatic_factory>(
"ForwardRomanPotRecParticles",
{
"MCParticles",
"ForwardRomanPotRecHits",
},
{
"ForwardRomanPotRecParticles",
},
{
.matrix_configs =
{{
.nomMomentum = 275.0,
.aX =
{
{3.251116, 30.285734},
{0.186036375, 0.196439472},
},
.aY =
{
{0.4730500000, 3.062999454},
{0.0204108951, -0.139318692},
},

recon_cfg.local_x_offset = 0.0; // in mm --> this is from misalignment of the detector
recon_cfg.local_y_offset = 0.0; // in mm --> this is from misalignment of the detector
recon_cfg.local_x_slope_offset = -0.00622147; // in mrad
recon_cfg.local_y_slope_offset = -0.0451035; // in mrad
recon_cfg.nomMomentum = 275.0; // in GEV --> exactly half of the top energy momentum (for proton spectators from deuteron breakup)
.local_x_offset = -1209.29, //-0.339334, these are the local coordinate values
.local_y_offset = 0.00132511, //-0.000299454,
.local_x_slope_offset = -45.4772, //-0.219603248,
.local_y_slope_offset = 0.000745498, //-0.000176128,

recon_cfg.hit1minZ = 32541.0;
recon_cfg.hit1maxZ = 32554.0;
recon_cfg.hit2minZ = 34239.0;
recon_cfg.hit2maxZ = 34252.0;
},
{
// NOT TUNED -- just for testing purposes
.nomMomentum = 130.0,
.aX =
{
{3.16912, 22.4693},
{0.182402, -0.218209},
},

recon_cfg.readout = "ForwardRomanPotRecHits";
.aY =
{
{0.520743, 3.17339},
{0.0222482, -0.0923779},
},

app->Add(new JOmniFactoryGeneratorT<MatrixTransferStatic_factory>("ForwardRomanPotRecParticles",{"MCParticles","ForwardRomanPotRecHits"},{"ForwardRomanPotRecParticles"},recon_cfg,app));
.local_x_offset = -1209.29, //-0.339334, these are the local coordinate values
.local_y_offset = 0.00132511, //-0.000299454,
.local_x_slope_offset = -45.4772, //-0.219603248,
.local_y_slope_offset = 0.000745498, //-0.000176128,

},
{
.nomMomentum = 100.0,

.aX =
{
{3.152158, 20.852072},
{0.181649517, -0.303998487},
},

.aY =
{
{0.5306100000, 3.19623343},
{0.0226283320, -0.082666019},
},

.local_x_offset = -1209.27, //-0.329072,
.local_y_offset = 0.00355218, //-0.00028343,
.local_x_slope_offset = -45.4737, //-0.218525084,
.local_y_slope_offset = 0.00204394, //-0.00015321,

},
{
.nomMomentum = 41.0,

.aX =
{
{3.135997, 18.482273},
{0.176479921, -0.497839483},

},
.aY = {{0.4914400000, 4.53857451}, {0.0179664765, 0.004160679}},

.local_x_offset = -1209.22, //-0.283273,
.local_y_offset = 0.00868737, //-0.00552451,
.local_x_slope_offset = -45.4641, //-0.21174031,
.local_y_slope_offset = 0.00498786, //-0.003212011,

}},
.hit1minZ = 32541.0,
.hit1maxZ = 32554.0,
.hit2minZ = 34239.0,
.hit2maxZ = 34252.0,

.readout = "ForwardRomanPotRecHits",
},
app));
}
}
5 changes: 0 additions & 5 deletions src/factories/fardetectors/MatrixTransferStatic_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ class MatrixTransferStatic_factory :
ParameterRef<float> partCharge{this, "partCharge", config().partCharge};
ParameterRef<long long> partPDG {this, "partPDG", config().partPDG};

ParameterRef<double> local_x_offset {this, "local_x_offset", config().local_x_offset};
ParameterRef<double> local_y_offset {this, "local_y_offset", config().local_y_offset};
ParameterRef<double> local_x_slope_offset{this, "local_x_slope_offset", config().local_x_slope_offset};
ParameterRef<double> local_y_slope_offset{this, "local_y_slope_offset", config().local_y_slope_offset};
ParameterRef<double> crossingAngle {this, "crossingAngle", config().crossingAngle};
ParameterRef<double> nomMomentum {this, "nomMomentum", config().nomMomentum};

// FIXME JANA2 does not support vector of vector
//ParameterRef<std::vector<std::vector<double>>> aX {this, "aX", config().aX};
Expand Down
Loading