CMS 3D CMS Logo

Typedefs | Functions
DDsvalues.h File Reference
#include <algorithm>
#include <map>
#include <ostream>
#include <utility>
#include <vector>
#include "DetectorDescription/Core/interface/DDValue.h"

Go to the source code of this file.

Typedefs

using DDsvalues_Content_type = DDsvalues_type::value_type
 
using DDsvalues_type = std::vector< std::pair< unsigned int, DDValue > >
 

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

using DDsvalues_Content_type = DDsvalues_type::value_type

Definition at line 13 of file DDsvalues.h.

using DDsvalues_type = std::vector< std::pair<unsigned int, DDValue> >

Definition at line 12 of file DDsvalues.h.

Function Documentation

bool DDfetch ( const DDsvalues_type p,
DDValue v 
)

helper for retrieving DDValues from DDsvalues_type *.

Example:

1 std::vector<std::string> myFunction(const DDsvalues_type * svalptr, const std::string & name)
2 {
3  static std::vector<std::string> v; // empty std::vector, for zero result
4  DDValue val(name);
5  if (DDfetch(svalptr,val)) {
6  return val.std::strings();
7  } else {
8  return v;
9  }
10 }

Definition at line 81 of file DDsvalues.cc.

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

Referenced by DDMapper< KeyType, ValueType >::all(), ME0GeometryParsFromDD::buildEtaPartition(), GEMGeometryParsFromDD::buildEtaPartition(), ME0GeometryBuilderFromDDD::buildEtaPartition(), GEMGeometryBuilderFromDDD::buildEtaPartition(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), DTGeometryParsFromDD::buildGeometry(), DTGeometryBuilderFromDDD::buildGeometry(), dddGetStringRaw(), DDfetch(), find(), FastTimeParametersFromDD::getDDDArray(), HGCalParametersFromDD::getDDDArray(), HFShowerFibreBundle::getDDDArray(), HFShowerPMT::getDDDArray(), HFFibre::getDDDArray(), MtdSD::getDDDArray(), MaterialBudgetHcalHistos::getDDDArray(), FastTimerSD::getDDDArray(), HFShower::getDDDArray(), HFShowerParam::getDDDArray(), ECalSD::getDDDArray(), HGCalGeomParameters::getDDDArray(), HFShowerLibrary::getDDDArray(), HCalSD::getDDDArray(), HGCalParametersFromDD::getDDDValue(), DDG4Builder::getDouble(), DDG4Builder::getInt(), MuonDDDNumbering::getInt(), CaloTrkProcessing::getNames(), CaloTrkProcessing::getNumbers(), DDG4SensitiveConverter::getString(), ECalSD::getStringArray(), DDMapper< KeyType, ValueType >::noSpecifics(), DDMapper< KeyType, ValueType >::toDouble(), and DDMapper< KeyType, ValueType >::toString().

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

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

94 {
95  unsigned int count = 0;
96  for( const auto & it : sp ) {
97  if (DDfetch( it, toFetch)) {
98  result.emplace_back(toFetch);
99  ++count;
100  }
101  }
102  return count;
103 }
bool DDfetch(const DDsvalues_type *p, DDValue &v)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
DDsvalues_type::const_iterator find ( DDsvalues_type::const_iterator  begin,
DDsvalues_type::const_iterator  end,
unsigned int  id 
)
inline

Definition at line 19 of file DDsvalues.h.

References end, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, and findQualityFiles::v.

Referenced by find().

19  {
20  static const DDValue dummy;
21  DDsvalues_Content_type v( id, dummy );
22  DDsvalues_type::const_iterator it = std::lower_bound( begin, end, v );
23  if( it != end && (*it).first == id ) return it;
24  return end;
25 }
DDsvalues_type::value_type DDsvalues_Content_type
Definition: DDsvalues.h:13
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
DDsvalues_type::const_iterator find ( DDsvalues_type const &  sv,
unsigned int  id 
)
inline

Definition at line 27 of file DDsvalues.h.

References DDfetch(), find(), triggerObjects_cff::id, merge(), operator<<(), mps_fire::result, pfDeepBoostedJetPreprocessParams_cfi::sv, and edmPickEvents::target.

27  {
28  return find( sv.begin(), sv.end(), id );
29 }
DDsvalues_type::const_iterator find(DDsvalues_type::const_iterator begin, DDsvalues_type::const_iterator end, unsigned int id)
Definition: DDsvalues.h:19
void merge ( DDsvalues_type target,
DDsvalues_type const &  sv,
bool  sortit = true 
)

Definition at line 5 of file DDsvalues.cc.

References spr::find(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, jetUpdater_cfi::sort, and pfDeepBoostedJetPreprocessParams_cfi::sv.

Referenced by find().

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

Definition at line 15 of file DDsvalues.h.

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

Definition at line 41 of file DDsvalues.cc.

Referenced by find().

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

Definition at line 58 of file DDsvalues.cc.

References mps_fire::i, and findQualityFiles::v.

59 {
60  for (const auto & i : v) {
61  os << *i; // << std::endl;
62  }
63 
64  return os;
65 }