diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/cmt/requirements b/TileCalorimeter/TileSvc/TileEventAthenaPool/cmt/requirements new file mode 100755 index 0000000000000000000000000000000000000000..7a981a5e0904a32df25ed5fe521d2cece4d2133a --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/cmt/requirements @@ -0,0 +1,27 @@ +package TileEventAthenaPool + +author Alexandre Solodkov <Sanya.Solodkov@cern.ch> + +private + +use GaudiInterface GaudiInterface-* External +use StoreGate StoreGate-* Control +use AthenaPoolCnvSvc AthenaPoolCnvSvc-* Database/AthenaPOOL +use CaloIdentifier CaloIdentifier-* Calorimeter +use CaloDetDescr CaloDetDescr-* Calorimeter +use TileSimEvent TileSimEvent-* TileCalorimeter +use TileTPCnv TileTPCnv-* TileCalorimeter/TileSvc +use TileEvent TileEvent-* TileCalorimeter + +public + +use AtlasPolicy AtlasPolicy-* +use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL + +apply_pattern poolcnv files="-s=${TileSimEvent_root}/TileSimEvent TileHitVector.h \ + -s=${TileEvent_root}/TileEvent TileHitContainer.h TileDigitsContainer.h TileRawChannelContainer.h TileBeamElemContainer.h \ + TileCellContainer.h TileMuContainer.h TileL2Container.h TileTTL1Container.h \ + TileTriggerContainer.h TileCosmicMuonContainer.h TileCosmicMuon.h TileMuonReceiverContainer.h" + +macro_append TileEventAthenaPoolPoolCnv_shlibflags "$(TileEventAthenaPool_dict_linkopts)" + diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/doc/mainpage.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/doc/mainpage.h new file mode 100644 index 0000000000000000000000000000000000000000..820d76f2467eb0882f81100adc40475f8be45c7b --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/doc/mainpage.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** +@mainpage TileEventAthenaPool Package + +This package handles the conversion of Tile data classes to Pool format. + +@author Alexander Solodkov <sanya.solodkov@cern.ch> + +In order to write the Tile EDM (Event Data Model) objects, defined in the +TileEvent and TileSimEvent packages, into Pool files (ESD, AOD, ...), pool +converters are needed. In many cases, the persistent version of the object can +be a simple copy of the transient one, so the automatic conversion will be +enough. However, in some cases a custom converter is needed if, for instance, +type casts have to be used. + +More details about Pool coversion here: +https://twiki.cern.ch/twiki/bin/view/Atlas/WriteReadDataViaPool + +@section Automatic Pool conversion +The AthenaPoolCnvSvc package provides generic converters via a CMT poolcnv +pattern. The Tile classes that use this are: + +TileEvent/TileMuContainer + TileL2Container + TileTTL1Container + TileTriggerContainer + TileCosmicMuon + +@section Custom Pool conversion + +The other Tile EDM classes have custom converters, defined in this package. + +TileSimEvent/TileHitVector +TileEvent/TileHitContainer.h + TileDigitsContainer.h + TileRawChannelContainer.h + TileBeamElemContainer.h + TileCellContainer.h + +Both TileHit and TileHitVector (and soon, TileDigits), have implemented +Transient/Persistent separation. More details here: +https://twiki.cern.ch/twiki/bin/view/Atlas/TransientPersistentSeparation + +*/ + +/** +@page used_MyPackage Used Packages +@htmlinclude used_packages.html +*/ + +/** +@page requirements_MyPackage Requirements +@include requirements + +*/ diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileBeamElemContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileBeamElemContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..5c58a8edf61c44cd1d71e79a9862efb4a1bfa86d --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileBeamElemContainerCnv.cxx @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileTPCnv/TileBeamElemContainerCnv_p1.h" +#include "TileBeamElemContainerCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" + +TileBeamElemContainer_PERS* TileBeamElemContainerCnv::createPersistent(TileBeamElemContainer* transCont) { + MsgStream mlog(messageService(), "TileBeamElemContainerConverter" ); + TileBeamElemContainerCnv_p1 converter; + TileBeamElemContainer_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + +TileBeamElemContainer* TileBeamElemContainerCnv::createTransient() { + MsgStream mlog(messageService(), "TileBeamElemContainerConverter" ); + TileBeamElemContainerCnv_p1 converter_p1; + + TileBeamElemContainer *trans_cont(0); + + static const pool::Guid p1_guid("CF8DE6AB-8E15-4B5F-881B-39B736EAB4E0"); + static const pool::Guid p0_guid("7FCE8F30-B59E-41E6-9A66-0DCD6134552E"); + + if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< TileBeamElemContainer_p1 > cont( this->poolReadObject< TileBeamElemContainer_p1 >() ); + trans_cont = converter_p1.createTransient( cont.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation + TileBeamElemCollectionVec* rdoV = this->poolReadObject<TileBeamElemCollectionVec>(); + + if (mlog.level()<=MSG::DEBUG) + mlog << MSG::DEBUG << "Read IDC, size " << rdoV->size() << endreq; + + // TileFragHash::TYPE type = rdoV->m_type; + + // create the Tile IdentifiableContainer to contain the rdo collections + trans_cont = new TileBeamElemContainer(false,SG::OWN_ELEMENTS); + + TileBeamElemCollectionVec::iterator it = rdoV->begin(); + TileBeamElemCollectionVec::iterator last = rdoV->end(); + + for (; it != last; ++it) { + + TileBeamElemCollection* rdoColl = *it; + rdoColl->setOwnership(SG::OWN_ELEMENTS); + + // register the rdo collection in StoreGate + TileBeamElemCollection::ID id_coll = rdoColl->identify(); + StatusCode sc = trans_cont->addCollection(rdoColl,trans_cont->hashFunc()(id_coll)); + if(sc.isFailure()) { + mlog << MSG::ERROR << "Can't add collection " << id_coll << " to container " << endreq; + } + } + delete rdoV; + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} + diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileBeamElemContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileBeamElemContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..4d265c3ade109b0b32198be58f23d9dc2d7b0339 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileBeamElemContainerCnv.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TILEBEAMELEMCONTAINERCNV +#define TILEBEAMELEMCONTAINERCNV + +#include "TileEvent/TileBeamElemContainer.h" +#include "TileTPCnv/TileBeamElemContainer_p1.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// typedef to the latest persistent version +typedef TileBeamElemContainer_p1 TileBeamElemContainer_PERS; + +class TileBeamElemContainerCnv : public T_AthenaPoolCustomCnv<TileBeamElemContainer, TileBeamElemContainer_PERS > { + friend class CnvFactory<TileBeamElemContainerCnv>; +protected: + TileBeamElemContainerCnv(ISvcLocator* svcloc) : + T_AthenaPoolCustomCnv<TileBeamElemContainer, TileBeamElemContainer_PERS >( svcloc) {} + TileBeamElemContainer_PERS* createPersistent(TileBeamElemContainer* transCont); + TileBeamElemContainer* createTransient (); +}; + + +#endif + + diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCellContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCellContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..14d2b31620cca8a60d0bb37d5382a28befc4944e --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCellContainerCnv.cxx @@ -0,0 +1,431 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileCellContainerCnv.h" +#include "CaloIdentifier/TileTBID.h" +#include "CaloDetDescr/MbtsDetDescrManager.h" + +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/StatusCode.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IIncidentSvc.h" +#include "GaudiKernel/IChronoStatSvc.h" + +// Athena +#include "StoreGate/StoreGateSvc.h" + +TileCellContainerCnv::TileCellContainerCnv(ISvcLocator* svcloc) + : TileCellContainerCnvBase::T_AthenaPoolCustCnv(svcloc) + // Must create DataVector that does NOT own elements + , m_vecCell() + , m_storeGate(0) + , m_tileTBID(0) + , m_mbtsMgr(0) + , m_version(0) + , m_id() + , m_dde() + , m_gainIndex() + , m_gain() +{ +} + + +TileCellContainerCnv::~TileCellContainerCnv() +{ +} + +StatusCode TileCellContainerCnv::initialize() +{ + // Call base clase initialize + if (!AthenaPoolConverter::initialize().isSuccess()) { + return StatusCode::FAILURE; + } + + // version 2 by default + m_version = 2; + + // Get the messaging service, print where you are + MsgStream log(messageService(), "TileCellContainerCnv"); + log << MSG::INFO << "TileCellContainerCnv::initialize(), packing format version " << m_version << endreq; + + // get StoreGate service + StatusCode sc=service("StoreGateSvc",m_storeGate); + if (sc.isFailure()) { + this->initIdToIndex(); + log << MSG::ERROR << "StoreGate service not found !" << endreq; + // log << MSG::FATAL << "StoreGate service not found !" << endreq; + // return StatusCode::FAILURE; + } + + StoreGateSvc* detStore; + sc=service("DetectorStore",detStore); + if (sc.isFailure()) { + this->initIdToIndex(); + log << MSG::ERROR << "DetectorStore service not found!" << endreq; + // log << MSG::FATAL << "DetectorStore service not found!" << endreq; + // return StatusCode::FAILURE; + } + + sc = detStore->retrieve(m_tileTBID); + if (sc.isFailure()) { + this->initIdToIndex(); + log << MSG::ERROR << "No TileTBID helper" << endreq; + // log << MSG::FATAL << "No TileTBID helper" << endreq; + // return StatusCode::FAILURE; + } else { + for (int side=0; side<nSide; ++side) { + for (int phi=0; phi<nPhi; ++phi) { + for (int eta=0; eta<nEta; ++eta) { + m_id[cell_index(side,phi,eta)] = m_tileTBID->channel_id((side>0)?1:-1,phi,eta); + } + } + } + } + + sc = detStore->retrieve(m_mbtsMgr); + if (sc.isFailure()) { + log << MSG::WARNING << "Unable to retrieve MbtsDetDescrManager from DetectorStore" << endreq; + memset(m_dde,0,sizeof(m_dde)); + } else { + for (int side=0; side<nSide; ++side) { + for (int phi=0; phi<nPhi; ++phi) { + for (int eta=0; eta<nEta; ++eta) { + m_dde[cell_index(side,phi,eta)] = m_mbtsMgr->get_element(m_id[cell_index(side,phi,eta)]); + } + } + } + } + + + // set CaloGain <-> gain index mapping for all possible TileCal gains + for (int i=0; i<17; ++i) m_gainIndex[i] = 8; m_gain[0] = -2; // put non-existing gain here + m_gainIndex[-CaloGain::TILELOWLOW] = 8 + 1; m_gain[1] = (int)CaloGain::TILELOWLOW; + m_gainIndex[-CaloGain::TILELOWHIGH] = 8 + 2; m_gain[2] = (int)CaloGain::TILELOWHIGH; + m_gainIndex[-CaloGain::TILEHIGHLOW] = 8 + 3; m_gain[3] = (int)CaloGain::TILEHIGHLOW; + m_gainIndex[-CaloGain::TILEHIGHHIGH] = 8 + 4; m_gain[4] = (int)CaloGain::TILEHIGHHIGH; + m_gainIndex[-CaloGain::TILEONELOW] = 8 + 5; m_gain[5] = (int)CaloGain::TILEONELOW; + m_gainIndex[-CaloGain::TILEONEHIGH] = 8 + 6; m_gain[6] = (int)CaloGain::TILEONEHIGH; + m_gainIndex[-CaloGain::INVALIDGAIN] = 8 + 7; m_gain[7] = (int)CaloGain::INVALIDGAIN; + + return StatusCode::SUCCESS; +} + +void TileCellContainerCnv::initIdToIndex() +{ + for (int side=0; side<nSide; ++side) { + for (int phi=0; phi<nPhi; ++phi) { + for (int eta=0; eta<nEta; ++eta) { + m_id[cell_index(side,phi,eta)] = (Identifier)cell_index(side,phi,eta); + } + } + } +} + +StatusCode TileCellContainerCnv::transToPers(TileCellContainer* cont, TileCellVec*& persObj) +{ + // Convert every TileCell to 3 32-bit integers: ID,Ene, and (time,qual,qain) + + MsgStream log(messageService(),"TileCellContainerCnv" ); + MSG::Level logLevel = log.level(); + bool lDebug = (logLevel<=MSG::DEBUG); + bool lVerbose = (logLevel<=MSG::VERBOSE); + + if (lDebug) log << MSG::DEBUG << "storing TileCells in POOL" << endreq; + + // Clear vector from previous write + m_vecCell.clear(); + + m_vecCell.push_back(m_version); + + std::vector<const TileCell *> allCells; + + switch (m_version) { + + case 1: // 3 words per cell, energy scale factor is 1000, time scale factor is 100 + for (TileCellContainer::const_iterator it = cont->begin(); it != cont->end(); ++it) { + const TileCell* cell = *it; + if (lVerbose) + log << MSG::VERBOSE + << "ene=" << cell->energy() + << " time=" << cell->time() + << " qual=" << (int)cell->qual1() + << " gain=" << (int)cell->gain() + << endreq; + unsigned int id = cell->ID().get_identifier32().get_compact(); + int ene = round32(cell->energy() * 1000.); + unsigned int tim = 0x8000 + round16(cell->time()*100.); + unsigned int qua = std::max(0, std::min(0xFF, (int)cell->qual1())); + unsigned int gai = std::max(0, std::min(0xFF, 0x80 + (int)(cell->gain()))); + unsigned int tqg = (tim<<16) | (qua<<8) | gai; + m_vecCell.push_back(id); + m_vecCell.push_back((unsigned int)ene); + m_vecCell.push_back(tqg); + if (lVerbose) + log << MSG::VERBOSE << "packing cell in three words " + << MSG::hex << id << " " << ene << " " << tqg << MSG::dec << endreq; + } + break; + + case 2: // 1 or 2 words for MBTS cells, 3 words for others, energy scale factor is 1000, time scale factor is 100 + + // prepare vector with all cells first, expect at least 32 MBTS cells + allCells.resize(nCellMBTS); + for (TileCellContainer::const_iterator it = cont->begin(); it != cont->end(); ++it) { + const TileCell* cell = *it; + Identifier id = cell->ID(); + if (m_tileTBID->is_tiletb(id)) { + int side = std::max(0,m_tileTBID->type(id)); + int phi = m_tileTBID->module(id); + int eta = m_tileTBID->channel(id); + int ind = cell_index(side,phi,eta); + if (ind < nCellMBTS) + allCells[ind] = cell; + else + allCells.push_back(cell); + } else { + allCells.push_back(cell); + } + } + + // save first 32 cells (MBTS) without identifiers, 2 words per cell, put zeros for empty cells + // if MBTS energy is in pCb, then LSB corresponds to 1/12 ADC count of high gain + for (int ind=0; ind<nCellMBTS; ++ind) { + int energy = 0; + int time = 0; + int quality= 0; + int gain = m_gain[0]; // non-existing gain in CaloGain - to mark non-existing cells + const TileCell* cell = allCells[ind]; + if (cell) { + energy = round32(cell->energy() * 1000.); + time = round16(cell->time() * 100.); + quality= cell->qual1(); + gain = cell->gain(); + + if (lVerbose) + log << MSG::VERBOSE + << "ind=" << ind + << " ene=" << cell->energy() + << " time=" << cell->time() + << " qual=" << (int)cell->qual1() + << " gain=" << (int)cell->gain() + << endreq; + } + else { + if (lVerbose) + log << MSG::VERBOSE + << "ind=" << ind + << " create MBTS cell with zero energy" + << endreq; + } + + // put correct MBTS cells in one word + if (time == 0 && // expect time to be equal to zero + -0x10000 < energy && energy < 0xEFFFF && // expect energy within (-65,980) pCb + -17 < gain && gain < 0 ) { // expext only gains in TileCal range + + unsigned int ene = energy+0x10000; // shift by 65 pCb (65*10^3 because of scaling) + unsigned int qua = std::max(0, std::min(0xFF, quality)); // 8 bits for quality + unsigned int gai = m_gainIndex[-gain]; + unsigned int gqe = (gai << 28) | (qua<<20) | ene; // upper most bit is always 1 here + m_vecCell.push_back(gqe); + + if (lVerbose) + log << MSG::VERBOSE << "packing cell " << ind << " in one word " + << MSG::hex << gqe << MSG::dec << endreq; + + } else { // cells with time, use 2 words for channel + // but make sure that upper most bit in energy word is zero + + unsigned int ene = std::max(0, std::min(0x7FFFFFFF, 0x40000000 + energy)); + unsigned int tim = std::max(0, std::min(0xFFFF, 0x8000 + time)); + unsigned int qua = std::max(0, std::min(0xFF, quality)); // 8 bits for quality + unsigned int gai = std::max(0, std::min(0xFF, 0x80 + gain)); + unsigned int tqg = (tim<<16) | (qua<<8) | gai; + m_vecCell.push_back(ene); + m_vecCell.push_back(tqg); + + if (lVerbose) + log << MSG::VERBOSE << "packing cell " << ind << " in two words " + << MSG::hex << ene << " " << tqg << MSG::dec << endreq; + } + } + + // keep all other cells (if any) with identifiers, 3 words per cell + for (unsigned int ind=nCellMBTS; ind<allCells.size(); ++ind) { + + const TileCell* cell = allCells[ind]; + + if (lVerbose) + log << MSG::VERBOSE + << "ind=" << ind + << " ene=" << cell->energy() + << " time=" << cell->time() + << " qual=" << (int)cell->qual1() + << " gain=" << (int)cell->gain() + << endreq; + + unsigned int id = cell->ID().get_identifier32().get_compact(); + int ene = round32(cell->energy() * 1000.); + unsigned int tim = 0x8000 + round16(cell->time()*100.); + unsigned int qua = std::max(0, std::min(0xFF, (int)cell->qual1())); + unsigned int gai = std::max(0, std::min(0xFF, 0x80 + (int)(cell->gain()))); + unsigned int tqg = (tim<<16) | (qua<<8) | gai; + m_vecCell.push_back(id); + m_vecCell.push_back((unsigned int)ene); + m_vecCell.push_back(tqg); + + if (lVerbose) + log << MSG::VERBOSE << "packing cell " << ind << " in three words " + << MSG::hex << id << " " << ene << " " << tqg << MSG::dec << endreq; + } + break; + + default: + + log << MSG::ERROR << "Unknown version of TileCellVec, ver="<<m_version << endreq; + return StatusCode::FAILURE; + } + + persObj = &m_vecCell; + + return StatusCode::SUCCESS; +} + +StatusCode TileCellContainerCnv::persToTrans(TileCellContainer*& cont, TileCellVec* vec) +{ + // Fill TileCellContainer from vector, creating cells from 3 integers + + MsgStream log(messageService(), "TileCellContainerCnv"); + MSG::Level logLevel = log.level(); + bool lDebug = (logLevel<=MSG::DEBUG); + bool lVerbose = (logLevel<=MSG::VERBOSE); + + if (lDebug) log << MSG::DEBUG << "Read TileCell Vec, size " << vec->size() << endreq; + + // create the TileCellContainer + cont = new TileCellContainer(); + + TileCellVec::const_iterator it = vec->begin(); + TileCellVec::const_iterator last = vec->end(); + + unsigned int version = *it++; + int iCell = 0; + + switch (version) { + case 1: + + for (; it != last; ) { + + Identifier id(Identifier32(*it++)); + int ene = (int)(*it++); + unsigned int tqg = *it++; + + float ener = ene/1000.; + float time = ((int)(tqg>>16) - 0x8000 ) / 100.; + uint16_t qual = ((tqg>>8) & 0xFF); + uint16_t qbit = TileCell::MASK_CMPC | TileCell::MASK_TIME; + int gain = (int)(tqg & 0xFF) - 0x80; + + if (lVerbose) { + log << MSG::VERBOSE << "reading cell " << (iCell++) << " " + << MSG::hex << id << MSG::dec << " " << ene << " " + << MSG::hex << tqg << MSG::dec << endreq; + log << MSG::VERBOSE << "ene=" << ener << " time=" << time + << " qual=" << qual << " gain=" << gain << endreq; + } + + TileCell * cell = new TileCell(NULL,id,ener,time,qual,qbit,(CaloGain::CaloGain)gain); + cont->push_back(cell); + } + break; + + case 2: + + for (; it != last; ) { + + Identifier id; + CaloDetDescrElement * dde = NULL; + float ener = 0.0; + float time = 0.0; + uint16_t qual = 0; + uint16_t qbit = TileCell::MASK_CMPC | TileCell::MASK_TIME; + int gain = m_gain[0]; // non-existing gain in CaloGain - to mark non-existing cells + + if (lVerbose) + log << MSG::VERBOSE << "reading cell " << iCell << " "; + + if (iCell < nCellMBTS) { // first 32 cells are MBTS cells without identifier + + id = m_id[iCell]; // identifier is taken from array + dde = m_dde[iCell]; // mbtsDDE is taken from array + + int ene = (int)(*it++); // first word is energy + + if (lVerbose) + log << MSG::hex << id << " " << ene << " " << MSG::dec; + + if (ene < 0 ) { // upper most bit is set, it means that everything is packed in one word + + if (lVerbose) + log << endreq; + + time = 0.0; // time was zero and it was not saved + ener = ((ene & 0xFFFFF) - 0x10000) / 1000.; + qual = ((ene>>20) & 0xFF); + gain = m_gain[((ene>>28) & 0x7)]; // gain is taken from array + + } else { // two words packing + + unsigned int tqg = *it++; + if (lVerbose) + log << MSG::hex << tqg << MSG::dec << endreq; + + ener = (ene - 0x40000000) / 1000.; + time = ((int)(tqg>>16) - 0x8000 ) / 100.; + qual = ((tqg>>8) & 0xFF); + gain = (int)(tqg & 0xFF) - 0x80; + } + + } else { // three words packing for remaining cells + + id = Identifier(Identifier32(*it++)); + int ene = (int)(*it++); + unsigned int tqg = *it++; + + if (lVerbose) + log << MSG::hex << id << MSG::dec << " " << ene << " " + << MSG::hex << tqg << MSG::dec << endreq; + + ener = ene/1000.; + time = ((int)(tqg>>16) - 0x8000 ) / 100.; + qual = ((tqg>>8) & 0xFF); + gain = (int)(tqg & 0xFF) - 0x80; + } + + if (lVerbose) + log << MSG::VERBOSE << "ene=" << ener << " time=" << time + << " qual=" << qual << " gain=" << gain << endreq; + + if (gain != m_gain[0]) { // don't create cells with non-existing gain + TileCell * cell = new TileCell(dde,id,ener,time,qual,qbit,(CaloGain::CaloGain)gain); + cont->push_back(cell); + } + else { + if (lVerbose) + log << MSG::VERBOSE << "Don't create MBTS cell with invalid gain" << endreq; + } + ++iCell; + } + break; + + default: + + log << MSG::ERROR << "Unknown version of TileCellVec, ver="<<version << endreq; + return StatusCode::FAILURE; + + } + + return StatusCode::SUCCESS; +} + diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCellContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCellContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..3e19c0928e735287762116646c21ccfa94ca985d --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCellContainerCnv.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TileCellContainerCnv_H +#define TileCellContainerCnv_H + +#include "AthenaPoolCnvSvc/T_AthenaPoolCustCnv.h" +#include "TileEvent/TileCellContainer.h" + +class TileTBID; +class StoreGateSvc; +class CaloDetDescrElement; +class MbtsDetDescrManager; +typedef T_AthenaPoolCustCnv<TileCellContainer,TileCellVec> TileCellContainerCnvBase; + +class TileCellContainerCnv:public TileCellContainerCnvBase +{ + + friend class CnvFactory<TileCellContainerCnv >; +public: + TileCellContainerCnv(ISvcLocator* svcloc); + virtual ~TileCellContainerCnv(); + + /// initialization + virtual StatusCode initialize(); + + virtual StatusCode transToPers(TileCellContainer* obj, + TileCellVec*& persObj) ; + virtual StatusCode persToTrans(TileCellContainer*& transObj, + TileCellVec* obj) ; + +private: + // vector of Collections. + TileCellVec m_vecCell; + StoreGateSvc* m_storeGate; + const TileTBID* m_tileTBID; + const MbtsDetDescrManager* m_mbtsMgr; + + int m_version; + + static const int nSide = 2; + static const int nPhi = 8; + static const int nEta = 2; + static const int nCellMBTS = nSide*nPhi*nEta; + + inline int cell_index(int side, int phi, int eta) const { return (side*nPhi+phi)*nEta+eta; } + void initIdToIndex(); + + Identifier m_id[nCellMBTS]; + CaloDetDescrElement * m_dde[nCellMBTS]; + int m_gainIndex[17]; + int m_gain[8]; + + inline int round32(double x) { + if (x<-2147483647.) return -0x7FFFFFFF; + else if (x>2147483647.) return 0x7FFFFFFF; + else return (int)lround(x); + } + + inline int round16(double x) { + if (x<-32767.) return -0x7FFF; + else if (x>32767.) return 0x7FFF; + else return (int)lround(x); + } +}; + +#endif diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCosmicMuonContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCosmicMuonContainerCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fc05377475e87ecf215bda07c020d6d2db175914 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCosmicMuonContainerCnv.cxx @@ -0,0 +1,70 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileCosmicMuonContainerCnv.cxx +// Implementation file for class TileCosmicMuonContainerCnv +// Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch> +// Date: July 2008 +// Revised: July 2009 maneira@lip.pt +/////////////////////////////////////////////////////////////////// + +// Framework includes +#include "GaudiKernel/MsgStream.h" + +// TileTPCnv includes +#include "TileTPCnv/TileCosmicMuonContainerCnv_p1.h" +#include "TileTPCnv/TileCosmicMuonContainerCnv_p2.h" + +// TileEventAthenaPool includes +#include "TileCosmicMuonContainerCnv.h" + +TileCosmicMuonContainer_PERS* +TileCosmicMuonContainerCnv::createPersistent( TileCosmicMuonContainer* transCont ) +{ + MsgStream msg( msgSvc(), "TileCosmicMuonContainerCnv" ); + + TileCosmicMuonContainerCnv_p2 cnv; + TileCosmicMuonContainer_PERS *persObj = cnv.createPersistent( transCont, msg ); + + if (msg.level()<=MSG::DEBUG) + msg << MSG::DEBUG << "::createPersistent [Success]" << endreq; + return persObj; +} + +TileCosmicMuonContainer* TileCosmicMuonContainerCnv::createTransient() { + + MsgStream msg( msgSvc(), "TileCosmicMuonContainerCnv" ); + + TileCosmicMuonContainer *transObj = 0; + + static pool::Guid tr_guid("81711CFC-C75C-49F4-BA12-31D6FAA2D93"); + static pool::Guid p0_guid("51A1E48E-5D5D-4491-85D0-3EFCCEBA5253"); //old before T/P + static pool::Guid p1_guid("716F406D-8F59-4879-AA07-C28BA374E6EF"); + static pool::Guid p2_guid("8957FF04-12E8-43BA-A0C8-D7D9638E242E"); + + if ( compareClassGuid(tr_guid) ) { + + // regular object from before the T/P separation + return poolReadObject<TileCosmicMuonContainer>(); + + } else if ( compareClassGuid(p1_guid) ) { + + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileCosmicMuonContainer_p1> persObj( poolReadObject<TileCosmicMuonContainer_p1>() ); + TileCosmicMuonContainerCnv_p1 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else if ( compareClassGuid(p2_guid) ) { + + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileCosmicMuonContainer_p2> persObj( poolReadObject<TileCosmicMuonContainer_p2>() ); + TileCosmicMuonContainerCnv_p2 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else { + throw std::runtime_error("Unsupported persistent version of TileCosmicMuonContainer"); + } + + return transObj; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCosmicMuonContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCosmicMuonContainerCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..8a7d14919965ccdf5adcb3a597f4dcbbeb4a215a --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileCosmicMuonContainerCnv.h @@ -0,0 +1,59 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileCosmicMuonContainerCnv.h +// Header file for class TileCosmicMuonContainerCnv +// Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch> +// Date: July 2008 +// Revised: July 2009 maneira@lip.pt +/////////////////////////////////////////////////////////////////// +#ifndef TILEEVENTATHENAPOOL_TILECOSMICMUONCONTAINERCNV_H +#define TILEEVENTATHENAPOOL_TILECOSMICMUONCONTAINERCNV_H + +// AthenaPoolCnvSvc includes +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +// TileTPCnv includes +#include "TileTPCnv/TileCosmicMuonContainer_p1.h" +#include "TileTPCnv/TileCosmicMuonContainer_p2.h" + +// TileEvent includes +#include "TileEvent/TileCosmicMuonContainer.h" + +typedef TileCosmicMuonContainer_p2 TileCosmicMuonContainer_PERS; + +class TileCosmicMuonContainerCnv: public T_AthenaPoolCustomCnv< + TileCosmicMuonContainer, + TileCosmicMuonContainer_PERS + > + +{ + + // make the factory for this converter our friend + friend class CnvFactory<TileCosmicMuonContainerCnv>; + + protected: + + /** Create the converter from the service locator + */ + TileCosmicMuonContainerCnv(ISvcLocator* svcloc); + + /** Build the persistent representation from the transient one. + */ + virtual TileCosmicMuonContainer_PERS* + createPersistent( TileCosmicMuonContainer* transCont ); + + /** Build the transient representation from a persistent one + */ + virtual TileCosmicMuonContainer* createTransient(); + +}; + +inline TileCosmicMuonContainerCnv::TileCosmicMuonContainerCnv( ISvcLocator* svcLocator ) : + T_AthenaPoolCustomCnv<TileCosmicMuonContainer, TileCosmicMuonContainer_PERS>(svcLocator) +{} + +#endif //> TILEEVENTATHENAPOOL_TILECOSMICMUONCONTAINERCNV_H diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileDigitsContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileDigitsContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..1ab31d85e0f6f6c42a0f147947d98ba7c3925c27 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileDigitsContainerCnv.cxx @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileTPCnv/TileDigitsContainerCnv_p1.h" +#include "TileDigitsContainerCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" + +TileDigitsContainer_PERS* TileDigitsContainerCnv::createPersistent(TileDigitsContainer* transCont) { + MsgStream mlog(messageService(), "TileDigitsContainerConverter" ); + TileDigitsContainerCnv_p1 converter; + TileDigitsContainer_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + +TileDigitsContainer* TileDigitsContainerCnv::createTransient() { + MsgStream mlog(messageService(), "TileDigitsContainerConverter" ); + TileDigitsContainerCnv_p1 converter_p1; + + TileDigitsContainer *trans_cont(0); + + static const pool::Guid p1_guid("F9386A42-43A7-4482-8A5B-F33EDE586FB2"); + static const pool::Guid p0_guid("EB51ED70-5EC0-4F31-97D3-14453F77C88B"); + + if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< TileDigitsContainer_p1 > cont( this->poolReadObject< TileDigitsContainer_p1 >() ); + trans_cont = converter_p1.createTransient( cont.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation + TileDigitsCollectionVec* rdoV = this->poolReadObject<TileDigitsCollectionVec>(); + + if (mlog.level()<=MSG::DEBUG) + mlog << MSG::DEBUG << "Read IDC, size " << rdoV->size() << endreq; + + // TileFragHash::TYPE type = rdoV->m_type; + + // create the Tile IdentifiableContainer to contain the rdo collections + trans_cont = new TileDigitsContainer(false,SG::OWN_ELEMENTS); + + TileDigitsCollectionVec::iterator it = rdoV->begin(); + TileDigitsCollectionVec::iterator last = rdoV->end(); + + for (; it != last; ++it) { + + TileDigitsCollection* rdoColl = *it; + rdoColl->setOwnership(SG::OWN_ELEMENTS); + + // register the rdo collection in StoreGate + TileDigitsCollection::ID id_coll = rdoColl->identify(); + StatusCode sc = trans_cont->addCollection(rdoColl,trans_cont->hashFunc()(id_coll)); + if(sc.isFailure()) { + mlog << MSG::ERROR << "Can't add collection " << id_coll << " to container " << endreq; + } + } + delete rdoV; + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileDigitsContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileDigitsContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..e99e763fe3e1aefecaba2df579179889905b0cbe --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileDigitsContainerCnv.h @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TILEDIGITSCONTAINERCNV +#define TILEDIGITSCONTAINERCNV + +#include "TileEvent/TileDigitsContainer.h" +#include "TileTPCnv/TileDigitsContainer_p1.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// typedef to the latest persistent version +typedef TileDigitsContainer_p1 TileDigitsContainer_PERS; + +class TileDigitsContainerCnv : public T_AthenaPoolCustomCnv<TileDigitsContainer, TileDigitsContainer_PERS > { + friend class CnvFactory<TileDigitsContainerCnv>; +protected: + TileDigitsContainerCnv(ISvcLocator* svcloc) : + T_AthenaPoolCustomCnv<TileDigitsContainer, TileDigitsContainer_PERS >( svcloc) {} + TileDigitsContainer_PERS* createPersistent(TileDigitsContainer* transCont); + TileDigitsContainer* createTransient (); +}; + + +#endif diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..e36d2ac0f332c7a7f0873a808fb239221aeac203 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitContainerCnv.cxx @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileTPCnv/TileHitContainerCnv_p1.h" +#include "TileHitContainerCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" + +TileHitContainer_PERS* TileHitContainerCnv::createPersistent(TileHitContainer* transCont) { + MsgStream mlog(messageService(), "TileHitContainerConverter" ); + TileHitContainerCnv_p1 converter; + TileHitContainer_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + +TileHitContainer* TileHitContainerCnv::createTransient() { + MsgStream mlog(messageService(), "TileHitContainerConverter" ); + TileHitContainerCnv_p1 converter_p1; + + TileHitContainer *trans_cont(0); + + static const pool::Guid p1_guid("E347580F-BBF0-441E-A799-9AC0256F69DF"); + static const pool::Guid p0_guid("704A373C-EA65-4721-A9B8-F577B683699E"); + + if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< TileHitContainer_p1 > cont( this->poolReadObject< TileHitContainer_p1 >() ); + trans_cont = converter_p1.createTransient( cont.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation + TileHitCollectionVec* rdoV = this->poolReadObject<TileHitCollectionVec>(); + + if (mlog.level()<=MSG::DEBUG) + mlog << MSG::DEBUG << "Read IDC, size " << rdoV->size() << endreq; + + // TileFragHash::TYPE type = rdoV->m_type; + + // create the Tile IdentifiableContainer to contain the rdo collections + trans_cont = new TileHitContainer(false,SG::OWN_ELEMENTS); + + TileHitCollectionVec::iterator it = rdoV->begin(); + TileHitCollectionVec::iterator last = rdoV->end(); + + for (; it != last; ++it) { + + TileHitCollection* rdoColl = *it; + rdoColl->setOwnership(SG::OWN_ELEMENTS); + + // register the rdo collection in StoreGate + TileHitCollection::ID id_coll = rdoColl->identify(); + StatusCode sc = trans_cont->addCollection(rdoColl,trans_cont->hashFunc()(id_coll)); + if(sc.isFailure()) { + mlog << MSG::ERROR << "Can't add collection " << id_coll << " to container " << endreq; + } + } + delete rdoV; + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..aa2a6f26828afa68d935a1e000fd9734268e1d40 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitContainerCnv.h @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TILEHITCONTAINERCNV +#define TILEHITCONTAINERCNV + +#include "TileEvent/TileHitContainer.h" +#include "TileTPCnv/TileHitContainer_p1.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// typedef to the latest persistent version +typedef TileHitContainer_p1 TileHitContainer_PERS; + +class TileHitContainerCnv : public T_AthenaPoolCustomCnv<TileHitContainer, TileHitContainer_PERS > { + friend class CnvFactory<TileHitContainerCnv>; +protected: + TileHitContainerCnv(ISvcLocator* svcloc) : + T_AthenaPoolCustomCnv<TileHitContainer, TileHitContainer_PERS >( svcloc) {} + TileHitContainer_PERS* createPersistent(TileHitContainer* transCont); + TileHitContainer* createTransient (); +}; + +#endif diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitVectorCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitVectorCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..5224b24c6c06133642ec6b40871d15b52c584d3d --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitVectorCnv.cxx @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileTPCnv/TileHitVectorCnv_p1.h" +#include "TileHitVectorCnv.h" +#include "TileTPCnv/TileHit_p1.h" + + +TileHitVector_PERS* TileHitVectorCnv::createPersistent(TileHitVector* transCont) { + MsgStream mlog(messageService(), "TileHitVectorConverter" ); + TileHitVectorCnv_p1 converter; + TileHitVector_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + + +TileHitVector* TileHitVectorCnv::createTransient() { + MsgStream mlog(messageService(), "TileHitVectorConverter" ); + TileHitVectorCnv_p1 converter_p1; + + TileHitVector *trans_cont(0); + + static const pool::Guid p1_guid("65AD597A-BF97-46EE-B9E3-203B35218EA7"); + static const pool::Guid p0_guid("EA2209D1-C339-453D-AEAD-21C026F0735E"); + + if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< TileHitVector_p1 > col_vect( this->poolReadObject< TileHitVector_p1 >() ); + trans_cont = converter_p1.createTransient( col_vect.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation + TileOldHitVector* oldVec = this->poolReadObject<TileOldHitVector>(); + size_t size = oldVec->size(); + trans_cont = new TileHitVector(); + trans_cont->reserve(size); + // copy all hits to new vector + TileOldHitVector::const_iterator it = oldVec->begin(), itEnd=oldVec->end(); + for (;it!=itEnd;++it) { + trans_cont->push_back(**it); + } + delete oldVec; + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitVectorCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitVectorCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..33c23fcecb2477ebdfe3a352aeb6ac5c9e0bf8d0 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileHitVectorCnv.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TILEHITVECTORCNV +#define TILEHITVECTORCNV + +#include "TileSimEvent/TileHitVector.h" +#include "TileTPCnv/TileHitVector_p1.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" +// typedef to the latest persistent version +typedef TileHitVector_p1 TileHitVector_PERS; + +class TileHitVectorCnv : public T_AthenaPoolCustomCnv<TileHitVector, TileHitVector_PERS > { + friend class CnvFactory<TileHitVectorCnv>; +protected: + TileHitVectorCnv(ISvcLocator* svcloc) : + T_AthenaPoolCustomCnv<TileHitVector, TileHitVector_PERS >( svcloc) {} + TileHitVector_PERS* createPersistent(TileHitVector* transCont); + TileHitVector* createTransient (); +}; + + +#endif diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileL2ContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileL2ContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..e7add1f2ee8a6c1bcc167740dfccc627452e7cae --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileL2ContainerCnv.cxx @@ -0,0 +1,68 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileL2ContainerCnv.cxx +// Implementation file for class TileL2ContainerCnv +// Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch> +// Date: July 2008 +/////////////////////////////////////////////////////////////////// + +// Framework includes +#include "GaudiKernel/MsgStream.h" + +// TileTPCnv includes +#include "TileTPCnv/TileL2ContainerCnv_p1.h" +#include "TileTPCnv/TileL2ContainerCnv_p2.h" + +// TileEventAthenaPool includes +#include "TileL2ContainerCnv.h" + +TileL2Container_PERS* +TileL2ContainerCnv::createPersistent( TileL2Container* transCont ) +{ + MsgStream msg( msgSvc(), "TileL2ContainerCnv" ); + + TileL2ContainerCnv_p2 cnv; + TileL2Container_PERS *persObj = cnv.createPersistent( transCont, msg ); + + if (msg.level()<=MSG::DEBUG) + msg << MSG::DEBUG << "::createPersistent [Success]" << endreq; + return persObj; +} + +TileL2Container* TileL2ContainerCnv::createTransient() { + + MsgStream msg( msgSvc(), "TileL2ContainerCnv" ); + + TileL2Container *transObj = 0; + + static pool::Guid tr_guid("E9BB4497-FF43-4D70-8A64-B509081DAD88"); + static pool::Guid p1_guid("FE877FF9-475D-42D9-8DC3-CABD220BFD27"); + static pool::Guid p2_guid("3283BF32-0B18-408F-9B46-6A1B26B37D5C"); + + if ( compareClassGuid(tr_guid) ) { + + // regular object from before the T/P separation + return poolReadObject<TileL2Container>(); + + } else if ( compareClassGuid(p1_guid) ) { + + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileL2Container_p1> persObj( poolReadObject<TileL2Container_p1>() ); + TileL2ContainerCnv_p1 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else if ( compareClassGuid(p2_guid) ) { + + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileL2Container_p2> persObj( poolReadObject<TileL2Container_p2>() ); + TileL2ContainerCnv_p2 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else { + throw std::runtime_error("Unsupported persistent version of TileL2Container"); + } + + return transObj; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileL2ContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileL2ContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..812ea17cd30a06b8d6f5d4c15930da8ea50533df --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileL2ContainerCnv.h @@ -0,0 +1,58 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileL2ContainerCnv.h +// Header file for class TileL2ContainerCnv +// Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch> +// Date: July 2008 +/////////////////////////////////////////////////////////////////// +#ifndef TILEEVENTATHENAPOOL_TILEL2CONTAINERCNV_H +#define TILEEVENTATHENAPOOL_TILEL2CONTAINERCNV_H + +// AthenaPoolCnvSvc includes +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +// TileTPCnv includes +#include "TileTPCnv/TileL2Container_p1.h" +#include "TileTPCnv/TileL2Container_p2.h" + +// TileEvent includes +#include "TileEvent/TileL2Container.h" + +typedef TileL2Container_p2 TileL2Container_PERS; + +class TileL2ContainerCnv: public T_AthenaPoolCustomCnv< + TileL2Container, + TileL2Container_PERS + > + +{ + + // make the factory for this converter our friend + friend class CnvFactory<TileL2ContainerCnv>; + + protected: + + /** Create the converter from the service locator + */ + TileL2ContainerCnv(ISvcLocator* svcloc); + + /** Build the persistent representation from the transient one. + */ + virtual TileL2Container_PERS* + createPersistent( TileL2Container* transCont ); + + /** Build the transient representation from a persistent one + */ + virtual TileL2Container* createTransient(); + +}; + +inline TileL2ContainerCnv::TileL2ContainerCnv( ISvcLocator* svcLocator ) : + T_AthenaPoolCustomCnv<TileL2Container, TileL2Container_PERS>(svcLocator) +{} + +#endif //> TILEEVENTATHENAPOOL_TILEL2CONTAINERCNV_H diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..af34d2cacaf6c76fa2c25040cf6f343b88899852 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuContainerCnv.cxx @@ -0,0 +1,60 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileMuContainerCnv.cxx +// Implementation file for class TileMuContainerCnv +// Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch> +// Date: July 2008 +/////////////////////////////////////////////////////////////////// + +// Framework includes +#include "GaudiKernel/MsgStream.h" + +// TileTPCnv includes +#include "TileTPCnv/TileMuContainerCnv_p1.h" + +// TileEventAthenaPool includes +#include "TileMuContainerCnv.h" + +TileMuContainer_PERS* +TileMuContainerCnv::createPersistent( TileMuContainer* transCont ) +{ + MsgStream msg( msgSvc(), "TileMuContainerCnv" ); + + TileMuContainerCnv_p1 cnv; + TileMuContainer_PERS *persObj = cnv.createPersistent( transCont, msg ); + + if (msg.level()<=MSG::DEBUG) + msg << MSG::DEBUG << "::createPersistent [Success]" << endreq; + return persObj; +} + +TileMuContainer* TileMuContainerCnv::createTransient() { + + MsgStream msg( msgSvc(), "TileMuContainerCnv" ); + + TileMuContainer *transObj = 0; + + static pool::Guid tr_guid("FC0456E4-912B-425B-9AA2-4DDD0C6B2275"); + static pool::Guid p1_guid("DE8904EB-25FD-495A-8DD5-E31B05E397C6"); + + if ( compareClassGuid(tr_guid) ) { + + // regular object from before the T/P separation + return poolReadObject<TileMuContainer>(); + + } else if ( compareClassGuid(p1_guid) ) { + + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileMuContainer_p1> persObj( poolReadObject<TileMuContainer_p1>() ); + TileMuContainerCnv_p1 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else { + throw std::runtime_error("Unsupported persistent version of TileMuContainer"); + } + + return transObj; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..718cb50455733b14a944732fc58070a1ed20fa59 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuContainerCnv.h @@ -0,0 +1,57 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileMuContainerCnv.h +// Header file for class TileMuContainerCnv +// Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch> +// Date: July 2008 +/////////////////////////////////////////////////////////////////// +#ifndef TILEEVENTATHENAPOOL_TILEMUCONTAINERCNV_H +#define TILEEVENTATHENAPOOL_TILEMUCONTAINERCNV_H + +// AthenaPoolCnvSvc includes +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +// TileTPCnv includes +#include "TileTPCnv/TileMuContainer_p1.h" + +// TileEvent includes +#include "TileEvent/TileMuContainer.h" + +typedef TileMuContainer_p1 TileMuContainer_PERS; + +class TileMuContainerCnv: public T_AthenaPoolCustomCnv< + TileMuContainer, + TileMuContainer_PERS + > + +{ + + // make the factory for this converter our friend + friend class CnvFactory<TileMuContainerCnv>; + + protected: + + /** Create the converter from the service locator + */ + TileMuContainerCnv(ISvcLocator* svcloc); + + /** Build the persistent representation from the transient one. + */ + virtual TileMuContainer_PERS* + createPersistent( TileMuContainer* transCont ); + + /** Build the transient representation from a persistent one + */ + virtual TileMuContainer* createTransient(); + +}; + +inline TileMuContainerCnv::TileMuContainerCnv( ISvcLocator* svcLocator ) : + T_AthenaPoolCustomCnv<TileMuContainer, TileMuContainer_PERS>(svcLocator) +{} + +#endif //> TILEEVENTATHENAPOOL_TILEMUCONTAINERCNV_H diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuonReceiverContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuonReceiverContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..ab2905bc8e4d55c2117ec674459721bd7f983afc --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuonReceiverContainerCnv.cxx @@ -0,0 +1,59 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileMuonReceveirContainerCnv.cxx +// Implementation file for class TileMuonReceiverContainerCnv +// Author: Joao Gentil Saraiva <joao.gentil.saraiva@cern.ch> +// Date: March 2014 +/////////////////////////////////////////////////////////////////// + +// Framework includes +#include "GaudiKernel/MsgStream.h" + +// TileTPCnv includes +#include "TileTPCnv/TileMuonReceiverContainerCnv_p1.h" + +// TileEventAthenaPool includes +#include "TileMuonReceiverContainerCnv.h" + +TileMuonReceiverContainer_PERS* +TileMuonReceiverContainerCnv::createPersistent( TileMuonReceiverContainer* transCont ) +{ + MsgStream msg( msgSvc(), "TileMuonReceiverContainerCnv" ); + + TileMuonReceiverContainerCnv_p1 cnv; + TileMuonReceiverContainer_PERS *persObj = cnv.createPersistent( transCont, msg ); + + if (msg.level()<=MSG::DEBUG) + msg << MSG::DEBUG << "::createPersistent [Success]" << endreq; + return persObj; +} + +TileMuonReceiverContainer* TileMuonReceiverContainerCnv::createTransient() { + + MsgStream msg( msgSvc(), "TileMuonReceiverContainerCnv" ); + + TileMuonReceiverContainer *transObj = 0; + + static pool::Guid tr_guid("A01F819F-4F0B-4713-A275-7DA5F47F77E5"); + static pool::Guid p1_guid("7F0DA5A3-7773-4852-AE55-A9920FEB31AB"); + + if ( compareClassGuid(tr_guid) ) { + + // regular object from before the T/P separation + return poolReadObject<TileMuonReceiverContainer>(); + + } else if ( compareClassGuid(p1_guid) ) { + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileMuonReceiverContainer_p1> persObj( poolReadObject<TileMuonReceiverContainer_p1>() ); + TileMuonReceiverContainerCnv_p1 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else { + throw std::runtime_error("Unsupported persistent version of TileMuonReceiverContainer"); + } + + return transObj; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuonReceiverContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuonReceiverContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..c788daf42572af2651e3e89ca4ca5b1ec0e7dda0 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileMuonReceiverContainerCnv.h @@ -0,0 +1,56 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileMuonReceiverContainerCnv.h +// Header file for class TileMuonReceiverContainerCnv +// Author: Joao Gentil Saraiva <joao.gentil.saraiva@cern.ch> +// Date: March 2014 +/////////////////////////////////////////////////////////////////// +#ifndef TILEEVENTATHENAPOOL_TILEMUONRECEIVERCONTAINERCNV_H +#define TILEEVENTATHENAPOOL_TILEMUONRECEIVERCONTAINERCNV_H + +// AthenaPoolCnvSvc includes +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +// TileTPCnv includes +#include "TileTPCnv/TileMuonReceiverContainer_p1.h" + +// TileEvent includes +#include "TileEvent/TileMuonReceiverContainer.h" + +typedef TileMuonReceiverContainer_p1 TileMuonReceiverContainer_PERS; + +class TileMuonReceiverContainerCnv: public T_AthenaPoolCustomCnv< + TileMuonReceiverContainer, + TileMuonReceiverContainer_PERS + > +{ + + // make the factory for this converter our friend + friend class CnvFactory<TileMuonReceiverContainerCnv>; + + protected: + + /** Create the converter from the service locator + */ + TileMuonReceiverContainerCnv(ISvcLocator* svcloc); + + /** Build the persistent representation from the transient one. + */ + virtual TileMuonReceiverContainer_PERS* + createPersistent( TileMuonReceiverContainer* transCont ); + + /** Build the transient representation from a persistent one + */ + virtual TileMuonReceiverContainer* createTransient(); + +}; + +inline TileMuonReceiverContainerCnv::TileMuonReceiverContainerCnv( ISvcLocator* svcLocator ) : + T_AthenaPoolCustomCnv<TileMuonReceiverContainer, TileMuonReceiverContainer_PERS>(svcLocator) +{} + +#endif diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileRawChannelContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileRawChannelContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..609ce1c16e7a1e5ae1a03613f2ad37ee75fc2749 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileRawChannelContainerCnv.cxx @@ -0,0 +1,79 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TileTPCnv/TileRawChannelContainerCnv_p1.h" +#include "TileRawChannelContainerCnv.h" +// Gaudi +#include "GaudiKernel/MsgStream.h" + +TileRawChannelContainer_PERS* TileRawChannelContainerCnv::createPersistent(TileRawChannelContainer* transCont) { + MsgStream mlog(messageService(), "TileRawChannelContainerConverter" ); + TileRawChannelContainerCnv_p1 converter; + TileRawChannelContainer_PERS *persObj = converter.createPersistent( transCont, mlog ); + return persObj; +} + +TileRawChannelContainer* TileRawChannelContainerCnv::createTransient() { + MsgStream mlog(messageService(), "TileRawChannelContainerConverter" ); + TileRawChannelContainerCnv_p1 converter_p1; + + TileRawChannelContainer *trans_cont(0); + + static const pool::Guid p1_guid("BF727F06-9F94-4989-9C1F-9E59023988EA"); + static const pool::Guid p0_guid("E18095F6-01D9-4E8B-AD51-A8628F92E7FF"); + + if( this->compareClassGuid(p1_guid)) { + std::auto_ptr< TileRawChannelContainer_p1 > cont( this->poolReadObject< TileRawChannelContainer_p1 >() ); + trans_cont = converter_p1.createTransient( cont.get(), mlog ); + } + else if( this->compareClassGuid(p0_guid)) { + // old version from before TP separation + TileRawChannelCollectionVec* rdoV = this->poolReadObject<TileRawChannelCollectionVec>(); + bool lDebug = (mlog.level()<=MSG::DEBUG); + + if (lDebug) + mlog << MSG::DEBUG << "Read IDC, size " << rdoV->size() << endreq; + + // fixing bug with units in 13.0.20 - should be removed once all RDO files produced with 13.0.20 disappear + if (rdoV->m_type == 104) { + if (lDebug) + mlog << MSG::DEBUG << "fixing units bug in 13.0.20 RDO data: if (type=104) type=4;" << endreq; + rdoV->m_type = (TileFragHash::TYPE)4; + } + + int hashType = rdoV->m_type & 0xF; + int type = (rdoV->m_type >> 4) & 0xF; + int unit = (rdoV->m_type >> 8) & 0xF; + uint32_t bsflags = rdoV->m_type & 0xFFFFF000; + + if (lDebug) + mlog << MSG::DEBUG << MSG::hex << "m_type=" << rdoV->m_type + << " " << bsflags << " " << unit << " " << type << " " << hashType << MSG::dec << endreq; + + // create the Tile IdentifiableContainer to contain the rdo collections + trans_cont = new TileRawChannelContainer(false,hashType,unit,SG::OWN_ELEMENTS); + if (type != 0) trans_cont->set_type((TileFragHash::TYPE)type); + trans_cont->set_bsflags(bsflags); + + TileRawChannelCollectionVec::iterator it = rdoV->begin(); + TileRawChannelCollectionVec::iterator last = rdoV->end(); + + for (; it != last; ++it) { + + TileRawChannelCollection* rdoColl = *it; + rdoColl->setOwnership(SG::OWN_ELEMENTS); + + // register the rdo collection in StoreGate + TileRawChannelCollection::ID id_coll = rdoColl->identify(); + StatusCode sc = trans_cont->addCollection(rdoColl,trans_cont->hashFunc()(id_coll)); + if(sc.isFailure()) { + mlog << MSG::ERROR << "Can't add collection " << id_coll << " to container" << endreq; + } + } + delete rdoV; + } else { + throw std::runtime_error("Unsupported persistent version of Data container"); + } + return trans_cont; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileRawChannelContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileRawChannelContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..da8a21f4288ca7c8c6c155b7bb8301eb34469934 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileRawChannelContainerCnv.h @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TILERAWCHANNELCONTAINERCNV +#define TILERAWCHANNELCONTAINERCNV + +#include "TileEvent/TileRawChannelContainer.h" +#include "TileTPCnv/TileRawChannelContainer_p1.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +// typedef to the latest persistent version +typedef TileRawChannelContainer_p1 TileRawChannelContainer_PERS; + +class TileRawChannelContainerCnv : public T_AthenaPoolCustomCnv<TileRawChannelContainer, TileRawChannelContainer_PERS > { + friend class CnvFactory<TileRawChannelContainerCnv>; +protected: + TileRawChannelContainerCnv(ISvcLocator* svcloc) : + T_AthenaPoolCustomCnv<TileRawChannelContainer, TileRawChannelContainer_PERS >( svcloc) {} + TileRawChannelContainer_PERS* createPersistent(TileRawChannelContainer* transCont); + TileRawChannelContainer* createTransient (); +}; + + +#endif diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileTTL1ContainerCnv.cxx b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileTTL1ContainerCnv.cxx new file mode 100755 index 0000000000000000000000000000000000000000..858ebf332a065260433c2dc553b0e827a92f824a --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileTTL1ContainerCnv.cxx @@ -0,0 +1,60 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileTTL1ContainerCnv.cxx +// Implementation file for class TileTTL1ContainerCnv +// Author: Alexander Solodkov <Sanya.Solodkov@cern.ch> +// Date: June 2009 +/////////////////////////////////////////////////////////////////// + +// Framework includes +#include "GaudiKernel/MsgStream.h" + +// TileTPCnv includes +#include "TileTPCnv/TileTTL1ContainerCnv_p1.h" + +// TileEventAthenaPool includes +#include "TileTTL1ContainerCnv.h" + +TileTTL1Container_PERS* +TileTTL1ContainerCnv::createPersistent( TileTTL1Container* transCont ) +{ + MsgStream msg( msgSvc(), "TileTTL1ContainerCnv" ); + + TileTTL1ContainerCnv_p1 cnv; + TileTTL1Container_PERS *persObj = cnv.createPersistent( transCont, msg ); + + if (msg.level()<=MSG::DEBUG) + msg << MSG::DEBUG << "::createPersistent [Success]" << endreq; + return persObj; +} + +TileTTL1Container* TileTTL1ContainerCnv::createTransient() { + + MsgStream msg( msgSvc(), "TileTTL1ContainerCnv" ); + + TileTTL1Container *transObj = 0; + + static pool::Guid tr_guid("F06C00C1-896A-4773-9F9C-21893C1E0CE7"); + static pool::Guid p1_guid("213FA88B-52AE-4229-8886-62D7D54FA7A3"); + + if ( compareClassGuid(tr_guid) ) { + + // regular object from before the T/P separation + return poolReadObject<TileTTL1Container>(); + + } else if ( compareClassGuid(p1_guid) ) { + + // using auto_ptr ensures deletion of the persistent object + std::auto_ptr<TileTTL1Container_p1> persObj( poolReadObject<TileTTL1Container_p1>() ); + TileTTL1ContainerCnv_p1 cnv; + transObj = cnv.createTransient( persObj.get(), msg ); + } else { + throw std::runtime_error("Unsupported persistent version of TileTTL1Container"); + } + + return transObj; +} diff --git a/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileTTL1ContainerCnv.h b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileTTL1ContainerCnv.h new file mode 100755 index 0000000000000000000000000000000000000000..1d158669473b8ace75d25a08f178298a640aefa8 --- /dev/null +++ b/TileCalorimeter/TileSvc/TileEventAthenaPool/src/TileTTL1ContainerCnv.h @@ -0,0 +1,57 @@ +///////////////////////// -*- C++ -*- ///////////////////////////// + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// TileTTL1ContainerCnv.h +// Header file for class TileTTL1ContainerCnv +// Author: Alexander Solodkov <Sanya.Solodkov@cern.ch> +// Date: June 2009 +/////////////////////////////////////////////////////////////////// +#ifndef TILEEVENTATHENAPOOL_TILETTL1CONTAINERCNV_H +#define TILEEVENTATHENAPOOL_TILETTL1CONTAINERCNV_H + +// AthenaPoolCnvSvc includes +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +// TileTPCnv includes +#include "TileTPCnv/TileTTL1Container_p1.h" + +// TileEvent includes +#include "TileEvent/TileTTL1Container.h" + +typedef TileTTL1Container_p1 TileTTL1Container_PERS; + +class TileTTL1ContainerCnv: public T_AthenaPoolCustomCnv< + TileTTL1Container, + TileTTL1Container_PERS + > + +{ + + // make the factory for this converter our friend + friend class CnvFactory<TileTTL1ContainerCnv>; + + protected: + + /** Create the converter from the service locator + */ + TileTTL1ContainerCnv(ISvcLocator* svcloc); + + /** Build the persistent representation from the transient one. + */ + virtual TileTTL1Container_PERS* + createPersistent( TileTTL1Container* transCont ); + + /** Build the transient representation from a persistent one + */ + virtual TileTTL1Container* createTransient(); + +}; + +inline TileTTL1ContainerCnv::TileTTL1ContainerCnv( ISvcLocator* svcLocator ) : + T_AthenaPoolCustomCnv<TileTTL1Container, TileTTL1Container_PERS>(svcLocator) +{} + +#endif //> TILEEVENTATHENAPOOL_TILETTL1CONTAINERCNV_H