Changeset 2339 for trunk/MagicSoft


Ignore:
Timestamp:
09/15/03 11:53:33 (21 years ago)
Author:
blanch
Message:
CAMERA_PIXELS changed to member variable numpix.
Less noise slices to avoid program abort.
File:
1 edited

Legend:

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

    r2290 r2339  
    1818#include "MGFadcSignal.hxx"
    1919
    20 MFadc::MFadc(Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) {
     20MFadc::MFadc(Int_t pix, Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) {
    2121  //
    2222  //  Constructor overloaded II
     
    3131  //     this parameters of the trigger may be changed
    3232  //  3. Then the all signals are set to zero
     33  numpix=pix;
    3334 
    3435  fwhm_resp = fwhm;
     
    136137  //   if this is the first use, reset all signal for that pixels
    137138  //
    138   if ( iPix > CAMERA_PIXELS ) {
     139  if ( iPix > numpix ) {
    139140    cout << " WARNING:  MFadc::Fill() :  iPix greater than CAMERA_PIXELS"
    140141         << endl ;
     
    201202  //   if this is the first use, reset all signal for that pixels
    202203  //
    203   if ( iPix > CAMERA_PIXELS ) {
     204  if ( iPix > numpix ) {
    204205    cout << " WARNING:  MFadc::FillOuter() :  iPix greater than CAMERA_PIXELS"
    205206         << endl ;
     
    264265  //   if this is the first use, reset all signal for that pixels
    265266  //
    266   if ( iPix > CAMERA_PIXELS ) {
     267  if ( iPix > numpix ) {
    267268    cout << " WARNING:  MFadc::Fill() :  iPix greater than CAMERA_PIXELS"
    268269         << endl ;
     
    298299  //   if this is the first use, reset all signal for that pixels
    299300  //
    300   if ( iPix > CAMERA_PIXELS ) {
     301  if ( iPix > numpix ) {
    301302    cout << " WARNING:  MFadc::Fill() :  iPix greater than CAMERA_PIXELS"
    302303         << endl ;
     
    323324  Int_t i;
    324325
    325   for(i=0;i<CAMERA_PIXELS;i++){
     326  for(i=0;i<numpix;i++){
    326327    pedestal[i]= (Float_t)(ped* GenElec->Rndm());
    327328  }
    328329}
    329330
    330 void MFadc::SetPedestals(  Float_t ped[CAMERA_PIXELS]) {
     331void MFadc::SetPedestals(  Float_t *ped) {
    331332  //  It sets pedestal for each pixel from ped array
    332333
    333334  Int_t i;
    334335
    335   for(i=0;i<CAMERA_PIXELS;i++){
     336  for(i=0;i<numpix;i++){
    336337    pedestal[i]= ped[i];
    337338  }
     
    346347  Float_t baseline;
    347348
    348   for(j=0;j<CAMERA_PIXELS;j++){
     349  for(j=0;j<numpix;j++){
    349350    baseline=0.0;
    350351    for(i=0;i<(Int_t) SLICES_MFADC;i++){
     
    367368  Int_t i, j;
    368369
    369   for(i=0;i<CAMERA_PIXELS;i++)
     370  for(i=0;i<numpix;i++)
    370371    for(j=0;j<(Int_t)SLICES_MFADC;j++)
    371372      sig[i][j]+=pedestal[i];
     
    388389      // It does not exist, so all pixels will have the same offset
    389390
    390       for(i=0;i<CAMERA_PIXELS;i++){
     391      for(i=0;i<numpix;i++){
    391392        if (used[i]){
    392393          fdum=(10*GenOff->Rndm());
     
    411412      // It does not exist, so all pixels will have the same offset
    412413
    413       for(i=0;i<CAMERA_PIXELS;i++){
     414      for(i=0;i<numpix;i++){
    414415        if (used[i]){
    415416          for(j=0;j<(Int_t) SLICES_MFADC;j++)
     
    433434  UInt_t i;
    434435 
    435   cout<<"MFadc::SetElecNoise ... generating database for electroni noise."
     436  cout<<"MFadc::SetElecNoise ... generating database for electronic noise."
    436437      <<endl;
    437438
    438   for (i=0;i<CAMERA_PIXELS*(Int_t) SLICES_MFADC*101;i++){
     439  for (i=0;i<UInt_t(SLICES_MFADC*1001);i++){
    439440    noise[i]=GenElec->Gaus(0., value  );
    440441      }
     
    452453  UInt_t startslice;
    453454
    454   startslice=GenElec->Integer(CAMERA_PIXELS*(Int_t) SLICES_MFADC*100);
    455 
    456     for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
     455    for ( Int_t i = 0 ; i < numpix; i++) {
    457456        //
    458457        //  but at the beginning we must check if this pixel is
    459458        //  hitted the first time
    460459        //
     460
     461      startslice=GenElec->Integer((Int_t) SLICES_MFADC*1000);
     462
    461463        if ( used[i] == FALSE ) {
    462464            used [i] = TRUE ;
    463465           
    464             memcpy( (Float_t*)&sig[0][0],
    465                     (Float_t*)&noise[startslice+i*(Int_t) SLICES_MFADC],
     466            memcpy( (Float_t*)&sig[i][0],
     467                    (Float_t*)&noise[startslice],
    466468                    (Int_t) SLICES_MFADC*sizeof(Float_t));
    467    
     469     
    468470        }
    469471        //     
     
    473475          for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
    474476           
    475             sig[i][is] += noise[startslice+i*(Int_t) SLICES_MFADC+is] ;
     477            sig[i][is] += noise[startslice+is] ;
    476478           
    477479          }
    478        
    479480    }
    480481}
     
    485486 
    486487
    487   for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
     488  for ( Int_t ip=0; ip<numpix; ip++ ) {
    488489   
    489490    if ( used[ip] == kTRUE ) {
     
    531532  iFirstSlice = (Int_t) ( t /  WIDTH_FADC_TIMESLICE ) ;
    532533
    533   for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
     534  for ( Int_t ip=0; ip<numpix; ip++ ) {
    534535   
    535536    if ( used[ip] == kTRUE ) {
     
    563564  //    puts the pedestal values into the array offset
    564565 
    565   for ( Int_t i=0; i< CAMERA_PIXELS; i++ ) {
     566  for ( Int_t i=0; i< numpix; i++ ) {
    566567
    567568    offset[i] = pedestal[i] ;
     
    593594  iFirstSlice = (Int_t) ( t /  WIDTH_FADC_TIMESLICE ) ;
    594595
    595   for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
     596  for ( Int_t ip=0; ip<numpix; ip++ ) {
    596597   
    597598    if ( used[ip] == kTRUE ) {
     
    600601        if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0)
    601602          {
    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          
     603            output[ip][i]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5));
     604            output_lowgain[ip][i]=
     605              (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/HIGH2LOWGAIN) > 255. ? 255 :
     606              (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/HIGH2LOWGAIN);
     607            i++;
     608          }
     609        else if(sig[ip][is]>0.0)
     610          {
     611            output[ip][i]= (UChar_t)(pedestal[ip]+0.5);
     612            output_lowgain[ip][i]= (UChar_t)(pedestal[ip]+0.5);
     613            i++;
    607614          }
    608615        else
    609616          {
    610617            output[ip][i]= 0;
    611             output_lowgain[ip][i++]= 0;
     618            output_lowgain[ip][i]= 0;
     619            i++;
    612620          }
    613621      }
     
    643651 
    644652  Int_t ic = 0 ;
    645   for ( Int_t i=0 ; i < CAMERA_PIXELS; i++  ) {
     653  for ( Int_t i=0 ; i < numpix; i++  ) {
    646654    if ( used [i] == TRUE ) {
    647655
     
    706714   return (output_lowgain[pixel][slice]);
    707715}
    708 
    709 
    710 
Note: See TracChangeset for help on using the changeset viewer.