Skip to content

Conversation

@ckierans
Copy link
Collaborator

I've added the ability to include the Yaw value from the mask metrology measurements to account for rotations of the strips on the LV and HV side.

If the MaskMetrology is enabled in the Depth Calibration module, then the position of the hit is determined by the intercept of the dominate (i.e. largest energy deposit) LV and HV strips, where the centroid of the strip and angle are read from the metrology file. The intercept is calculated in a new function GetStripIntersection, and the metrology file is loaded with a new function LoadMaskMetrologyFile.

TODO: Aldo's file has the HV strip ID flipped (as evident in the x,y position reported in the metrology files), so there is a int HVStripID_flipped = 63 - HVStripID; placeholder until the files are fixed.

TODO: The initial X/Y position should be more rigorous to include charge sharing down the line. This method will need to be updated at that time.

I confirmed that the implementation in nuclearizer gives ARM values that are the same as without the correction (unfortunately, not actually measurably better).

ckierans and others added 4 commits November 24, 2025 21:19
…works for 2 detectors based on latest files from Aldo
* Merging select files from StripPairingTesting into StripPairingCleanUp so I can do pull request

* Clean up comments. Remove long debugging statements for readability

* Calling charge trapping correction function in chi square calculation and hit population

* Cleaning up comments

* Reformatting strip pairing module

* Update copywrite. Change name of module.

* Fixing documentation in header files

* Change how strip pairing chi square is read out to .dat file

* Adding comments for all the nested vectors

* Adding new version to StreamDat that reads out LV and HV energy of each hit

* Adding Sean's new strip pairing expos to chi square version of strip pairing

* Changing all instances of RedChiSquare to ReducedChiSquare for clarity

* Flags for multiple hits on a single strip are now defined on the MHit level

* Initializing m_StripHitMultipleTimesX and m_StripHitMultipleTimesY to false

* Changing StreamDAT version from Version 1 to Version 3

* Rebased and fixed merge conflict with strip pairing

---------

Co-authored-by: Julian Gerber <jmgerber@ucsd.edu>
@ckierans ckierans requested a review from zoglauer December 9, 2025 03:43
@ckierans
Copy link
Collaborator Author

ckierans commented Dec 9, 2025

This is ready to review, with the acknowledgement that the X/Y position will needs to be updated based on the coordinate system we define. This can be done in a future small PR.

@ckierans ckierans linked an issue Dec 9, 2025 that may be closed by this pull request
//! Select mask metrology file to load. This gives the translation and rotation for each strip in the detector frame
MGUIEFileSelector* m_MaskMetrologyFileSelector;

int m_UseMaskMetCorr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use bool

