ATLAS Offline Software
Loading...
Searching...
No Matches
RpcSectorLogicContainerCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10
11// Gaudi
12#include "GaudiKernel/ISvcLocator.h"
13#include "GaudiKernel/Bootstrap.h"
14#include "GaudiKernel/StatusCode.h"
15#include "GaudiKernel/Service.h"
16#include "GaudiKernel/MsgStream.h"
17
18// Athena
20
22
23#include <ranges>
24#include <cassert>
25
27{
28 unsigned int tCsize=transCont->size();
29 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "RpcSectorLogicContainerCnv_p1::transToPers " << endmsg;
30 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " RpcSectorLogicContainerCnv_p1 sizes: trans: " << tCsize << " " << endmsg;
31 //std::cout<<"m_sectorList[0]: "<<transCont->m_sectorList[0]<<", m_sectorList[1]"<<transCont->m_sectorList[1]<<std::endl;
32 persCont->m_sectorList[0] = transCont->sectorList()[0];
33 persCont->m_sectorList[1] = transCont->sectorList()[1];
34
36 RpcSectorLogicContainer::const_iterator it_CollEnd = transCont->end();
37 //std::cout<<"RpcSectorLogicContainer has "<<transCont->size()<<" SLs"<<std::endl;
38 unsigned int slVariableIndex=0;
39 unsigned int triggerRateIndex=0;
40
41 if (transCont->empty()) return; //All we can do in this case
42
43 //std::cout<<"persCont->m_slVariables.resize(transCont->size() * 8) = "<<transCont->size() * 8<<std::endl;
44
45 persCont->m_slVariables.resize(tCsize * 8);// We know that AT MINIMUM it will be this big.
46 //std::cout<<"A"<<std::endl;
47 persCont->m_slVariables[slVariableIndex++]=tCsize; // 1st element is number of SLs. Format is defined in RpcSectorLogicContainer_p1.h
48 //std::cout<<"B"<<std::endl;
49
50 persCont->m_hasMoreThan2TriggerCand.reserve(tCsize);
51 //unsigned int indexSL=0;
52 for (; it_Coll != it_CollEnd; ++it_Coll) {
53 //std::cout<<"Processing SL :"<<indexSL++<<", slVariableIndex="<<slVariableIndex<<std::endl;
54
55 // Resize now, to allow stl::copy to work safely.
56 persCont->m_slVariables.resize(persCont->m_slVariables.size() + 8 + (**it_Coll).counters().size()); // 8 because it's 5 SL variables, plus 3 size counters
57
58 // SectorLogic variables
59 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).sectorId();
60 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).fel1Id();
61 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).bcid();
62 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).errorCode();
63 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).crc();
64 //std::cout<<"sl variables="<<persCont->m_slVariables[slVariableIndex-5]<<", "<<persCont->m_slVariables[slVariableIndex-4]<<", "<<persCont->m_slVariables[slVariableIndex-3]<<", "<<persCont->m_slVariables[slVariableIndex-2]<<", "<<persCont->m_slVariables[slVariableIndex-1]<<std::endl;
65
66 // m_counters (pers version already resized at start of loop)
67 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).counters().size(); // Size of m_counters
68 //std::cout<<"m_counters.size()="<<(**it_Coll).counters().size()<<", slVariableIndex="<<slVariableIndex<<std::endl;
69
70 std::copy ((**it_Coll).counters().begin(), (**it_Coll).counters().end(), persCont->m_slVariables.begin()+slVariableIndex);
71 slVariableIndex+=(**it_Coll).counters().size();
72
73 // m_triggerRates
74 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).triggerRates().size(); // Size of m_triggerRates
75//std::cout<<"m_triggerRates :"<<persCont->m_slVariables[slVariableIndex]<<", slVariableIndex="<<slVariableIndex<<std::endl;
76 persCont->m_triggerRates.resize(persCont->m_triggerRates.size()+(**it_Coll).triggerRates().size());
77 std::copy ((**it_Coll).triggerRates().begin(), (**it_Coll).triggerRates().end(), persCont->m_triggerRates.begin()+triggerRateIndex);
78 triggerRateIndex+=(**it_Coll).triggerRates().size();
79
80 persCont->m_hasMoreThan2TriggerCand.push_back((**it_Coll).hasMoreThan2TriggerCand());
81
82 // Now handle RpcSLTriggerHit info
83 persCont->m_slVariables.resize(persCont->m_slVariables.size() + 1 + 9*(**it_Coll).size());
84 persCont->m_slVariables[slVariableIndex++]=(**it_Coll).size(); // Size of RpcSLTriggerHits
85 DataVector<RpcSLTriggerHit>::const_iterator itSLTH=(**it_Coll).begin();
86 DataVector<RpcSLTriggerHit>::const_iterator itSLTHEnd=(**it_Coll).end();
87 for (; itSLTH!=itSLTHEnd ; ++itSLTH){
88 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).rowinBcid();
89 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).padId();
90 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).ptId();
91 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).roi();
92 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).outerPlane();
93 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).overlapPhi();
94 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).overlapEta();
95 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).triggerBcid();
96 persCont->m_slVariables[slVariableIndex++]=(**itSLTH).isInput();
97 }
98 }
99 if (log.level() <= MSG::DEBUG) log << MSG::DEBUG
100 << "RpcSectorLogicContainerCnv_p1 summary: vector size "
101 << persCont->m_slVariables.size() << ", last index used "
102 << slVariableIndex
103 << endmsg;
104}
105
107{
108 transCont->setSectorList (persCont->m_sectorList);
109 //std::cout<<"**** RpcSectorLogicContainerCnv_p1::persToTrans"<<std::endl;
110 //std::cout<<"m_sectorList[0]: "<<transCont->m_sectorList[0]<<", m_sectorList[1]"<<transCont->m_sectorList[1]<<std::endl;
111
112 if (persCont->m_slVariables.empty()) return; //empty container
113
114 unsigned int index = 0; // for position within persCont->m_slVariables
115 unsigned int numOfSL= persCont->m_slVariables[index++];// 1st element is number of SLs
116//std::cout<<"persCont->m_slVariables.size(): "<<persCont->m_slVariables.size()<<", with numSL="<<numOfSL<<std::endl;
117 transCont->resize(numOfSL);
118 unsigned int indexSL = 0; // for number of SL & position within persCont->m_hasMoreThan2TriggerCand
119 unsigned int indexTR = 0;// for m_triggerRates
120 while (indexSL<numOfSL){
121//std::cout<<"Processing SL :"<<indexSL<<", index"<<index<<std::endl;
122//std::cout<<"sl variables="<<persCont->m_slVariables[index]<<", "<<persCont->m_slVariables[index+1]<<", "<<persCont->m_slVariables[index+2]<<", "<<persCont->m_slVariables[index+3]<<", "<<persCont->m_slVariables[index+4]<<std::endl;
123
124 RpcSectorLogic* rsl = new RpcSectorLogic(persCont->m_slVariables[index], //m_sectorId
125 persCont->m_slVariables[index+1], //m_fel1Id
126 persCont->m_slVariables[index+2], //m_bcid
127 persCont->m_slVariables[index+3], //m_errorCode
128 persCont->m_slVariables[index+4]);//m_crc
129 index+=5; // Fix for coverity defect 17799 - no multiple index++ in the same line.
131 uint16_t numCounters=persCont->m_slVariables[index++];
132 for (uint16_t i : std::ranges::subrange (persCont->m_slVariables.begin()+index,
133 persCont->m_slVariables.begin()+index + numCounters))
134 rsl->addCounter(i);
135 index+=numCounters;
136
137 uint16_t numTriggerRates=persCont->m_slVariables[index++];
138 //std::cout<<"numTriggerRates: "<<numTriggerRates<<", index"<<index<<", indexTR: "<<indexTR<<std::endl;
139
140//std::cout<<"persCont->m_triggerRates.size(): "<<persCont->m_triggerRates.size()<<std::endl;
141
142 for (double r : std::ranges::subrange(persCont->m_triggerRates.begin()+indexTR,
143 persCont->m_triggerRates.begin()+indexTR+numTriggerRates))
144 rsl->addTriggerRate (r);
145 indexTR+=numTriggerRates;
147 uint16_t numRpcSLTriggerHits = persCont->m_slVariables[index++];
148 //std::cout<<"numRpcSLTriggerHits: "<<numRpcSLTriggerHits<<std::endl;
149 rsl->resize(numRpcSLTriggerHits);
150 for (unsigned int th=0; th<numRpcSLTriggerHits; ++th){
151 //std::cout<<"begin th "<<th<<", index="<<index<<std::endl;
152 (*rsl)[th]=new RpcSLTriggerHit(persCont->m_slVariables[index], //rowinBcid
153 persCont->m_slVariables[index+1], //padid
154 persCont->m_slVariables[index+2], //ptid
155 persCont->m_slVariables[index+3], //roi
156 persCont->m_slVariables[index+4],//outerPlane
157 persCont->m_slVariables[index+5],//overlapPhi
158 persCont->m_slVariables[index+6],//overlapEta
159 persCont->m_slVariables[index+7]);//triggerBcid
160 index+=8;
161 (*rsl)[th]->setIsInput (static_cast<bool>(persCont->m_slVariables[index++]));
162 //std::cout<<"end th "<<th<<", index="<<index<<std::endl;
163 }
164 (*transCont)[indexSL++]=rsl;
165 //std::cout<<"End of loop on SL, index"<<index<<std::endl;
166 }
167}
168
169
#define endmsg
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
void resize(size_type sz)
Resizes the collection to the specified number of elements.
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.
bool empty() const noexcept
Returns true if the collection is empty.
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log) const override
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log) const override
std::vector< uint16_t > m_slVariables
This contains the bulk of the information from the various SL objects.
std::vector< double > m_triggerRates
Number of m_triggerRates per SL is defined in m_slVariables.
uint32_t m_sectorList[2]
From RpcSectorLogicContainer.
std::vector< bool > m_hasMoreThan2TriggerCand
This is just one per SL.
void setSectorList(const SectorList_t &sectorList)
const SectorListElement_t * sectorList() const
void addCounter(const uint16_t counter)
Set methods.
void addTriggerRate(const double trig)
void setHasMoreThan2TriggerCand(const bool a)
int r
Definition globals.cxx:22
Definition index.py:1