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

Last change on this file since 417 was 415, checked in by harald, 25 years ago
small changes to read in also cphotons
File size: 2.8 KB
Line 
1//
2//
3//
4//
5//
6//
7#include <stdlib.h>
8#include "TROOT.h"
9#include "TApplication.h"
10
11#include "TCanvas.h"
12#include "TView.h"
13
14#include "TSPHE.h"
15#include "TBRIK.h"
16
17#include "TNode.h"
18
19#include "TFile.h"
20#include "TNtuple.h"
21
22#include "COREventHeader.hxx"
23#include "CORParticle.hxx"
24#include "CORStatfile.hxx"
25
26#include "MSimone.hxx"
27
28int main(int argc, char **argv)
29{
30 // initialise ROOT
31
32 TROOT simple("simple", "SIMONE - statistic of MonteCarlo");
33
34 TApplication theApp("App", &argc, argv);
35
36 char path[100] = "/dat1/Mmcs/Gamm/" ;
37 // char path[100] = "/hd02/Maggi/Data/prot_15/" ;
38 // char path[100] = "/data/mmcs/" ;
39 char cername[120] ;
40 char datname[120] ;
41
42 ifstream cerfile ;
43
44 COREventHeader Event ;
45 CORParticle Photon ;
46
47 MSimone Infos ;
48
49 Int_t iPhotonInShower ;
50
51 Float_t lambda ;
52
53 cout << " SImulated MONte carlo Events" << endl ;
54
55 //
56 // now create a root-file for the ntuple output
57 //
58
59 TFile *outfile = new TFile("simone.root","RECREATE");
60
61 TNtuple *Ntup = new TNtuple("simone",
62 "Simone info of mmcs",
63 "fPartId:fEnergy:fTheta:fPhi:fCoreX:fCoreY:fCoreD:fNumCerPhot");
64
65
66 for (int i_cer = 1; i_cer <= 100; i_cer++ ) {
67 //
68 // info of progress
69 //
70 if (!( i_cer %10) )
71 {
72 cout << i_cer << endl ;
73 }
74
75 //
76 // create the file names
77 //
78 sprintf ( cername, "%s/cer%06d", path, i_cer ) ;
79 sprintf ( datname, "%s/dat%06d", path, i_cer ) ;
80
81 // cout << cername << endl ;
82 // cout << datname << endl ;
83
84 //
85 // try to open the files
86 //
87
88 cerfile.open( cername );
89
90 if ( cerfile.bad() ) {
91 cout << "Cannot open input file: " << cername << endl ;
92 continue ;
93 }
94
95 //
96 // cout << " Read event " << endl ;
97 //
98
99 Event.read( cerfile );
100 Infos.Transfer ( &Event ) ;
101
102 //
103 // loop over the particles (cerenkov photons) in
104 // the file
105 //
106
107 iPhotonInShower = 0 ;
108
109 while( ! (cerfile.eof() || cerfile.bad() )) {
110
111 //
112 // read in the particles
113 //
114
115 Photon.read ( cerfile ) ;
116
117 //
118 // only if the wavelength lambda is greater than
119 // 1.0 it is a real cerenkov photon
120 //
121 lambda = Photon.get_wl() ;
122
123 if ( lambda < 1.0 )
124 break ;
125
126 iPhotonInShower++ ;
127
128 //Photon.print() ;
129 }
130
131 Infos.SetNumCerPhot( iPhotonInShower ) ;
132
133 //
134 // fill the ntuple
135 //
136
137 Infos.NtupFill ( Ntup ) ;
138
139
140 cerfile.close();
141
142
143
144 }
145
146
147 //
148 // write all to file
149 //
150 outfile->Write() ;
151
152
153 //
154 //
155 //
156
157 Ntup->Draw("fEnergy") ;
158
159
160 theApp.Run();
161 return 0;
162
163
164}
165
166
Note: See TracBrowser for help on using the repository browser.