From 4ceca25547f07338764d1e9284b9e6670373901f Mon Sep 17 00:00:00 2001
From: Stefano Rosati <stefano.rosati@cern.ch>
Date: Tue, 13 Mar 2018 16:39:31 +0100
Subject: [PATCH] Adding a first version of the conversion tool for sTGC
 RDO->PRD conversion

	deleted:    MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.cxx
	modified:   MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx
	new file:   MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx
	renamed:    MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.h -> MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h


Former-commit-id: 9275180aa15ff1e2b3ea71123ac1f2d541e5fc45
---
 .../src/STGC_RawDataToPrepDataTool.cxx        | 164 -----------
 .../components/MuonSTGC_CnvTools_entries.cxx  |   5 +-
 .../src/sTgcRdoToPrepDataTool.cxx             | 277 ++++++++++++++++++
 ...PrepDataTool.h => sTgcRdoToPrepDataTool.h} |  55 ++--
 4 files changed, 310 insertions(+), 191 deletions(-)
 delete mode 100644 MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.cxx
 create mode 100644 MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx
 rename MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/{STGC_RawDataToPrepDataTool.h => sTgcRdoToPrepDataTool.h} (57%)

diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.cxx
deleted file mode 100644
index a98fb05b5718..000000000000
--- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.cxx
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// TGC_CnvTool.cxx, (c) ATLAS Detector software
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include "STGC_RawDataToPrepDataTool.h"
-
-#include "GaudiKernel/ISvcLocator.h"
-
-#include "MuonReadoutGeometry/MuonDetectorManager.h"
-#include "MuonReadoutGeometry/sTgcReadoutElement.h"
-
-#include "TrkSurfaces/Surface.h"
-
-#include "MuonCnvToolInterfaces/IDC_Helper.h"
-
-#include "EventPrimitives/EventPrimitives.h"
-// BS access
-#include "MuonCnvToolInterfaces/IMuonRawDataProviderTool.h"
-
-#include <cfloat>
-#include <algorithm>
-
-//================ Constructor =================================================
-
-Muon::STGC_RawDataToPrepDataTool::STGC_RawDataToPrepDataTool(const std::string& t, const std::string& n, const IInterface* p)
-  : AthAlgTool(t, n, p), 
-    m_muonMgr(0),
-    m_rawDataProviderTool("Muon::sTGC_RawDataProviderTool/sTGC_RawDataProviderTool"),
-    m_RDO_Key("sTGCRDO"),
-    m_PRD_Key("sTGC_Measurements")
-{
-  declareProperty("RawDataProviderTool",  m_rawDataProviderTool);
-  declareProperty("RDOContainer",         m_RDO_Key);
-  declareProperty("OutputCollection",     m_PRD_Key);
-}  
-
-//================ Destructor =================================================
-
-Muon::STGC_RawDataToPrepDataTool::~STGC_RawDataToPrepDataTool()
-{}
-
-//___________________________________________________________________________
-StatusCode Muon::STGC_RawDataToPrepDataTool::queryInterface(const InterfaceID& riid, void** ppvIf)
-{
-  if(riid==IMuonRdoToPrepDataTool::interfaceID()) {
-    *ppvIf = (IMuonRdoToPrepDataTool*)this;
-    addRef();
-    return StatusCode::SUCCESS;
-  }
-  
-  return AthAlgTool::queryInterface(riid, ppvIf);
-}
-
-
-//================ Initialization =================================================
-
-StatusCode Muon::STGC_RawDataToPrepDataTool::initialize()
-{
-  StatusCode sc = AthAlgTool::initialize();
-  if(sc.isFailure()) return sc;
-
-  sc = detStore()->retrieve(m_muonMgr);
-  if(sc.isFailure()) {
-    ATH_MSG_FATAL("Cannot retrieve MuonDetectorManager");
-    return sc;
-  }
-
-  /// get tgcIdHelper from muonMgr
-  m_sTGC_Helper = m_muonMgr->stgcIdHelper();
-    
-  ATH_CHECK(m_RDO_Key.initialize());
-  ATH_CHECK(m_PRD_Key.initialize());
-  
-  ATH_MSG_INFO("initialize() successful in " << name());
-  return StatusCode::SUCCESS;
-}
-
-//================ Finalization =================================================
-
-StatusCode Muon::STGC_RawDataToPrepDataTool::finalize()
-{
-  StatusCode sc = AthAlgTool::finalize();
-  return sc;
-}
-
-//================ Decoding =================================================
-StatusCode Muon::STGC_RawDataToPrepDataTool::decode(std::vector<IdentifierHash>& requestedIdHashVect, 
-					      std::vector<IdentifierHash>& selectedIdHashVect)
-{
-  int sizeVectorRequested = requestedIdHashVect.size();
-  ATH_MSG_DEBUG("decode for " << sizeVectorRequested << " offline collections called");
-
-  // clear output vector of selected data collections containing data 
-  // selectedIdHashVect.clear();
-  //
-  // if(!evtStore()->contains<Muon::sTgcPrepDataContainer>( m_PRD_Key )) {
-  //   // initialize with false
-  //   // std::fill(m_decodedOnlineId.begin(), m_decodedOnlineId.end(), false);
-  //   SG::WriteHandle<sTgcPrepDataContainer>  handle(m_PRD_Key);
-  //
-  //   // record the container in storeGate
-  //   auto prds = std::make_unique<sTgcPrepDataContainer> (m_sTGC_Helper->module_hash_max());
-  //   ATH_CHECK( handle.record (std::move (prds)) );
-  //
-  //   // cache the pointer, storegate retains ownership
-  //   sTgcPrepDataContainer* stgcPrepDataContainer = handle.ptr();
-  // }
-
-  // seeded or unseeded decoding
-  // if (sizeVectorRequested != 0) {
-  //   processPRDHashes(idVect,idWithDataVect, *stgcPrepDataContainer);
-  // }  else {
-  //   processRDOContainer(idWithDataVect, *stgcPrepDataContainer);
-  // }
-
-  return StatusCode::SUCCESS;
-}
-
-void Muon::STGC_RawDataToPrepDataTool::processPRDHashes( const std::vector<IdentifierHash>& chamberHashInRobs, std::vector<IdentifierHash>& idWithDataVect, sTgcPrepDataContainer& prds ){
-  
-  // get RDO container
-  
-  SG::ReadHandle<STGC_RawDataContainer> rdos(m_RDO_Key);
-  const STGC_RawDataContainer* rdoContainer = rdos.ptr();
-    
-  if(!rdoContainer) {
-    return;
-  }                 
-
-  for( auto it = chamberHashInRobs.begin(); it != chamberHashInRobs.end(); ++it ){
-    if(!handlePRDHash(*it,*rdoContainer,idWithDataVect, prds) ) {
-      ATH_MSG_DEBUG("Failed to process hash " << *it );
-    }
-  }//ends loop over chamberhash  
-}
-
-bool Muon::STGC_RawDataToPrepDataTool::handlePRDHash( IdentifierHash hash, const STGC_RawDataContainer& rdoContainer, std::vector<IdentifierHash>& idWithDataVect, sTgcPrepDataContainer& prds ) {
-  
-  // if in prep data the chamber already exists ... do nothing
-  // if( m_mdtPrepDataContainer->indexFind(hash) != m_mdtPrepDataContainer->end() ) return true;
-  //
-  // IdentifierHash rdoHash = hash; // before BMEs were installed, RDOs were indexed by offline hashes (same as PRD)
-  // // process CSM if data was found
-  // STGC_RawDataContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash);
-  // if( rdoColli != rdoContainer.end() ) {
-  //   rdoColli->push_back(new STGC_RawData() );
-  // } else {
-  //   ATH_MSG_DEBUG("handlePRDHash: hash id " << (unsigned int)(hash) << " not found in RDO container");
-  // }
-  return true;
-}
-
-void Muon::STGC_RawDataToPrepDataTool::printPrepData() {
-  
-}
-
-void Muon::STGC_RawDataToPrepDataTool::printInputRdo() {
-  
-}
-
diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx
index bb97cdbad288..6eed8b31e177 100644
--- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/components/MuonSTGC_CnvTools_entries.cxx
@@ -1,6 +1,5 @@
-#include "../STGC_RawDataToPrepDataTool.h"
+#include "../sTgcRdoToPrepDataTool.h"
 #include "../STGC_RawDataProviderTool.h"
 
