Skip to content
Snippets Groups Projects
Commit d2643fac authored by Roland Jansky's avatar Roland Jansky
Browse files

adding TP converters for StripClusters. adding tool to import stripcluster...

adding TP converters for StripClusters. adding tool to import stripcluster information from simple ntuples. changing identifiers of some collections.
parent a69cfe11
No related branches found
No related tags found
No related merge requests found
Showing
with 416 additions and 321 deletions
#ifndef TRKDETSTRIPCLUSTERFORMATION_STRIPCLUSTERIZATION_H
#define TRKDETSTRIPCLUSTERFORMATION_STRIPCLUSTERIZATION_H
//STL
#include <string>
#include <map>
#include <set>
//Gaudi
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
// Base class
#include "AthenaBaseComps/AthAlgorithm.h"
//InDet includes
//Stored by value, cannot be fwd declared
#include "Identifier/IdentifierHash.h"
//template parameter, so should not be possible to just fwd declare
#include "Identifier/Identifier.h"
//Next contains a typedef so cannot be fwd declared
#include "InDetPrepRawData/SCT_ClusterContainer.h"
#include "InDetRawData/SCT_RDO_Container.h"
//tool/service handle template parameters
class SCT_ID;
class SCT_ChannelStatusAlg;
class SiDetectorManager;
class ISvcLocator;
class StatusCode;
class ISCT_FlaggedConditionSvc;
class IInDetConditionsSvc;
namespace InDetDD{
class SiDetectorManager;
}
namespace InDet {
class ISCT_ClusteringTool;
/**
* @class SCT_Clusterization
* @brief Form clusters from SCT Raw Data Objects
* The class loops over an RDO grouping strips and creating collections of clusters, subsequently recorded in StoreGate
* Uses SCT_ConditionsServices to determine which strips to include.
*/
class SCT_Clusterization : public AthAlgorithm {
public:
/// Constructor with parameters:
SCT_Clusterization(const std::string &name,ISvcLocator *pSvcLocator);
/** @name Usual algorithm methods */
//@{
///Retrieve the tools used and initialize variables
virtual StatusCode initialize();
///Form clusters and record them in StoreGate (detector store)
virtual StatusCode execute();
///Clean up and release the collection containers
virtual StatusCode finalize();
//@}
private:
/** @name Disallow default instantiation, copy, assignment */
//@{
SCT_Clusterization() = delete;
SCT_Clusterization(const SCT_Clusterization&) = delete;
SCT_Clusterization &operator=(const SCT_Clusterization&) = delete;
//@}
ToolHandle< ISCT_ClusteringTool > m_clusteringTool; //!< Clustering algorithm
// std::string m_dataObjectName; //!< RDO container name in StoreGate
std::string m_managerName; //REMOVE LATER //!< Detector manager name in StoreGate
// std::string m_clustersName; //REMOVE LATER
// int m_page; //REMOVE LATER //!< Page number for hash function
const SCT_ID* m_idHelper;
// typedef std::map<Identifier, int> IdMap_t;//REMOVE LATER
// IdMap_t m_status;//REMOVE LATER
// IdentifierHash m_maxKey;//REMOVE LATER
SG::ReadHandle<SCT_RDO_Container> m_rdoContainer; //(m_dataObjectName);
SG::WriteHandle<SCT_ClusterContainer> m_clusterContainer;
const InDetDD::SiDetectorManager* m_manager;
unsigned int m_maxRDOs;
ServiceHandle<IInDetConditionsSvc> m_pSummarySvc;
ServiceHandle<ISCT_FlaggedConditionSvc> m_flaggedConditionSvc;
bool m_checkBadModules;
std::set<IdentifierHash> m_flaggedModules;
unsigned int m_maxTotalOccupancyPercent;
};
}
#endif // TRKDETSTRIPCLUSTERFORMATION_STRIPCLUSTERIZATION_H
\ No newline at end of file
#include "InDetPrepRawDataFormation/SCT_Clusterization.h"
#include "InDetPrepRawData/SiClusterContainer.h"
#include "InDetPrepRawData/SCT_ClusterCollection.h"
#include "InDetConditionsSummaryService/IInDetConditionsSvc.h"
#include "InDetRawData/SCT_RDORawData.h"
#include "InDetRawData/SCT_RDO_Container.h"
#include "InDetReadoutGeometry/SiDetectorManager.h"
#include "AtlasDetDescr/AtlasDetectorID.h"
#include "InDetIdentifier/SCT_ID.h"
#include "SCT_ConditionsServices/ISCT_FlaggedConditionSvc.h"
#include "SiClusterizationTool/ISCT_ClusteringTool.h"
#include "StoreGate/StoreClearedIncident.h"
#include "GaudiKernel/PropertyMgr.h"
#include "GaudiKernel/IIncidentSvc.h"
#include "StoreGate/DataHandle.h"
#include "CxxUtils/make_unique.h"
namespace InDet{
using namespace InDet;
static const std::string moduleFailureReason("SCT_Clusterization: Exceeds max RDOs");
// Constructor with parameters:
SCT_Clusterization::SCT_Clusterization(const std::string &name, ISvcLocator *pSvcLocator) :
AthAlgorithm(name,pSvcLocator),
m_clusteringTool("InDet::SCT_ClusteringTool", this), //Changed to private // public - does this need to be changed for athenaMT
// m_dataObjectName("SCT_RDOs"), // RDO container
m_managerName("SCT"),
// m_clustersName("NOTTHISNOTHIS"),
// m_page(0),
m_idHelper(nullptr),
// m_maxKey(0),
m_rdoContainer(),
m_clusterContainer(),
m_manager(nullptr),
m_maxRDOs(384), //(77),
m_pSummarySvc("SCT_ConditionsSummarySvc", name),
m_flaggedConditionSvc("SCT_FlaggedConditionSvc",name),
m_checkBadModules(true),
m_flaggedModules(),
m_maxTotalOccupancyPercent(10)
{
// Get parameter values from jobOptions file
declareProperty("DataObjectName", m_rdoContainer = SG::ReadHandle<SCT_RDO_Container> ("SCT_RDOs"), "SCT RDOs" );
declareProperty("DetectorManagerName",m_managerName);
declareProperty("clusteringTool",m_clusteringTool); //inconsistent nomenclature!
// declareProperty("ClustersName",m_clustersName);
// declareProperty("PageNumber",m_page);
declareProperty("conditionsService" , m_pSummarySvc);
declareProperty("maxRDOs", m_maxRDOs);
declareProperty("checkBadModules",m_checkBadModules);
declareProperty("FlaggedConditionService", m_flaggedConditionSvc);
declareProperty("maxTotalOccupancyInPercent",m_maxTotalOccupancyPercent);
declareProperty("ClustersName",
m_clusterContainer = SG::WriteHandle<SCT_ClusterContainer>("SCT_Clusters"),
"SCT cluster container");
}
// Initialize method:
StatusCode SCT_Clusterization::initialize(){
ATH_MSG_INFO( "SCT_Clusterization::initialize()!");
// Get the conditions summary service (continue anyway, just check the pointer
// later and declare everything to be 'good' if it is NULL)
if (m_checkBadModules){
ATH_MSG_INFO( "Clusterization has been asked to look at bad module info" );
ATH_CHECK(m_pSummarySvc.retrieve());
}
// Get the flagged conditions service
ATH_CHECK(m_flaggedConditionSvc.retrieve());
// Get the clustering tool
ATH_CHECK (m_clusteringTool.retrieve());
// Get the SCT manager
ATH_CHECK (detStore()->retrieve(m_manager,"SCT"));
// Get the SCT ID helper
ATH_CHECK (detStore()->retrieve(m_idHelper,"SCT_ID"));
ATH_MSG_INFO( "Container m_clusterContainer '" << m_clusterContainer.name() << "' set");
return StatusCode::SUCCESS;
}
// Execute method:
StatusCode SCT_Clusterization::execute(){
// Register the IdentifiableContainer into StoreGate
// ATH_MSG_INFO( "Container m_clusterContainer '" << m_clusterContainer.name() << "' set");
m_clusterContainer = CxxUtils::make_unique<SCT_ClusterContainer>(m_idHelper->wafer_hash_max());
// declare the container:
// m_clusterContainer->addRef();
SiClusterContainer* symSiContainer = nullptr;
StatusCode sc = evtStore()->symLink(m_clusterContainer.cptr(), symSiContainer);
if (sc.isFailure()) {
ATH_MSG_FATAL("Pixel clusters could not be symlinked in StoreGate !");
return StatusCode::FAILURE;
} else {
ATH_MSG_DEBUG( "Pixel clusters '" << m_clusterContainer.name() << "' symlinked in StoreGate");
}
if (! m_clusterContainer.isValid() ){
msg(MSG:: FATAL) << "Container of type SCT_ClusterContainer could not be initialised !"<< endreq;
return StatusCode::FAILURE;
}else{
ATH_MSG_DEBUG( "Container '" << m_clusterContainer.name() << "' initialised" );
}
// First, we have to retrieve and access the container, not because we want to
// use it, but in order to generate the proxies for the collections, if they
// are being provided by a container converter.
// const SG::ReadHandle<SCT_RDO_Container> p_rdoContainer(m_dataObjectName);
if (!m_rdoContainer.isValid()){
msg(MSG:: FATAL) << "Could not find the data object "<< m_rdoContainer.name() << " !" << endreq;
return StatusCode::FAILURE;
}
// Anything to dereference the DataHandle will trigger the converter
m_rdoContainer->clID();
SCT_RDO_Container::const_iterator rdoCollections = m_rdoContainer->begin();
SCT_RDO_Container::const_iterator rdoCollectionsEnd = m_rdoContainer->end();
bool dontDoClusterization(false);
//new code to remove large numbers of hits (what is large?)
if (m_maxTotalOccupancyPercent != 100){
constexpr int totalNumberOfChannels(6279168);
const int maxAllowableHits(totalNumberOfChannels*m_maxTotalOccupancyPercent/100);//integer arithmetic, should be ok
int totalHits(0);
for(; rdoCollections != rdoCollectionsEnd; ++rdoCollections){
const InDetRawDataCollection<SCT_RDORawData>* rd(*rdoCollections);
totalHits+=rd->size();
}//iterator is now at the end
//reset the iterator
rdoCollections = m_rdoContainer->begin();
if (totalHits > maxAllowableHits) {
ATH_MSG_INFO("This event has too many hits in the SCT");
dontDoClusterization=true;
}
}
//detType doesn't seem to do anything, does it need to be here?
// AtlasDetectorID detType;
if (not dontDoClusterization){
for(; rdoCollections != rdoCollectionsEnd; ++rdoCollections){
const InDetRawDataCollection<SCT_RDORawData>* rd(*rdoCollections);
#ifndef NDEBUG
ATH_MSG_DEBUG("RDO collection size=" << rd->size() << ", Hash=" << rd->identifyHash());
#endif
bool goodModule = (m_checkBadModules and m_pSummarySvc) ? m_pSummarySvc->isGood(rd->identifyHash()) : true;
// Check the RDO is not empty and that the wafer is good according to the conditions
if ((not rd->empty()) and goodModule){
// If more than a certain number of RDOs set module to bad
if (m_maxRDOs and (rd->size() > m_maxRDOs)) {
m_flaggedConditionSvc->flagAsBad(rd->identifyHash(), moduleFailureReason);
m_flaggedModules.insert(rd->identifyHash());
continue;
}
// Use one of the specific clustering AlgTools to make clusters
std::unique_ptr<SCT_ClusterCollection> clusterCollection ( m_clusteringTool->clusterize(*rd,*m_manager,*m_idHelper));
if (clusterCollection) {
// ATH_MSG_DEBUG("SCT_ClusterCollection" << clusterCollection->size() << "\n");
if (not clusterCollection->empty()) {
//Using get because I'm unsure of move semantec status
if (m_clusterContainer->addCollection(clusterCollection.get(), clusterCollection->identifyHash()).isFailure()){
msg(MSG:: FATAL) << "Clusters could not be added to container !"<< endreq;
// delete clusterCollection; // Graceful exit?
return StatusCode::FAILURE;
} else {
#ifndef NDEBUG
ATH_MSG_DEBUG("Clusters with key '" << clusterCollection->identifyHash() << "' added to Container\n");
#endif
clusterCollection.release();//Release ownership if sucessfully added to collection
}
} else {
#ifndef NDEBUG
ATH_MSG_DEBUG("Don't write empty collections\n");
#endif
// delete clusterCollection;
}
} else {
ATH_MSG_DEBUG("Clustering algorithm found no clusters\n");
}
}
}
}
// Set container to const
if (m_clusterContainer.setConst().isFailure()){
ATH_MSG_FATAL("FAILED TO SET CONST");
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
// Finalize method:
StatusCode SCT_Clusterization::finalize()
{
msg(MSG::INFO) << "SCT_Clusterization::finalize() " << PACKAGE_VERSION << endreq;
if (m_maxRDOs) {
msg(MSG::INFO)
<< "Number of noisy modules killed by maximum RDO limit of "
<< m_maxRDOs << " = " << m_flaggedModules.size() << endreq;
msg(MSG::INFO) << "Printing info on up to 10 modules:" << endreq;
std::set<IdentifierHash>::const_iterator itr(m_flaggedModules.begin());
std::set<IdentifierHash>::const_iterator end(m_flaggedModules.end());
for (int num(0); (itr != end) && (num < 10) ; ++itr, ++num) {
msg(MSG::INFO) << "Noisy: " << m_idHelper->print_to_string(m_idHelper->wafer_id(*itr)) << endreq;
}
}
return StatusCode::SUCCESS;
}
}
\ No newline at end of file
################################################################################
# Package: TrkDetStripClusterImporter
################################################################################
# Declare the package name:
atlas_subdir( TrkDetStripClusterImporter )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
xAOD/xAODFaserTracking
GaudiKernel
PRIVATE
Control/AthenaKernel
)
# External dependencies:
find_package( Eigen )
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread EG )
find_package( XercesC )
find_package( Boost )
# Component(s) in the package:
atlas_add_component( TrkDetStripClusterImporter
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${Boost_LIBRARIES} ${EIGEN_LIBRARIES}
AthenaBaseComps xAODFaserTracking GaudiKernel AthenaKernel
)
# Install files from the package:
atlas_install_headers( TrkDetStripClusterImporter )
\ No newline at end of file
#ifndef TRKDETSTRIPCLUSTERIMPORTER_H
#define TRKDETSTRIPCLUSTERIMPORTER_H
//STL
#include <string>
// Base class
#include "AthenaBaseComps/AthAlgorithm.h"
#include "xAODFaserTracking/StripClusterContainer.h"
namespace TrkDet{
class StripClusterImporter : public AthAlgorithm {
public:
/// Constructor with parameters:
StripClusterImporter(const std::string &name,ISvcLocator *pSvcLocator);
~StripClusterImporter();
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
private:
std::string m_clusCollectionName;
StatusCode retrieveFatrasCluster() const;
};
}
#endif // TRKDETSTRIPCLUSTERIMPORTER_H
\ No newline at end of file
from AthenaCommon import CfgMgr
import AthenaRootComps.ReadAthenaRoot
svcMgr.EventSelector.InputCollections = ["/afs/cern.ch/work/r/rjansky/FASER/clusters.root"]
svcMgr.EventSelector.TupleName = "clusters"
# Access the algorithm sequence:
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
from StripClusterImporter.StripClusterImporterConf import TrkDet__StripClusterImporter
# Add the algorithm.
importalg = TrkDet__StripClusterImporter("StripClusterImporter")
importalg.OutputLevel = VERBOSE
topSequence += importalg
print importalg
from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
xaodStream = MSMgr.NewPoolRootStream( "StreamAOD", "XAOD_"+"clusters"+".pool.root" )
xaodStream.AddItem("xAOD::StripClusterContainer#*")
xaodStream.AddItem("xAOD::StripClusterAuxContainer#*")
\ No newline at end of file
#include <vector>
#include "TFile.h"
#include "TTree.h"
#include "TSystem.h"
#include "TInterpreter.h"
void read()
{
gInterpreter->GenerateDictionary("vector<vector<float> >","vector");
TFile *f = TFile::Open("/afs/cern.ch/work/r/rjansky/FASER/clusters.root","READ");
if (!f) { return; }
TTree *t = (TTree*)f->Get("clusters");
Int_t event_nr;
Float_t g_x,g_y,g_z,l_x,l_y;
t->SetBranchAddress("event_nr",&event_nr);
t->SetBranchAddress("g_x",&g_x);
t->SetBranchAddress("g_y",&g_y);
t->SetBranchAddress("g_z",&g_z);
t->SetBranchAddress("l_x",&l_x);
t->SetBranchAddress("l_y",&l_y);
TFile *fNew = TFile::Open("clustersVec.root","RECREATE");
std::vector<float> g_xV,g_yV,g_zV,l_xV,l_yV;
// Create a TTree
TTree *tNew = new TTree("clusters","Tree with clusters");
tNew->Branch("g_x",&g_xV);
tNew->Branch("g_y",&g_yV);
tNew->Branch("g_z",&g_zV);
tNew->Branch("l_x",&l_xV);
tNew->Branch("l_y",&l_yV);
int prevEvent=0;
for (Long64_t i = 0; i < t->GetEntries(); i++) {
t->GetEntry(i);
if(prevEvent!=event_nr&&i!=0){
tNew->Fill();
g_xV.clear();
g_yV.clear();
g_zV.clear();
l_xV.clear();
l_yV.clear();
std::cout << "clearing: " << i <<std::endl;
}
prevEvent=event_nr;
g_xV.push_back(g_x);
g_yV.push_back(g_y);
g_zV.push_back(g_z);
l_xV.push_back(l_x);
l_yV.push_back(l_y);
}
fNew->Write();
delete fNew;
}
void flatTreeConv()
{
read();
}
\ No newline at end of file
#include "TrkDetStripClusterImporter/StripClusterImporter.h"
#include "xAODFaserTracking/StripClusterAuxContainer.h"
namespace TrkDet {
StripClusterImporter::StripClusterImporter (const std::string& name, ISvcLocator* pSvcLocator) :
AthAlgorithm( name, pSvcLocator ),
m_clusCollectionName("StripClusters")
{
declareProperty("OutputClustersName" , m_clusCollectionName);
}
StripClusterImporter::~StripClusterImporter()
{}
StatusCode StripClusterImporter::initialize() {
return StatusCode::SUCCESS;
}
StatusCode StripClusterImporter::finalize()
{
return StatusCode::SUCCESS;
}
StatusCode StripClusterImporter::retrieveFatrasCluster() const
{
const std::vector<float> *g_x,*g_y,*g_z,*l_x,*l_y;
CHECK( evtStore()->retrieve( g_x, "g_x" ) );
CHECK( evtStore()->retrieve( g_y, "g_y" ) );
CHECK( evtStore()->retrieve( g_z, "g_z" ) );
CHECK( evtStore()->retrieve( l_x, "l_x" ) );
CHECK( evtStore()->retrieve( l_y, "l_y" ) );
// Add one strip cluster to the container:
// Create the cluster containers:
xAOD::StripClusterContainer* clusterC = new xAOD::StripClusterContainer();
ATH_CHECK( evtStore()->record( clusterC, m_clusCollectionName ) );
xAOD::StripClusterAuxContainer* aux = new xAOD::StripClusterAuxContainer();
ATH_CHECK( evtStore()->record( aux, m_clusCollectionName + "Aux." ) );
clusterC->setStore( aux );
//p.setLocalPosition( 1.0, 2.0);
//p.setLocalPositionError( 0.2, 0.2, 0.05 );
for(unsigned int i = 0; i<g_x->size();i++){
xAOD::StripCluster* p = new xAOD::StripCluster();
clusterC->push_back( p );
p->setId(i);
float x(g_x->at(i)),y(g_y->at(i)),z(g_z->at(i));
float lx(l_x->at(i)),ly(l_y->at(i));
p->setGlobalPosition( z, y, x );
p->setLocalPosition(lx, ly);
//implement hack for covariance here!
//p->setLocalPositionError(covX, covY, covXY);
ATH_MSG_DEBUG( "global x = " << p->globalX() << ", global y = " << p->globalY() << ", global z = " << p->globalZ() );
}
return StatusCode::SUCCESS;
}
StatusCode StripClusterImporter::execute() {
if(!retrieveFatrasCluster()){
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
}
\ No newline at end of file
#include "TrkDetStripClusterImporter/StripClusterImporter.h"
DECLARE_COMPONENT( TrkDet::StripClusterImporter )
......@@ -43,6 +43,6 @@ namespace xAOD {
// Set up a CLID for the container:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF( xAOD::StripClusterAuxContainer , 1311112289 , 1 )
CLASS_DEF( xAOD::StripClusterAuxContainer , 1314387539 , 1 )
#endif // XAODFASERTRACKING_STRIPCLUSTERAUXCONTAINER_H
\ No newline at end of file
......@@ -13,6 +13,6 @@ namespace xAOD {
// Set up a CLID for the container:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF( xAOD::StripClusterContainer , 1123888166 , 1 )
CLASS_DEF( xAOD::StripClusterContainer , 1123887426 , 1 )
#endif // XAODFASERTRACKING_STRIPCLUSTERCONTAINER_H
\ No newline at end of file
......@@ -22,6 +22,6 @@ namespace xAOD {
// Set up a CLID for the container:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF( xAOD::StripRawDataAuxContainer , 1171743595 , 1 )
CLASS_DEF( xAOD::StripRawDataAuxContainer , 1173573595 , 1 )
#endif // XAODFASERTRACKING_STRIPRAWDATAAUXCONTAINER_H
\ No newline at end of file
......@@ -14,6 +14,6 @@ namespace xAOD {
// Set up a CLID for the container:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF(xAOD::StripRawDataContainer, 1314367244, 1)
CLASS_DEF(xAOD::StripRawDataContainer, 1312857244, 1)
#endif // XAODFASERTRACKING_STRIPRAWDATACONTAINER_H
\ No newline at end of file
......@@ -229,6 +229,6 @@ namespace xAOD {
// Set up a CLID for the class:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF( xAOD::Track, 159016719, 1 )
CLASS_DEF( xAOD::Track, 159248719, 1 )
#endif // XAODFASERTRACKING_TRACK_H
\ No newline at end of file
......@@ -91,7 +91,7 @@ namespace xAOD {
// Set up a CLID and StoreGate inheritance for the class:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF( xAOD::TrackAuxContainer, 1209269198, 1 )
CLASS_DEF( xAOD::TrackAuxContainer, 1209585198, 1 )
#endif // XAODFASERTRACKING_TRACKAUXCONTAINER_H
\ No newline at end of file
......@@ -16,6 +16,6 @@ namespace xAOD {
// Set up a CLID for the container:
#include "xAODCore/CLASS_DEF.h"
CLASS_DEF( xAOD::TrackContainer, 1287425431, 1 )
CLASS_DEF( xAOD::TrackContainer, 1287447991, 1 )
#endif // XAODFASERTRACKING_TRACKCONTAINER_H
\ No newline at end of file
......@@ -36,9 +36,9 @@
<!-- StripCluster dictionaries: -->
<class name="xAOD::StripCluster"/>
<class name="xAOD::StripClusterAuxContainer"
id="61B62A1A-4C51-43A2-9623-1B9E910A81E8"/>
id="61B62A1A-4C51-43A2-8364-1B9E910A81E8"/>
<class name="xAOD::StripClusterContainer"
id="868F1FD8-AFE7-4B40-B12E-73716C37A6B0"/>
id="868F1FD8-A5E7-4B40-B84E-73716C37A6B0"/>
<!-- Smart pointers to objects: -->
<class name="DataLink<xAOD::StripClusterContainer>" />
......
################################################################################
# Package: xAODFaserTrackingAthenaPool
################################################################################
# Declare the package name:
atlas_subdir( xAODFaserTrackingAthenaPool )
# Declare the package's dependencies:
atlas_depends_on_subdirs(
PRIVATE
Control/AthContainers
Control/AthenaKernel
Database/AthenaPOOL/AthenaPoolCnvSvc
Database/AthenaPOOL/AthenaPoolUtilities
xAOD/xAODFaserTracking )
# External dependencies:
find_package( ROOT COMPONENTS Core )
# Component(s) in the package:
atlas_add_poolcnv_library( xAODFaserTrackingAthenaPoolPoolCnv
src/*.h src/*.cxx
FILES xAODFaserTracking/StripClusterContainer.h
xAODFaserTracking/StripClusterAuxContainer.h
TYPES_WITH_NAMESPACE xAOD::StripClusterContainer xAOD::StripClusterAuxContainer
CNV_PFX xAOD
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers AthenaKernel
AthenaPoolCnvSvcLib AthenaPoolUtilities xAODFaserTracking xAODTrackingCnvLib )
\ No newline at end of file
// System include(s):
#include <exception>
// Local include(s):
#include "xAODStripClusterAuxContainerCnv.h"
#include "AthContainers/tools/copyThinned.h"
#include "AthenaKernel/IThinningSvc.h"
xAODStripClusterAuxContainerCnv::
xAODStripClusterAuxContainerCnv( ISvcLocator* svcLoc )
: xAODStripClusterAuxContainerCnvBase( svcLoc ) {
}
xAOD::StripClusterAuxContainer*
xAODStripClusterAuxContainerCnv::
createPersistent( xAOD::StripClusterAuxContainer* trans ) {
// Create a copy of the container:
return SG::copyThinned (*trans, IThinningSvc::instance());
}
xAOD::StripClusterAuxContainer*
xAODStripClusterAuxContainerCnv::createTransient() {
// The known ID(s) for this container:
static const pool::Guid v1_guid( "61B62A1A-4C51-43A2-8364-1B9E910A81E8" );
// Check which version of the container we're reading:
if( compareClassGuid( v1_guid ) ) {
// It's the latest version, read it directly:
return poolReadObject< xAOD::StripClusterAuxContainer >();
}
// If we didn't recognise the ID:
throw std::runtime_error( "Unsupported version of "
"xAOD::StripClusterAuxContainer found" );
return 0;
}
\ No newline at end of file
#ifndef XAODFASERTRACKINGATHENAPOOL_XAODSTRIPCLUSTERAUXCONTAINERCNV_H
#define XAODFASERTRACKINGATHENAPOOL_XAODSTRIPCLUSTERAUXCONTAINERCNV_H
// Gaudi/Athena include(s):
#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h"
// EDM include(s):
#include "xAODFaserTracking/StripClusterAuxContainer.h"
/// Base class for the converter
typedef T_AthenaPoolCustomCnv< xAOD::StripClusterAuxContainer,
xAOD::StripClusterAuxContainer >
xAODStripClusterAuxContainerCnvBase;
/**
* @short POOL converter for the xAOD::StripClusterAuxContainer class
*
*/
class xAODStripClusterAuxContainerCnv :
public xAODStripClusterAuxContainerCnvBase {
public:
/// Converter constructor
xAODStripClusterAuxContainerCnv( ISvcLocator* svcLoc );
protected:
/// Function preparing the container to be written out
virtual xAOD::StripClusterAuxContainer*
createPersistent( xAOD::StripClusterAuxContainer* trans );
/// Function reading in the object from the input file
virtual xAOD::StripClusterAuxContainer* createTransient();
}; // class xAODStripClusterAuxContainerCnv
#endif
// System include(s):
#include <exception>
// Local include(s):
#include "xAODStripClusterContainerCnv.h"
namespace {
/// Helper function setting up the container's link to its auxiliary store
void setStoreLink( SG::AuxVectorBase* cont, const std::string& key ) {
// The link to set up:
DataLink< SG::IConstAuxStore > link( key + "Aux." );
// Give it to the container:
cont->setStore( link );
return;
}
} // private namespace
xAODStripClusterContainerCnv::xAODStripClusterContainerCnv( ISvcLocator* svcLoc )
: xAODStripClusterContainerCnvBase( svcLoc ) {
}
xAOD::StripClusterContainer*
xAODStripClusterContainerCnv::
createPersistent( xAOD::StripClusterContainer* trans ) {
// Create a view copy of the container:
xAOD::StripClusterContainer* result =
new xAOD::StripClusterContainer( trans->begin(), trans->end(),
SG::VIEW_ELEMENTS );
// Return the new container:
return result;
}
/**
* This function needs to be re-implemented in order to figure out the StoreGate
* key of the container that's being created. After that's done, it lets the
* base class do its normal task.
*/
StatusCode xAODStripClusterContainerCnv::createObj( IOpaqueAddress* pAddr,
DataObject*& pObj ) {
// Get the key of the container that we'll be creating:
m_key = *( pAddr->par() + 1 );
ATH_MSG_VERBOSE( "Key of xAOD::StripClusterContainer: " << m_key );
// Let the base class do its thing now:
return AthenaPoolConverter::createObj( pAddr, pObj );
}
xAOD::StripClusterContainer* xAODStripClusterContainerCnv::createTransient() {
// The known ID(s) for this container:
static pool::Guid v1_guid( "868F1FD8-A5E7-4B40-B84E-73716C37A6B0" );
// Check if we're reading the most up to date type:
if( compareClassGuid( v1_guid ) ) {
xAOD::StripClusterContainer* c = poolReadObject< xAOD::StripClusterContainer >();
setStoreLink( c, m_key );
return c;
}
// If we didn't recognise the ID, let's complain:
throw std::runtime_error( "Unsupported version of "
"xAOD::StripClusterContainer found" );
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment