CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/EcalRawToDigi/src/EcalElectronicsMapper.cc

Go to the documentation of this file.
00001 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00002 #include <EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h>
00003 #include <Geometry/EcalMapping/interface/EcalElectronicsMapping.h>
00004 #include <DataFormats/EcalDigi/interface/EBSrFlag.h>
00005 #include <DataFormats/EcalDigi/interface/EESrFlag.h>
00006 #include <EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h>
00007 
00008 EcalElectronicsMapper::EcalElectronicsMapper( unsigned int numbXtalTSamples, unsigned int numbTriggerTSamples)
00009 : pathToMapFile_(""),
00010 numbXtalTSamples_(numbXtalTSamples),
00011 numbTriggerTSamples_(numbTriggerTSamples),
00012 mappingBuilder_(0)
00013 {
00014   resetPointers();
00015 }
00016 
00017 void EcalElectronicsMapper::resetPointers(){
00018   
00019   // Reset Arrays
00020   for(unsigned int sm=0; sm < NUMB_SM; sm++){
00021     for(unsigned int fe=0; fe< NUMB_FE; fe++){
00022           
00023       for(unsigned int strip=0; strip<NUMB_STRIP;strip++){
00024         for(unsigned int xtal=0; xtal<NUMB_XTAL;xtal++){
00025                     
00026              //Reset DFrames and xtalDetIds
00027           xtalDetIds_[sm][fe][strip][xtal]=0;
00028         }
00029       }
00030 
00031       //Reset SC Det Ids
00032       //scDetIds_[sm][fe]=0;
00033       scEleIds_[sm][fe]=0;
00034       //srFlags_[sm][fe]=0;
00035     }
00036   }
00037   
00038   
00039   //Reset TT det Ids
00040   for( unsigned int tccid=0; tccid < NUMB_TCC; tccid++){
00041     for(unsigned int tpg =0; tpg<NUMB_FE;tpg++){
00042       ttDetIds_[tccid][tpg]=0;
00043       ttTPIds_[tccid][tpg]=0;
00044       ttEleIds_[tccid][tpg]=0;
00045     }
00046   }
00047 
00048   // reset trigger electronics Id
00049   for (int tccid=0; tccid<NUMB_TCC; tccid++){
00050       for (int ttid=0; ttid<TCC_EB_NUMBTTS; ttid++){
00051           for (int ps=0; ps<NUMB_STRIP; ps++){
00052               psInput_[tccid][ttid][ps]=0;
00053           }}}
00054   
00055   // initialize TCC maps
00056   for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
00057       for (int psCounter=0; psCounter<EcalTrigTowerDetId::kEBTowersPerSM*5; psCounter++) {
00058           for (int u=0; u<2; u++){
00059               tTandPs_[tccId][psCounter][u]=-1;
00060           } } }
00061   
00062   
00063 
00064   //Fill map sm id to tcc ids
00065   std::vector<unsigned int> * ids;
00066   ids = new std::vector<unsigned int>;
00067   ids->push_back(1); ids->push_back(18);ids->push_back(19);ids->push_back(36);
00068   mapSmIdToTccIds_[1]= ids;
00069                 
00070   ids = new std::vector<unsigned int>;
00071   ids->push_back(2); ids->push_back(3);ids->push_back(20);ids->push_back(21);
00072   mapSmIdToTccIds_[2]= ids;
00073                 
00074   ids = new std::vector<unsigned int>;
00075   ids->push_back(4); ids->push_back(5);ids->push_back(22);ids->push_back(23);
00076   mapSmIdToTccIds_[3]= ids;
00077                 
00078   ids = new std::vector<unsigned int>;
00079   ids->push_back(6); ids->push_back(7);ids->push_back(24);ids->push_back(25);
00080   mapSmIdToTccIds_[4]= ids;
00081                 
00082   ids = new std::vector<unsigned int>;
00083   ids->push_back(8); ids->push_back(9);ids->push_back(26);ids->push_back(27);
00084   mapSmIdToTccIds_[5]= ids;
00085                 
00086   ids = new std::vector<unsigned int>;
00087   ids->push_back(10); ids->push_back(11);ids->push_back(28);ids->push_back(29);
00088   mapSmIdToTccIds_[6]= ids;
00089                 
00090   ids = new std::vector<unsigned int>;
00091   ids->push_back(12); ids->push_back(13);ids->push_back(30);ids->push_back(31);
00092   mapSmIdToTccIds_[7]= ids;
00093                 
00094   ids = new std::vector<unsigned int>;
00095   ids->push_back(14); ids->push_back(15);ids->push_back(32);ids->push_back(33);
00096   mapSmIdToTccIds_[8]= ids;
00097                 
00098   ids = new std::vector<unsigned int>;
00099   ids->push_back(16); ids->push_back(17);ids->push_back(34);ids->push_back(35);
00100   mapSmIdToTccIds_[9]= ids;
00101                 
00102   ids = new std::vector<unsigned int>;
00103   ids->push_back(73); ids->push_back(90);ids->push_back(91);ids->push_back(108);
00104   mapSmIdToTccIds_[46]= ids;
00105                 
00106   ids = new std::vector<unsigned int>;
00107   ids->push_back(74); ids->push_back(75);ids->push_back(92);ids->push_back(93);
00108   mapSmIdToTccIds_[47]= ids;
00109                 
00110   ids = new std::vector<unsigned int>;
00111   ids->push_back(76); ids->push_back(77);ids->push_back(94);ids->push_back(95);
00112   mapSmIdToTccIds_[48]= ids;
00113                 
00114   ids = new std::vector<unsigned int>;
00115   ids->push_back(78); ids->push_back(79);ids->push_back(96);ids->push_back(97);
00116   mapSmIdToTccIds_[49]= ids;
00117                 
00118   ids = new std::vector<unsigned int>;
00119   ids->push_back(80); ids->push_back(81);ids->push_back(98);ids->push_back(99);  
00120   mapSmIdToTccIds_[50]= ids;
00121                  
00122   ids = new std::vector<unsigned int>;
00123   ids->push_back(82); ids->push_back(83);ids->push_back(100);ids->push_back(101);
00124   mapSmIdToTccIds_[51]= ids;
00125                 
00126   ids = new std::vector<unsigned int>;
00127   ids->push_back(84); ids->push_back(85);ids->push_back(102);ids->push_back(103);
00128   mapSmIdToTccIds_[52]= ids;
00129                 
00130   ids = new std::vector<unsigned int>;
00131   ids->push_back(86); ids->push_back(87);ids->push_back(104);ids->push_back(105);
00132   mapSmIdToTccIds_[53]= ids;
00133                 
00134   ids = new std::vector<unsigned int>;
00135   ids->push_back(88); ids->push_back(89);ids->push_back(106);ids->push_back(107);
00136   mapSmIdToTccIds_[54]= ids;
00137         
00138   
00139   //Compute data block sizes
00140   unfilteredFEBlockLength_= computeUnfilteredFEBlockLength();  
00141   ebTccBlockLength_       = computeEBTCCBlockLength();
00142   eeTccBlockLength_       = computeEETCCBlockLength();
00143     
00144 
00145 }
00146 
00147 
00148 EcalElectronicsMapper::~EcalElectronicsMapper(){
00149   deletePointers();
00150 }
00151 
00152 void EcalElectronicsMapper::deletePointers(){
00153 
00154   //DETETE ARRAYS
00155   for(unsigned int sm=0; sm < NUMB_SM; sm++){
00156     for(unsigned int fe=0; fe< NUMB_FE; fe++){
00157       for(unsigned int strip=0; strip<NUMB_STRIP;strip++){
00158         for(unsigned int xtal=0; xtal<NUMB_XTAL;xtal++) delete xtalDetIds_[sm][fe][strip][xtal];         
00159       }
00160 
00161       // if(scDetIds_[sm][fe]){ 
00162       //  delete scDetIds_[sm][fe];
00163       //  delete scEleIds_[sm][fe];
00164       for(size_t i = 0; i< srFlags_[sm][fe].size(); ++i) delete srFlags_[sm][fe][i];
00165       srFlags_[sm][fe].clear();
00166  
00167       delete scEleIds_[sm][fe];
00168            
00169     }
00170  
00171   }
00172 
00173   // delete trigger electronics Id
00174   for (int tccid=0; tccid<NUMB_TCC; tccid++){
00175     for (int ttid=0; ttid<TCC_EB_NUMBTTS; ttid++){
00176       for (int ps=0; ps<NUMB_STRIP; ps++){
00177         delete psInput_[tccid][ttid][ps];
00178       }
00179     }
00180   }
00181 
00182 
00183   
00184   for( unsigned int tccid=0; tccid < NUMB_TCC; tccid++){
00185     for(unsigned int tpg =0; tpg<NUMB_FE;tpg++){
00186       if(ttDetIds_[tccid][tpg]){ 
00187         delete ttDetIds_[tccid][tpg];
00188         delete ttTPIds_[tccid][tpg];
00189         delete ttEleIds_[tccid][tpg];
00190       }
00191     }
00192   }
00193 
00194 
00195   pathToMapFile_.clear();
00196   
00197   
00198   std::map<unsigned int, std::vector<unsigned int> *>::iterator it;
00199   for(it = mapSmIdToTccIds_.begin(); it != mapSmIdToTccIds_.end(); it++ ){ delete (*it).second; }
00200   
00201   mapSmIdToTccIds_.clear();
00202  
00203 }
00204 
00205 void EcalElectronicsMapper::setEcalElectronicsMapping(const EcalElectronicsMapping * m){
00206   mappingBuilder_= m;
00207   fillMaps();
00208 }
00209 
00210 bool EcalElectronicsMapper::setActiveDCC(unsigned int dccId){
00211    
00212   bool ret(true);
00213         
00214   //Update active dcc and associated smId
00215   dccId_ = dccId;
00216    
00217   smId_  = getSMId(dccId_);
00218         
00219   if(!smId_) ret = false;
00220         
00221   return ret;
00222         
00223  } 
00224  
00225  
00226 bool EcalElectronicsMapper::setDCCMapFilePath(std::string aPath_){
00227 
00228   
00229   //try to open a dccMapFile in the given path
00230   std::ifstream dccMapFile_(aPath_.c_str());
00231 
00232   //if not successful return false
00233   if(!dccMapFile_.is_open()) return false;
00234 
00235   //else close file and accept given path
00236   dccMapFile_.close();
00237   pathToMapFile_ = aPath_;
00238 
00239   return true;
00240 }
00241 
00242 
00243 // bool EcalElectronicsMapper::readDCCMapFile(){
00244 
00245 //   //try to open a dccMapFile in the given path
00246 //   std::ifstream dccMapFile_(pathToMapFile_.c_str());
00247   
00248 //   //if not successful return false
00249 //   if(!dccMapFile_.is_open()) return false;
00250   
00251 //   char lineBuf_[100];
00252 //   unsigned int SMId_,DCCId_;
00253 //   // loop while extraction from file is possible
00254 //   dccMapFile_.getline(lineBuf_,10);       //read line from file
00255 //   while (dccMapFile_.good()) {
00256 //     sscanf(lineBuf_,"%u:%u",&SMId_,&DCCId_);
00257 //     myDCCMap_[SMId_] = DCCId_;
00258 //     dccMapFile_.getline(lineBuf_,10);       //read line from file
00259 //   }
00260   
00261   
00262 //   return true;
00263   
00264 // }
00265 
00266 // bool EcalElectronicsMapper::readDCCMapFile(std::string aPath_){
00267 //   //test if path is good
00268 //   edm::FileInPath eff(aPath_);
00269   
00270 //   if(!setDCCMapFilePath(eff.fullPath())) return false;
00271 
00272 //   //read DCC map file
00273 //   readDCCMapFile();
00274 //   return true;
00275 // }
00276 
00277 
00278 bool EcalElectronicsMapper::makeMapFromVectors( std::vector<int>& orderedFedUnpackList,
00279                                                std::vector<int>& orderedDCCIdList )
00280 {
00281 
00282   // in case as non standard set of DCCId:FedId pairs was provided
00283   if ( orderedFedUnpackList.size() == orderedDCCIdList.size() &&
00284        orderedFedUnpackList.size() > 0)
00285     {
00286       edm::LogInfo("EcalElectronicsMapper") << "DCCIdList/FedUnpackList lists given. Being loaded.";
00287       
00288       std::string correspondence("list of pairs DCCId:FedId :  ");
00289       char           onePair[50];
00290       for (int v=0;  v< ((int)orderedFedUnpackList.size());  v++)        {
00291         myDCCMap_[ orderedDCCIdList[v]  ] = orderedFedUnpackList[v] ;
00292         
00293         sprintf( onePair, "  %d:%d",  orderedDCCIdList[v], orderedFedUnpackList[v]);
00294         std::string                 tmp(onePair);
00295         correspondence += tmp;
00296       }
00297       edm::LogInfo("EcalElectronicsMapper") << correspondence;
00298       
00299     }
00300   else    
00301     {  // default set of DCCId:FedId for ECAL
00302 
00303       edm::LogInfo("EcalElectronicsMapper") << "No input DCCIdList/FedUnpackList lists given for ECAL unpacker"
00304                                             << "(or given with different number of elements). "
00305                                             << " Loading default association DCCIdList:FedUnpackList,"
00306                                             << "i.e.  1:601 ... 53:653,  54:654.";
00307       
00308       for (unsigned int v=1; v<=54; v++)        {
00309         myDCCMap_[ v ] = (v+600) ;   }
00310     }
00311 
00312   return true;
00313 }
00314 
00315 
00316 std::ostream &operator<< (std::ostream& o, const EcalElectronicsMapper &aMapper_) {
00317   //print class information
00318   o << "---------------------------------------------------------";
00319 
00320   if(aMapper_.pathToMapFile_.size() < 1){
00321     o << "No correct input for DCC map has been given yet...";
00322   }
00323   else{
00324     o << "DCC Map (Map file: " << aMapper_.pathToMapFile_ << " )" << "SM id\t\tDCCid ";
00325 
00326     //get DCC map and iterator
00327     std::map<unsigned int ,unsigned int > aMap;
00328     aMap=aMapper_.myDCCMap_;
00329     std::map<unsigned int ,unsigned int >::iterator iter;
00330 
00331     //print info contained in map
00332     for(iter = aMap.begin(); iter != aMap.end(); iter++)
00333       o << iter->first << "\t\t" << iter->second;
00334   }
00335 
00336   o << "---------------------------------------------------------";
00337   return o;
00338 }
00339 
00340   
00341 
00342 unsigned int EcalElectronicsMapper::computeUnfilteredFEBlockLength(){
00343 
00344   return ((numbXtalTSamples_-2)/4+1)*25+1; 
00345 
00346 }
00347 
00348 
00349 unsigned int EcalElectronicsMapper::computeEBTCCBlockLength(){
00350 
00351   unsigned int nTT=68;
00352   unsigned int tf;
00353           
00354   //TCC block size: header (8 bytes) + 17 words with 4 trigger primitives (17*8bytes)
00355   if( (nTT*numbTriggerTSamples_)<4 || (nTT*numbTriggerTSamples_)%4 ) tf=1;  
00356   else tf=0;
00357     
00358   return 1 + ((nTT*numbTriggerTSamples_)/4) + tf ;
00359 
00360 }
00361 
00362 unsigned int EcalElectronicsMapper::computeEETCCBlockLength(){
00363   //Todo : implement multiple tt samples for the endcap
00364   return 9;  
00365 
00366 }
00367 
00368 bool EcalElectronicsMapper::isTCCExternal(unsigned int TCCId){
00369   if(
00370      (NUMB_TCC_EE_MIN_EXT_MIN <= TCCId && TCCId<=NUMB_TCC_EE_MIN_EXT_MAX) ||
00371      (NUMB_TCC_EE_PLU_EXT_MIN <= TCCId && TCCId<=NUMB_TCC_EE_PLU_EXT_MAX)
00372      ) return true;
00373   else return false;
00374 }
00375 
00376 unsigned int EcalElectronicsMapper::getDCCId(unsigned int aSMId_) const{
00377   //get iterator for SM id
00378   std::map<unsigned int ,unsigned int>::const_iterator it = myDCCMap_.find(aSMId_);
00379 
00380   //check if SMid exists and return DCC id
00381   if(it!= myDCCMap_.end()) return it->second;
00382  
00383   //error return
00384   if( ! DCCDataUnpacker::silentMode_ ){
00385     edm::LogError("IncorrectMapping") << "DCC requested for SM id: " << aSMId_ << " not found";
00386   }
00387   return 0;
00388 }
00389 
00390 
00391 unsigned int EcalElectronicsMapper::getSMId(unsigned int aDCCId_) const {
00392   //get iterator map
00393   std::map<unsigned int ,unsigned int>::const_iterator it;
00394 
00395   //try to find SM id for given DCC id
00396   for(it = myDCCMap_.begin(); it != myDCCMap_.end(); it++)
00397     if(it->second == aDCCId_) 
00398       return it->first;
00399 
00400   //error return
00401   if( ! DCCDataUnpacker::silentMode_ ){
00402     edm::LogError("IncorrectMapping") << "SM requested DCC id: " << aDCCId_ << " not found";
00403   }
00404   return 0;
00405 }
00406 
00407 
00408 
00409 
00410 void EcalElectronicsMapper::fillMaps(){
00411  
00412   for( int smId=1 ; smId<= 54; smId++){
00413 
00414     
00415     // Fill EB arrays  
00416     if( smId > 9 && smId < 46 ){
00417          
00418       for(int feChannel =1; feChannel<=68; feChannel++){
00419                    
00420         unsigned int tccId = smId + TCCID_SMID_SHIFT_EB;
00421                   
00422         // Builds Ecal Trigger Tower Det Id 
00423 
00424         unsigned int rawid = (mappingBuilder_->getTrigTowerDetId(tccId, feChannel)).rawId();
00425         EcalTrigTowerDetId * ttDetId = new EcalTrigTowerDetId(rawid);
00426         ttDetIds_[tccId-1][feChannel-1] = ttDetId;
00427         EcalElectronicsId * ttEleId = new EcalElectronicsId(smId, feChannel, 1, 1);
00428         ttEleIds_[tccId-1][feChannel-1] = ttEleId;
00429         EcalTriggerPrimitiveDigi * tp     = new EcalTriggerPrimitiveDigi(*ttDetId);
00430         tp->setSize(numbTriggerTSamples_);
00431         for(unsigned int i=0;i<numbTriggerTSamples_;i++){
00432           tp->setSample( i, EcalTriggerPrimitiveSample(0) );
00433         }
00434         ttTPIds_[tccId-1][feChannel-1]  = tp;
00435 
00436         // build pseudostrip input data digi
00437         for(int ps=1; ps<=5; ps++){
00438             psInput_[tccId-1][feChannel-1][ps-1]= new EcalPseudoStripInputDigi( EcalTriggerElectronicsId(tccId, feChannel, ps, 1) );
00439             psInput_[tccId-1][feChannel-1][ps-1]->setSize(1);
00440             psInput_[tccId-1][feChannel-1][ps-1]->setSample( 0, EcalPseudoStripInputSample(0) );
00441         }
00442 
00443         // Buil SRP Flag
00444         srFlags_[smId-1][feChannel-1].push_back(new EBSrFlag(*ttDetId,0));
00445 
00446         //only one element for barrel: 1-to-1 correspondance between
00447         //DCC channels and EB trigger tower:
00448         assert(srFlags_[smId-1][feChannel-1].size()==1);
00449  
00450         for(unsigned int stripId =1; stripId<=5; stripId++){
00451                     
00452           for(unsigned int xtalId =1;xtalId<=5;xtalId++){
00453                    
00454               EcalElectronicsId eid(smId,feChannel,stripId,xtalId);
00455               EBDetId * detId = new EBDetId( (mappingBuilder_->getDetId(eid)).rawId());
00456               xtalDetIds_[smId-1][feChannel-1][stripId-1][xtalId-1] = detId;
00457                          
00458            } // close loop over xtals
00459         }// close loop over strips
00460                                   
00461       }// close loop over fechannels
00462                 
00463     }//close loop over sm ids in the EB
00464     // Fill EE arrays (Todo : waiting SC correction)
00465     
00466     else{
00467          
00468         std::vector<unsigned int> * pTCCIds = mapSmIdToTccIds_[smId];
00469         std::vector<unsigned int>::iterator it;
00470                 
00471         for(it= pTCCIds->begin(); it!= pTCCIds->end(); it++){
00472                         
00473           unsigned int tccId = *it;
00474           
00475           // creating arrays of pointers for trigger objects
00476           for(unsigned int towerInTCC =1; towerInTCC <= numChannelsInDcc_[smId-1]; towerInTCC++){
00477               
00478               // Builds Ecal Trigger Tower Det Id 
00479               EcalTrigTowerDetId ttDetId = mappingBuilder_->getTrigTowerDetId(tccId, towerInTCC);
00480               
00481               ttDetIds_[tccId-1][towerInTCC-1] = new EcalTrigTowerDetId(ttDetId.rawId());
00482               EcalTriggerPrimitiveDigi * tp   = new EcalTriggerPrimitiveDigi(ttDetId);
00483               tp->setSize(numbTriggerTSamples_);
00484               for(unsigned int i=0;i<numbTriggerTSamples_;i++){
00485                   tp->setSample( i, EcalTriggerPrimitiveSample(0) );
00486               }
00487               
00488               ttTPIds_[tccId-1][towerInTCC-1]  = tp;
00489               
00490               // build pseudostrip input data digi
00491                for(int ps=1; ps<=5; ps++){
00492                    psInput_[tccId-1][towerInTCC-1][ps-1]= new EcalPseudoStripInputDigi( EcalTriggerElectronicsId(tccId, towerInTCC, ps, 1) );
00493                    psInput_[tccId-1][towerInTCC-1][ps-1]->setSize(1);
00494                    psInput_[tccId-1][towerInTCC-1][ps-1]->setSample( 0, EcalPseudoStripInputSample(0) );
00495                }
00496               
00497           }
00498         }
00499         
00500         // creating arrays of pointers for digi objects
00501         for(unsigned int feChannel = 1; feChannel <= numChannelsInDcc_[smId-1]; feChannel++){
00502           
00503           // to avoid gap in CCU_id's
00504           if((smId==SECTOR_EEM_CCU_JUMP   || smId== SECTOR_EEP_CCU_JUMP) &&
00505              (MIN_CCUID_JUMP <= feChannel && feChannel <=MAX_CCUID_JUMP )
00506              ) continue;
00507           
00508           std::vector<EcalScDetId> scDetIds = mappingBuilder_->getEcalScDetId(smId,feChannel);
00509           // scDetIds_[smId-1][feChannel-1] = new EcalScDetId(scDetId.rawId());
00510           scEleIds_[smId-1][feChannel-1] = new EcalElectronicsId(smId,feChannel,1,1);
00511 
00512           for(size_t i = 0; i < scDetIds.size(); ++i){
00513             // std::cout << __FILE__ << ":" << __LINE__ << ": "
00514             //            << "(DCC,RU) = (" <<  smId << "," << feChannel
00515             //            << ") -> " << scDetIds[i] << "\n";
00516             
00517             srFlags_[smId-1][feChannel-1].push_back(new EESrFlag( EcalScDetId( scDetIds[i].rawId() ) , 0 ));
00518           }
00519           //usually only one element 1 DCC channel <-> 1 SC
00520           //in few case two or three elements: partial SCs grouped. 
00521           assert(srFlags_[smId-1][feChannel-1].size()<=3);
00522           
00523           std::vector<DetId> ecalDetIds = mappingBuilder_->dccTowerConstituents(smId,feChannel);
00524           std::vector<DetId>::iterator it;
00525                                   
00526           //EEDetIds        
00527           for(it = ecalDetIds.begin(); it!= ecalDetIds.end(); it++){
00528             
00529             EcalElectronicsId ids = mappingBuilder_->getElectronicsId((*it));
00530             
00531             int stripId    = ids.stripId();
00532             int xtalId     = ids.xtalId();
00533             
00534             EEDetId * detId = new EEDetId((*it).rawId());
00535             xtalDetIds_[smId-1][feChannel-1][stripId-1][xtalId-1] = detId;
00536           }// close loop over tower constituents
00537           
00538         }// close loop over  FE Channels                
00539         
00540     }// closing loop over sm ids in EE
00541         
00542   }
00543 
00544 
00545   // developing mapping for pseudostrip input data: (tccId,psNumber)->(tccId,towerId,psId)
00546   // initializing array for pseudostrip data
00547   short numStripInTT[EcalTriggerElectronicsId::MAX_TCCID][EcalTrigTowerDetId::kEBTowersPerSM];
00548   for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++){
00549       for (int tt=0; tt<EcalTrigTowerDetId::kEBTowersPerSM; tt++){
00550           numStripInTT[tccId][tt]=-2;} }
00551 
00552   
00553   // assumption: if ps_max is the largest pseudostripId within a trigger tower
00554   // all the pseudostrip 1 ...  ps_max are actually present
00555   std::vector<DetId>::iterator theTCCConstituent;
00556   for(int tccId = 0; tccId< EcalTriggerElectronicsId::MAX_TCCID ; tccId++)
00557   {
00558       
00559       // loop over all constituents of a TCC and collect
00560       // the largest pseudostripId within each trigger tower
00561       std::vector<DetId> tccConstituents = mappingBuilder_->tccConstituents(tccId+1);
00562       
00563       for (theTCCConstituent  = tccConstituents.begin();
00564            theTCCConstituent != tccConstituents.end();
00565            theTCCConstituent++)
00566       {
00567 
00568           int towerId = ( mappingBuilder_->getTriggerElectronicsId(*theTCCConstituent) ) .ttId();
00569           int ps    = ( mappingBuilder_->getTriggerElectronicsId(*theTCCConstituent) ) .pseudoStripId();
00570           if( ps > numStripInTT[tccId][towerId-1]) numStripInTT[tccId][towerId-1] = ps;
00571 
00572           //std::cout << "tccId: " << (tccId+1) << "    towerId: " << towerId
00573           // << "    ps: " << ps << "    numStripInTT: " << numStripInTT[tccId][towerId-1] << std::endl;
00574           
00575       }// loop on TCC constituents
00576 
00577   }// loop on TCC's
00578 
00579   
00580   int   psCounter;
00581   for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++)
00582   {
00583       // resetting pseudostrip counter at each new TCC
00584       psCounter=0;
00585       for (int towerId=0; towerId < EcalTrigTowerDetId::kEBTowersPerSM; towerId++)
00586       {
00587           // if there's not a given towerId, numStripInTT==-1
00588           for (int ps=0; ps<numStripInTT[tccId][towerId]; ps++)
00589           {
00590               tTandPs_[tccId][psCounter][0]=towerId+1;
00591               tTandPs_[tccId][psCounter][1]=ps+1;
00592               psCounter++;
00593           } // loop on TCC's
00594       } // loop on towers in TCC
00595   } // loop in ps in tower
00596   
00597   
00598 //   for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
00599 //       for (int psCounter=0; psCounter<EcalTrigTowerDetId::kEBTowersPerSM*5; psCounter++) {
00600 //           std::cout << "tccId: " << (tccId+1) << "    counter: " << (psCounter+1)
00601 //                     << " tt: " << tTandPs_[tccId][psCounter][0]
00602 //                     << " ps: " << tTandPs_[tccId][psCounter][1]
00603 //                     << std::endl;
00604 //       } } 
00605   
00606   
00607   
00608   // Note:
00609   // for TCC 48 in EE, pseudostrip data in the interval:
00610   // + 1-30 is good pseudostrip data
00611   // + 31-42 is a duplication of the last 12 ps of the previous block, and needs be ignored
00612   // + 43-60 is further good pseudostrip data
00613   
00614   for (int tcc=EcalTriggerElectronicsId::MIN_TCCID_EEM; tcc<=EcalTriggerElectronicsId::MAX_TCCID_EEM; tcc++)
00615   {
00616       int tccId=tcc-1;
00617       short tTandPs_tmp[18][2];
00618 
00619       // store entries _after_ the pseudostrip data which gets duplicated
00620       for (int psCounter=30; psCounter<48; psCounter++) {
00621           tTandPs_tmp[psCounter-30][0] = tTandPs_[tccId][psCounter][0];
00622           tTandPs_tmp[psCounter-30][1] = tTandPs_[tccId][psCounter][1]; }
00623       
00624       // duplication
00625       for (int psCounter=18; psCounter<30; psCounter++) {
00626           tTandPs_[tccId][psCounter+12][0] = tTandPs_[tccId][psCounter][0];
00627           tTandPs_[tccId][psCounter+12][1] = tTandPs_[tccId][psCounter][1]; }
00628       
00629       // append stoed
00630       for (int psCounter=42; psCounter<60; psCounter++) {
00631           tTandPs_[tccId][psCounter][0] = tTandPs_tmp[psCounter-42][0];
00632           tTandPs_[tccId][psCounter][1] = tTandPs_tmp[psCounter-42][1]; }
00633       
00634   }// loop on EEM TCC's
00635 
00636   
00637   for (int tcc=EcalTriggerElectronicsId::MIN_TCCID_EEP; tcc<=EcalTriggerElectronicsId::MAX_TCCID_EEP; tcc++)
00638   {
00639       int tccId=tcc-1;
00640       short tTandPs_tmp[18][2];
00641       
00642       // store entries _after_ the pseudostrip data which gets duplicated
00643       for (int psCounter=30; psCounter<48; psCounter++) {
00644           tTandPs_tmp[psCounter-30][0] = tTandPs_[tccId][psCounter][0];
00645           tTandPs_tmp[psCounter-30][1] = tTandPs_[tccId][psCounter][1]; }
00646       
00647       // duplication
00648       for (int psCounter=18; psCounter<30; psCounter++) {
00649           tTandPs_[tccId][psCounter+12][0] = tTandPs_[tccId][psCounter][0];
00650           tTandPs_[tccId][psCounter+12][1] = tTandPs_[tccId][psCounter][1]; }
00651       
00652       // append stoed
00653       for (int psCounter=42; psCounter<60; psCounter++) {
00654           tTandPs_[tccId][psCounter][0] = tTandPs_tmp[psCounter-42][0];
00655           tTandPs_[tccId][psCounter][1] = tTandPs_tmp[psCounter-42][1]; }
00656       
00657   }// loop on EEP TCC's
00658 
00659   
00660   //for (int tccId=0; tccId<EcalTriggerElectronicsId::MAX_TCCID; tccId++) {
00661   //for (int psCounter=0; psCounter<EcalTrigTowerDetId::kEBTowersPerSM*5; psCounter++) {
00662   //std::cout << "AF tccId: " << (tccId+1) << "    counter: " << (psCounter+1)
00663   //<< " tt: " << tTandPs_[tccId][psCounter][0]
00664   //<< " ps: " << tTandPs_[tccId][psCounter][1]
00665   //<< std::endl;
00666 //} }
00667 
00668 }
00669 
00670 // number of readout channels (TT in EB, SC in EE) in a DCC
00671 const unsigned int  EcalElectronicsMapper::numChannelsInDcc_[NUMB_SM] = {34,32,33,33,32,34,33,41,33,    // EE -
00672                                                                           68,68,68,68,68,68,68,68,68,68, // EB-
00673                                                                           68,68,68,68,68,68,68,68,
00674                                                                           68,68,68,68,68,68,68,68,68,68, // EB+
00675                                                                           68,68,68,68,68,68,68,68,
00676                                                                           34,32,33,33,32,34,33,41,33};   // EE+