File indexing completed on 2023-03-17 10:49:58
0001 #include "Utilities/General/interface/precomputed_value_sort.h"
0002 #include "DataFormats/GeometrySurface/interface/Plane.h"
0003 #include "DataFormats/GeometrySurface/interface/GeometricSorting.h"
0004 #include <iostream>
0005 #include <iterator>
0006
0007 using namespace std;
0008 using namespace geomsort;
0009
0010 typedef Surface::PositionType PositionType;
0011 typedef Surface::RotationType RotationType;
0012
0013
0014 struct dump {
0015 void operator()(const Surface& o) {
0016 cout << o.position() << " R : " << o.position().perp() << " Phi: " << o.position().phi()
0017 << " Z : " << o.position().z() << endl;
0018 }
0019 void operator()(const std::unique_ptr<Surface>& o) { operator()(*o); }
0020 void operator()(const Surface* o) { operator()(*o); }
0021 };
0022
0023 int main() {
0024 using Pointer = std::unique_ptr<Surface>;
0025
0026
0027
0028
0029
0030 vector<Pointer> v;
0031 v.push_back(Pointer(new Plane(PositionType(2, 1, 1), RotationType())));
0032 v.push_back(Pointer(new Plane(PositionType(1, 1, 2), RotationType())));
0033 v.push_back(Pointer(new Plane(PositionType(1, 2, 3), RotationType())));
0034 v.push_back(Pointer(new Plane(PositionType(2, 2, 4), RotationType())));
0035
0036 cout << "Original vector: " << endl;
0037 for_each(v.begin(), v.end(), dump());
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 cout << endl << "Again with pointers" << endl;
0060
0061 vector<const Surface*> vp;
0062 for (auto i = v.begin(); i != v.end(); i++) {
0063 vp.push_back(&(**i));
0064 }
0065
0066 cout << "Sort in R : " << endl;
0067
0068 precomputed_value_sort(vp.begin(), vp.end(), ExtractR<Surface>());
0069 for_each(vp.begin(), vp.end(), dump());
0070
0071 cout << "Sort in phi : " << endl;
0072
0073 precomputed_value_sort(vp.begin(), vp.end(), ExtractPhi<Surface>());
0074 for_each(vp.begin(), vp.end(), dump());
0075
0076 cout << "Sort in z : " << endl;
0077
0078 precomputed_value_sort(vp.begin(), vp.end(), ExtractZ<Surface>());
0079 for_each(vp.begin(), vp.end(), dump());
0080
0081 return 0;
0082 }