Changeset 4991


Ignore:
Timestamp:
09/14/04 12:13:07 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4990 r4991  
    1919
    2020                                                 -*-*- END OF LINE -*-*-
    21 
     21 2004/09/14: Thomas Bretz
     22
     23   * mbase/MFilter.[h,cc]:
     24     - added PrintSkipped
     25
     26   * mbase/MTask.[h,cc]:
     27     - added PrintSkipped
     28
     29   * mfilter/FilterLinkDef.h, mfilter/Makefile:
     30     - added MFDeltaT
     31
     32   * mhbase/MFillH.[h,cc]:
     33     - added forwarding of number of executions
     34     - removed obsolete ->cd() around filling
     35
     36   * mhbase/MH.[h,cc]:
     37     - simplified the new Projecttion functions
     38     - added PrintSkipped
     39     - increased ClassDef version number to 2
     40
     41   * mhcalib/HCalibLinkDef.h:
     42     - removed second + from MHGausEvents
     43
     44   * mjobs/MJCalibration.cc:
     45     - fixed a comment
     46
     47   * mjobs/MJStar.cc:
     48     - added MFDeltaT
     49
     50   * mpedestal/MPedCalcFromLoGain.cc:
     51     - fixed a typo in a comment
     52
     53
     54 
    2255 2004/09/13: Antonio Stamerra
    2356
     
    76109   * mhcalib/MHCalibrationChargeCam.[h,cc]
    77110     - wrote a ReadEnv function
     111
     112   * mbase/MFilter.[h,cc]:
     113     - added PrintSkipped
     114
     115   * mbase/MTask.[h,cc]:
     116     - added PrintSkipped
     117
     118   * mfilter/FilterLinkDef.h, mfilter/Makefile:
     119     - added MFDeltaT
     120
     121   * mhbase/MFillH.[h,cc]:
     122     - added forwarding of number of executions
     123
     124   * mhbase/MH.[h,cc]:
     125     - simplified the new Projecttion functions
     126     - added PrintSkipped
     127     - increased ClassDef version number to 2
     128
     129   * mhcalib/HCalibLinkDef.h:
     130     - removed second + from MHGausEvents
     131
     132   * mjobs/MJCalibration.cc:
     133     - fixed a comment
     134
     135   * mjobs/MJStar.cc:
     136     - added MFDeltaT
     137
     138   * mpedestal/MPedCalcFromLoGain.cc:
     139     - fixed a typo in a comment
    78140
    79141
  • trunk/MagicSoft/Mars/mbase/MFilter.cc

    r2386 r4991  
    1818!   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    2424
    2525/////////////////////////////////////////////////////////////////////////////
    26 //                                                                         //
    27 //   MFilter                                                               //
    28 //                                                                         //
    29 //   This is a base class which defines an interface to create your own    //
    30 //   filters. To do it derive a class from MFilter.                        //
    31 //                                                                         //
    32 //   You can invert the meaning of a filter (logical NOT '!') by calling   //
    33 //   SetInverted().                                                        //
    34 //                                                                         //
    35 //   You can create two types of Filters:                                  //
    36 //    - static Filters and                                                 //
    37 //    - dynamic Filters                                                    //
    38 //                                                                         //
    39 //   Static Filters:                                                       //
    40 //    A static filter is a filter which value doesn't change dynamically,  //
    41 //    which mean only once while running through your tasklist. To create  //
    42 //    a static filter override the Process-function of MFilter (this is    //
    43 //    the function in which the filer-value should be updated). If         //
    44 //    necessary you can also overwrite Pre-/PostProcess. The process       //
    45 //    function should calculate the return value of IsExpressionTrue.      //
    46 //    IsExpressionTrue should simply return this value. This kind of       //
    47 //    filter must be added to the tasklist at a point which is forseen to  //
    48 //    update the value of the filter (eg. after the reading task).         //
    49 //                                                                         //
    50 //   Dynamic Filters:                                                      //
    51 //    A dynamic filter is a filter which returns a value which must be     //
    52 //    calculated at the time the filter is called. To create such a        //
    53 //    filter you have to overwrite IsExpressionTrue only. If there is      //
    54 //    no need for a 'one-point' update this filter must not be added to    //
    55 //    the tasklist.                                                        //
    56 //                                                                         //
    57 //   Usage:                                                                //
    58 //    A Filter is connected to a task by calling MTask::SetFilter. The     //
    59 //    task is now executed when IsExpressionTrue returns a value           //
    60 //    (different from kFALSE) only.                                        //
    61 //                                                                         //
    62 //   Remarks:                                                              //
    63 //    - Make sure, that all tasks which depends on this filter are either  //
    64 //      collected in a MTaskList-object or are conected to the same        //
    65 //      filter.                                                            //
    66 //    - If you want to use different filters (combined logically) for one  //
    67 //      task please look for the MFilterList class.                        //
    68 //    - Be careful, the return value of IsExpressionTrue is NOT a real     //
    69 //      boolean. You can return other values, too.                         //
    70 //                                                                         //
     26//
     27//   MFilter
     28//
     29//   This is a base class which defines an interface to create your own
     30//   filters. To do it derive a class from MFilter.
     31//
     32//   You can invert the meaning of a filter (logical NOT '!') by calling
     33//   SetInverted().
     34//
     35//   You can create two types of Filters:
     36//    - static Filters and
     37//    - dynamic Filters
     38//
     39//   Static Filters:
     40//    A static filter is a filter which value doesn't change dynamically,
     41//    which mean only once while running through your tasklist. To create
     42//    a static filter override the Process-function of MFilter (this is
     43//    the function in which the filer-value should be updated). If
     44//    necessary you can also overwrite Pre-/PostProcess. The process
     45//    function should calculate the return value of IsExpressionTrue.
     46//    IsExpressionTrue should simply return this value. This kind of
     47//    filter must be added to the tasklist at a point which is forseen to
     48//    update the value of the filter (eg. after the reading task).
     49//
     50//   Dynamic Filters:
     51//    A dynamic filter is a filter which returns a value which must be
     52//    calculated at the time the filter is called. To create such a
     53//    filter you have to overwrite IsExpressionTrue only. If there is
     54//    no need for a 'one-point' update this filter must not be added to
     55//    the tasklist.
     56//
     57//   Usage:
     58//    A Filter is connected to a task by calling MTask::SetFilter. The
     59//    task is now executed when IsExpressionTrue returns a value
     60//    (different from kFALSE) only.
     61//
     62//   Remarks:
     63//    - Make sure, that all tasks which depends on this filter are either
     64//      collected in a MTaskList-object or are conected to the same
     65//      filter.
     66//    - If you want to use different filters (combined logically) for one
     67//      task please look for the MFilterList class.
     68//    - Be careful, the return value of IsExpressionTrue is NOT a real
     69//      boolean. You can return other values, too.
     70//
    7171/////////////////////////////////////////////////////////////////////////////
     72#include "MFilter.h"
    7273
    73 #include "MFilter.h"
     74#include "MLog.h"
     75#include "MLogManip.h"
    7476
    7577ClassImp(MFilter);
    7678
     79using namespace std;
     80
     81// --------------------------------------------------------------------------
     82//
     83//  Default constructor for a filter. Initializes fInverted with kFALSE
     84//
    7785MFilter::MFilter(const char *name, const char *title) : fInverted(kFALSE)
    7886{
     
    8189}
    8290
     91// --------------------------------------------------------------------------
     92//
     93//  return the Rule corresponding to this filter (see MF and MDataChain)
     94//
    8395TString MFilter::GetRule() const
    8496{
    8597    return "<GetRule n/a for " + fName + ">";
    8698}
     99
     100// --------------------------------------------------------------------------
     101//
     102//  This is used to print the output in the PostProcess/Finalize.
     103//  Or everywhere else in a nice fashioned and unified way.
     104//
     105void MFilter::PrintSkipped(UInt_t n, const char *str)
     106{
     107    *fLog << " " << setw(7) << n << " (";
     108    *fLog << setw(3) << TMath::Nint(100.*n/GetNumExecutions());
     109    *fLog << "%) Evts fullfilled: " << str << endl;
     110}
  • trunk/MagicSoft/Mars/mbase/MFilter.h

    r1948 r4991  
    2525    Bool_t IsInverted() const  { return fInverted; }
    2626
     27    void PrintSkipped(UInt_t n, const char *str);
     28
    2729    ClassDef(MFilter, 1)                // Abstract base class for the filters
    2830};
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r3895 r4991  
    483483    MParContainer::SetDisplay(d);
    484484}
     485
     486// --------------------------------------------------------------------------
     487//
     488//  This is used to print the output in the PostProcess/Finalize.
     489//  Or everywhere else in a nice fashioned and unified way.
     490//
     491void MTask::PrintSkipped(UInt_t n, const char *str)
     492{
     493    *fLog << " " << setw(7) << n << " (";
     494    *fLog << setw(3) << TMath::Nint(100.*n/GetNumExecutions());
     495    *fLog << "%) Evts skipped: " << str << endl;
     496}
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r3666 r4991  
    9595    Double_t GetRealTime() const;
    9696    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
     97    virtual void PrintSkipped(UInt_t n, const char *str);
    9798
    9899    // Task overwrite functions
  • trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h

    r3331 r4991  
    99#pragma link C++ class MFTriggerLvl2+;
    1010#pragma link C++ class MFGeomag+;
     11#pragma link C++ class MFDeltaT+;
    1112#pragma link C++ class MFParticleId+;
    1213
  • trunk/MagicSoft/Mars/mfilter/Makefile

    r4584 r4991  
    2121           MFTriggerLvl2.cc \
    2222           MFGeomag.cc \
     23           MFDeltaT.cc \
    2324           MFParticleId.cc \
    2425           MFAlpha.cc \
  • trunk/MagicSoft/Mars/mhbase/MFillH.cc

    r4058 r4991  
    1818!   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    2424
    2525//////////////////////////////////////////////////////////////////////////////
    26 //                                                                          //
    27 //  MFillH                                                                  //
    28 //                                                                          //
    29 //  This is a common interface (task) to fill mars histograms. Every mars   //
    30 //  histogram which is derived from MH can be filled with this task.        //
    31 //                                                                          //
    32 //  There are two options to use:                                           //
    33 //                                                                          //
    34 //  1) You specifiy the parameter container with which data the             //
    35 //     histogram container should be filled, and the histogram container    //
    36 //     which has to be filled. This can be done by either specifing the     //
    37 //     name of the objects in the parameter list or by specifiing a pointer //
    38 //     to the object. (s. Constructor)                                      //
    39 //                                                                          //
    40 //  2) You specify the name and/or type of the histogram to become filled.  //
    41 //     Any other action imust be taken by the histogram class.              //
    42 //                                                                          //
    43 //  PreProcess: In the preprocessing of this task we setup all pointers     //
    44 //              to instances which are needed and call FillSetup of the     //
    45 //              histogram class with the parameter list as an argument.     //
    46 //                                                                          //
    47 //  Process: The process function calls the Fill member function of the     //
    48 //           histogram class instance (inheriting from MH) with either      //
    49 //           a NULL pointer or a pointer to the corresponding container     //
    50 //           as an argument.                                                //
    51 //                                                                          //
    52 // To use a weight for each event filled in a histogram call                //
    53 // SetWeight(). You can eithe use the name of a MWeight container stored    //
    54 // in the parameter list or a pointer to it as an argument.                 //
    55 //                                                                          //
    56 //                                                                          //
    57 //  WARNING:                                                                //
    58 //   Because MFillH is a generalized task to fill histograms it doesn't     //
    59 //   know about which branches from a file are necessary to fill the        //
    60 //   histograms. If you are reading data from a file which is directly      //
    61 //   filled into a histogram via MFillH, please call either                 //
    62 //   MReadTree::DisableAutoScheme() or enable the necessary branches by     //
    63 //   yourself, using MReadTree::EnableBranch()                              //
    64 //                                                                          //
    65 //   Checkout the Warning in MTaskList.                                     //
    66 //                                                                          //
    67 //  Input Containers:                                                       //
    68 //   A parameter container                                                  //
    69 //                                                                          //
    70 //  Output Containers:                                                      //
    71 //   A histogram container                                                  //
    72 //                                                                          //
     26//
     27//  MFillH
     28//
     29//  This is a common interface (task) to fill mars histograms. Every mars
     30//  histogram which is derived from MH can be filled with this task.
     31//
     32//  There are two options to use:
     33//
     34//  1) You specifiy the parameter container with which data the
     35//     histogram container should be filled, and the histogram container
     36//     which has to be filled. This can be done by either specifing the
     37//     name of the objects in the parameter list or by specifiing a pointer
     38//     to the object. (s. Constructor)
     39//
     40//  2) You specify the name and/or type of the histogram to become filled.
     41//     Any other action imust be taken by the histogram class.
     42//
     43//  PreProcess: In the preprocessing of this task we setup all pointers
     44//              to instances which are needed and call FillSetup of the
     45//              histogram class with the parameter list as an argument.
     46//
     47//  Process: The process function calls the Fill member function of the
     48//           histogram class instance (inheriting from MH) with either
     49//           a NULL pointer or a pointer to the corresponding container
     50//           as an argument.
     51//
     52// To use a weight for each event filled in a histogram call
     53// SetWeight(). You can eithe use the name of a MWeight container stored
     54// in the parameter list or a pointer to it as an argument.
     55//
     56//
     57//  WARNING:
     58//   Because MFillH is a generalized task to fill histograms it doesn't
     59//   know about which branches from a file are necessary to fill the
     60//   histograms. If you are reading data from a file which is directly
     61//   filled into a histogram via MFillH, please call either
     62//   MReadTree::DisableAutoScheme() or enable the necessary branches by
     63//   yourself, using MReadTree::EnableBranch()
     64//
     65//   Checkout the Warning in MTaskList.
     66//
     67//  Version 2:
     68//  ----------
     69//   - added fNumExcutions
     70//
     71//
     72//  Input Containers:
     73//   A parameter container
     74//
     75//  Output Containers:
     76//   A histogram container
     77//
    7378//////////////////////////////////////////////////////////////////////////////
    7479#include "MFillH.h"
     
    457462    //
    458463    fH->SetSerialNumber(GetSerialNumber());
     464    fH->SetNumExecutions(0);
    459465    if (!fH->SetupFill(pList))
    460466    {
     
    519525     ((MHArray*)fH)->SetIndex(idx);
    520526     */
    521 
     527/*
    522528    TVirtualPad *save = gPad;
    523529    if (fCanvas)
    524530        fCanvas->cd();
    525 
     531  */
    526532    const Bool_t rc = fH->Fill(fParContainer, fWeight?fWeight->GetWeight():1);
    527 
     533    fH->SetNumExecutions(GetNumExecutions()+1);
     534/*
    528535    if (save && fCanvas)
    529536        save->cd();
    530 
     537  */
    531538    return rc;
    532539}
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r4966 r4991  
    12711271                       const char* name, const char* title)
    12721272{
    1273     const Int_t size = array.GetSize();
    1274 
    1275     TH1I *h1=0;
    1276 
    1277     //check if histogram with identical name exist
    1278     TObject *h1obj = gROOT->FindObject(name);
    1279     if (h1obj && h1obj->InheritsFrom("TH1I"))
    1280     {
    1281         h1 = (TH1I*)h1obj;
    1282         h1->Reset();
    1283     }
    1284 
    1285     Double_t min = size>0 ? array[0] : 0;
    1286     Double_t max = size>0 ? array[0] : 1;
    1287 
    1288     // first loop over array to find the min and max
    1289     for (Int_t i=1; i<size;i++)
    1290     {
    1291         max = TMath::Max((Double_t)array[i], max);
    1292         min = TMath::Min((Double_t)array[i], min);
    1293     }
    1294 
    1295     Int_t newbins = 0;
    1296     FindGoodLimits(nbins, newbins, min, max, kFALSE);
    1297 
    1298     if (!h1)
    1299     {
    1300         h1 = new TH1I(name, title, nbins, min, max);
    1301         h1->SetXTitle("");
    1302         h1->SetYTitle("Counts");
    1303         h1->SetDirectory(gROOT);
    1304     }
    1305 
    1306     // Second loop to fill the histogram
    1307     for (Int_t i=0;i<size;i++)
    1308         h1->Fill(array[i]);
    1309 
    1310     return h1;
     1273    const TArrayF arr(array.GetSize(), array.GetArray());
     1274    return ProjectArray(array, nbins, name, title);
    13111275}
    13121276
     
    13171281TH1I* MH::ProjectArray(const MArrayD &array, Int_t nbins, const char* name, const char* title)
    13181282{
    1319     const Int_t size = array.GetSize();
    1320     TH1I *h1=0;
    1321 
    1322     //check if histogram with identical name exist
    1323     TObject *h1obj = gROOT->FindObject(name);
    1324     if (h1obj && h1obj->InheritsFrom("TH1I"))
    1325     {
    1326         h1 = (TH1I*)h1obj;
    1327         h1->Reset();
    1328     }
    1329 
    1330     Double_t min = size>0 ? array[0] : 0;
    1331     Double_t max = size>0 ? array[0] : 1;
    1332 
    1333     // first loop over array to find the min and max
    1334     for (Int_t i=1; i<size;i++)
    1335     {
    1336         max = TMath::Max(array[i], max);
    1337         min = TMath::Min(array[i], min);
    1338     }
    1339 
    1340     Int_t newbins = 0;
    1341     FindGoodLimits(nbins, newbins, min, max, kFALSE);
    1342 
    1343     if (!h1)
    1344     {
    1345         h1 = new TH1I(name, title, newbins, min, max);
    1346         h1->SetXTitle("");
    1347         h1->SetYTitle("Counts");
    1348         h1->SetDirectory(gROOT);
    1349     }
    1350 
    1351     // Second loop to fill the histogram
    1352     for (Int_t i=0;i<size;i++)
    1353         h1->Fill(array[i]);
    1354 
    1355     return h1;
    1356 }
    1357 
     1283    const TArrayD arr(array.GetSize(), array.GetArray());
     1284    return ProjectArray(array, nbins, name, title);
     1285}
     1286
     1287// --------------------------------------------------------------------------
     1288//
     1289// See MTask::PrintSkipped
     1290//
     1291void MH::PrintSkipped(UInt_t n, const char *str)
     1292{
     1293    *fLog << " " << setw(7) << n << " (";
     1294    *fLog << setw(3) << (int)(100.*n/GetNumExecutions());
     1295    *fLog << "%) Evts skipped: " << str << endl;
     1296}
  • trunk/MagicSoft/Mars/mhbase/MH.h

    r4966 r4991  
    2424{
    2525private:
    26     Byte_t fSerialNumber;
     26    Byte_t fSerialNumber;   // Serial number (eg of telecope)
     27    UInt_t fNumExecutions;  // Number of calls to Fill function
    2728
    2829public:
    2930    MH(const char *name=NULL, const char *title=NULL);
    30 
    3131
    3232    virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
     
    3434    TString AddSerialNumber(const char *str) const { TString s(str); if (fSerialNumber==0) return s; s += ";"; s += fSerialNumber; return s; }
    3535    TString AddSerialNumber(const TString &str) const { return AddSerialNumber((const char*)str); }
     36
     37    UInt_t GetNumExecutions() const { return fNumExecutions; }
     38    void SetNumExecutions(UInt_t n) { fNumExecutions=n; }
     39
     40    void PrintSkipped(UInt_t n, const char *str);
    3641
    3742    Bool_t OverwritesDraw(TClass *cls=NULL) const;
     
    110115    static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL);
    111116
    112     ClassDef(MH, 1) //A base class for Mars histograms
     117    ClassDef(MH, 2) //A base class for Mars histograms
    113118};
    114119
  • trunk/MagicSoft/Mars/mhcalib/HCalibLinkDef.h

    r4940 r4991  
    1616#pragma link C++ class MHCalibrationTestTimeCam+;
    1717
    18 #pragma link C++ class MHGausEvents++;
     18#pragma link C++ class MHGausEvents+;
    1919
    2020#endif
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r4987 r4991  
    13691369//   MJCalibration.Datacheck: yes,no
    13701370//   MJCalibration.Debug: yes,no
     1371//   MJCalibration.Intensity: yes,no
    13711372//   MJCalibration.UseBlindPixel: yes,no
    13721373//   MJCalibration.UsePINDiode: yes,no
  • trunk/MagicSoft/Mars/mjobs/MJStar.cc

    r4966 r4991  
    5050#include "MReadReports.h"
    5151#include "MReadMarsFile.h"
     52#include "MFDeltaT.h"
     53#include "MContinue.h"
    5254#include "MGeomApply.h"
    5355#include "MEventRateCalc.h"
     
    160162
    161163    // ------------------ Setup general tasks ----------------
     164
     165    MFDeltaT               fdeltat;
     166    MContinue              cont(&fdeltat, "FilterDeltaT", "Filter events with wrong timing");
     167    cont.SetInverted();
    162168
    163169    MGeomApply             apply; // Only necessary to craete geometry
     
    218224    if (ismc)
    219225    {
    220         write.AddContainer("MPointingPos", "Events");
     226        write.AddContainer("MPointingPos",        "Events");
    221227        // Monte Carlo
    222228        write.AddContainer("MMcEvt",              "Events");
     
    229235    else
    230236    {
    231         write.AddContainer("MTime",         "Events");
     237        write.AddContainer("MTime",               "Events");
    232238        // Run Header
    233239        write.AddContainer("MRawRunHeader",       "RunHeaders");
     
    237243        // Drive
    238244        //write.AddContainer("MSrcPosCam",   "Drive");
    239         write.AddContainer("MPointingPos", "Drive");
    240         write.AddContainer("MReportDrive", "Drive");
    241         write.AddContainer("MTimeDrive",   "Drive");
     245        write.AddContainer("MPointingPos",        "Drive");
     246        write.AddContainer("MReportDrive",        "Drive");
     247        write.AddContainer("MTimeDrive",          "Drive");
    242248        // Effective On Time
    243249        write.AddContainer("MEffectiveOnTime",     "EffectiveOnTime");
     
    249255    if (!ismc)
    250256    {
     257        tlist2.AddToList(&cont);
    251258        tlist2.AddToList(&rate);
    252259        //tlist2.AddToList(&rate10000);
  • trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc

    r4682 r4991  
    3333//
    3434//
    35 //  This task is devide form MPedCalcPedRun, described below. However, It
     35//  This task is derived form MPedCalcPedRun, described below. However, It
    3636//  calculates the pedstals using the low gain slices, whenever the difference
    3737//  between the highest and the lowest slice in the high gain
Note: See TracChangeset for help on using the changeset viewer.