ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterContainerCnv_p3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
11
14 MsgStream &log) const
15{
16 if (log.level() <= MSG::DEBUG) log<< MSG::DEBUG << "Reading CaloClusterContainerCNV_p3" << endmsg;
17
18 // reset element link converters, and provide container name lookup table
19 ShowerLinkState showerLinkState (pers->m_linkNames);
20 CellLinkState cellLinkState (pers->m_linkNames);
21
22 // Use data pool for clusters to avoid calling constructor for each event
23 DataPool<CaloCluster> clusters;
24
25 trans->clear (SG::VIEW_ELEMENTS);
26 trans->reserve(pers->m_vec.size());
27
30 pers->m_vec.size(),
31 samplingState))
32 {
33 REPORT_MESSAGE_WITH_CONTEXT(MSG::WARNING, "CaloClusterContainerCnv_p3")
34 << "Not converting CaloClusterContainer.";
35 return;
36 }
37
40
41 std::vector<float> temp_Moments;
43 A.expandToFloat( pers->m_momentContainer.m_Mvalue, temp_Moments); // unpacks moments
44
45 std::vector<float>::const_iterator i_mom = temp_Moments.begin();
46
47 const std::vector<unsigned short>& keys = pers->m_momentContainer.m_Mkey;
48 unsigned int nkeys = keys.size();
49
50 for(;itp!=itp_e;++itp) {
51 // Get next ptr for next cluster
52 CaloCluster* transCluster = clusters.nextElementPtr();
53 //Convert Cluster-quantities
54 persToTrans(&(*itp),transCluster,
55 showerLinkState,
56 cellLinkState,
57 log);
58 //Convert sampling data store
59 m_samplingDataContainerCnv.persToTrans(&(pers->m_samplingDataContainer),&(transCluster->m_dataStore),
60 samplingState);
61
62 //Convert moment store
64 for (unsigned short i=0;i<nkeys;++i) {
65 transStore.insert (transStore.end(), CaloClusterMomentStore::moment_store::value_type( keys[i], (*i_mom) ) );
66 //std::cout<<"imom: "<<(*i_key)<<" "<<(*i_mom)<<"\t";
67 ++i_mom;
68 }
69 transCluster->m_momentStore.setMomentStore (std::move (transStore));
70 //std::cout<<std::endl;
71 trans->push_back(transCluster);
72 }
73 //Convert TowerSegment
74 CaloTowerSeg seg;
75 m_caloTowerSegCnv.persToTrans(&(pers->m_towerSeg),&seg);
76 trans->setTowerSeg (seg);
77}
78
79
80
83 MsgStream &log) const
84{
85 if (log.level() <= MSG::DEBUG) log<< MSG::DEBUG << "Writing CaloClusterContainerCNV_p3" << endmsg;
86
87 // reset element link converters, and provide container name lookup table
88 ShowerLinkState showerLinkState (pers->m_linkNames);
89 CellLinkState cellLinkState (pers->m_linkNames);
90
91 pers->m_vec.resize(trans->size());
95
96
97 // moment keys are done here - once per container - we store keys and number of them
98 pers->m_momentContainer.m_Mkey.clear();
99 if (it!=it_e) {
100 const CaloClusterMomentStore* ms=&((*it)->m_momentStore);
101 CaloClusterMomentStore::moment_iterator mit=((*it)->m_momentStore).begin();
102 int nMom=ms->size();
103 pers->m_momentContainer.m_nMoments = nMom;
104 for (int w=0; w<nMom; w++){ // here stores moment keys per container not cluster
105 // std::cout<<"key: "<<mit.getMomentType()<<"\t";
106 pers->m_momentContainer.m_Mkey.push_back(mit.getMomentType());
107 ++mit;
108 }
109 // std::cout<<std::endl;
110 }
111 else
113
114 std::vector<float> temp_Moments;
115
116 for(;it!=it_e;++it,++itp) {
117 transToPers(*it,&(*itp),
118 showerLinkState,
119 cellLinkState,
120 log);
121 m_samplingDataContainerCnv.transToPers(&((*it)->m_dataStore),&(pers->m_samplingDataContainer),log);
122
123 CaloClusterMomentStore::moment_iterator itm=(*it)->m_momentStore.begin();
124 CaloClusterMomentStore::moment_iterator itm_e=(*it)->m_momentStore.end();
125
126 for(;itm!=itm_e;++itm) {
127 temp_Moments.push_back(itm.getMoment().getValue());
128 //std::cout<<"mom: "<<itm.getMoment().getValue()<<"\t";
129 }
130 //std::cout<<std::endl;
131 }
132
134 A.setNrBits(16);
135 // A.setIgnoreSign();
136 A.reduce(temp_Moments,pers->m_momentContainer.m_Mvalue); // packs moments
137
138 m_caloTowerSegCnv.transToPers(&trans->getTowerSeg(),&(pers->m_towerSeg));
139
140}
141
142
143
145 CaloCluster* trans,
146 ShowerLinkState& showerLinkState,
147 CellLinkState& cellLinkState,
148 MsgStream& log) const
149{
151 trans->setBasicEnergy (pers->m_basicSignal);
152 trans->setTime (pers->m_time);
154 trans->m_barrel=pers->m_barrel;
155 trans->m_endcap=pers->m_endcap;
156 trans->m_eta0=pers->m_eta0;
157 trans->m_phi0=pers->m_phi0;
159 trans->setClusterSize (pers->m_clusterSize);
160
161 //trans->m_barrel=pers->m_samplingPattern & 0x1ff00f; //That's the OR of all barrel-bits
162 //trans->m_endcap=pers->m_samplingPattern & 0xe00ff0; //That's the OR of all endcap-bits
163
164 //Convert base class and element links
165 m_P4EEtaPhiMCnv.persToTrans(&pers->m_P4EEtaPhiM,static_cast<P4EEtaPhiM*>(trans),log);
166 m_showerElementLinkCnv.persToTrans(showerLinkState, pers->m_dataLink, trans->m_dataLink,log);
167 m_cellElementLinkCnv.persToTrans(cellLinkState, pers->m_cellLink, trans->m_cellLink,log);
169
170}
171
172
175 ShowerLinkState& showerLinkState,
176 CellLinkState& cellLinkState,
177 MsgStream& log) const
178{
179 pers->m_basicSignal=trans->getBasicEnergy();
180 pers->m_time=trans->getTime();
182 pers->m_barrel=trans->m_barrel;
183 pers->m_endcap=trans->m_endcap;
184 pers->m_eta0=trans->eta0();
185 pers->m_phi0=trans->phi0();
187 pers->m_clusterSize=trans->getClusterSize();
188
189 //Convert base class and element links
190 P4EEtaPhiM tmp = *trans;
191 m_P4EEtaPhiMCnv.transToPers(&tmp,&pers->m_P4EEtaPhiM,log);
192 m_showerElementLinkCnv.transToPers(showerLinkState, trans->m_dataLink, pers->m_dataLink,log);
193 m_cellElementLinkCnv.transToPers(cellLinkState, trans->m_cellLink, pers->m_cellLink,log);
194}
#define endmsg
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
virtual void setAthenaBarCode(AthenaBarCode_t id)
virtual void persToTrans(const CaloClusterContainer_p3 *pers, CaloClusterContainer *trans, MsgStream &log) const override
ElementLinkCnv_p2< ElementLink< CaloCellLinkContainer > >::State CellLinkState
ElementLinkCnv_p2< ElementLink< CaloShowerContainer > >::State ShowerLinkState
CaloSamplingDataContainerCnv_p1 m_samplingDataContainerCnv
ElementLinkCnv_p2< ElementLink< CaloShowerContainer > > m_showerElementLinkCnv
ElementLinkCnv_p2< ElementLink< CaloCellLinkContainer > > m_cellElementLinkCnv
virtual void transToPers(const CaloClusterContainer *trans, CaloClusterContainer_p3 *pers, MsgStream &log) const override
CaloSamplingDataContainer_p1 m_samplingDataContainer
CaloClusterMomentContainer_p2 m_momentContainer
ElementLinkContNames_p2 m_linkNames
contType::const_iterator const_iterator
virtual const CaloTowerSeg & getTowerSeg() const
Retrieve tower segmentation.
virtual void setTowerSeg(const CaloTowerSeg &towerSeg)
Set tower segmentation into CaloClusterContainer.
Stores CaloClusterMoment in a keyed map.
CaloClusterMomentIterator moment_iterator
External moment iterator type.
virtual void setMomentStore(const moment_store &rMomStore)
Set internal store.
std::map< moment_key, moment_value > moment_store
Internal moment store type.
cell_link_type m_cellLink
Local pointer to cell store.
Principal data class for CaloCell clusters.
double eta0() const
Returns raw of cluster seed.
CaloClusterMomentStore m_momentStore
cluster moments
virtual double getBasicEnergy() const
Access basic energy scale signal.
unsigned int m_samplingPattern
Sampling pattern.
double getTime() const
Access cluster time.
bool m_endcap
Flag is true if at least one cell in EMB.
bool setDefaultSignalState(signalstate_t s)
Sets default signal state.
void setClusterSize(unsigned int theClusterSize)
Set cluster size.
void setTime(double theTime)
Set cluster time.
unsigned int getClusterSize() const
Get cluster size.
CaloSamplingData m_dataStore
{\ brief Cached Stores
virtual void setBasicEnergy(double theEnergy)
Set basic energy scale signal.
double phi0() const
Returns raw of cluster seed.
bool m_barrel
Flag is true if at least one cell in EMB.
CaloRecoStatus m_status
Calorimeter reconstruction status.
reconstruction status indicator
virtual const store_type & getStatusWord() const
retrieve the entire status word
Data object stores CaloTower segmentation.
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
static const AthenaBarCode_t UNDEFINEDBARCODE
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
hold the test vectors and ease the comparison