19 |
|
} |
20 |
|
|
21 |
|
|
22 |
< |
int MySimEvent::LoadEvent(FILE* f) |
22 |
> |
void MySimEvent::LoadEvent(FILE* pFile, stChunk* ParentChunk) |
23 |
|
{ |
24 |
< |
Chunk primary_chunk; |
24 |
> |
unsigned short temp; |
25 |
> |
fread(&temp,1,2,pFile); |
26 |
> |
fseek(pFile,-2,SEEK_CUR); |
27 |
> |
// printf("Parent = %i --> Current ChunkId = %i to read = %i\n",ParentChunk->type,temp,0); |
28 |
|
|
29 |
< |
primary_chunk.read =fread(&primary_chunk.type,sizeof(int),1,f) * sizeof(int); |
30 |
< |
primary_chunk.read +=fread(&primary_chunk.size,sizeof(int),1,f) * sizeof(int); |
29 |
> |
stChunk* CurrentChunk = new stChunk; |
30 |
> |
ReadChunk(pFile, CurrentChunk); |
31 |
|
|
32 |
< |
if(primary_chunk.type!=C_EVENT) return 0; |
30 |
< |
|
31 |
< |
while(primary_chunk.read<primary_chunk.size) |
32 |
> |
switch(CurrentChunk->type) |
33 |
|
{ |
34 |
< |
primary_chunk.read += LoadChunk(f); |
35 |
< |
} |
36 |
< |
|
37 |
< |
// ComputeLine(); |
38 |
< |
|
38 |
< |
return primary_chunk.read; |
39 |
< |
} |
40 |
< |
|
41 |
< |
|
42 |
< |
void MySimEvent::SaveEvent(FILE* f) |
43 |
< |
{ |
44 |
< |
Chunk Primary_chunk; |
45 |
< |
Primary_chunk.type = C_EVENT; |
46 |
< |
Primary_chunk.read = 2*sizeof(int); |
47 |
< |
Primary_chunk.size = Chunk_size(); |
48 |
< |
|
49 |
< |
fwrite(&Primary_chunk.type,sizeof(int),1,f); |
50 |
< |
fwrite(&Primary_chunk.size,sizeof(int),1,f); |
51 |
< |
|
52 |
< |
Chunk chunk_temp; |
53 |
< |
|
54 |
< |
unsigned int i; |
55 |
< |
for(i=0;i<MyPSimHitCollection.size();i++){ |
56 |
< |
chunk_temp.type = C_PSIMHIT; |
57 |
< |
chunk_temp.size = 2*sizeof(int)+sizeof(MyPSimHit); |
58 |
< |
|
59 |
< |
fwrite(&chunk_temp.type,sizeof(int),1,f); |
60 |
< |
fwrite(&chunk_temp.size,sizeof(int),1,f); |
61 |
< |
fwrite(&MyPSimHitCollection[i],sizeof(MyPSimHit),1,f); |
62 |
< |
|
63 |
< |
Primary_chunk.read+= chunk_temp.size; |
64 |
< |
} |
65 |
< |
|
66 |
< |
for(i=0;i<MyPCaloHitCollection.size();i++){ |
67 |
< |
chunk_temp.type = C_PCALOHIT; |
68 |
< |
chunk_temp.size = 2*sizeof(int)+sizeof(MyPCaloHit); |
69 |
< |
|
70 |
< |
fwrite(&chunk_temp.type,sizeof(int),1,f); |
71 |
< |
fwrite(&chunk_temp.size,sizeof(int),1,f); |
72 |
< |
fwrite(&MyPCaloHitCollection[i],sizeof(MyPCaloHit),1,f); |
73 |
< |
|
74 |
< |
Primary_chunk.read+= chunk_temp.size; |
75 |
< |
} |
76 |
< |
|
77 |
< |
for(i=0;i<MySimVertexCollection.size();i++){ |
78 |
< |
chunk_temp.type = C_SIMVERTEX; |
79 |
< |
chunk_temp.size = 2*sizeof(int)+sizeof(MySimVertex); |
80 |
< |
|
81 |
< |
fwrite(&chunk_temp.type,sizeof(int),1,f); |
82 |
< |
fwrite(&chunk_temp.size,sizeof(int),1,f); |
83 |
< |
fwrite(&MySimVertexCollection[i],sizeof(MySimVertex),1,f); |
84 |
< |
|
85 |
< |
Primary_chunk.read+= chunk_temp.size; |
86 |
< |
} |
87 |
< |
|
88 |
< |
for(i=0;i<MySimTrackCollection.size();i++){ |
89 |
< |
chunk_temp.type = C_SIMTRACK; |
90 |
< |
chunk_temp.size = 2*sizeof(int)+sizeof(MySimTrack); |
91 |
< |
|
92 |
< |
fwrite(&chunk_temp.type,sizeof(int),1,f); |
93 |
< |
fwrite(&chunk_temp.size,sizeof(int),1,f); |
94 |
< |
fwrite(&MySimTrackCollection[i],sizeof(MySimTrack),1,f); |
95 |
< |
|
96 |
< |
Primary_chunk.read+= chunk_temp.size; |
97 |
< |
} |
98 |
< |
|
99 |
< |
|
100 |
< |
for(i=0;i<MyRecoTrackCollection.size();i++){ |
101 |
< |
chunk_temp.type = C_RECOTRACK; |
102 |
< |
// chunk_temp.size = 2*sizeof(int)+sizeof(MyRecoTrack); |
103 |
< |
chunk_temp.size = 2*sizeof(int)+sizeof(int)+MyRecoTrackCollection[i].N * sizeof(MyRecoHit); |
104 |
< |
|
105 |
< |
fwrite(&chunk_temp.type,sizeof(int),1,f); |
106 |
< |
fwrite(&chunk_temp.size,sizeof(int),1,f); |
107 |
< |
fwrite(&MyRecoTrackCollection[i].N,sizeof(int),1,f); |
108 |
< |
|
109 |
< |
for(int j=0;j<MyRecoTrackCollection[i].N;j++){ |
110 |
< |
fwrite(&MyRecoTrackCollection[i].Hits[j],sizeof(MyRecoHit),1,f); |
111 |
< |
} |
112 |
< |
|
113 |
< |
Primary_chunk.read+= chunk_temp.size; |
114 |
< |
} |
34 |
> |
case C_EVENT: // Event |
35 |
> |
while(CurrentChunk->read<CurrentChunk->size){ |
36 |
> |
LoadEvent(pFile,CurrentChunk); |
37 |
> |
} |
38 |
> |
break; |
39 |
|
|
40 |
|
|
41 |
< |
} |
41 |
> |
///////////////////////////SIM DATA////////////////////////// |
42 |
> |
case C_SIM: // SimData |
43 |
> |
while(CurrentChunk->read<CurrentChunk->size){ |
44 |
> |
LoadEvent(pFile,CurrentChunk); |
45 |
> |
} |
46 |
> |
break; |
47 |
|
|
48 |
< |
int MySimEvent::LoadChunk (FILE* f) |
120 |
< |
{ |
121 |
< |
Chunk chunk; |
122 |
< |
|
123 |
< |
chunk.read =fread(&chunk.type,sizeof(int),1,f) * sizeof(int); |
124 |
< |
chunk.read +=fread(&chunk.size,sizeof(int),1,f) * sizeof(int); |
125 |
< |
switch(chunk.type) |
126 |
< |
{ |
127 |
< |
case C_PSIMHIT: // PSimHit |
48 |
> |
case C_SIM_TRACKHIT: // PSimHit |
49 |
|
MyPSimHit temp_SimHit; |
50 |
< |
chunk.read += fread(&temp_SimHit,sizeof(MyPSimHit),1,f) * sizeof(MyPSimHit); |
50 |
> |
CurrentChunk->read += fread(&temp_SimHit,sizeof(MyPSimHit),1,pFile) * sizeof(MyPSimHit); |
51 |
|
MyPSimHitCollection.push_back(temp_SimHit); |
52 |
|
break; |
53 |
|
|
54 |
< |
case C_PCALOHIT: // PCaloHit |
54 |
> |
case C_SIM_CALOHIT: // PCaloHit |
55 |
|
MyPCaloHit temp_CaloHit; |
56 |
< |
chunk.read += fread(&temp_CaloHit,sizeof(MyPCaloHit),1,f) * sizeof(MyPCaloHit); |
56 |
> |
CurrentChunk->read += fread(&temp_CaloHit,sizeof(MyPCaloHit),1,pFile) * sizeof(MyPCaloHit); |
57 |
|
MyPCaloHitCollection.push_back(temp_CaloHit); |
58 |
|
break; |
59 |
|
|
60 |
< |
case C_SIMVERTEX: // SimVertex |
60 |
> |
case C_SIM_VERTEX: // SimVertex |
61 |
|
MySimVertex temp_SimVertex; |
62 |
< |
chunk.read += fread(&temp_SimVertex,sizeof(MySimVertex),1,f) * sizeof(MySimVertex); |
62 |
> |
CurrentChunk->read += fread(&temp_SimVertex,sizeof(MySimVertex),1,pFile) * sizeof(MySimVertex); |
63 |
|
MySimVertexCollection.push_back(temp_SimVertex); |
64 |
|
break; |
65 |
|
|
66 |
< |
case C_SIMTRACK: // SimTrack |
66 |
> |
case C_SIM_TRACK: // SimTrack |
67 |
|
MySimTrack temp_SimTrack; |
68 |
< |
chunk.read += fread(&temp_SimTrack,sizeof(MySimTrack),1,f) * sizeof(MySimTrack); |
68 |
> |
CurrentChunk->read += fread(&temp_SimTrack,sizeof(MySimTrack),1,pFile) * sizeof(MySimTrack); |
69 |
|
MySimTrackCollection.push_back(temp_SimTrack); |
70 |
|
break; |
71 |
|
|
151 |
– |
case C_RECOTRACK: // RecoTrack |
152 |
– |
MyRecoTrack temp_RecoTrack; |
153 |
– |
chunk.read += fread(&temp_RecoTrack.N,sizeof(int),1,f) * sizeof(int); |
154 |
– |
temp_RecoTrack.Hits = new MyRecoHit[temp_RecoTrack.N]; |
72 |
|
|
73 |
< |
for(int j=0;j<temp_RecoTrack.N;j++){ |
74 |
< |
chunk.read += fread(&temp_RecoTrack.Hits[j],sizeof(MyRecoHit),1,f) * sizeof(MyRecoHit); |
73 |
> |
|
74 |
> |
//////////////////////////RECO DATA////////////////////////// |
75 |
> |
case C_RECO: // RecoData |
76 |
> |
while(CurrentChunk->read<CurrentChunk->size){ |
77 |
> |
LoadEvent(pFile,CurrentChunk); |
78 |
|
} |
79 |
+ |
break; |
80 |
|
|
81 |
< |
MyRecoTrackCollection.push_back(temp_RecoTrack); |
81 |
> |
case C_RECO_TRACK: // RecoTrack |
82 |
> |
MyRecoTrackCollection.push_back(*(new MyRecoTrack)); |
83 |
> |
while(CurrentChunk->read<CurrentChunk->size){ |
84 |
> |
LoadEvent(pFile,CurrentChunk); |
85 |
> |
} |
86 |
|
break; |
87 |
|
|
88 |
+ |
case C_RECO_TRACKHITS: // RecHits |
89 |
+ |
MyRecoHit temp_RecoHit; |
90 |
+ |
CurrentChunk->read += fread(&temp_RecoHit,sizeof(MyRecoHit),1,pFile) * sizeof(MyRecoHit); |
91 |
+ |
MyRecoTrackCollection[MyRecoTrackCollection.size()-1].Hits.push_back(temp_RecoHit); |
92 |
+ |
break; |
93 |
+ |
|
94 |
+ |
|
95 |
|
|
96 |
+ |
////////////////////////UNKOWN CHUNK //////////////////////// |
97 |
|
default: |
98 |
< |
fseek (f,chunk.size-chunk.read,SEEK_CUR); |
99 |
< |
chunk.read += chunk.size-chunk.read; |
98 |
> |
printf("Unknown ChunkID (%i)\n",CurrentChunk->type); |
99 |
> |
printf("Chunk will be skipped\n"); |
100 |
> |
printf("The program can not run properly\n"); |
101 |
> |
fseek (pFile,CurrentChunk->size-CurrentChunk->read,SEEK_CUR); |
102 |
> |
CurrentChunk->read += CurrentChunk->size-CurrentChunk->read; |
103 |
|
break; |
104 |
|
} |
105 |
|
|
106 |
< |
return chunk.read; |
106 |
> |
ParentChunk->read += CurrentChunk->read; |
107 |
|
} |
108 |
|
|
173 |
– |
int MySimEvent::Chunk_size() |
174 |
– |
{ |
175 |
– |
int size = 2*sizeof(int); |
176 |
– |
size += MyPSimHitCollection.size() *(sizeof(MyPSimHit) + 2*sizeof(int)); |
177 |
– |
size += MyPCaloHitCollection.size() *(sizeof(MyPCaloHit) + 2*sizeof(int)); |
178 |
– |
size += MySimVertexCollection.size()*(sizeof(MySimVertex)+ 2*sizeof(int)); |
179 |
– |
size += MySimTrackCollection.size() *(sizeof(MySimTrack) + 2*sizeof(int)); |
180 |
– |
|
181 |
– |
for(unsigned int i=0;i<MyRecoTrackCollection.size();i++){ |
182 |
– |
size += 2*sizeof(int) + sizeof(int); |
183 |
– |
size += MyRecoTrackCollection[i].N * sizeof(MyRecoHit); |
184 |
– |
} |
109 |
|
|
186 |
– |
return size; |
187 |
– |
} |
110 |
|
|
111 |
< |
void MySimEvent::Open(char* path) |
111 |
> |
void MySimEvent::SaveEvent(stChunkToSave* ParentChunk) |
112 |
|
{ |
113 |
< |
FILE* f = fopen(path,"wb" ); |
114 |
< |
SaveEvent(f); |
115 |
< |
fclose(f); |
113 |
> |
unsigned int i; |
114 |
> |
stChunkToSave* CurrentChunk; |
115 |
> |
|
116 |
> |
switch(ParentChunk->type) |
117 |
> |
{ |
118 |
> |
case C_PRIMARY: // PrimaryChunk |
119 |
> |
CurrentChunk = new stChunkToSave; |
120 |
> |
CurrentChunk->type = C_EVENT; |
121 |
> |
CurrentChunk->size = 6; |
122 |
> |
ParentChunk->daughters.push_back(CurrentChunk); |
123 |
> |
break; |
124 |
|
|
125 |
+ |
case C_EVENT: // Event |
126 |
+ |
CurrentChunk = new stChunkToSave; |
127 |
+ |
CurrentChunk->type = C_SIM; |
128 |
+ |
CurrentChunk->size = 6; |
129 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
130 |
+ |
|
131 |
+ |
CurrentChunk = new stChunkToSave; |
132 |
+ |
CurrentChunk->type = C_RECO; |
133 |
+ |
CurrentChunk->size = 6; |
134 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
135 |
+ |
break; |
136 |
+ |
|
137 |
+ |
case C_SIM: // SimData |
138 |
+ |
for(i=0;i<MyPSimHitCollection.size();i++){ |
139 |
+ |
CurrentChunk = new stChunkToSave; |
140 |
+ |
CurrentChunk->type = C_SIM_TRACKHIT; |
141 |
+ |
CurrentChunk->size = 6+sizeof(MyPSimHit); |
142 |
+ |
CurrentChunk->data = (char*)&MyPSimHitCollection[i]; |
143 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
144 |
+ |
} |
145 |
+ |
for(i=0;i<MyPCaloHitCollection.size();i++){ |
146 |
+ |
CurrentChunk = new stChunkToSave; |
147 |
+ |
CurrentChunk->type = C_SIM_CALOHIT; |
148 |
+ |
CurrentChunk->size = 6+sizeof(MyPCaloHit); |
149 |
+ |
CurrentChunk->data = (char*)&MyPCaloHitCollection[i]; |
150 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
151 |
+ |
} |
152 |
+ |
for(i=0;i<MySimVertexCollection.size();i++){ |
153 |
+ |
CurrentChunk = new stChunkToSave; |
154 |
+ |
CurrentChunk->type = C_SIM_VERTEX; |
155 |
+ |
CurrentChunk->size = 6+sizeof(MySimVertex); |
156 |
+ |
CurrentChunk->data = (char*)&MySimVertexCollection[i]; |
157 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
158 |
+ |
} |
159 |
+ |
for(i=0;i<MySimTrackCollection.size();i++){ |
160 |
+ |
CurrentChunk = new stChunkToSave; |
161 |
+ |
CurrentChunk->type = C_SIM_TRACK; |
162 |
+ |
CurrentChunk->size = 6+sizeof(MySimTrack); |
163 |
+ |
CurrentChunk->data = (char*)&MySimTrackCollection[i]; |
164 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
165 |
+ |
} |
166 |
+ |
break; |
167 |
|
|
196 |
– |
FILE* g = fopen(path,"rb" ); |
197 |
– |
LoadEvent(g); |
198 |
– |
fclose(g); |
199 |
– |
} |
168 |
|
|
169 |
+ |
case C_RECO: // RecoData |
170 |
+ |
for(i=0;i<MyRecoTrackCollection.size();i++){ |
171 |
+ |
CurrentChunk = new stChunkToSave; |
172 |
+ |
CurrentChunk->type = C_RECO_TRACK; |
173 |
+ |
CurrentChunk->size = 6; |
174 |
+ |
CurrentChunk->buffer = &MyRecoTrackCollection[i]; |
175 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
176 |
+ |
} |
177 |
+ |
break; |
178 |
|
|
179 |
|
|
180 |
+ |
case C_RECO_TRACK: // RecoTrack |
181 |
+ |
for(i=0;i<((MyRecoTrack*)ParentChunk->buffer)->Hits.size();i++){ |
182 |
+ |
CurrentChunk = new stChunkToSave; |
183 |
+ |
CurrentChunk->type = C_RECO_TRACKHITS; |
184 |
+ |
CurrentChunk->size = 6+sizeof(MyRecoHit); |
185 |
+ |
CurrentChunk->data = (char*)&((MyRecoTrack*)ParentChunk->buffer)->Hits[i]; |
186 |
+ |
ParentChunk->daughters.push_back(CurrentChunk); |
187 |
+ |
} |
188 |
+ |
break; |
189 |
|
|
190 |
+ |
default: |
191 |
+ |
break; |
192 |
+ |
} |
193 |
|
|
205 |
– |
////////////////////////// SIM EVENTS /////////////////////////// |
194 |
|
|
195 |
+ |
for(unsigned int i=0; i<ParentChunk->daughters.size();i++) |
196 |
+ |
{ |
197 |
+ |
if( !(ParentChunk->type == C_PRIMARY && i!=ParentChunk->daughters.size()-1)) |
198 |
+ |
SaveEvent(ParentChunk->daughters[i]); |
199 |
+ |
ParentChunk->size += ParentChunk->daughters[i]->size; |
200 |
+ |
} |
201 |
+ |
|
202 |
+ |
} |
203 |
|
|
204 |
|
MySimEvents::MySimEvents() |
205 |
|
{ |
208 |
|
MySimEvent* temp_Event = new MySimEvent; |
209 |
|
for(int j=0;j<2;j++){ |
210 |
|
MyPSimHit temp; |
211 |
< |
temp.x = float(rand()%200-100); |
212 |
< |
temp.y = float(rand()%200-100); |
213 |
< |
temp.z = float(rand()%200-100); |
214 |
< |
temp.dEdX = float(1+rand()%10); |
211 |
> |
temp.x = (float)(1.0f); |
212 |
> |
temp.y = (float)(2.0f); |
213 |
> |
temp.z = (float)(3.0f); |
214 |
> |
temp.dEdX = 0.01f; |
215 |
> |
temp.ProcessType = 255; |
216 |
|
temp_Event->MyPSimHitCollection.push_back(temp); |
217 |
|
|
218 |
|
MyPCaloHit temp2; |
219 |
< |
temp2.x = float(rand()%200-100); |
220 |
< |
temp2.y = float(rand()%200-100); |
221 |
< |
temp2.z = float(rand()%200-100); |
222 |
< |
temp2.E = float(1+rand()%3); |
219 |
> |
temp2.x = (float)(rand()%200-100); |
220 |
> |
temp2.y = (float)(rand()%200-100); |
221 |
> |
temp2.z = (float)(rand()%200-100); |
222 |
> |
temp2.E = 0.01f; |
223 |
> |
temp2.ProcessType = 255; |
224 |
|
temp_Event->MyPCaloHitCollection.push_back(temp2); |
225 |
|
|
226 |
|
MySimVertex temp3; |
227 |
< |
temp3.x = float(rand()%200-100); |
228 |
< |
temp3.y = float(rand()%200-100); |
229 |
< |
temp3.z = float(rand()%200-100); |
227 |
> |
temp3.x = (float)(rand()%200-100); |
228 |
> |
temp3.y = (float)(rand()%200-100); |
229 |
> |
temp3.z = (float)(rand()%200-100); |
230 |
> |
temp3.parentTrack_id = 255; |
231 |
|
temp_Event->MySimVertexCollection.push_back(temp3); |
232 |
|
|
233 |
|
MySimTrack temp4; |
234 |
< |
temp4.Px = 10; |
234 |
> |
temp4.Px = (float)(rand()%200-100); |
235 |
> |
temp4.Py = (float)(rand()%200-100); |
236 |
> |
temp4.Pz = (float)(rand()%200-100); |
237 |
> |
temp4.E = 1; |
238 |
> |
temp4.track_id = 255; |
239 |
> |
temp4.Type = 255; |
240 |
> |
temp4.charge = 0; |
241 |
|
temp_Event->MySimTrackCollection.push_back(temp4); |
242 |
|
|
243 |
< |
// MyRecoTrack temp5; |
244 |
< |
// temp5.N = rand()%5+1; |
245 |
< |
// temp5.Hits = new MyRecoHit[10]; |
246 |
< |
// for(int h=0;h<temp5.N;h++){ |
247 |
< |
// temp5.Hits[h].x = (float)(rand()%200-100); |
248 |
< |
// temp5.Hits[h].y = (float)(rand()%200-100); |
249 |
< |
// temp5.Hits[h].z = (float)(rand()%200-100); |
250 |
< |
// temp5.Hits[h].DetId = rand()%2000; |
251 |
< |
// temp5.Hits[h].Charge = rand()%500; |
252 |
< |
// } |
253 |
< |
// temp_Event->MyRecoTrackCollection.push_back(temp5); |
254 |
< |
|
250 |
< |
} |
251 |
< |
|
243 |
> |
MyRecoTrack temp5; |
244 |
> |
for(unsigned int h=0;h<2;h++){ |
245 |
> |
MyRecoHit tmp; |
246 |
> |
tmp.x = (float)(rand()%200-100); |
247 |
> |
tmp.y = (float)(rand()%200-100); |
248 |
> |
tmp.z = (float)(rand()%200-100); |
249 |
> |
tmp.DetId = 255; |
250 |
> |
tmp.Charge = rand()%500; |
251 |
> |
temp5.Hits.push_back(tmp); |
252 |
> |
} |
253 |
> |
temp_Event->MyRecoTrackCollection.push_back(temp5); |
254 |
> |
} |
255 |
|
Events.push_back(temp_Event); |
256 |
|
} |
257 |
|
*/ |
255 |
– |
// Current_Event = 1; |
258 |
|
} |
259 |
|
|
260 |
|
|
267 |
|
{ |
268 |
|
FILE* f = fopen(path,"rb" ); |
269 |
|
|
270 |
< |
Chunk primary_chunk; |
269 |
< |
|
270 |
< |
primary_chunk.read =fread(&primary_chunk.type,sizeof(int),1,f) * sizeof(int); |
271 |
< |
primary_chunk.read +=fread(&primary_chunk.size,sizeof(int),1,f) * sizeof(int); |
270 |
> |
stChunk* PrimaryChunk = new stChunk; |
271 |
|
|
272 |
< |
if(primary_chunk.type!=C_PRIMARY) return; |
272 |
> |
PrimaryChunk->read =fread(&PrimaryChunk->type,1,2,f); |
273 |
> |
PrimaryChunk->read +=fread(&PrimaryChunk->size,1,4,f); |
274 |
|
|
275 |
+ |
if(PrimaryChunk->type!=C_PRIMARY){ |
276 |
+ |
printf("PrimaryChunk has not a good Id (%i!=%i)\n",PrimaryChunk->type,C_PRIMARY); |
277 |
+ |
printf("Exiting...\n"); |
278 |
+ |
exit(0); |
279 |
+ |
} |
280 |
|
|
281 |
< |
while(primary_chunk.read<primary_chunk.size) |
281 |
> |
while(PrimaryChunk->read<PrimaryChunk->size) |
282 |
|
{ |
283 |
|
MySimEvent* temp = new MySimEvent; |
284 |
< |
primary_chunk.read += temp->LoadEvent(f); |
284 |
> |
temp->LoadEvent(f,PrimaryChunk); |
285 |
|
Events.push_back(temp); |
286 |
|
} |
287 |
|
fclose(f); |
322 |
|
for(j=0;j<Events[i]->MyRecoTrackCollection.size();j++) |
323 |
|
{ |
324 |
|
MyRecoTrack track = Events[i]->MyRecoTrackCollection[j]; |
325 |
< |
fprintf(g,"RecoTrack\t%8i\n",track.N); |
326 |
< |
for(int h=0;h<track.N;h++){ |
325 |
> |
fprintf(g,"RecoTrack\t%4i\n",track.Hits.size()); |
326 |
> |
for(unsigned int h=0;h<track.Hits.size();h++){ |
327 |
|
MyRecoHit hit = track.Hits[h]; |
328 |
< |
fprintf(g,"\t\t\tHit : %6.2f\t%6.2f\t%6.2f\t%8i\t%8i\n",hit.x,hit.y,hit.z,hit.Charge,hit.DetId); |
328 |
> |
fprintf(g," Hit : %6.2f\t%6.2f\t%6.2f\t%8i\t%8i\n",hit.x,hit.y,hit.z,hit.Charge,hit.DetId); |
329 |
|
} |
330 |
< |
} |
326 |
< |
|
330 |
> |
} |
331 |
|
} |
332 |
|
fclose(g); |
333 |
|
|
337 |
|
|
338 |
|
void MySimEvents::Save(char* path) |
339 |
|
{ |
340 |
< |
FILE* f = fopen(path,"wb" ); |
337 |
< |
|
338 |
< |
Chunk Primary_chunk; |
340 |
> |
stChunkToSave* Primary_chunk = new stChunkToSave; |
341 |
|
|
342 |
< |
Primary_chunk.type = C_PRIMARY; |
343 |
< |
Primary_chunk.read = 2*sizeof(int); |
344 |
< |
Primary_chunk.size = 2*sizeof(int); |
345 |
< |
for(unsigned int i=0;i<Events.size();i++){ |
346 |
< |
Primary_chunk.size += Events[i]->Chunk_size(); |
342 |
> |
Primary_chunk->type = C_PRIMARY; |
343 |
> |
Primary_chunk->size = 6; |
344 |
> |
|
345 |
> |
for(unsigned int i=0;i<Events.size();i++){ |
346 |
> |
Events[i]->SaveEvent(Primary_chunk); |
347 |
|
} |
348 |
|
|
349 |
< |
fwrite(&Primary_chunk.type,sizeof(int),1,f); |
350 |
< |
fwrite(&Primary_chunk.size,sizeof(int),1,f); |
349 |
> |
Primary_chunk->size = 6; |
350 |
> |
for(unsigned int i=0;i<Primary_chunk->daughters.size();i++){ |
351 |
> |
Primary_chunk->size += Primary_chunk->daughters[i]->size; |
352 |
> |
} |
353 |
|
|
354 |
< |
for(unsigned int i=0;i<Events.size();i++){ |
355 |
< |
Events[i]->SaveEvent(f); |
354 |
> |
printf("%i (%iKo)\n",Primary_chunk->type,Primary_chunk->size); |
355 |
> |
for(unsigned int i=0;i<Primary_chunk->daughters.size();i++){ |
356 |
> |
stChunkToSave* tmp = Primary_chunk->daughters[i]; |
357 |
> |
printf(" %i (%i)\n",tmp->type,tmp->size); |
358 |
> |
for(unsigned int j=0;j<tmp->daughters.size();j++){ |
359 |
> |
stChunkToSave* Tmp = tmp->daughters[j]; |
360 |
> |
printf(" %i (%i)\n",Tmp->type,Tmp->size); |
361 |
> |
for(unsigned int k=0;k<Tmp->daughters.size();k++){ |
362 |
> |
stChunkToSave* TMp = Tmp->daughters[k]; |
363 |
> |
printf(" %i (%i)\n",TMp->type,TMp->size); |
364 |
> |
for(unsigned int l=0;l<TMp->daughters.size();l++){ |
365 |
> |
stChunkToSave* TMP = TMp->daughters[l]; |
366 |
> |
printf(" %i (%i)\n",TMP->type,TMP->size); |
367 |
> |
} |
368 |
> |
} |
369 |
> |
} |
370 |
|
} |
371 |
|
|
372 |
< |
fclose(f); |
372 |
> |
FILE* pFile = fopen(path,"wb" ); |
373 |
> |
WriteChunk(pFile, Primary_chunk); |
374 |
> |
fclose(pFile); |
375 |
|
|
376 |
|
// Events.clear(); |
377 |
|
} |