Ignore:
Timestamp:
02/11/04 18:35:50 (21 years ago)
Author:
hbartko
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MExtractSignal2.cc

    r3094 r3102  
    1717!
    1818!   Author(s): Thomas Bretz, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!              Hendrik Bartko, 01/2004 <mailto:hbartko@mppmu.mpg.de>
    1920!
    2021!   Copyright: MAGIC Software Development, 2000-2004
     
    2728//   MExtractSignal2
    2829//
    29 //  Calculate the signal as the fWindow time slices which have the highest
     30//  Calculate the signal as the fWindowSize time slices which have the highest
    3031// integral contents.
    3132//
    32 // Calculation of arrival time not yet implemented
     33//
    3334//
    3435//////////////////////////////////////////////////////////////////////////////
     
    4950#include "MExtractedSignalPix.h"
    5051
     52//#include "MArrivalTime.h"
     53
    5154ClassImp(MExtractSignal2);
    5255
     
    5457
    5558const Byte_t MExtractSignal2::fgSaturationLimit = 254;
    56 const Byte_t MExtractSignal2::fgFirst  =  2;
     59const Byte_t MExtractSignal2::fgFirst  =  0;
    5760const Byte_t MExtractSignal2::fgLast   = 14;
    58 const Byte_t MExtractSignal2::fgWindow =  8;
     61const Byte_t MExtractSignal2::fgWindowSize = 6;
    5962
    6063// --------------------------------------------------------------------------
     
    7477}
    7578
    76 void MExtractSignal2::SetRange(Byte_t first, Byte_t last, Byte_t window)
    77 {
    78 
    79     fNumHiGainSamples = last-first+1;
    80     fNumLoGainSamples = last-first+1;
    81 
    82     fHiGainFirst = first;
    83     fLoGainFirst = first;
    84 
    85     fWindow     = window & ~1;
    86     fWindowSqrt = TMath::Sqrt((Float_t)fWindow);
    87 
    88     if (fWindow==window)
    89         return;
    90 
    91     *fLog << warn << "MExtractSignal2::SetRange - Window size set to even " << fWindow << endl;
    92 }
     79void MExtractSignal2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
     80{
     81
     82    fNumHiGainSamples = hilast-hifirst+1;
     83    fNumLoGainSamples = lolast-lofirst+1;
     84
     85    fHiGainFirst = hifirst;
     86    fLoGainFirst = lofirst;
     87
     88   
     89    fWindowSize = windowsize & ~1;
     90
     91    if (fWindowSize != windowsize)
     92      *fLog << warn << "MExtractSignal2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
     93   
     94    if (fWindowSize<2)
     95    {
     96      fWindowSize = 2;
     97      *fLog << warn << "MExtractSignal2::SetRange - window size set to two samples" << endl;
     98    }
     99
     100    if (fWindowSize > fNumHiGainSamples)
     101    {
     102      fWindowSize = fNumLoGainSamples & ~1;
     103      *fLog << warn << "MExtractSignal2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
     104    }
     105   
     106    if (fWindowSize > fNumLoGainSamples)
     107    {
     108      fWindowSize = fNumLoGainSamples & ~1;
     109      *fLog << warn << "MExtractSignal2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
     110    }
     111
     112    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
     113
     114}
     115
     116
    93117
    94118// --------------------------------------------------------------------------
     
    126150        return kFALSE;
    127151    }
     152/*
     153    fArrivalTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
     154    if (!fArrivalTime)
     155        return kFALSE;
     156 */
    128157    return kTRUE;
    129158}
     
    136165
    137166    //
    138     // Calculate the sum of the first fWindow slices
     167    // Calculate the sum of the first fWindowSize slices
    139168    //
    140169    sat = 0;
    141170    Byte_t *p = ptr;
    142     while (p<ptr+fWindow)
     171    while (p<ptr+fWindowSize)
    143172    {
    144173        sum += *p;
     
    159188    // This is fast and accurate (because we are using int's)
    160189    //
    161     max=0;
    162     for (p=ptr; p+fWindow<end; p++)
    163     {
    164         sum += *(p+fWindow) - *p;
     190    max=sum;
     191    for (p=ptr; p+fWindowSize<end; p++)
     192    {
     193        sum += *(p+fWindowSize) - *p;
    165194        if (sum>max)
    166195            max = sum;
     
    170199// --------------------------------------------------------------------------
    171200//
    172 // Calculate the integral of the FADC of fWindow time slices which have the
     201// Calculate the integral of the FADC of fWindowSize time slices which have the
    173202// highest signal
    174203//
     
    178207    fSignals->Clear();
    179208
    180     TString satpixels;
    181209    Int_t sat=0;
    182 
    183210    while (pixel.Next())
    184211    {
     
    190217        FindSignal(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, sumlo, satlo);
    191218        if (satlo)
    192           {
    193219            sat++;
    194             satpixels += Form("%d%s",pixel.GetPixelId()," ");
    195           }
    196        
     220
    197221        //
    198222        // Take correspodning pedestal
     
    209233        // Set extracted signal with pedestal substracted
    210234        //
    211         pix.SetExtractedSignal(sumhi - pedes*fWindow, pedrms*fWindowSqrt,
    212                                sumlo - pedes*fWindow, pedrms*fWindowSqrt);
     235        pix.SetExtractedSignal(sumhi - pedes*fWindowSize, pedrms*fWindowSizeSqrt,
     236                               sumlo - pedes*fWindowSize, pedrms*fWindowSizeSqrt);
    213237
    214238        pix.SetGainSaturation(sathi, sathi, satlo);
     
    219243    //
    220244    if (sat)
    221       *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels: " << satpixels << endl;
     245        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
    222246
    223247    fSignals->SetReadyToSave();
Note: See TracChangeset for help on using the changeset viewer.