CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DPGAnalysis/SiStripTools/src/APVCyclePhaseCollection.cc

Go to the documentation of this file.
00001 #include <string.h>
00002 #include <set>
00003 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
00004 
00005 const int APVCyclePhaseCollection::getPhase(const std::string partition) const {
00006 
00007   int phase = invalid;
00008 
00009   for(std::map<std::string,int>::const_iterator it=_apvmap.begin();it!=_apvmap.end();it++) {
00010     if(strstr(it->first.c_str(),partition.c_str())==it->first.c_str() || strcmp(partition.c_str(),"All")==0 ) {
00011       if(phase==invalid ) {
00012         phase = it->second;
00013       }
00014       else if(phase!=it->second) {
00015         return multiphase;
00016       }
00017     }
00018   }
00019 
00020   if(phase==invalid) return nopartition;
00021   return phase;
00022 
00023 
00024 }
00025 
00026 const std::vector<int> APVCyclePhaseCollection::getPhases(const std::string partition) const {
00027 
00028   std::set<int> phasesset;
00029 
00030   for(std::map<std::string,int>::const_iterator it=_apvmap.begin();it!=_apvmap.end();it++) {
00031     if(strstr(it->first.c_str(),partition.c_str())==it->first.c_str() || strcmp(partition.c_str(),"Any")==0 ) {
00032       if(it->second>=0 ) {
00033         phasesset.insert(it->second);
00034       }
00035     }
00036   }
00037 
00038   std::vector<int> phases;
00039   
00040   for(std::set<int>::const_iterator phase=phasesset.begin();phase!=phasesset.end();++phase) {
00041     phases.push_back(*phase);
00042   }
00043 
00044   return phases;
00045 
00046 
00047 }
00048