ATLAS Offline Software
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
19 #include "StoreGate/StoreGateSvc.h"
20 
21 #include "AthAllocators/DataPool.h"
22 
23 #include "boost/range/iterator_range.hpp"
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 
35  RpcSectorLogicContainer::const_iterator it_Coll = transCont->begin();
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
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.
130  rsl->setHasMoreThan2TriggerCand (persCont->m_hasMoreThan2TriggerCand[indexSL]);
131  uint16_t numCounters=persCont->m_slVariables[index++];
132  for (uint16_t i : boost::make_iterator_range (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 : boost::make_iterator_range(persCont->m_triggerRates.begin()+indexTR,
143  persCont->m_triggerRates.begin()+indexTR+numTriggerRates))
144  rsl->addTriggerRate (r);
145  indexTR+=numTriggerRates;
146  rsl->setHasMoreThan2TriggerCand (persCont->m_hasMoreThan2TriggerCand[indexSL]);
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 
beamspotman.r
def r
Definition: beamspotman.py:676
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
RpcSectorLogicContainer.h
RpcSectorLogicContainer::sectorList
const SectorListElement_t * sectorList() const
Definition: RpcSectorLogicContainer.cxx:31
RpcSectorLogic
Definition: RpcSectorLogic.h:20
RpcSLTriggerHit
Definition: RpcSLTriggerHit.h:16
index
Definition: index.py:1
RpcSectorLogicContainer_p1::m_sectorList
uint32_t m_sectorList[2]
From RpcSectorLogicContainer.
Definition: RpcSectorLogicContainer_p1.h:23
RpcSectorLogicContainer_p1::m_hasMoreThan2TriggerCand
std::vector< bool > m_hasMoreThan2TriggerCand
This is just one per SL.
Definition: RpcSectorLogicContainer_p1.h:53
RpcSectorLogic::addCounter
void addCounter(const uint16_t counter)
Set methods.
Definition: RpcSectorLogic.cxx:7
RpcSectorLogicContainerCnv_p1::persToTrans
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log) const override
Definition: RpcSectorLogicContainerCnv_p1.cxx:106
python.TriggerHandler.th
th
Definition: TriggerHandler.py:296
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
RpcSectorLogicContainer
Definition: RpcSectorLogicContainer.h:20
RpcSectorLogicContainer_p1::m_triggerRates
std::vector< double > m_triggerRates
Number of m_triggerRates per SL is defined in m_slVariables.
Definition: RpcSectorLogicContainer_p1.h:55
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DataPool.h
RpcSectorLogicContainerCnv_p1::transToPers
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log) const override
Definition: RpcSectorLogicContainerCnv_p1.cxx:26
DataVector::resize
void resize(size_type sz)
Resizes the collection to the specified number of elements.
RpcSectorLogicContainer_p1
Class to represent.
Definition: RpcSectorLogicContainer_p1.h:19
RpcSectorLogicContainer_p1::m_slVariables
std::vector< uint16_t > m_slVariables
This contains the bulk of the information from the various SL objects.
Definition: RpcSectorLogicContainer_p1.h:51
RpcSectorLogicContainer::setSectorList
void setSectorList(const SectorList_t &sectorList)
Definition: RpcSectorLogicContainer.cxx:37
RpcSectorLogic::setHasMoreThan2TriggerCand
void setHasMoreThan2TriggerCand(const bool a)
Definition: RpcSectorLogic.h:50
RpcSLTriggerHit.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
RpcSectorLogic.h
RpcSectorLogic::addTriggerRate
void addTriggerRate(const double trig)
Definition: RpcSectorLogic.h:49
RpcSectorLogicContainerCnv_p1.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
calibdata.copy
bool copy
Definition: calibdata.py:27
StoreGateSvc.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.