-
-DECLARE_COMPONENT( Muon::STGC_RawDataToPrepDataTool )
+DECLARE_COMPONENT( Muon::sTgcRdoToPrepDataTool )
 DECLARE_COMPONENT( Muon::STGC_RawDataProviderTool )
diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx
new file mode 100644
index 000000000000..7ea311ca29b3
--- /dev/null
+++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.cxx
@@ -0,0 +1,277 @@
+/*
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+*/
+
+///////////////////////////////////////////////////////////////////
+// sTgcRdoToPrepDataTool.cxx, (c) ATLAS Detector software
+///////////////////////////////////////////////////////////////////
+
+#include "sTgcRdoToPrepDataTool.h"
+#include "GaudiKernel/MsgStream.h"
+#include "GaudiKernel/AlgFactory.h"
+#include "GaudiKernel/ISvcLocator.h"
+#include "GaudiKernel/PropertyMgr.h"
+
+#include "StoreGate/StoreGateSvc.h"
+
+#include "MuonIdHelpers/sTgcIdHelper.h"
+#include "MuonIdHelpers/MuonIdHelperTool.h"
+#include "MuonIdHelpers/MuonIdHelper.h"
+#include "MuonReadoutGeometry/MuonStation.h"
+#include "MuonReadoutGeometry/sTgcReadoutElement.h"
+
+// BS access
+#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
+#include "MuonCnvToolInterfaces/IMuonRawDataProviderTool.h"
+
+using namespace MuonGM;
+using namespace Trk;
+using namespace Muon;
+
+Muon::sTgcRdoToPrepDataTool::sTgcRdoToPrepDataTool(const std::string& t,
+						   const std::string& n,
+						   const IInterface*  p )
+  :
+  AthAlgTool(t,n,p),
+  m_muonMgr(0),
+  m_stgcIdHelper(0),
+  m_muonIdHelper(0),
+  m_fullEventDone(false),
+  m_stgcPrepDataContainer(0)
+{
+  declareInterface<Muon::IMuonRdoToPrepDataTool>(this);
+  
+  //  template for property decalration
+  declareProperty("OutputCollection",    m_stgcPrepDataContainerKey = std::string("sTGC_Measurements"),
+		  "Muon::sTgcPrepDataContainer to record");
+  
+}
+
+
+Muon::sTgcRdoToPrepDataTool::~sTgcRdoToPrepDataTool()
+{
+
+}
+
+StatusCode Muon::sTgcRdoToPrepDataTool::initialize()
+{  
+  ATH_MSG_DEBUG(" in initialize()");
+  
+  /// get the detector descriptor manager
+  StoreGateSvc* detStore=0;
+  StatusCode sc = serviceLocator()->service("DetectorStore", detStore);
+  
+  if (sc.isSuccess()) {
+    sc = detStore->retrieve( m_muonMgr );
+    if (sc.isFailure()) {
+      ATH_MSG_FATAL(" Cannot retrieve MuonReadoutGeometry ");
+      return sc;
+    }
+  } else {
+    ATH_MSG_ERROR("DetectorStore not found ");
+    return sc;
+  }
+  
+  m_stgcIdHelper = m_muonMgr->stgcIdHelper();
+
+  // check if the initialization of the data container is success
+  ATH_CHECK(m_stgcPrepDataContainerKey.initialize());
+
+
+  ATH_MSG_INFO("initialize() successful in " << name());
+  return StatusCode::SUCCESS;
+}
+
+StatusCode Muon::sTgcRdoToPrepDataTool::finalize()
+{
+  if (0 != m_stgcPrepDataContainer) m_stgcPrepDataContainer->release();
+  return StatusCode::SUCCESS;
+
+}
+
+StatusCode Muon::sTgcRdoToPrepDataTool::processCollection(const STGC_RawDataCollection *rdoColl, 
+							  std::vector<IdentifierHash>& idWithDataVect)
+{
+  ATH_MSG_DEBUG(" ***************** Start of process STGC Collection");
+
+  const IdentifierHash hash = rdoColl->identifyHash();
+
+  sTgcPrepDataCollection* prdColl = nullptr;
+  
+  // check if the collection already exists, otherwise add it
+  if ( m_stgcPrepDataContainer->indexFind(hash) != m_stgcPrepDataContainer->end() ) {
+
+    ATH_MSG_DEBUG("In processCollection: collection already contained in the MM PrepData container");
+    return StatusCode::FAILURE;
+  } 
+  else {
+    prdColl = new sTgcPrepDataCollection(hash);
+    idWithDataVect.push_back(hash);
+
+    if (StatusCode::SUCCESS != m_stgcPrepDataContainer->addCollection(prdColl, hash)) {
+      ATH_MSG_DEBUG("In processCollection - Couldn't record in the Container MM Collection with hashID = "
+		    << (int)hash );
+      return StatusCode::FAILURE;
+    }
+
+  }
+
+  // convert the RDO collection to a PRD collection
+  STGC_RawDataCollection::const_iterator it = rdoColl->begin();
+  for ( ; it != rdoColl->end() ; ++it ) {
+
+    ATH_MSG_DEBUG("Adding a new sTgc PrepRawData");
+
+    const STGC_RawData* rdo = *it;
+    const Identifier rdoId = rdo->identify();
+    const Identifier elementId = m_stgcIdHelper->elementID(rdoId);
+    std::vector<Identifier> rdoList;
+    rdoList.push_back(rdoId);
+    
+    // get the local and global positions
+    const MuonGM::sTgcReadoutElement* detEl = m_muonMgr->getsTgcReadoutElement(elementId);
+    Amg::Vector2D localPos;
+
+    bool getLocalPos = detEl->stripPosition(rdoId,localPos);
+    if ( !getLocalPos ) {
+      ATH_MSG_ERROR("Could not get the local strip position for sTgc");
+      return StatusCode::FAILURE;
+    } 
+
+    // get the resolution from strip width
+    const int gasGap  = m_stgcIdHelper->gasGap(rdoId);
+    const int channel = m_stgcIdHelper->channel(rdoId);
+
+    // to be fixed: for now do not set the resolution, it will be added in the 
+    // next update
+    double width = 0.;
+
+    int channelType = m_stgcIdHelper->channelType(rdoId);
+
+    ATH_MSG_DEBUG("Adding a new STGC PRD, gasGap: " << gasGap << " channel: " << channel 
+		  << " type: " << channelType );
+
+    double resolution = width/sqrt(12.); 
+
+    Amg::MatrixX* cov = new Amg::MatrixX(1,1);
+    cov->setIdentity();
+    (*cov)(0,0) = resolution*resolution;  
+
+    sTgcPrepData* stgcPrd = new sTgcPrepData(rdoId,hash,localPos,
+					     rdoList,cov,detEl);
+
+    prdColl->push_back(stgcPrd);
+
+  }
+
+
+
+  return StatusCode::SUCCESS;
+}
+
+
+Muon::sTgcRdoToPrepDataTool::SetupSTGC_PrepDataContainerStatus Muon::sTgcRdoToPrepDataTool::setupSTGC_PrepDataContainer() 
+{
+
+  if(!evtStore()->contains<Muon::sTgcPrepDataContainer>(m_stgcPrepDataContainerKey.key())){    
+    m_fullEventDone=false;
+    
+    SG::WriteHandle< Muon::sTgcPrepDataContainer > handle(m_stgcPrepDataContainerKey);
+    StatusCode status = handle.record(std::make_unique<Muon::sTgcPrepDataContainer>(m_stgcIdHelper->module_hash_max()));
+    
+    if (status.isFailure() || !handle.isValid() )   {
+      ATH_MSG_FATAL("Could not record container of STGC PrepData Container at " << m_stgcPrepDataContainerKey.key()); 
+      return FAILED;
+    }
+    m_stgcPrepDataContainer = handle.ptr();
+    return ADDED;
+  }
+  return ALREADYCONTAINED;
+}
+
+
+const STGC_RawDataContainer* Muon::sTgcRdoToPrepDataTool::getRdoContainer() {
+
+  auto rdoContainerHandle  = SG::makeHandle(m_rdoContainerKey);
+  if(rdoContainerHandle.isValid()) {
+    ATH_MSG_DEBUG("STGC_getRdoContainer success");
+    return rdoContainerHandle.cptr();  
+  }
+  ATH_MSG_WARNING("Retrieval of STGC_RawDataContainer failed !");
+
+  return nullptr;
+}
+
+
+void Muon::sTgcRdoToPrepDataTool::processRDOContainer( std::vector<IdentifierHash>& idWithDataVect ) 
+{
+
+  ATH_MSG_DEBUG("In processRDOContainer");
+  const STGC_RawDataContainer* rdoContainer = getRdoContainer();
+  if (!rdoContainer) {
+    return;
+  }
+  
+  // run in unseeded mode
+  for (STGC_RawDataContainer::const_iterator it = rdoContainer->begin(); it != rdoContainer->end(); ++it ) {
+    
+    auto rdoColl = *it;
+    if (rdoColl->empty()) continue;
+    ATH_MSG_DEBUG("New RDO collection with " << rdoColl->size() << "MM Hits");
+    if(processCollection(rdoColl, idWithDataVect).isFailure()) {
+      ATH_MSG_DEBUG("processCsm returns a bad StatusCode - keep going for new data collections in this event");
+    }
+  } 
+  
+  
+  return;
+}
+
+
+// methods for ROB-based decoding
+StatusCode Muon::sTgcRdoToPrepDataTool::decode( std::vector<IdentifierHash>& idVect, 
+						std::vector<IdentifierHash>& idWithDataVect )
+{
+
+  ATH_MSG_DEBUG("Size of the input hash id vector: " << idVect.size());
+
+  // clear the output vector of selected data
+  idWithDataVect.clear();
+  
+  SetupSTGC_PrepDataContainerStatus containerRecordStatus = setupSTGC_PrepDataContainer();
+
+  if ( containerRecordStatus == FAILED ) {
+    return StatusCode::FAILURE;
+  } 
+
+  // check if the full event has already been decoded
+  if ( m_fullEventDone ) {
+    ATH_MSG_DEBUG ("Full event dcoded, nothing to do");
+    return StatusCode::SUCCESS;
+  } 
+
+ 
+  return StatusCode::SUCCESS;
+} 
+
+StatusCode Muon::sTgcRdoToPrepDataTool::decode( const std::vector<uint32_t>& robIds )
+{
+
+  ATH_MSG_DEBUG("Size of the robIds" << robIds.size() );
+
+  return StatusCode::SUCCESS;
+}
+
+// printout methods
+void Muon::sTgcRdoToPrepDataTool::printInputRdo() {
+
+
+  return;
+}
+
+
+void Muon::sTgcRdoToPrepDataTool::printPrepData() {
+
+
+  return;
+}
diff --git a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.h b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h
similarity index 57%
rename from MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.h
rename to MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h
index 36215e66e761..e6c8f6a375c6 100644
--- a/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/STGC_RawDataToPrepDataTool.h
+++ b/MuonSpectrometer/MuonCnv/MuonSTGC_CnvTools/src/sTgcRdoToPrepDataTool.h
@@ -1,12 +1,12 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
 */
 
 ///////////////////////////////////////////////////////////////////
