Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:42

0001 #include <cstring>
0002 #include <set>
0003 #include "DPGAnalysis/SiStripTools/interface/APVCyclePhaseCollection.h"
0004 
0005 const int APVCyclePhaseCollection::getPhase(const std::string partition) const {
0006   int phase = empty;
0007 
0008   for (std::map<std::string, int>::const_iterator it = _apvmap.begin(); it != _apvmap.end(); it++) {
0009     if (strstr(it->first.c_str(), partition.c_str()) == it->first.c_str() || strcmp(partition.c_str(), "All") == 0) {
0010       if (phase == empty) {
0011         phase = it->second;
0012       } else if (phase != it->second) {
0013         return multiphase;
0014       }
0015     }
0016   }
0017 
0018   if (phase == empty)
0019     return nopartition;
0020   return phase;
0021 }
0022 
0023 const std::vector<int> APVCyclePhaseCollection::getPhases(const std::string partition) const {
0024   std::set<int> phasesset;
0025 
0026   for (std::map<std::string, int>::const_iterator it = _apvmap.begin(); it != _apvmap.end(); it++) {
0027     if (strstr(it->first.c_str(), partition.c_str()) == it->first.c_str() || strcmp(partition.c_str(), "Any") == 0) {
0028       if (it->second >= 0) {
0029         phasesset.insert(it->second);
0030       }
0031     }
0032   }
0033 
0034   std::vector<int> phases;
0035 
0036   for (std::set<int>::const_iterator phase = phasesset.begin(); phase != phasesset.end(); ++phase) {
0037     if (*phase != empty && *phase != invalid) {
0038       phases.push_back(*phase);
0039     }
0040   }
0041 
0042   return phases;
0043 }