Changeset 2290


Ignore:
Timestamp:
07/17/03 19:07:24 (21 years ago)
Author:
blanch
Message:
Low gain implemented
Faster noise simulation
Different signal for inner and outer pixels
File:
1 edited

Legend:

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

    r1200 r2290  
    1818#include "MGFadcSignal.hxx"
    1919
    20 MFadc::MFadc(Float_t ampl, Float_t fwhm) {
     20MFadc::MFadc(Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) {
    2121  //
    2222  //  Constructor overloaded II
    2323  // 
     24  //  Input variables:
     25  //  1. ampl(out) = integration of the single phe response (outer pixels)
     26  //  2. fwhm(out) = width at half high of the single phe
     27  //  response(outer pixels)
     28  //
    2429  //  The procedure is the following:
    2530  //  1. some parameters of the trigger are set to default.   
     
    2732  //  3. Then the all signals are set to zero
    2833 
    29   fwhm_resp = fwhm       ;
    30   ampl_resp = ampl  ;
     34  fwhm_resp = fwhm;
     35  ampl_resp = ampl;
     36  fwhm_resp_outer = fwhmout;
     37  ampl_resp_outer = amplout;
    3138 
    3239  //
     
    4249 
    4350  Float_t   dX, dX2 ;
    44  
     51
    4552  dX  = WIDTH_FADC_TIMESLICE / SUBBINS ;
    4653  dX2 = dX/2. ;
     
    5158   
    5259    //
    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) ) ;
     60    //   the value 1/(2*Pi*sigma^2) was introduced to normalize
     61    //   the area at the input value
     62    //
     63    sing_resp[i] = ampl_resp / sqrt(2*3.1415926*sigma*sigma)* 
     64       expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
     65
     66  }
     67
     68  sigma = fwhm_resp_outer / 2.35 ;
     69  x0 = 3*sigma ;
     70 
     71  dX  = WIDTH_FADC_TIMESLICE / SUBBINS ;
     72  dX2 = dX/2. ;
     73 
     74  for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) { 
     75
     76    x = i * dX + dX2 ;
     77   
     78    //
     79    //   the value 1/(2*Pi*sigma^2) was introduced to normalize
     80    //   the area at the input value
     81    //
     82    sing_resp_outer[i] = ampl_resp_outer / sqrt(2*3.1415926*sigma*sigma)* 
     83       expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
    5784
    5885  }
     
    82109    memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t));
    83110    memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
    84 }
    85 
     111    memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
     112}
     113void MFadc::Fill( Int_t iPix, Float_t time,
     114                  Float_t amplitude, Int_t isinner ) {
     115
     116  if(isinner)
     117    Fill(iPix, time, amplitude);
     118  else
     119    FillOuter(iPix, time, amplitude);
     120
     121}
    86122void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) {
    87123 
     
    143179  else {
    144180    cout << "  WARNING!  Fadc::Fill " << time << "  out of TriggerTimeRange "
     181         << TOTAL_TRIGGER_TIME << endl ;
     182  }
     183
     184}
     185
     186void MFadc::FillOuter( Int_t iPix, Float_t time, Float_t amplitude ) {
     187 
     188  //
     189  // fills the information about one single Phe in the Trigger class
     190  // for an outer pixel
     191  //
     192  // parameter is the number of the pixel and the time-difference to the
     193  // first particle
     194  //
     195  //
     196
     197  Int_t i, ichan, ichanfadc ;
     198 
     199  //
     200  //   first we have to check if the pixel iPix is used or not until now
     201  //   if this is the first use, reset all signal for that pixels
     202  //
     203  if ( iPix > CAMERA_PIXELS ) {
     204    cout << " WARNING:  MFadc::FillOuter() :  iPix greater than CAMERA_PIXELS"
     205         << endl ;
     206    exit(987) ;
     207  }
     208
     209  if ( used[iPix] == FALSE ) {
     210    used [iPix] = TRUE ;
     211   
     212    for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
     213      sig[iPix][i] = 0. ;
     214    }
     215  }
     216
     217  //
     218  //   then select the time slice to use (ican)
     219  //
     220
     221 
     222  if ( time < 0. ) {
     223    cout << "  WARNING! Fadc::FillOuter  " << time << "  below ZERO!! Very strange!!"
     224         << endl ;
     225  }
     226  else if ( time < TOTAL_TRIGGER_TIME ) {
     227    //
     228    //   determine the slices number assuming the WIDTH_RESPONSE_MFADC
     229    //
     230    ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
     231
     232    //
     233    //   putting the response slices in the right sig slices.
     234    //   Be carefull, because both slices have different widths.
     235    //
     236
     237    for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
     238      ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
     239      if ( (ichanfadc) < (Int_t)SLICES_MFADC ) { 
     240        sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] )  ;
     241      }
     242    }
     243  }
     244  else {
     245    cout << "  WARNING!  Fadc::FillOuter " << time << "  out of TriggerTimeRange "
    145246         << TOTAL_TRIGGER_TIME << endl ;
    146247  }
     
    328429}
    329430
     431void MFadc::SetElecNoise(Float_t value){
     432
     433  UInt_t i;
     434 
     435  cout<<"MFadc::SetElecNoise ... generating database for electroni noise."
     436      <<endl;
     437
     438  for (i=0;i<CAMERA_PIXELS*(Int_t) SLICES_MFADC*101;i++){
     439    noise[i]=GenElec->Gaus(0., value  );
     440      }
     441
     442  cout<<"MFadc::SetElecNoise ... done"<<endl;
     443
     444}
     445
    330446void MFadc::ElecNoise(Float_t value) {
    331447  // ============================================================
     
    334450  //    to the signal
    335451  //
     452  UInt_t startslice;
     453
     454  startslice=GenElec->Integer(CAMERA_PIXELS*(Int_t) SLICES_MFADC*100);
    336455
    337456    for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
     
    343462            used [i] = TRUE ;
    344463           
    345             for (Int_t ii=0; ii < (Int_t)SLICES_MFADC; ii++ ) {
    346                 sig[i][ii] = 0. ;
    347             }
     464            memcpy( (Float_t*)&sig[0][0],
     465                    (Float_t*)&noise[startslice+i*(Int_t) SLICES_MFADC],
     466                    (Int_t) SLICES_MFADC*sizeof(Float_t));
     467   
    348468        }
    349469        //     
    350470        //  Then the noise is introduced for each time slice
    351471        //
    352         for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
     472        else
     473          for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
    353474           
    354             sig[i][is] += GenElec->Gaus(0., value) ;
     475            sig[i][is] += noise[startslice+i*(Int_t) SLICES_MFADC+is] ;
    355476           
    356         }
     477          }
    357478       
    358479    }
     
    478599      for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) {
    479600        if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0)
    480           output[ip][i++]=(UChar_t) (sig[ip][is]+0.5);
     601          {
     602          output[ip][i++]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5));
     603          output_lowgain[ip][i++]=
     604            (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/HIGH2LOWGAIN) > 255. ? 255 :
     605            (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/HIGH2LOWGAIN);
     606         
     607          }
    481608        else
    482           output[ip][i++]= 0;
     609          {
     610            output[ip][i]= 0;
     611            output_lowgain[ip][i++]= 0;
     612          }
    483613      }
    484614
     
    490620  // ============================================================
    491621  //
    492   //  This method is used to book the histogramm to show the signal in
     622  //  This method is used to book the histogram to show the signal in
    493623  //  a special gui frame (class MGTriggerSignal). After the look onto the
    494624  //  signals for a better understanding of the things we will expect
     
    568698}
    569699
    570 
     700 
     701UChar_t MFadc::GetFadcLowGainSignal(Int_t pixel, Int_t slice){
     702 
     703   //  It returns the analog signal for a given pixel and a given FADC
     704   //  time slice which would be read.
     705 
     706   return (output_lowgain[pixel][slice]);
     707}
     708
     709
     710
Note: See TracChangeset for help on using the changeset viewer.