-// STGC_RawDataToPrepDataTool.h, (c) ATLAS Detector software
+// sTgcRdoToPrepDataTool.h, (c) ATLAS Detector software
 ///////////////////////////////////////////////////////////////////
-#ifndef MUONATGC_CNVTOOLS_STGC_RAWDATATOPREPDATATOOL
-#define MUONATGC_CNVTOOLS_STGC_RAWDATATOPREPDATATOOL
+#ifndef MUONTGC_CNVTOOLS_STGCRDOTOPREPDATATOOL
+#define MUONTGC_CNVTOOLS_STGCRDOTOPREPDATATOOL
 
 #include "AthenaBaseComps/AthAlgTool.h"
 #include "MuonCnvToolInterfaces/IMuonRdoToPrepDataTool.h"
@@ -36,17 +36,14 @@ namespace Muon
    *  This is the algorithm that convert STGC Raw data  To STGC PRD  as a tool.
    */  
 
-  class STGC_RawDataToPrepDataTool : virtual public IMuonRdoToPrepDataTool, virtual public AthAlgTool
+  class sTgcRdoToPrepDataTool : virtual public IMuonRdoToPrepDataTool, virtual public AthAlgTool
     {
     public:
       /** Constructor */
-      STGC_RawDataToPrepDataTool(const std::string& t, const std::string& n, const IInterface* p);
+      sTgcRdoToPrepDataTool(const std::string& t, const std::string& n, const IInterface* p);
       
       /** Destructor */
-      virtual ~STGC_RawDataToPrepDataTool();
-      
-      /** Query the IMuonRdoToPrepDataTool interface */
-      virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvIf) override;
+      virtual ~sTgcRdoToPrepDataTool();
       
       /** Standard AthAlgTool initialize method */
       virtual StatusCode initialize() override;
