@@ -66,14 +66,14 @@ void Mapper::init(const std::string_view filename)
6666
6767 auto chantype = o2::emcal::intToChannelType (caloflag);
6868
69- mMapping .insert (std::pair<int , ChannelID>(address, {uint8_t (row), uint8_t (col), chantype}));
70- mInverseMapping .insert (std::pair<ChannelID, int >({uint8_t (row), uint8_t (col), chantype}, address));
69+ mMapping .insert (std::pair<int , ChannelID>(static_cast < unsigned int >( address) , {uint8_t (row), uint8_t (col), chantype}));
70+ mInverseMapping .insert (std::pair<ChannelID, int >({uint8_t (row), uint8_t (col), chantype}, static_cast < unsigned int >( address) ));
7171 }
7272
7373 mInitStatus = true ;
7474}
7575
76- Mapper::ChannelID Mapper::getChannelID (int hardawareaddress) const
76+ Mapper::ChannelID Mapper::getChannelID (unsigned int hardawareaddress) const
7777{
7878 if (!mInitStatus ) {
7979 throw InitStatusException ();
@@ -85,12 +85,12 @@ Mapper::ChannelID Mapper::getChannelID(int hardawareaddress) const
8585 return res->second ;
8686}
8787
88- int Mapper::getHardwareAddress (int row, int col, ChannelType_t channeltype) const
88+ unsigned int Mapper::getHardwareAddress (uint8_t row, uint8_t col, ChannelType_t channeltype) const
8989{
9090 if (!mInitStatus ) {
9191 throw InitStatusException ();
9292 }
93- ChannelID channelToFind{uint8_t ( row), uint8_t ( col) , channeltype};
93+ ChannelID channelToFind{row, col, channeltype};
9494 auto found = mInverseMapping .find (channelToFind);
9595 if (found == mInverseMapping .end ()) {
9696 throw ChannelNotFoundException (channelToFind);
@@ -101,9 +101,9 @@ int Mapper::getHardwareAddress(int row, int col, ChannelType_t channeltype) cons
101101MappingHandler::MappingHandler ()
102102{
103103 const std::array<char , 2 > SIDES = {{' A' , ' C' }};
104- const int NDDL = 2 ;
105- for (int iside = 0 ; iside < 2 ; iside++) {
106- for (int iddl = 0 ; iddl < NDDL; iddl++) {
104+ const unsigned int NDDL = 2 ;
105+ for (unsigned int iside = 0 ; iside < 2 ; iside++) {
106+ for (unsigned int iddl = 0 ; iddl < NDDL; iddl++) {
107107 mMappings [iside * NDDL + iddl].setMapping (Form (" %s/share/Detectors/EMC/files/RCU%d%c.data" , gSystem ->Getenv (" O2_ROOT" ), iddl, SIDES[iside]));
108108 }
109109 }
@@ -114,10 +114,15 @@ Mapper& MappingHandler::getMappingForDDL(unsigned int ddl)
114114 if (ddl >= 40 ) {
115115 throw MappingHandler::DDLInvalid (ddl);
116116 }
117- const int NDDLSM = 2 , NSIDES = 2 ;
118- int ddlInSM = ddl % NDDLSM,
119- sideID = (ddl / NDDLSM) % NSIDES;
120- return mMappings [sideID * NDDLSM + ddlInSM];
117+ const unsigned int NDDLSM = 2 , NSIDES = 2 ;
118+ unsigned int ddlInSM = ddl % NDDLSM,
119+ sideID = (ddl / NDDLSM) % NSIDES;
120+ unsigned int mappingIndex = sideID * NDDLSM + ddlInSM;
121+ if (mappingIndex < 0 || mappingIndex >= mMappings .size ()) {
122+ std::cout << " Access to invalid mapping position for ddl " << ddl << std::endl;
123+ throw MappingHandler::DDLInvalid (ddl);
124+ }
125+ return mMappings [mappingIndex];
121126}
122127
123128int MappingHandler::getFEEForChannelInDDL (unsigned int ddl, unsigned int channelFEC, unsigned int branch)
0 commit comments