Changeset 7098 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
05/27/05 16:25:27 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msignal
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msignal/MC_weights46.dat

    r7013 r7098  
    4343# Low Gain Weights: 6 10
    4444# (Amplitude)  (Time)
    45 0.0138311 -0.0165919
    46 0.0117372 -0.0354005
    47 0.00232654 -0.0581018
    48 -0.00791094 -0.0631271
    49 -0.0131845 -0.0558022
    50 -0.0154786 -0.0480772
    51 -0.0171358 -0.0420274
    52 -0.0199068 -0.0340744
    53 -0.02688 -0.0117278
    54 -0.0404328 0.0754397
    55 -0.0357035 0.342673
    56 0.00409834 0.849274
    57 0.248584 1.52181
    58 0.528673 1.67974
    59 0.67261 1.47068
    60 0.735023 1.24965
    61 0.778865 1.10395
    62 0.832049 1.02856
    63 0.907609 1.00924
    64 1.07304 1.09208
    65 1.25051 1.14906
    66 1.37475 1.0253
    67 1.52056 0.653112
    68 1.53175 0.163076
    69 1.49683 -0.15273
    70 1.47188 -0.344252
    71 1.45258 -0.50129
    72 1.42348 -0.670218
    73 1.3673 -0.87756
    74 1.19832 -1.20557
    75 0.99973 -1.53248
    76 0.808836 -1.68211
    77 0.533208 -1.45238
    78 0.446023 -0.900265
    79 0.459037 -0.529769
    80 0.470945 -0.368053
    81 0.465845 -0.313525
    82 0.446981 -0.311926
    83 0.415815 -0.342317
    84 0.348688 -0.425439
    85 0.271752 -0.495437
    86 0.211195 -0.503879
    87 0.131582 -0.413276
    88 0.109187 -0.245156
    89 0.114005 -0.139006
    90 0.117671 -0.0939116
    91 0.116527 -0.078572
    92 0.11177 -0.0772896
    93 0.103901 -0.0840098
    94 0.0871027 -0.102357
    95 0.0758618 -0.119019
    96 0.0611863 -0.118991
    97 0.0430436 -0.0930814
    98 0.0390695 -0.0517162
    99 0.0409257 -0.027711
    100 0.0420581 -0.0186558
    101 0.0419035 -0.0164813
    102 0.0408279 -0.0174564
    103 0.0389147 -0.0202082
    104 0.0345678 -0.025232
     450.0446612 -0.385273
     460.038191 -0.00418687
     470.0386966 0.0212324
     480.0402881 0.0744799
     490.0415794 0.229615
     500.0598731 0.44332
     510.0758477 0.661518
     520.101509 1.10641
     530.159323 1.64997
     540.497256 2.83685
     550.245087 3.27499
     560.140546 2.46177
     570.58086 2.2849
     580.632721 2.45587
     590.72819 2.52835
     600.889583 2.48099
     610.980812 2.50031
     621.09885 2.55892
     631.21374 2.78769
     641.61928 3.08069
     651.38544 1.95583
     661.31998 1.1792
     671.50633 0.591226
     681.50916 0.0793899
     691.5008 -0.33188
     701.47339 -0.575386
     711.45362 -0.915309
     721.40214 -1.31593
     731.34175 -1.77904
     741.0661 -2.05471
     751.31087 -1.49798
     761.33793 -1.34758
     771.10172 -1.21719
     781.08133 -1.09356
     791.04007 -0.981455
     800.976745 -1.08299
     810.930979 -1.14774
     820.874203 -1.18348
     830.816708 -1.20126
     840.587354 -1.92869
     850.783078 -1.89621
     860.792771 -1.03439
     870.622278 -0.781807
     880.61184 -0.745831
     890.578792 -0.683741
     900.537336 -0.596328
     910.51443 -0.592858
     920.482294 -0.560586
     930.462351 -0.827587
     940.317989 -1.05649
     950.459672 -0.775035
     960.468287 -0.619961
     970.374182 -0.31635
     980.376946 -0.225242
     990.367075 -0.347444
     1000.340737 -0.393231
     1010.321054 -0.187384
     1020.320654 -0.225558
     1030.302148 -0.399499
     1040.232954 -0.607578
  • trunk/MagicSoft/Mars/msignal/MExtractFixedWindow.cc

    r7043 r7098  
    181181    case 8:
    182182    case 10:
     183    case 12:
    183184      SetResolutionPerPheLoGain(0.011);     
    184185      break;
    185186    default:
    186187      *fLog << warn << GetDescriptor() << ": Could not set the lo-gain extractor resolution/phe for window size " << wslogain << endl;
     188      SetResolutionPerPheLoGain(0.011);
    187189    }
    188190}
  • trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc

    r7043 r7098  
    3030//   Hendrik has promised to write more documentation
    3131//
    32 //
    3332//   The following variables have to be set by the derived class and
    3433//   do not have defaults:
     
    3837//   - fSqrtLoGainSamples
    3938//
     39// The reading of automatic weights files (color, type) can be switched
     40// off using EnableAutomaticWeights(kFALSE).
     41//
     42// An empty name or "-" as the weights file name is a synonym for
     43// setting all weights to 1
     44//
    4045// Input Containers:
    4146//   MRawEvtData
    4247//   MRawRunHeader
    4348//   MPedestalCam
     49//   [MCalibrationPattern]
    4450//
    4551// Output Containers:
     
    5359#include <fstream>
    5460
    55 #include <TFile.h>
    56 #include <TH1F.h>
    57 #include <TH2F.h>
    58 #include <TString.h>
     61#include <TH1.h>
     62#include <TH2.h>
    5963#include <TMatrix.h>
    6064
    6165#include "MLog.h"
    6266#include "MLogManip.h"
     67
     68#include "MParList.h"
     69
     70#include "MRawRunHeader.h"
     71#include "MCalibrationPattern.h"
    6372
    6473#include "MPedestalPix.h"
     
    7887const Int_t  MExtractTimeAndChargeDigitalFilter::fgSignalStartBinHiGain    =  4;
    7988const Int_t  MExtractTimeAndChargeDigitalFilter::fgSignalStartBinLoGain    =  4;
    80 const TString MExtractTimeAndChargeDigitalFilter::fgNameWeightsFile        = "msignal/cosmics_weights.dat";
    8189const Float_t MExtractTimeAndChargeDigitalFilter::fgOffsetLoGain           =  1.7; // 5 ns
    8290const Float_t MExtractTimeAndChargeDigitalFilter::fgLoGainStartShift       = -1.8;
     
    94102//
    95103MExtractTimeAndChargeDigitalFilter::MExtractTimeAndChargeDigitalFilter(const char *name, const char *title)
    96     : fTimeShiftHiGain(0.), fTimeShiftLoGain(0.), fWeightsSet(kFALSE), fRandomIter(0)
     104    : fTimeShiftHiGain(0.), fTimeShiftLoGain(0.), fAutomaticWeights(kTRUE), fRandomIter(0)
    97105{
    98106    fName  = name  ? name  : "MExtractTimeAndChargeDigitalFilter";
     
    104112    SetSignalStartBin();
    105113
    106     SetNameWeightsFile();
    107114    SetOffsetLoGain(fgOffsetLoGain);
    108115    SetLoGainStartShift(fgLoGainStartShift);
     
    184191// --------------------------------------------------------------------------
    185192//
     193// Executing MExtractTimeAndCharge::PreProcess and searching for
     194// MCalibrationPattern
     195//
     196Int_t MExtractTimeAndChargeDigitalFilter::PreProcess(MParList *pList)
     197{
     198    if (!MExtractTimeAndCharge::PreProcess(pList))
     199        return kFALSE;
     200
     201    fCalibPattern = (MCalibrationPattern*)pList->FindObject("MCalibrationPattern");
     202    return kTRUE;
     203}
     204
     205// --------------------------------------------------------------------------
     206//
    186207// InitArrays
    187208//
     
    190211Bool_t MExtractTimeAndChargeDigitalFilter::InitArrays()
    191212{
    192 
    193   Int_t range = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
    194 
    195   fHiGainSignal.Set(range);
    196 
    197   range = (Int_t)(fLoGainLast - fLoGainFirst + 1);
    198 
    199   fLoGainSignal.Set(range);
    200 
    201   if (!fWeightsSet)
    202     if (!ReadWeightsFile(fNameWeightsFile))
    203       return kFALSE;
    204 
    205   fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain;
    206   fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain;
    207   //
    208   // We need here the effective number of samples which is about 2.5 in the case of a window
    209   // size of 6. The exact numbers have to be found still.
    210   //
    211   fNumHiGainSamples = (Float_t)fWindowSizeHiGain/2.4;
    212   fNumLoGainSamples = (Float_t)fWindowSizeLoGain/2.4;
    213   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
    214   fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
    215  
    216   return kTRUE;
     213    if (!fRunHeader)
     214        return kFALSE;
     215
     216    const Int_t rangehi = (Int_t)(fHiGainLast - fHiGainFirst + 1 + fHiLoLast);
     217    const Int_t rangelo = (Int_t)(fLoGainLast - fLoGainFirst + 1);
     218
     219    fHiGainSignal.Set(rangehi);
     220    fLoGainSignal.Set(rangelo);
     221
     222    // Try to get automatic weights
     223    if (!ReadAutomaticWeightsFile())
     224        return kFALSE;
     225
     226    // If still no weights set try conservative way
     227    if (fNameWeightsFileSet.IsNull())
     228        if (!ReadWeightsFile(fNameWeightsFile))
     229            return kFALSE;
     230
     231    fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain;
     232    fTimeShiftLoGain = 0.5 + 1./fBinningResolutionLoGain;
     233    //
     234    // We need here the effective number of samples which is about 2.5 in the case of a window
     235    // size of 6. The exact numbers have to be found still.
     236    //
     237    fNumHiGainSamples = (Float_t)fWindowSizeHiGain/2.4;
     238    fNumLoGainSamples = (Float_t)fWindowSizeLoGain/2.4;
     239    fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
     240    fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
     241
     242    return kTRUE;
    217243}
    218244
     
    556582//   MJPedestal.MExtractor.BinningResolutionLoGain: 10
    557583//   MJPedestal.MExtractor.WeightsFile: filename
     584//   MJPedestal.MExtractor.AutomaticWeights: off
    558585//
    559586Int_t MExtractTimeAndChargeDigitalFilter::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     
    563590  Byte_t lw = fWindowSizeLoGain;
    564591  Bool_t rc = kFALSE;
    565  
     592
     593  if (IsEnvDefined(env, prefix, "AutomaticWeights", print))
     594  {
     595      EnableAutomaticWeights(GetEnvValue(env, prefix, "AutomaticWeights", fAutomaticWeights));
     596      rc = kTRUE;
     597  }
     598
    566599  if (IsEnvDefined(env, prefix, "WindowSizeHiGain", print))
    567600    {
     
    601634  if (IsEnvDefined(env, prefix, "WeightsFile", print))
    602635    {
    603       if (!ReadWeightsFile(GetEnvValue(env, prefix, "WeightsFile", "")))
    604         return kERROR;
    605       rc = kTRUE;
     636        SetNameWeightsFile(GetEnvValue(env, prefix, "WeightsFile", ""));
     637        *fLog << all << "**********> " << fNameWeightsFile << endl;
     638        rc = kTRUE;
    606639    }
    607640 
     
    621654    // This is a fix for TEnv files edited with windows editors
    622655    filename.ReplaceAll("\015", "");
    623 
    624     SetNameWeightsFile(filename);
    625656
    626657    fAmpWeightsHiGain .Set(fBinningResolutionHiGain*fWindowSizeHiGain);
     
    629660    fTimeWeightsLoGain.Set(fBinningResolutionLoGain*fWindowSizeLoGain);
    630661
    631     if (fNameWeightsFile.IsNull())
     662    if (fNameWeightsFile.IsNull() || fNameWeightsFile=="-")
    632663    {
    633664        fAmpWeightsHiGain.Reset(1);
     
    635666        fAmpWeightsLoGain.Reset(1);
    636667        fTimeWeightsLoGain.Reset(1);
     668        fNameWeightsFileSet = "-";
    637669        return kTRUE;
    638670    }
     671
     672    //filename = MJob::ExpandPath(filename);
     673
     674    if (fNameWeightsFileSet==filename)
     675        return kTRUE;
    639676
    640677    ifstream fin(filename.Data());
     
    646683    }
    647684
    648     *fLog << inf << "Reading weights file " << filename << "..." << flush;
     685    *fLog << all << "DigitalFilter: Reading weights in " << filename << "..." << flush;
    649686
    650687    Int_t len = 0;
     
    780817      }
    781818
    782     fWeightsSet = kTRUE;
     819    fNameWeightsFileSet = filename;
    783820
    784821    return kTRUE;
     822}
     823
     824
     825//----------------------------------------------------------------------------
     826//
     827// If automatic weight disabled or run type is pedestal no action is taken
     828// and kTRUE is returned.
     829//
     830// Otherwise:
     831//  - If runtype is kRTData and filename starts with "MC_weights" "MC" is
     832//    replaced by "cosmics"
     833//  - If runtype is kRTMonteCarlo and filename starts with "cosmics_weights"
     834//    "cosmics" is replaced by "MC"
     835//  - If name filename begins with "calibration_weights_" for blue and green
     836//    "UV" is replaced by "blue"
     837//  - If name filename begins with "calibration_weights_" for UV and CT1
     838//    "blue" is replaced by "UV"
     839//
     840// The replacements are done in this order. If no match is found no
     841// replacement is done. Afterwards ReadWeightsFile for the resulting
     842// path-/filename is called.
     843//
     844Bool_t MExtractTimeAndChargeDigitalFilter::ReadAutomaticWeightsFile()
     845{
     846    if (!fAutomaticWeights || fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal)
     847        return kTRUE;
     848
     849    *fLog << dbg << endl;
     850    *fLog << underline << GetDescriptor() << endl;
     851    *fLog << " Trying to get automatic weight for " << fNameWeightsFile << endl;
     852
     853    const Ssiz_t pos = fNameWeightsFile.Last('/')+1;
     854    const Ssiz_t len = fNameWeightsFile.Length();
     855
     856    TString path = fNameWeightsFile(0, pos>=0?pos:len);
     857    TString name = fNameWeightsFile(pos>=0?pos:0, len);
     858
     859    if (name.BeginsWith("cosmics_weights") && fRunHeader->GetRunType()==MRawRunHeader::kRTMonteCarlo)
     860    {
     861        name.Remove(0, 7);
     862        name.Prepend("MC");
     863        *fLog << "Run type: Monte Carlo data" << endl;
     864    }
     865    if (name.BeginsWith("MC_weights") && fRunHeader->GetRunType()==MRawRunHeader::kRTData)
     866    {
     867        name.Remove(0, 2);
     868        name.Prepend("cosmics");
     869        *fLog << "Run type: Cosmics data" << endl;
     870    }
     871
     872    if (name.BeginsWith("calibration_weights_") && fCalibPattern)
     873    {
     874        *fLog << " Run type: Calibration with color " << (int)fCalibPattern->GetPulserColor() << ", setting ";
     875        switch (fCalibPattern->GetPulserColor())
     876        {
     877        case MCalibrationCam::kBLUE:  // 2
     878        case MCalibrationCam::kGREEN: // 1
     879            *fLog << "blue/green" << endl;
     880            name.ReplaceAll("UV", "blue");
     881            break;
     882
     883        case MCalibrationCam::kUV:    // 3
     884        case MCalibrationCam::kCT1:   // 0
     885            *fLog << "UV/CT1" << endl;
     886            name.ReplaceAll("blue", "UV");
     887            break;
     888        case MCalibrationCam::kNONE:
     889            *fLog << "None" << endl;
     890            break;
     891        default: // kNONE=4
     892            *fLog << "???" << endl;
     893        }
     894    }
     895
     896    path += name;
     897
     898    return ReadWeightsFile(path);
    785899}
    786900
     
    10651179    *fLog << " Window Size HiGain: " << fWindowSizeHiGain        << "  LoGain: " << fWindowSizeLoGain << endl;
    10661180    *fLog << " Binning Res HiGain: " << fBinningResolutionHiGain << "  LoGain: " << fBinningResolutionHiGain << endl;
    1067     *fLog << " Weights File:       " << fNameWeightsFile << endl;
     1181    *fLog << " Weights File desired: " << (fNameWeightsFile.IsNull()?"-":fNameWeightsFile) << endl;
     1182    if (!fNameWeightsFileSet.IsNull())
     1183        *fLog << " Weights File set:     " << fNameWeightsFileSet << endl;
    10681184
    10691185    TString opt(o);
Note: See TracChangeset for help on using the changeset viewer.