Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-23 15:57:28

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author Paolo Ronchese INFN Padova
0005  *
0006  */
0007 
0008 //----------------------
0009 // This Class' Header --
0010 //----------------------
0011 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
0012 
0013 //-------------------------------
0014 // Collaborating Class Headers --
0015 //-------------------------------
0016 #include "CondFormats/DTObjects/interface/DTBufferTree.h"
0017 #include "CondFormats/DTObjects/interface/DTReadOutMappingCache.h"
0018 
0019 //---------------
0020 // C++ Headers --
0021 //---------------
0022 #include <iostream>
0023 #include <sstream>
0024 #include <map>
0025 
0026 //-------------------
0027 // Initializations --
0028 //-------------------
0029 
0030 //----------------
0031 // Constructors --
0032 //----------------
0033 DTReadOutMapping::DTReadOutMapping()
0034     : cellMapVersion(" "), robMapVersion(" "), rgBuf(new DTBufferTree<int, int>), grBuf(new DTBufferTree<int, int>) {
0035   readOutChannelDriftTubeMap.reserve(2000);
0036 }
0037 
0038 DTReadOutMapping::DTReadOutMapping(const std::string& cell_map_version, const std::string& rob_map_version)
0039     : cellMapVersion(cell_map_version),
0040       robMapVersion(rob_map_version),
0041       rgBuf(new DTBufferTree<int, int>),
0042       grBuf(new DTBufferTree<int, int>) {
0043   readOutChannelDriftTubeMap.reserve(2000);
0044 }
0045 
0046 DTReadOutGeometryLink::DTReadOutGeometryLink()
0047     : dduId(0),
0048       rosId(0),
0049       robId(0),
0050       tdcId(0),
0051       channelId(0),
0052       wheelId(0),
0053       stationId(0),
0054       sectorId(0),
0055       slId(0),
0056       layerId(0),
0057       cellId(0) {}
0058 
0059 //--------------
0060 // Destructor --
0061 //--------------
0062 DTReadOutMapping::~DTReadOutMapping() {}
0063 
0064 DTReadOutGeometryLink::~DTReadOutGeometryLink() {}
0065 
0066 //--------------
0067 // Operations --
0068 //--------------
0069 int DTReadOutMapping::readOutToGeometry(
0070     int dduId, int rosId, int robId, int tdcId, int channelId, DTWireId& wireId) const {
0071   int wheelId;
0072   int stationId;
0073   int sectorId;
0074   int slId;
0075   int layerId;
0076   int cellId;
0077 
0078   int status =
0079       readOutToGeometry(dduId, rosId, robId, tdcId, channelId, wheelId, stationId, sectorId, slId, layerId, cellId);
0080 
0081   wireId = DTWireId(wheelId, stationId, sectorId, slId, layerId, cellId);
0082   return status;
0083 }
0084 
0085 int DTReadOutMapping::readOutToGeometry(int dduId,
0086                                         int rosId,
0087                                         int robId,
0088                                         int tdcId,
0089                                         int channelId,
0090                                         int& wheelId,
0091                                         int& stationId,
0092                                         int& sectorId,
0093                                         int& slId,
0094                                         int& layerId,
0095                                         int& cellId) const {
0096   wheelId = stationId = sectorId = slId = layerId = cellId = 0;
0097 
0098   if (!atomicCache().isSet()) {
0099     cacheMap();
0100   }
0101 
0102   int defaultValue;
0103   atomicCache()->mType.find(0, defaultValue);
0104   if (defaultValue) {
0105     int searchStatus;
0106     int ientry;
0107 
0108     std::vector<int> dduKey;
0109     dduKey.reserve(5);
0110     dduKey.push_back(dduId);
0111     dduKey.push_back(rosId);
0112     searchStatus = atomicCache()->rgDDU.find(dduKey.begin(), dduKey.end(), ientry);
0113     if (searchStatus)
0114       return searchStatus;
0115     const DTReadOutGeometryLink& lros(readOutChannelDriftTubeMap[ientry]);
0116     wheelId = lros.wheelId;
0117     sectorId = lros.sectorId;
0118 
0119     std::vector<int> rosKey;
0120     rosKey.reserve(5);
0121     rosKey.push_back(lros.cellId);
0122     rosKey.push_back(robId);
0123     searchStatus = atomicCache()->rgROS.find(rosKey.begin(), rosKey.end(), ientry);
0124     if (searchStatus)
0125       return searchStatus;
0126     const DTReadOutGeometryLink& lrob(readOutChannelDriftTubeMap[ientry]);
0127     if (lrob.wheelId != defaultValue)
0128       wheelId = lrob.wheelId;
0129     stationId = lrob.stationId;
0130     if (lrob.sectorId != defaultValue)
0131       sectorId = lrob.sectorId;
0132 
0133     std::vector<int> robKey;
0134     robKey.reserve(5);
0135     robKey.push_back(lrob.cellId);
0136     robKey.push_back(tdcId);
0137     robKey.push_back(channelId);
0138     searchStatus = atomicCache()->rgROB.find(robKey.begin(), robKey.end(), ientry);
0139     if (searchStatus)
0140       return searchStatus;
0141     const DTReadOutGeometryLink& ltdc(readOutChannelDriftTubeMap[ientry]);
0142     slId = ltdc.slId;
0143     layerId = ltdc.layerId;
0144     cellId = ltdc.cellId;
0145     return 0;
0146   }
0147 
0148   std::vector<int> chanKey;
0149   chanKey.reserve(5);
0150   chanKey.push_back(dduId);
0151   chanKey.push_back(rosId);
0152   chanKey.push_back(robId);
0153   chanKey.push_back(tdcId);
0154   chanKey.push_back(channelId);
0155   int ientry;
0156   int searchStatus = atomicCache()->rgBuf.find(chanKey.begin(), chanKey.end(), ientry);
0157   if (!searchStatus) {
0158     const DTReadOutGeometryLink& link(readOutChannelDriftTubeMap[ientry]);
0159     wheelId = link.wheelId;
0160     stationId = link.stationId;
0161     sectorId = link.sectorId;
0162     slId = link.slId;
0163     layerId = link.layerId;
0164     cellId = link.cellId;
0165   }
0166 
0167   return searchStatus;
0168 }
0169 
0170 int DTReadOutMapping::geometryToReadOut(
0171     const DTWireId& wireId, int& dduId, int& rosId, int& robId, int& tdcId, int& channelId) const {
0172   return geometryToReadOut(wireId.wheel(),
0173                            wireId.station(),
0174                            wireId.sector(),
0175                            wireId.superLayer(),
0176                            wireId.layer(),
0177                            wireId.wire(),
0178                            dduId,
0179                            rosId,
0180                            robId,
0181                            tdcId,
0182                            channelId);
0183 }
0184 
0185 int DTReadOutMapping::geometryToReadOut(int wheelId,
0186                                         int stationId,
0187                                         int sectorId,
0188                                         int slId,
0189                                         int layerId,
0190                                         int cellId,
0191                                         int& dduId,
0192                                         int& rosId,
0193                                         int& robId,
0194                                         int& tdcId,
0195                                         int& channelId) const {
0196   dduId = rosId = robId = tdcId = channelId = 0;
0197 
0198   if (!atomicCache().isSet()) {
0199     cacheMap();
0200   }
0201 
0202   int defaultValue;
0203   atomicCache()->mType.find(0, defaultValue);
0204   if (defaultValue) {
0205     int searchStatus;
0206     int mapId = 0;
0207     std::vector<int> const* robMLgr;
0208     std::vector<int> const* rosMLgr;
0209     std::vector<int> const* dduMLgr;
0210 
0211     std::vector<int> cellKey;
0212     cellKey.reserve(6);
0213     cellKey.push_back(cellId);
0214     cellKey.push_back(layerId);
0215     cellKey.push_back(slId);
0216     std::vector<int> stdcKey = cellKey;
0217     searchStatus = atomicCache()->grROB.find(cellKey.begin(), cellKey.end(), robMLgr);
0218     if (searchStatus)
0219       return searchStatus;
0220     if (robMLgr->empty())
0221       return 1;
0222     std::vector<int>::const_iterator tdc_iter = robMLgr->begin();
0223     std::vector<int>::const_iterator tdc_iend = robMLgr->end();
0224     while (tdc_iter != tdc_iend) {
0225       const DTReadOutGeometryLink& ltdc(readOutChannelDriftTubeMap[*tdc_iter++]);
0226       channelId = ltdc.channelId;
0227       tdcId = ltdc.tdcId;
0228       mapId = ltdc.rosId;
0229       cellKey.clear();
0230       cellKey.push_back(mapId);
0231       cellKey.push_back(stationId);
0232       std::vector<int> srosKey = cellKey;
0233       searchStatus = atomicCache()->grROS.find(cellKey.begin(), cellKey.end(), rosMLgr);
0234       if (searchStatus)
0235         continue;
0236       if (rosMLgr->empty())
0237         continue;
0238       std::vector<int>::const_iterator ros_iter = rosMLgr->begin();
0239       std::vector<int>::const_iterator ros_iend = rosMLgr->end();
0240       while (ros_iter != ros_iend) {
0241         const DTReadOutGeometryLink& lros(readOutChannelDriftTubeMap[*ros_iter++]);
0242         int secCk = lros.sectorId;
0243         int wheCk = lros.wheelId;
0244         if ((secCk != defaultValue) && (secCk != sectorId))
0245           continue;
0246         if ((wheCk != defaultValue) && (wheCk != wheelId))
0247           continue;
0248         robId = lros.robId;
0249         mapId = lros.rosId;
0250         cellKey.clear();
0251         cellKey.push_back(mapId);
0252         cellKey.push_back(wheelId);
0253         cellKey.push_back(sectorId);
0254         std::vector<int> sdduKey = cellKey;
0255         searchStatus = atomicCache()->grDDU.find(cellKey.begin(), cellKey.end(), dduMLgr);
0256         if (searchStatus)
0257           continue;
0258         if (dduMLgr->empty())
0259           continue;
0260         if (searchStatus)
0261           return searchStatus;
0262         if (dduMLgr->empty())
0263           return 1;
0264         std::vector<int>::const_iterator ddu_iter = dduMLgr->begin();
0265         std::vector<int>::const_iterator ddu_iend = dduMLgr->end();
0266         while (ddu_iter != ddu_iend) {
0267           const DTReadOutGeometryLink& lddu(readOutChannelDriftTubeMap[*ddu_iter++]);
0268           if (((sectorId == secCk) || (sectorId == lddu.sectorId)) &&
0269               ((wheelId == wheCk) || (wheelId == lddu.wheelId))) {
0270             rosId = lddu.rosId;
0271             dduId = lddu.dduId;
0272             return 0;
0273           }
0274         }
0275       }
0276     }
0277 
0278     return 1;
0279   }
0280 
0281   std::vector<int> cellKey;
0282   cellKey.reserve(6);
0283   cellKey.push_back(wheelId);
0284   cellKey.push_back(stationId);
0285   cellKey.push_back(sectorId);
0286   cellKey.push_back(slId);
0287   cellKey.push_back(layerId);
0288   cellKey.push_back(cellId);
0289   int ientry;
0290   int searchStatus = atomicCache()->grBuf.find(cellKey.begin(), cellKey.end(), ientry);
0291   if (!searchStatus) {
0292     const DTReadOutGeometryLink& link(readOutChannelDriftTubeMap[ientry]);
0293     dduId = link.dduId;
0294     rosId = link.rosId;
0295     robId = link.robId;
0296     tdcId = link.tdcId;
0297     channelId = link.channelId;
0298   }
0299 
0300   return searchStatus;
0301 }
0302 
0303 DTReadOutMapping::type DTReadOutMapping::mapType() const {
0304   if (!atomicCache().isSet()) {
0305     cacheMap();
0306   }
0307 
0308   int defaultValue;
0309   atomicCache()->mType.find(0, defaultValue);
0310   if (defaultValue)
0311     return compact;
0312   else
0313     return plain;
0314 }
0315 
0316 const std::string& DTReadOutMapping::mapCellTdc() const { return cellMapVersion; }
0317 
0318 std::string& DTReadOutMapping::mapCellTdc() { return cellMapVersion; }
0319 
0320 const std::string& DTReadOutMapping::mapRobRos() const { return robMapVersion; }
0321 
0322 std::string& DTReadOutMapping::mapRobRos() { return robMapVersion; }
0323 
0324 void DTReadOutMapping::clear() {
0325   atomicCache().reset();
0326   rgBuf->clear();
0327   grBuf->clear();
0328   readOutChannelDriftTubeMap.clear();
0329   return;
0330 }
0331 
0332 int DTReadOutMapping::insertReadOutGeometryLink(int dduId,
0333                                                 int rosId,
0334                                                 int robId,
0335                                                 int tdcId,
0336                                                 int channelId,
0337                                                 int wheelId,
0338                                                 int stationId,
0339                                                 int sectorId,
0340                                                 int slId,
0341                                                 int layerId,
0342                                                 int cellId) {
0343   DTReadOutGeometryLink link;
0344   link.dduId = dduId;
0345   link.rosId = rosId;
0346   link.robId = robId;
0347   link.tdcId = tdcId;
0348   link.channelId = channelId;
0349   link.wheelId = wheelId;
0350   link.stationId = stationId;
0351   link.sectorId = sectorId;
0352   link.slId = slId;
0353   link.layerId = layerId;
0354   link.cellId = cellId;
0355 
0356   int ientry = readOutChannelDriftTubeMap.size();
0357   readOutChannelDriftTubeMap.push_back(link);
0358 
0359   DTBufferTree<int, int>* pgrBuf;
0360   DTBufferTree<int, int>* prgBuf;
0361 
0362   if (atomicCache().isSet()) {
0363     pgrBuf = &atomicCache()->grBuf;
0364     prgBuf = &atomicCache()->rgBuf;
0365   } else {
0366     pgrBuf = grBuf.get();
0367     prgBuf = rgBuf.get();
0368   }
0369 
0370   std::vector<int> cellKey;
0371   cellKey.reserve(6);
0372   cellKey.push_back(wheelId);
0373   cellKey.push_back(stationId);
0374   cellKey.push_back(sectorId);
0375   cellKey.push_back(slId);
0376   cellKey.push_back(layerId);
0377   cellKey.push_back(cellId);
0378   int grStatus = pgrBuf->insert(cellKey.begin(), cellKey.end(), ientry);
0379 
0380   std::vector<int> chanKey;
0381   chanKey.reserve(5);
0382   chanKey.push_back(dduId);
0383   chanKey.push_back(rosId);
0384   chanKey.push_back(robId);
0385   chanKey.push_back(tdcId);
0386   chanKey.push_back(channelId);
0387   int rgStatus = prgBuf->insert(chanKey.begin(), chanKey.end(), ientry);
0388 
0389   if (grStatus || rgStatus)
0390     return 1;
0391   else
0392     return 0;
0393 }
0394 
0395 DTReadOutMapping::const_iterator DTReadOutMapping::begin() const { return readOutChannelDriftTubeMap.begin(); }
0396 
0397 DTReadOutMapping::const_iterator DTReadOutMapping::end() const { return readOutChannelDriftTubeMap.end(); }
0398 
0399 const DTReadOutMapping* DTReadOutMapping::fullMap() const {
0400   if (mapType() == plain)
0401     return this;
0402   return expandMap(*this);
0403 }
0404 
0405 // The code for this function was copied verbatim from
0406 // CondCore/DTPlugins/src/DTCompactMapPluginHandler.c
0407 DTReadOutMapping* DTReadOutMapping::expandMap(const DTReadOutMapping& compMap) {
0408   std::vector<DTReadOutGeometryLink> entryList;
0409   DTReadOutMapping::const_iterator compIter = compMap.begin();
0410   DTReadOutMapping::const_iterator compIend = compMap.end();
0411   while (compIter != compIend)
0412     entryList.push_back(*compIter++);
0413 
0414   std::string rosMap = "expand_";
0415   rosMap += compMap.mapRobRos();
0416   std::string tdcMap = "expand_";
0417   tdcMap += compMap.mapCellTdc();
0418   DTReadOutMapping* fullMap = new DTReadOutMapping(tdcMap, rosMap);
0419   int ddu;
0420   int ros;
0421   int rch;
0422   int tdc;
0423   int tch;
0424   int whe;
0425   int sta;
0426   int sec;
0427   int rob;
0428   int qua;
0429   int lay;
0430   int cel;
0431   int mt1;
0432   int mi1;
0433   int mt2;
0434   int mi2;
0435   int def;
0436   int wha;
0437   int sea;
0438   std::vector<DTReadOutGeometryLink>::const_iterator iter = entryList.begin();
0439   std::vector<DTReadOutGeometryLink>::const_iterator iend = entryList.end();
0440   std::vector<DTReadOutGeometryLink>::const_iterator iros = entryList.end();
0441   std::vector<DTReadOutGeometryLink>::const_iterator irob = entryList.end();
0442   while (iter != iend) {
0443     const DTReadOutGeometryLink& rosEntry(*iter++);
0444     if (rosEntry.dduId > 0x3fffffff)
0445       continue;
0446     ddu = rosEntry.dduId;
0447     ros = rosEntry.rosId;
0448     whe = rosEntry.wheelId;
0449     def = rosEntry.stationId;
0450     sec = rosEntry.sectorId;
0451     mt1 = rosEntry.layerId;
0452     mi1 = rosEntry.cellId;
0453     iros = entryList.begin();
0454     while (iros != iend) {
0455       wha = whe;
0456       sea = sec;
0457       const DTReadOutGeometryLink& rchEntry(*iros++);
0458       if ((rchEntry.dduId != mt1) || (rchEntry.rosId != mi1))
0459         continue;
0460       rch = rchEntry.robId;
0461       if (rchEntry.wheelId != def)
0462         wha = rchEntry.wheelId;
0463       sta = rchEntry.stationId;
0464       if (rchEntry.sectorId != def)
0465         sea = rchEntry.sectorId;
0466       rob = rchEntry.slId;
0467       mt2 = rchEntry.layerId;
0468       mi2 = rchEntry.cellId;
0469       irob = entryList.begin();
0470       while (irob != iend) {
0471         const DTReadOutGeometryLink& robEntry(*irob++);
0472         if ((robEntry.dduId != mt2) || (robEntry.rosId != mi2))
0473           continue;
0474         if (robEntry.robId != rob) {
0475           std::cout << "ROB mismatch " << rob << " " << robEntry.robId << std::endl;
0476         }
0477         tdc = robEntry.tdcId;
0478         tch = robEntry.channelId;
0479         qua = robEntry.slId;
0480         lay = robEntry.layerId;
0481         cel = robEntry.cellId;
0482         fullMap->insertReadOutGeometryLink(ddu, ros, rch, tdc, tch, wha, sta, sea, qua, lay, cel);
0483       }
0484     }
0485   }
0486   return fullMap;
0487 }
0488 
0489 std::string DTReadOutMapping::mapNameGR() const {
0490   std::stringstream name;
0491   name << cellMapVersion << "_" << robMapVersion << "_map_GR" << this;
0492   return name.str();
0493 }
0494 
0495 std::string DTReadOutMapping::mapNameRG() const {
0496   std::stringstream name;
0497   name << cellMapVersion << "_" << robMapVersion << "_map_RG" << this;
0498   return name.str();
0499 }
0500 
0501 void DTReadOutMapping::cacheMap() const {
0502   std::unique_ptr<DTReadOutMappingCache> localCache(new DTReadOutMappingCache);
0503 
0504   localCache->mType.insert(0, 0);
0505 
0506   int entryNum = 0;
0507   int entryMax = readOutChannelDriftTubeMap.size();
0508   std::vector<int> cellKey;
0509   cellKey.reserve(6);
0510   std::vector<int> chanKey;
0511   chanKey.reserve(5);
0512   int defaultValue = 0;
0513   int key;
0514   int val;
0515   int rosMapKey = 0;
0516   int robMapKey = 0;
0517   std::map<int, std::vector<int>*> dduEntries;
0518   for (entryNum = 0; entryNum < entryMax; entryNum++) {
0519     const DTReadOutGeometryLink& link(readOutChannelDriftTubeMap[entryNum]);
0520 
0521     key = link.dduId;
0522     val = link.stationId;
0523     if (key > 0x3fffffff) {
0524       if (link.tdcId > 0x3fffffff) {
0525         localCache->mType.insert(0, defaultValue = link.tdcId);
0526         rosMapKey = key;
0527       } else {
0528         localCache->mType.insert(0, defaultValue = link.wheelId);
0529         robMapKey = key;
0530       }
0531     }
0532 
0533     if (defaultValue == 0) {
0534       chanKey.clear();
0535       chanKey.push_back(link.dduId);
0536       chanKey.push_back(link.rosId);
0537       chanKey.push_back(link.robId);
0538       chanKey.push_back(link.tdcId);
0539       chanKey.push_back(link.channelId);
0540 
0541       localCache->rgBuf.insert(chanKey.begin(), chanKey.end(), entryNum);
0542 
0543       cellKey.clear();
0544       cellKey.push_back(link.wheelId);
0545       cellKey.push_back(link.stationId);
0546       cellKey.push_back(link.sectorId);
0547       cellKey.push_back(link.slId);
0548       cellKey.push_back(link.layerId);
0549       cellKey.push_back(link.cellId);
0550 
0551       localCache->grBuf.insert(cellKey.begin(), cellKey.end(), entryNum);
0552     }
0553 
0554     if (key == robMapKey) {
0555       chanKey.clear();
0556       chanKey.push_back(link.rosId);
0557       chanKey.push_back(link.tdcId);
0558       chanKey.push_back(link.channelId);
0559       localCache->rgROB.insert(chanKey.begin(), chanKey.end(), entryNum);
0560 
0561       cellKey.clear();
0562       cellKey.push_back(link.cellId);
0563       cellKey.push_back(link.layerId);
0564       cellKey.push_back(link.slId);
0565       std::vector<int>* robMLgr;
0566       localCache->grROB.find(cellKey.begin(), cellKey.end(), robMLgr);
0567       if (robMLgr == nullptr) {
0568         std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
0569         robMLgr = newVector.get();
0570         localCache->grROB.insert(cellKey.begin(), cellKey.end(), std::move(newVector));
0571       }
0572       robMLgr->push_back(entryNum);
0573     }
0574 
0575     if (key == rosMapKey) {
0576       chanKey.clear();
0577       chanKey.push_back(link.rosId);
0578       chanKey.push_back(link.robId);
0579       localCache->rgROS.insert(chanKey.begin(), chanKey.end(), entryNum);
0580 
0581       cellKey.clear();
0582       cellKey.push_back(link.cellId);
0583       cellKey.push_back(link.stationId);
0584       std::vector<int>* rosMLgr;
0585       localCache->grROS.find(cellKey.begin(), cellKey.end(), rosMLgr);
0586       if (rosMLgr == nullptr) {
0587         std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
0588         rosMLgr = newVector.get();
0589         localCache->grROS.insert(cellKey.begin(), cellKey.end(), std::move(newVector));
0590       }
0591       rosMLgr->push_back(entryNum);
0592     }
0593 
0594     if ((key < 0x3fffffff) && (val > 0x3fffffff)) {
0595       chanKey.clear();
0596       chanKey.push_back(link.dduId);
0597       chanKey.push_back(link.rosId);
0598       localCache->rgDDU.insert(chanKey.begin(), chanKey.end(), entryNum);
0599 
0600       int mapId = link.cellId;
0601       std::vector<int>* dduMLgr;
0602       std::map<int, std::vector<int>*>::const_iterator dduEntIter = dduEntries.find(mapId);
0603       if (dduEntIter == dduEntries.end())
0604         dduEntries.insert(std::pair<int, std::vector<int>*>(mapId, dduMLgr = new std::vector<int>));
0605       else
0606         dduMLgr = dduEntIter->second;
0607       dduMLgr->push_back(entryNum);
0608     }
0609   }
0610 
0611   if (defaultValue != 0) {
0612     for (entryNum = 0; entryNum < entryMax; entryNum++) {
0613       const DTReadOutGeometryLink& link(readOutChannelDriftTubeMap[entryNum]);
0614       key = link.dduId;
0615       if (key != rosMapKey)
0616         continue;
0617       int mapId = link.rosId;
0618       int whchkId = link.wheelId;
0619       int secchkId = link.sectorId;
0620 
0621       std::vector<int>* dduMLgr;
0622       std::map<int, std::vector<int>*>::const_iterator dduEntIter = dduEntries.find(mapId);
0623       if (dduEntIter != dduEntries.end())
0624         dduMLgr = dduEntIter->second;
0625       else
0626         continue;
0627       std::vector<int>::const_iterator dduIter = dduMLgr->begin();
0628       std::vector<int>::const_iterator dduIend = dduMLgr->end();
0629       while (dduIter != dduIend) {
0630         int ientry = *dduIter++;
0631         const DTReadOutGeometryLink& lros(readOutChannelDriftTubeMap[ientry]);
0632         int wheelId = whchkId;
0633         int sectorId = secchkId;
0634         if (wheelId == defaultValue)
0635           wheelId = lros.wheelId;
0636         if (sectorId == defaultValue)
0637           sectorId = lros.sectorId;
0638         cellKey.clear();
0639         cellKey.push_back(mapId);
0640         cellKey.push_back(wheelId);
0641         cellKey.push_back(sectorId);
0642         std::vector<int>* dduMLgr = nullptr;
0643         localCache->grDDU.find(cellKey.begin(), cellKey.end(), dduMLgr);
0644         if (dduMLgr == nullptr) {
0645           std::unique_ptr<std::vector<int> > newVector(new std::vector<int>);
0646           dduMLgr = newVector.get();
0647           localCache->grDDU.insert(cellKey.begin(), cellKey.end(), std::move(newVector));
0648         }
0649         dduMLgr->push_back(ientry);
0650       }
0651     }
0652 
0653     std::map<int, std::vector<int>*>::const_iterator dduEntIter = dduEntries.begin();
0654     std::map<int, std::vector<int>*>::const_iterator dduEntIend = dduEntries.end();
0655     while (dduEntIter != dduEntIend) {
0656       const std::pair<int, std::vector<int>*>& dduEntry = *dduEntIter++;
0657       delete dduEntry.second;
0658     }
0659 
0660     localCache->rgBuf.clear();
0661     localCache->grBuf.clear();
0662   }
0663 
0664   atomicCache().set(std::move(localCache));
0665 
0666   return;
0667 }