-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortTest.cxx
More file actions
57 lines (46 loc) · 1.35 KB
/
Copy pathSortTest.cxx
File metadata and controls
57 lines (46 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <vector>
#include <map>
//#include <pair>
#include <algorithm>
#include <iostream>
#include <TLorentzVector.h>
using namespace std;
typedef pair<TLorentzVector,double> TlvPt;
struct TlvPtCmp {
bool operator()( TlvPt const & a, TlvPt const & b) {
return a.second < b.second ;
}
};
struct pred {
bool operator()(TLorentzVector const & a, TLorentzVector const & b) const {
return a.Pt() < b.Pt();
}
};
int SortTest(){
vector<TLorentzVector> v;
v.push_back( TLorentzVector( 1,1,1,1 ));
v.push_back( TLorentzVector( 3,3,3,3 ));
v.push_back( TLorentzVector( 2,2,2,2 ));
// cout << v.at(0).Pt() << endl;
// cout << v.at(1).Pt() << endl;
// cout << v.at(2).Pt() << endl;
// std::sort(v.begin(), v.end(), pred() );
// cout << endl;
// cout << v.at(0).Pt() << endl;
// cout << v.at(1).Pt() << endl;
// cout << v.at(2).Pt() << endl;
// cout << endl;
vector< TlvPt > pv;
pv.push_back( TlvPt (v.at(0), v.at(0).Pt() ) );
pv.push_back( TlvPt (v.at(1), v.at(1).Pt() ) );
pv.push_back( TlvPt (v.at(2), v.at(2).Pt() ) );
cout << pv.at(0).first.Pt() << endl;
cout << pv.at(1).first.Pt() << endl;
cout << pv.at(2).first.Pt() << endl;
sort(pv.begin(), pv.end(), TlvPtCmp() );
cout << endl;
cout << pv.at(0).first.Pt() << endl;
cout << pv.at(1).first.Pt() << endl;
cout << pv.at(2).first.Pt() << endl;
return 0;
}