ATLAS Offline Software
TgcCoinDataCnv_p2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------------
6 //
7 // file: TgcCoinDataCnv_p2.cxx
8 //* Takashi Kubota - June 30, 2008 */
9 //-----------------------------------------------------------------------------
10 
13 #include <algorithm>
16 
18 persToTrans( const Muon::TgcCoinData_p2 *persObj, Muon::TgcCoinData *transObj,MsgStream &log )
19 {
20  log << MSG::DEBUG << "TgcCoinDataCnv_p2::persToTrans" << endmsg;
21 
23  switch(persObj->m_type){
25  case 1: type=Muon::TgcCoinData::TYPE_HIPT; break;
26  case 2: type=Muon::TgcCoinData::TYPE_SL; break;
29  default: break;
30  }
31 
32  auto posIn = std::unique_ptr<Amg::Vector2D>
34  auto posOut = std::unique_ptr<Amg::Vector2D>
36 
39  auto tempMat = std::make_unique<Amg::MatrixX>();
40  if (!dummy.values.empty())
41  EigenHelpers::vectorToEigenMatrix(dummy.values, *tempMat, "TgcCoinDataCnv_p2");
42 
43  *transObj = Muon::TgcCoinData (Identifier(persObj->m_channelIdIn),
44  Identifier(persObj->m_channelIdOut),
45  persObj->m_collectionIdHash,
46  transObj->detectorElementIn(),
47  transObj->detectorElementOut(),
48  type,
49  persObj->m_isAside,
50  persObj->m_phi,
51  false, // isInner
52  persObj->m_isForward,
53  persObj->m_isStrip,
54  persObj->m_trackletId,
55  posIn.release(),
56  posOut.release(),
57  persObj->m_widthIn,
58  persObj->m_widthOut,
59  persObj->m_delta,
60  persObj->m_sub,
61  0, // tile
62  persObj->m_roi,
63  persObj->m_pt,
64  persObj->m_trackletIdStrip,
65  tempMat.release(),
66  persObj->m_isPositiveDeltaR
67  );
68 
69  transObj->setHashAndIndex(persObj->m_indexAndHash);
70 }
71 
73 transToPers( const Muon::TgcCoinData *transObj, Muon::TgcCoinData_p2 *persObj, MsgStream &log )
74 {
75  log << MSG::DEBUG << "TgcCoinDataCnv_p2::transToPers" << endmsg;
76 
77  // Tracklet and HiPt should have valid channelIdIn
78  if(transObj->type()==Muon::TgcCoinData::TYPE_TRACKLET ||
79  transObj->type()==Muon::TgcCoinData::TYPE_HIPT ||
81  if(!transObj->channelIdIn().get_identifier32().is_valid()) {
82  log << MSG::ERROR << "TgcCoinDataCnv_p2::transToPers - invalid trans channelIdIn!! "
83  << (transObj->type()==Muon::TgcCoinData::TYPE_TRACKLET ? "(TRACKLET)" :
84  (transObj->type()==Muon::TgcCoinData::TYPE_TRACKLET_EIFI ? "(TRACKLET_EIFI)" : "(HIPT)"))
85  << endmsg;
86  }
87  }
88  // Tracklet, HiPt and SL should have valid channelIdOut
89  if(transObj->type()==Muon::TgcCoinData::TYPE_TRACKLET ||
90  transObj->type()==Muon::TgcCoinData::TYPE_HIPT ||
91  transObj->type()==Muon::TgcCoinData::TYPE_SL) {
92  if(!transObj->channelIdOut().get_identifier32().is_valid()) {
93  log << MSG::ERROR << "TgcCoinDataCnv_p2::transToPers - invalid trans channelIdOut!! "
94  << (transObj->type()==Muon::TgcCoinData::TYPE_TRACKLET ? "(TRACKLET)" :
95  (transObj->type()==Muon::TgcCoinData::TYPE_HIPT ? "(HIPT)" : "(SL)"))
96  << endmsg;
97  }
98  }
99  persObj->m_channelIdIn = transObj->channelIdIn().get_identifier32().get_compact();
100  persObj->m_channelIdOut = transObj->channelIdOut().get_identifier32().get_compact();
101  persObj->m_collectionIdHash = transObj->identifyHash();
102  persObj->m_indexAndHash=transObj->getHashAndIndex().hashAndIndex();
103  switch(transObj->type()){
104  case Muon::TgcCoinData::TYPE_TRACKLET: persObj->m_type=0; break;
105  case Muon::TgcCoinData::TYPE_HIPT: persObj->m_type=1; break;
106  case Muon::TgcCoinData::TYPE_SL: persObj->m_type=2; break;
107  case Muon::TgcCoinData::TYPE_UNKNOWN: persObj->m_type=3; break;
108  case Muon::TgcCoinData::TYPE_TRACKLET_EIFI: persObj->m_type=4; break;
109  default: break;
110  }
111 
112  persObj->m_isAside = transObj->isAside();
113  persObj->m_phi = transObj->phi();
114  persObj->m_isForward = transObj->isForward();
115  persObj->m_isStrip = transObj->isStrip();
116  persObj->m_trackletId = transObj->trackletId();
117  persObj->m_trackletIdStrip = transObj->trackletIdStrip();
118  persObj->m_widthIn = transObj->widthIn();
119  persObj->m_widthOut = transObj->widthOut();
120  persObj->m_posIn = toPersistent( &m_localPosCnv, transObj->posInPtr(), log );
121  persObj->m_posOut = toPersistent( &m_localPosCnv, transObj->posOutPtr(), log );
122  // persObj->m_errMat = toPersistent( &m_errorMxCnv, transObj->m_errMat, log );
123 
124  if (transObj->hasErrMat() )
125  {
126  if (! transObj->errMat().cols() || !transObj->errMat().rows()) {
127  if (m_numErrsPrinted<10) {
129  log << MSG::WARNING << "Have been given a TgcCoinData error matrix with size = ["
130  <<transObj->errMat().rows()<<","<<transObj->errMat().cols()<<"]. Skipping writing of the matrix."<<endmsg;
131  }
132  } else {
133  Trk::ErrorMatrix pMat;
134  EigenHelpers::eigenMatrixToVector(pMat.values, transObj->errMat(), "TgcCoinDataCnv_p2");
135  persObj->m_errMat = toPersistent( &m_errorMxCnv, &pMat, log );
136  }
137  }
138 
139  persObj->m_delta = transObj->delta();
140  persObj->m_roi = transObj->roi();
141  persObj->m_pt = transObj->pt();
142 
143  persObj->m_sub = transObj->sub();
144  persObj->m_isPositiveDeltaR = transObj->isPositiveDeltaR();
145 }
146 
147 
Muon::TgcCoinData::hasErrMat
bool hasErrMat() const
Test to see if the error matrix is present.
Definition: TgcCoinData.h:368
Identifier32::is_valid
bool is_valid() const
Check if id is in a valid state.
Definition: Identifier32.h:50
Muon::TgcCoinData_p2::m_indexAndHash
unsigned int m_indexAndHash
Definition: TgcCoinData_p2.h:51
Muon::TgcCoinData::channelIdOut
Identifier channelIdOut() const
return offlineID on track on TGC3
Definition: TgcCoinData.h:344
Muon::TgcCoinData_p2::m_errMat
TPObjRef m_errMat
Definition: TgcCoinData_p2.h:63
Muon::TgcCoinData::isAside
bool isAside() const
Aside or Cside.
Definition: TgcCoinData.h:348
Muon::TgcCoinData::type
CoinDataType type() const
return the coincidence type (HIPT, LPT, SL)
Definition: TgcCoinData.h:346
Muon::TgcCoinData_p2::m_phi
int m_phi
Definition: TgcCoinData_p2.h:55
Muon::TgcCoinData::isStrip
bool isStrip() const
Strip hit or Wire hit?
Definition: TgcCoinData.h:356
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Muon::TgcCoinData_p2::m_isPositiveDeltaR
bool m_isPositiveDeltaR
Definition: TgcCoinData_p2.h:72
Muon::TgcCoinData_p2::m_widthIn
double m_widthIn
Definition: TgcCoinData_p2.h:64
Muon::TgcCoinData::TYPE_TRACKLET
@ TYPE_TRACKLET
Definition: TgcCoinData.h:50
Muon::TgcCoinData::trackletId
int trackletId() const
return trackletId (Identifier for each track)
Definition: TgcCoinData.h:358
Muon::TgcCoinData_p2
Definition: TgcCoinData_p2.h:24
Muon::TgcCoinData_p2::m_sub
int m_sub
Definition: TgcCoinData_p2.h:71
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
Muon::TgcCoinData::identifyHash
IdentifierHash identifyHash() const
return the identifierHash of Outer Hit
Definition: TgcCoinData.h:319
Muon::TgcCoinData::isPositiveDeltaR
bool isPositiveDeltaR() const
return isPositiveDeltaR (isMuplus) of SL
Definition: TgcCoinData.h:388
Muon::TgcCoinData
Definition: TgcCoinData.h:37
ITPConverterFor< TRANS_BASE >::fillTransFromPStore
void fillTransFromPStore(CNV **cnv, const TPObjRef &ref, TRANS_T *trans, MsgStream &log) const
Convert persistent object, stored in the the top-level persistent object and referenced by the TP Ref...
Definition: TPConverter.h:145
Muon::TgcCoinData_p2::m_pt
int m_pt
Definition: TgcCoinData_p2.h:69
Muon::TgcCoinData_p2::m_trackletId
int m_trackletId
Definition: TgcCoinData_p2.h:58
TgcCoinDataCnv_p2.h
Trk::ErrorMatrix
Definition: ErrorMatrixCnv_p1.h:25
Muon::TgcCoinData_p2::m_trackletIdStrip
int m_trackletIdStrip
Definition: TgcCoinData_p2.h:59
Muon::TgcCoinData::trackletIdStrip
int trackletIdStrip() const
return trackletId for strip (Identifier for each track)
Definition: TgcCoinData.h:360
TgcCoinDataCnv_p2::m_errorMxCnv
ErrorMatrixCnv_p1 * m_errorMxCnv
Definition: TgcCoinDataCnv_p2.h:41
Muon::TgcCoinData_p2::m_posIn
TPObjRef m_posIn
Definition: TgcCoinData_p2.h:61
Muon::TgcCoinData_p2::m_isForward
bool m_isForward
Definition: TgcCoinData_p2.h:56
Muon::TgcCoinData::delta
int delta() const
return the deviation from Pt=oo track
Definition: TgcCoinData.h:376
EigenHelpers::vectorToEigenMatrix
static void vectorToEigenMatrix(VECTOR &vec, COVARIANCE &cov, const char *)
Helper fn to fill the covariance from the raw data (vec<float>)
Definition: EigenHelpers.h:22
TgcCoinDataCnv_p2::m_localPosCnv
LocalPositionCnv_p1 * m_localPosCnv
Definition: TgcCoinDataCnv_p2.h:40
Muon::TgcCoinData::CoinDataType
CoinDataType
Definition: TgcCoinData.h:49
Muon::TgcCoinData::TYPE_HIPT
@ TYPE_HIPT
Definition: TgcCoinData.h:51
Muon::TgcCoinData_p2::m_delta
int m_delta
Definition: TgcCoinData_p2.h:67
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Muon::TgcCoinData::setHashAndIndex
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
Definition: TgcCoinData.h:326
Muon::TgcCoinData::widthIn
double widthIn() const
return region width of hit on TGC1
Definition: TgcCoinData.h:372
Muon::TgcCoinData::errMat
const Amg::MatrixX & errMat() const
return 2d width of ROI for SL: errMat[0][0]==(width for R), errMat[1][1]==(width for phi)
Definition: TgcCoinData.h:370
Muon::TgcCoinData::widthOut
double widthOut() const
return region width of hit on TGC2(TRACKLET) or TGC3(HIPT)
Definition: TgcCoinData.h:374
Muon::TgcCoinData_p2::m_widthOut
double m_widthOut
Definition: TgcCoinData_p2.h:65
EigenHelpers.h
Muon::TgcCoinData_p2::m_channelIdOut
Identifier32::value_type m_channelIdOut
Definition: TgcCoinData_p2.h:48
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Muon::TgcCoinData::posInPtr
const Amg::Vector2D * posInPtr() const
Definition: TgcCoinData.h:363
Muon::TgcCoinData::TYPE_UNKNOWN
@ TYPE_UNKNOWN
Definition: TgcCoinData.h:53
Muon::TgcCoinData::detectorElementIn
const MuonGM::TgcReadoutElement * detectorElementIn() const
return TgcReadoutElement of track on TGC1(HIPT) or TGC2(TRACKLET)
Definition: TgcCoinData.h:390
EigenHelpers::eigenMatrixToVector
static void eigenMatrixToVector(VECTOR &vec, COVARIANCE &cov, const char *)
Helper fn to get raw data (vec<float>) from the covariance.
Definition: EigenHelpers.h:30
Muon::TgcCoinData_p2::m_type
int m_type
Definition: TgcCoinData_p2.h:53
ITPConverterFor< TRANS_BASE >::toPersistent
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Persistify an object and store the persistent represenation in the storage vector of the top-level pe...
Definition: TPConverter.h:119
IdentContIndex::hashAndIndex
unsigned int hashAndIndex() const
combined index
Definition: IdentContIndex.h:99
Muon::TgcCoinData::getHashAndIndex
const IdentContIndex & getHashAndIndex() const
Definition: TgcCoinData.h:337
TgcCoinDataCnv_p2::persToTrans
void persToTrans(const Muon::TgcCoinData_p2 *persObj, Muon::TgcCoinData *transObj, MsgStream &log)
Definition: TgcCoinDataCnv_p2.cxx:18
IdentContIndex.h
TgcCoinDataCnv_p2::m_numErrsPrinted
unsigned int m_numErrsPrinted
Definition: TgcCoinDataCnv_p2.h:42
Muon::TgcCoinData::roi
int roi() const
return ROI number
Definition: TgcCoinData.h:378
Muon::TgcCoinData::posOutPtr
const Amg::Vector2D * posOutPtr() const
Definition: TgcCoinData.h:366
Muon::TgcCoinData_p2::m_channelIdIn
Identifier32::value_type m_channelIdIn
Definition: TgcCoinData_p2.h:47
Trk::ErrorMatrix::values
std::vector< float > values
Definition: ErrorMatrixCnv_p1.h:27
Muon::TgcCoinData::isForward
bool isForward() const
Forward region or Endcap region.
Definition: TgcCoinData.h:354
Muon::TgcCoinData::sub
int sub() const
return subMatrix of Tracklet or hsub of HiPt
Definition: TgcCoinData.h:384
Muon::TgcCoinData::pt
int pt() const
return pt threshold value
Definition: TgcCoinData.h:380
Muon::TgcCoinData_p2::m_collectionIdHash
IdentifierHash m_collectionIdHash
Definition: TgcCoinData_p2.h:49
TgcCoinDataCnv_p2::transToPers
void transToPers(const Muon::TgcCoinData *transObj, Muon::TgcCoinData_p2 *persObj, MsgStream &log)
Definition: TgcCoinDataCnv_p2.cxx:73
Muon::TgcCoinData::TYPE_SL
@ TYPE_SL
Definition: TgcCoinData.h:52
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Muon::TgcCoinData::TYPE_TRACKLET_EIFI
@ TYPE_TRACKLET_EIFI
Definition: TgcCoinData.h:54
Muon::TgcCoinData::channelIdIn
Identifier channelIdIn() const
return offlineID on TGC1(HIPT) or TGC2(TRACKLET)
Definition: TgcCoinData.h:342
Muon::TgcCoinData::detectorElementOut
const MuonGM::TgcReadoutElement * detectorElementOut() const
return TgcReadoutElement of track on TGC3
Definition: TgcCoinData.h:395
TgcCoinData.h
Muon::TgcCoinData_p2::m_isStrip
bool m_isStrip
Definition: TgcCoinData_p2.h:57
Muon::TgcCoinData_p2::m_roi
int m_roi
Definition: TgcCoinData_p2.h:68
ITPConverterFor< TRANS_BASE >::createTransFromPStore
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Create transient representation of a persistent object, stored in the the top-level persistent object...
Definition: TPConverter.h:172
Muon::TgcCoinData_p2::m_posOut
TPObjRef m_posOut
Definition: TgcCoinData_p2.h:62
Muon::TgcCoinData::phi
int phi() const
return phi number of trigger sector
Definition: TgcCoinData.h:350
Identifier
Definition: IdentifierFieldParser.cxx:14
Muon::TgcCoinData_p2::m_isAside
bool m_isAside
Definition: TgcCoinData_p2.h:54