14 #include "MuCalDecode/CalibEvent.h"
15 #include "MuCalDecode/CalibUti.h"
21 const std::string&
name,
37 m_localBuffer.clear();
39 m_localBufferSize = 0;
46 return StatusCode::SUCCESS;
57 std::string
name = m_calBufferName;
58 name +=
"_"+m_algInstanceName;
60 if ( m_circ ==
nullptr ) {
69 <<
name <<
" buffer size=" << calBufferSize);
72 ATH_MSG_INFO(
"Opening muon calibration stream. Buffer name: "
73 <<
name <<
" buffer size: " << calBufferSize);
76 return StatusCode::SUCCESS;
88 std::string
name = m_calBufferName+
"_"+m_algInstanceName;
97 return StatusCode::SUCCESS;
118 bool &updateTriggerElement,
const EventContext& ctx)
const
127 unsigned int totalHits = mdtHits.size()+rpcHits.size()+tgcHits.size();
128 if ( totalHits > 500 ) {
130 updateTriggerElement=
false;
131 return StatusCode::SUCCESS;
137 return StatusCode::FAILURE;
152 float phi = (
float)
track.phiVtx;
157 std::vector<uint32_t> robIdList_MDT;
158 double etaMin = roi->eta()-0.05;
159 double etaMax = roi->eta()+0.05;
160 double phi_roi = roi->phi();
161 double phiMin = roi->phi()-0.05;
162 double phiMax = roi->phi()+0.05;
163 if( phi_roi < 0 ) phi_roi += 2*
M_PI;
164 if( phiMin < 0 ) phiMin += 2*
M_PI;
165 if( phiMax < 0 ) phiMax += 2*
M_PI;
170 m_regSel_MDT->lookup( ctx )->ROBIDList(*iroi,robIdList_MDT);
173 ATH_MSG_DEBUG(
"Size of the MDT rob list: " << robIdList_MDT.size());
174 int isize = robIdList_MDT.size()<5 ? robIdList_MDT.size() : 4;
175 for (
int ii = 0 ; ii<isize ; ++ii ) {
176 ATH_MSG_DEBUG(
"robId: 0x" << std::hex << robIdList_MDT.at(ii) << std::dec);
177 mrods[ii] = robIdList_MDT.at(ii);
181 std::vector<uint32_t> robIdList_TGC;
182 m_regSel_TGC->lookup(ctx)->ROBIDList(*iroi,robIdList_TGC);
183 ATH_MSG_DEBUG(
"Size of the TGC rob list: " << robIdList_TGC.size());
186 LVL2_MUON_CALIBRATION::CalibEvent
event(1,
runId,lvl1Id,1,1,mrods,
name().c_str(),eta,phi,
pt);
187 LVL2_MUON_CALIBRATION::MdtCalibFragment mdtFragment;
190 if ( mdtHits.size()>0 ) {
191 ATH_CHECK( createMdtFragment(mdtHits,mdtFragment,phi) );
194 event << mdtFragment;
198 return StatusCode::SUCCESS;
202 if ( rpcHits.size() > 0 ) {
203 LVL2_MUON_CALIBRATION::RpcCalibFragment rpcFragment;
205 if ( createRpcFragment(roi, rpcFragment, ctx) != StatusCode::SUCCESS ) {
206 ATH_MSG_WARNING(
"Could not create the Rpc fragment of the calibration stream");
209 ATH_MSG_DEBUG(
"Adding the RPC fragment to the calibration stream");
210 event << rpcFragment;
214 if ( tgcHits.size() > 0 ) {
215 LVL2_MUON_CALIBRATION::TgcCalibFragment tgcFragment;
217 if ( createTgcFragment(robIdList_TGC,tgcFragment) != StatusCode::SUCCESS ) {
218 ATH_MSG_ERROR(
"Could not create the Tgc fragment of the calibration stream");
221 ATH_MSG_DEBUG(
"Adding the TGC fragment to the calibration stream");
222 event << tgcFragment;
232 m_circ->dumpToCirc (
event);
235 return StatusCode::SUCCESS;
242 LVL2_MUON_CALIBRATION::MdtCalibFragment& mdtFragment,
246 TrigL2MuonSA::MdtHits::const_iterator
it = mdtHits.begin();
247 for ( ;
it != mdtHits.end() ; ++
it ) {
250 int stationEta = (*it).StationEta;
251 int stationPhi = (*it).StationPhi;
252 int multilayer = (*it).Multilayer;
253 int layer = (*it).TubeLayer;
254 int tube = (*it).Tube;
257 stationEta,stationPhi,multilayer,
layer,
tube);
259 uint16_t leadingCoarseTime = (*it).LeadingCoarseTime;
260 uint16_t leadingFineTime = (*it).LeadingFineTime;
261 uint16_t trailingCoarseTime = (*it).TrailingCoarseTime;
262 uint16_t trailingFineTime = (*it).TrailingFineTime;
265 LVL2_MUON_CALIBRATION::MdtCalibData mdt(
ID,leadingCoarseTime,leadingFineTime,
266 trailingCoarseTime,trailingFineTime,
adc
275 return StatusCode::SUCCESS;
284 LVL2_MUON_CALIBRATION::RpcCalibFragment& rpcFragment,
const EventContext& ctx)
const
289 if ( roi->
getSource() != 0 )
return StatusCode::SUCCESS;
304 unsigned int padIdHash;
305 if (readCdo->give_PAD_address(
side, sector,
roiNumber, padIdHash)) {
308 if( itPad==
nullptr ) {
310 return StatusCode::FAILURE;
312 const RpcPad* rpcPad = itPad;
315 uint16_t sysId = (sector<32)? 0x66 : 0x65;
321 LVL2_MUON_CALIBRATION::RpcCalibFragment frag(sysId,secId,padId,
status,
error);
324 for (; it3!=rpcPad->
end() ; ++it3) {
332 LVL2_MUON_CALIBRATION::RpcCalibData
matrix(cmaId,fel1Id,febcId,crc);
336 for (; it5 != (*it3)->end() ; ++it5) {
356 ATH_MSG_WARNING(
"Can't get the pad address from the RpcCablingCondData");
357 return StatusCode::FAILURE;
360 return StatusCode::SUCCESS;
369 LVL2_MUON_CALIBRATION::TgcCalibFragment& tgcFragment)
const
373 if ( robIdList_TGC.size()<1 ) {
375 return StatusCode::SUCCESS;
381 uint16_t subSystemId = ( (robIdList_TGC.at(0) & 0xff0000) >> 16 );
382 uint16_t rdoId = ( robIdList_TGC.at(0) & 0xff );
386 tgcFragment = LVL2_MUON_CALIBRATION::TgcCalibFragment(
systemId,subSystemId,rdoId,
roiNumber);
392 return StatusCode::FAILURE;
400 LVL2_MUON_CALIBRATION::TgcCalibData tgc_payload;
403 for ( ;
it != tgcRdoContainer->
end() ; ++
it ) {
411 for ( ; itRaw != (*it)->end() ; ++itRaw ) {
414 LVL2_MUON_CALIBRATION::TGC_BYTESTREAM_READOUTHIT roh;
415 LVL2_MUON_CALIBRATION::TGC_BYTESTREAM_READOUTTRIPLETSTRIP tps;
416 LVL2_MUON_CALIBRATION::TGC_BYTESTREAM_READOUTTRACKLET rot;
417 LVL2_MUON_CALIBRATION::TGC_BYTESTREAM_HIPT hpt;
418 LVL2_MUON_CALIBRATION::TGC_BYTESTREAM_SL sl;
421 switch (raw->
type()) {
424 roh.channel = raw->
channel()-40;
425 roh.sbId = raw->
slbId();
428 roh.ldbId = raw->
sswId();
440 tps.sbId = raw->
slbId();
441 tps.ldbId = raw->
sswId();
451 rot.delta = raw->
delta();
452 rot.sbId = raw->
slbId();
453 rot.ldbId = raw->
sswId();
463 hpt.delta = raw->
delta();
464 hpt.hitId = raw->
hitId();
466 hpt.cand = raw->
index();
467 hpt.chip = raw->
chip();
468 hpt.sector = raw->
sector();
480 sl.cand = raw->
index();
481 sl.sector = raw->
sector();
490 return StatusCode::FAILURE;
494 tgc_payload.getHit(roh,tps,rot,hpt,sl);
499 tgcFragment << tgc_payload;
501 return StatusCode::SUCCESS;