@@ -58,7 +55,12 @@ namespace Muon
        *  @param requestedIdHashVect          Vector of hashes to convert i.e. the hashes of ROD collections in a 'Region of Interest'  
        *  @return selectedIdHashVect This is the subset of requestedIdVect which were actually found to contain data   
        *  (i.e. if you want you can use this vector of hashes to optimise the retrieval of data in subsequent steps.) */ 
-      virtual StatusCode decode(std::vector<IdentifierHash>& idVect, std::vector<IdentifierHash>& idWithDataVect) override;
+      StatusCode decode(std::vector<IdentifierHash>& idVect, std::vector<IdentifierHash>& idWithDataVect);
+      StatusCode decode(const std::vector<uint32_t>& robIds);
+
+      
+      StatusCode processCollection(const STGC_RawDataCollection *rdoColl, 
+				   std::vector<IdentifierHash>& idWithDataVect);
 
       virtual void printPrepData() override;
       virtual void printInputRdo() override;
@@ -68,27 +70,32 @@ namespace Muon
       
     private:
       
-      void processPRDHashes( const std::vector<IdentifierHash>& chamberHashInRobs, std::vector<IdentifierHash>& idWithDataVect, sTgcPrepDataContainer& prds );
-      bool handlePRDHash( IdentifierHash hash, const STGC_RawDataContainer& rdoContainer, std::vector<IdentifierHash>& idWithDataVect, sTgcPrepDataContainer& prds );
-      
+      enum SetupSTGC_PrepDataContainerStatus {
+	FAILED = 0, ADDED, ALREADYCONTAINED
+      };
+
+      SetupSTGC_PrepDataContainerStatus setupSTGC_PrepDataContainer();
+
+      const STGC_RawDataContainer* getRdoContainer();
+
+      void processRDOContainer(std::vector<IdentifierHash>& idWithDataVect);
+
       /** muon detector manager */
       const MuonGM::MuonDetectorManager * m_muonMgr;
 
       /** TGC identifier helper */
