source: trunk/MagicSoft/Simulation/Detector/include-MTrigger/MTrigger.hxx@ 5441

Last change on this file since 5441 was 5321, checked in by moralejo, 20 years ago
*** empty log message ***
File size: 7.1 KB
Line 
1#ifndef __MTrigger__
2#define __MTrigger__
3
4#define CASE_SHOW 0
5#define CASE_NSB 1
6#define CASE_STAR 2
7
8// class MTrigger
9//
10// implemented by Harald Kornmayer
11//
12// This is a class to simulate the trigger.
13// It assumes a special response of the PMT for one single Photo-electron.
14//
15//
16//
17#include <iostream>
18#include <math.h>
19
20#include "TROOT.h"
21#include "TObject.h"
22#include "TRandom.h"
23#include "TH1.h"
24
25#include "Mdefine.h"
26#include "MMcEvt.hxx"
27
28#include "MGeomCam.h"
29
30#include "MTriggerDefine.h"
31
32
33//==========
34// MTrigger FIXME: some explanations are rather outdated!!
35//
36// The simulation of the Trigger for MonteCarlo Events is using this
37// class. So all methods concerning the trigger should be done inside this
38// class.
39//
40// For a better understanding of the behavior of the trigger is here small
41// abstract of the trigger. This may change in the future.
42//
43//
44// We now from the camera program (This is the surrounding of the class
45// MTrigger.) that one photo electron leaves at time t the photo cathode
46// of the pixel number iPix).
47//
48// At the end of the PMT, the preamp, the optical fiber transmission we
49// get a signal of a given shape. After some discussion with Eckart the
50// standard response function looks like this :
51//
52// It is a gaussian Signal with a given FWHM.
53//
54// So whenever a photo electron leaves the photo cathod, on has to add
55// the standard response function to the analog signal of the pixel.
56//
57// Each pixel of the camera has such an summed-up analog signal.
58//
59// This is the input of the discriminator for the pixels. The output of
60// the discriminator is a digital signal. The response of the diskriminator
61// is not fixed at the moment. There are discussion about this topic.
62//
63// At the moment the response is very simple. Whenever the analog signal
64// is crossing a defined threshold from below to above, a digital signal
65// with a given length is created.
66//
67// Now one can start with the simulation of different trigger levels.
68//
69// The TriggerLevelZero is a very easy one. It is just looking if there
70// are more than N digital signals at level ON (=1). If this is the case,
71// a TriggerLevelZero signal is created.
72//
73//
74//
75class MTrigger {
76
77 private:
78 Int_t pixnum;
79 //
80 // then for all pixels the shape of all the analog signals
81 //
82 Bool_t *used; // a boolean to indicated if the pixels is used in this event
83 Int_t *nphotshow; // count the photo electrons per pixel coming from showers
84 Int_t *nphotnsb; // count the photo electrons per pixel coming from NSB
85 Int_t *nphotstar; // count the photo electrons per pixel coming from stars
86
87 Float_t **a_sig ; // the analog signal for pixels
88
89 Float_t *baseline; // for the baseline shift
90
91 //
92 // then for all pixels the shape of the digital signal
93 //
94 Bool_t *dknt ; // a boolean to indicated if the pixels has passed the diskrminator
95 Float_t **d_sig ; // the digital signal for all pixels
96
97 //
98 // and the sum of all digital signals
99 //
100 Float_t sum_d_sig[TRIGGER_TIME_SLICES] ;
101
102 //
103 // first the data for the response function
104 //
105 Float_t fwhm_resp ; // fwhm of the phe_response function
106 Float_t ampl_resp ; // amplitude of the phe_response function (in mV)
107 Float_t sing_resp[RESPONSE_SLICES_TRIG] ; // the shape of the phe_response function
108 Float_t peak_time ; // the time from the start of the response
109 // function to the maximum peak
110
111 TH1F *histPmt ;
112 Float_t histMean ; // Mean value of the distribution of Razmik (stored in histPmt)
113 TRandom *GenElec ; // RandomGenerator for the Electronic Noise
114
115 Float_t *noise;
116
117 //
118 // some values for the trigger settings
119 //
120
121 Float_t *chan_thres ; // the threshold (in mV) for each individuel pixels
122 Float_t gate_leng ; // the length of the digital signal if analog signal is above threshold
123
124 Float_t overlaping_time; // Minimum coincidence time
125
126 Float_t trigger_multi ; // Number of Pixels requested for a Trigger
127 Int_t trigger_geometry ; // 0 means a pixel with trigger_multi-1 neighbours
128 // 1 means trigger_multi neighbours
129 // 2 means trigger_multi closed neighbours
130 //
131 // The lookup table for the next neighbours
132 //
133
134 Int_t *NN[6] ;
135
136 //
137 // The lookup table for trigger cells
138 //
139
140 Int_t *TC[TRIGGER_CELLS] ;
141
142 //
143 // some information about the different TriggerLevels in each Event
144 //
145
146 Int_t nZero ; // how many ZeroLevel Trigger in one Event
147 Bool_t SlicesZero[TRIGGER_TIME_SLICES] ; // Times Slices at which the ZeroLevel Triggers occur
148
149 Int_t nFirst ; // how many FirstLevel Trigger in one Event
150 Int_t SlicesFirst[5] ; // Times Slices at which the FirstLevel Triggers occur
151 Int_t PixelsFirst[5] ; // Pixel which fires the trigger
152
153 Int_t nSecond ; // how many SecondLevel Trigger in one Event
154 Int_t SlicesSecond[5] ; // Times Slices at which the SecondLevel Triggers occur
155 Int_t PixelsSecond[5] ; // Pixel which fires the trigger
156
157 Float_t Fill( Int_t, Float_t, Int_t ) ;
158
159 Bool_t PassNextNeighbour( Bool_t m[], Bool_t *n) ;
160
161 void OverlapingTime( Bool_t m[], Bool_t *n, Int_t ifSli);
162 // n[] will have pixels of m[] that are on for the required overlaping time
163
164 Bool_t fGainFluctuations;
165 void InitGainFluctuations();
166
167public:
168
169 MTrigger(int pix=577) ;
170
171 MTrigger(int pix, MGeomCam *camgeom,
172 float gate, float overt, float ampl, float fwhm, int ct_id=0) ;
173
174 MTrigger(int pix,
175 float gate, float overt, float ampl, float fwhm) ;
176
177 ~MTrigger() ;
178
179 void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);}
180
181 void Reset() ;
182
183 void ClearZero() ;
184
185 void ClearFirst() ;
186
187 Float_t FillShow( Int_t, Float_t ) ;
188
189 Float_t FillNSB( Int_t, Float_t ) ;
190
191 Float_t FillStar( Int_t, Float_t ) ;
192
193 void AddNSB( Int_t pix, Float_t resp[TRIGGER_TIME_SLICES]);
194
195 void SetElecNoise(Float_t factor=0.3);
196
197 void ElecNoise(Float_t factor = 0.3) ;
198
199 void SetResponseShape();
200
201 void SetMultiplicity (Int_t multi);
202
203 void SetTopology (Int_t topo);
204
205 void SetThreshold (Float_t thres[]);
206
207 void SetFwhm(Float_t fwhm);
208
209 void SetAmpl(Float_t ampl){
210 ampl_resp=ampl;
211 }
212
213 void SetGainFluctuations(Bool_t x) { fGainFluctuations = x; }
214
215 void CheckThreshold (float *thres, int cells);
216
217 void ReadThreshold (char name[]);
218
219 void ReadParam(char name[]);
220
221 Float_t GetMultiplicity (){
222 return(trigger_multi);
223 }
224
225 Int_t GetTopology (){
226 return(trigger_geometry);
227 }
228
229 Float_t GetThreshold (Int_t il){
230 return(chan_thres[il]);
231 }
232
233 void GetResponse( Float_t * resp) ;
234
235 void GetMapDiskriminator(Byte_t *map);
236
237 void Diskriminate() ;
238
239 void ShowSignal (MMcEvt *McEvt) ;
240
241 Int_t ZeroLevel() ;
242
243 Int_t FirstLevel() ;
244
245 Float_t GetFirstLevelTime( Int_t il ) ;
246
247 Int_t GetFirstLevelPixel( Int_t il ) ;
248
249 Float_t GetAmplitude() {
250 return ampl_resp ;
251 }
252
253 Float_t GetFwhm() {
254 return fwhm_resp ;
255 }
256
257 Bool_t GetGainFluctuations() { return fGainFluctuations; }
258
259} ;
260
261#endif
262
Note: See TracBrowser for help on using the repository browser.