CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CaloOnlineTools/EcalTools/src/EcalFedMap.cc

Go to the documentation of this file.
00001 #include "CaloOnlineTools/EcalTools/interface/EcalFedMap.h"
00002 #include <iostream>
00003 #include <cctype> // for toupper
00004 #include <algorithm>
00005 
00006 EcalFedMap::~EcalFedMap(){}
00007 
00008 EcalFedMap::EcalFedMap(){
00009 
00010   // EE-
00011   fedToSliceMap_.insert( std::make_pair(601, "EE-07") );
00012   fedToSliceMap_.insert( std::make_pair(602, "EE-08") );
00013   fedToSliceMap_.insert( std::make_pair(603, "EE-09") );
00014   fedToSliceMap_.insert( std::make_pair(604, "EE-01") );
00015   fedToSliceMap_.insert( std::make_pair(605, "EE-02") );
00016   fedToSliceMap_.insert( std::make_pair(606, "EE-03") );
00017   fedToSliceMap_.insert( std::make_pair(607, "EE-04") );
00018   fedToSliceMap_.insert( std::make_pair(608, "EE-05") );
00019   fedToSliceMap_.insert( std::make_pair(609, "EE-06") );
00020 
00021   // EB-
00022   fedToSliceMap_.insert( std::make_pair(610, "EB-01") );
00023   fedToSliceMap_.insert( std::make_pair(611, "EB-02") );
00024   fedToSliceMap_.insert( std::make_pair(612, "EB-03") );
00025   fedToSliceMap_.insert( std::make_pair(613, "EB-04") );
00026   fedToSliceMap_.insert( std::make_pair(614, "EB-05") );
00027   fedToSliceMap_.insert( std::make_pair(615, "EB-06") );
00028   fedToSliceMap_.insert( std::make_pair(616, "EB-07") );
00029   fedToSliceMap_.insert( std::make_pair(617, "EB-08") );
00030   fedToSliceMap_.insert( std::make_pair(618, "EB-09") );
00031   fedToSliceMap_.insert( std::make_pair(619, "EB-10") );
00032   fedToSliceMap_.insert( std::make_pair(620, "EB-11") );
00033   fedToSliceMap_.insert( std::make_pair(621, "EB-12") );
00034   fedToSliceMap_.insert( std::make_pair(622, "EB-13") );
00035   fedToSliceMap_.insert( std::make_pair(623, "EB-14") );
00036   fedToSliceMap_.insert( std::make_pair(624, "EB-15") );
00037   fedToSliceMap_.insert( std::make_pair(625, "EB-16") );
00038   fedToSliceMap_.insert( std::make_pair(626, "EB-17") );
00039   fedToSliceMap_.insert( std::make_pair(627, "EB-18") );
00040 
00041   // EB+
00042   fedToSliceMap_.insert( std::make_pair(628, "EB+01") );
00043   fedToSliceMap_.insert( std::make_pair(629, "EB+02") );
00044   fedToSliceMap_.insert( std::make_pair(630, "EB+03") );
00045   fedToSliceMap_.insert( std::make_pair(631, "EB+04") );
00046   fedToSliceMap_.insert( std::make_pair(632, "EB+05") );
00047   fedToSliceMap_.insert( std::make_pair(633, "EB+06") );
00048   fedToSliceMap_.insert( std::make_pair(634, "EB+07") );
00049   fedToSliceMap_.insert( std::make_pair(635, "EB+08") );
00050   fedToSliceMap_.insert( std::make_pair(636, "EB+09") );
00051   fedToSliceMap_.insert( std::make_pair(637, "EB+10") );
00052   fedToSliceMap_.insert( std::make_pair(638, "EB+11") );
00053   fedToSliceMap_.insert( std::make_pair(639, "EB+12") );
00054   fedToSliceMap_.insert( std::make_pair(640, "EB+13") );
00055   fedToSliceMap_.insert( std::make_pair(641, "EB+14") );
00056   fedToSliceMap_.insert( std::make_pair(642, "EB+15") );
00057   fedToSliceMap_.insert( std::make_pair(643, "EB+16") );
00058   fedToSliceMap_.insert( std::make_pair(644, "EB+17") );
00059   fedToSliceMap_.insert( std::make_pair(645, "EB+18") );
00060 
00061   // EE+
00062   fedToSliceMap_.insert( std::make_pair(646, "EE+07") );
00063   fedToSliceMap_.insert( std::make_pair(647, "EE+08") );
00064   fedToSliceMap_.insert( std::make_pair(648, "EE+09") );
00065   fedToSliceMap_.insert( std::make_pair(649, "EE+01") );
00066   fedToSliceMap_.insert( std::make_pair(650, "EE+02") );
00067   fedToSliceMap_.insert( std::make_pair(651, "EE+03") );
00068   fedToSliceMap_.insert( std::make_pair(652, "EE+04") );
00069   fedToSliceMap_.insert( std::make_pair(653, "EE+05") );
00070   fedToSliceMap_.insert( std::make_pair(654, "EE+06") );
00071 
00072 
00073   std::map<int, std::string>::iterator it;
00074   for (it = fedToSliceMap_.begin();
00075        it != fedToSliceMap_.end();
00076        it++)
00077     {
00078       //  std::cout<<  "fed: "<< (*it).first << " slice: " << (*it).second << std::endl;
00079       sliceToFedMap_.insert( std::make_pair( (*it).second, (*it).first) );
00080     }
00081 
00082   //  std::map<std::string, int>::iterator ti;
00083   //  for (ti = sliceToFedMap_.begin();
00084   //       ti != sliceToFedMap_.end();
00085   //       ti++)
00086   //    {
00087   //      //      std::cout<<  "slice: "<< (*ti).first << " fed: " << (*ti).second << std::endl;
00088   //    }
00089 
00090 }
00091 
00092 
00093 std::string EcalFedMap::getSliceFromFed(int fedNumber)
00094 {
00095   //std::cout << "received: " << fedNumber << std::endl;
00096   std::map< int, std::string >::iterator found  = fedToSliceMap_.find(fedNumber);
00097   
00098   if ( found != fedToSliceMap_.end() ) 
00099     return (* found).second;
00100   else
00101     return std::string("invalid Fed");
00102 }
00103 
00104 int EcalFedMap::getFedFromSlice(std::string slice)
00105 {
00106 
00107   transform(slice.begin(), slice.end(), slice.begin(), toupper);
00108 
00109   std::map< std::string , int>::iterator found  = sliceToFedMap_.find(slice);
00110   
00111   if ( found != sliceToFedMap_.end() ) 
00112     return (* found).second;
00113   else
00114     return -999;
00115 }