Changeset 1891


Ignore:
Timestamp:
04/03/03 10:28:31 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1890 r1891  
    11                                                 -*-*- END OF LINE -*-*-
     2
     3 2003/04/02: Thomas Bretz
     4
     5   * mhist/MHMatrix.[h,cc]:
     6     - added ReadEnv
     7     
     8   * mfileio/MCT1ReadPreProc.[h,cc]:
     9     - base SmearTheta on new FindLoEndge
     10     - simplified
     11   
     12   * mhist/MBinning.h:
     13     - added FindBinLoEdge
     14     - added FindBinHiEdge
     15
     16   * mdata/MDataArray.[h,cc]:
     17     - added Clear
     18     - added Delete
     19
     20
    221
    322 2003/04/02: Abelardo Moralejo
     
    2645       separation)
    2746
     47
     48
    2849 2003/04/02: Wolfgang Wittek
    2950
     
    4667
    4768
     69
    4870 2003/04/01: Abelardo Moralejo
    4971
     
    5779
    5880
     81
    5982 2003/03/31: Thomas Bretz
     83
     84   * manalysis/MParameters.[h,cc]:
     85     - added
     86
     87   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
     88     - added MParameters, MParameterD, MParameterI
     89
     90   * mhist/MHArray.[h,cc]:
     91     - added default constructor
     92     - added Set-function
     93     - added Init function
     94     - moved code from constructors to Set and Init
    6095 
    6196   * Makefile.conf.linux:
  • trunk/MagicSoft/Mars/mdata/MDataArray.h

    r1574 r1891  
    4242    Int_t GetNumEntries() const { return fList.GetEntries(); }
    4343
     44    void Clear(Option_t *option="")  { fList.Clear(option); }
     45    void Delete(Option_t *option="") { fList.Delete(option); }
     46
    4447    ClassDef(MDataArray, 1) // An array of MData containers
    4548};
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc

    r1888 r1891  
    784784        return kFALSE;
    785785
     786    fBinningT = (MBinning*)pList->FindObject("BinningTheta");
     787    if (!fBinningT)
     788    {
     789        *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl;
     790        return kFALSE;
     791    }
     792
    786793    fNumFilterEvts = 0;
    787794    fNumEvents     = 0;
     
    796803// --------------------------------------------------------------------------
    797804//
    798 // Smear Theta uniformly in a bin of Theta; result is stored in ThetaSmeared
    799 //
    800 //
    801 Bool_t MCT1ReadPreProc::SmearTheta(MParList *plist, Float_t *Theta,
    802                              Float_t *ThetaSmeared)
    803 {
    804   // both Theta and ThetaSmeared are in [radians]
    805   // the edges are in [degrees]
    806 
    807   const MBinning *binstheta = (MBinning*)plist->FindObject("BinningTheta");
    808   if (!binstheta)
    809   {
    810     *fLog << err << dbginf << "BinningTheta not found ... aborting." << endl;
    811     return kFALSE;
    812   }
    813 
    814   Int_t nedges = binstheta->GetNumEdges();
    815   Double_t *edges  = (Double_t*)binstheta->GetEdges();
    816 
    817   Int_t bin = -1;
    818   *ThetaSmeared = *Theta;
    819 
    820   Float_t Thetadeg = (*Theta) * 180.0/TMath::Pi();
    821   Float_t ThetaSmeareddeg;
    822  
    823   // search Theta bin
    824   Int_t i;
    825   for (i=1; i<nedges; i++)
    826   {
    827     if (Thetadeg >= *(edges+i)  ) continue;
    828     if (Thetadeg  < *(edges+i-1)) break;
    829     bin = i;
    830     break;
    831   }
    832 
    833   Float_t low=0.0;
    834   Float_t up =0.0;
    835 
    836   // smear Theta within the Theta bin
    837   ThetaSmeareddeg = -1.0;
    838   if (bin != -1)
    839   {
    840     low = *(edges+bin-1);
    841     up  = *(edges+bin);
    842 
    843     Double_t ran = ran3.Rndm(1);
    844     ThetaSmeareddeg = (low + ran * (up-low));
    845   }
    846   *ThetaSmeared = ThetaSmeareddeg * TMath::Pi()/180.0;
    847 
    848   //*fLog << "SmearTheta : Thetadeg, ThetaSmeareddeg, low, up, bin = "
    849   //      << Thetadeg
    850   //      << ",  " << ThetaSmeareddeg << ",  " << low << ",  " << up << ",  "
    851   //      << bin << endl;   
    852 
    853   return kTRUE;
     805// Smear Theta uniformly in a bin of Theta
     806//
     807Float_t MCT1ReadPreProc::SmearTheta(Float_t theta)
     808{
     809    // both Theta and ThetaSmeared are in [radians]
     810    // the edges are in [degrees]
     811    const Int_t bin = fBinningT->FindLoEdge(theta * 180.0/TMath::Pi());
     812    if (bin == -1)
     813        return theta;
     814
     815    // smear Theta within the Theta bin
     816    const Double_t low = fBinningT->GetEdges()[bin];
     817    const Double_t up  = fBinningT->GetEdges()[bin+1];
     818
     819    return (low + gRandom->Rndm(1) * (up-low)) * TMath::Pi()/180;
    854820}
    855821
     
    942908
    943909    // smear Theta in its Theta bin
    944     Float_t ThetaOrig =  TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600); // [radians]
    945     Float_t ThetaSmeared;                                               // [radians]
    946     SmearTheta(fParList, &ThetaOrig, &ThetaSmeared);
    947     fThetaOrig->SetVal(ThetaOrig);
     910    Float_t theta = TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600);
     911    fThetaOrig->SetVal(theta);
    948912
    949913    // store hour angle
    950914    fHourAngle->SetVal(event.fhourangle);
    951 
    952     //*fLog << "MCt1ReadPreProc::ProcessEvent; fhourangle = "
    953     //      << event.fhourangle << endl;
    954915
    955916    fMcEvt->Fill(event.isecs_since_midday,     //0, /*fEvtNum*/
     
    969930                 fIsMcFile ? event.imcimpact_m*100 : 0,
    970931                 TMath::Pi()/180*event.iaz_arcs/3600, // azimuth (arcseconds)
    971                  ThetaSmeared,
    972                 0, /* fTFirst */
     932                 SmearTheta(theta),
     933                0, /* fTFirst */
    973934                 0, /* fTLast */
    974935                 0, /* fL_Nmax */
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h

    r1888 r1891  
    99#include "MRead.h"
    1010#endif
    11 
    12 #include <TRandom3.h>
    1311
    1412class TList;
     
    2523class MParList;
    2624class MParameterD;
     25class MBinning;
    2726
    2827struct outputpars;
     
    4746    MParameterD   *fHourAngle;    // hour angle [deg]
    4847    MParameterD   *fThetaOrig;    // original zenith angle [rad]
     48    MBinning      *fBinningT;     // Theta binning for the smearing
    4949
    5050    Bool_t fIsMcFile;       // Flag whether current run is a MC run
     
    5757
    5858    TArrayF fPedRMS;
    59 
    60     TRandom3 ran3;
    6159
    6260    Bool_t OpenNextFile();
     
    7169    void   ProcessRunHeader(const struct outputpars &outpars);
    7270    void   ProcessEvent(const struct eventrecord &event);
     71
     72    Float_t SmearTheta(Float_t theta);
    7373
    7474    Bool_t PreProcess(MParList *pList);
     
    8787    UInt_t GetEntries() { return fEntries; }
    8888
    89     Bool_t SmearTheta(MParList *plist, Float_t *theta, Float_t *thetasmeared);
    90 
    9189    ClassDef(MCT1ReadPreProc, 0) // Reads the CT1 preproc data file
    9290};
  • trunk/MagicSoft/Mars/mhist/MBinning.h

    r1668 r1891  
    4242    void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up);
    4343
     44    Int_t FindLoEdge(Double_t val) const
     45    {
     46        for (int i=0; i<fEdges.GetSize(); i++)
     47        {
     48            if (val >= ((TArrayD)fEdges)[i])
     49                return i;
     50        }
     51        return -1;
     52    }
     53    Int_t FindHiEdge(Double_t val) const
     54    {
     55        for (int i=0; i<fEdges.GetSize(); i++)
     56        {
     57            if (val < ((TArrayD)fEdges)[i])
     58                return i;
     59        }
     60        return -1;
     61    }
     62
    4463    // FIXME: ROOT workaround: "operator[] const" missing
    4564    Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
  • trunk/MagicSoft/Mars/mhist/MHMatrix.cc

    r1887 r1891  
    10021002
    10031003// --------------------------------------------------------------------------
     1004//
     1005// Read the setup from a TEnv:
     1006//   Column0, Column1, Column2, ..., Column10, ..., Column100, ...
     1007//
     1008// Searching stops if the first key isn't found in the TEnv. Empty
     1009// columns are not allowed
     1010//
     1011// eg.
     1012//     MHMatrix.Column0: cos(MMcEvt.fTelescopeTheta)
     1013//     MHMatrix.Column1: MHillasSrc.fAlpha
     1014//
     1015Bool_t MHMatrix::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     1016{
     1017    if (fM.IsValid())
     1018    {
     1019        *fLog << err << "ERROR - matrix is already in use. Can't add a new column from TEnv... skipped." << endl;
     1020        return kERROR;
     1021    }
     1022
     1023    if (TestBit(kIsLocked))
     1024    {
     1025        *fLog << err << "ERROR - matrix is locked. Can't add new column from TEnv... skipped." << endl;
     1026        return kERROR;
     1027    }
     1028
     1029    if (fData)
     1030    {
     1031        *fLog << inf << "Removing all existing columns in " << GetDescriptor() << endl;
     1032        fData->Delete();
     1033    }
     1034    else
     1035    {
     1036        fData = new MDataArray;
     1037        SetBit(kIsOwner);
     1038    }
     1039
     1040    //
     1041    // Search (beginning with 0) all keys
     1042    //
     1043    for (int i=0;; i++)
     1044    {
     1045        TString idx = "Column";
     1046        idx += i;
     1047
     1048        // Output if print set to kTRUE
     1049        IsEnvDefined(env, prefix, idx, print);
     1050
     1051        // Try to get the file name
     1052        TString name = GetEnvValue(env, prefix, idx, "");
     1053        if (name.IsNull())
     1054            return kTRUE;
     1055
     1056        /*
     1057        if (name.BeginsWith("\"") && name.EndsWith("\""))
     1058        {
     1059            name.Remove(name.Last('\"'), 1);
     1060            name.Remove(name.First('\"'), 1);
     1061        }
     1062        */
     1063
     1064        if (print)
     1065            *fLog << all << "Add Column: " << name << endl;
     1066        fData->AddEntry(name);
     1067    }
     1068
     1069    return kTRUE;
     1070}
  • trunk/MagicSoft/Mars/mhist/MHMatrix.h

    r1879 r1891  
    110110    Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
    111111
     112    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     113
    112114    ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
    113115};
Note: See TracChangeset for help on using the changeset viewer.