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

Last change on this file since 5082 was 5082, checked in by moralejo, 20 years ago
*** empty log message ***
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
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.SetShapeFadc ( fadc->GetShape() ) ;
49 data.SetIntegFadc ( fadc->GetIntegral() ) ;
50 data.SetFwhmFadc ( fadc->GetFwhm() ) ;
51
52 // start with the loop over random events
53 //
54
55 Float_t a = 0. ; // the amplitude of the signal
56 Float_t time = 0. ; // the time of the phe
57
58 for (Int_t i = 0 ; i< (Int_t ) (brightness * TIMERANGE) ; i++) {
59
60 a = trigger->FillStar( 500, 10.) ; // random the amplitude
61 time=Zufall.Rndm() * TIMERANGE ; // random the time
62
63 data.FillResponse(a, time ) ; // fill the response function
64
65 }
66
67 if(brightness<=1.0)
68 sprintf(filename, "%sBrightness%.2f.slt", path, brightness) ;
69 else
70 sprintf(filename, "%sBrightness%.1f.slt", path, brightness) ;
71 data.WriteBinary( filename ) ;
72
73 data.Reset() ;
74
75 if(write_root){
76 data.ReadBinary( filename ) ;
77
78 if(brightness<1.0)
79 sprintf(filename, "%sBrightness%.2f.root", path, brightness) ;
80 else
81 sprintf(filename, "%sBrightness%.1f.root", path, brightness) ;
82 sprintf(filename, "%sBrightness%.2f.root", path, brightness) ;
83 cout << " the file will be written in " << filename
84 << endl ;
85
86 data.StoreHisto( filename ) ;
87 }
88
89 return (0) ;
90
91}
92// ======================================================================
93// ======================================================================
94// ======================================================================
95// ======================================================================
96// ======================================================================
97// ======================================================================
98int main (int argc, char **argv )
99{
100 cout << " Start with the StarResponse " << endl ;
101
102 // first of all initalize ROOT
103
104 TROOT starrespo("starrespo", "The response of MAGIC to Starlight");
105
106 // Variables that define the StarLight which is going to be generated.
107
108 float nphe_min=0.0, nphe_max=10.0, nphe_pre=0.1;
109
110 float trig_fwhm,trig_ampl;
111 float fadc_fwhm,fadc_integral;
112 int fadc_shape, trig_shape;
113
114 //
115 char path[256] ;
116 char parfilename[256];
117 sprintf (path, "./") ;
118
119 // Instance of MFadc and MTrigger needed inside BuildStarLight
120 MTrigger *trigger;//= new MTrigger(1);
121 MFadc *fadc;//= new MFadc;
122
123 if(argc == 1){
124 sprintf(parfilename, "starresponse.par");
125 }
126 else{ // a filename was given
127 sprintf(parfilename, "%s", argv[1]);
128 }
129
130 // Reading parameters from input card
131
132 readparam(parfilename);
133
134 // Setting the parameters read from teh input card
135 strcpy( path,get_database_path());
136
137 get_simulated_phe(&nphe_min, &nphe_max, &nphe_pre);
138
139 get_trig_properties(&trig_shape, &trig_ampl, &trig_fwhm);
140 trigger = new MTrigger(1,0.,0.,trig_ampl,trig_fwhm);
141
142 get_fadc_properties(&fadc_shape, &fadc_integral, &fadc_fwhm);
143 fadc = new MFadc(1,fadc_shape,fadc_integral,fadc_fwhm,fadc_shape,fadc_integral,fadc_fwhm);
144
145 for (Float_t b=nphe_min; b<=nphe_max; b=b+nphe_pre ) // loop over Brightness
146 {
147 BuildStarLight (b, path, trigger, fadc ) ;
148 }
149 delete(trigger);
150 delete(fadc);
151
152 return 0;
153}
154
Note: See TracBrowser for help on using the repository browser.