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

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