-      const sTgcIdHelper* m_sTGC_Helper;
+      const sTgcIdHelper* m_stgcIdHelper;
+      const MuonIdHelper* m_muonIdHelper;
+
+      bool m_fullEventDone;
 
       /** TgcPrepRawData container key for current BC */ 
       std::string m_outputCollectionLocation;      
-            
-      /** ToolHandle of the TGC_RawDataProviderTool */
-      ToolHandle<IMuonRawDataProviderTool> m_rawDataProviderTool;
-
-      SG::ReadHandleKey<STGC_RawDataContainer> m_RDO_Key;//"TGCRDO"
-      SG::WriteHandleKey<sTgcPrepDataContainer> m_PRD_Key;
+      Muon::sTgcPrepDataContainer* m_stgcPrepDataContainer;
+      SG::ReadHandleKey<STGC_RawDataContainer> m_rdoContainerKey;//"TGCRDO"
+      SG::WriteHandleKey<sTgcPrepDataContainer> m_stgcPrepDataContainerKey;
 
-      /** Aboid compiler warning **/
-      virtual StatusCode decode( const std::vector<uint32_t>& /*robIds*/ ) override {return StatusCode::FAILURE;}
    }; 
 } // end of namespace
 
-#endif // MUONTGC_CNVTOOLS_TGCRDOTOPREPDATATOOL_H
+#endif // MUONTGC_CNVTOOLS_STGCRDOTOPREPDATATOOL_H
-- 
GitLab