@@ -1,4 +1,4 @@
/*
/*:q
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove :q

// TGLayoutHints* FileLabelLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX, m_FontScaler*65 + 21*m_FontScaler, m_FontScaler*65, 0, 2*m_FontScaler);

m_MaskMetrologyFileSelector = new MGUIEFileSelector(m_OptionsFrame, "", dynamic_cast<MModuleDepthCalibration2024*>(m_Module)->GetMaskMetrologyFileName());
m_MaskMetrologyFileSelector->SetFileType("metrology", "*.csv");
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have so many css files, can we name this *.metrology.csv or soemthing similar?

switch (Parameter1) {
case c_MetFile:
if (m_MaskMetModeCB->GetState() == kButtonDown) {
m_UseMaskMetCorr = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

bool

double Xpos = m_YPitches[DetID]*((m_NYStrips[DetID]/2.0) - ((double)LVStripID));
double Ypos = m_XPitches[DetID]*((m_NXStrips[DetID]/2.0) - ((double)HVStripID));
double Zpos = 0.0;
double Xpos, Ypos, Zpos;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please initialize all variables in C/C++

double Zpos = 0.0;
double Xpos, Ypos, Zpos;

if ( m_MaskMetrologyEnabled ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting: if (sdkjvghjk == true) {

std::vector<double>* MModuleDepthCalibration2024::GetPixelCoeffs(int PixelCode)
{
// Check to see if the stretch and offset have been loaded. If so, try to get the coefficients for the specified pixel.
if( m_CoeffsFileIsLoaded ){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting

//Read the Mask Metrology File
// Det ID, Side (l,h), Strip ID (0-63), x_mm, y_mm, z_mm, roll_deg, pitch_deg, yaw_deg
MFile F;
if( F.Open(FName) == false ){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting... There are a bunch of these... I no longer mention them but please fix

} else {
MString Line;
while( F.ReadLine( Line ) ){
if ( Line.BeginsWith('#') ){
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (Line.BeginsWith('#') == true) continue;
This makes it easier to read

}
else {
std::vector<MString> Tokens = Line.Tokenize(",");
if( Tokens.size() == 9 ){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dl we want an error message if it is not 9?

}

MXmlNode* MasKMetrologyNode = Node->GetNode("MaskMetrology");
if( MasKMetrologyNode != NULL ){
Copy link
Collaborator

Choose a reason for hiding this comment

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

!= nullptr
NULL is just for C


MXmlNode* MasKMetrologyNode = Node->GetNode("MaskMetrology");
if( MasKMetrologyNode != NULL ){
m_MaskMetrologyEnabled = (bool) MasKMetrologyNode->GetValueAsInt();
Copy link
Collaborator

Choose a reason for hiding this comment

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

GetValueAsBoolean()

}

MXmlNode* MaskMetrologyFileNameNode = Node->GetNode("MaskMetrologyFileName");
if (MaskMetrologyFileNameNode != 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nullptr

}

MXmlNode* UCSDOverrideNode = Node->GetNode("UCSDOverride");
if( UCSDOverrideNode != NULL ){
Copy link
Collaborator

Choose a reason for hiding this comment

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

nullptr


MXmlNode* UCSDOverrideNode = Node->GetNode("UCSDOverride");
if( UCSDOverrideNode != NULL ){
m_UCSDOverride = (bool) UCSDOverrideNode->GetValueAsInt();
Copy link
Collaborator

Choose a reason for hiding this comment

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

GetValueAsBoolean

MXmlNode* Node = new MXmlNode(0,m_XmlTag);
new MXmlNode(Node, "CoeffsFileName", m_CoeffsFile);
new MXmlNode(Node, "SplinesFileName", m_SplinesFile);
new MXmlNode(Node, "MaskMetrology", (unsigned int) m_MaskMetrologyEnabled);
Copy link
Collaborator

Choose a reason for hiding this comment

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

bool should work

new MXmlNode(Node, "SplinesFileName", m_SplinesFile);
new MXmlNode(Node, "MaskMetrology", (unsigned int) m_MaskMetrologyEnabled);
new MXmlNode(Node, "MaskMetrologyFileName", m_MaskMetrologyFile);
new MXmlNode(Node, "UCSDOverride",(unsigned int) m_UCSDOverride);
Copy link
Collaborator

Choose a reason for hiding this comment

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

bool should work

map<MReadOutElementDoubleStrip, vector<double>> m_MaskMetrology;


// boolean for use with the card cage at UCSD since it tags all events as detector 11
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need that?
The UCSD code should be its own branch and not be in the main code?
Maybe make an issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I created an issue for this. Leaving this code for now.

ckierans and others added 5 commits December 9, 2025 22:59
…works for 2 detectors based on latest files from Aldo
* Merging select files from StripPairingTesting into StripPairingCleanUp so I can do pull request

* Clean up comments. Remove long debugging statements for readability

* Calling charge trapping correction function in chi square calculation and hit population

* Cleaning up comments

* Reformatting strip pairing module

* Update copywrite. Change name of module.

* Fixing documentation in header files

* Change how strip pairing chi square is read out to .dat file

* Adding comments for all the nested vectors

* Adding new version to StreamDat that reads out LV and HV energy of each hit

* Adding Sean's new strip pairing expos to chi square version of strip pairing

* Changing all instances of RedChiSquare to ReducedChiSquare for clarity

* Flags for multiple hits on a single strip are now defined on the MHit level

* Initializing m_StripHitMultipleTimesX and m_StripHitMultipleTimesY to false

* Changing StreamDAT version from Version 1 to Version 3

* Rebased and fixed merge conflict with strip pairing

---------

Co-authored-by: Julian Gerber <jmgerber@ucsd.edu>
@ckierans
Copy link
Collaborator Author

Sorry the commit history turned so messy. I had to resolve the merge conflict with Sean's PR that I merged this morning and obviously didn't do it in the cleanest way.

But all of your comments should be address. I cleaned up Sean's code a bit too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mask Metrology corrections

5 participants