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

Last change on this file since 4308 was 2978, checked in by blanch, 21 years ago
Change in variables name to clarify the meaning. Small change to write brightness1.00.slt instead on brightness1.0.slt
File size: 4.1 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 information from FADC instance !!!!!
43
44 Float_t fadcresp[45] ;
45 fadc->GetResponse (fadcresp ) ;
46 data.SetFadcResponse( fadcresp ) ;
47
48 data.SetIntegFadc ( fadc->GetIntegral() ) ;
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 if(brightness<1.0)
78 sprintf(filename, "%sBrightness%.2f.root", path, brightness) ;
79 else
80 sprintf(filename, "%sBrightness%.1f.root", path, brightness) ;
81 sprintf(filename, "%sBrightness%.2f.root", path, brightness) ;
82 cout << " the file will be written in " << filename
83 << endl ;
84
85 data.StoreHisto( filename ) ;
86 }
87
88 return (0) ;
89
90}
91// ======================================================================
92// ======================================================================
93// ======================================================================
94// ======================================================================
95// ======================================================================
96// ======================================================================
97int main (int argc, char **argv )
98{
99 cout << " Start with the StarResponse " << endl ;
100
101 // first of all initalize ROOT
102
103 TROOT starrespo("starrespo", "The response of MAGIC to Starlight");
104
105 // Variables that define the StarLight which is going to be generated.
106
107 float nphe_min=0.0, nphe_max=10.0, nphe_pre=0.1;
108
109 float trig_fwhm,trig_ampl,trig_shape;
110 float fadc_fwhm,fadc_integral,fadc_shape;
111
112 //
113 char path[256] ;
114 char parfilename[256];
115 sprintf (path, "./") ;
116
117 // Instance of MFadc and MTrigger needed inside BuildStarLight
118 MTrigger *trigger;//= new MTrigger(1);
119 MFadc *fadc;//= new MFadc;
120
121 if(argc == 1){
122 sprintf(parfilename, "starresponse.par");
123 }
124 else{ // a filename was given
125 sprintf(parfilename, "%s", argv[1]);
126 }
127
128 // Reading parameters from input card
129
130 readparam(parfilename);
131
132 // Setting the parameters read from teh input card
133 strcpy( path,get_database_path());
134
135 get_simulated_phe(&nphe_min, &nphe_max, &nphe_pre);
136
137 get_trig_properties(&trig_shape, &trig_ampl, &trig_fwhm);
138 trigger = new MTrigger(1,0.,0.,trig_ampl,trig_fwhm);
139
140 get_fadc_properties(&fadc_shape, &fadc_integral, &fadc_fwhm);
141 fadc = new MFadc(1,fadc_integral,fadc_fwhm,fadc_integral,fadc_fwhm);
142
143 for (Float_t b=nphe_min; b<=nphe_max; b=b+nphe_pre ) // loop over Brightness
144 {
145 BuildStarLight (b, path, trigger, fadc ) ;
146 }
147 delete(trigger);
148 delete(fadc);
149
150 return 0;
151}
152
Note: See TracBrowser for help on using the repository browser.