CMS 3D CMS Logo

Typedefs | Functions

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DetectorDescription/Core/interface/DDsvalues.h File Reference

#include <ostream>
#include <map>
#include <vector>
#include <algorithm>
#include "DetectorDescription/Core/interface/DDValue.h"

Go to the source code of this file.

Typedefs

typedef DDsvalues_type::value_type DDsvalues_Content_type
typedef std::vector< std::pair
< unsigned int, DDValue > > 
DDsvalues_type
 std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::mapped DDValue.

Functions

bool DDfetch (const DDsvalues_type *, DDValue &)
 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 *).
DDsvalues_type::const_iterator find (DDsvalues_type::const_iterator begin, DDsvalues_type::const_iterator end, unsigned int id)
DDsvalues_type::const_iterator find (DDsvalues_type const &sv, unsigned int id)
void merge (DDsvalues_type &target, DDsvalues_type const &sv, bool sortit=true)
bool operator< (const DDsvalues_Content_type &lh, const DDsvalues_Content_type &rh)
std::ostream & operator<< (std::ostream &, const std::vector< const DDsvalues_type * > &)
std::ostream & operator<< (std::ostream &, const DDsvalues_type &)

Typedef Documentation

typedef DDsvalues_type::value_type DDsvalues_Content_type

Definition at line 20 of file DDsvalues.h.

typedef std::vector< std::pair<unsigned int, DDValue> > DDsvalues_type

std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::mapped DDValue.

Definition at line 19 of file DDsvalues.h.


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;
}
DDsvalues_type::const_iterator find ( DDsvalues_type::const_iterator  begin,
DDsvalues_type::const_iterator  end,
unsigned int  id 
) [inline]

Definition at line 30 of file DDsvalues.h.

References end, and v.

                                                                                                                                 {
   static DDValue dummy;
   DDsvalues_Content_type v(id,dummy);
   DDsvalues_type::const_iterator it = std::lower_bound(begin,end,v);
   if (it!=end && (*it).first==id) return it;
   return end; 
}
DDsvalues_type::const_iterator find ( DDsvalues_type const &  sv,
unsigned int  id 
) [inline]

Definition at line 38 of file DDsvalues.h.

References spr::find(), and ExpressReco_HICollisions_FallBack::id.

                                                                                     {
  return find(sv.begin(),sv.end(),id);
}
void merge ( DDsvalues_type target,
DDsvalues_type const &  sv,
bool  sortit = true 
)

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());
}
bool operator< ( const DDsvalues_Content_type lh,
const DDsvalues_Content_type rh 
) [inline]

Definition at line 26 of file DDsvalues.h.

                                                                                           {
   return lh.first < rh.first;
}
std::ostream& operator<< ( std::ostream &  ,
const std::vector< const DDsvalues_type * > &   
)

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 &  ,
const DDsvalues_type  
)

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;
}