Ignore:
Timestamp:
11/13/01 17:01:06 (23 years ago)
Author:
blanch
Message:
Several changes to speed up the camera program have been done and some
memory leakage due to an undeleted pointer has been solved
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx

    r692 r1066  
    1 /////////////////////////////////////////////////////////////////
     1////////////////////////////////////////////////////////////////
    22//
    33//  MFadc
     
    1818#include "MGFadcSignal.hxx"
    1919
    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 all pedestals to 0
    77   //
    78  
    79   for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
    80     pedestal[i] = 0.0 ;
    81   }
    82 
    83   //
    84   //  set tha values of FADC slices that would be read after trigger to zero
    85   //
    86  
    87   for (i=0; i <CAMERA_PIXELS; i++){
    88     for (j=0; j<FADC_SLICES;j++){
    89        output[i][j]=0;
    90     }
    91   }
    92 
    93 }
    94 
    95 MFadc::MFadc(Float_t ampl, Float_t fwhm) {
     20MFadc::MFadc(Float_t ampl, Float_t fwhm) {
    9621  //
    9722  //  Constructor overloaded II
     
    10833  //    set up the response shape
    10934  //
    110   Int_t  i,j ;
     35  Int_t  i ;
    11136 
    11237  Float_t   sigma ;
     
    13964  GenElec = new TRandom () ;
    14065
    141   //
    142   //  set all the booleans used to FALSE, indicating that the pixel is not
    143   //  used in this event.
    144   //
    145  
    146   for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
    147     used [i] = FALSE ;
    148   }
     66  Reset();
    14967
    15068  //
     
    15573    pedestal[i] = 0.0 ;
    15674  }
    157 
    158   //
    159   //  set tha values of FADC slices that would be read after trigger to zero
    160   //
    161  
    162   for (i=0; i <CAMERA_PIXELS; i++){
    163     for (j=0; j<FADC_SLICES;j++){
    164        output[i][j]=0;
    165     }
    166   }
    167 
    16875}
    16976 
    17077void MFadc::Reset() {
    171   //
    172   //  set all values of the signals to zero
    173   //
    174   Int_t  i,j ;
    175  
    176   for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
    177     used [i] = FALSE ;
    178   }
    179   //
    180   //  set tha values of FADC slices that would be read after trigger to zero
    181   //
    182  
    183   for (i=0; i <CAMERA_PIXELS; i++){
    184     for (j=0; j<FADC_SLICES;j++){
    185        output[i][j]=0;
    186     }
    187   }
     78    //
     79    //  set all values of the signals to zero
     80    //  set tha values of FADC slices that would be read after trigger to zero
     81    //
     82    memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t));
     83    memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
    18884}
    18985
     
    213109    used [iPix] = TRUE ;
    214110   
    215     for (i=0; i < SLICES_MFADC; i++ ) {
     111    for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
    216112      sig[iPix][i] = 0. ;
    217113    }
     
    240136    for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
    241137      ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
    242       if ( (ichanfadc) < SLICES_MFADC ) { 
     138      if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 
    243139        sig[iPix][ichanfadc] += (amplitude * sing_resp[i] )  ;
    244140      }
     
    276172    used [iPix] = TRUE ;
    277173   
    278     for (i=0; i < SLICES_MFADC; i++ ) {
     174    for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
    279175      sig[iPix][i] = 0. ;
    280176    }
    281177  }
    282   for ( i = 0 ; i<SLICES_MFADC; i++ ) {
     178  for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
    283179    sig[iPix][i] = resp[i] ;
    284180  }
     
    310206    used [iPix] = TRUE ;
    311207   
    312     for (i=0; i < SLICES_MFADC; i++ ) {
     208    for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
    313209      sig[iPix][i] = 0. ;
    314210    }
    315211  }
    316   for ( i = 0 ; i<SLICES_MFADC; i++ ) {
     212  for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
    317213    sig[iPix][i] += resp[i] ;
    318214  }
     
    371267
    372268  for(i=0;i<CAMERA_PIXELS;i++)
    373     for(j=0;j<SLICES_MFADC;j++)
     269    for(j=0;j<(Int_t)SLICES_MFADC;j++)
    374270      sig[i][j]+=pedestal[i];
    375271}
     
    429325    }
    430326  }
     327  delete GenOff;
    431328}
    432329
     
    438335  for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
    439336    if ( used [i] == TRUE ) {
    440       for ( Int_t is=0 ; is< SLICES_MFADC ; is++ ) {
     337      for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
    441338
    442339        sig[i][is] += GenElec->Gaus(0., 2.) ;
     
    458355      printf ("Pid %3d",  ip ) ;
    459356
    460       for ( Int_t is=0 ; is < SLICES_MFADC; is++ ) {
     357      for ( Int_t is=0 ; is < (Int_t)SLICES_MFADC; is++ ) {
    461358
    462359        if ( sig[ip][is] > 0. ) {
     
    565462      i=0;
    566463      for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) {
    567         if (is< SLICES_MFADC && sig[ip][is]>0.0)
     464        if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0)
    568465          output[ip][i++]=(UChar_t) sig[ip][is];
    569466        else
     
    612509      //
    613510     
    614       for (Int_t ibin=1; ibin <=SLICES_MFADC; ibin++) {
     511      for (Int_t ibin=1; ibin <=(Int_t)SLICES_MFADC; ibin++) {
    615512        hist->SetBinContent (ibin, sig[i][ibin-1]) ;
    616513      }
Note: See TracChangeset for help on using the changeset viewer.