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 |
|
---|
10 | Int_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 | sprintf(filename, "%sBrightness%.1f.slt", path, brightness) ;
|
---|
67 | data.WriteBinary( filename ) ;
|
---|
68 |
|
---|
69 | data.Reset() ;
|
---|
70 |
|
---|
71 | if(write_root){
|
---|
72 | data.ReadBinary( filename ) ;
|
---|
73 |
|
---|
74 | sprintf(filename, "%sBrightness%.1f.root", path, brightness) ;
|
---|
75 | cout << " the file will be written in " << filename
|
---|
76 | << endl ;
|
---|
77 |
|
---|
78 | data.StoreHisto( filename ) ;
|
---|
79 | }
|
---|
80 |
|
---|
81 | return (0) ;
|
---|
82 |
|
---|
83 | }
|
---|
84 | // ======================================================================
|
---|
85 | // ======================================================================
|
---|
86 | // ======================================================================
|
---|
87 | // ======================================================================
|
---|
88 | // ======================================================================
|
---|
89 | // ======================================================================
|
---|
90 | main (int argc, char **argv )
|
---|
91 | {
|
---|
92 | cout << " Start with the StarResponse " << endl ;
|
---|
93 |
|
---|
94 | // first of all initalize ROOT
|
---|
95 |
|
---|
96 | TROOT starrespo("starrespo", "The response of MAGIC to Starlight");
|
---|
97 |
|
---|
98 | // Variables that define the StarLight which is going to be generated.
|
---|
99 |
|
---|
100 | float nphe_min=0.0, nphe_max=10.0, nphe_pre=0.1;
|
---|
101 |
|
---|
102 | float trig_fwhm,trig_ampl,trig_shape;
|
---|
103 | float fadc_fwhm,fadc_ampl,fadc_shape;
|
---|
104 |
|
---|
105 | //
|
---|
106 | char path[256] ;
|
---|
107 | char parfilename[256];
|
---|
108 | sprintf (path, "./") ;
|
---|
109 |
|
---|
110 | // Instance of MFadc and MTrigger needed inside BuildStarLight
|
---|
111 | MTrigger *trigger= new MTrigger;
|
---|
112 | MFadc *fadc= new MFadc;
|
---|
113 |
|
---|
114 | if(argc == 1){
|
---|
115 | sprintf(parfilename, "starresponse.par");
|
---|
116 | }
|
---|
117 | else{ // a filename was given
|
---|
118 | sprintf(parfilename, "%s", argv[1]);
|
---|
119 | }
|
---|
120 |
|
---|
121 | // Reading parameters from input card
|
---|
122 |
|
---|
123 | readparam(parfilename);
|
---|
124 |
|
---|
125 | // Setting the parameters read from teh input card
|
---|
126 | strcpy( path,get_database_path());
|
---|
127 |
|
---|
128 | get_simulated_phe(&nphe_min, &nphe_max, &nphe_pre);
|
---|
129 |
|
---|
130 | get_trig_properties(&trig_shape, &trig_ampl, &trig_fwhm);
|
---|
131 | trigger->SetAmpl(trig_ampl);
|
---|
132 | trigger->SetFwhm(trig_fwhm);
|
---|
133 |
|
---|
134 | get_fadc_properties(&fadc_shape, &fadc_ampl, &fadc_fwhm);
|
---|
135 | fadc->SetAmpl(fadc_ampl);
|
---|
136 | fadc->SetFwhm(fadc_fwhm);
|
---|
137 |
|
---|
138 | for (Float_t b=nphe_min; b<=nphe_max; b=b+nphe_pre ) // loop over Brightness
|
---|
139 | {
|
---|
140 | BuildStarLight (b, path, trigger, fadc ) ;
|
---|
141 | }
|
---|
142 | delete(trigger);
|
---|
143 | delete(fadc);
|
---|
144 | }
|
---|
145 |
|
---|