Ignore:
Timestamp:
06/30/04 17:55:26 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msignal/MExtractor.cc

    r4340 r4368  
    2525//////////////////////////////////////////////////////////////////////////////
    2626//
    27 //   MExtractor
     27// MExtractor
     28// ==========
    2829//
    2930//   Base class for the signal extractors, used the functions
     
    3839//   - fSqrtLoGainSamples
    3940//
     41//   The signal extractor classes can be setup from an environmental
     42//   setup file. For more information see ReadEnv and MEvtLoop::ReadEnv
     43//
    4044// Input Containers:
    4145//   MRawEvtData
     
    7175
    7276const Byte_t MExtractor::fgSaturationLimit = 254;
     77
    7378// --------------------------------------------------------------------------
    7479//
     
    8893      fSaturationLimit(fgSaturationLimit)
    8994{
    90 
    9195    fName  = name  ? name  : "MExtractor";
    9296    fTitle = title ? title : "Base class for signal extractors";
     
    99103void MExtractor::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
    100104{
    101  
    102   fHiGainFirst = hifirst;
    103   fHiGainLast  = hilast;
    104 
    105   fLoGainFirst = lofirst;
    106   fLoGainLast  = lolast;
    107 
    108 }
    109 
     105    fHiGainFirst = hifirst;
     106    fHiGainLast  = hilast;
     107
     108    fLoGainFirst = lofirst;
     109    fLoGainLast  = lolast;
     110}
    110111
    111112// --------------------------------------------------------------------------
     
    123124Int_t MExtractor::PreProcess(MParList *pList)
    124125{
    125 
    126126    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
    127127    if (!fRawEvt)
     
    178178Bool_t MExtractor::ReInit(MParList *pList)
    179179{
    180  
    181   Int_t lastdesired   = (Int_t)(fLoGainLast);
    182   Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
    183 
    184   if (lastavailable < 0)
    185     *fLog << warn << GetDescriptor()
    186           << ": WARNING: Number of available Low-Gain Slices is smaller than or equal zero!" << endl;
    187  
     180    Int_t lastdesired   = (Int_t)(fLoGainLast);
     181    Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
     182
     183    if (lastavailable < 0)
     184        *fLog << warn << GetDescriptor() << " - WARNING: Number of available Low-Gain Slices is smaller than or equal zero!" << endl;
     185
     186    if (lastdesired > lastavailable)
     187    {
     188        const Int_t diff = lastdesired - lastavailable;
     189
     190        *fLog << endl;
     191        *fLog << warn << GetDescriptor() << ": Selected Lo Gain FADC Window [";
     192        *fLog << Form("%2i,%2i", (int)fLoGainFirst, lastdesired);
     193        *fLog << "] ranges out of the available limits: [0," << Form("%2i", lastavailable) << "]" << endl;
     194        *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
     195        SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
     196    }
     197
     198    lastdesired   = (Int_t)fHiGainLast;
     199    lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
     200
     201    if (lastavailable < 0)
     202    {
     203        *fLog << err << GetDescriptor();
     204        *fLog << " - ERROR: Number of available High-Gain Slices is smaller than or equal zero!" << endl;
     205        return kFALSE;
     206    }
     207
    188208  if (lastdesired > lastavailable)
    189     {
     209  {
    190210      const Int_t diff = lastdesired - lastavailable;
    191       *fLog << endl;
    192       *fLog << warn << GetDescriptor()
    193             << Form("%s%2i%s%2i%s%2i%s",": Selected Lo Gain FADC Window [",
    194                     (int)fLoGainFirst,",",lastdesired,
    195                     "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
    196       *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
    197       SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
    198     }
    199 
    200   lastdesired   = (Int_t)fHiGainLast;
    201   lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
    202  
    203   if (lastavailable < 0)
    204     {
    205       *fLog << err << GetDescriptor()
    206             << ": ERROR: Number of available High-Gain Slices is smaller than or equal zero!" << endl;
    207       return kFALSE;
    208     }
    209 
    210   if (lastdesired > lastavailable)
    211     {
    212       const Int_t diff = lastdesired - lastavailable;
     211
    213212      *fLog << endl;
    214       *fLog << warn << GetDescriptor()
    215             << Form("%s%2i%s%2i%s%2i%s",": Selected Hi Gain FADC Window [",
    216                     (int)fHiGainFirst,",",lastdesired,
    217                     "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
    218       *fLog << warn << GetDescriptor()
    219             << Form("%s%2i%s",": Will use ",diff," samples from the Low-Gain for the High-Gain extraction")
    220             << endl;
     213      *fLog << warn << GetDescriptor() << ": Selected Hi Gain FADC Window [";
     214      *fLog << Form("%2i,%2i%s%2i%s", (int)fHiGainFirst,",",lastdesired);
     215      *fLog << "] ranges out of the available limits: [0," << Form("%2i", lastavailable) << "]" << endl;
     216      *fLog << warn << GetDescriptor() << ": Will use ";
     217      *fLog << Form("%2i", diff) << " samples from the Low-Gain for the High-Gain extraction";
     218      *fLog << endl;
     219
    221220      fHiGainLast -= diff;
    222221      fHiLoLast    = diff;
    223     }
     222  }
    224223
    225224  return kTRUE;
    226 }
    227 
    228 
    229 
    230 void MExtractor::FindSignalHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Byte_t &sat) const
    231 {
    232   return;
    233 }
    234 
    235 void MExtractor::FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const
    236 {
    237   return;
    238225}
    239226
     
    245232Int_t MExtractor::Process()
    246233{
    247 
    248234  MRawEvtPixelIter pixel(fRawEvt);
    249235  fSignals->Clear();
     
    290276void MExtractor::StreamPrimitive(ofstream &out) const
    291277{
    292 
    293278  out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
    294279  out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
    295280 
    296281  if (fSaturationLimit!=fgSaturationLimit)
    297     {
     282  {
    298283      out << "   " << GetUniqueName() << ".SetSaturationLimit(";
    299284      out << (int)fSaturationLimit << ");" << endl;
    300     }
     285  }
    301286 
    302287  out << "   " << GetUniqueName() << ".SetRange(";
     
    308293}
    309294
     295// --------------------------------------------------------------------------
     296//
     297// Read the setup from a TEnv, eg:
     298//   MJPedestal.MExtractor.HiGainFirst: 5
     299//   MJPedestal.MExtractor.LoGainFirst: 5
     300//   MJPedestal.MExtractor.HiGainLast:  10
     301//   MJPedestal.MExtractor.LoGainLast:  10
     302//   MJPedestal.MExtractor.SaturationLimit: 88
     303//
     304Bool_t MExtractor::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     305{
     306    Byte_t hf = fHiGainFirst;
     307    Byte_t lf = fLoGainFirst;
     308    Byte_t hl = fHiGainLast;
     309    Byte_t ll = fLoGainLast;
     310
     311    if (IsEnvDefined(env, prefix, "HiGainFirst", print))
     312        hf = GetEnvValue(env, prefix, "HiGainFirst", hf);
     313    if (IsEnvDefined(env, prefix, "LoGainFirst", print))
     314        lf = GetEnvValue(env, prefix, "LoGainFirst", lf);
     315
     316    if (IsEnvDefined(env, prefix, "HiGainLast", print))
     317        hl = GetEnvValue(env, prefix, "HiGainLast", hl);
     318    if (IsEnvDefined(env, prefix, "LoGainLast", print))
     319        ll = GetEnvValue(env, prefix, "LoGainLast", ll);
     320
     321    SetRange(hf, hl, lf, ll);
     322
     323    if (IsEnvDefined(env, prefix, "SaturationLimit", print))
     324        SetSaturationLimit(GetEnvValue(env, prefix, "SaturationLimit", fSaturationLimit));
     325
     326    return kTRUE;
     327}
  • trunk/MagicSoft/Mars/msignal/MExtractor.h

    r4339 r4368  
    4747    Byte_t  fSaturationLimit;
    4848
    49     virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const;
    50     virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const;
     49    virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const { }
     50    virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const { }
    5151
    52     virtual Int_t  PreProcess(MParList *pList);
    53     virtual Bool_t ReInit(MParList *pList);
    54     virtual Int_t  Process();
    55     virtual void   StreamPrimitive(ofstream &out) const;
     52    Int_t  PreProcess(MParList *pList);
     53    Bool_t ReInit(MParList *pList);
     54    Int_t  Process();
     55    void   StreamPrimitive(ofstream &out) const;
     56    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    5657
    5758public:
    58 
    5959    MExtractor(const char *name=NULL, const char *title=NULL);
    6060
    61     Byte_t  GetHiGainFirst()      const      { return fHiGainFirst;      }
    62     Byte_t  GetHiGainLast ()      const      { return fHiGainLast ;      }
    63     Byte_t  GetLoGainFirst()      const      { return fLoGainFirst;      }
    64     Byte_t  GetLoGainLast ()      const      { return fLoGainLast ;      }
    65     Float_t GetNumHiGainSamples() const      { return fNumHiGainSamples; }
    66     Float_t GetNumLoGainSamples() const      { return fNumLoGainSamples; }
     61    Byte_t  GetHiGainFirst()      const { return fHiGainFirst;      }
     62    Byte_t  GetHiGainLast ()      const { return fHiGainLast ;      }
     63    Byte_t  GetLoGainFirst()      const { return fLoGainFirst;      }
     64    Byte_t  GetLoGainLast ()      const { return fLoGainLast ;      }
     65    Float_t GetNumHiGainSamples() const { return fNumHiGainSamples; }
     66    Float_t GetNumLoGainSamples() const { return fNumLoGainSamples; }
    6767   
    6868    virtual void SetRange  (Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
Note: See TracChangeset for help on using the changeset viewer.