-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreconstruction.cxx
91 lines (68 loc) · 1.92 KB
/
reconstruction.cxx
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "Tracker.h"
#include "TString.h"
#include "TFile.h"
#include <iostream>
using namespace std;
int main()
{
bool analyseTruth = false;
const int nEvents = 1;
const int firstEvent=1000;
//TString dir = "../task/train_100_events/";
TString dir = "data/train_100_events/";
/*
const int nEvents = 125;
const int firstEvent=0;
TString dir = "data/test/";
*/
/*
const int nEvents = 1000;
const int firstEvent=1000;
TString dir = "../task/train_1/";
*/
ofstream out("mysubmission.csv");
if( !out.is_open() ){
cout<<"Can not open output file"<<endl;
exit(0);
}
out<<"event_id,hit_id,track_id"<<endl;
Tracker tracker;
long int currentID=1;
for( int event = firstEvent; event<firstEvent+nEvents; event++){
cout<<"read event "<<event<<endl;
tracker.readEvent( dir.Data(), event, analyseTruth );
//tracker.analyzeGeometry(0);
//continue;
tracker.reconstruct();
cout<<"Event "<<event<<": reconstructed "<<tracker.proc.vTracks.size()<<" tracks"<<endl;
TrackletConstructor &proc = tracker.proc;
for( int ih=0; ih<tracker.mHits.size(); ih++ ){
Hit &h = tracker.mHits[ih];
h.trackID=0;
}
currentID=1;
for( int itr=0; itr<proc.vTracks.size(); itr++ ){
Tracklet &t = proc.vTracks[itr];
if( t.vHits.size()==0 ) continue;
for( int ih=0; ih<t.vHits.size(); ih++ ){
Hit &h = tracker.mHits[t.vHits[ih]];
if( h.trackID>0 ){
cout<<"reconstruction.cxx: Wrong hit indexing!"<<endl;
cout<<"track "<<itr<<" nhits "<<t.vHits.size()<<endl;
cout<<"hit "<<ih<<" trackID "<<h.trackID<<endl;
h.Print();
exit(1);
}
h.trackID=currentID;
}
currentID++;
}
for( int ih=0; ih<tracker.mHits.size(); ih++ ){
Hit &h = tracker.mHits[ih];
out<<event<<","<<ih+1<<","<<h.trackID<<endl;
}
} // events
//tracker.analyzeGeometry(1);
out.close();
return 0;
}