test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Typedefs | Functions
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. More...
 

Functions

bool DDfetch (const DDsvalues_type *, DDValue &)
 helper for retrieving DDValues from DDsvalues_type *. More...
 
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 *). More...
 
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 DDsvalues_type &)
 
std::ostream & operator<< (std::ostream &, const std::vector< 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 80 of file DDsvalues.cc.

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

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

81 {
82  bool result = false;
83  DDsvalues_type::const_iterator it = find(*p, v);
84  if (it != p->end()) {
85  result = true;
86  v = it->second;
87  }
88  return result;
89 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
tuple result
Definition: mps_fire.py:83
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 92 of file DDsvalues.cc.

References KineDebug3::count(), and DDfetch().

93 {
94  unsigned int count = 0;
95  for( const auto & it : sp ) {
96  if (DDfetch( it, toFetch)) {
97  result.push_back(toFetch);
98  ++count;
99  }
100  }
101  return count;
102 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:83
Definition: sp.h:21
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 findQualityFiles::v.

30  {
31  static const DDValue dummy;
32  DDsvalues_Content_type v(id,dummy);
33  DDsvalues_type::const_iterator it = std::lower_bound(begin,end,v);
34  if (it!=end && (*it).first==id) return it;
35  return end;
36 }
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:20
DDsvalues_type::const_iterator find ( DDsvalues_type const &  sv,
unsigned int  id 
)
inline

Definition at line 38 of file DDsvalues.h.

References spr::find().

38  {
39  return find(sv.begin(),sv.end(),id);
40 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void merge ( DDsvalues_type target,
DDsvalues_type const &  sv,
bool  sortit = true 
)

Definition at line 5 of file DDsvalues.cc.

References spr::find().

5  {
6  if (target.empty()) {
7  target = sv;
8  return;
9  }
10  DDsvalues_type::const_iterator sit = sv.begin();
11  DDsvalues_type::const_iterator sed = sv.end();
12  // fast merge
13  if (target.back()<sv.front()) {
14  target.insert(target.end(),sit,sed);
15  return;
16  }
17  if (sv.back()<target.front()) {
18  target.insert(target.begin(),sit,sed);
19  return;
20  }
21  {
22  DDsvalues_type::iterator it = std::lower_bound(target.begin(),target.end(),sv.front());
23  if (it == std::lower_bound(target.begin(),target.end(),sv.back())) {
24  target.insert(it,sit,sed);
25  return;
26  }
27  }
28  // it nevers arrives here...
29  target.reserve(target.size()+sv.size());
30  DDsvalues_type::const_iterator ted = target.end();
31  for (; sit != sed; ++sit) {
32  DDsvalues_type::const_iterator it = find(target.begin(),ted, (*sit).first);
33  if (it!=ted) const_cast<DDsvalues_Content_type&>(*it).second = (*sit).second;
34  else target.push_back(*sit);
35  }
36  if (sortit) std::sort(target.begin(),target.end());
37 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:20
bool operator< ( const DDsvalues_Content_type lh,
const DDsvalues_Content_type rh 
)
inline

Definition at line 26 of file DDsvalues.h.

26  {
27  return lh.first < rh.first;
28 }
bool int lh
Definition: SIMDVec.h:21
std::ostream& operator<< ( std::ostream &  ,
const DDsvalues_type  
)

Definition at line 40 of file DDsvalues.cc.

41 {
42  DDsvalues_type::const_iterator it = s.begin();
43  for(; it != s.end(); ++it) {
44  os << it->second;
45  /*
46  os << DDValue(it->first).name() << " = ";
47  for (unsigned int i=0; i<it->second.size(); ++i) {
48  os << it->second[i] << ' ';
49  }
50  os << std::endl;
51  */
52  }
53  return os;
54 }
std::ostream& operator<< ( std::ostream &  ,
const std::vector< const DDsvalues_type * > &   
)

Definition at line 57 of file DDsvalues.cc.

References i, and findQualityFiles::v.

58 {
59  for (unsigned int i=0; i<v.size() ; ++i) {
60  os << *(v[i]); // << std::endl;
61  }
62 
63  return os;
64 }
int i
Definition: DBlmapReader.cc:9