Commit 48328085 authored by Rafal Bielski's avatar Rafal Bielski Committed by Johannes Elmsheuser
Browse files

Rec[Em|Jet|Energy]RoI + L1TopoTOB: Avoid unnecessary narrowing casts between...

Rec[Em|Jet|Energy]RoI + L1TopoTOB: Avoid unnecessary narrowing casts between signed and unsigned integers
parent 54c0f956
......@@ -374,7 +374,7 @@ StatusCode L1TopoLegacyOnlineMonitor::doCnvMon(xAOD::TrigComposite& errorFlags,
break;
}
case L1Topo::BlockTypes::L1TOPO_TOB: {
block.daqTobs.emplace_back(static_cast<int32_t>(word)); // TODO: Fix L1TopoTOB ctor to take uint32_t word
block.daqTobs.emplace_back(word);
if (block.header.bcn_offset() == 0) {
daqTobsBC0.emplace_back(rdo->getSourceID(), block.daqTobs.back());
}
......
......@@ -17,11 +17,11 @@ namespace L1Topo {
class L1TopoTOB {
public:
//! Construct from contents and encode word
L1TopoTOB(const int32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits, uint32_t error_bits);
L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits, uint32_t error_bits);
//! Construct from contents and encode word, without CRC error bits (they will be 0 by default)
L1TopoTOB(const int32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits);
L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits);
//! Construct with word and decode contents
L1TopoTOB(const int32_t word);
L1TopoTOB(const uint32_t word);
//! access method for ctp signal bits
uint32_t ctp_signal() const;
//! accessor method for overflow bits
......
......@@ -41,7 +41,7 @@ std::ostream& operator<<(std::ostream& os, const L1TopoRDO& rdo) {
}
os << " Data words:\n";
std::vector<uint32_t> data = rdo.getDataWords();
for(auto & word: data){
for(const uint32_t word: data){
os << " " << L1Topo::formatHex8(word) << " ";
switch (L1Topo::blockType(word)){
case L1Topo::BlockTypes::HEADER:
......@@ -166,7 +166,7 @@ const std::string formatVecHex8(const std::vector<uint32_t>& vec)
for (L1TopoRDOCollection::const_iterator pRDO = col.begin(); pRDO != col.end(); ++pRDO){
const std::vector<uint32_t> data = (*pRDO)->getDataWords();
//std::cout << "L1Topo::getDecisionAndOverflowBits: number of data words " << data.size() << std::endl;
for(auto & word: data){
for(const uint32_t word: data){
if (L1Topo::blockType(word) == L1Topo::BlockTypes::L1TOPO_TOB){
L1Topo::L1TopoTOB c(word);
const uint32_t triggerByte = c.trigger_bits();
......
......@@ -11,15 +11,15 @@
namespace L1Topo {
L1TopoTOB::L1TopoTOB(const int32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits, uint32_t error_bits)
L1TopoTOB::L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits, uint32_t error_bits)
: m_ctp_signal(ctp_signal), m_overflow_bits(overflow_bits), m_trigger_bits(trigger_bits),m_error_bits(error_bits),m_word(0){
this->encode();
}
L1TopoTOB::L1TopoTOB(const int32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits)
L1TopoTOB::L1TopoTOB(const uint32_t ctp_signal, uint32_t overflow_bits, uint32_t trigger_bits)
: m_ctp_signal(ctp_signal), m_overflow_bits(overflow_bits), m_trigger_bits(trigger_bits),m_error_bits(0),m_word(0){
this->encode();
}
L1TopoTOB::L1TopoTOB(const int32_t word)
L1TopoTOB::L1TopoTOB(const uint32_t word)
: m_word(word){
this->decode();
}
......
......@@ -290,7 +290,7 @@ L1TopoSimulation::retrieveHardwareDecision()
const std::vector<uint32_t> cDataWords = rdo->getDataWords();
// initialise header: set version 15, BCN -7, which is unlikely
L1Topo::Header header(0xf,0,0,0,0,1,0x7);
for (auto word : cDataWords){
for (const uint32_t word : cDataWords){
switch (L1Topo::blockType(word)){
case L1Topo::BlockTypes::HEADER: {
header = L1Topo::Header(word);
......
......@@ -380,13 +380,13 @@ void L1JetCMXTools::getHits(const xAOD::CMXJetTob *tob, HitsVector &hit10,
energyLg[slice], energySm[slice]);
LVL1::RecJetRoI roi(tobRoi.roiWord(), &thresholds);
int numThresholdsHalf = 5;
int numBitsPerCounter = 3;
unsigned int numThresholdsHalf = 5;
unsigned int numBitsPerCounter = 3;
for (int i = 0; i < numThresholdsHalf * 2; ++i) {
for (unsigned int i = 0; i < numThresholdsHalf * 2; ++i) {
if (roi.passedThreshold(i)) {
HitsVector &hit = i < numThresholdsHalf ? hit10 : hit11;
int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf;
unsigned int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf;
hit[slice] |= (1 << (ibit * numBitsPerCounter));
}
}
......@@ -394,10 +394,10 @@ void L1JetCMXTools::getHits(const xAOD::CMXJetTob *tob, HitsVector &hit10,
numThresholdsHalf = 8;
numBitsPerCounter = 2;
for (int i = 0; i < numThresholdsHalf * 2; ++i) {
for (unsigned int i = 0; i < numThresholdsHalf * 2; ++i) {
if (roi.passedThreshold(10 + i)) {
HitsVector &hit = i < numThresholdsHalf ? hit20 : hit21;
int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf;
unsigned int ibit = i < numThresholdsHalf ? i : i - numThresholdsHalf;
hit[slice] |= (1 << (ibit * numBitsPerCounter));
}
}
......
......@@ -95,7 +95,7 @@ namespace LVL1 {
/** returns TRUE if threshold number <em>threshold_number</em> has been
passed by this ROI. */
bool passedThreshold( int threshold_number ) const;
bool passedThreshold( unsigned int threshold_number ) const;
/** returns the CoordinateRange. This is worked out from the RoIWord's hardware coords
(i.e. crate number, CPM number etc.) by the RoIDecoder class. */
......
......@@ -74,15 +74,15 @@ namespace LVL1 {
/** returns TRUE if threshold number <em>threshold_number</em> has been passed
by this ROI. */
bool passedEtMissThreshold( int thresholdNumber ) const;
bool passedEtMissThreshold( unsigned int thresholdNumber ) const;
/** returns TRUE if threshold number <em>threshold_number</em> has been passed
by this ROI. */
bool passedSumEtThreshold( int thresholdNumber ) const;
bool passedSumEtThreshold( unsigned int thresholdNumber ) const;
/** returns TRUE if threshold number <em>threshold_number</em> has been passed
by this ROI. */
bool passedMEtSigThreshold( int thresholdNumber ) const;
bool passedMEtSigThreshold( unsigned int thresholdNumber ) const;
/** returns a vector of thresholds passed. */
std::vector<unsigned int> etMissThresholdsPassed() const;
......
......@@ -88,10 +88,10 @@ namespace LVL1 {
virtual unsigned int etSmall() const;
/** returns TRUE if threshold number <em>threshold_number</em> has been passed by this ROI. */
bool passedThreshold( int thresholdNumber ) const;
bool passedThreshold( unsigned int thresholdNumber ) const;
/** Same for forward jets. Deprecated in Run 2, will always return false. */
bool passedFwdThreshold( int thresholdNumber ) const;
bool passedFwdThreshold( unsigned int thresholdNumber ) const;
/** @brief returns the CoordinateRange.
* This is worked out from the RoIWord's hardware coords
......@@ -144,8 +144,8 @@ namespace LVL1 {
/** Information on trigger thresholds passed by RoI */
unsigned long int m_thresholdMask { 0 };
std::map< int, unsigned int > m_triggerThresholdValue;
std::map< int, unsigned int > m_windowSize;
std::map< unsigned int, unsigned int > m_triggerThresholdValue; //< {threshold number, threshold value}
std::map< unsigned int, unsigned int > m_windowSize; //< {threshold number, window size}
private:
// Constructor for Run 1 RoI format
......
......@@ -379,7 +379,7 @@ LVL1::RecEmTauRoI::roiType() const { return m_type; }
/** returns TRUE if threshold number <em>threshold_number</em> has been passed
* by this ROI. */
bool LVL1::RecEmTauRoI::passedThreshold(int threshold_number) const
bool LVL1::RecEmTauRoI::passedThreshold(unsigned int threshold_number) const
{
if (this->isValidThreshold(threshold_number)) {
return ((1 << threshold_number) & m_thresholdMask) != 0;
......
......@@ -175,7 +175,7 @@ unsigned int LVL1::RecEnergyRoI::roiWord2() const
/** returns TRUE if threshold number <em>threshold_number</em> has been pass
ed by this ROI. */
bool LVL1::RecEnergyRoI::passedEtMissThreshold(int thresholdNumber) const
bool LVL1::RecEnergyRoI::passedEtMissThreshold(unsigned int thresholdNumber) const
{
if ( this->isValidEtMissThreshold( thresholdNumber ) ) {
......@@ -187,7 +187,7 @@ bool LVL1::RecEnergyRoI::passedEtMissThreshold(int thresholdNumber) const
/** returns TRUE if threshold number <em>threshold_number</em> has been pass
ed by this ROI. */
bool LVL1::RecEnergyRoI::passedSumEtThreshold(int thresholdNumber) const
bool LVL1::RecEnergyRoI::passedSumEtThreshold(unsigned int thresholdNumber) const
{
if ( this->isValidSumEtThreshold( thresholdNumber ) ) {
......@@ -199,7 +199,7 @@ bool LVL1::RecEnergyRoI::passedSumEtThreshold(int thresholdNumber) const
/** returns TRUE if threshold number <em>threshold_number</em> has been pass
ed by this ROI. */
bool LVL1::RecEnergyRoI::passedMEtSigThreshold(int thresholdNumber) const
bool LVL1::RecEnergyRoI::passedMEtSigThreshold(unsigned int thresholdNumber) const
{
if ( this->isValidSumEtThreshold( thresholdNumber ) ) {
......
......@@ -102,15 +102,15 @@ void LVL1::RecJetRoI::constructRun1(const std::vector<TriggerThreshold *> *caloT
// easy
//
std::map<int, TriggerThreshold *> thrMap;
std::map<unsigned int, TriggerThreshold *> thrMap;
for (std::vector<TriggerThreshold *>::const_iterator it =
caloThresholds->begin();
it != caloThresholds->end(); ++it)
{
if ((*it)->type() == jetTriggerType)
{
int num = (*it)->thresholdNumber();
thrMap.insert(std::map<int, TriggerThreshold *>::value_type(num, (*it)));
unsigned int num = static_cast<unsigned int>((*it)->thresholdNumber());
thrMap.insert(std::map<unsigned int, TriggerThreshold *>::value_type(num, (*it)));
}
}
......@@ -131,7 +131,7 @@ void LVL1::RecJetRoI::constructRun1(const std::vector<TriggerThreshold *> *caloT
for (vector<unsigned int>::const_iterator itp = passed_thresholds.begin();
itp != passed_thresholds.end(); ++itp)
{
std::map<int, TriggerThreshold *>::const_iterator thr =
std::map<unsigned int, TriggerThreshold *>::const_iterator thr =
thrMap.find(*itp - 1);
if (thr != thrMap.end())
{
......@@ -140,10 +140,10 @@ void LVL1::RecJetRoI::constructRun1(const std::vector<TriggerThreshold *> *caloT
JetThresholdValue *jtv = dynamic_cast<JetThresholdValue *>(ttv);
if (jtv)
{
m_triggerThresholdValue.insert(std::map<int, unsigned int>::value_type(
m_triggerThresholdValue.insert(std::map<unsigned int, unsigned int>::value_type(
*itp, jtv->thresholdValueCount()));
m_windowSize.insert(
std::map<int, unsigned int>::value_type(*itp, jtv->window()));
std::map<unsigned int, unsigned int>::value_type(*itp, jtv->window()));
}
} // end "found threshold in map"
} // end loop through passed thresholds
......@@ -185,11 +185,11 @@ LVL1::RecJetRoI::constructRun2(const std::vector<TriggerThreshold *> *caloThresh
unsigned int roiET =
(window == JetWindowSize::LARGE ? etLarge() : etSmall());
if (roiET > threshold) {
int num = (*it)->thresholdNumber();
unsigned int num = static_cast<unsigned int>((*it)->thresholdNumber());
m_triggerThresholdValue.insert(
std::map<int, unsigned int>::value_type(num, etCut));
std::map<unsigned int, unsigned int>::value_type(num, etCut));
m_windowSize.insert(
std::map<int, unsigned int>::value_type(num, window));
std::map<unsigned int, unsigned int>::value_type(num, window));
m_thresholdMask |= (1 << num);
} // passes cuts
} // JetThresholdValue pointer valid
......@@ -227,7 +227,7 @@ LVL1::RecJetRoI::constructRun3(const TrigConf::L1Menu * const l1menu)
if (eTPassed)
{
int num = thr->mapping();
const unsigned int num = thr->mapping();
m_triggerThresholdValue[num] = etCut;
m_windowSize[num] = window;
m_thresholdMask |= (1 << num);
......@@ -284,7 +284,7 @@ LVL1::RecJetRoI::etLarge() const {
return m_decoder->etLarge(m_roiWord);
} else {
float highest = 0;
std::map<int, unsigned int>::const_iterator it =
std::map<unsigned int, unsigned int>::const_iterator it =
m_triggerThresholdValue.begin();
for (; it != m_triggerThresholdValue.end(); ++it)
if (it->second > highest)
......@@ -301,7 +301,7 @@ LVL1::RecJetRoI::etSmall() const {
return m_decoder->etSmall(m_roiWord);
} else {
float highest = 0;
std::map<int, unsigned int>::const_iterator it =
std::map<unsigned int, unsigned int>::const_iterator it =
m_triggerThresholdValue.begin();
for (; it != m_triggerThresholdValue.end(); ++it)
if (it->second > highest)
......@@ -317,11 +317,11 @@ LVL1::RecJetRoI::thresholdPattern() const { return m_thresholdMask; }
/** returns TRUE if threshold number <em>threshold_number</em> has been pass
ed by this ROI. */
bool
LVL1::RecJetRoI::passedThreshold(int thresholdNumber) const {
LVL1::RecJetRoI::passedThreshold(unsigned int thresholdNumber) const {
bool value = false;
std::map<int, unsigned int>::const_iterator it =
std::map<unsigned int, unsigned int>::const_iterator it =
m_triggerThresholdValue.find(thresholdNumber);
if (it != m_triggerThresholdValue.end())
value = true;
......@@ -333,7 +333,7 @@ LVL1::RecJetRoI::passedThreshold(int thresholdNumber) const {
ed by this ROI.
Returns FALSE if used in Run 2, where forward jet is not defined */
bool
LVL1::RecJetRoI::passedFwdThreshold(int thresholdNumber) const {
LVL1::RecJetRoI::passedFwdThreshold(unsigned int thresholdNumber) const {
if ((m_version < 2) && this->isValidThreshold(thresholdNumber)) {
return (((1 << (thresholdNumber + 7)) & m_roiWord) > 0);
......@@ -362,7 +362,7 @@ LVL1::RecJetRoI::thresholdsPassed() const {
}
for (unsigned int iTh = 0; iTh <= nThresh; ++iTh) {
std::map<int, unsigned int>::const_iterator it =
std::map<unsigned int, unsigned int>::const_iterator it =
m_triggerThresholdValue.find(iTh);
if (it != m_triggerThresholdValue.end())
newVec.push_back(iTh);
......@@ -377,7 +377,7 @@ LVL1::RecJetRoI::thresholdsPassed() const {
**/
unsigned int
LVL1::RecJetRoI::triggerThreshold(const unsigned int thresh) const {
map<int, unsigned int>::const_iterator it =
map<unsigned int, unsigned int>::const_iterator it =
m_triggerThresholdValue.find(thresh);
if (it != m_triggerThresholdValue.end()) {
return it->second;
......@@ -388,7 +388,7 @@ LVL1::RecJetRoI::triggerThreshold(const unsigned int thresh) const {
/** returns the value of the jet cluster for the threshold passed.*/
unsigned int
LVL1::RecJetRoI::windowSize(const unsigned int thresh) const {
map<int, unsigned int>::const_iterator it = m_windowSize.find(thresh);
map<unsigned int, unsigned int>::const_iterator it = m_windowSize.find(thresh);
if (it != m_windowSize.end()) {
return it->second;
}
......
......@@ -601,7 +601,7 @@ StatusCode L1CaloL1TopoMon::fillHistograms()
// set version 15, BCN -7, which is unlikely:
L1Topo::Header header(0xf, 0, 0, 0, 0, 1, 0x7);
int i_fpga=-1;
for (auto word : cDataWords){
for (const uint32_t word : cDataWords){
switch (L1Topo::blockType(word)){
case L1Topo::BlockTypes::HEADER:
{
......@@ -765,7 +765,7 @@ StatusCode L1CaloL1TopoMon::fillHistograms()
m_h_l1topo_1d_Errors->Fill(NO_ROI);
topo_error|=(1<<NO_ROI);
}
for (auto word : cDataWords) {
for (const uint32_t word : cDataWords) {
switch (L1Topo::blockType(word)) {
case L1Topo::BlockTypes::L1TOPO_TOB:
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment