Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:45:21

0001 #include <cassert>
0002 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0003 #include <EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h>
0004 #include <Geometry/EcalMapping/interface/EcalElectronicsMapping.h>
0005 #include <DataFormats/EcalDigi/interface/EBSrFlag.h>
0006 #include <DataFormats/EcalDigi/interface/EESrFlag.h>
0007 #include <EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h>
0008 
0009 EcalElectronicsMapper::EcalElectronicsMapper(unsigned int numbXtalTSamples, unsigned int numbTriggerTSamples)
0010     : pathToMapFile_(""),
0011       numbXtalTSamples_(numbXtalTSamples),
0012       numbTriggerTSamples_(numbTriggerTSamples),
0013       mappingBuilder_(nullptr) {
0014   resetPointers();
0015   setupGhostMap();
0016 }
0017 
0018 void EcalElectronicsMapper::resetPointers() {
0019   // Reset Arrays
0020   for (unsigned int sm = 0; sm < NUMB_SM; sm++) {
0021     for (unsigned int fe = 0; fe < NUMB_FE; fe++) {
0022       for (unsigned int strip = 0; strip < NUMB_STRIP; strip++) {
0023         for (unsigned int xtal = 0; xtal < NUMB_XTAL; xtal++) {
0024           //Reset DFrames and xtalDetIds
0025           xtalDetIds_[sm][fe][strip][xtal] = nullptr;
0026         }
0027       }
0028 
0029       //Reset SC Det Ids
0030       //scDetIds_[sm][fe]=0;
0031       scEleIds_[sm][fe] = nullptr;
0032       //srFlags_[sm][fe]=0;
0033     }
0034   }
0035 
0036   //Reset TT det Ids
0037   for (unsigned int tccid = 0; tccid < NUMB_TCC; tccid++) {
0038     for (unsigned int tpg = 0; tpg < NUMB_FE; tpg++) {
0039       ttDetIds_[tccid][tpg] = nullptr;
0040       ttTPIds_[tccid][tpg] = nullptr;
0041       ttEleIds_[tccid][tpg] = nullptr;
0042     }
0043   }
0044 
0045   // reset trigger electronics Id
0046   for (int tccid = 0; tccid < NUMB_TCC; tccid++) {
0047     for (int ttid = 0; ttid < TCC_EB_NUMBTTS; ttid++) {
0048       for (int ps = 0; ps < NUMB_STRIP; ps++) {
0049         psInput_[tccid][ttid][ps] = nullptr;
0050       }
0051     }
0052   }
0053 
0054   // initialize TCC maps
0055   for (int tccId = 0; tccId < EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
0056     for (int psCounter = 0; psCounter < EcalTrigTowerDetId::kEBTowersPerSM * 5; psCounter++) {
0057       for (int u = 0; u < 2; u++) {
0058         tTandPs_[tccId][psCounter][u] = -1;
0059       }
0060     }
0061   }
0062 
0063   //Fill map sm id to tcc ids
0064   std::vector<unsigned int>* ids;
0065   ids = new std::vector<unsigned int>;
0066   ids->push_back(1);
0067   ids->push_back(18);
0068   ids->push_back(19);
0069   ids->push_back(36);
0070   mapSmIdToTccIds_[1] = ids;
0071 
0072   ids = new std::vector<unsigned int>;
0073   ids->push_back(2);
0074   ids->push_back(3);
0075   ids->push_back(20);
0076   ids->push_back(21);
0077   mapSmIdToTccIds_[2] = ids;
0078 
0079   ids = new std::vector<unsigned int>;
0080   ids->push_back(4);
0081   ids->push_back(5);
0082   ids->push_back(22);
0083   ids->push_back(23);
0084   mapSmIdToTccIds_[3] = ids;
0085 
0086   ids = new std::vector<unsigned int>;
0087   ids->push_back(6);
0088   ids->push_back(7);
0089   ids->push_back(24);
0090   ids->push_back(25);
0091   mapSmIdToTccIds_[4] = ids;
0092 
0093   ids = new std::vector<unsigned int>;
0094   ids->push_back(8);
0095   ids->push_back(9);
0096   ids->push_back(26);
0097   ids->push_back(27);
0098   mapSmIdToTccIds_[5] = ids;
0099 
0100   ids = new std::vector<unsigned int>;
0101   ids->push_back(10);
0102   ids->push_back(11);
0103   ids->push_back(28);
0104   ids->push_back(29);
0105   mapSmIdToTccIds_[6] = ids;
0106 
0107   ids = new std::vector<unsigned int>;
0108   ids->push_back(12);
0109   ids->push_back(13);
0110   ids->push_back(30);
0111   ids->push_back(31);
0112   mapSmIdToTccIds_[7] = ids;
0113 
0114   ids = new std::vector<unsigned int>;
0115   ids->push_back(14);
0116   ids->push_back(15);
0117   ids->push_back(32);
0118   ids->push_back(33);
0119   mapSmIdToTccIds_[8] = ids;
0120 
0121   ids = new std::vector<unsigned int>;
0122   ids->push_back(16);
0123   ids->push_back(17);
0124   ids->push_back(34);
0125   ids->push_back(35);
0126   mapSmIdToTccIds_[9] = ids;
0127 
0128   ids = new std::vector<unsigned int>;
0129   ids->push_back(73);
0130   ids->push_back(90);
0131   ids->push_back(91);
0132   ids->push_back(108);
0133   mapSmIdToTccIds_[46] = ids;
0134 
0135   ids = new std::vector<unsigned int>;
0136   ids->push_back(74);
0137   ids->push_back(75);
0138   ids->push_back(92);
0139   ids->push_back(93);
0140   mapSmIdToTccIds_[47] = ids;
0141 
0142   ids = new std::vector<unsigned int>;
0143   ids->push_back(76);
0144   ids->push_back(77);
0145   ids->push_back(94);
0146   ids->push_back(95);
0147   mapSmIdToTccIds_[48] = ids;
0148 
0149   ids = new std::vector<unsigned int>;
0150   ids->push_back(78);
0151   ids->push_back(79);
0152   ids->push_back(96);
0153   ids->push_back(97);
0154   mapSmIdToTccIds_[49] = ids;
0155 
0156   ids = new std::vector<unsigned int>;
0157   ids->push_back(80);
0158   ids->push_back(81);
0159   ids->push_back(98);
0160   ids->push_back(99);
0161   mapSmIdToTccIds_[50] = ids;
0162 
0163   ids = new std::vector<unsigned int>;
0164   ids->push_back(82);
0165   ids->push_back(83);
0166   ids->push_back(100);
0167   ids->push_back(101);
0168   mapSmIdToTccIds_[51] = ids;
0169 
0170   ids = new std::vector<unsigned int>;
0171   ids->push_back(84);
0172   ids->push_back(85);
0173   ids->push_back(102);
0174   ids->push_back(103);
0175   mapSmIdToTccIds_[52] = ids;
0176 
0177   ids = new std::vector<unsigned int>;
0178   ids->push_back(86);
0179   ids->push_back(87);
0180   ids->push_back(104);
0181   ids->push_back(105);
0182   mapSmIdToTccIds_[53] = ids;
0183 
0184   ids = new std::vector<unsigned int>;
0185   ids->push_back(88);
0186   ids->push_back(89);
0187   ids->push_back(106);
0188   ids->push_back(107);
0189   mapSmIdToTccIds_[54] = ids;
0190 
0191   //Compute data block sizes
0192   unfilteredFEBlockLength_ = computeUnfilteredFEBlockLength();
0193   ebTccBlockLength_ = computeEBTCCBlockLength();
0194   eeTccBlockLength_ = computeEETCCBlockLength();
0195 }
0196 
0197 EcalElectronicsMapper::~EcalElectronicsMapper() { deletePointers(); }
0198 
0199 void EcalElectronicsMapper::deletePointers() {
0200   //DETETE ARRAYS
0201   for (unsigned int sm = 0; sm < NUMB_SM; sm++) {
0202     for (unsigned int fe = 0; fe < NUMB_FE; fe++) {
0203       for (unsigned int strip = 0; strip < NUMB_STRIP; strip++) {
0204         for (unsigned int xtal = 0; xtal < NUMB_XTAL; xtal++)
0205           delete xtalDetIds_[sm][fe][strip][xtal];
0206       }
0207 
0208       // if(scDetIds_[sm][fe]){
0209       //  delete scDetIds_[sm][fe];
0210       //  delete scEleIds_[sm][fe];
0211       for (size_t i = 0; i < srFlags_[sm][fe].size(); ++i)
0212         delete srFlags_[sm][fe][i];
0213       srFlags_[sm][fe].clear();
0214 
0215       delete scEleIds_[sm][fe];
0216     }
0217   }
0218 
0219   // delete trigger electronics Id
0220   for (int tccid = 0; tccid < NUMB_TCC; tccid++) {
0221     for (int ttid = 0; ttid < TCC_EB_NUMBTTS; ttid++) {
0222       for (int ps = 0; ps < NUMB_STRIP; ps++) {
0223         delete psInput_[tccid][ttid][ps];
0224       }
0225     }
0226   }
0227 
0228   for (unsigned int tccid = 0; tccid < NUMB_TCC; tccid++) {
0229     for (unsigned int tpg = 0; tpg < NUMB_FE; tpg++) {
0230       if (ttDetIds_[tccid][tpg]) {
0231         delete ttDetIds_[tccid][tpg];
0232         delete ttTPIds_[tccid][tpg];
0233         delete ttEleIds_[tccid][tpg];
0234       }
0235     }
0236   }
0237 
0238   pathToMapFile_.clear();
0239 
0240   std::map<unsigned int, std::vector<unsigned int>*>::iterator it;
0241   for (it = mapSmIdToTccIds_.begin(); it != mapSmIdToTccIds_.end(); it++) {
0242     delete (*it).second;
0243   }
0244 
0245   mapSmIdToTccIds_.clear();
0246 }
0247 
0248 void EcalElectronicsMapper::setEcalElectronicsMapping(const EcalElectronicsMapping* m) {
0249   mappingBuilder_ = m;
0250   fillMaps();
0251 }
0252 
0253 bool EcalElectronicsMapper::setActiveDCC(unsigned int dccId) {
0254   bool ret(true);
0255 
0256   //Update active dcc and associated smId
0257   dccId_ = dccId;
0258 
0259   smId_ = getSMId(dccId_);
0260 
0261   if (!smId_)
0262     ret = false;
0263 
0264   return ret;
0265 }
0266 
0267 bool EcalElectronicsMapper::setDCCMapFilePath(std::string aPath_) {
0268   //try to open a dccMapFile in the given path
0269   std::ifstream dccMapFile_(aPath_.c_str());
0270 
0271   //if not successful return false
0272   if (!dccMapFile_.is_open())
0273     return false;
0274 
0275   //else close file and accept given path
0276   dccMapFile_.close();
0277   pathToMapFile_ = aPath_;
0278 
0279   return true;
0280 }
0281 
0282 // bool EcalElectronicsMapper::readDCCMapFile(){
0283 
0284 //   //try to open a dccMapFile in the given path
0285 //   std::ifstream dccMapFile_(pathToMapFile_.c_str());
0286 
0287 //   //if not successful return false
0288 //   if(!dccMapFile_.is_open()) return false;
0289 
0290 //   char lineBuf_[100];
0291 //   unsigned int SMId_,DCCId_;
0292 //   // loop while extraction from file is possible
0293 //   dccMapFile_.getline(lineBuf_,10);       //read line from file
0294 //   while (dccMapFile_.good()) {
0295 //     sscanf(lineBuf_,"%u:%u",&SMId_,&DCCId_);
0296 //     myDCCMap_[SMId_] = DCCId_;
0297 //     dccMapFile_.getline(lineBuf_,10);       //read line from file
0298 //   }
0299 
0300 //   return true;
0301 
0302 // }
0303 
0304 // bool EcalElectronicsMapper::readDCCMapFile(std::string aPath_){
0305 //   //test if path is good
0306 //   edm::FileInPath eff(aPath_);
0307 
0308 //   if(!setDCCMapFilePath(eff.fullPath())) return false;
0309 
0310 //   //read DCC map file
0311 //   readDCCMapFile();
0312 //   return true;
0313 // }
0314 
0315 bool EcalElectronicsMapper::makeMapFromVectors(std::vector<int>& orderedFedUnpackList,
0316                                                std::vector<int>& orderedDCCIdList) {
0317   // in case as non standard set of DCCId:FedId pairs was provided
0318   if (orderedFedUnpackList.size() == orderedDCCIdList.size() && !orderedFedUnpackList.empty()) {
0319     edm::LogInfo("EcalElectronicsMapper") << "DCCIdList/FedUnpackList lists given. Being loaded.";
0320 
0321     std::string correspondence("list of pairs DCCId:FedId :  ");
0322     char onePair[50];
0323     for (int v = 0; v < ((int)orderedFedUnpackList.size()); v++) {
0324       myDCCMap_[orderedDCCIdList[v]] = orderedFedUnpackList[v];
0325 
0326       sprintf(onePair, "  %d:%d", orderedDCCIdList[v], orderedFedUnpackList[v]);
0327       std::string tmp(onePair);
0328       correspondence += tmp;
0329     }
0330     edm::LogInfo("EcalElectronicsMapper") << correspondence;
0331 
0332   } else {  // default set of DCCId:FedId for ECAL
0333 
0334     edm::LogInfo("EcalElectronicsMapper") << "No input DCCIdList/FedUnpackList lists given for ECAL unpacker"
0335                                           << "(or given with different number of elements). "
0336                                           << " Loading default association DCCIdList:FedUnpackList,"
0337                                           << "i.e.  1:601 ... 53:653,  54:654.";
0338 
0339     for (unsigned int v = 1; v <= 54; v++) {
0340       myDCCMap_[v] = (v + 600);
0341     }
0342   }
0343 
0344   return true;
0345 }
0346 
0347 std::ostream& operator<<(std::ostream& o, const EcalElectronicsMapper& aMapper_) {
0348   //print class information
0349   o << "---------------------------------------------------------";
0350 
0351   if (aMapper_.pathToMapFile_.empty()) {
0352     o << "No correct input for DCC map has been given yet...";
0353   } else {
0354     o << "DCC Map (Map file: " << aMapper_.pathToMapFile_ << " )"
0355       << "SM id\t\tDCCid ";
0356 
0357     //get DCC map and iterator
0358     std::map<unsigned int, unsigned int> aMap;
0359     aMap = aMapper_.myDCCMap_;
0360     std::map<unsigned int, unsigned int>::iterator iter;
0361 
0362     //print info contained in map
0363     for (iter = aMap.begin(); iter != aMap.end(); iter++)
0364       o << iter->first << "\t\t" << iter->second;
0365   }
0366 
0367   o << "---------------------------------------------------------";
0368   return o;
0369 }
0370 
0371 unsigned int EcalElectronicsMapper::computeUnfilteredFEBlockLength() {
0372   return ((numbXtalTSamples_ - 2) / 4 + 1) * 25 + 1;
0373 }
0374 
0375 unsigned int EcalElectronicsMapper::computeEBTCCBlockLength() {
0376   unsigned int nTT = 68;
0377   unsigned int tf;
0378 
0379   //TCC block size: header (8 bytes) + 17 words with 4 trigger primitives (17*8bytes)
0380   if ((nTT * numbTriggerTSamples_) < 4 || (nTT * numbTriggerTSamples_) % 4)
0381     tf = 1;
0382   else
0383     tf = 0;
0384 
0385   return 1 + ((nTT * numbTriggerTSamples_) / 4) + tf;
0386 }
0387 
0388 unsigned int EcalElectronicsMapper::computeEETCCBlockLength() {
0389   //Todo : implement multiple tt samples for the endcap
0390   return 9;
0391 }
0392 
0393 bool EcalElectronicsMapper::isTCCExternal(unsigned int TCCId) {
0394   if ((NUMB_TCC_EE_MIN_EXT_MIN <= TCCId && TCCId <= NUMB_TCC_EE_MIN_EXT_MAX) ||
0395       (NUMB_TCC_EE_PLU_EXT_MIN <= TCCId && TCCId <= NUMB_TCC_EE_PLU_EXT_MAX))
0396     return true;
0397   else
0398     return false;
0399 }
0400 
0401 unsigned int EcalElectronicsMapper::getDCCId(unsigned int aSMId_) const {
0402   //get iterator for SM id
0403   std::map<unsigned int, unsigned int>::const_iterator it = myDCCMap_.find(aSMId_);
0404 
0405   //check if SMid exists and return DCC id
0406   if (it != myDCCMap_.end())
0407     return it->second;
0408 
0409   //error return
0410   if (!DCCDataUnpacker::silentMode_) {
0411     edm::LogError("IncorrectMapping") << "DCC requested for SM id: " << aSMId_ << " not found";
0412   }
0413   return 0;
0414 }
0415 
0416 unsigned int EcalElectronicsMapper::getSMId(unsigned int aDCCId_) const {
0417   //get iterator map
0418   std::map<unsigned int, unsigned int>::const_iterator it;
0419 
0420   //try to find SM id for given DCC id
0421   for (it = myDCCMap_.begin(); it != myDCCMap_.end(); it++)
0422     if (it->second == aDCCId_)
0423       return it->first;
0424 
0425   //error return
0426   if (!DCCDataUnpacker::silentMode_) {
0427     edm::LogError("IncorrectMapping") << "SM requested DCC id: " << aDCCId_ << " not found";
0428   }
0429   return 0;
0430 }
0431 
0432 void EcalElectronicsMapper::fillMaps() {
0433   for (int smId = 1; smId <= 54; smId++) {
0434     // Fill EB arrays
0435     if (smId > 9 && smId < 46) {
0436       for (int feChannel = 1; feChannel <= 68; feChannel++) {
0437         unsigned int tccId = smId + TCCID_SMID_SHIFT_EB;
0438 
0439         // Builds Ecal Trigger Tower Det Id
0440 
0441         unsigned int rawid = (mappingBuilder_->getTrigTowerDetId(tccId, feChannel)).rawId();
0442         EcalTrigTowerDetId* ttDetId = new EcalTrigTowerDetId(rawid);
0443         ttDetIds_[tccId - 1][feChannel - 1] = ttDetId;
0444         EcalElectronicsId* ttEleId = new EcalElectronicsId(smId, feChannel, 1, 1);
0445         ttEleIds_[tccId - 1][feChannel - 1] = ttEleId;
0446         EcalTriggerPrimitiveDigi* tp = new EcalTriggerPrimitiveDigi(*ttDetId);
0447         tp->setSize(numbTriggerTSamples_);
0448         for (unsigned int i = 0; i < numbTriggerTSamples_; i++) {
0449           tp->setSample(i, EcalTriggerPrimitiveSample(0));
0450         }
0451         ttTPIds_[tccId - 1][feChannel - 1] = tp;
0452 
0453         // build pseudostrip input data digi
0454         for (int ps = 1; ps <= 5; ps++) {
0455           psInput_[tccId - 1][feChannel - 1][ps - 1] =
0456               new EcalPseudoStripInputDigi(EcalTriggerElectronicsId(tccId, feChannel, ps, 1));
0457           psInput_[tccId - 1][feChannel - 1][ps - 1]->setSize(1);
0458           psInput_[tccId - 1][feChannel - 1][ps - 1]->setSample(0, EcalPseudoStripInputSample(0));
0459         }
0460 
0461         // Buil SRP Flag
0462         srFlags_[smId - 1][feChannel - 1].push_back(new EBSrFlag(*ttDetId, 0));
0463 
0464         //only one element for barrel: 1-to-1 correspondance between
0465         //DCC channels and EB trigger tower:
0466         assert(srFlags_[smId - 1][feChannel - 1].size() == 1);
0467 
0468         for (unsigned int stripId = 1; stripId <= 5; stripId++) {
0469           for (unsigned int xtalId = 1; xtalId <= 5; xtalId++) {
0470             EcalElectronicsId eid(smId, feChannel, stripId, xtalId);
0471             EBDetId* detId = new EBDetId((mappingBuilder_->getDetId(eid)).rawId());
0472             xtalDetIds_[smId - 1][feChannel - 1][stripId - 1][xtalId - 1] = detId;
0473 
0474           }  // close loop over xtals
0475         }    // close loop over strips
0476 
0477       }  // close loop over fechannels
0478 
0479     }  //close loop over sm ids in the EB
0480     // Fill EE arrays (Todo : waiting SC correction)
0481 
0482     else {
0483       std::vector<unsigned int>* pTCCIds = mapSmIdToTccIds_[smId];
0484       std::vector<unsigned int>::iterator it;
0485 
0486       for (it = pTCCIds->begin(); it != pTCCIds->end(); it++) {
0487         unsigned int tccId = *it;
0488 
0489         // creating arrays of pointers for trigger objects
0490         for (unsigned int towerInTCC = 1; towerInTCC <= numChannelsInDcc_[smId - 1]; towerInTCC++) {
0491           // Builds Ecal Trigger Tower Det Id
0492           EcalTrigTowerDetId ttDetId = mappingBuilder_->getTrigTowerDetId(tccId, towerInTCC);
0493 
0494           ttDetIds_[tccId - 1][towerInTCC - 1] = new EcalTrigTowerDetId(ttDetId.rawId());
0495           EcalTriggerPrimitiveDigi* tp = new EcalTriggerPrimitiveDigi(ttDetId);
0496           tp->setSize(numbTriggerTSamples_);
0497           for (unsigned int i = 0; i < numbTriggerTSamples_; i++) {
0498             tp->setSample(i, EcalTriggerPrimitiveSample(0));
0499           }
0500 
0501           ttTPIds_[tccId - 1][towerInTCC - 1] = tp;
0502 
0503           // build pseudostrip input data digi
0504           for (int ps = 1; ps <= 5; ps++) {
0505             psInput_[tccId - 1][towerInTCC - 1][ps - 1] =
0506                 new EcalPseudoStripInputDigi(EcalTriggerElectronicsId(tccId, towerInTCC, ps, 1));
0507             psInput_[tccId - 1][towerInTCC - 1][ps - 1]->setSize(1);
0508             psInput_[tccId - 1][towerInTCC - 1][ps - 1]->setSample(0, EcalPseudoStripInputSample(0));
0509           }
0510         }
0511       }
0512 
0513       // creating arrays of pointers for digi objects
0514       for (unsigned int feChannel = 1; feChannel <= numChannelsInDcc_[smId - 1]; feChannel++) {
0515         // to avoid gap in CCU_id's
0516         if ((smId == SECTOR_EEM_CCU_JUMP || smId == SECTOR_EEP_CCU_JUMP) &&
0517             (MIN_CCUID_JUMP <= feChannel && feChannel <= MAX_CCUID_JUMP))
0518           continue;
0519 
0520         std::vector<EcalScDetId> scDetIds = mappingBuilder_->getEcalScDetId(smId, feChannel);
0521         // scDetIds_[smId-1][feChannel-1] = new EcalScDetId(scDetId.rawId());
0522         scEleIds_[smId - 1][feChannel - 1] = new EcalElectronicsId(smId, feChannel, 1, 1);
0523 
0524         for (size_t i = 0; i < scDetIds.size(); ++i) {
0525           // std::cout << __FILE__ << ":" << __LINE__ << ": "
0526           //            << "(DCC,RU) = (" <<  smId << "," << feChannel
0527           //            << ") -> " << scDetIds[i] << "\n";
0528 
0529           srFlags_[smId - 1][feChannel - 1].push_back(new EESrFlag(EcalScDetId(scDetIds[i].rawId()), 0));
0530         }
0531         //usually only one element 1 DCC channel <-> 1 SC
0532         //in few case two or three elements: partial SCs grouped.
0533         assert(srFlags_[smId - 1][feChannel - 1].size() <= 3);
0534 
0535         std::vector<DetId> ecalDetIds = mappingBuilder_->dccTowerConstituents(smId, feChannel);
0536         std::vector<DetId>::iterator it;
0537 
0538         //EEDetIds
0539         for (it = ecalDetIds.begin(); it != ecalDetIds.end(); it++) {
0540           EcalElectronicsId ids = mappingBuilder_->getElectronicsId((*it));
0541 
0542           int stripId = ids.stripId();
0543           int xtalId = ids.xtalId();
0544 
0545           EEDetId* detId = new EEDetId((*it).rawId());
0546           xtalDetIds_[smId - 1][feChannel - 1][stripId - 1][xtalId - 1] = detId;
0547         }  // close loop over tower constituents
0548 
0549       }  // close loop over  FE Channels
0550 
0551     }  // closing loop over sm ids in EE
0552   }
0553 
0554   // developing mapping for pseudostrip input data: (tccId,psNumber)->(tccId,towerId,psId)
0555   // initializing array for pseudostrip data
0556   short numStripInTT[EcalTriggerElectronicsId::MAX_TCCID][EcalTrigTowerDetId::kEBTowersPerSM];
0557   for (int tccId = 0; tccId < EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
0558     for (int tt = 0; tt < EcalTrigTowerDetId::kEBTowersPerSM; tt++) {
0559       numStripInTT[tccId][tt] = -2;
0560     }
0561   }
0562 
0563   // assumption: if ps_max is the largest pseudostripId within a trigger tower
0564   // all the pseudostrip 1 ...  ps_max are actually present
0565   std::vector<DetId>::iterator theTCCConstituent;
0566   for (int tccId = 0; tccId < EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
0567     // loop over all constituents of a TCC and collect
0568     // the largest pseudostripId within each trigger tower
0569     std::vector<DetId> tccConstituents = mappingBuilder_->tccConstituents(tccId + 1);
0570 
0571     for (theTCCConstituent = tccConstituents.begin(); theTCCConstituent != tccConstituents.end(); theTCCConstituent++) {
0572       int towerId = (mappingBuilder_->getTriggerElectronicsId(*theTCCConstituent)).ttId();
0573       int ps = (mappingBuilder_->getTriggerElectronicsId(*theTCCConstituent)).pseudoStripId();
0574       if (ps > numStripInTT[tccId][towerId - 1])
0575         numStripInTT[tccId][towerId - 1] = ps;
0576 
0577       //std::cout << "tccId: " << (tccId+1) << "    towerId: " << towerId
0578       // << "    ps: " << ps << "    numStripInTT: " << numStripInTT[tccId][towerId-1] << std::endl;
0579 
0580     }  // loop on TCC constituents
0581 
0582   }  // loop on TCC's
0583 
0584   int psCounter;
0585   for (int tccId = 0; tccId < EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
0586     // resetting pseudostrip counter at each new TCC
0587     psCounter = 0;
0588     for (int towerId = 0; towerId < EcalTrigTowerDetId::kEBTowersPerSM; towerId++) {
0589       // if there's not a given towerId, numStripInTT==-1
0590       for (int ps = 0; ps < numStripInTT[tccId][towerId]; ps++) {
0591         tTandPs_[tccId][psCounter][0] = towerId + 1;
0592         tTandPs_[tccId][psCounter][1] = ps + 1;
0593         psCounter++;
0594       }  // loop on TCC's
0595     }    // loop on towers in TCC
0596   }      // loop in ps in tower
0597 
0598   //   for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
0599   //       for (int psCounter=0; psCounter<EcalTrigTowerDetId::kEBTowersPerSM*5; psCounter++) {
0600   //           std::cout << "tccId: " << (tccId+1) << "    counter: " << (psCounter+1)
0601   //                     << " tt: " << tTandPs_[tccId][psCounter][0]
0602   //                     << " ps: " << tTandPs_[tccId][psCounter][1]
0603   //                     << std::endl;
0604   //       } }
0605 
0606   // Note:
0607   // for TCC 48 in EE, pseudostrip data in the interval:
0608   // + 1-30 is good pseudostrip data
0609   // + 31-42 is a duplication of the last 12 ps of the previous block, and needs be ignored
0610   // + 43-60 is further good pseudostrip data
0611 
0612   for (int tcc = EcalTriggerElectronicsId::MIN_TCCID_EEM; tcc <= EcalTriggerElectronicsId::MAX_TCCID_EEM; tcc++) {
0613     int tccId = tcc - 1;
0614     short tTandPs_tmp[18][2];
0615 
0616     // store entries _after_ the pseudostrip data which gets duplicated
0617     for (int psCounter = 30; psCounter < 48; psCounter++) {
0618       tTandPs_tmp[psCounter - 30][0] = tTandPs_[tccId][psCounter][0];
0619       tTandPs_tmp[psCounter - 30][1] = tTandPs_[tccId][psCounter][1];
0620     }
0621 
0622     // duplication
0623     for (int psCounter = 18; psCounter < 30; psCounter++) {
0624       tTandPs_[tccId][psCounter + 12][0] = tTandPs_[tccId][psCounter][0];
0625       tTandPs_[tccId][psCounter + 12][1] = tTandPs_[tccId][psCounter][1];
0626     }
0627 
0628     // append stoed
0629     for (int psCounter = 42; psCounter < 60; psCounter++) {
0630       tTandPs_[tccId][psCounter][0] = tTandPs_tmp[psCounter - 42][0];
0631       tTandPs_[tccId][psCounter][1] = tTandPs_tmp[psCounter - 42][1];
0632     }
0633 
0634   }  // loop on EEM TCC's
0635 
0636   for (int tcc = EcalTriggerElectronicsId::MIN_TCCID_EEP; tcc <= EcalTriggerElectronicsId::MAX_TCCID_EEP; tcc++) {
0637     int tccId = tcc - 1;
0638     short tTandPs_tmp[18][2];
0639 
0640     // store entries _after_ the pseudostrip data which gets duplicated
0641     for (int psCounter = 30; psCounter < 48; psCounter++) {
0642       tTandPs_tmp[psCounter - 30][0] = tTandPs_[tccId][psCounter][0];
0643       tTandPs_tmp[psCounter - 30][1] = tTandPs_[tccId][psCounter][1];
0644     }
0645 
0646     // duplication
0647     for (int psCounter = 18; psCounter < 30; psCounter++) {
0648       tTandPs_[tccId][psCounter + 12][0] = tTandPs_[tccId][psCounter][0];
0649       tTandPs_[tccId][psCounter + 12][1] = tTandPs_[tccId][psCounter][1];
0650     }
0651 
0652     // append stoed
0653     for (int psCounter = 42; psCounter < 60; psCounter++) {
0654       tTandPs_[tccId][psCounter][0] = tTandPs_tmp[psCounter - 42][0];
0655       tTandPs_[tccId][psCounter][1] = tTandPs_tmp[psCounter - 42][1];
0656     }
0657 
0658   }  // loop on EEP TCC's
0659 
0660   //for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
0661   //for (int psCounter=0; psCounter<EcalTrigTowerDetId::kEBTowersPerSM*5; psCounter++) {
0662   //std::cout << "AF tccId: " << (tccId+1) << "    counter: " << (psCounter+1)
0663   //<< " tt: " << tTandPs_[tccId][psCounter][0]
0664   //<< " ps: " << tTandPs_[tccId][psCounter][1]
0665   //<< std::endl;
0666   // } }
0667 }
0668 
0669 void EcalElectronicsMapper::setupGhostMap() {
0670   // number of 'ghost' VFEs
0671   const int n = 44;
0672 
0673   // here is a list of all 'ghost' VFEs
0674   // in format {FED, CCU, VFE}
0675   const struct {
0676     int FED, CCU, VFE;
0677   } v[n] = {{601, 10, 5}, {601, 34, 3}, {601, 34, 4}, {601, 34, 5}, {602, 32, 5}, {603, 12, 5}, {603, 30, 5},
0678             {604, 12, 5}, {604, 30, 5}, {605, 32, 5}, {606, 10, 5}, {606, 34, 3}, {606, 34, 4}, {606, 34, 5},
0679             {608, 27, 3}, {608, 27, 4}, {608, 27, 5}, {608, 3, 3},  {608, 3, 4},  {608, 3, 5},  {608, 30, 5},
0680             {608, 6, 5},  {646, 10, 5}, {646, 34, 3}, {646, 34, 4}, {646, 34, 5}, {647, 32, 5}, {648, 12, 5},
0681             {648, 30, 5}, {649, 12, 5}, {649, 30, 5}, {650, 32, 5}, {651, 10, 5}, {651, 34, 3}, {651, 34, 4},
0682             {651, 34, 5}, {653, 27, 3}, {653, 27, 4}, {653, 27, 5}, {653, 3, 3},  {653, 3, 4},  {653, 3, 5},
0683             {653, 30, 5}, {653, 6, 5}};
0684 
0685   for (int i = 0; i < n; ++i)
0686     ghost_[v[i].FED][v[i].CCU][v[i].VFE] = true;
0687 }
0688 
0689 bool EcalElectronicsMapper::isGhost(const int FED, const int CCU, const int VFE) {
0690   if (ghost_.find(FED) == ghost_.end())
0691     return false;
0692 
0693   if (ghost_[FED].find(CCU) == ghost_[FED].end())
0694     return false;
0695 
0696   if (ghost_[FED][CCU].find(VFE) == ghost_[FED][CCU].end())
0697     return false;
0698 
0699   return true;
0700 }
0701 
0702 // number of readout channels (TT in EB, SC in EE) in a DCC
0703 const unsigned int EcalElectronicsMapper::numChannelsInDcc_[NUMB_SM] = {
0704     34, 32, 33, 33, 32, 34, 33, 41, 33,                                      // EE -
0705     68, 68, 68, 68, 68, 68, 68, 68, 68, 68,                                  // EB-
0706     68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,  // EB+
0707     68, 68, 68, 68, 68, 68, 68, 68, 34, 32, 33, 33, 32, 34, 33, 41, 33};     // EE+