hepmc - Diff between revs 371 and 376

Subversion Repositories:
Rev:
Show entire file - Ignore whitespace
Rev 371 Rev 376
Line 59... Line 59...
59 } 59 }
60 60
61 // clean up and get next event 61 // clean up and get next event
62 delete evt; 62 delete evt;
63 ascii_in >> evt; 63 ascii_in >> evt;
64 } -  
65 // print status of input stream -  
66 if ( ascii_in.error_type() != 0 ) { -  
67 std::cout << "processing of @srcdir@/testIOGenEvent.input ended with error " -  
68 << ascii_in.error_type() << std::endl; -  
69 std::cout << " --- " << ascii_in.error_message() << std::endl; -  
70 } 64 }
71 //........................................PRINT RESULT 65 //........................................PRINT RESULT
72 std::cout << num_good_events << " out of " << icount 66 std::cout << num_good_events << " out of " << icount
73 << " processed events passed the cuts. Finished." << std::endl; 67 << " processed events passed the cuts. Finished." << std::endl;
74 } 68 }
Line 90... Line 84...
90 << std::endl; 84 << std::endl;
91 return; 85 return;
92 } 86 }
93 //........................................EVENT LOOP 87 //........................................EVENT LOOP
94 int icount=0; 88 int icount=0;
95 int invaliddata=0; -  
96 bool ok = true; -  
97 HepMC::GenEvent* evt = ascii_in.read_next_event(); 89 HepMC::GenEvent* evt = ascii_in.read_next_event();
98 while ( ok ) { -  
99 if( evt ) { -  
100 icount++; -  
101 if ( icount%50==1 ) std::cout << "Processing Event Number " << icount -  
102 << " its # " << evt->event_number() -  
103 << std::endl; -  
104 ascii_out << evt; -  
-   90 while ( evt ) {
-   91 icount++;
-   92 if ( icount%50==1 ) std::cout << "Processing Event Number " << icount
-   93 << " its # " << evt->event_number()
-   94 << std::endl;
-   95 ascii_out << evt;
105 96
106 // clean up and get next event -  
107 delete evt; -  
108 ascii_in >> evt; -  
109 } else if (ascii_in.error_type() == HepMC::IO_Exception::InvalidData ) { -  
110 ++invaliddata; -  
111 std::cerr << "INPUT ERROR: " << ascii_in.error_message() << std::endl; -  
112 // clean up and get next event -  
113 delete evt; -  
114 ascii_in >> evt; -  
115 } else if (invaliddata > 50 ) { -  
116 ok = false; -  
117 } else { -  
118 ok = false; -  
119 } -  
120 } -  
121 // print status of input stream -  
122 if ( ascii_in.error_type() != 0 ) { -  
123 std::cout << "processing of @srcdir@/testAscii.input ended with error " -  
124 << ascii_in.error_type() << std::endl; -  
125 std::cout << " --- " << ascii_in.error_message() << std::endl; -  
-   97 // clean up and get next event
-   98 delete evt;
-   99 ascii_in >> evt;
126 } 100 }
127 //........................................PRINT RESULT 101 //........................................PRINT RESULT
128 std::cout << icount << " events processed. Finished." << std::endl; 102 std::cout << icount << " events processed. Finished." << std::endl;
129 } 103 }
130 104
Line 132... Line 106...
132 { 106 {
133 // extended (complete) output 107 // extended (complete) output
134 HepMC::IO_GenEvent xin("@srcdir@/testHepMCExtended.input",std::ios::in); 108 HepMC::IO_GenEvent xin("@srcdir@/testHepMCExtended.input",std::ios::in);
135 // declare another IO_GenEvent for output 109 // declare another IO_GenEvent for output
136 HepMC::IO_GenEvent xout("testIOHepMCExtended.dat",std::ios::out); 110 HepMC::IO_GenEvent xout("testIOHepMCExtended.dat",std::ios::out);
137 IsGoodEvent is_good_event; -  
138 //........................................EVENT LOOP 111 //........................................EVENT LOOP
139 int icount=0; 112 int icount=0;
140 int invaliddata=0; -  
141 bool ok = true; -  
142 int num_good_events=0; -  
143 HepMC::GenEvent* evt = xin.read_next_event(); 113 HepMC::GenEvent* evt = xin.read_next_event();
144 //while ( evt ) { -  
145 while ( ok ) { -  
146 if( evt ) { -  
147 icount++; -  
148 if ( icount%50==1 ) std::cout << "Processing Event Number " << icount -  
149 << " its # " << evt->event_number() -  
150 << std::endl; -  
151 //xout << evt; -  
152 if ( is_good_event(evt) ) { -  
153 xout << evt; -  
154 ++num_good_events; -  
155 } -  
-   114 while ( evt ) {
-   115 icount++;
-   116 if ( icount%50==1 ) std::cout << "Processing Event Number " << icount
-   117 << " its # " << evt->event_number()
-   118 << std::endl;
-   119 xout << evt;
156 120
157 // clean up and get next event -  
158 delete evt; -  
159 xin >> evt; -  
160 } else if (xin.error_type() == HepMC::IO_Exception::InvalidData ) { -  
161 ++invaliddata; -  
162 std::cerr << "INPUT ERROR: " << xin.error_message() << std::endl; -  
163 // clean up and get next event -  
164 delete evt; -  
165 xin >> evt; -  
166 } else if (invaliddata > 50 ) { -  
167 std::cerr << "INPUT ERROR: " << xin.error_message() << std::endl; -  
168 ok = false; -  
169 } else { -  
170 ok = false; -  
171 } -  
172 } -  
173 // print status of input stream -  
174 if ( xin.error_type() != 0 ) { -  
175 std::cout << "processing of @srcdir@/testHepMCExtended.input ended with error " -  
176 << xin.error_type() << std::endl; -  
177 std::cout << " --- " << xin.error_message() << std::endl; -  
-   121 // clean up and get next event
-   122 delete evt;
-   123 xin >> evt;
178 } 124 }
179 std::cout << icount << " events processed. Finished." << std::endl; 125 std::cout << icount << " events processed. Finished." << std::endl;
180 } 126 }
181 127
182 void read_various() 128 void read_various()
Line 195... Line 141...
195 << std::endl; 141 << std::endl;
196 ascii_out << evt; 142 ascii_out << evt;
197 // clean up and get next event 143 // clean up and get next event
198 delete evt; 144 delete evt;
199 ascii_in >> evt; 145 ascii_in >> evt;
200 } -  
201 // print status of input stream -  
202 if ( ascii_in.error_type() != 0 ) { -  
203 std::cout << "processing of @srcdir@/testHepMCVarious.input ended with error " -  
204 << ascii_in.error_type() << std::endl; -  
205 std::cout << " --- " << ascii_in.error_message() << std::endl; -  
206 } 146 }
207 //........................................PRINT RESULT 147 //........................................PRINT RESULT
208 std::cout << icount << " events processed. Finished." << std::endl; 148 std::cout << icount << " events processed. Finished." << std::endl;
209 } 149 }