Skip to content
Snippets Groups Projects
Commit 422d0ea3 authored by Hong Ma's avatar Hong Ma Committed by Graeme Stewart
Browse files

initial version (CaloSimEventTPCnv-00-00-00)

parent 9fd993a2
No related merge requests found
Showing
with 736 additions and 0 deletions
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCNV_P1_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCNV_P1_H
#include "CaloSimEvent/CaloCalibrationHit.h"
#include "CaloSimEventTPCnv/CaloCalibrationHit_p1.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
class MsgStream;
class CaloCalibrationHitCnv_p1 : public T_AthenaPoolTPCnvBase<CaloCalibrationHit, CaloCalibrationHit_p1>
{
public:
CaloCalibrationHitCnv_p1() {}
virtual void persToTrans(const CaloCalibrationHit_p1* persObj, CaloCalibrationHit* transObj, MsgStream &log);
virtual void transToPers(const CaloCalibrationHit* transObj, CaloCalibrationHit_p1* persObj, MsgStream &log);
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCNV_P2_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCNV_P2_H
#include "CaloSimEvent/CaloCalibrationHit.h"
#include "CaloSimEventTPCnv/CaloCalibrationHit_p2.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
class MsgStream;
class CaloCalibrationHitCnv_p2 : public T_AthenaPoolTPCnvBase<CaloCalibrationHit, CaloCalibrationHit_p2>
{
public:
CaloCalibrationHitCnv_p2() {}
virtual void persToTrans(const CaloCalibrationHit_p2* persObj, CaloCalibrationHit* transObj, MsgStream &log);
virtual void transToPers(const CaloCalibrationHit* transObj, CaloCalibrationHit_p2* persObj, MsgStream &log);
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P1_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P1_H
#define private public
#include "CaloSimEventTPCnv/CaloCalibrationHitContainer_p1.h"
#undef private
#include "CaloSimEvent/CaloCalibrationHitContainer.h"
#include "CaloCalibrationHitCnv_p1.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
typedef T_AthenaHitsVectorCnv< CaloCalibrationHitContainer, CaloCalibrationHitContainer_p1, CaloCalibrationHitCnv_p1 > CaloCalibrationHitContainerCnv_p1;
#endif // not CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P1_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P2_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P2_H
#define private public
#include "CaloSimEventTPCnv/CaloCalibrationHitContainer_p2.h"
#undef private
#include "CaloSimEvent/CaloCalibrationHitContainer.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
//typedef T_AthenaHitsVectorCnv< CaloCalibrationHitContainer, CaloCalibrationHitContainer_p1, CaloCalibrationHitCnv_p1 > CaloCalibrationHitContainerCnv_p1;
class CaloCalibrationHitContainerCnv_p2 : public T_AthenaPoolTPCnvBase<CaloCalibrationHitContainer, CaloCalibrationHitContainer_p2>
{
public:
CaloCalibrationHitContainerCnv_p2(){};
virtual void persToTrans(const CaloCalibrationHitContainer_p2* persColl, CaloCalibrationHitContainer* transColl, MsgStream &log);
virtual void transToPers(const CaloCalibrationHitContainer* transColl, CaloCalibrationHitContainer_p2* persColl, MsgStream &log);
private:
};
#endif // not CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P2_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P3_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P3_H
#define private public
#include "CaloSimEventTPCnv/CaloCalibrationHitContainer_p3.h"
#undef private
#include "CaloSimEvent/CaloCalibrationHitContainer.h"
#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h"
//typedef T_AthenaHitsVectorCnv< CaloCalibrationHitContainer, CaloCalibrationHitContainer_p1, CaloCalibrationHitCnv_p1 > CaloCalibrationHitContainerCnv_p1;
class CaloCalibrationHitContainerCnv_p3 : public T_AthenaPoolTPCnvBase<CaloCalibrationHitContainer, CaloCalibrationHitContainer_p3>
{
public:
CaloCalibrationHitContainerCnv_p3(){};
virtual void persToTrans(const CaloCalibrationHitContainer_p3* persColl, CaloCalibrationHitContainer* transColl, MsgStream &log);
virtual void transToPers(const CaloCalibrationHitContainer* transColl, CaloCalibrationHitContainer_p3* persColl, MsgStream &log);
private:
};
#endif // not CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINERCNV_P1_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINER_P1_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINER_P1_H
#include <vector>
#include <string>
#include "CaloSimEventTPCnv/CaloCalibrationHit_p1.h"
class CaloCalibrationHitContainer_p1
{
public:
/// typedefs
typedef std::vector<CaloCalibrationHit_p1> HitVector;
typedef HitVector::const_iterator const_iterator;
typedef HitVector::iterator iterator;
/// Default constructor
CaloCalibrationHitContainer_p1();
// Accessors
const std::string& name() const;
const HitVector& getVector() const;
private:
std::vector<CaloCalibrationHit_p1> m_cont;
std::string m_name;
};
// inlines
inline CaloCalibrationHitContainer_p1::CaloCalibrationHitContainer_p1() {}
inline const std::string& CaloCalibrationHitContainer_p1::name() const {return m_name;}
inline const std::vector<CaloCalibrationHit_p1>& CaloCalibrationHitContainer_p1::getVector() const {return m_cont;}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINER_P2_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINER_P2_H
/**
@class CaloCalibrationHitContainer_p2
@brief Persistent represenation of a CaloCalibrationContainer,
@author: Ilija Vukotic
*/
#include <vector>
#include <string>
class CaloCalibrationHitContainer_p2
{
public:
/// Default constructor
CaloCalibrationHitContainer_p2();
// Accessors
const std::string& name() const;
private:
std::vector<unsigned int> m_channelHash;
std::vector<unsigned int> m_energy; // 18 bits compressed - all four of them in the same array
// std::vector<unsigned int> m_energy1; // 18 bits compressed
// std::vector<unsigned int> m_energy2; // 18 bits compressed
// std::vector<unsigned int> m_energy3; // 18 bits compressed
std::string m_name;
};
// inlines
inline CaloCalibrationHitContainer_p2::CaloCalibrationHitContainer_p2() {}
inline const std::string& CaloCalibrationHitContainer_p2::name() const {return m_name;}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINER_P3_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHITCONTAINER_P3_H
/**
@class CaloCalibrationHitContainer_p3
@brief Persistent represenation of a CaloCalibrationContainer,
@author: Ilija Vukotic
*/
#include <vector>
#include <string>
class CaloCalibrationHitContainer_p3
{
public:
/// Default constructor
CaloCalibrationHitContainer_p3();
// Accessors
const std::string& name() const;
private:
std::vector<unsigned int> m_channelHash;
std::vector<unsigned int> m_energy; // 18 bits compressed - all four of them in the same array
// std::vector<unsigned int> m_energy1; // 18 bits compressed
// std::vector<unsigned int> m_energy2; // 18 bits compressed
// std::vector<unsigned int> m_energy3; // 18 bits compressed
std::string m_name;
std::vector<unsigned int> m_particleID;
};
// inlines
inline CaloCalibrationHitContainer_p3::CaloCalibrationHitContainer_p3() {}
inline const std::string& CaloCalibrationHitContainer_p3::name() const {return m_name;}
#endif
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHIT_P1_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHIT_P1_H
/** @class CaloCalibrationHit_p1
@brief Persistent CaloCalibrationHit class, version p1.
*/
#include "Identifier/Identifier.h"
class CaloCalibrationHit_p1
{
public:
CaloCalibrationHit_p1()
: m_energy0(0),
m_energy1(0),
m_energy2(0),
m_energy3(0)
{}
friend class CaloCalibrationHitCnv_p1;
private:
/** identifier of the cell in which this hit occured. */
Identifier m_ID;
/** energies (in MeV) deposited in this hit. In order, they represent:
* EM energy deposited
* non-EM energy deposited
* "invisible" energy deposited
* escaped energy */
float m_energy0;
float m_energy1;
float m_energy2;
float m_energy3;
};
#endif
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTTPCNV_CALOCALIBRATIONHIT_P2_H
#define CALOSIMEVENTTPCNV_CALOCALIBRATIONHIT_P2_H
/** @class CaloCalibrationHit_p2
@brief Persistent CaloCalibrationHit class, version p2.
*/
#include "Identifier/Identifier.h"
class CaloCalibrationHit_p2
{
public:
CaloCalibrationHit_p2()
: m_energy0(0),
m_energy1(0),
m_energy2(0),
m_energy3(0),
m_particleID(0)
{}
friend class CaloCalibrationHitCnv_p2;
private:
/** identifier of the cell in which this hit occured. */
Identifier m_ID;
/** energies (in MeV) deposited in this hit. In order, they represent:
* EM energy deposited
* non-EM energy deposited
* "invisible" energy deposited
* escaped energy */
float m_energy0;
float m_energy1;
float m_energy2;
float m_energy3;
/** identifier of Primary Particle which caused this hit */
unsigned int m_particleID;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOSIMEVENTATHENAPOOL_CALOSIMEVENTATHENAPOOLCNVDICT_H
#define CALOSIMEVENTATHENAPOOL_CALOSIMEVENTATHENAPOOLCNVDICT_H
#include "CaloSimEventTPCnv/CaloCalibrationHitContainer_p1.h"
//Version 2
#include "CaloSimEventTPCnv/CaloCalibrationHitContainer_p2.h"
//Version 3
#include "CaloSimEventTPCnv/CaloCalibrationHitContainer_p3.h"
#include "CaloSimEventTPCnv/CaloCalibrationHit_p2.h"
#endif
<lcgdict>
<!-- optimized version 3 -->
<class name="CaloCalibrationHit_p1" />
<class name="std::vector<CaloCalibrationHit_p1>" />
<class name="CaloCalibrationHitContainer_p1" id="185FEF89-2350-4D1E-A1A7-9CB5A357232E" />
<class name="CaloCalibrationHitContainer_p2" id="4942B9D4-F545-4C68-BD2D-A8E5923C29F3" />
<!-- optimized version 4 -->
<class name="CaloCalibrationHit_p2" />
<class name="CaloCalibrationHitContainer_p3" id="D4E51325-2A55-41E4-B163-5224F2FA27CB" />
</lcgdict>
<lcgdict>
</lcgdict>
package CaloSimEventTPCnv
author Walter Lampl <walter.lampl@cern.ch>
author RD Schaffer <R.D.Schaffer@cern.ch>
use AtlasPolicy AtlasPolicy-*
use AthenaPoolCnvSvc AthenaPoolCnvSvc-* Database/AthenaPOOL
use CaloSimEvent CaloSimEvent-* Calorimeter
use Identifier Identifier-* DetectorDescription
private
use AtlasReflex AtlasReflex-* External
use AthenaKernel AthenaKernel-* Control
use EventCommonTPCnv EventCommonTPCnv-* Event
use CaloIdentifier CaloIdentifier-* Calorimeter
end_private
apply_pattern tpcnv_library
library CaloSimEventTPCnv *.cxx
private
apply_pattern lcgdict dict=CaloSimEventTPCnv selectionfile=selection.xml headerfiles="../CaloSimEventTPCnv/CaloSimEventTPCnvDict.h"
apply_pattern lcgdict dict=OLD_CaloSimEventTPCnv selectionfile=OLD_selection.xml headerfiles="../CaloSimEventTPCnv/CaloSimEventTPCnvDict.h"
#use TestTools TestTools-* AtlasTest
#apply_pattern UnitTest_run unit_test=CaloCellLinkContainerCnv_p2 extrapatterns='Athena::getMessageSvc'
#apply_pattern UnitTest_run unit_test=CaloClusterContainerCnv
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#define private public
#define protected public
#include "CaloSimEvent/CaloCalibrationHit.h"
#undef private
#undef protected
#include "Identifier/Identifier.h"
#include "CaloSimEventTPCnv/CaloCalibrationHit_p1.h"
#include "CaloSimEventTPCnv/CaloCalibrationHitCnv_p1.h"
void CaloCalibrationHitCnv_p1::persToTrans(const CaloCalibrationHit_p1* persObj, CaloCalibrationHit* transObj, MsgStream &log)
{
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "CaloCalibrationHitCnv_p1::persToTrans called " << endreq;
transObj->m_ID = Identifier(persObj->m_ID);
transObj->m_energy0 = (double) persObj->m_energy0;
transObj->m_energy1 = (double) persObj->m_energy1;
transObj->m_energy2 = (double) persObj->m_energy2;
transObj->m_energy3 = (double) persObj->m_energy3;
}
void CaloCalibrationHitCnv_p1::transToPers(const CaloCalibrationHit* transObj, CaloCalibrationHit_p1* persObj, MsgStream &log)
{
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "CaloCalibrationHitCnv_p1::transToPers called " << endreq;
persObj->m_ID = transObj->m_ID.get_compact();
persObj->m_energy0 = (float) transObj->m_energy0;
persObj->m_energy1 = (float) transObj->m_energy1;
persObj->m_energy2 = (float) transObj->m_energy2;
persObj->m_energy3 = (float) transObj->m_energy3;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#define private public
#define protected public
#include "CaloSimEvent/CaloCalibrationHit.h"
#undef private
#undef protected
#include "Identifier/Identifier.h"
#include "CaloSimEventTPCnv/CaloCalibrationHit_p2.h"
#include "CaloSimEventTPCnv/CaloCalibrationHitCnv_p2.h"
void CaloCalibrationHitCnv_p2::persToTrans(const CaloCalibrationHit_p2* persObj, CaloCalibrationHit* transObj, MsgStream &log)
{
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "CaloCalibrationHitCnv_p2::persToTrans called " << endreq;
transObj->m_ID = Identifier(persObj->m_ID);
transObj->m_energy0 = (double) persObj->m_energy0;
transObj->m_energy1 = (double) persObj->m_energy1;
transObj->m_energy2 = (double) persObj->m_energy2;
transObj->m_energy3 = (double) persObj->m_energy3;
transObj->m_particleID = (unsigned int) persObj->m_particleID;
}
void CaloCalibrationHitCnv_p2::transToPers(const CaloCalibrationHit* transObj, CaloCalibrationHit_p2* persObj, MsgStream &log)
{
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "CaloCalibrationHitCnv_p2::transToPers called " << endreq;
persObj->m_ID = transObj->m_ID.get_compact();
persObj->m_energy0 = (float) transObj->m_energy0;
persObj->m_energy1 = (float) transObj->m_energy1;
persObj->m_energy2 = (float) transObj->m_energy2;
persObj->m_energy3 = (float) transObj->m_energy3;
persObj->m_particleID = (unsigned int) transObj->m_particleID;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#define private public
#define protected public
#include "CaloSimEvent/CaloCalibrationHit.h"
#include "CaloSimEvent/CaloCalibrationHitContainer.h"
#undef private
#undef protected
#include "Identifier/Identifier.h"
#include "Identifier/IdentifierHash.h"
#include "CaloIdentifier/CaloCell_ID.h"
#include "CaloIdentifier/CaloDM_ID.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "EventCommonTPCnv/Compressor.h"
// CaloCalibrationHitContainerCnv_p2, used for T/P separation
// author Ilija Vukotic
#include "CaloSimEventTPCnv/CaloCalibrationHitContainerCnv_p2.h"
#include "map"
void CaloCalibrationHitContainerCnv_p2::transToPers(const CaloCalibrationHitContainer* transCont, CaloCalibrationHitContainer_p2* persCont, MsgStream &log)
{
// static int ev=0;
size_t size = transCont->size();
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing CaloCalibrationHitContainer_p2 of size:"<<size<<endreq;
persCont->m_channelHash.reserve(size);
std::vector<float> tempE; tempE.reserve(size*4);
// const CaloCell_ID* cellIdHelper = (CaloIdManager::instance())->getCaloCell_ID();
// const CaloDM_ID* cellIdHelper = (CaloIdManager::instance())->getDM_ID();
CaloCalibrationHitContainer::const_iterator it = transCont->begin();
std::multimap <unsigned int, unsigned int> map_hashPositions;// first hash ; second its position in container
for (unsigned int w=0;w<size;++w){
//IdentifierHash hashId = cellIdHelper->calo_cell_hash((*it)->m_ID);
unsigned int id = (*it)->m_ID.get_identifier32().get_compact();
/* when hash things are clear it could be usefull to change from storing ID to storing hash
IdentifierHash hashId = -1;
if (cellIdHelper->is_lar_dm(id))
hashId =cellIdHelper->lar_zone_hash(id);
else if (cellIdHelper->is_tile_dm(id))
hashId =cellIdHelper->tile_zone_hash(id)+cellIdHelper->lar_zone_hash_max();
*/
map_hashPositions.insert(std::pair<unsigned int, int>(id, w));
/* if (!ev){
if ( cellIdHelper->is_lar_dm(id) ) std::cout<<"LAR ";
if ( cellIdHelper->is_tile_dm(id)) std::cout<<"TILE ";
std::cout<<hashId;
std::cout<<"\t"<<id<<std::endl;
}*/
++it;
}
std::multimap<unsigned int, unsigned int>::const_iterator iter;
unsigned int old=0;
for (iter=map_hashPositions.begin(); iter != map_hashPositions.end(); ++iter) {
//cout <<"container position:"<< iter->second << " \t hash:" << iter->first << endl;
unsigned int pHash=(iter->first)-old; // to store as a difference
old=iter->first;
unsigned int pos=iter->second;
persCont->m_channelHash.push_back(pHash);
tempE.push_back( (float) (transCont->At(pos))->m_energy0 );
tempE.push_back( (float) (transCont->At(pos))->m_energy1 );
tempE.push_back( (float) (transCont->At(pos))->m_energy2 );
tempE.push_back( (float) (transCont->At(pos))->m_energy3 );
// if (!ev) std::cout<<"Writing Hash: "<<iter->first<<"\t E: "<< (float) (transCont->At(pos))->m_energy0<<std::endl;
}
Compressor A; A.setNrBits(18);
A.reduce(tempE,persCont->m_energy); // packs energy
persCont->m_name = transCont->Name(); //stores name
// ev++;
}
void CaloCalibrationHitContainerCnv_p2::persToTrans(const CaloCalibrationHitContainer_p2* persCont, CaloCalibrationHitContainer* transCont, MsgStream &log)
{
// static int dog=0;
size_t cells=persCont->m_channelHash.size();
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading CaloCalibrationHitContainer of size: "<<cells<<endreq;
transCont->clear();
transCont->reserve(cells);
transCont->setName(persCont->name() );
//const CaloCell_ID* cellIdHelper = (CaloIdManager::instance())->getCaloCell_ID();
//const CaloDM_ID* cellIdHelper = (CaloIdManager::instance())->getDM_ID();
Compressor A;
std::vector<float> tempE; tempE.reserve(cells*4);
A.expandToFloat(persCont->m_energy,tempE);
unsigned int sum=0;
for (unsigned int i=0;i<cells;++i){
CaloCalibrationHit* trans=new CaloCalibrationHit();
sum+= persCont->m_channelHash[i];
/* //trans->m_ID=cellIdHelper->cell_id(sum);
//trans->m_ID=cellIdHelper->lar_zone_id(sum); when story with hashes gets clarified
*/
trans->m_ID=sum;
trans->m_energy0 =(double)tempE[i*4];
trans->m_energy1 =(double)tempE[i*4+1];
trans->m_energy2 =(double)tempE[i*4+2];
trans->m_energy3 =(double)tempE[i*4+3];
// if(!dog) std::cout<<"Reading hash: "<<sum <<"\t E: "<< (double)tempE[i] <<std::endl;
transCont->push_back(trans);
}
// dog++;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#define private public
#define protected public
#include "CaloSimEvent/CaloCalibrationHit.h"
#include "CaloSimEvent/CaloCalibrationHitContainer.h"
#undef private
#undef protected
#include "Identifier/Identifier.h"
#include "Identifier/IdentifierHash.h"
#include "CaloIdentifier/CaloCell_ID.h"
#include "CaloIdentifier/CaloDM_ID.h"
#include "CaloIdentifier/CaloIdManager.h"
#include "EventCommonTPCnv/Compressor.h"
// CaloCalibrationHitContainerCnv_p3, used for T/P separation
// author Ilija Vukotic
#include "CaloSimEventTPCnv/CaloCalibrationHitContainerCnv_p3.h"
#include "map"
void CaloCalibrationHitContainerCnv_p3::transToPers(const CaloCalibrationHitContainer* transCont, CaloCalibrationHitContainer_p3* persCont, MsgStream &log)
{
// static int ev=0;
size_t size = transCont->size();
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Writing CaloCalibrationHitContainer_p3 of size:"<<size<<endreq;
persCont->m_channelHash.reserve(size);
std::vector<float> tempE; tempE.reserve(size*4);
std::vector<unsigned int> tempPID; tempPID.reserve(size);
// const CaloCell_ID* cellIdHelper = (CaloIdManager::instance())->getCaloCell_ID();
// const CaloDM_ID* cellIdHelper = (CaloIdManager::instance())->getDM_ID();
CaloCalibrationHitContainer::const_iterator it = transCont->begin();
std::multimap <unsigned int, unsigned int> map_hashPositions;// first hash ; second its position in container
for (unsigned int w=0;w<size;++w){
//IdentifierHash hashId = cellIdHelper->calo_cell_hash((*it)->m_ID);
unsigned int id = (*it)->m_ID.get_identifier32().get_compact();
/* when hash things are clear it could be usefull to change from storing ID to storing hash
IdentifierHash hashId = -1;
if (cellIdHelper->is_lar_dm(id))
hashId =cellIdHelper->lar_zone_hash(id);
else if (cellIdHelper->is_tile_dm(id))
hashId =cellIdHelper->tile_zone_hash(id)+cellIdHelper->lar_zone_hash_max();
*/
map_hashPositions.insert(std::pair<unsigned int, int>(id, w));
/* if (!ev){
if ( cellIdHelper->is_lar_dm(id) ) std::cout<<"LAR ";
if ( cellIdHelper->is_tile_dm(id)) std::cout<<"TILE ";
std::cout<<hashId;
std::cout<<"\t"<<id<<std::endl;
}*/
++it;
}
std::multimap<unsigned int, unsigned int>::const_iterator iter;
unsigned int old=0;
for (iter=map_hashPositions.begin(); iter != map_hashPositions.end(); ++iter) {
//cout <<"container position:"<< iter->second << " \t hash:" << iter->first << endl;
unsigned int pHash=(iter->first)-old; // to store as a difference
old=iter->first;
unsigned int pos=iter->second;
persCont->m_channelHash.push_back(pHash);
tempE.push_back( (float) (transCont->At(pos))->m_energy0 );
tempE.push_back( (float) (transCont->At(pos))->m_energy1 );
tempE.push_back( (float) (transCont->At(pos))->m_energy2 );
tempE.push_back( (float) (transCont->At(pos))->m_energy3 );
tempPID.push_back( (unsigned int) (transCont->At(pos))->m_particleID );
// if (!ev) std::cout<<"Writing Hash: "<<iter->first<<"\t E: "<< (float) (transCont->At(pos))->m_energy0<<std::endl;
}
Compressor A; A.setNrBits(18);
A.reduce(tempE,persCont->m_energy); // packs energy
persCont->m_name = transCont->Name(); //stores name
persCont->m_particleID = tempPID;
// ev++;
}
void CaloCalibrationHitContainerCnv_p3::persToTrans(const CaloCalibrationHitContainer_p3* persCont, CaloCalibrationHitContainer* transCont, MsgStream &log)
{
// static int dog=0;
size_t cells=persCont->m_channelHash.size();
if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " *** Reading CaloCalibrationHitContainer of size: "<<cells<<endreq;
transCont->clear();
transCont->reserve(cells);
transCont->setName(persCont->name() );
//const CaloCell_ID* cellIdHelper = (CaloIdManager::instance())->getCaloCell_ID();
//const CaloDM_ID* cellIdHelper = (CaloIdManager::instance())->getDM_ID();
Compressor A;
std::vector<float> tempE; tempE.reserve(cells*4);
A.expandToFloat(persCont->m_energy,tempE);
unsigned int sum=0;
for (unsigned int i=0;i<cells;++i){
CaloCalibrationHit* trans=new CaloCalibrationHit();
sum+= persCont->m_channelHash[i];
/* //trans->m_ID=cellIdHelper->cell_id(sum);
//trans->m_ID=cellIdHelper->lar_zone_id(sum); when story with hashes gets clarified
*/
trans->m_ID=sum;
trans->m_energy0 =(double)tempE[i*4];
trans->m_energy1 =(double)tempE[i*4+1];
trans->m_energy2 =(double)tempE[i*4+2];
trans->m_energy3 =(double)tempE[i*4+3];
trans->m_particleID = (unsigned int)persCont->m_particleID[i];
// if(!dog) std::cout<<"Reading hash: "<<sum <<"\t E: "<< (double)tempE[i] <<std::endl;
transCont->push_back(trans);
}
// dog++;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// generate the T/P converter entries
#include "AthenaKernel/TPCnvFactory.h"
#include "CaloSimEventTPCnv/CaloCalibrationHitContainerCnv_p3.h"
DECLARE_TPCNV_FACTORY(CaloCalibrationHitContainerCnv_p3,
CaloCalibrationHitContainer,
CaloCalibrationHitContainer_p3,
Athena::TPCnvVers::Current)
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