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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
1 #include<iostream>
2 #include<fstream>
3 #include<stdlib.h>
4 #include <assert.h>
5 #include <TROOT.h>
6 #include <TApplication.h>
7 #include <TTree.h>
8 #include <TFile.h>
9 #include <TBrowser.h>
10 #include <TStyle.h>
11 #include <list>
12 #include <math.h>
13 #include "cosmic_class.h"
14 using namespace std;
15
16
17 int checkmatch(list<padfire>::iterator,list<padfire>);
18 int shareside(list<padfire>::iterator,list<padfire>::iterator,list<padfire>);
19 void listprint(list<padfire>);
20
21 int checkmatch(list<padfire>::iterator ai,list<padfire> b)
22 {int temp=0;
23 for(list<padfire>::iterator bi = b.begin(); bi != b.end();bi++)
24 {
25 if( ((*ai).x ==(*bi).x) && ((*ai).y ==(*bi).y))
26 temp=1;
27
28 }
29 return temp;
30 }
31
32 int shareside(list<padfire>::iterator ai,list<padfire>::iterator bi,list <padfire> b)
33 { int temp=0;
34 if(b.size()==0)
35 return 0;
36 for(bi = b.begin(); bi != b.end();bi++)
37 {
38 if((*ai).z==(*bi).z)
39 {if( ((*ai).x ==(*bi).x) || ((*ai).y ==(*bi).y))
40 {temp=1;
41 return temp;
42 }
43 }
44 }
45 return temp;
46 }
47
48 void listprint(list<padfire> a)
49 {
50 for(list<padfire>::iterator g = a.begin(); g!=a.end();g++ )
51 {cout<< (*g).x <<" "<<(*g).y <<" "<< (*g).z << endl;}
52 return;
53 }
54
55 //###########################
56 //###########################
57
58 int main( )
59 {
60
61 char *filename2= "run300649.txt";
62 // sprintf(filename2,"run%s.txt",filename);
63 cout<<filename2<<endl;
64 ifstream input;
65 input.open(filename2);
66 int garbage,count=0,flg=0;
67 int ix,iy,iz,itime;
68
69
70
71
72 list<padfire> tlist,cevent,intercls,ceventcls; // total list, current event, current cluster
73 list<int> etrack;
74 list<clstr> clusters;
75 list<padfire>::iterator iter = tlist.begin();
76 list<padfire>::iterator iter2 = cevent.begin();
77 list<clstr>::iterator iter3 = clusters.begin();
78 list<padfire>::iterator iter4 = (*iter3).cls.begin();
79 list<padfire>::iterator iter5 = intercls.begin();
80 padfire templ;
81 input >> garbage;
82 input >> garbage;
83 input >> garbage;
84 input >> garbage;
85
86
87 do{
88 input >>itime;
89 input >>ix;
90 input >>iy;
91 input >>iz;
92 //cout<< itime << " " << ix <<" "<< iy <<" "<< iz << endl;
93 templ.time=itime;
94 templ.x=ix;
95 templ.y=iy;
96 templ.z=iz;
97 tlist.push_back(templ);
98 if(ix==-1)
99 {etrack.push_back(count);}
100 count++;
101 } while(!input.eof());
102
103
104 list<int>::iterator a=etrack.begin(); //declaring iterators to loop through the lists
105 list<padfire>::iterator cit=cevent.begin();
106
107
108 for(int l=0;l<*a+1;l++){iter++;} //finds which line the first event ends on
109
110 cevent.splice(cevent.end(),tlist,tlist.begin(),iter); //take the first event from tlist and put it into cevent
111
112 cout<< "pre clustering test"<<endl;
113
114 //################################
115 //##############CLUSTERING########
116 //################################
117
118 // clustering the layers of the current event
119
120
121 do {flg=0;
122 intercls.push_back(*cit);
123 cit = cevent.erase(cit);
124 flg = shareside(iter5,iter2,cevent);
125 if (flg==1)
126 {while (flg==1)
127 {intercls.push_back(*iter2);
128 cevent.erase(iter2);
129 flg=0;
130 flg = shareside(iter5,iter2,cevent);
131 }
132 }
133 else{
134 clusters.push_back(intercls); //here needs to copy all of intercls into a part of clusters
135 iter5 = intercls.erase(iter5); // needs to erase all of intercls
136
137 // ###### need to increment the clusters variable so its pointing at the next list########
138
139 }
140
141 } while(cit != cevent.end());
142
143 input.close();
144 return0;
145 }
|