Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:54

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