File indexing completed on 2024-04-06 12:14:23
0001 #include "Utilities/General/interface/precomputed_value_sort.h"
0002 #include "Geometry/CommonTopologies/interface/GeomDet.h"
0003 #include "Geometry/CommonTopologies/interface/DetSorting.h"
0004 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
0005 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008 #include <iostream>
0009 #include <iterator>
0010
0011 using namespace std;
0012 using namespace geomsort;
0013
0014 typedef Surface::PositionType PositionType;
0015 typedef Surface::RotationType RotationType;
0016
0017
0018
0019 class MyDet : public GeomDet {
0020 public:
0021 MyDet(const PositionType& pos) : GeomDet(new BoundPlane(pos, RotationType(), new RectangularPlaneBounds(0, 0, 0))) {}
0022
0023 virtual DetId geographicalId() const { return DetId(); }
0024 std::vector<const GeomDet*> components() const override { return std::vector<const GeomDet*>(); }
0025
0026
0027 SubDetector subDetector() const override { return GeomDetEnumerators::DT; }
0028 };
0029
0030
0031 struct dump {
0032 void operator()(const GeomDet& o) {
0033 edm::LogVerbatim("CommonTopologies") << o.position() << " R : " << o.position().perp()
0034 << " Phi: " << o.position().phi() << " Z : " << o.position().z();
0035 }
0036 void operator()(const GeomDet* o) { operator()(*o); }
0037 };
0038
0039 int main() {
0040
0041
0042
0043
0044
0045 std::vector<MyDet> v;
0046 v.emplace_back(MyDet(PositionType(2, 1, 1)));
0047 v.emplace_back(MyDet(PositionType(1, 1, 2)));
0048 v.emplace_back(MyDet(PositionType(1, 2, 3)));
0049 v.emplace_back(MyDet(PositionType(2, 2, 4)));
0050
0051 edm::LogVerbatim("CommonTopologies") << "Original vector: ";
0052 for_each(v.begin(), v.end(), dump());
0053
0054 edm::LogVerbatim("CommonTopologies") << "Sort in R : ";
0055
0056 precomputed_value_sort(v.begin(), v.end(), DetR());
0057 for_each(v.begin(), v.end(), dump());
0058
0059 edm::LogVerbatim("CommonTopologies") << "Sort in phi : ";
0060
0061 precomputed_value_sort(v.begin(), v.end(), DetPhi());
0062 for_each(v.begin(), v.end(), dump());
0063
0064 edm::LogVerbatim("CommonTopologies") << "Sort in z : ";
0065
0066 precomputed_value_sort(v.begin(), v.end(), DetZ());
0067 for_each(v.begin(), v.end(), dump());
0068
0069
0070
0071
0072 edm::LogVerbatim("CommonTopologies") << std::endl << "Again with pointers";
0073
0074 std::vector<const MyDet*> vp;
0075 for (std::vector<MyDet>::const_iterator i = v.begin(); i != v.end(); i++) {
0076 vp.emplace_back(&(*i));
0077 }
0078
0079 edm::LogVerbatim("CommonTopologies") << "Sort in R : ";
0080
0081 precomputed_value_sort(vp.begin(), vp.end(), DetR());
0082 for_each(vp.begin(), vp.end(), dump());
0083
0084 edm::LogVerbatim("CommonTopologies") << "Sort in phi : ";
0085
0086 precomputed_value_sort(vp.begin(), vp.end(), DetPhi());
0087 for_each(vp.begin(), vp.end(), dump());
0088
0089 edm::LogVerbatim("CommonTopologies") << "Sort in z : ";
0090
0091 precomputed_value_sort(vp.begin(), vp.end(), DetZ());
0092 for_each(vp.begin(), vp.end(), dump());
0093
0094 return 0;
0095 }