Changeset 2802


Ignore:
Timestamp:
01/14/04 16:18:50 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2801 r2802  
    1212       rms = 0 later resulted in the pixel being eliminated in the
    1313       image cleaning.
     14
     15
     16
    1417
    1518 2004/01/14: Thomas Bretz
     
    4144   * mreport/MReportFileRead.cc:
    4245     - moved code from MReportHelp to new file
    43      - removed usage of MRepoort class completely
     46     - removed usage of MReport class completely
     47
     48   * mfilter/MFGeomag.[h,cc]:
     49     - fixed a bug which causes MFGeomag to fail if MARSSYS is not set
     50     - changed the second loop from 0->1151 to 1152->2304
     51     - removed dummy arrays used for reading
     52     - output filename in case of 'file not found'
     53     - removed obsolete data members
     54     - removed obsolete Init function
     55     - removed forbidden underscore from member variable
     56     - changed wrong 0/1 in allocation of fResult into kFALSE/TRUE
    4457
    4558
  • trunk/MagicSoft/Mars/mfilter/MFGeomag.cc

    r2779 r2802  
    1616!
    1717!
    18 !   Author(s): R.K.Bock 11/2003     <mailto:rkb@mppmu.mpg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2001
     18!   Author(s): R.K.Bock 11/2003 <mailto:rkb@mppmu.mpg.de>
     19!
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    3939#include "MFGeomag.h"
    4040
    41 #include "fstream"        //for ifstream
    42 #include "TRandom.h"      //for gRandom
     41#include <fstream>        //for ifstream
     42
     43#include <TRandom.h>      //for gRandom
     44#include <TSystem.h>
    4345
    4446#include "MLog.h"
     
    4951#include "MMcEvt.hxx"
    5052
    51 #include <TSystem.h>
    52 
    5353ClassImp(MFGeomag);
    5454
     
    5757// --------------------------------------------------------------------------
    5858//
    59 MFGeomag::MFGeomag(const char *cname, const char type, const Int_t val,
    60                            const char *name, const char *title) : fMcEvt(NULL)
    61 {
    62     fContName = cname;
    63     Init(type, val, name, title);
    64 }
    65 
    66 // --------------------------------------------------------------------------
    67 //
    68 void MFGeomag::Init(const char type, const Int_t val,
    69                         const char *name, const char *title)
    70 
     59MFGeomag::MFGeomag(const char *name, const char *title) : fMcEvt(NULL)
    7160{
    7261    fName  = name  ? name  : "MFGeomag";
    7362    fTitle = title ? title : "Filter using geomagnetic field";
    7463
    75     fGamm_elec = kFALSE;  // logical variable, will not take gammas as electrons (default)
    76 
    77     AddToBranchList(Form("%s.fPartId", (const char*)fContName));
     64    fGammaElectron = kFALSE;  // logical variable, will not take gammas as electrons (default)
     65
     66    AddToBranchList("MMcEvt.fPartId");
    7867}
     68
    7969// --------------------------------------------------------------------------
    8070//
     
    8272{
    8373    //  reading of tables (variables defined as 'private')
    84 
    85     Float_t azim  [2*1152];      // (these variables not used)
    86     Float_t thet  [2*1152];
    87 
    88     TString filename = gSystem->Getenv("MARSSYS");
    89     filename += "/mfilter/gcplus.txt";
     74    TString marssys(gSystem->Getenv("MARSSYS"));
     75    if (!marssys.IsNull() && !marssys.EndsWith("/"))
     76        marssys += "/";
     77
     78    //
     79    // Read gcminus.txt
     80    //
     81    TString filename(marssys);
     82    filename += "mfilter/gcplus.txt";
    9083
    9184    ifstream geomagp(filename);
    9285
    93     if (!geomagp) {
    94         *fLog << err <<" ERROR gcplus.txt file not found by Geomag"<<endl;
     86    if (!geomagp)
     87    {
     88        *fLog << err << "ERROR - file " << filename << " not found." << endl;
    9589        return kFALSE;
    9690    }
    9791    for (int i=0; i<1152; i++)
    9892    {
    99         geomagp >>azim[i]>>thet[i];
    100         geomagp >>fRigMin[i]>>fRigMax[i]>>fProb[i];
     93        Float_t dummy;
     94        geomagp >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i];
    10195    }
    10296    *fLog << inf << endl;
    103     *fLog << "gcplus.txt  read, first line: ";
     97    *fLog << "gcplus.txt - first line: ";
    10498    *fLog << Form ("FRigMin=%8f  fRigMax=%8f  fProb=%8f",
    10599                   fRigMin[0], fRigMax[0], fProb[0]) << endl;
    106100
    107     filename = gSystem->Getenv("MARSSYS");
    108     filename += "/mfilter/gcminus.txt";
     101    //
     102    // Read gcminus.txt
     103    //
     104    filename = marssys;
     105    filename += "mfilter/gcminus.txt";
    109106
    110107    ifstream geomagm(filename);
    111     if (!geomagm) {
    112         *fLog << err <<" ERROR gcminus.txt file not found by Geomag"<<endl;
    113         return kFALSE;
    114     }
    115     for (int i=0; i<1152; i++)
    116     {
    117         geomagm >>azim[i+1152]>>thet[i+1152];
    118         geomagm >>fRigMin[i+1152]>>fRigMax[i+1152]>>fProb[i+1152];
    119     }
    120     *fLog << "gcminus.txt read, first line: ";
     108    if (!geomagm)
     109    {
     110        *fLog << err << "ERROR - file " << filename << " not found." << endl;
     111        return kFALSE;
     112    }
     113    for (int i=1152; i<2304; i++)
     114    {
     115        Float_t dummy;
     116        geomagm >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i];
     117    }
     118    *fLog << "gcminus.txt - first line: ";
    121119    *fLog << Form ("fRigMin=%8f  fRigMax=%8f  fProb=%8f",
    122120                   fRigMin[1152], fRigMax[1152], fProb[1152]) << endl;
     
    129127    if (!fMcEvt)
    130128    {
    131         *fLog << err << dbginf << "  [MMcEvt] not found... aborting." << endl;
     129        *fLog << err << "MMcEvt not found... aborting." << endl;
    132130        return kFALSE;
    133131    }
     
    139137void MFGeomag::SetGammElec()
    140138{
    141     fGamm_elec = kTRUE;  // logical variable, will take gammas as electrons
     139    fGammaElectron = kTRUE;  // logical variable, will take gammas as electrons
    142140    *fLog <<" MFGeomag called to treat gammas as electrons" << endl;
    143141    return;
     
    157155    {
    158156    case kGAMMA:
    159         if (!fGamm_elec)         //accept gammas if not set to electrons
     157        if (!fGammaElectron)         //accept gammas if not set to electrons
    160158          {
    161             fResult = 0;
     159            fResult = kFALSE;
    162160            return kTRUE;
    163161          }
     
    180178
    181179    default:
    182         Int_t id = fMcEvt->GetPartId();
    183         *fLog << err <<" Unknown Monte Carlo Particle Id#: "<< id << endl;
     180        *fLog << err << " Unknown Monte Carlo Particle Id#: "<< fMcEvt->GetPartId() << endl;
    184181        return kFALSE;
    185182    }
     
    188185      int ia=(int)(az*11.459156);
    189186      ia = (ia+36) % 72;             // azimuth definitions differ by 180 deg
     187
    190188      float r1=fRigMin[72*it+ia+indadd];
    191189      if (rig<=r1) {
    192           fResult=1;        // reject
     190          fResult=kTRUE;    // reject
    193191          return kTRUE;
    194192      }
     193
    195194      float r2=fRigMax[72*it+ia+indadd];
    196195      if (rig>=r2) {
    197           fResult=0;        // accept
     196          fResult=kFALSE;   // accept
    198197          return kTRUE;
    199198      }
    200       float R = gRandom->Rndm(0);        //accept if above intermediate threshold
    201       float pr=fProb  [72*it+ia+indadd];   
    202       fResult = 0;
    203       if (rig < 0.5/pr*R*(r2-r1) + r1)  fResult = 1; // pretty good approximation
     199
     200      float R = gRandom->Rndm(0);        // accept if above intermediate threshold
     201      float pr=fProb[72*it+ia+indadd];
     202      fResult = kFALSE;
     203
     204      if (rig < 0.5/pr*R*(r2-r1) + r1)
     205          fResult = kTRUE;               // pretty good approximation
     206
    204207      return kTRUE;
    205208   }
  • trunk/MagicSoft/Mars/mfilter/MFGeomag.h

    r2510 r2802  
    11#ifndef MARS_MFGeomag
    22#define MARS_MFGeomag
    3 
    4 /////////////////////////////////////////////////////////////////////////////
    5 //                                                                         //
    6 // MFGeomag                                                                //
    7 //                                                                         //
    8 /////////////////////////////////////////////////////////////////////////////
    93
    104#ifndef MARS_MFilter
     
    1913private:
    2014    MMcEvt *fMcEvt;
    21     TString fContName;
    22 
    23     typedef enum { kEEqual, kENotEqual } FilterType_t;
    24     FilterType_t fFilterType;
    2515
    2616    Bool_t fResult;    //!
    27     Bool_t fGamm_elec;  // switches gammas to electrons
    28     //
     17    Bool_t fGammaElectron;  // switches gammas to electrons
     18
    2919    Float_t fRigMin[2*1152];    //tables to contain cut limits
    3020    Float_t fRigMax[2*1152];
    3121    Float_t fProb  [2*1152];
    32 
    33     void Init(const char type, const Int_t val,
    34               const char *name, const char *title);
    35 
    3622
    3723    Int_t PreProcess(MParList *pList);
     
    3925
    4026public:
    41     MFGeomag(const char *cname="MMcEvt", const char type='=', const Int_t val=0,
    42                  const char *name=NULL, const char *title=NULL);
     27    MFGeomag(const char *name=NULL, const char *title=NULL);
    4328
    4429    void  SetGammElec();    // allows to use gammas like electrons
    45     Bool_t IsExpressionTrue() const {return fResult;};
     30    Bool_t IsExpressionTrue() const { return fResult; }
    4631
    4732    ClassDef(MFGeomag,0) // Filter for MC particles, by geomagnetic field
Note: See TracChangeset for help on using the changeset viewer.