Skip to content
Snippets Groups Projects
Commit 8d3321d7 authored by Ke Li's avatar Ke Li
Browse files

add the elementlink in spacepoint

parent 2d227b8b
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,7 @@ namespace TrackerEventTPCnvDict {
// std::vector< InDetLowBetaCandidate_p1> m_v12;
std::vector<FaserSCT_SpacePoint_p0> m_v13;
std::vector<FaserSCT_SpacePointCollection_p0> m_v14;
std::vector<FaserSCT_SpacePointContainer_p0> m_v15;
};
} //> namespace TrackerEventTPCnvDict
......
......@@ -3,11 +3,20 @@
*/
#include "TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h"
#include "AthLinks/ElementLink.h"
#include "Identifier/Identifier.h"
#include "TrackerPrepRawData/FaserSCT_Cluster.h"
#include "TrackerPrepRawData/FaserSCT_ClusterContainer.h"
void
FaserSCT_SpacePointCnv_p0::persToTrans(const FaserSCT_SpacePoint_p0* persObj, Tracker::FaserSCT_SpacePoint* transObj, MsgStream& /*log*/) {
FaserSCT_SpacePointCnv_p0::persToTrans(const FaserSCT_SpacePoint_p0* persObj, Tracker::FaserSCT_SpacePoint* transObj, MsgStream& log) {
// TODO
ElementLink<Tracker::FaserSCT_ClusterContainer> link1;
ElementLink<Tracker::FaserSCT_ClusterContainer> link2;
m_elCnv.persToTrans(&persObj->m_link1,&link1,log);
m_elCnv.persToTrans(&persObj->m_link2,&link2,log);
Amg::Vector3D pos(persObj->m_pos_x,persObj->m_pos_y,persObj->m_pos_z);
*transObj=Tracker::FaserSCT_SpacePoint(std::make_pair(persObj->m_idHash0,persObj->m_idHash1),&pos,link1,link2);
}
......@@ -28,6 +37,20 @@ FaserSCT_SpacePointCnv_p0::transToPers(const Tracker::FaserSCT_SpacePoint* trans
persObj->m_cov01 = cov(0,1);
persObj->m_cov02 = cov(0,2);
persObj->m_cov11 = cov(1,1);
persObj->m_cov12 = cov(2,2);
persObj->m_cov12 = cov(1,2);
persObj->m_cov22 = cov(2,2);
// static const SG::InitializedReadHandleKey<Tracker::FaserSCT_ClusterContainer> sctClusContName ("FaserSCT_Clusters");
// ElementLink<Tracker::FaserSCT_ClusterContainer>::index_type hashAndIndex1{0};
// ElementLink<Tracker::FaserSCT_ClusterContainer>::index_type hashAndIndex2{0};
// bool isFound1{m_eventCnvTool->getHashAndIndex1<Tracker::FaserSCT_ClusterContainer, Tracker::FaserSCT_SpacePoint>(transObj, sctClusContName, hashAndIndex1)};
// bool isFound2{m_eventCnvTool->getHashAndIndex2<Tracker::FaserSCT_ClusterContainer, Tracker::FaserSCT_SpacePoint>(transObj, sctClusContName, hashAndIndex2)};
// persObj->m_link1.m_contName=(isFound1 ? sctClusContName.key() : "");
// persObj->m_link2.m_contName=(isFound2 ? sctClusContName.key() : "");
// persObj->m_link1.m_elementIndex= hashAndIndex1;
// persObj->m_link2.m_elementIndex= hashAndIndex2;
persObj->m_link1.m_contName = transObj->getElementLink1()->dataID();
persObj->m_link1.m_elementIndex = transObj->getElementLink1()->index();
persObj->m_link2.m_contName = transObj->getElementLink2()->dataID();
persObj->m_link2.m_elementIndex = transObj->getElementLink2()->index();
}
/*
Copyright (C) 2021 CERN for the benefit of the FASER collaboration
*/
Copyright (C) 2021 CERN for the benefit of the FASER collaboration
*/
#include "TrackerEventTPCnv/FaserSCT_SpacePointContainerCnv_p0.h"
#include "TrackerEventTPCnv/FaserSCT_SpacePoint_p0.h"
#include "TrackerEventTPCnv/FaserSCT_SpacePointCollection_p0.h"
#include "TrackerEventTPCnv/FaserSCT_SpacePointCnv_p0.h"
#include "TrackerSpacePoint/FaserSCT_SpacePointContainer.h"
void FaserSCT_SpacePointContainerCnv_p0::persToTrans(const FaserSCT_SpacePointContainer_p0* /*persObj*/, FaserSCT_SpacePointContainer* /*transObj*/, MsgStream& /*log*/) {
void FaserSCT_SpacePointContainerCnv_p0::persToTrans(const FaserSCT_SpacePointContainer_p0* persObj, FaserSCT_SpacePointContainer* transObj, MsgStream& log) {
// TODO
FaserSCT_SpacePointCollection* coll = 0;
FaserSCT_SpacePointCnv_p0 chanCnv;
unsigned int collBegin(0);
for (unsigned int icoll = 0; icoll < persObj->m_spacepoint_collections.size(); ++icoll) {
const FaserSCT_SpacePointCollection_p0& pcoll = persObj->m_spacepoint_collections[icoll];
IdentifierHash collIDHash(IdentifierHash(pcoll.m_idHash));
coll = new FaserSCT_SpacePointCollection(collIDHash);
coll->setIdentifier(Identifier(pcoll.m_id));
unsigned int nchans = pcoll.m_end - pcoll.m_begin;
coll->resize(nchans);
for (unsigned int ichan = 0; ichan < nchans; ++ ichan) {
const FaserSCT_SpacePoint_p0* pchan=&(persObj->m_spacepoints[ichan+collBegin]);
Tracker::FaserSCT_SpacePoint* transSP=nullptr;
chanCnv.persToTrans(pchan, transSP, log);
if(transSP==nullptr)std::cout<<"did not found space"<<std::endl;
(*coll)[ichan]=transSP;
}
collBegin +=nchans;
StatusCode sc = transObj->addCollection(coll, collIDHash);
if (sc.isFailure())
throw std::runtime_error("Failed to add collection to ID Container");
}
}
......@@ -25,7 +48,7 @@ void FaserSCT_SpacePointContainerCnv_p0::transToPers(const FaserSCT_SpacePointCo
unsigned int spCollId;
unsigned int spId = 0;
unsigned int nextSpId = 0;
unsigned int lastIdHash = 0;
//unsigned int lastIdHash = 0;
// resize data vectors
persObj->m_spacepoint_collections.resize(transObj->numberOfCollections());
......@@ -40,12 +63,16 @@ void FaserSCT_SpacePointContainerCnv_p0::transToPers(const FaserSCT_SpacePointCo
const FaserSCT_SpacePointCollection& collection = **spColl;
FaserSCT_SpacePointCollection_p0& pcollection = persObj->m_spacepoint_collections[spCollId];
pcollection.m_size = collection.size();
pcollection.m_idHash = collection.identifyHash() - lastIdHash;
lastIdHash = collection.identifyHash();
pcollection.m_idHash = (unsigned int)collection.identifyHash();
pcollection.m_id = collection.identify().get_compact();
//lastIdHash = collection.identifyHash();
spId = nextSpId;
nextSpId += collection.size();
pcollection.m_begin=spId;
pcollection.m_end=nextSpId;
// create persitent representation of FaserSCT_SpacePoints
for (std::size_t i = 0; i < collection.size(); ++i) {
FaserSCT_SpacePoint_p0* persSP = &(persObj->m_spacepoints[i + spId]);
......
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