| 1 | /////////////////////////////////////////////////////////////////
|
|---|
| 2 | //
|
|---|
| 3 | // MFadc
|
|---|
| 4 | //
|
|---|
| 5 | //
|
|---|
| 6 | #include "MFadc.hxx"
|
|---|
| 7 |
|
|---|
| 8 | #include "MMcEvt.h"
|
|---|
| 9 |
|
|---|
| 10 | #include "TROOT.h"
|
|---|
| 11 | #include <TApplication.h>
|
|---|
| 12 | #include <TVirtualX.h>
|
|---|
| 13 | #include <TGClient.h>
|
|---|
| 14 |
|
|---|
| 15 | #include "TH1.h"
|
|---|
| 16 | #include "TObjArray.h"
|
|---|
| 17 |
|
|---|
| 18 | #include "MGFadcSignal.hxx"
|
|---|
| 19 |
|
|---|
| 20 | MFadc::MFadc() {
|
|---|
| 21 | //
|
|---|
| 22 | // default constructor
|
|---|
| 23 | //
|
|---|
| 24 | // The procedure is the following:
|
|---|
| 25 | // 1. some parameters of the trigger are set to default.
|
|---|
| 26 | // this parameters of the trigger may be changed
|
|---|
| 27 | // 3. Then the all signals are set to zero
|
|---|
| 28 |
|
|---|
| 29 | fwhm_resp = MFADC_RESPONSE_FWHM ;
|
|---|
| 30 | ampl_resp = MFADC_RESPONSE_AMPLITUDE ;
|
|---|
| 31 |
|
|---|
| 32 | //
|
|---|
| 33 | // set up the response shape
|
|---|
| 34 | //
|
|---|
| 35 | Int_t i,j ;
|
|---|
| 36 |
|
|---|
| 37 | Float_t sigma ;
|
|---|
| 38 | Float_t x, x0 ;
|
|---|
| 39 |
|
|---|
| 40 | sigma = fwhm_resp / 2.35 ;
|
|---|
| 41 | x0 = 3*sigma ;
|
|---|
| 42 |
|
|---|
| 43 | Float_t dX, dX2 ;
|
|---|
| 44 |
|
|---|
| 45 | dX = WIDTH_FADC_TIMESLICE / SUBBINS ;
|
|---|
| 46 | dX2 = dX/2. ;
|
|---|
| 47 |
|
|---|
| 48 | for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {
|
|---|
| 49 |
|
|---|
| 50 | x = i * dX + dX2 ;
|
|---|
| 51 |
|
|---|
| 52 | //
|
|---|
| 53 | // the value 0.125 was introduced to normalize the things
|
|---|
| 54 | //
|
|---|
| 55 | sing_resp[i] = 0.125 *
|
|---|
| 56 | ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
|
|---|
| 57 |
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | //
|
|---|
| 61 | // init the Random Generator for Electonic Noise
|
|---|
| 62 | //
|
|---|
| 63 |
|
|---|
| 64 | GenElec = new TRandom () ;
|
|---|
| 65 |
|
|---|
| 66 | //
|
|---|
| 67 | // set all the booleans used to FALSE, indicating that the pixel is not
|
|---|
| 68 | // used in this event.
|
|---|
| 69 | //
|
|---|
| 70 |
|
|---|
| 71 | for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
|
|---|
| 72 | used [i] = FALSE ;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | //
|
|---|
| 76 | // set tha values of FADC slices that would be read after trigger to zero
|
|---|
| 77 | //
|
|---|
| 78 |
|
|---|
| 79 | for (i=0; i <CAMERA_PIXELS; i++){
|
|---|
| 80 | for (j=0; j<FADC_SLICES;j++){
|
|---|
| 81 | output[i][j]=0;
|
|---|
| 82 | }
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | void MFadc::Reset() {
|
|---|
| 89 | //
|
|---|
| 90 | // set all values of the signals to zero
|
|---|
| 91 | //
|
|---|
| 92 | Int_t i,j ;
|
|---|
| 93 |
|
|---|
| 94 | for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
|
|---|
| 95 | used [i] = FALSE ;
|
|---|
| 96 | }
|
|---|
| 97 | //
|
|---|
| 98 | // set tha values of FADC slices that would be read after trigger to zero
|
|---|
| 99 | //
|
|---|
| 100 |
|
|---|
| 101 | for (i=0; i <CAMERA_PIXELS; i++){
|
|---|
| 102 | for (j=0; j<FADC_SLICES;j++){
|
|---|
| 103 | output[i][j]=0;
|
|---|
| 104 | }
|
|---|
| 105 | }
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) {
|
|---|
| 110 |
|
|---|
| 111 | //
|
|---|
| 112 | // fills the information about one single Phe in the Trigger class
|
|---|
| 113 | //
|
|---|
| 114 | // parameter is the number of the pixel and the time-difference to the
|
|---|
| 115 | // first particle
|
|---|
| 116 | //
|
|---|
| 117 | //
|
|---|
| 118 |
|
|---|
| 119 | Int_t i, ichan, ichanfadc ;
|
|---|
| 120 |
|
|---|
| 121 | //
|
|---|
| 122 | // first we have to check if the pixel iPix is used or not until now
|
|---|
| 123 | // if this is the first use, reset all signal for that pixels
|
|---|
| 124 | //
|
|---|
| 125 | if ( iPix > CAMERA_PIXELS ) {
|
|---|
| 126 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
|---|
| 127 | << endl ;
|
|---|
| 128 | exit(987) ;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | if ( used[iPix] == FALSE ) {
|
|---|
| 132 | used [iPix] = TRUE ;
|
|---|
| 133 |
|
|---|
| 134 | for (i=0; i < SLICES_MFADC; i++ ) {
|
|---|
| 135 | sig[iPix][i] = 0. ;
|
|---|
| 136 | }
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | //
|
|---|
| 140 | // then select the time slice to use (ican)
|
|---|
| 141 | //
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | if ( time < 0. ) {
|
|---|
| 145 | cout << " WARNING! Fadc::Fill " << time << " below ZERO!! Very strange!!"
|
|---|
| 146 | << endl ;
|
|---|
| 147 | }
|
|---|
| 148 | else if ( time < TOTAL_TRIGGER_TIME ) {
|
|---|
| 149 | //
|
|---|
| 150 | // determine the slices number assuming the WIDTH_RESPONSE_MFADC
|
|---|
| 151 | //
|
|---|
| 152 | ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
|
|---|
| 153 |
|
|---|
| 154 | //
|
|---|
| 155 | // putting the response slices in the right sig slices.
|
|---|
| 156 | // Be carefull, because both slices have different widths.
|
|---|
| 157 | //
|
|---|
| 158 |
|
|---|
| 159 | for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
|
|---|
| 160 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
|
|---|
| 161 | if ( (ichanfadc) < SLICES_MFADC ) {
|
|---|
| 162 | sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ;
|
|---|
| 163 | }
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|
| 166 | else {
|
|---|
| 167 | cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange "
|
|---|
| 168 | << TOTAL_TRIGGER_TIME << endl ;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | void MFadc::ElecNoise() {
|
|---|
| 174 | //
|
|---|
| 175 | //
|
|---|
| 176 | //
|
|---|
| 177 |
|
|---|
| 178 | for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
|
|---|
| 179 | if ( used [i] == TRUE ) {
|
|---|
| 180 | for ( Int_t is=0 ; is< SLICES_MFADC ; is++ ) {
|
|---|
| 181 |
|
|---|
| 182 | sig[i][is] += GenElec->Gaus(0., 2.) ;
|
|---|
| 183 |
|
|---|
| 184 | }
|
|---|
| 185 | }
|
|---|
| 186 | }
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | void MFadc::Scan() {
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 | for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
|
|---|
| 195 |
|
|---|
| 196 | if ( used[ip] == kTRUE ) {
|
|---|
| 197 |
|
|---|
| 198 | printf ("Pid %3d", ip ) ;
|
|---|
| 199 |
|
|---|
| 200 | for ( Int_t is=0 ; is < SLICES_MFADC; is++ ) {
|
|---|
| 201 |
|
|---|
| 202 | if ( sig[ip][is] > 0. ) {
|
|---|
| 203 | printf (" %4.1f/", sig[ip][is] ) ;
|
|---|
| 204 | }
|
|---|
| 205 | else {
|
|---|
| 206 | printf ("----/" ) ;
|
|---|
| 207 | }
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | printf ("\n");
|
|---|
| 211 |
|
|---|
| 212 | }
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | void MFadc::Scan(Float_t time) {
|
|---|
| 218 |
|
|---|
| 219 | //
|
|---|
| 220 | // first of all we subtract from the time a offset (8 ns)
|
|---|
| 221 | //
|
|---|
| 222 |
|
|---|
| 223 | Float_t t ;
|
|---|
| 224 |
|
|---|
| 225 | (0 > time - TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
|
|---|
| 226 |
|
|---|
| 227 | if ( t < 0. ) {
|
|---|
| 228 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
|---|
| 229 | exit (776) ;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | //
|
|---|
| 233 | // calculate the first slice to write out
|
|---|
| 234 | //
|
|---|
| 235 |
|
|---|
| 236 | Int_t iFirstSlice ;
|
|---|
| 237 |
|
|---|
| 238 | iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
|
|---|
| 239 |
|
|---|
| 240 | for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
|
|---|
| 241 |
|
|---|
| 242 | if ( used[ip] == kTRUE ) {
|
|---|
| 243 |
|
|---|
| 244 | printf ("Pid %3d", ip ) ;
|
|---|
| 245 |
|
|---|
| 246 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+15); is++ ) {
|
|---|
| 247 | printf (" %5.2f /", sig[ip][is] ) ;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | printf ("\n");
|
|---|
| 251 |
|
|---|
| 252 | }
|
|---|
| 253 | }
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | void MFadc::TriggeredFadc(Float_t time) {
|
|---|
| 257 |
|
|---|
| 258 | //
|
|---|
| 259 | // first of all we subtract from the time a offset (8 ns)
|
|---|
| 260 | //
|
|---|
| 261 |
|
|---|
| 262 | Float_t t ;
|
|---|
| 263 |
|
|---|
| 264 | (0>time-TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
|
|---|
| 265 |
|
|---|
| 266 | if ( t < 0. ) {
|
|---|
| 267 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
|---|
| 268 | exit (776) ;
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | //
|
|---|
| 272 | // calculate the first slice to write out
|
|---|
| 273 | //
|
|---|
| 274 |
|
|---|
| 275 | Int_t iFirstSlice ;
|
|---|
| 276 | Int_t i;
|
|---|
| 277 |
|
|---|
| 278 | iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
|
|---|
| 279 |
|
|---|
| 280 | for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
|
|---|
| 281 |
|
|---|
| 282 | if ( used[ip] == kTRUE ) {
|
|---|
| 283 | i=0;
|
|---|
| 284 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES); is++ ) {
|
|---|
| 285 | output[ip][i++]=(UChar_t) sig[ip][is];
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | }
|
|---|
| 289 | }
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | void MFadc::ShowSignal (MMcEvt *McEvt, Float_t trigTime) {
|
|---|
| 293 | // ============================================================
|
|---|
| 294 | //
|
|---|
| 295 | // This method is used to book the histogramm to show the signal in
|
|---|
| 296 | // a special gui frame (class MGTriggerSignal). After the look onto the
|
|---|
| 297 | // signals for a better understanding of the things we will expect
|
|---|
| 298 | // the gui frame and all histogramms will be destroyed.
|
|---|
| 299 | //
|
|---|
| 300 |
|
|---|
| 301 | //
|
|---|
| 302 | // first of all create a list of the histograms to show
|
|---|
| 303 | //
|
|---|
| 304 | // take only that one with a entry
|
|---|
| 305 |
|
|---|
| 306 | TH1F *hist ;
|
|---|
| 307 | Char_t dumm[10];
|
|---|
| 308 | Char_t name[256];
|
|---|
| 309 |
|
|---|
| 310 | TObjArray *AList ;
|
|---|
| 311 | AList = new TObjArray(10) ;
|
|---|
| 312 |
|
|---|
| 313 | // the list of analog signal histograms
|
|---|
| 314 | // at the beginning we initalise 10 elements
|
|---|
| 315 | // but this array expand automaticly if neccessay
|
|---|
| 316 |
|
|---|
| 317 | Int_t ic = 0 ;
|
|---|
| 318 | for ( Int_t i=0 ; i < CAMERA_PIXELS; i++ ) {
|
|---|
| 319 | if ( used [i] == TRUE ) {
|
|---|
| 320 |
|
|---|
| 321 | sprintf (dumm, "FADC_%d", i ) ;
|
|---|
| 322 | sprintf (name, "fadc signal %d", i ) ;
|
|---|
| 323 |
|
|---|
| 324 | hist = new TH1F(dumm, name, SLICES_MFADC, 0., TOTAL_TRIGGER_TIME);
|
|---|
| 325 | //
|
|---|
| 326 | // fill the histogram
|
|---|
| 327 | //
|
|---|
| 328 |
|
|---|
| 329 | for (Int_t ibin=1; ibin <=SLICES_MFADC; ibin++) {
|
|---|
| 330 | hist->SetBinContent (ibin, sig[i][ibin-1]) ;
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 | // hist->SetMaximum( 5.);
|
|---|
| 334 | // hist->SetMinimum(-10.);
|
|---|
| 335 | hist->SetStats(kFALSE);
|
|---|
| 336 |
|
|---|
| 337 | // hist->SetAxisRange(0., 80. ) ;
|
|---|
| 338 |
|
|---|
| 339 | AList->Add(hist) ;
|
|---|
| 340 |
|
|---|
| 341 | ic++ ;
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | //
|
|---|
| 346 | // create the Gui Tool
|
|---|
| 347 | //
|
|---|
| 348 | //
|
|---|
| 349 |
|
|---|
| 350 | new MGFadcSignal(McEvt,
|
|---|
| 351 | AList,
|
|---|
| 352 | trigTime,
|
|---|
| 353 | gClient->GetRoot(),
|
|---|
| 354 | gClient->GetRoot(),
|
|---|
| 355 | 400, 400 ) ;
|
|---|
| 356 |
|
|---|
| 357 | //
|
|---|
| 358 | // delete the List of histogramms
|
|---|
| 359 | //
|
|---|
| 360 | AList->Delete() ;
|
|---|
| 361 |
|
|---|
| 362 | delete AList ;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | Float_t MFadc::GetFadcSignal(Int_t pixel, Int_t slice){
|
|---|
| 366 |
|
|---|
| 367 | // It returns the analog signal for a given pixel and a given FADC
|
|---|
| 368 | // time slice which would be read.
|
|---|
| 369 |
|
|---|
| 370 | return (output[pixel][slice]);
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|