source: trunk/MagicSoft/Simulation/Corsika/Simone/simone.cxx@ 6724

Last change on this file since 6724 was 722, checked in by harald, 24 years ago
Added the functionality that is runs moerless proper. It is now able to read the single file MMCS output.
File size: 2.8 KB
Line 
1//
2//
3//
4//
5//
6//
7#include <stdlib.h>
8#include <stdio.h>
9
10#include "COREventHeader.hxx"
11#include "CORParticle.hxx"
12#include "CORStatfile.hxx"
13
14int main(int argc, char **argv)
15{
16 char path[100] = "" ;
17
18 char cername[120] ;
19 char datname[120] ;
20
21 ifstream cerfile ;
22
23 COREventHeader Event ;
24 CORParticle Photon ;
25
26 Int_t iPhotonInShower ;
27 Int_t iShowers = 0 ;
28
29 Float_t lambda ;
30
31 cout << " ============================" << endl ;
32 cout << " SIMONE" << endl ;
33 cout << " " << endl ;
34 cout << " SImulated MONte carlo Events" << endl ;
35 cout << " " << endl ;
36
37
38 if ( argc <= 1 ) {
39 cout << endl ;
40 cout << " INFO: You have to start the program with "<<endl <<endl ;
41 cout << " -> simone DIRECTORY_WITH_CER_FILES" <<endl <<endl ;
42 cout << " no SLASH at the end of the directory name"<<endl ;
43 cout << " (example: -> simone /hd123/Protons "<<endl ;
44 exit (-1) ;
45 }
46
47 // copy the argument to filename
48
49 sprintf (cername , "%s", argv[1] ) ;
50
51
52 cout << cername << endl ;
53
54 //
55 // try to open the files
56 //
57
58 cerfile.open( cername );
59
60 if ( cerfile.bad() ) {
61 cout << "Cannot open input file: " << cername << endl ;
62 exit (1) ;
63 }
64
65 //
66 // cout << " Read event " << endl ;
67 //
68
69 // tricky stuff. We read in the RunHeader which has by chance the
70 // same sice than the EventHeader
71 Event.read( cerfile );
72 Event.Print() ;
73 // now we read in the event
74
75 while( ! (cerfile.eof() || cerfile.bad() )) {
76
77 Event.read( cerfile );
78
79 Event.Print() ;
80
81 iShowers++ ;
82
83 //
84 // loop over the particles (cerenkov photons) in
85 // the file
86 //
87
88 iPhotonInShower = 0 ;
89
90 while( ! (cerfile.eof() || cerfile.bad() )) {
91
92 //
93 // read in the particles
94 //
95
96 Photon.read ( cerfile ) ;
97
98 //
99 // only if the wavelength lambda is greater than
100 // 1.0 it is a real cerenkov photon
101 //
102 lambda = Photon.get_wl() ;
103
104 // Photon.print() ;
105
106 if ( lambda < 1.0 ) {
107 // here we got to the next event reading in all the ZERO
108 // from the file
109 while ( lambda < 1. && ! (cerfile.eof() || cerfile.bad() ) ) {
110
111 Photon.read ( cerfile ) ;
112 lambda = Photon.get_wl() ;
113 // cout << lambda << endl ;
114 }
115
116 // go back in the file
117 cerfile.seekg( -28, ios::cur ) ;
118
119 // read in an Event footer or something like that
120 Event.read( cerfile );
121
122 break ;
123 }
124
125 iPhotonInShower++ ;
126
127 }
128
129 cout << "Number of Photons In Shower: "
130 << iPhotonInShower << endl ;
131
132
133
134 }
135
136 //
137 // close the file
138 //
139
140 cerfile.close();
141
142}
143
144
Note: See TracBrowser for help on using the repository browser.