CMS 3D CMS Logo

Functions

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DetectorDescription/Core/src/DDsvalues.cc File Reference

#include "DetectorDescription/Core/interface/DDsvalues.h"
#include <iostream>

Go to the source code of this file.

Functions

bool DDfetch (const DDsvalues_type *p, DDValue &v)
 helper for retrieving DDValues from DDsvalues_type *.
unsigned int DDfetch (const std::vector< const DDsvalues_type * > &sp, DDValue &toFetch, std::vector< DDValue > &result)
 helper for retrieving DDValues from a std::vector of (DDsvalues_type *).
void merge (DDsvalues_type &target, DDsvalues_type const &sv, bool sortit)
std::ostream & operator<< (std::ostream &os, const std::vector< const DDsvalues_type * > &v)
std::ostream & operator<< (std::ostream &os, const DDsvalues_type &s)

Function Documentation

bool DDfetch ( const DDsvalues_type p,
DDValue v 
)

helper for retrieving DDValues from DDsvalues_type *.

Example:

   std::vector<std::string> myFunction(const DDsvalues_type * svalptr, const std::string & name) 
   {
      static std::vector<std::string> v; // empty std::vector, for zero result
      DDValue val(name);
      if (DDfetch(svalptr,val)) {
        return val.std::strings(); 
      } else {
       return v;
      }          
   }

Definition at line 102 of file DDsvalues.cc.

References spr::find(), and query::result.

Referenced by DDMapper< KeyType, ValueType >::all(), RPCGeometryBuilderFromDDD::buildGeometry(), DTGeometryParsFromDD::buildGeometry(), DTGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), dddGetStringRaw(), DDfetch(), HFShowerLibrary::getDDDArray(), MaterialBudgetHcalHistos::getDDDArray(), HCalSD::getDDDArray(), HFFibre::getDDDArray(), HFShower::getDDDArray(), HFShowerPMT::getDDDArray(), HFShowerFibreBundle::getDDDArray(), HcalNumberingFromDDD::getDDDArray(), HFShowerParam::getDDDArray(), ECalSD::getDDDArray(), DDG4Builder::getDouble(), DDG4Builder::getInt(), MuonDDDNumbering::getInt(), CaloTrkProcessing::getNames(), CaloTrkProcessing::getNumbers(), DDG4SensitiveConverter::getString(), ExtractStringFromDDD::getString(), ECalSD::getStringArray(), CocoaAnalyzer::myFetchDbl(), CocoaAnalyzer::myFetchString(), DDMapper< KeyType, ValueType >::noSpecifics(), DDMapper< KeyType, ValueType >::toDouble(), DDMapper< KeyType, ValueType >::toString(), and MagGeoBuilderFromDDD::volumeHandle::volumeHandle().

{
  bool result = false;
  DDsvalues_type::const_iterator it = find(*p, v);
  if (it != p->end()) {
    result = true;
    v = it->second;
  }
  return result;
}
unsigned int DDfetch ( const std::vector< const DDsvalues_type * > &  sp,
DDValue toFetch,
std::vector< DDValue > &  result 
)

helper for retrieving DDValues from a std::vector of (DDsvalues_type *).

Definition at line 114 of file DDsvalues.cc.

References prof2calltree::count, and DDfetch().

{
   unsigned int count = 0;
   std::vector<const DDsvalues_type *>::const_iterator it(sp.begin()), ed(sp.end());
   for (; it != ed; ++it) {
     if (DDfetch(*it, toFetch)) {
       result.push_back(toFetch);
       ++count;
     }
   }    
   return count;
}
void merge ( DDsvalues_type target,
DDsvalues_type const &  sv,
bool  sortit 
)

Definition at line 21 of file DDsvalues.cc.

References cmsDriverOptions::counter, spr::find(), and python::multivaluedict::sort().

                                                                              {
  static Counter counter = {0,0,0,0,0};
  if (target.empty()) {
    ++counter.empty;
    target = sv; 
    return;
  }
  DDsvalues_type::const_iterator sit = sv.begin();
  DDsvalues_type::const_iterator sed = sv.end();
  // fast merge
  if (target.back()<sv.front()) {
    ++counter.end;
    target.insert(target.end(),sit,sed);
    return;
  }
  if (sv.back()<target.front()) {
    ++counter.begin;
    target.insert(target.begin(),sit,sed);
    return;
  }
  {
    DDsvalues_type::iterator it = std::lower_bound(target.begin(),target.end(),sv.front()); 
    if (it == std::lower_bound(target.begin(),target.end(),sv.back())) {
      ++counter.middle; 
      target.insert(it,sit,sed);
      return;
    }
  }
  // it nevers arrives here...
  ++counter.mixed;
  target.reserve(target.size()+sv.size());
  DDsvalues_type::const_iterator ted = target.end();
  for (; sit != sed; ++sit) {
    DDsvalues_type::const_iterator it = find(target.begin(),ted, (*sit).first);
    if (it!=ted) const_cast<DDsvalues_Content_type&>(*it).second = (*sit).second;
    else target.push_back(*sit);
  }
  if (sortit) std::sort(target.begin(),target.end());
}
std::ostream& operator<< ( std::ostream &  os,
const std::vector< const DDsvalues_type * > &  v 
)

Definition at line 79 of file DDsvalues.cc.

References i, and v.

{
   for (unsigned int i=0; i<v.size() ; ++i) {
     os << *(v[i]); // << std::endl;
   }
   
   return os;
}
std::ostream& operator<< ( std::ostream &  os,
const DDsvalues_type s 
)

Definition at line 62 of file DDsvalues.cc.

{
  DDsvalues_type::const_iterator it = s.begin();
  for(; it != s.end(); ++it)  {
    os << it->second; 
    /*
    os << DDValue(it->first).name() << " = ";
    for (unsigned int i=0; i<it->second.size(); ++i) {
       os << it->second[i] << ' ';
    }    
    os << std::endl;
    */
  }  
  return os;
}