Changeset 4368


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsMerge.cc

    r3734 r4368  
    5353// constructor. To keep track of all bad pixels the instance this pointer
    5454// is pointing to is used to collect all bad pixels used so far.
     55//
     56//
     57// ToDo:
     58//   - Take a setup file (ReadEnv-implementation) as input
    5559//
    5660//
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r3666 r4368  
    7272#include <fstream>          // ofstream, SavePrimitive
    7373
     74#include <TEnv.h>           // TEnv
    7475#include <TRint.h>          // gApplication, TRint::Class()
    7576#include <TTime.h>          // TTime
     
    956957// --------------------------------------------------------------------------
    957958//
     959// Calls 'ReadEnv' with a TEnv initialized with the given file name.
     960// If 'config=0' kTRUE is returned.
     961//
     962Bool_t MEvtLoop::ReadEnv(const char *config)
     963{
     964    return config ? ReadEnv(TEnv(config)) : kTRUE;
     965}
     966
     967// --------------------------------------------------------------------------
     968//
    958969// Write the contents/setup of a parameter container/task to a TEnv
    959970// instance (steering card/setup file).
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.h

    r2728 r4368  
    8080    Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
    8181
     82    Bool_t ReadEnv(const char *config);
     83
    8284    void RecursiveRemove(TObject *obj);
    8385
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r4303 r4368  
    3232
    3333#include <TF1.h>
     34#include <TEnv.h>
    3435#include <TFile.h>
     36#include <TLine.h>
     37#include <TLatex.h>
    3538#include <TString.h>
    3639#include <TCanvas.h>
    3740#include <TSystem.h>
    38 #include <TLine.h>
    3941#include <TLegend.h>
    40 #include <TLatex.h>
    4142
    4243#include "MLog.h"
     
    7071const Double_t MJPedestal::fgPedRmsMin   = 0.;
    7172const Double_t MJPedestal::fgPedRmsMax   = 20.;
    72 const Float_t  MJPedestal::fgRefPedClosedLids    = 9.635;
    73 const Float_t  MJPedestal::fgRefPedExtraGalactic = 9.93;
    74 const Float_t  MJPedestal::fgRefPedGalactic      = 10.03;
    75 const Float_t  MJPedestal::fgRefPedRmsClosedLids = 1.7;
     73
     74const Float_t  MJPedestal::fgRefPedClosedLids       = 9.635;
     75const Float_t  MJPedestal::fgRefPedExtraGalactic    = 9.93;
     76const Float_t  MJPedestal::fgRefPedGalactic         = 10.03;
     77const Float_t  MJPedestal::fgRefPedRmsClosedLids    = 1.7;
    7678const Float_t  MJPedestal::fgRefPedRmsExtraGalactic = 5.6;
    7779const Float_t  MJPedestal::fgRefPedRmsGalactic      = 6.92;
     80
    7881// --------------------------------------------------------------------------
    7982//
     
    8386//
    8487MJPedestal::MJPedestal(const char *name, const char *title)
    85     : fRuns(0), fExtractor(NULL), fDataCheck(kFALSE)
     88    : fEnv(0), fRuns(0), fExtractor(NULL), fDataCheck(kFALSE)
    8689{
    8790    fName  = name  ? name  : "MJPedestal";
     
    8992}
    9093
     94MJPedestal::~MJPedestal()
     95{
     96    if (fEnv)
     97        delete fEnv;
     98}
     99
    91100const char* MJPedestal::GetOutputFile() const
    92101{
    93 
    94   if (!fRuns)
    95     return "";
    96 
    97   return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
    98 
     102    if (!fRuns)
     103        return "";
     104
     105    return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
    99106}
    100107
    101108Bool_t MJPedestal::ReadPedestalCam()
    102109{
    103 
    104110    const TString fname = GetOutputFile();
    105111
     
    139145void MJPedestal::DisplayResult(MParList &plist)
    140146{
    141 
    142147    if (!fDisplay)
    143148        return;
     
    148153    TString title = fDisplay->GetTitle();
    149154    title += "--  Pedestal ";
    150     title += fRuns->GetRunsAsString();
     155    if (fRuns)  // FIXME: What to do if an environmentfile was used?
     156        title += fRuns->GetRunsAsString();
    151157    title += "  --";
    152158    fDisplay->SetTitle(title);
     
    179185    c3.Divide(2,3);
    180186
    181     if (fDataCheck)
    182       {
    183 
    184         c3.cd(1);
    185         gPad->SetBorderMode(0);
    186         gPad->SetTicks();
    187         MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist");
    188         obj1->SetDirectory(NULL);
    189         //
    190         // for the datacheck, fix the ranges!!
    191         //
    192         obj1->SetMinimum(fgPedestalMin);
    193         obj1->SetMaximum(fgPedestalMax);
    194         //
    195         // set reference lines
    196         //
    197         DisplayReferenceLines(obj1,0);
    198         //
    199         // end reference lines
    200         //
    201         c3.cd(3);
    202         gPad->SetBorderMode(0);
    203         obj1->SetPrettyPalette();
    204         obj1->Draw();
    205        
    206         c3.cd(5);
    207         gPad->SetBorderMode(0);
    208         gPad->SetTicks();
    209         obj1->DrawProjection(7);
    210 
    211         c3.cd(2);
    212         gPad->SetBorderMode(0);
    213         gPad->SetTicks();
    214         MHCamera *obj2=(MHCamera*)disp1.DrawCopy("hist");
    215         obj2->SetDirectory(NULL);
    216         obj2->SetMinimum(fgPedRmsMin);
    217         obj2->SetMaximum(fgPedRmsMax);
    218         //
    219         // set reference lines
    220         //
    221         DisplayReferenceLines(obj1,1);
    222 
    223         c3.cd(4);
    224         gPad->SetBorderMode(0);
    225         obj2->SetPrettyPalette();
    226         obj2->Draw();
    227        
    228         c3.cd(6);
    229         gPad->SetBorderMode(0);
    230         gPad->SetTicks();
    231 
    232         TArrayI inner(1);
    233         inner[0] = 0;
    234        
    235         TArrayI outer(1);
    236         outer[0] = 1;
    237 
    238         if (geomcam.InheritsFrom("MGeomCamMagic"))
    239         {
    240           TArrayI s0(6);
    241           s0[0] = 6;
    242           s0[1] = 1;
    243           s0[2] = 2;
    244           s0[3] = 3;
    245           s0[4] = 4;
    246           s0[5] = 5;
    247 
    248           TArrayI s1(3);
    249           s1[0] = 6;
    250           s1[1] = 1;
    251           s1[2] = 2;
    252          
    253           TArrayI s2(3);
    254           s2[0] = 3;
    255           s2[1] = 4;
    256           s2[2] = 5;
    257 
    258           gPad->Clear();
    259           TVirtualPad *pad = gPad;
    260           pad->Divide(2,1);
    261          
    262           TH1D *inout[2];
    263           inout[0] = disp1.ProjectionS(s0, inner, "Inner");
    264           inout[1] = disp1.ProjectionS(s0, outer, "Outer");
    265          
    266           inout[0]->SetDirectory(NULL);
    267           inout[1]->SetDirectory(NULL);
    268 
    269           for (int i=0; i<2; i++)
    270             {
    271               TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
    272               leg2->SetHeader(inout[i]->GetName());
    273               pad->cd(i+1);
    274               inout[i]->SetLineColor(kRed+i);
    275               inout[i]->SetBit(kCanDelete);
    276               inout[i]->Draw();
    277               inout[i]->Fit("gaus","Q");
    278               leg2->AddEntry(inout[i],inout[i]->GetName(),"l");
    279              
    280               //
    281               // Display the outliers as dead and noisy pixels
    282               //
    283               DisplayOutliers(inout[i]);
    284 
    285               //
    286               // Display the two half of the camera separately
    287               //
    288               TH1D *half[2];
    289               half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
    290               half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
    291              
    292               for (int j=0; j<2; j++)
    293                 {
    294                   half[j]->SetLineColor(kRed+i+2*j+1);
    295                   half[j]->SetDirectory(NULL);
    296                   half[j]->SetBit(kCanDelete);
    297                   half[j]->Draw("same");
    298                   leg2->AddEntry(half[j],half[j]->GetName(),"l");
    299                 }
    300               leg2->Draw();
    301             }
    302         }
    303       }
    304     else
    305       {
     187    if (!fDataCheck)
     188    {
    306189        disp0.CamDraw(c3, 1, 2, 1);
    307190        disp1.CamDraw(c3, 2, 2, 6);
    308       }
     191        return;
     192    }
     193
     194    c3.cd(1);
     195    gPad->SetBorderMode(0);
     196    gPad->SetTicks();
     197    MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist");
     198    obj1->SetDirectory(NULL);
     199
     200    //
     201    // for the datacheck, fix the ranges!!
     202    //
     203    obj1->SetMinimum(fgPedestalMin);
     204    obj1->SetMaximum(fgPedestalMax);
     205
     206    //
     207    // set reference lines
     208    //
     209    DisplayReferenceLines(obj1,0);
     210
     211    //
     212    // end reference lines
     213    //
     214    c3.cd(3);
     215    gPad->SetBorderMode(0);
     216    obj1->SetPrettyPalette();
     217    obj1->Draw();
     218
     219    c3.cd(5);
     220    gPad->SetBorderMode(0);
     221    gPad->SetTicks();
     222    obj1->DrawProjection(7);
     223
     224    c3.cd(2);
     225    gPad->SetBorderMode(0);
     226    gPad->SetTicks();
     227    MHCamera *obj2=(MHCamera*)disp1.DrawCopy("hist");
     228    obj2->SetDirectory(NULL);
     229    obj2->SetMinimum(fgPedRmsMin);
     230    obj2->SetMaximum(fgPedRmsMax);
     231
     232    //
     233    // set reference lines
     234    //
     235    DisplayReferenceLines(obj1,1);
     236
     237    c3.cd(4);
     238    gPad->SetBorderMode(0);
     239    obj2->SetPrettyPalette();
     240    obj2->Draw();
     241
     242    c3.cd(6);
     243    gPad->SetBorderMode(0);
     244    gPad->SetTicks();
     245
     246    TArrayI inner(1);
     247    inner[0] = 0;
     248
     249    TArrayI outer(1);
     250    outer[0] = 1;
     251
     252    if (geomcam.InheritsFrom("MGeomCamMagic"))
     253    {
     254        TArrayI s0(6);
     255        s0[0] = 6;
     256        s0[1] = 1;
     257        s0[2] = 2;
     258        s0[3] = 3;
     259        s0[4] = 4;
     260        s0[5] = 5;
     261
     262        TArrayI s1(3);
     263        s1[0] = 6;
     264        s1[1] = 1;
     265        s1[2] = 2;
     266
     267        TArrayI s2(3);
     268        s2[0] = 3;
     269        s2[1] = 4;
     270        s2[2] = 5;
     271
     272        gPad->Clear();
     273        TVirtualPad *pad = gPad;
     274        pad->Divide(2,1);
     275
     276        TH1D *inout[2];
     277        inout[0] = disp1.ProjectionS(s0, inner, "Inner");
     278        inout[1] = disp1.ProjectionS(s0, outer, "Outer");
     279
     280        inout[0]->SetDirectory(NULL);
     281        inout[1]->SetDirectory(NULL);
     282
     283        for (int i=0; i<2; i++)
     284        {
     285            TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
     286            leg2->SetHeader(inout[i]->GetName());
     287            pad->cd(i+1);
     288            inout[i]->SetLineColor(kRed+i);
     289            inout[i]->SetBit(kCanDelete);
     290            inout[i]->Draw();
     291            inout[i]->Fit("gaus","Q");
     292            leg2->AddEntry(inout[i],inout[i]->GetName(),"l");
     293
     294            //
     295            // Display the outliers as dead and noisy pixels
     296            //
     297            DisplayOutliers(inout[i]);
     298
     299            //
     300            // Display the two half of the camera separately
     301            //
     302            TH1D *half[2];
     303            half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
     304            half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
     305
     306            for (int j=0; j<2; j++)
     307            {
     308                half[j]->SetLineColor(kRed+i+2*j+1);
     309                half[j]->SetDirectory(NULL);
     310                half[j]->SetBit(kCanDelete);
     311                half[j]->Draw("same");
     312                leg2->AddEntry(half[j],half[j]->GetName(),"l");
     313            }
     314            leg2->Draw();
     315        }
     316    }
    309317}
    310318
    311319void  MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
    312320{
    313 
    314   TLine *gala = new TLine(0,
    315                           what ? fgRefPedRmsGalactic : fgRefPedGalactic,cam->GetNbinsX(),
    316                           what ? fgRefPedRmsGalactic : fgRefPedGalactic);
    317   gala->SetBit(kCanDelete);
    318   gala->SetLineColor(4);
    319   gala->SetLineStyle(2);
    320   gala->SetLineWidth(3);
    321   gala->Draw();
    322   TLine *extr = new TLine(0,
    323                           what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic,cam->GetNbinsX(),
    324                           what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic); 
    325   extr->SetBit(kCanDelete);
    326   extr->SetLineColor(5);
    327   extr->SetLineStyle(2);
    328   extr->SetLineWidth(3);
    329   extr->Draw();
    330   TLine *close = new TLine(0,
    331                           what ? fgRefPedRmsClosedLids : fgRefPedClosedLids,cam->GetNbinsX(),
    332                           what ? fgRefPedRmsClosedLids : fgRefPedClosedLids); 
    333   close->SetBit(kCanDelete);
    334   close->SetLineColor(6);
    335   close->SetLineStyle(2);
    336   close->SetLineWidth(3);
    337   close->Draw();
    338   TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
    339   leg->SetBit(kCanDelete);
    340   leg->AddEntry(gala,"Galactic Source","l");
    341   leg->AddEntry(extr,"Extra-Galactic Source","l");
    342   leg->AddEntry(close,"Closed Lids","l");
    343   leg->Draw();
     321    const Double_t x = cam->GetNbinsX();
     322
     323    TLine line;
     324    line.SetLineStyle(kDashed);
     325    line.SetLineWidth(3);
     326   
     327    line.SetLineColor(kBlue);
     328    TLine *l1 = line.DrawLine(0, what ? fgRefPedRmsGalactic : fgRefPedGalactic,
     329                              x, what ? fgRefPedRmsGalactic : fgRefPedGalactic);
     330
     331    line.SetLineColor(kYellow);
     332    TLine *l2 = line.DrawLine(0, what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic,
     333                              x, what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic);
     334
     335    line.SetLineColor(kMagenta);
     336    TLine *l3 = line.DrawLine(0, what ? fgRefPedRmsClosedLids : fgRefPedClosedLids,
     337                              x, what ? fgRefPedRmsClosedLids : fgRefPedClosedLids);
     338
     339   
     340    TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
     341    leg->SetBit(kCanDelete);
     342    leg->AddEntry(l1, "Galactic Source","l");
     343    leg->AddEntry(l2, "Extra-Galactic Source","l");
     344    leg->AddEntry(l3, "Closed Lids","l");
     345    leg->Draw();
    344346}
    345347
    346348void  MJPedestal::DisplayOutliers(TH1D *hist) const
    347349{
    348  
    349   const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
    350   const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2);
    351   const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2);
    352   const Stat_t  dead  = hist->Integral(0,hist->FindBin(lolim)-1);
    353   const Stat_t  noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
    354              
    355   TLatex deadtex;
    356   deadtex.SetTextSize(0.06);
    357   deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead));
    358  
    359   TLatex noisytex;
    360   noisytex.SetTextSize(0.06);
    361   noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy));
    362  
     350    const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
     351    const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2);
     352    const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2);
     353    const Stat_t  dead  = hist->Integral(0,hist->FindBin(lolim)-1);
     354    const Stat_t  noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
     355
     356    TLatex deadtex;
     357    deadtex.SetTextSize(0.06);
     358    deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead));
     359
     360    TLatex noisytex;
     361    noisytex.SetTextSize(0.06);
     362    noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy));
    363363}
    364364
     
    402402}
    403403
     404void MJPedestal::SetEnv(const char *env)
     405{
     406    if (fEnv)
     407        delete fEnv;
     408    fEnv = new TEnv(env);
     409}
     410
    404411Bool_t MJPedestal::Process()
    405412{
     
    412419Bool_t MJPedestal::ProcessFile()
    413420{
    414     if (!fRuns)
    415     {
    416         *fLog << err << "No Runs choosen... abort." << endl;
    417         return kFALSE;
    418     }
    419     if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
     421    if (!fRuns && !fEnv)
     422    {
     423        *fLog << err << "Neither AddRuns was called nor SetEnv was used... abort." << endl;
     424        return kFALSE;
     425    }
     426    if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
    420427    {
    421428        *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
     
    425432    *fLog << inf;
    426433    fLog->Separator(GetDescriptor());
    427     *fLog << "Calculate MPedestalCam from Runs " << fRuns->GetRunsAsString() << endl;
     434    *fLog << "Calculate MPedestalCam from Runs ";
     435    if (fRuns)
     436        *fLog << fRuns->GetRunsAsString() << endl;
     437    else
     438        *fLog << "in " << fEnv->GetName() << endl;
    428439    *fLog << endl;
    429440
     
    437448    if (fDataCheck)
    438449    {
    439         rawread.AddFiles(*fRuns);
     450        if (fRuns)
     451            rawread.AddFiles(*fRuns);
    440452        tlist.AddToList(&rawread);
    441453    }
    442454    else
    443455    {
    444         read.DisableAutoScheme();
    445         static_cast<MRead&>(read).AddFiles(*fRuns);
     456        read.DisableAutoScheme();
     457        if (fRuns)
     458            static_cast<MRead&>(read).AddFiles(*fRuns);
    446459        tlist.AddToList(&read);
    447460    }
     
    454467
    455468    MGeomApply      geomapl;
    456     // MBadPixelsMerge merge(&fBadPixels);
     469    MBadPixelsMerge merge(&fBadPixels);
    457470    MPedCalcPedRun  pedcalc;
    458471
    459472    if (fExtractor)
    460       {
     473    {
    461474        pedcalc.SetWindowSize((Int_t)fExtractor->GetNumHiGainSamples());
    462475        pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast());
    463       }
     476    }
    464477    else
    465       {
    466         *fLog << warn << GetDescriptor() 
    467             << ": No extractor has been chosen, take default number of FADC samples " << endl;
    468       }
     478    {
     479        *fLog << warn << GetDescriptor();
     480        *fLog << ": No extractor has been chosen, take default number of FADC samples " << endl;
     481    }
    469482
    470483    tlist.AddToList(&geomapl);
    471     //    tlist.AddToList(&merge);
    472     //tlist.AddToList(&sigcalc);
     484    tlist.AddToList(&merge);
    473485    tlist.AddToList(&pedcalc);
    474486
     
    480492    evtloop.SetDisplay(fDisplay);
    481493    evtloop.SetLogStream(fLog);
     494    if (fEnv)
     495        evtloop.ReadEnv(*fEnv);
    482496
    483497    // Execute first analysis
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.h

    r4303 r4368  
    99#endif
    1010
     11class TEnv;
    1112class TCanvas;
    1213class MParList;
     
    1516class TH1D;
    1617class MExtractor;
    17 class MJPedestal : public MParContainer 
     18
     19class MJPedestal : public MParContainer
    1820{
    1921private:
     22    static const Double_t fgPedestalMin;
     23    static const Double_t fgPedestalMax;
     24    static const Double_t fgPedRmsMin;
     25    static const Double_t fgPedRmsMax;
    2026
    21   static const Double_t fgPedestalMin;
    22   static const Double_t fgPedestalMax; 
    23   static const Double_t fgPedRmsMin;
    24   static const Double_t fgPedRmsMax; 
     27    static const Float_t  fgRefPedClosedLids;
     28    static const Float_t  fgRefPedExtraGalactic;
     29    static const Float_t  fgRefPedGalactic;
    2530
    26   static const Float_t  fgRefPedClosedLids;
    27   static const Float_t  fgRefPedExtraGalactic;
    28   static const Float_t  fgRefPedGalactic;
     31    static const Float_t  fgRefPedRmsClosedLids;
     32    static const Float_t  fgRefPedRmsExtraGalactic;
     33    static const Float_t  fgRefPedRmsGalactic;
    2934
    30   static const Float_t  fgRefPedRmsClosedLids;
    31   static const Float_t  fgRefPedRmsExtraGalactic;
    32   static const Float_t  fgRefPedRmsGalactic;
     35    TString fOutputPath;
    3336
    34   TString fOutputPath;
    35  
    36   MRunIter   *fRuns;
    37   MExtractor *fExtractor;                         // Signal extractor, used to find the nr. of used FADC slices
     37    TEnv       *fEnv;           // Input setup-file
    3838
    39   MPedestalCam  fPedestalCam;
    40   MBadPixelsCam fBadPixels;
    41  
    42   Bool_t fDataCheck;                              // Flag if the data check is run on raw data
    43  
    44   Bool_t ReadPedestalCam();
    45   Bool_t WriteResult();
    46  
    47   void   DisplayResult(MParList &plist);
    48   void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
    49   void   DisplayOutliers(      TH1D *hist) const;
    50  
     39    MRunIter   *fRuns;
     40    MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
     41
     42    MPedestalCam  fPedestalCam;
     43    MBadPixelsCam fBadPixels;
     44
     45    Bool_t fDataCheck;          // Flag if the data check is run on raw data
     46
     47    Bool_t ReadPedestalCam();
     48    Bool_t WriteResult();
     49
     50    void   DisplayResult(MParList &plist);
     51    void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
     52    void   DisplayOutliers(TH1D *hist) const;
     53
    5154public:
     55    MJPedestal(const char *name=NULL, const char *title=NULL);
     56    ~MJPedestal();
    5257
    53   MJPedestal(const char *name=NULL, const char *title=NULL);
     58    MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
     59    const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
    5460
    55   MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
    56   const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
    57  
    58   const char* GetOutputFile() const;
    59   const Bool_t IsDataCheck() const    { return fDataCheck;  }
    60  
    61   Bool_t Process();
    62   Bool_t ProcessFile();
    63  
    64   void SetBadPixels ( const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
    65   void SetDataCheck ( const Bool_t b=kTRUE    ) { fDataCheck = b;       }
    66   void SetExtractor (       MExtractor* ext   ) { fExtractor = ext;     }
    67   void SetInput     (       MRunIter *iter    ) { fRuns      = iter;    }
    68   void SetOutputPath( const char *path="."    );
    69  
    70   ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
     61    const char* GetOutputFile() const;
     62    const Bool_t IsDataCheck() const    { return fDataCheck;  }
     63
     64    Bool_t Process();
     65    Bool_t ProcessFile();
     66
     67    void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
     68    void SetExtractor(MExtractor* ext   ) { fExtractor = ext;     }
     69    void SetInput(MRunIter *iter) { fRuns = iter; }
     70    void SetOutputPath(const char *path=".");
     71    void SetEnv(const char *env);
     72
     73    void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; }
     74
     75    ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
    7176};
    7277
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc

    r4288 r4368  
    101101//   fLoGainWindowSize = fgLoGainWindowSize = 0
    102102//
     103//
     104// ToDo:
     105//   - Take a setup file (ReadEnv-implementation) as input
     106//
     107//
    103108//  Input Containers:
    104109//   MRawEvtData
  • 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.