ATLAS Offline Software
CaloTTPpmRxIdMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "GaudiKernel/ISvcLocator.h"
9 #include "GaudiKernel/Bootstrap.h"
10 #include "GaudiKernel/MsgStream.h"
11 #include "GaudiKernel/IMessageSvc.h"
12 
13 #include "StoreGate/StoreGateSvc.h"
14 
15 #include <iostream>
16 
18 }
19 
20 
22 }
23 
24 //------------------------------------------//
26 
27  convert_to_P(m);
28 
29  IMessageSvc *msgSvc;
30  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
31  if(status.isFailure()){
32  std::cout << "Cannot locate MessageSvc" << std::endl;
33  }
34  MsgStream log( msgSvc, "CaloTTPpmRxIdMap");
35  bool dump=false;
36  if (log.level()<=MSG::VERBOSE) dump=true;
37  bool dump2=false;
38  if (log.level()<=MSG::DEBUG) dump2=true;
39 
40 
41  log<<MSG::DEBUG<<" CaloTTPpmRxId size = "<<m.size() <<endmsg;
43  status = Gaudi::svcLocator()->service("DetectorStore",detStore);
44  if(status.isFailure()){
45  log << MSG::ERROR << "Cannot locate DetectorStore" << endmsg;
46  }
47 
48  CaloTTPpmRxId::const_iterator it = m.begin();
49  CaloTTPpmRxId::const_iterator it_e = m.end();
50 
51  try {
52  for (; it!=it_e; ++it) {
53  const CaloTTPpmRxId_t& t = *it;
54 
55  L1CaloCoolChannelId ppmChannelId(t.ppm_crate, L1CaloModuleType::Ppm, t.ppm_module, t.ppm_subModule, t.ppm_channel);
56  L1CaloRxCoolChannelId rxChannelId(t.rx_crate, t.rx_module, t.rx_inputConn, t.rx_inputPair, t.rx_outputConn, t.rx_outputPair);
57 
58 /*
59  log<<MSG::VERBOSE
60  << " db struct= "
61  <<" pn="<<t.pn<<" sampling="<<t.sampling
62  <<" region="<<t.region
63  <<" eta="<<t.eta<<" phi="<<t.phi<<" layer="<<t.layer<<" | "
64  <<" crate="<<t.crate<<" module="<<t.module
65  <<" submodule="<<t.submodule
66  <<" channel="<<t.channel
67  << endmsg;
68 */
69  if (dump) log << MSG::VERBOSE << " ppm id = " << ppmChannelId.id() << " rx id =" << rxChannelId.id() <<endmsg;
70 
71  m_mPpmIdToRx[ppmChannelId].push_back(rxChannelId);
72  m_mRxIdToPpm[rxChannelId] = ppmChannelId;
73 
74  }
75  if (dump2) log<<MSG::DEBUG<<" CaloTTPpmRxIdMap::set : number of Ids="<<m_mPpmIdToRx.size()<<std::endl;
76  } catch (CaloID_Exception& except) {
77  log<<MSG::ERROR<<" Failed in CaloTTPpmRxIdMap::set " << endmsg;
78  log<<MSG::ERROR<< (std::string) except << endmsg ;
79  }
80  return;
81 }
82 
83 //--------------------------------------------------------------------------//
84 std::vector<L1CaloRxCoolChannelId> CaloTTPpmRxIdMap::ppmToRxId(const L1CaloCoolChannelId& ppmChannelId) const {
85 
86  std::map<L1CaloCoolChannelId, std::vector<L1CaloRxCoolChannelId> >::const_iterator it = m_mPpmIdToRx.find(ppmChannelId);
87 
88  if(it!=m_mPpmIdToRx.end()){
89  return it->second;
90  }
91 
92  IMessageSvc *msgSvc;
93  StatusCode status = Gaudi::svcLocator()->service("MessageSvc",msgSvc);
94  if(status.isFailure()){
95  std::cout << "Cannot locate MessageSvc" << std::endl;
96  }
97 
98  MsgStream log( msgSvc, "CaloTTPpmRxIdMap");
99  log<<MSG::ERROR<<" Ppm channel ID not found, id= "<< ppmChannelId.id()<<" in Ppm to Rx map." <<endmsg;
100 
101  return std::vector<L1CaloRxCoolChannelId>();
102 }
103 
104 
105 //---------------------------------------------------------------------//
107 
108  std::map<L1CaloRxCoolChannelId, L1CaloCoolChannelId >::const_iterator it=m_mRxIdToPpm.find(rxChannelId);
109 
110  if(it!=m_mRxIdToPpm.end()){
111  return it->second;
112  }
113 
114  // ERROR, can not find the id.
115  IMessageSvc *msgSvc;
116  StatusCode status =Gaudi::svcLocator()->service("MessageSvc",msgSvc);
117  if(status.isFailure()){
118  std::cout << "Cannot locate MessageSvc" << std::endl;
119  }
120 
121  MsgStream log( msgSvc, "CaloTTPpmRxIdMap");
122  log<<MSG::ERROR<<" Rx channel ID not found, id = " <<rxChannelId.id()<<" in Rx to Ppm map."<< endmsg;
123 
124  return L1CaloCoolChannelId(0) ;
125 }
126 
128  return &m_persData;
129 }
130 
132 
133  CaloTTPpmRxId::const_iterator it = d.begin();
134  CaloTTPpmRxId::const_iterator it_e = d.end();
135 
136  for ( ;it!=it_e;++it){
137  const CaloTTPpmRxId_t& t = *it;
139 
140  t2.ppm_crate = t.ppm_crate;
141  t2.ppm_module = t.ppm_module;
142  t2.ppm_subModule = t.ppm_subModule;
143  t2.ppm_channel = t.ppm_channel;
144 
145  t2.rx_crate = t.rx_crate ;
146  t2.rx_module = t.rx_module;
147  t2.rx_inputConn = t.rx_inputConn;
148  t2.rx_inputPair = t.rx_inputPair;
149  t2.rx_outputConn = t.rx_outputConn;
150  t2.rx_outputPair = t.rx_outputPair;
151 
152  m_persData.m_v.push_back(t2);
153  }
154 }
155 
156 
158 
159  std::vector<CaloTTPpmRxId_P::__t>::const_iterator it = p.m_v.begin();
160  std::vector<CaloTTPpmRxId_P::__t>::const_iterator it_e = p.m_v.end();
161 
162  d.clear();
163  for ( ;it!=it_e;++it){
164  const CaloTTPpmRxId_P::__t& t = *it;
166 
167  t2.ppm_crate = t.ppm_crate;
168  t2.ppm_module = t.ppm_module;
169  t2.ppm_subModule = t.ppm_subModule;
170  t2.ppm_channel = t.ppm_channel;
171 
172  t2.rx_crate = t.rx_crate ;
173  t2.rx_module = t.rx_module;
174  t2.rx_inputConn = t.rx_inputConn;
175  t2.rx_inputPair = t.rx_inputPair;
176  t2.rx_outputConn = t.rx_outputConn;
177  t2.rx_outputPair = t.rx_outputPair;
178 
179  d.push_back(t2);
180  }
181 }
182 
184 
186  convert_to_D(p,d);
187  set(d);
188  m_persData.m_version = p.m_version;
189  return;
190 }
CaloTTPpmRxIdMap::getP
CaloTTPpmRxId_P * getP()
return the persistified map
Definition: CaloTTPpmRxIdMap.cxx:127
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CaloID_Exception
Exception class for Calo Identifiers.
Definition: CaloID_Exception.h:20
CaloTTPpmRxId
std::vector< CaloTTPpmRxId_t > CaloTTPpmRxId
Definition: CaloTTPpmRxId.h:30
hist_file_dump.d
d
Definition: hist_file_dump.py:137
skel.it
it
Definition: skel.GENtoEVGEN.py:423
L1CaloRxCoolChannelId::id
unsigned int id() const
Definition: L1CaloRxCoolChannelId.h:27
CaloTTPpmRxIdMap::~CaloTTPpmRxIdMap
~CaloTTPpmRxIdMap()
Definition: CaloTTPpmRxIdMap.cxx:21
CaloTTPpmRxIdMap::ppmToRxId
std::vector< L1CaloRxCoolChannelId > ppmToRxId(const L1CaloCoolChannelId &ppmChannelId) const
return the corresponding Rx channels to the Ppm input one
Definition: CaloTTPpmRxIdMap.cxx:84
CaloTTPpmRxIdMap.h
CaloTTPpmRxId_P::CaloTTPpmRxId_P_t
Structure of the map.
Definition: CaloTTPpmRxId_P.h:27
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
CaloTTPpmRxId_P::m_v
std::vector< __t > m_v
Definition: CaloTTPpmRxId_P.h:48
CaloTTPpmRxIdMap::set
void set(const PDATA &t)
initialize from Nova
Definition: CaloTTPpmRxIdMap.cxx:25
CaloTTPpmRxIdMap::CaloTTPpmRxIdMap
CaloTTPpmRxIdMap()
Definition: CaloTTPpmRxIdMap.cxx:17
CaloTTPpmRxIdMap::convert_to_D
void convert_to_D(const CaloTTPpmRxId_P &t, CaloTTPpmRxId &d)
Definition: CaloTTPpmRxIdMap.cxx:157
CaloTTPpmRxId_t
Structure definition of the CaloTTPpmRxIdMap.
Definition: CaloTTPpmRxId.h:15
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
L1CaloRxCoolChannelId
Definition: L1CaloRxCoolChannelId.h:10
CaloTTPpmRxIdMap::rxToPpmId
L1CaloCoolChannelId rxToPpmId(const L1CaloRxCoolChannelId &rxChannelId) const
return the corresponfing ppm channel to the Rx input one
Definition: CaloTTPpmRxIdMap.cxx:106
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
CaloTTPpmRxIdMap::m_persData
CaloTTPpmRxId_P m_persData
Definition: CaloTTPpmRxIdMap.h:64
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
L1CaloCoolChannelId::id
unsigned int id() const
Definition: L1CaloCoolChannelId.h:32
CaloTTPpmRxId_P::m_version
int m_version
Definition: CaloTTPpmRxId_P.h:50
python.ChapPy.dump
def dump(buf, stdout=sys.stdout)
Definition: ChapPy.py:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloTTPpmRxId_P
This is a database object holding the TT PPM to RX channels map.
Definition: CaloTTPpmRxId_P.h:22
L1CaloCoolChannelId
Definition: L1CaloCoolChannelId.h:10
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
L1CaloModuleType::Ppm
@ Ppm
Definition: L1CaloModuleType.h:17
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
merge.status
status
Definition: merge.py:17
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
CaloTTPpmRxIdMap::convert_to_P
void convert_to_P(const CaloTTPpmRxId &t)
Definition: CaloTTPpmRxIdMap.cxx:131
CaloTTPpmRxIdMap::m_mPpmIdToRx
std::map< L1CaloCoolChannelId, std::vector< L1CaloRxCoolChannelId > > m_mPpmIdToRx
Definition: CaloTTPpmRxIdMap.h:61
CaloID_Exception.h
CaloTTPpmRxIdMap::m_mRxIdToPpm
std::map< L1CaloRxCoolChannelId, L1CaloCoolChannelId > m_mRxIdToPpm
Definition: CaloTTPpmRxIdMap.h:62
StoreGateSvc.h