source: trunk/MagicSoft/Simulation/Detector/StarResponse/starresponse.cxx@ 2521

Last change on this file since 2521 was 2374, checked in by blanch, 21 years ago
Removed warning about no main type.
File size: 3.9 KB
Line 
1#include "starresponse.hxx"
2
3#include <TROOT.h>
4#include <TRandom2.h>
5
6#include "MStarLight.hxx"
7#include "MTrigger.hxx"
8#include "MFadc.hxx"
9
10Int_t BuildStarLight( Float_t brightness, char *path, MTrigger *trigger, MFadc *fadc )
11{
12 // this functions fills the things with the standard response
13 // function of MTrigger and MFadc
14 //
15
16 cout << " filling Starlight for Brightness " << brightness
17 << " phe/nsec " << endl ;
18
19 char filename[256] ;
20
21 TRandom2 Zufall( (UInt_t) brightness * 100) ; // a random generator
22
23 MStarLight data ; // create instance of the MStarLight
24
25 // Shall I write the root file???
26
27 int write_root;
28
29 write_root= get_write_root();
30
31 // Get information from Trigger instance!!!
32
33 cout << sizeof (trigger) << endl ;
34
35 Float_t trigresp[40] ;
36 trigger->GetResponse ( trigresp ) ;
37 data.SetTrigResponse( trigresp ) ;
38
39 data.SetAmplTrig ( trigger->GetAmplitude() ) ;
40 data.SetFwhmTrig ( trigger->GetFwhm() ) ;
41
42 // Get infroamtion from FADC instance !!!!!
43
44 Float_t fadcresp[45] ;
45 fadc->GetResponse (fadcresp ) ;
46 data.SetFadcResponse( fadcresp ) ;
47
48 data.SetAmplFadc ( fadc->GetAmplitude() ) ;
49 data.SetFwhmFadc ( fadc->GetFwhm() ) ;
50
51 // start with the loop over random events
52 //
53
54 Float_t a = 0. ; // the amplitude of the signal
55 Float_t time = 0. ; // the time of the phe
56
57 for (Int_t i = 0 ; i< (Int_t ) (brightness * TIMERANGE) ; i++) {
58
59 a = trigger->FillStar( 500, 10.) ; // random the amplitude
60 time=Zufall.Rndm() * TIMERANGE ; // random the time
61
62 data.FillResponse(a, time ) ; // fill the response function
63
64 }
65
66 if(brightness<1.0)
67 sprintf(filename, "%sBrightness%.2f.slt", path, brightness) ;
68 else
69 sprintf(filename, "%sBrightness%.1f.slt", path, brightness) ;
70 data.WriteBinary( filename ) ;
71
72 data.Reset() ;
73
74 if(write_root){
75 data.ReadBinary( filename ) ;
76
77 sprintf(filename, "%sBrightness%.1f.root", path, brightness) ;
78 cout << " the file will be written in " << filename
79 << endl ;
80
81 data.StoreHisto( filename ) ;
82 }
83
84 return (0) ;
85
86}
87// ======================================================================
88// ======================================================================
89// ======================================================================
90// ======================================================================
91// ======================================================================
92// ======================================================================
93int main (int argc, char **argv )
94{
95 cout << " Start with the StarResponse " << endl ;
96
97 // first of all initalize ROOT
98
99 TROOT starrespo("starrespo", "The response of MAGIC to Starlight");
100
101 // Variables that define the StarLight which is going to be generated.
102
103 float nphe_min=0.0, nphe_max=10.0, nphe_pre=0.1;
104
105 float trig_fwhm,trig_ampl,trig_shape;
106 float fadc_fwhm,fadc_ampl,fadc_shape;
107
108 //
109 char path[256] ;
110 char parfilename[256];
111 sprintf (path, "./") ;
112
113 // Instance of MFadc and MTrigger needed inside BuildStarLight
114 MTrigger *trigger= new MTrigger(1);
115 MFadc *fadc= new MFadc;
116
117 if(argc == 1){
118 sprintf(parfilename, "starresponse.par");
119 }
120 else{ // a filename was given
121 sprintf(parfilename, "%s", argv[1]);
122 }
123
124 // Reading parameters from input card
125
126 readparam(parfilename);
127
128 // Setting the parameters read from teh input card
129 strcpy( path,get_database_path());
130
131 get_simulated_phe(&nphe_min, &nphe_max, &nphe_pre);
132
133 get_trig_properties(&trig_shape, &trig_ampl, &trig_fwhm);
134 trigger->SetAmpl(trig_ampl);
135 trigger->SetFwhm(trig_fwhm);
136
137 get_fadc_properties(&fadc_shape, &fadc_ampl, &fadc_fwhm);
138 fadc->SetAmpl(fadc_ampl);
139 fadc->SetFwhm(fadc_fwhm);
140
141 for (Float_t b=nphe_min; b<=nphe_max; b=b+nphe_pre ) // loop over Brightness
142 {
143 BuildStarLight (b, path, trigger, fadc ) ;
144 }
145 delete(trigger);
146 delete(fadc);
147
148 return 0;
149}
150
Note: See TracBrowser for help on using the repository browser.