15#include "GaudiKernel/MsgStream.h"
16#include "GaudiKernel/SmartDataPtr.h"
18#include "GaudiKernel/ThreadGaudi.h"
21#include "EventModel/EventModel.h"
22#include "Identifier/Identifier.h"
23#include "Identifier/TofID.h"
24#include "McTruth/TofMcHit.h"
25#include "RawDataCnv/EventManagement/RAWEVENT.h"
26#include "RawDataCnv/EventManagement/RawEvent.h"
27#include "RawDataCnv/RawDataInputSvc.h"
28#include "RawDataCnv/RawDataTofMcHitCnv.h"
52 std::string PackedRawDataCnvSvc_Name(
"PackedRawDataCnvSvc");
53 std::string RawDataInputSvc_Name(
"RawDataInputSvc");
54 std::string RawDataTofMcHitCnv_Name(
"RawDataTofMcHitCnv");
59 SmartIF<IService> pCnvSvc(conversionSvc());
60 if (isGaudiThreaded(pCnvSvc->name())){
61 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
62 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
63 RawDataTofMcHitCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
67 MsgStream log(messageService(), RawDataTofMcHitCnv_Name.c_str());
70 if (StatusCode::SUCCESS != sc) {
71 log << MSG::ERROR <<
"RawDataBaseCnv: Cant initialize PackedRawDataCnvSvc" << endreq;
77 sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc,
true);
78 if (sc != StatusCode::SUCCESS) {
79 log << MSG::ERROR <<
"Cant get PackedRawDataCnvSvc" << endreq;
83 if (m_RawDataAccess == 0 ) {
84 log << MSG::ERROR <<
"RawDataTofCnv: Cant cast to RawDataCnvSvc " << endreq;
85 return StatusCode::FAILURE;
88 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), isvc);
89 if (sc != StatusCode::SUCCESS ) {
90 log << MSG::WARNING <<
"Cant get RawDataInputSvc " << endreq;
95 if (m_inputSvc == 0 ) {
96 log << MSG::WARNING <<
"Cant cast to RawDataInputSvc " << endreq;
97 return StatusCode::FAILURE ;
100 return StatusCode::SUCCESS;
110 return Converter::updateObj(pAddr, pObj);
116 MsgStream log(
msgSvc(),
"RawDataTofMcHitCnv");
119 TofMcHitCol *tofMcHitCol =
new TofMcHitCol;
125 return StatusCode::FAILURE;
133 std::vector<uint32_t>::const_iterator
iter = evt->
getTofTruth().begin();
134 std::vector<uint32_t>::const_iterator eiter = evt->
getTofTruth().end();
136 for (
int tofMcHitId = 0;
iter != eiter; tofMcHitId++) {
138 m_tofMcHitBuilder.
unPack(
iter, eiter, m_TofTruth);
141 unsigned int barrel_ec = m_TofTruth.
partId;
143 if( barrel_ec>=0 && barrel_ec<=2 ) {
144 unsigned int layer = 0;
152 else if( barrel_ec>=3 ) {
153 unsigned int endcap = 0;
154 if( barrel_ec==4 ) { endcap = 1; }
158 log << MSG::ERROR <<
"barrel_ec is not correct! barrel_ec=" << barrel_ec << endreq;
163 m_TofTruth.
x/(m_tofMcHitBuilder.
m_xCoeff*1.0),
164 m_TofTruth.
y/(m_tofMcHitBuilder.
m_yCoeff*1.0),
165 m_TofTruth.
z/(m_tofMcHitBuilder.
m_zCoeff*1.0),
172 tofMcHitCol->push_back(tofMcHit);
175 return StatusCode::SUCCESS;
188 return StatusCode::FAILURE;
195 return StatusCode::FAILURE;
198 StatusCode sc = m_tofMcHitBuilder.
pack(mcHitCol, re);
const CLID & CLID_TofMcHitCol
unsigned const long PACKEDRAWEVENT_StorageType
const CLID & CLID_TofMcHitCol
virtual WriteRawEvent *& getRawEvent()
const int_vector & getTofTruth() const
static const CLID & classID()
RawDataTofMcHitCnv(ISvcLocator *svc)
virtual StatusCode updateObj(IOpaqueAddress *, DataObject *)
override the RawDataBaseCnv version
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
static Identifier cell_id(int barrel_ec, int layer, int phi_module, int end)
For a single crystal.
static value_type getPHI_BARREL_MAX()
virtual void unPack(vector< uint32_t >::const_iterator &, vector< uint32_t >::const_iterator &, TofTruth_t &)
uint64_t m_trackLengthCoeff
virtual StatusCode pack(TofMcHitCol *tofMcHitCol, WriteRawEvent *&re)
_EXTERN_ std::string TofMcHitCol
ObjectVector< TofMcHit > TofMcHitCol