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

Last change on this file since 664 was 631, checked in by magicsol, 24 years ago
It produces the database for the NSB.
File size: 3.4 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 // create a Standard Trigger !!!
26
27 //MTrigger trigger ;
28
29
30 cout << sizeof (trigger) << endl ;
31
32 Float_t trigresp[40] ;
33 trigger->GetResponse ( trigresp ) ;
34 data.SetTrigResponse( trigresp ) ;
35
36 data.SetAmplTrig ( trigger->GetAmplitude() ) ;
37 data.SetFwhmTrig ( trigger->GetFwhm() ) ;
38
39 // create a Standard FADC !!!!!
40
41 //MFadc fadc ;
42 Float_t fadcresp[45] ;
43 fadc->GetResponse (fadcresp ) ;
44 data.SetFadcResponse( fadcresp ) ;
45
46 data.SetAmplFadc ( fadc->GetAmplitude() ) ;
47 data.SetFwhmFadc ( fadc->GetFwhm() ) ;
48
49 // start with the loop over random events
50 //
51
52 Float_t a = 0. ; // the amplitude of the signal
53 Float_t time = 0. ; // the time of the phe
54
55 for (Int_t i = 0 ; i< (Int_t ) (brightness * TIMERANGE) ; i++) {
56
57 a = trigger->FillStar( 500, 10.) ; // random the amplitude
58 time=Zufall.Rndm() * TIMERANGE ; // random the time
59
60 data.FillResponse(a, time ) ; // fill the response function
61
62 }
63
64 // data.ElecNoise() ;
65
66
67
68
69 sprintf(filename, "%sBrightness%.1f.slt", path, brightness) ;
70 data.WriteBinary( filename ) ;
71
72 data.Reset() ;
73
74 data.ReadBinary( filename ) ;
75
76 sprintf(filename, "%sBrightness%.1f.root", path, brightness) ;
77 cout << " the file will be written in " << filename
78 << endl ;
79
80 data.StoreHisto( filename ) ;
81
82 return (0) ;
83
84}
85// ======================================================================
86// ======================================================================
87// ======================================================================
88// ======================================================================
89// ======================================================================
90// ======================================================================
91main (int argc, char **argv )
92{
93 cout << " Start with the StarResponse " << endl ;
94
95 // first of all initalize ROOT
96
97 TROOT starrespo("starrespo", "The response of MAGIC to Starlight");
98
99 // Variables that define the StarLight which is going to be generated.
100
101 float nphe_min=0.0, nphe_max=10.0, nphe_pre=0.1;
102
103 //
104 char path[256] ;
105 char parfilename[256];
106 sprintf (path, "./") ;
107
108 // Instance of MFadc and MTrigger needed inside BuildStarLight
109 MTrigger *trigger= new MTrigger;
110 MFadc *fadc= new MFadc;
111
112 if(argc == 1){
113 sprintf(parfilename, "starresponse.par");
114 }
115 else{ // a filename was given
116 sprintf(parfilename, "%s", argv[1]);
117 }
118
119 readparam(parfilename);
120
121 strcpy( path,get_database_path());
122
123 get_simulated_phe(&nphe_min, &nphe_max, &nphe_pre);
124
125 for (Float_t b=nphe_min; b<=nphe_max; b=b+nphe_pre ) // loop over Brightness
126 {
127 BuildStarLight (b, path, trigger, fadc ) ;
128 }
129 delete(trigger);
130 delete(fadc);
131}
132
Note: See TracBrowser for help on using the repository browser.