Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:00:05

0001 #include "CaloOnlineTools/EcalTools/interface/EcalFedMap.h"
0002 #include <iostream>
0003 #include <cctype>  // for toupper
0004 #include <algorithm>
0005 
0006 EcalFedMap::~EcalFedMap() {}
0007 
0008 EcalFedMap::EcalFedMap() {
0009   // EE-
0010   fedToSliceMap_.insert(std::make_pair(601, "EE-07"));
0011   fedToSliceMap_.insert(std::make_pair(602, "EE-08"));
0012   fedToSliceMap_.insert(std::make_pair(603, "EE-09"));
0013   fedToSliceMap_.insert(std::make_pair(604, "EE-01"));
0014   fedToSliceMap_.insert(std::make_pair(605, "EE-02"));
0015   fedToSliceMap_.insert(std::make_pair(606, "EE-03"));
0016   fedToSliceMap_.insert(std::make_pair(607, "EE-04"));
0017   fedToSliceMap_.insert(std::make_pair(608, "EE-05"));
0018   fedToSliceMap_.insert(std::make_pair(609, "EE-06"));
0019 
0020   // EB-
0021   fedToSliceMap_.insert(std::make_pair(610, "EB-01"));
0022   fedToSliceMap_.insert(std::make_pair(611, "EB-02"));
0023   fedToSliceMap_.insert(std::make_pair(612, "EB-03"));
0024   fedToSliceMap_.insert(std::make_pair(613, "EB-04"));
0025   fedToSliceMap_.insert(std::make_pair(614, "EB-05"));
0026   fedToSliceMap_.insert(std::make_pair(615, "EB-06"));
0027   fedToSliceMap_.insert(std::make_pair(616, "EB-07"));
0028   fedToSliceMap_.insert(std::make_pair(617, "EB-08"));
0029   fedToSliceMap_.insert(std::make_pair(618, "EB-09"));
0030   fedToSliceMap_.insert(std::make_pair(619, "EB-10"));
0031   fedToSliceMap_.insert(std::make_pair(620, "EB-11"));
0032   fedToSliceMap_.insert(std::make_pair(621, "EB-12"));
0033   fedToSliceMap_.insert(std::make_pair(622, "EB-13"));
0034   fedToSliceMap_.insert(std::make_pair(623, "EB-14"));
0035   fedToSliceMap_.insert(std::make_pair(624, "EB-15"));
0036   fedToSliceMap_.insert(std::make_pair(625, "EB-16"));
0037   fedToSliceMap_.insert(std::make_pair(626, "EB-17"));
0038   fedToSliceMap_.insert(std::make_pair(627, "EB-18"));
0039 
0040   // EB+
0041   fedToSliceMap_.insert(std::make_pair(628, "EB+01"));
0042   fedToSliceMap_.insert(std::make_pair(629, "EB+02"));
0043   fedToSliceMap_.insert(std::make_pair(630, "EB+03"));
0044   fedToSliceMap_.insert(std::make_pair(631, "EB+04"));
0045   fedToSliceMap_.insert(std::make_pair(632, "EB+05"));
0046   fedToSliceMap_.insert(std::make_pair(633, "EB+06"));
0047   fedToSliceMap_.insert(std::make_pair(634, "EB+07"));
0048   fedToSliceMap_.insert(std::make_pair(635, "EB+08"));
0049   fedToSliceMap_.insert(std::make_pair(636, "EB+09"));
0050   fedToSliceMap_.insert(std::make_pair(637, "EB+10"));
0051   fedToSliceMap_.insert(std::make_pair(638, "EB+11"));
0052   fedToSliceMap_.insert(std::make_pair(639, "EB+12"));
0053   fedToSliceMap_.insert(std::make_pair(640, "EB+13"));
0054   fedToSliceMap_.insert(std::make_pair(641, "EB+14"));
0055   fedToSliceMap_.insert(std::make_pair(642, "EB+15"));
0056   fedToSliceMap_.insert(std::make_pair(643, "EB+16"));
0057   fedToSliceMap_.insert(std::make_pair(644, "EB+17"));
0058   fedToSliceMap_.insert(std::make_pair(645, "EB+18"));
0059 
0060   // EE+
0061   fedToSliceMap_.insert(std::make_pair(646, "EE+07"));
0062   fedToSliceMap_.insert(std::make_pair(647, "EE+08"));
0063   fedToSliceMap_.insert(std::make_pair(648, "EE+09"));
0064   fedToSliceMap_.insert(std::make_pair(649, "EE+01"));
0065   fedToSliceMap_.insert(std::make_pair(650, "EE+02"));
0066   fedToSliceMap_.insert(std::make_pair(651, "EE+03"));
0067   fedToSliceMap_.insert(std::make_pair(652, "EE+04"));
0068   fedToSliceMap_.insert(std::make_pair(653, "EE+05"));
0069   fedToSliceMap_.insert(std::make_pair(654, "EE+06"));
0070 
0071   std::map<int, std::string>::iterator it;
0072   for (it = fedToSliceMap_.begin(); it != fedToSliceMap_.end(); it++) {
0073     //  std::cout<<  "fed: "<< (*it).first << " slice: " << (*it).second << std::endl;
0074     sliceToFedMap_.insert(std::make_pair((*it).second, (*it).first));
0075   }
0076 
0077   //  std::map<std::string, int>::iterator ti;
0078   //  for (ti = sliceToFedMap_.begin();
0079   //       ti != sliceToFedMap_.end();
0080   //       ti++)
0081   //    {
0082   //      //      std::cout<<  "slice: "<< (*ti).first << " fed: " << (*ti).second << std::endl;
0083   //    }
0084 }
0085 
0086 std::string EcalFedMap::getSliceFromFed(int fedNumber) {
0087   //std::cout << "received: " << fedNumber << std::endl;
0088   std::map<int, std::string>::iterator found = fedToSliceMap_.find(fedNumber);
0089 
0090   if (found != fedToSliceMap_.end())
0091     return (*found).second;
0092   else
0093     return std::string("invalid Fed");
0094 }
0095 
0096 int EcalFedMap::getFedFromSlice(std::string slice) {
0097   transform(slice.begin(), slice.end(), slice.begin(), toupper);
0098 
0099   std::map<std::string, int>::iterator found = sliceToFedMap_.find(slice);
0100 
0101   if (found != sliceToFedMap_.end())
0102     return (*found).second;
0103   else
0104     return -999;
0105 }