From 8a97f0666b19625d4b2f4ff3e9e0d15728d42162 Mon Sep 17 00:00:00 2001
From: Tadej Novak <tadej.novak@cern.ch>
Date: Thu, 18 Jun 2020 07:38:59 +0000
Subject: [PATCH] Merge branch 'fixEigenWarningFromMMPrepDataStripErrors' into
 '21.3'

Writing longitudenal and transversal strip errors of MM seperatly in ESD instead of MatrixX

See merge request atlas/athena!33787

(cherry picked from commit 8640b9a29579f27b5a70918c4d507cd84146c082)

f85b7718  writing longitudenal and transversal strip errors seperatly in ESD instead of MatrixX
---
 .../MuonPrepRawData/MMPrepData_p1.h           |  2 +-
 .../src/MuonPrepRawData/MMPrepDataCnv_p1.cxx  |  6 ++--
 .../MuonPrepRawData/MMPrepData.h              |  7 ++++
 .../MuonPrepRawData/src/MMPrepData.cxx        | 34 +++++++++++++++++++
 4 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/MuonEventTPCnv/MuonPrepRawData/MMPrepData_p1.h b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/MuonEventTPCnv/MuonPrepRawData/MMPrepData_p1.h
index 125dd6e022aa..c86301e23595 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/MuonEventTPCnv/MuonPrepRawData/MMPrepData_p1.h
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/MuonEventTPCnv/MuonPrepRawData/MMPrepData_p1.h
@@ -46,7 +46,7 @@ namespace Muon
 	std::vector<int>       m_stripCharges;
 
 	std::vector<float>        m_stripDriftDist;
-	std::vector<Amg::MatrixX> m_stripDriftErrors;
+	std::vector<float> m_stripDriftErrors_0_0, m_stripDriftErrors_1_1;
 
   int m_author; // contains the info about which cluster builder tool produced the PRD
         
diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/src/MuonPrepRawData/MMPrepDataCnv_p1.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/src/MuonPrepRawData/MMPrepDataCnv_p1.cxx
index 4de8ba22719f..1c76cb98d20c 100644
--- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/src/MuonPrepRawData/MMPrepDataCnv_p1.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/src/MuonPrepRawData/MMPrepDataCnv_p1.cxx
@@ -27,6 +27,7 @@ createMMPrepData ( const Muon::MMPrepData_p1 *persObj,
     rdoList.push_back(rdoId);
   }
 
+
   auto cmat = CxxUtils::make_unique<Amg::MatrixX>(1,1);
   (*cmat)(0,0) = static_cast<double>(persObj->m_errorMat);
 
@@ -46,7 +47,7 @@ createMMPrepData ( const Muon::MMPrepData_p1 *persObj,
   // se the microTPC parameters
   data.setMicroTPC(persObj->m_angle, persObj->m_chisqProb);
   // set the drift distances
-  data.setDriftDist(persObj->m_stripDriftDist,persObj->m_stripDriftErrors);
+  data.setDriftDist(persObj->m_stripDriftDist,persObj->m_stripDriftErrors_0_0, persObj->m_stripDriftErrors_1_1);
   data.setAuthor(static_cast<Muon::MMPrepData::Author>(persObj->m_author));
 
   return data;
@@ -79,7 +80,8 @@ transToPers( const Muon::MMPrepData *transObj, Muon::MMPrepData_p1 *persObj, Msg
     persObj->m_stripCharges = transObj->stripCharges();
 
     persObj->m_stripDriftDist   = transObj->stripDriftDist();
-    persObj->m_stripDriftErrors = transObj->stripDriftErrors();
+    persObj->m_stripDriftErrors_0_0 = transObj->stripDriftErrors_0_0();
+    persObj->m_stripDriftErrors_1_1 = transObj->stripDriftErrors_1_1();
 
     persObj->m_author = static_cast<int>(transObj->author());
 
diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MMPrepData.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MMPrepData.h
index 09344d872053..fcf94dcdb2d1 100755
--- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MMPrepData.h
+++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MMPrepData.h
@@ -100,6 +100,9 @@ namespace Muon
     /** @brief set drift distances and uncertainties */
     void setDriftDist(const std::vector<float>& driftDist, const std::vector<Amg::MatrixX>& driftDistErrors);
 
+    // setter functions for the EventTPConverters
+    void setDriftDist(const std::vector<float>& driftDist, const std::vector<float>& stripDriftErrors_0_0, const std::vector<float>& stripDriftErrors_1_1);
+
     /** @brief Returns the global position*/
     const Amg::Vector3D& globalPosition() const;
 
@@ -136,6 +139,10 @@ namespace Muon
 
     /** @brief returns the list of drift distances */
     const std::vector<Amg::MatrixX>& stripDriftErrors() const;
+     
+    // getter functions for the EventTPConverters
+    const std::vector<float> stripDriftErrors_0_0() const;
+    const std::vector<float> stripDriftErrors_1_1() const;
     
     /** @brief Dumps information about the PRD*/
     MsgStream&    dump( MsgStream&    stream) const;
diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/src/MMPrepData.cxx b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/src/MMPrepData.cxx
index 67a2a0f867ba..6f83ab2217b8 100755
--- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/src/MMPrepData.cxx
+++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/src/MMPrepData.cxx
@@ -163,6 +163,22 @@ namespace Muon
     m_stripDriftErrors = driftDistErrors;
   }
 
+
+  void MMPrepData::setDriftDist(const std::vector<float>& driftDist, const std::vector<float>& stripDriftErrors_0_0, const std::vector<float>& stripDriftErrors_1_1){
+    m_stripDriftDist = driftDist;
+    
+    if(stripDriftErrors_0_0.size() != stripDriftErrors_1_1.size()){
+      //ATH_MSG_FATAL("trying to set MMPrepData uncertainties with unequal number of elements");
+    }
+    m_stripDriftErrors.clear();
+    for(uint i_strip = 0; i_strip < stripDriftErrors_1_1.size(); i_strip++){
+      Amg::MatrixX tmp(2,2);
+      tmp(0,0) = stripDriftErrors_0_0.at(i_strip);
+      tmp(1,1) = stripDriftErrors_1_1.at(i_strip);
+      m_stripDriftErrors.push_back(tmp);
+    }
+  }
+
   void MMPrepData::setAuthor(MMPrepData::Author author){
     m_author = author;
   }
@@ -235,6 +251,24 @@ namespace Muon
 
     return stream;
   }
+
+  const std::vector<float> MMPrepData::stripDriftErrors_0_0 () const {
+    std::vector<float> ret;
+    for (const Amg::MatrixX& mat: m_stripDriftErrors) {
+      ret.push_back(mat(0,0));
+    }
+    return ret;
+  }
+  
+  const std::vector<float> MMPrepData::stripDriftErrors_1_1 () const {
+    std::vector<float> ret;
+    for (const Amg::MatrixX& mat: m_stripDriftErrors) {
+      ret.push_back(mat(1,1));
+    }
+    return ret;
+  }
+
+
   //end of classdef
 }//end of ns
 
-- 
GitLab