Including Metrology Mask Rotation#74
Conversation
…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 <[email protected]>
|
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. |
| //! 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; |
| @@ -1,4 +1,4 @@ | |||
| /* | |||
| /*: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"); |
There was a problem hiding this comment.
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; |
src/MModuleDepthCalibration2024.cxx
Outdated
| 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; |
There was a problem hiding this comment.
Please initialize all variables in C/C++
src/MModuleDepthCalibration2024.cxx
Outdated
| double Zpos = 0.0; | ||
| double Xpos, Ypos, Zpos; | ||
|
|
||
| if ( m_MaskMetrologyEnabled ) { |
There was a problem hiding this comment.
Formatting: if (sdkjvghjk == true) {
src/MModuleDepthCalibration2024.cxx
Outdated
| 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 ){ |
src/MModuleDepthCalibration2024.cxx
Outdated
| //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 ){ |
There was a problem hiding this comment.
Formatting... There are a bunch of these... I no longer mention them but please fix
src/MModuleDepthCalibration2024.cxx
Outdated
| } else { | ||
| MString Line; | ||
| while( F.ReadLine( Line ) ){ | ||
| if ( Line.BeginsWith('#') ){ |
There was a problem hiding this comment.
if (Line.BeginsWith('#') == true) continue;
This makes it easier to read
src/MModuleDepthCalibration2024.cxx
Outdated
| } | ||
| else { | ||
| std::vector<MString> Tokens = Line.Tokenize(","); | ||
| if( Tokens.size() == 9 ){ |
There was a problem hiding this comment.
Dl we want an error message if it is not 9?
src/MModuleDepthCalibration2024.cxx
Outdated
| } | ||
|
|
||
| MXmlNode* MasKMetrologyNode = Node->GetNode("MaskMetrology"); | ||
| if( MasKMetrologyNode != NULL ){ |
There was a problem hiding this comment.
!= nullptr
NULL is just for C
src/MModuleDepthCalibration2024.cxx
Outdated
|
|
||
| MXmlNode* MasKMetrologyNode = Node->GetNode("MaskMetrology"); | ||
| if( MasKMetrologyNode != NULL ){ | ||
| m_MaskMetrologyEnabled = (bool) MasKMetrologyNode->GetValueAsInt(); |
src/MModuleDepthCalibration2024.cxx
Outdated
| } | ||
|
|
||
| MXmlNode* MaskMetrologyFileNameNode = Node->GetNode("MaskMetrologyFileName"); | ||
| if (MaskMetrologyFileNameNode != 0) { |
src/MModuleDepthCalibration2024.cxx
Outdated
| } | ||
|
|
||
| MXmlNode* UCSDOverrideNode = Node->GetNode("UCSDOverride"); | ||
| if( UCSDOverrideNode != NULL ){ |
src/MModuleDepthCalibration2024.cxx
Outdated
|
|
||
| MXmlNode* UCSDOverrideNode = Node->GetNode("UCSDOverride"); | ||
| if( UCSDOverrideNode != NULL ){ | ||
| m_UCSDOverride = (bool) UCSDOverrideNode->GetValueAsInt(); |
src/MModuleDepthCalibration2024.cxx
Outdated
| 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); |
src/MModuleDepthCalibration2024.cxx
Outdated
| 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); |
…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 <[email protected]>
* Set the geometry in SMEX DEE SubModules * Read detector dimensions from the geometry * Read detector radius from geometry
Merging in formating fixes after Andreas's review, rebased with develop/em
|
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. |
|
@zoglauer do you mind checking my changes here? I'd like to merge this PR since I cleaned up Sean's Depth Calibration code pretty substantially, but want to keep making progress on that module in a separate PR. I'm still waiting on the updated metrology file from Aldo to get this finalized, but the functionality should be right. |
| //! Select mask metrology file to load. This gives the translation and rotation for each strip in the detector frame | ||
| MGUIEFileSelector* m_MaskMetrologyFileSelector; | ||
|
|
||
| bool m_UseMaskMetCorr; |
There was a problem hiding this comment.
Please describe everything
src/MModuleDepthCalibration2024.cxx
Outdated
| } | ||
|
|
||
| if (m_MaskMetrologyEnabled == true) { | ||
| cout << "\n !!! Mask Metrology Enabled !!! \n" << endl; |
There was a problem hiding this comment.
Standard format please:
if (g_Verbosity >= c_Info) cout<<m_XmlTag<<": ..."<<endl;
And please use endl instead of \n
| // Det ID, Side (l,h), Strip ID (0-63), x_mm, y_mm, z_mm, roll_deg, pitch_deg, yaw_deg | ||
| MFile MetrologyFile; | ||
| if (MetrologyFile.Open(FileName) == false) { | ||
| cout << "ERROR in MModuleDepthCalibration2024::LoadMaskMetrologyFile: failed to open metrology file." << endl; |
There was a problem hiding this comment.
Standard format please:
if (g_Verbosity >= c_Error) cout<<m_XmlTag<<": ..."<<endl;
src/MModuleDepthCalibration2024.cxx
Outdated
| vector<double> LVStripMet = m_MaskMetrology[R_LVStrip]; | ||
| vector<double> HVStripMet = m_MaskMetrology[R_HVStrip]; | ||
|
|
||
| //Find the x position of two lines represented by the dominate strips: |
There was a problem hiding this comment.
White space:
// Find
// LVstrip
| // HVstrip is centered at (x,y,z) = (hv_strip_met[0], hv_strip_met[1], hv_strip_met[2]) | ||
| // and is approximately parallel to the x axis, but rotated at angle (hv_strip_met[5] - pi/2) | ||
| // around the z axis of the detector | ||
| double XIntercept = (HVStripMet[0]*tan((HVStripMet[5]-90)*TMath::DegToRad()) - LVStripMet[0]/tan(LVStripMet[5]*TMath::DegToRad()) - LVStripMet[1] + HVStripMet[1])/(tan((HVStripMet[5]-90)*TMath::DegToRad())-1/tan(LVStripMet[5]*TMath::DegToRad())); |
There was a problem hiding this comment.
Are you 100% sure there is never ever any possibility of a division by zero, or any other issues?
There was a problem hiding this comment.
Even if you are 99.999% sure, check for it...
Merged latest develop/em into metrology fix before updating PR
Updating remote origin/metrology_fix branch with latest PRs
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).