Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:57

0001 #include "CommonTools/Clustering1D/test/Input.cpp"
0002 #include "CommonTools/Clustering1D/interface/Cluster1DMerger.h"
0003 #include "CommonTools/Clustering1D/interface/TrivialWeightEstimator.h"
0004 
0005 #define HaveMtv
0006 #define HaveFsmw
0007 #define HaveDivisive
0008 #ifdef HaveMtv
0009 #include "CommonTools/Clustering1D/interface/MtvClusterizer1D.h"
0010 #endif
0011 #ifdef HaveFsmw
0012 #include "CommonTools/Clustering1D/interface/FsmwClusterizer1D.h"
0013 #endif
0014 #ifdef HaveDivisive
0015 #include "CommonTools/Clustering1D/interface/DivisiveClusterizer1D.h"
0016 #endif
0017 
0018 #include <string>
0019 #include <iostream>
0020 
0021 using namespace std;
0022 
0023 namespace {
0024   void print(const Cluster1D<string>& obj) {
0025     cout << "   Cluster1D ";
0026     vector<const string*> names = obj.tracks();
0027     for (vector<const string*>::iterator nm = names.begin(); nm != names.end(); ++nm) {
0028       cout << **nm;
0029     };
0030     cout << " at " << obj.position().value() << " +/- " << obj.position().error() << " weight " << obj.weight();
0031     cout << endl;
0032   }
0033 
0034   void mergingResult(const Cluster1D<string>& one, const Cluster1D<string>& two) {
0035     cout << "Merger test:" << endl;
0036     print(one);
0037     print(two);
0038 
0039     Cluster1D<string> result = Cluster1DMerger<string>(TrivialWeightEstimator<string>())(one, two);
0040     cout << "Merge result: " << endl;
0041     print(result);
0042   }
0043 
0044   void mergerTest() {
0045     string one_s = "a";
0046     vector<const string*> one_names;
0047     one_names.push_back(&one_s);
0048     Cluster1D<string> one(Measurement1D(1.0, 0.1), one_names, 1.0);
0049 
0050     vector<const string*> two_names;
0051     string two_s = "b";
0052     two_names.push_back(&two_s);
0053     Cluster1D<string> two(Measurement1D(2.0, 0.2), two_names, 1.0);
0054 
0055     mergingResult(one, two);
0056   }
0057 }  // namespace
0058 
0059 int main(int argc, char** argv) { mergerTest(); }