CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Geometry/MuonNumbering/src/MuonBaseNumber.cc

Go to the documentation of this file.
00001 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include <iostream>
00004 
00005 //#define LOCAL_DEBUG
00006 
00007 void MuonBaseNumber::addBase(LevelBaseNumber num){
00008   basenumber_type::iterator cur=sortedBaseNumber.begin();
00009   basenumber_type::iterator end=sortedBaseNumber.end();
00010 
00011   // do a small check if level is already occupied
00012 
00013   while (cur!=end) {
00014     if (num.level()==(*cur).level()) {
00015       LogDebug("MuonBaseNumber") << "MuonBaseNumber::addBase was asked to add "
00016            <<num.level()<<" "
00017            <<num.super()<<" "
00018            <<num.base()
00019            <<" to existing level "
00020            <<(*cur).level()<<" "
00021            <<(*cur).super()<<" "
00022            <<(*cur).base() << " but refused.";
00023       return; // don't overwrite current volume stored
00024     }
00025     cur++;
00026   }
00027 
00028   cur=sortedBaseNumber.begin();
00029   while (cur!=end) {
00030     if (num.level()<(*cur).level()) break;
00031     cur++;
00032   }
00033   sortedBaseNumber.insert(cur,num);
00034 
00035 #ifdef LOCAL_DEBUG
00036   cur=sortedBaseNumber.begin();
00037   end=sortedBaseNumber.end();
00038   std::cout << "MuonBaseNumber::AddBase ";
00039   while (cur!=end) {
00040     std::cout<<(*cur).level()<<" ";
00041     std::cout<<(*cur).super()<<" ";
00042     std::cout<<(*cur).base();
00043     std::cout<<",";
00044     cur++;
00045   }
00046   std::cout <<std::endl;
00047 #endif
00048 
00049 }
00050 
00051 void MuonBaseNumber::addBase(const int level,const int super,const int base){
00052   LevelBaseNumber num(level,super,base);
00053   addBase(num);
00054 }
00055 
00056 int MuonBaseNumber::getLevels() const {
00057   return sortedBaseNumber.size();
00058 }
00059 
00060 int MuonBaseNumber::getSuperNo(int level) const {
00061   basenumber_type::const_iterator cur=sortedBaseNumber.begin();
00062   basenumber_type::const_iterator end=sortedBaseNumber.end();
00063   while (cur!=end) {
00064     if ((*cur).level()==level) {
00065       return (*cur).super();
00066     }
00067     cur++;
00068   }
00069   return 0;
00070 }
00071 
00072 int MuonBaseNumber::getBaseNo(int level) const {
00073   basenumber_type::const_iterator cur=sortedBaseNumber.begin();
00074   basenumber_type::const_iterator end=sortedBaseNumber.end();
00075   while (cur!=end) {
00076     if ((*cur).level()==level) {
00077       return (*cur).base();
00078     }
00079     cur++;
00080   }
00081   return 0;
00082 }
00083 
00084 
00085 
00086 
00087