From 465a6f1049f8913c4007304588bf75fb5b00978b Mon Sep 17 00:00:00 2001 From: John Derek Chapman <chapman@hep.phy.cam.ac.uk> Date: Fri, 18 Jan 2019 10:46:29 +0000 Subject: [PATCH] Merge branch '21.3-ATLASSIM-3903' into '21.3' SCT RDO updates to reduce size for overlay MC (ATLASSIM-3903) See merge request atlas/athena!20374 (cherry picked from commit e0854f094e9c43e8b55ca5c57cf2e0ca1f2af2a2) 007a644d Create SCT3_RawData_p4 3590a454 Create SCT3_RawData_p4 6d958f55 Store row number (3 bits) and strip number (13 bits) instead of Identifier (64 bits) fe329d46 Bug fixes a2642511 Add comments a16b4d8a Code cleanup 8425f003 Comment out unused variable fd2cdecf Use unique_ptr 0434a27d Use unique_ptr 1d1963a4 Code cleanup --- .../SCT_Digitization/src/SCT_FrontEnd.cxx | 49 +++-- .../InDetEventAthenaPoolCnvDict.h | 4 +- .../InDetEventAthenaPool/SCT3_RawData_p4.h | 39 ++++ .../SCT_RawDataContainer_p4.h | 45 +++++ .../InDetEventAthenaPool/selection.xml | 3 + .../src/SCT1_RawDataCnv_p1.cxx | 14 +- .../src/SCT1_RawDataCnv_p2.cxx | 14 +- .../src/SCT3_RawDataCnv_p1.cxx | 32 +-- .../src/SCT3_RawDataCnv_p1.h | 4 +- .../src/SCT3_RawDataCnv_p2.cxx | 22 +-- .../src/SCT3_RawDataCnv_p2.h | 4 +- .../src/SCT3_RawDataCnv_p3.cxx | 22 +-- .../src/SCT3_RawDataCnv_p3.h | 4 +- .../src/SCT3_RawDataCnv_p4.cxx | 49 +++++ .../src/SCT3_RawDataCnv_p4.h | 33 ++++ .../src/SCT_ClusterContainerCnv.cxx | 10 +- .../src/SCT_RDO_ContainerCnv.cxx | 39 ++-- .../src/SCT_RDO_ContainerCnv.h | 8 +- .../src/SCT_RawDataContainerCnv_p1.cxx | 40 ++-- .../src/SCT_RawDataContainerCnv_p1.h | 8 +- .../src/SCT_RawDataContainerCnv_p2.cxx | 45 +++-- .../src/SCT_RawDataContainerCnv_p2.h | 8 +- .../src/SCT_RawDataContainerCnv_p3.cxx | 45 ++--- .../src/SCT_RawDataContainerCnv_p3.h | 12 +- .../src/SCT_RawDataContainerCnv_p4.cxx | 182 ++++++++++++++++++ .../src/SCT_RawDataContainerCnv_p4.h | 47 +++++ .../src/SCT_ClusteringTool.cxx | 24 +-- .../src/TotPixelClusterSplitter.cxx | 2 +- 28 files changed, 614 insertions(+), 194 deletions(-) create mode 100644 InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT3_RawData_p4.h create mode 100644 InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT_RawDataContainer_p4.h create mode 100644 InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.cxx create mode 100644 InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.h create mode 100644 InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.cxx create mode 100644 InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.h diff --git a/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx b/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx index ee40373e143..9dd6704efc6 100755 --- a/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx +++ b/InnerDetector/InDetDigitization/SCT_Digitization/src/SCT_FrontEnd.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "SCT_FrontEnd.h" @@ -21,10 +21,10 @@ // C++ Standard Library #include <algorithm> +#include <iostream> // #define SCT_DIG_DEBUG -#include <iostream> using namespace std; // --------------- @@ -1383,25 +1383,36 @@ StatusCode SCT_FrontEnd::doClustering(SiChargedDiodeCollection &collection) } while (strip < m_strip_max); } else { - do { // Expanded read out mode, one RDO/strip per cluster - if (m_StripHitsOnWafer[strip] > 0) { - clusterSize = 1; - hitStrip = m_sct_id->strip_id(collection.identify(), strip); - SiChargedDiode &HitDiode = *(collection.find(hitStrip)); - - SiHelper::SetStripNum(HitDiode, clusterSize); - - + // Expanded read out mode, basically one RDO/strip per cluster + // But if consecutively fired strips have the same time bin, those are converted into one cluster. + do { + clusterSize = 1; + if (m_StripHitsOnWafer[strip] > 0) { + hitStrip = m_sct_id->strip_id(collection.identify(), strip); + SiChargedDiode& hitDiode = *(collection.find(hitStrip)); + int timeBin = SiHelper::GetTimeBin(hitDiode); + SiChargedDiode* previousHitDiode = &hitDiode; + // Check if consecutively fired strips have the same time bin + for (int newStrip=strip+1; newStrip<m_strip_max; newStrip++) { + if (not (m_StripHitsOnWafer[newStrip]>0)) break; + Identifier newHitStrip = m_sct_id->strip_id(collection.identify(), newStrip); + SiChargedDiode& newHitDiode = *(collection.find(newHitStrip)); + if (timeBin!=SiHelper::GetTimeBin(newHitDiode)) break; + SiHelper::ClusterUsed(newHitDiode, true); + previousHitDiode->setNextInCluster(&newHitDiode); + previousHitDiode = &newHitDiode; + clusterSize++; + } + SiHelper::SetStripNum(hitDiode, clusterSize); #ifdef SCT_DIG_DEBUG - ATH_MSG_DEBUG("RDO Strip = " << strip << ", tbin = " << - SiHelper::GetTimeBin(HitDiode) << - ", HitInfo(1=real, 2=crosstalk, 3=noise): " << - m_StripHitsOnWafer[strip]); + ATH_MSG_DEBUG("RDO Strip = " << strip << ", tbin = " << + SiHelper::GetTimeBin(hitDiode) << + ", HitInfo(1=real, 2=crosstalk, 3=noise): " << + m_StripHitsOnWafer[strip]); #endif - } - ++strip; // !< This is the starting point of the next - // cluster within this collection - } while (strip < m_strip_max); + } + strip += clusterSize; // If more than one strip fires, those following strips are skipped. + } while (strip < m_strip_max); } // clusters below threshold, only from pre-digits that existed before no diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/InDetEventAthenaPoolCnvDict.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/InDetEventAthenaPoolCnvDict.h index 6603d9ebcde..db71486c7d0 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/InDetEventAthenaPoolCnvDict.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/InDetEventAthenaPoolCnvDict.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef INDETEVENTATHENAPOOLDICT_H @@ -14,12 +14,14 @@ #include "InDetEventAthenaPool/SCT3_RawData_p1.h" #include "InDetEventAthenaPool/SCT3_RawData_p2.h" #include "InDetEventAthenaPool/SCT3_RawData_p3.h" +#include "InDetEventAthenaPool/SCT3_RawData_p4.h" #include "InDetEventAthenaPool/InDetRawDataCollection_p1.h" #include "InDetEventAthenaPool/InDetRawDataContainer_p1.h" #include "InDetEventAthenaPool/InDetRawDataContainer_p2.h" #include "InDetEventAthenaPool/SCT_RawDataContainer_p1.h" #include "InDetEventAthenaPool/SCT_RawDataContainer_p2.h" #include "InDetEventAthenaPool/SCT_RawDataContainer_p3.h" +#include "InDetEventAthenaPool/SCT_RawDataContainer_p4.h" namespace InDetEventAthenaPoolCnvDict { diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT3_RawData_p4.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT3_RawData_p4.h new file mode 100644 index 00000000000..c2bad82a25a --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT3_RawData_p4.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/** S.Oda, Oct 2018 + * replace Identifier::value_type by Identifier32::value_type and + unsigned int by unsigned short for + for the premixing samples for Overlay MC. */ + +#ifndef SCT3_RAWDATA_P4_H +#define SCT3_RAWDATA_P4_H + +#include "Identifier/Identifier32.h" + +class SCT3_RawData_p4 { + public: + SCT3_RawData_p4() {}; +// List of Cnv classes that convert this into Rdo objects + friend class SCT3_RawDataCnv_p4; + //private: + unsigned short m_rowStrip; // row and strip numbers from Identifier. Bits 0-12 for strip, Bits 13-15 for row + unsigned short m_word; // raw data word. Bits 0-10 for group size, Bits 11-13 for time bin + + void setRowStrip(const int row, const int strip) { + m_rowStrip = (static_cast<unsigned int>(strip) & 0x1FFF); + m_rowStrip |= ((static_cast<unsigned int>(row) & 0x7) << 13); + } + + int getRow() const { + return ((m_rowStrip >> 13) & 0x7); + } + + int getStrip() const { + return (m_rowStrip & 0x1FFF); + } + +}; + +#endif // SCT3_RAWDATA_P4_H diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT_RawDataContainer_p4.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT_RawDataContainer_p4.h new file mode 100644 index 00000000000..30983c109f9 --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/SCT_RawDataContainer_p4.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCT_RAWDATACONTAINER_P4_H +#define SCT_RAWDATACONTAINER_P4_H + +/** + +* Persistent represenation of an SCT_RawDataContainer. +* New version to deal with SCT_RawData_p4 +* Susumu Oda Oct 2018. + +*/ + +#include <vector> +#include <string> +#include "InDetEventAthenaPool/SCT3_RawData_p4.h" +#include "InDetEventAthenaPool/InDetRawData_p2.h" +#include "InDetEventAthenaPool/InDetRawDataCollection_p1.h" + + +class SCT_RawDataContainer_p4 +{ + public: +/// Default constructor + SCT_RawDataContainer_p4(); + friend class SCT_RawDataContainerCnv_p4; + private: + std::vector<InDetRawDataCollection_p1> m_collections; + std::vector<InDetRawData_p2> m_rawdata; + std::vector<SCT3_RawData_p4> m_sct3data; + /** because ROOT isn't good at storing vectors of vectors, + * store the individual strip errors in the persistent container + * rather than in the persistent SCT3_RawData_p4 itself.. + */ +}; + + +/** inlines */ + +inline +SCT_RawDataContainer_p4::SCT_RawDataContainer_p4() {} + +#endif // SCT_RAWDATACONTAINER_P4_H diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/selection.xml b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/selection.xml index 3583eae8a19..fc5711ae6fe 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/selection.xml +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/InDetEventAthenaPool/selection.xml @@ -19,16 +19,19 @@ <class name="SCT3_RawData_p1" /> <class name="SCT3_RawData_p2" /> <class name="SCT3_RawData_p3" /> + <class name="SCT3_RawData_p4" /> <class name="InDetRawDataCollection_p1" /> <class name="std::vector<InDetRawData_p1>" /> <class name="std::vector<InDetRawData_p2>" /> <class name="std::vector<SCT3_RawData_p1>" /> <class name="std::vector<SCT3_RawData_p2>" /> <class name="std::vector<SCT3_RawData_p3>" /> + <class name="std::vector<SCT3_RawData_p4>" /> <class name="InDetRawDataContainer_p1" id="DA76970C-E019-43D2-B2F9-25660DCECD9D" /> <class name="InDetRawDataContainer_p2" id="7138342E-0A80-4A32-A387-2842A01C2539" /> <class name="SCT_RawDataContainer_p1" id="8E13963E-13E5-4D10-AA8B-73F00AFF8FA8" /> <class name="SCT_RawDataContainer_p2" id="D1258125-2CBA-476E-8578-E09D54F477E1" /> <class name="SCT_RawDataContainer_p3" id="5FBC8D4D-7B4D-433A-8487-0EA0C870CBDB" /> + <class name="SCT_RawDataContainer_p4" id="6C7540BE-E85C-4777-BC1C-A9FF11460F54" /> <class name="std::vector<InDetRawDataCollection_p1>" /> </lcgdict> diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p1.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p1.cxx index ee03f505cef..c0a274ca63a 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p1.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p1.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT1_RawData.h" @@ -17,15 +17,15 @@ void SCT1_RawDataCnv_p1::persToTrans(const InDetRawData_p1* persObj, SCT1_RawData* transObj, MsgStream &log) { - MSG_VERBOSE(log,"SCT1_RawDataCnv_p1::persToTrans called "); - *transObj = SCT1_RawData (Identifier(persObj->m_rdoId), - persObj->m_word); + MSG_VERBOSE(log,"SCT1_RawDataCnv_p1::persToTrans called "); + *transObj = SCT1_RawData(Identifier(persObj->m_rdoId), + persObj->m_word); } void SCT1_RawDataCnv_p1::transToPers(const SCT1_RawData* transObj, InDetRawData_p1* persObj, MsgStream &log) { - MSG_VERBOSE(log,"SCT1_RawDataCnv_p1::transToPers called "); - persObj->m_rdoId = transObj->identify().get_compact(); - persObj->m_word = transObj->getWord(); + MSG_VERBOSE(log,"SCT1_RawDataCnv_p1::transToPers called "); + persObj->m_rdoId = transObj->identify().get_compact(); + persObj->m_word = transObj->getWord(); } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p2.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p2.cxx index e2d15cb78e9..3890234528d 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p2.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT1_RawDataCnv_p2.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT1_RawData.h" @@ -17,15 +17,15 @@ void SCT1_RawDataCnv_p2::persToTrans(const InDetRawData_p2* persObj, SCT1_RawData* transObj, MsgStream &log) { - MSG_VERBOSE(log,"SCT1_RawDataCnv_p2::persToTrans called "); - *transObj = SCT1_RawData (Identifier(persObj->m_rdoId), - persObj->m_word); + MSG_VERBOSE(log,"SCT1_RawDataCnv_p2::persToTrans called "); + *transObj = SCT1_RawData(Identifier(persObj->m_rdoId), + persObj->m_word); } void SCT1_RawDataCnv_p2::transToPers(const SCT1_RawData* transObj, InDetRawData_p2* persObj, MsgStream &log) { - MSG_VERBOSE(log,"SCT1_RawDataCnv_p2::transToPers called "); - persObj->m_rdoId = transObj->identify().get_compact(); - persObj->m_word = transObj->getWord(); + MSG_VERBOSE(log,"SCT1_RawDataCnv_p2::transToPers called "); + persObj->m_rdoId = transObj->identify().get_compact(); + persObj->m_word = transObj->getWord(); } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.cxx index c3c7bb8dfff..1aa3f480158 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT3_RawData.h" @@ -13,25 +13,25 @@ void -SCT3_RawDataCnv_p1::persToTrans(const SCT3_RawData_p1* persObj, SCT3_RawData* transObj, MsgStream &log) +SCT3_RawDataCnv_p1::persToTrans(const SCT3_RawData_p1* persObj, SCT3_RawData* transObj, MsgStream& log) { -//#ifdef SCT_DEBUG - MSG_DEBUG(log,"SCT3_RawDataCnv_p1::persToTrans called "); -//#endif - std::vector<int> errHit; - errHit.reserve(20); - for (int ii=0; ii<20; ii++) { - if (persObj->m_errCH[ii] > 0 ) - errHit.push_back(ii); - } + MSG_DEBUG(log,"SCT3_RawDataCnv_p1::persToTrans called "); - *transObj = SCT3_RawData (Identifier(persObj->m_rdoId), - persObj->m_word, - std::move(errHit)); + std::vector<int> errHit; + errHit.reserve(20); + for (int ii=0; ii<20; ii++) { + if (persObj->m_errCH[ii] > 0) { + errHit.push_back(ii); + } + } + + *transObj = SCT3_RawData(Identifier(persObj->m_rdoId), + persObj->m_word, + std::move(errHit)); } void -SCT3_RawDataCnv_p1::transToPers(const SCT3_RawData*, SCT3_RawData_p1*, MsgStream &log) +SCT3_RawDataCnv_p1::transToPers(const SCT3_RawData*, SCT3_RawData_p1*, MsgStream& log) { - log << MSG::ERROR << "SCT3_RawDataCnv_p1::transToPers is deprecated. " << endreq; + log << MSG::ERROR << "SCT3_RawDataCnv_p1::transToPers is deprecated. " << endmsg; } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.h index fdc97de60ab..874fb5cac6a 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p1.h @@ -23,8 +23,8 @@ class SCT3_RawDataCnv_p1 : public T_AthenaPoolTPCnvBase<SCT3_RawData, SCT3_RawD public: SCT3_RawDataCnv_p1() {} - virtual void persToTrans(const SCT3_RawData_p1* persObj, SCT3_RawData* transObj, MsgStream &log); - virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p1* persObj, MsgStream &log); + virtual void persToTrans(const SCT3_RawData_p1* persObj, SCT3_RawData* transObj, MsgStream& log); + virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p1* persObj, MsgStream& log); }; diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.cxx index 8d21d50e80d..f246c5bf743 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT3_RawData.h" @@ -15,24 +15,20 @@ void -SCT3_RawDataCnv_p2::persToTrans(const SCT3_RawData_p2* persObj, SCT3_RawData* transObj, MsgStream &log) +SCT3_RawDataCnv_p2::persToTrans(const SCT3_RawData_p2* persObj, SCT3_RawData* transObj, MsgStream& log) { -//#ifdef SCT_DEBUG MSG_DEBUG(log,"SCT3_RawDataCnv_p2::persToTrans called "); -//#endif - *transObj = SCT3_RawData (Identifier(persObj->m_rdoId), - persObj->m_word, - std::vector<int>()); + *transObj = SCT3_RawData(Identifier(persObj->m_rdoId), + persObj->m_word, + std::vector<int>()); } void -SCT3_RawDataCnv_p2::transToPers(const SCT3_RawData* transObj, SCT3_RawData_p2* persObj, MsgStream &log) +SCT3_RawDataCnv_p2::transToPers(const SCT3_RawData* transObj, SCT3_RawData_p2* persObj, MsgStream& log) { -//#ifdef SCT_DEBUG - MSG_DEBUG(log,"SCT3_RawDataCnv_p2::transToPers called "); -//#endif - persObj->m_rdoId = transObj->identify().get_compact(); - persObj->m_word = transObj->getWord(); + MSG_DEBUG(log,"SCT3_RawDataCnv_p2::transToPers called "); + persObj->m_rdoId = transObj->identify().get_compact(); + persObj->m_word = transObj->getWord(); } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.h index bfe7c90e058..f22ae0a59d2 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p2.h @@ -22,8 +22,8 @@ class SCT3_RawDataCnv_p2 : public T_AthenaPoolTPCnvBase<SCT3_RawData, SCT3_RawD public: SCT3_RawDataCnv_p2() {} - virtual void persToTrans(const SCT3_RawData_p2* persObj, SCT3_RawData* transObj, MsgStream &log); - virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p2* persObj, MsgStream &log); + virtual void persToTrans(const SCT3_RawData_p2* persObj, SCT3_RawData* transObj, MsgStream& log); + virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p2* persObj, MsgStream& log); }; diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.cxx index d1dd8a61cb4..e1796fcee86 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT3_RawData.h" @@ -15,24 +15,20 @@ void -SCT3_RawDataCnv_p3::persToTrans(const SCT3_RawData_p3* persObj, SCT3_RawData* transObj, MsgStream &log) +SCT3_RawDataCnv_p3::persToTrans(const SCT3_RawData_p3* persObj, SCT3_RawData* transObj, MsgStream& log) { -//#ifdef SCT_DEBUG MSG_DEBUG(log,"SCT3_RawDataCnv_p3::persToTrans called "); -//#endif - *transObj = SCT3_RawData (Identifier(persObj->m_rdoId), - persObj->m_word, - std::vector<int>()); + *transObj = SCT3_RawData(Identifier(persObj->m_rdoId), + persObj->m_word, + std::vector<int>()); } void -SCT3_RawDataCnv_p3::transToPers(const SCT3_RawData* transObj, SCT3_RawData_p3* persObj, MsgStream &log) +SCT3_RawDataCnv_p3::transToPers(const SCT3_RawData* transObj, SCT3_RawData_p3* persObj, MsgStream& log) { -//#ifdef SCT_DEBUG - MSG_DEBUG(log,"SCT3_RawDataCnv_p3::transToPers called "); -//#endif - persObj->m_rdoId = transObj->identify().get_compact(); - persObj->m_word = transObj->getWord(); + MSG_DEBUG(log,"SCT3_RawDataCnv_p3::transToPers called "); + persObj->m_rdoId = transObj->identify().get_compact(); + persObj->m_word = transObj->getWord(); } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.h index 39f409d243a..1db345d06eb 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p3.h @@ -22,8 +22,8 @@ class SCT3_RawDataCnv_p3 : public T_AthenaPoolTPCnvBase<SCT3_RawData, SCT3_RawD public: SCT3_RawDataCnv_p3() {} - virtual void persToTrans(const SCT3_RawData_p3* persObj, SCT3_RawData* transObj, MsgStream &log); - virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p3* persObj, MsgStream &log); + virtual void persToTrans(const SCT3_RawData_p3* persObj, SCT3_RawData* transObj, MsgStream& log); + virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p3* persObj, MsgStream& log); }; diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.cxx new file mode 100644 index 00000000000..934dfa9a440 --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.cxx @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "SCT3_RawDataCnv_p4.h" + +#include "MsgUtil.h" + +#include "InDetEventAthenaPool/SCT3_RawData_p4.h" +#include "InDetIdentifier/SCT_ID.h" +#include "InDetRawData/SCT3_RawData.h" + +#include <vector> + +void +SCT3_RawDataCnv_p4::persToTrans(const SCT3_RawData_p4* persObj, SCT3_RawData* transObj, MsgStream& log) +{ + MSG_DEBUG(log, "SCT3_RawDataCnv_p4::persToTrans called"); + + // Convert unsigned short to unsigned int + // P: Bits 0-10 for group size, Bits 11-13 for time bin + // T: Bits 0-10 for group size, Bits 22-24 for time bin + unsigned int word = static_cast<unsigned int>(persObj->m_word); + word = ((word & 0x7FF) | (((word >> 11) & 0x7) << 22)); + + // Convert row and strip numbers to strip Identifeir using wafer Identifer + Identifier stripId = m_sctId->strip_id(m_waferId, + persObj->getRow(), + persObj->getStrip()); + + *transObj = SCT3_RawData(stripId, + word, + std::vector<int>()); +} + +void +SCT3_RawDataCnv_p4::transToPers(const SCT3_RawData* transObj, SCT3_RawData_p4* persObj, MsgStream& log) +{ + MSG_DEBUG(log, "SCT3_RawDataCnv_p4::transToPers called"); + // Set row and strip numbers + persObj->setRowStrip(m_sctId->row(transObj->identify()), m_sctId->strip(transObj->identify())); + + // Convert unsigned int to unsigned short + // T: Bits 0-10 for group size, Bits 22-24 for time bin + // P: Bits 0-10 for group size, Bits 11-13 for time bin + unsigned int word = transObj->getWord(); + word = ((word & 0x7FF) | (((word >> 22) & 0x7) << 11)); + persObj->m_word = static_cast<unsigned short>(word); +} diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.h new file mode 100644 index 00000000000..f8cc533084c --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT3_RawDataCnv_p4.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCT3_RAWDATACNV_P4_H +#define SCT3_RAWDATACNV_P4_H + +/* +Transient/Persistent converter for SCT3_RawData class +*/ + +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" + +#include "Identifier/Identifier.h" +#include "InDetRawData/SCT3_RawData.h" +#include "InDetEventAthenaPool/SCT3_RawData_p4.h" + +class MsgStream; +class SCT_ID; + +class SCT3_RawDataCnv_p4 : public T_AthenaPoolTPCnvBase<SCT3_RawData, SCT3_RawData_p4> +{ + public: + SCT3_RawDataCnv_p4(const SCT_ID* sctId) { m_sctId = sctId; } + virtual void persToTrans(const SCT3_RawData_p4* persObj, SCT3_RawData* transObj, MsgStream& log); + virtual void transToPers(const SCT3_RawData* transObj, SCT3_RawData_p4* persObj, MsgStream& log); + void setWaferId(const Identifier waferId) { m_waferId = waferId; } + private: + const SCT_ID* m_sctId; + Identifier m_waferId; +}; + +#endif // SCT3_RAWDATACNV_P4_H diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_ClusterContainerCnv.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_ClusterContainerCnv.cxx index e62cb8a7747..72014c57ee1 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_ClusterContainerCnv.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_ClusterContainerCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ @@ -42,7 +42,7 @@ StatusCode SCT_ClusterContainerCnv::initialize() { } // get DetectorStore service - StoreGateSvc *detStore(0); + StoreGateSvc* detStore(nullptr); if (service("DetectorStore", detStore).isFailure()) { ATH_MSG_FATAL("DetectorStore service not found !"); return StatusCode::FAILURE; @@ -51,7 +51,7 @@ StatusCode SCT_ClusterContainerCnv::initialize() { } // Get the SCT helper from the detector store - const SCT_ID* idhelper(0); + const SCT_ID* idhelper(nullptr); if (detStore->retrieve(idhelper, "SCT_ID").isFailure()) { ATH_MSG_FATAL("Could not get SCT_ID helper !"); return StatusCode::FAILURE; @@ -79,7 +79,7 @@ InDet::SCT_ClusterContainer* SCT_ClusterContainerCnv::createTransient() { static pool::Guid p3_guid("623F5836-369F-4A94-9DD4-DAD728E93C13"); // with SCT_Cluster_p3 //ATH_MSG_DEBUG("createTransient(): main converter"); - InDet::SCT_ClusterContainer* p_collection(0); + InDet::SCT_ClusterContainer* p_collection(nullptr); if( compareClassGuid(p3_guid) ) { //ATH_MSG_DEBUG("createTransient(): T/P version 3 detected"); std::unique_ptr< SCT_ClusterContainer_PERS > p_coll( poolReadObject< SCT_ClusterContainer_PERS >() ); @@ -115,7 +115,7 @@ InDet::SCT_ClusterContainer* SCT_ClusterContainerCnv::createTransient() { SCT_ClusterContainer_PERS* SCT_ClusterContainerCnv::createPersistent (InDet::SCT_ClusterContainer* transCont) { - SCT_ClusterContainer_PERS *sctdc_p= m_TPConverter_p3.createPersistent( transCont, msg() ); + SCT_ClusterContainer_PERS* sctdc_p= m_TPConverter_p3.createPersistent( transCont, msg() ); return sctdc_p; } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.cxx index 0441369eeca..bbfcd3ec710 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "SCT_RDO_ContainerCnv.h" @@ -15,7 +15,7 @@ //================================================================ namespace { #ifdef SCT_DEBUG - std::string shortPrint(const SCT_RDO_Container *main_input_SCT, unsigned maxprint=25) { + std::string shortPrint(const SCT_RDO_Container* main_input_SCT, unsigned maxprint=25) { std::ostringstream os; if(main_input_SCT) { for(unsigned i=0; i<maxprint; i++) { @@ -64,7 +64,7 @@ StatusCode SCT_RDO_ContainerCnv::initialize() { } // get DetectorStore service - StoreGateSvc *detStore(0); + StoreGateSvc* detStore(nullptr); if (service("DetectorStore", detStore).isFailure()) { ATH_MSG_FATAL("DetectorStore service not found !"); return StatusCode::FAILURE; @@ -73,7 +73,7 @@ StatusCode SCT_RDO_ContainerCnv::initialize() { } // Get the sct helper from the detector store - const SCT_ID* idhelper(0); + const SCT_ID* idhelper(nullptr); if (detStore->retrieve(idhelper, "SCT_ID").isFailure()) { ATH_MSG_FATAL("Could not get SCT_ID helper !"); return StatusCode::FAILURE; @@ -86,6 +86,7 @@ StatusCode SCT_RDO_ContainerCnv::initialize() { m_converter_SCT_TP1.initialize(idhelper); m_converter_SCT_TP2.initialize(idhelper); m_converter_SCT_TP3.initialize(idhelper); + m_converter_SCT_TP4.initialize(idhelper); m_converter_PERS.initialize(idhelper); // ATH_MSG_DEBUG("Converter initialized"); @@ -110,7 +111,7 @@ SCT_RDO_Container_PERS* SCT_RDO_ContainerCnv::createPersistent(SCT_RDO_Container if(it_Coll != it_CollEnd) { while (it_Coll != it_CollEnd && (*it_Coll)->size() == 0 ) it_Coll++; if(it_Coll != it_CollEnd) { - const SCT_RDORawData *test((**it_Coll)[0]); + const SCT_RDORawData* test((**it_Coll)[0]); if(dynamic_cast<const SCT1_RawData*>(test) != 0 ) { //ATH_MSG_DEBUG("Found container with SCT1_RawData concrete type objects"); converter_num=1; @@ -129,7 +130,7 @@ SCT_RDO_Container_PERS* SCT_RDO_ContainerCnv::createPersistent(SCT_RDO_Container } // Switch facility depending on the concrete data type of the contained objects // Should do by getting the type_info of one of the contained objects - SCT_RDO_Container_PERS *persObj(0); + SCT_RDO_Container_PERS* persObj(nullptr); if(converter_num == 1 || converter_num == 3) { m_converter_PERS.setType(converter_num); persObj = m_converter_PERS.createPersistent( transCont, msg() ); @@ -150,17 +151,31 @@ SCT_RDO_Container* SCT_RDO_ContainerCnv::createTransient() { static pool::Guid SCT_TP1_guid("8E13963E-13E5-4D10-AA8B-73F00AFF8FA8"); // for t/p separated version with SCT_RawDataContainer_p1 static pool::Guid SCT_TP2_guid("D1258125-2CBA-476E-8578-E09D54F477E1"); // for t/p separated version with SCT_RawDataContainer_p2 static pool::Guid SCT_TP3_guid("5FBC8D4D-7B4D-433A-8487-0EA0C870CBDB"); // for t/p separated version with SCT_RawDataContainer_p3 + static pool::Guid SCT_TP4_guid("6C7540BE-E85C-4777-BC1C-A9FF11460F54"); // for t/p separated version with SCT_RawDataContainer_p4 #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(): main converter"); #endif - if( compareClassGuid(SCT_TP3_guid) ) { + if( compareClassGuid(SCT_TP4_guid) ) { +#ifdef SCT_DEBUG + ATH_MSG_DEBUG("createTransient(): New TP version - TP4 branch"); +#endif + + std::unique_ptr< SCT_RawDataContainer_p4 > col_vect( poolReadObject< SCT_RawDataContainer_p4 >() ); + SCT_RDO_Container* res = m_converter_SCT_TP4.createTransient( col_vect.get(), msg() ); +#ifdef SCT_DEBUG + ATH_MSG_DEBUG("createTransient(), TP4 branch: returns TRANS = "<<shortPrint(res)); +#endif + return res; + + } + else if( compareClassGuid(SCT_TP3_guid) ) { #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(): New TP version - TP3 branch"); #endif std::unique_ptr< SCT_RawDataContainer_p3 > col_vect( poolReadObject< SCT_RawDataContainer_p3 >() ); - SCT_RDO_Container *res = m_converter_SCT_TP3.createTransient( col_vect.get(), msg() ); + SCT_RDO_Container* res = m_converter_SCT_TP3.createTransient( col_vect.get(), msg() ); #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(), TP3 branch: returns TRANS = "<<shortPrint(res)); #endif @@ -173,7 +188,7 @@ SCT_RDO_Container* SCT_RDO_ContainerCnv::createTransient() { #endif std::unique_ptr< SCT_RawDataContainer_p2 > col_vect( poolReadObject< SCT_RawDataContainer_p2 >() ); - SCT_RDO_Container *res = m_converter_SCT_TP2.createTransient( col_vect.get(), msg() ); + SCT_RDO_Container* res = m_converter_SCT_TP2.createTransient( col_vect.get(), msg() ); #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(), TP2 branch: returns TRANS = "<<shortPrint(res)); #endif @@ -185,7 +200,7 @@ SCT_RDO_Container* SCT_RDO_ContainerCnv::createTransient() { ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch"); #endif std::unique_ptr< SCT_RawDataContainer_p1 > col_vect( poolReadObject< SCT_RawDataContainer_p1 >() ); - SCT_RDO_Container *res = m_converter_SCT_TP1.createTransient( col_vect.get(), msg() ); + SCT_RDO_Container* res = m_converter_SCT_TP1.createTransient( col_vect.get(), msg() ); #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res)); #endif @@ -197,7 +212,7 @@ SCT_RDO_Container* SCT_RDO_ContainerCnv::createTransient() { ATH_MSG_DEBUG("createTransient(): New TP version - TP1 branch"); std::unique_ptr< InDetRawDataContainer_p1 > col_vect( poolReadObject< InDetRawDataContainer_p1 >() ); - SCT_RDO_Container *res = m_converter_TP1.createTransient( col_vect.get(), msg() ); + SCT_RDO_Container* res = m_converter_TP1.createTransient( col_vect.get(), msg() ); #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(), TP1 branch: returns TRANS = "<<shortPrint(res)); #endif @@ -210,7 +225,7 @@ SCT_RDO_Container* SCT_RDO_ContainerCnv::createTransient() { ATH_MSG_DEBUG("createTransient(): Old input file - p0 branch"); #endif std::unique_ptr< SCT_RDO_Container_p0 > col_vect( poolReadObject< SCT_RDO_Container_p0 >() ); - SCT_RDO_Container *res = m_converter_p0.createTransient( col_vect.get(), msg() ); + SCT_RDO_Container* res = m_converter_p0.createTransient( col_vect.get(), msg() ); #ifdef SCT_DEBUG ATH_MSG_DEBUG("createTransient(), p0 branch: returns TRANS = "<<shortPrint(res)); #endif diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.h index 5ae704fe943..b68c4d9caf4 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RDO_ContainerCnv.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef SCT_RDO_CONTAINERCNV_H @@ -18,10 +18,11 @@ #include "SCT_RawDataContainerCnv_p1.h" #include "SCT_RawDataContainerCnv_p2.h" #include "SCT_RawDataContainerCnv_p3.h" +#include "SCT_RawDataContainerCnv_p4.h" // the latest persistent representation type of DataCollection: -typedef SCT_RawDataContainer_p3 SCT_RDO_Container_PERS; -typedef SCT_RawDataContainerCnv_p3 SCT_RDO_ContainerCnv_PERS; +typedef SCT_RawDataContainer_p4 SCT_RDO_Container_PERS; +typedef SCT_RawDataContainerCnv_p4 SCT_RDO_ContainerCnv_PERS; typedef T_AthenaPoolCustomCnv<SCT_RDO_Container, SCT_RDO_Container_PERS > SCT_RDO_ContainerCnvBase; @@ -35,6 +36,7 @@ class SCT_RDO_ContainerCnv : public SCT_RDO_ContainerCnvBase { SCT_RawDataContainerCnv_p1 m_converter_SCT_TP1; SCT_RawDataContainerCnv_p2 m_converter_SCT_TP2; SCT_RawDataContainerCnv_p3 m_converter_SCT_TP3; + SCT_RawDataContainerCnv_p4 m_converter_SCT_TP4; SCT_RDO_ContainerCnv_PERS m_converter_PERS; // Should not be needed at some point. diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.cxx index 37a75257080..03431ba76aa 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT3_RawData.h" @@ -13,6 +13,8 @@ #include "SCT3_RawDataCnv_p1.h" #include "SCT_RawDataContainerCnv_p1.h" +#include <memory> + void SCT_RawDataContainerCnv_p1::transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p1* persCont, MsgStream& log) { @@ -57,7 +59,7 @@ void SCT_RawDataContainerCnv_p1::transToPers(const SCT_RDO_Container* transCont, chanEnd += collection.size(); InDetRawDataCollection_p1& pcollection = persCont->m_collections[collIndex]; pcollection.m_id = collection.identify().get_compact(); - pcollection.m_hashId = (unsigned int) collection.identifyHash(); + pcollection.m_hashId = static_cast<unsigned int>(collection.identifyHash()); pcollection.m_begin = chanBegin; pcollection.m_end = chanEnd; // MSG_VERBOSE(log,"Writing collection number " << collIndex << " with hash" << pcollection.m_hashId); @@ -81,7 +83,7 @@ void SCT_RawDataContainerCnv_p1::transToPers(const SCT_RDO_Container* transCont, // MSG_DEBUG(log," *** Writing SCT_RDO_Container (SCT1/3_RawData concrete type)"); } -void SCT_RawDataContainerCnv_p1::persToTrans(const SCT_RawDataContainer_p1* persCont, SCT_RDO_Container* transCont, MsgStream &log) +void SCT_RawDataContainerCnv_p1::persToTrans(const SCT_RawDataContainer_p1* persCont, SCT_RDO_Container* transCont, MsgStream& log) { // The transient model has a container holding collections and the @@ -99,8 +101,6 @@ void SCT_RawDataContainerCnv_p1::persToTrans(const SCT_RawDataContainer_p1* per // from the vector. - SCT_RDO_Collection* coll = 0; - SCT1_RawDataCnv_p1 chan1Cnv; SCT3_RawDataCnv_p1 chan3Cnv; // check for the type of the contained objects: @@ -117,7 +117,7 @@ void SCT_RawDataContainerCnv_p1::persToTrans(const SCT_RawDataContainer_p1* per const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll]; Identifier collID(pcoll.m_id); IdentifierHash collIDHash(IdentifierHash(pcoll.m_hashId)); - coll = new SCT_RDO_Collection(collIDHash ); + std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(collIDHash); coll->setIdentifier(collID); unsigned int nchans = pcoll.m_end - pcoll.m_begin; coll->resize(nchans); @@ -126,24 +126,24 @@ void SCT_RawDataContainerCnv_p1::persToTrans(const SCT_RawDataContainer_p1* per for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { if(m_type == 1) { const InDetRawData_p1* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]); - SCT1_RawData* chan = new SCT1_RawData(); - chan1Cnv.persToTrans(pchan, chan, log); - (*coll)[ichan] = chan; + std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>(); + chan1Cnv.persToTrans(pchan, chan.get(), log); + (*coll)[ichan] = chan.release(); } else if (m_type == 3) { const SCT3_RawData_p1* pchan = &(persCont->m_sct3data[ichan + pcoll.m_begin]); - SCT3_RawData* chan = new SCT3_RawData(); - chan3Cnv.persToTrans(pchan, chan, log); - (*coll)[ichan] = chan; + std::unique_ptr<SCT3_RawData> chan = std::make_unique<SCT3_RawData>(); + chan3Cnv.persToTrans(pchan, chan.get(), log); + (*coll)[ichan] = chan.release(); } } // register the rdo collection in IDC with hash - faster addCollection - StatusCode sc = transCont->addCollection(coll, collIDHash); - if (sc.isFailure()) { - throw std::runtime_error("Failed to add collection to ID Container"); - } - MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " - << (int) collIDHash << " / " << collID.get_compact() << ", added to Identifiable container."); + StatusCode sc = transCont->addCollection(coll.release(), collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } + MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " + << collIDHash.value() << " / " << collID.get_compact() << ", added to Identifiable container."); } // MSG_DEBUG(log," *** Reading SCT_RDO_Container (SCT1/3_RawData concrete type)"); @@ -151,8 +151,8 @@ void SCT_RawDataContainerCnv_p1::persToTrans(const SCT_RawDataContainer_p1* per //================================================================ SCT_RDO_Container* SCT_RawDataContainerCnv_p1::createTransient(const SCT_RawDataContainer_p1* persObj, MsgStream& log) { - std::unique_ptr<SCT_RDO_Container> trans(new SCT_RDO_Container(m_sctId->wafer_hash_max())); + std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max())); persToTrans(persObj, trans.get(), log); - return(trans.release()); + return trans.release(); } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.h index c3412e929be..10d00a7a8b5 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p1.h @@ -25,22 +25,22 @@ class SCT_ID; class SCT_RawDataContainerCnv_p1 : public T_AthenaPoolTPCnvBase<SCT_RDO_Container, SCT_RawDataContainer_p1> { private: - const SCT_ID *m_sctId = nullptr; + const SCT_ID* m_sctId = nullptr; int m_type; public: SCT_RawDataContainerCnv_p1() :m_type(0) {}; virtual void persToTrans(const SCT_RawDataContainer_p1* persCont, SCT_RDO_Container* transCont, - MsgStream &log) ; + MsgStream& log) ; virtual void transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p1* persCont, - MsgStream &log) ; + MsgStream& log) ; virtual SCT_RDO_Container* createTransient(const SCT_RawDataContainer_p1* persObj, MsgStream& log) ; // ID helper can't be used in the constructor, need initialize() - void initialize(const SCT_ID *idhelper) { m_sctId = idhelper; } + void initialize(const SCT_ID* idhelper) { m_sctId = idhelper; } void setType(int type) {m_type = type; } }; diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.cxx index ef7310e73ab..95eb6d1ef40 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT3_RawData.h" @@ -14,9 +14,11 @@ #include "SCT3_RawDataCnv_p2.h" #include "SCT_RawDataContainerCnv_p2.h" +#include <memory> + //#define SCT_DEBUG -void SCT_RawDataContainerCnv_p2::transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p2* persCont, MsgStream &log) +void SCT_RawDataContainerCnv_p2::transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p2* persCont, MsgStream& log) { /// The transient model has a container holding collections and the @@ -61,7 +63,7 @@ void SCT_RawDataContainerCnv_p2::transToPers(const SCT_RDO_Container* transCont, chanEnd += collection.size(); InDetRawDataCollection_p1& pcollection = persCont->m_collections[collIndex]; pcollection.m_id = collection.identify().get_compact(); - pcollection.m_hashId = (unsigned int) collection.identifyHash(); + pcollection.m_hashId = static_cast<unsigned int>(collection.identifyHash()); pcollection.m_begin = chanBegin; pcollection.m_end = chanEnd; #ifdef SCT_DEBUG @@ -100,7 +102,7 @@ void SCT_RawDataContainerCnv_p2::transToPers(const SCT_RDO_Container* transCont, #endif } -void SCT_RawDataContainerCnv_p2::persToTrans(const SCT_RawDataContainer_p2* persCont, SCT_RDO_Container* transCont, MsgStream &log) +void SCT_RawDataContainerCnv_p2::persToTrans(const SCT_RawDataContainer_p2* persCont, SCT_RDO_Container* transCont, MsgStream& log) { /// The transient model has a container holding collections and the @@ -118,8 +120,6 @@ void SCT_RawDataContainerCnv_p2::persToTrans(const SCT_RawDataContainer_p2* per /// from the vector. - SCT_RDO_Collection* coll = 0; - SCT1_RawDataCnv_p1 chan1Cnv; SCT3_RawDataCnv_p2 chan3Cnv; /** check for the type of the contained objects: */ @@ -136,10 +136,10 @@ void SCT_RawDataContainerCnv_p2::persToTrans(const SCT_RawDataContainer_p2* per /** Create trans collection - in NOT owner of SCT_RDO_RawData (SG::VIEW_ELEMENTS) * IDet collection don't have the Ownership policy c'tor */ - const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll]; + const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll]; Identifier collID(pcoll.m_id); IdentifierHash collIDHash(pcoll.m_hashId); - coll = new SCT_RDO_Collection(IdentifierHash(collIDHash)); + std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(IdentifierHash(collIDHash)); coll->setIdentifier(collID); unsigned int nchans = pcoll.m_end - pcoll.m_begin; @@ -152,9 +152,9 @@ void SCT_RawDataContainerCnv_p2::persToTrans(const SCT_RawDataContainer_p2* per for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { if(m_type == 1) { const InDetRawData_p1* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]); - SCT1_RawData* chan = new SCT1_RawData(); - chan1Cnv.persToTrans(pchan, chan, log); - (*coll)[ichan] = chan; + std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>(); + chan1Cnv.persToTrans(pchan, chan.get(), log); + (*coll)[ichan] = chan.release(); } else if (m_type == 3) { const SCT3_RawData_p2* pchan = &(persCont->m_sct3data[ichan + pcoll.m_begin]); /** now need to fill the vector of errors for the transient RDO @@ -163,20 +163,20 @@ void SCT_RawDataContainerCnv_p2::persToTrans(const SCT_RawDataContainer_p2* per int errEnd = errCount + persCont->m_numErrorsInRDO[ichan + pcoll.m_begin]; for ( ; errCount < errEnd ; ++errCount) errorCondensedHit.push_back(persCont->m_allErrorsInContainer[errCount]); - - (*coll)[ichan] = new SCT3_RawData (Identifier (pchan->m_rdoId), - pchan->m_word, - std::move(errorCondensedHit)); + std::unique_ptr<SCT3_RawData> chan = std::make_unique<SCT3_RawData>(Identifier(pchan->m_rdoId), + pchan->m_word, + std::move(errorCondensedHit)); + (*coll)[ichan] = chan.release(); } } // register the rdo collection in IDC with hash - faster addCollection - StatusCode sc = transCont->addCollection(coll, collIDHash); - if (sc.isFailure()) { - throw std::runtime_error("Failed to add collection to ID Container"); - } - MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " - << (int) collIDHash << " / " << collID.get_compact() << ", added to Identifiable container."); + StatusCode sc = transCont->addCollection(coll.release(), collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } + MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " + << collIDHash.value() << " / " << collID.get_compact() << ", added to Identifiable container."); } #ifdef SCT_DEBUG @@ -189,8 +189,7 @@ SCT_RDO_Container* SCT_RawDataContainerCnv_p2::createTransient(const SCT_RawData #ifdef SCT_DEBUG MSG_DEBUG(log,"creating transient SCT_RDO_Container"); #endif - std::unique_ptr<SCT_RDO_Container> trans(new SCT_RDO_Container(m_sctId->wafer_hash_max())); + std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max())); persToTrans(persObj, trans.get(), log); return(trans.release()); } - diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.h index de4627d316d..c8a747969e0 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p2.h @@ -25,22 +25,22 @@ class SCT_ID; class SCT_RawDataContainerCnv_p2 : public T_AthenaPoolTPCnvBase<SCT_RDO_Container, SCT_RawDataContainer_p2> { private: - const SCT_ID *m_sctId = nullptr; + const SCT_ID* m_sctId = nullptr; int m_type; public: SCT_RawDataContainerCnv_p2() :m_type(0) {}; virtual void persToTrans(const SCT_RawDataContainer_p2* persCont, SCT_RDO_Container* transCont, - MsgStream &log) ; + MsgStream& log) ; virtual void transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p2* persCont, - MsgStream &log) ; + MsgStream& log) ; virtual SCT_RDO_Container* createTransient(const SCT_RawDataContainer_p2* persObj, MsgStream& log) ; // ID helper can't be used in the constructor, need initialize() - void initialize(const SCT_ID *idhelper) { m_sctId = idhelper; } + void initialize(const SCT_ID* idhelper) { m_sctId = idhelper; } void setType(int type) {m_type = type; } }; diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.cxx index 1e4918e9a09..76507648f3c 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.cxx +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "InDetRawData/SCT3_RawData.h" @@ -14,9 +14,11 @@ #include "SCT3_RawDataCnv_p3.h" #include "SCT_RawDataContainerCnv_p3.h" +#include <memory> + //#define SCT_DEBUG -void SCT_RawDataContainerCnv_p3::transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p3* persCont, MsgStream &log) +void SCT_RawDataContainerCnv_p3::transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p3* persCont, MsgStream& log) { /// The transient model has a container holding collections and the @@ -61,7 +63,7 @@ void SCT_RawDataContainerCnv_p3::transToPers(const SCT_RDO_Container* transCont, chanEnd += collection.size(); InDetRawDataCollection_p1& pcollection = persCont->m_collections[collIndex]; pcollection.m_id = collection.identify().get_identifier32().get_compact(); - pcollection.m_hashId = (unsigned int) collection.identifyHash(); + pcollection.m_hashId = static_cast<unsigned int>(collection.identifyHash()); pcollection.m_begin = chanBegin; pcollection.m_end = chanEnd; #ifdef SCT_DEBUG @@ -86,7 +88,7 @@ void SCT_RawDataContainerCnv_p3::transToPers(const SCT_RDO_Container* transCont, for (unsigned int i = 0; i < collection.size(); ++i) { SCT3_RawData_p3* pchan = &(persCont->m_sct3data[i + chanBegin]); const SCT3_RawData* chan = dynamic_cast<const SCT3_RawData*>(collection[i]); - if (0 == chan) throw std::runtime_error("SCT_RawDataContainerCnv_p3::transToPers: *** UNABLE TO DYNAMIC CAST TO SCT3_RawData"); + if (nullptr == chan) throw std::runtime_error("SCT_RawDataContainerCnv_p3::transToPers: *** UNABLE TO DYNAMIC CAST TO SCT3_RawData"); chan3Cnv.transToPers(chan, pchan, log); const std::vector<int>& errHit = chan->getErrorCondensedHit(); persCont->m_numErrorsInRDO.push_back(errHit.size() ); @@ -101,7 +103,7 @@ void SCT_RawDataContainerCnv_p3::transToPers(const SCT_RDO_Container* transCont, #endif } -void SCT_RawDataContainerCnv_p3::persToTrans(const SCT_RawDataContainer_p3* persCont, SCT_RDO_Container* transCont, MsgStream &log) +void SCT_RawDataContainerCnv_p3::persToTrans(const SCT_RawDataContainer_p3* persCont, SCT_RDO_Container* transCont, MsgStream& log) { /// The transient model has a container holding collections and the @@ -119,8 +121,6 @@ void SCT_RawDataContainerCnv_p3::persToTrans(const SCT_RawDataContainer_p3* per /// from the vector. - SCT_RDO_Collection* coll = 0; - SCT1_RawDataCnv_p2 chan1Cnv; SCT3_RawDataCnv_p3 chan3Cnv; /** check for the type of the contained objects: */ @@ -140,7 +140,7 @@ void SCT_RawDataContainerCnv_p3::persToTrans(const SCT_RawDataContainer_p3* per const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll]; Identifier collID(pcoll.m_id); IdentifierHash collIDHash(pcoll.m_hashId); - coll = new SCT_RDO_Collection(IdentifierHash(collIDHash)); + std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(IdentifierHash(collIDHash)); coll->setIdentifier(collID); unsigned int nchans = pcoll.m_end - pcoll.m_begin; @@ -153,9 +153,9 @@ void SCT_RawDataContainerCnv_p3::persToTrans(const SCT_RawDataContainer_p3* per for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { if(m_type == 1) { const InDetRawData_p2* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]); - SCT1_RawData* chan = new SCT1_RawData(); - chan1Cnv.persToTrans(pchan, chan, log); - (*coll)[ichan] = chan; + std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>(); + chan1Cnv.persToTrans(pchan, chan.get(), log); + (*coll)[ichan] = chan.release(); } else if (m_type == 3) { const SCT3_RawData_p3* pchan = &(persCont->m_sct3data[ichan + pcoll.m_begin]); /** now need to fill the vector of errors for the transient RDO @@ -164,19 +164,20 @@ void SCT_RawDataContainerCnv_p3::persToTrans(const SCT_RawDataContainer_p3* per int errEnd = errCount + persCont->m_numErrorsInRDO[ichan + pcoll.m_begin]; for ( ; errCount < errEnd ; ++errCount) errorCondensedHit.push_back(persCont->m_allErrorsInContainer[errCount]); - (*coll)[ichan] = new SCT3_RawData (Identifier (pchan->m_rdoId), - pchan->m_word, - std::move (errorCondensedHit)); + std::unique_ptr<SCT3_RawData> chan = std::make_unique<SCT3_RawData>(Identifier(pchan->m_rdoId), + pchan->m_word, + std::move (errorCondensedHit)); + (*coll)[ichan] = chan.release(); } } // register the rdo collection in IDC with hash - faster addCollection - StatusCode sc = transCont->addCollection(coll, collIDHash); - if (sc.isFailure()) { - throw std::runtime_error("Failed to add collection to ID Container"); - } - MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " - << (int) collIDHash << " / " << collID.get_compact() << ", added to Identifiable container."); + StatusCode sc = transCont->addCollection(coll.release(), collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } + MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " + << collIDHash.value() << " / " << collID.get_compact() << ", added to Identifiable container."); } #ifdef SCT_DEBUG @@ -189,8 +190,8 @@ SCT_RDO_Container* SCT_RawDataContainerCnv_p3::createTransient(const SCT_RawData #ifdef SCT_DEBUG MSG_DEBUG(log,"creating transient SCT_RDO_Container"); #endif - std::unique_ptr<SCT_RDO_Container> trans(new SCT_RDO_Container(m_sctId->wafer_hash_max())); + std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max())); persToTrans(persObj, trans.get(), log); - return(trans.release()); + return trans.release(); } diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.h index a1b11a6aeb8..a73962ee9a8 100644 --- a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.h +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p3.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef SCT_RAWDATACONTAINERCNV_P3_H @@ -25,22 +25,22 @@ class SCT_ID; class SCT_RawDataContainerCnv_p3 : public T_AthenaPoolTPCnvBase<SCT_RDO_Container, SCT_RawDataContainer_p3> { private: - const SCT_ID *m_sctId; + const SCT_ID* m_sctId; int m_type; public: - SCT_RawDataContainerCnv_p3() : m_sctId(0), m_type(0) {}; + SCT_RawDataContainerCnv_p3() : m_sctId(nullptr), m_type(0) {}; virtual void persToTrans(const SCT_RawDataContainer_p3* persCont, SCT_RDO_Container* transCont, - MsgStream &log) ; + MsgStream& log) ; virtual void transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p3* persCont, - MsgStream &log) ; + MsgStream& log) ; virtual SCT_RDO_Container* createTransient(const SCT_RawDataContainer_p3* persObj, MsgStream& log) ; // ID helper can't be used in the constructor, need initialize() - void initialize(const SCT_ID *idhelper) { m_sctId = idhelper; } + void initialize(const SCT_ID* idhelper) { m_sctId = idhelper; } void setType(int type) {m_type = type; } }; diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.cxx b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.cxx new file mode 100644 index 00000000000..0abda9133a2 --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.cxx @@ -0,0 +1,182 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "InDetRawData/SCT3_RawData.h" +#include "InDetEventAthenaPool/SCT3_RawData_p4.h" +#include "InDetEventAthenaPool/InDetRawDataCollection_p1.h" +#include "InDetRawData/SCT_RDO_Container.h" +#include "MsgUtil.h" + +#include "InDetIdentifier/SCT_ID.h" +#include "InDetRawData/SCT_RDO_Collection.h" +#include "SCT1_RawDataCnv_p2.h" +#include "SCT3_RawDataCnv_p4.h" +#include "SCT_RawDataContainerCnv_p4.h" + +#include <memory> + +//#define SCT_DEBUG + +void SCT_RawDataContainerCnv_p4::transToPers(const SCT_RDO_Container* transCont, SCT_RawDataContainer_p4* persCont, MsgStream& log) +{ + + /// The transient model has a container holding collections and the + /// collections hold channels. + /// + /// The persistent model flattens this so that the persistent + /// container has two vectors: + /// 1) all collections, and + /// 2) all RDO + /// + /// The persistent collections, then only maintain indexes into the + /// container's vector of all channels. + /// + /// So here we loop over all collection and add their channels + /// to the container's vector, saving the indexes in the + /// collection. + + typedef SCT_RDO_Container TRANS; + + SCT1_RawDataCnv_p2 chan1Cnv; + SCT3_RawDataCnv_p4 chan3Cnv(m_sctId); + TRANS::const_iterator it_Coll = transCont->begin(); + TRANS::const_iterator it_CollEnd = transCont->end(); + unsigned int collIndex; + unsigned int chanBegin = 0; + unsigned int chanEnd = 0; + int numColl = transCont->numberOfCollections(); + persCont->m_collections.resize(numColl); +#ifdef SCT_DEBUG + MSG_DEBUG(log,"SCT_RawDataContainerCnv_p4 Preparing " << persCont->m_collections.size() << "Collections"); +#endif + + /** we're going to store all the strip errors from each RDO + * in vectors in the collection */ + + for (collIndex = 0; it_Coll != it_CollEnd; ++collIndex, it_Coll++) { + /** Add in new collection */ + const SCT_RDO_Collection& collection = (**it_Coll); + chanBegin = chanEnd; + chanEnd += collection.size(); + InDetRawDataCollection_p1& pcollection = persCont->m_collections[collIndex]; + pcollection.m_id = collection.identify().get_identifier32().get_compact(); + pcollection.m_hashId = static_cast<unsigned int>(collection.identifyHash()); + pcollection.m_begin = chanBegin; + pcollection.m_end = chanEnd; +#ifdef SCT_DEBUG + MSG_DEBUG(log,"Writing collection number " << collIndex << " with hash" << pcollection.m_hashId); +#endif + /** Add in channels */ + if(m_type == 1) { +#ifdef SCT_DEBUG + MSG_DEBUG(log,"SCT_RawDataContainerCnv_p4 m_type is 1"); +#endif + persCont->m_rawdata.resize(chanEnd); + for (unsigned int i = 0; i < collection.size(); ++i) { + InDetRawData_p2* pchan = &(persCont->m_rawdata[i + chanBegin]); + const SCT1_RawData* chan = dynamic_cast<const SCT1_RawData*>(collection[i]); + chan1Cnv.transToPers(chan, pchan, log); + } + } else if (m_type == 3) { +#ifdef SCT_DEBUG + MSG_DEBUG(log,"SCT_RawDataContainerCnv_p4 m_type is 3"); +#endif + persCont->m_sct3data.resize(chanEnd); + for (unsigned int i = 0; i < collection.size(); ++i) { + SCT3_RawData_p4* pchan = &(persCont->m_sct3data[i + chanBegin]); + const SCT3_RawData* chan = dynamic_cast<const SCT3_RawData*>(collection[i]); + if (nullptr == chan) throw std::runtime_error("SCT_RawDataContainerCnv_p4::transToPers: *** UNABLE TO DYNAMIC CAST TO SCT3_RawData"); + chan3Cnv.transToPers(chan, pchan, log); + } + } + } +#ifdef SCT_DEBUG + MSG_DEBUG(log," *** Writing SCT_RDO_Container (SCT1/3_RawData concrete type)"); +#endif +} + +void SCT_RawDataContainerCnv_p4::persToTrans(const SCT_RawDataContainer_p4* persCont, SCT_RDO_Container* transCont, MsgStream& log) +{ + + /// The transient model has a container holding collections and the + /// collections hold channels. + /// + /// The persistent model flattens this so that the persistent + /// container has two vectors: + /// 1) all collections, and + /// 2) all channels + /// + /// The persistent collections, then only maintain indexes into the + /// container's vector of all channels. + /// + /// So here we loop over all collection and extract their channels + /// from the vector. + + + SCT1_RawDataCnv_p2 chan1Cnv; + SCT3_RawDataCnv_p4 chan3Cnv(m_sctId); + /** check for the type of the contained objects: */ + + if(persCont->m_rawdata.size() !=0 && persCont->m_sct3data.size() != 0) + log << MSG::FATAL << "The collection has mixed SCT1 and SCT3 elements, this is not allowed " << endreq; + if(persCont->m_rawdata.size() != 0 ) m_type = 1; + if(persCont->m_sct3data.size() != 0 ) m_type = 3; +#ifdef SCT_DEBUG + MSG_DEBUG(log," Reading " << persCont->m_collections.size() << " Collections"); +#endif + for (unsigned int icoll = 0; icoll < persCont->m_collections.size(); ++icoll) { + + /** Create trans collection - in NOT owner of SCT_RDO_RawData (SG::VIEW_ELEMENTS) + * IDet collection don't have the Ownership policy c'tor */ + const InDetRawDataCollection_p1& pcoll = persCont->m_collections[icoll]; + Identifier collID(pcoll.m_id); + chan3Cnv.setWaferId(collID); + IdentifierHash collIDHash(pcoll.m_hashId); + std::unique_ptr<SCT_RDO_Collection> coll = std::make_unique<SCT_RDO_Collection>(IdentifierHash(collIDHash)); + coll->setIdentifier(collID); + unsigned int nchans = pcoll.m_end - pcoll.m_begin; + + coll->resize(nchans); +#ifdef SCT_DEBUG + MSG_DEBUG(log,"Reading collection with id = " << pcoll.m_id << " id hash= " << pcoll.m_hashId + << " and num el= " << nchans << " m_type is "<<m_type); +#endif + // Fill with channels + for (unsigned int ichan = 0; ichan < nchans; ++ ichan) { + if(m_type == 1) { + const InDetRawData_p2* pchan = &(persCont->m_rawdata[ichan + pcoll.m_begin]); + std::unique_ptr<SCT1_RawData> chan = std::make_unique<SCT1_RawData>(); + chan1Cnv.persToTrans(pchan, chan.get(), log); + (*coll)[ichan] = chan.release(); + } else if (m_type == 3) { + const SCT3_RawData_p4* pchan = &(persCont->m_sct3data[ichan + pcoll.m_begin]); + std::unique_ptr<SCT3_RawData> chan = std::make_unique<SCT3_RawData>(); + chan3Cnv.persToTrans(pchan, chan.get(), log); + (*coll)[ichan] = chan.release(); + } + } + + // register the rdo collection in IDC with hash - faster addCollection + StatusCode sc = transCont->addCollection(coll.release(), collIDHash); + if (sc.isFailure()) { + throw std::runtime_error("Failed to add collection to ID Container"); + } + MSG_VERBOSE(log,"AthenaPoolTPCnvIDCont::persToTrans, collection, hash_id/coll id = " + << collIDHash.value() << " / " << collID.get_compact() << ", added to Identifiable container."); + + } +#ifdef SCT_DEBUG + MSG_DEBUG(log," *** Reading SCT_RDO_Container (SCT1/3_RawData concrete type)"); +#endif +} + +//================================================================ +SCT_RDO_Container* SCT_RawDataContainerCnv_p4::createTransient(const SCT_RawDataContainer_p4* persObj, MsgStream& log) { +#ifdef SCT_DEBUG + MSG_DEBUG(log,"creating transient SCT_RDO_Container"); +#endif + std::unique_ptr<SCT_RDO_Container> trans(std::make_unique<SCT_RDO_Container>(m_sctId->wafer_hash_max())); + persToTrans(persObj, trans.get(), log); + return trans.release(); +} diff --git a/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.h b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.h new file mode 100644 index 00000000000..966e16479cb --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetEventAthenaPool/src/SCT_RawDataContainerCnv_p4.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCT_RAWDATACONTAINERCNV_P4_H +#define SCT_RAWDATACONTAINERCNV_P4_H + +// SCT_RawDataContainerCnv_p4, T/P separation of SCT Raw data +// author Susumu Oda <Susumu.Oda@cern.ch> + +#include "InDetRawData/SCT_RDO_Container.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "InDetEventAthenaPool/SCT_RawDataContainer_p4.h" +class SCT_ID; + + +// We do NOT use T_AthenaPoolTPCnvIDCont because we do all of the +// conversion in the .cxx. Same as for the LAr Raw Channels +// Note that this is used for a container of SCT Raw Data +// that containes only SCR1_RawData concrete types +// SCT_RDO_ContainerCnv.cxx delegates the conversion to this +// converter if the objects are of the correct type + + +class SCT_RawDataContainerCnv_p4 : public T_AthenaPoolTPCnvBase<SCT_RDO_Container, SCT_RawDataContainer_p4> +{ +private: + const SCT_ID* m_sctId; + int m_type; +public: + SCT_RawDataContainerCnv_p4() : m_sctId(nullptr), m_type(0) {}; + + virtual void persToTrans(const SCT_RawDataContainer_p4* persCont, + SCT_RDO_Container* transCont, + MsgStream& log) ; + virtual void transToPers(const SCT_RDO_Container* transCont, + SCT_RawDataContainer_p4* persCont, + MsgStream& log) ; + virtual SCT_RDO_Container* createTransient(const SCT_RawDataContainer_p4* persObj, MsgStream& log) ; + + + // ID helper can't be used in the constructor, need initialize() + void initialize(const SCT_ID* idhelper) { m_sctId = idhelper; } + void setType(int type) {m_type = type; } +}; + +#endif diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/src/SCT_ClusteringTool.cxx b/InnerDetector/InDetRecTools/SiClusterizationTool/src/SCT_ClusteringTool.cxx index e2b5772ab5d..8cbc93a5c59 100755 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/src/SCT_ClusteringTool.cxx +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/src/SCT_ClusteringTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ /** @@ -279,19 +279,19 @@ namespace InDet{ // Now we are either (a) pushing more contiguous strips onto an existing vector // or (b) pushing a new set of ids onto an empty vector if (passTiming) { - if (not m_checkBadChannels){ - addStripsToCluster(firstStripId, nStrips, currentVector, idHelper); // Note this takes the current vector only - if (stripCount < 16) hitsInThirdTimeBin = hitsInThirdTimeBin | (timePattern.test(0) << stripCount); - stripCount++; - } else { - addStripsToClusterWithChecks(firstStripId, nStrips, currentVector,idGroups, idHelper); // This one includes the groups of vectors as well - if (stripCount < 16) hitsInThirdTimeBin = hitsInThirdTimeBin | (timePattern.test(0) << stripCount); - stripCount++; - } + if (not m_checkBadChannels){ + addStripsToCluster(firstStripId, nStrips, currentVector, idHelper); // Note this takes the current vector only + } else { + addStripsToClusterWithChecks(firstStripId, nStrips, currentVector,idGroups, idHelper); // This one includes the groups of vectors as well + } + for (unsigned int iStrip=0; iStrip<nStrips; iStrip++) { + if (stripCount < 16) hitsInThirdTimeBin |= (timePattern.test(0) << stripCount); + stripCount++; + } } if (not currentVector.empty()) { - // Gives the last strip number in the cluster - previousStrip = idHelper.strip(currentVector.back()); + // Gives the last strip number in the cluster + previousStrip = idHelper.strip(currentVector.back()); } } diff --git a/InnerDetector/InDetRecTools/SiClusterizationTool/src/TotPixelClusterSplitter.cxx b/InnerDetector/InDetRecTools/SiClusterizationTool/src/TotPixelClusterSplitter.cxx index f6e91a74263..6d1e8963539 100644 --- a/InnerDetector/InDetRecTools/SiClusterizationTool/src/TotPixelClusterSplitter.cxx +++ b/InnerDetector/InDetRecTools/SiClusterizationTool/src/TotPixelClusterSplitter.cxx @@ -218,7 +218,7 @@ std::vector<InDet::PixelClusterParts> InDet::TotPixelClusterSplitter::splitClust if (!pixelIDp){ ATH_MSG_ERROR("Could not get PixelID pointer"); } - const PixelID& pixelID = *pixelIDp; + // const PixelID& pixelID = *pixelIDp; for (unsigned int i = 0; i < NumPixels; i++) -- GitLab