Changeset 8719


Ignore:
Timestamp:
08/28/07 13:03:04 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8711 r8719  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20 2007/08/28 Thomas Bretz
     21
     22   * mbase/MEnv.[h,cc]:
     23     - added handling an Include-resource. Note, that there is no
     24       check for recursions, they can crash your program.
     25
     26   * sponde.cc:
     27     - check for batch mode and no output file
     28     - changed title
     29     - moved HasWritePermission to MJSpectrum.cc
     30
     31   * mdata/MDataPhrase.cc:
     32     - fixed a bug which caused a variable (eg. [0]) at the beginning
     33       of a line not be detected correctly
     34
     35   * mhbase/MHn.cc:
     36     - added some comments
     37
     38   * mhflux/MHDisp.[h,cc]:
     39     - changed axis titles from x/y to dx/dy
     40     - changed cutting out a part of the cake into stamping a hole
     41       at the source position (currently with a fix PSF!)
     42     - for the moment display everything in Wobble-mode (to be fixed!)
     43
     44   * mhflux/MMcSpectrumWeight.cc:
     45     - some cosmetics to output
     46
     47   * mjobs/MJCut.cc:
     48     - check if output file is writeable (necessary in on/off mode
     49       to detect that incident before filling the source plot)
     50
     51   * mjobs/MJob.cc:
     52     - added a comment
     53     - fixed a bug in HasWritePermission (it must be fOverwrite not
     54       !fOverwrite)
     55
     56   * mjobs/MJSpectrum.cc:
     57     - replaced #cdot by a dot (it seems it is not supported anymore??)
     58     - set a proper display name
     59     - print an error message if writing the result failed
     60
     61   * mjtrain/MJTrainDisp.[h,cc]:
     62     - a further small step to unify all MJOptim classes
     63     - let the user change the theta-cut for the displayed efficiency
     64
     65   * macros/train/traindisp.C:
     66     - added comment about new SetThetaCut
     67
     68   * mjtrain/MJTrainEnergy.[h,cc]
     69     - a further small step to unify all MJOptim classes
     70     - removed obsolete columns for Impact and TelescopeTheta
     71       (MHEnergyEst doesn't read from the matrix here)
     72     - set palette
     73
     74   * mpointing/MSrcPosCalc.[h,cc]:
     75     - replaced CalcXYinCamera by MAstro::GetDistOnPlain. It has the
     76       same accuracy and is not remarkably slower
     77
     78   * mpointing/MSrcPosCorrect.[h,cc]:
     79     - changed comments
     80     - made sure that any possible anti-source position in the camera
     81       is handled correctly (maybe we should move it before
     82       MSrcPosCalc and skip the anti-source here???)
     83
     84
     85
     86
    2087 2007/08/27 Markus Meyer
    2188
    2289   * mmuon/MHMuonPar.cc:
    2390     - Reference lines changed
     91
     92
     93
     94 2007/08/27 Thomas Bretz
     95
     96   * resources/starguider00000001.txt, resources/starguider0085240.txt,
     97     resources/starguider00089180.txt:
     98     - added more starguider calibration files
     99
     100   * resources/starguider.txt:
     101     - removed obsolete old one
     102
     103
     104
     105 2007/08/26 Thomas Bretz
     106
     107   * mranforest/MRFEnergyEst.[h,cc]:
     108     - removed obsolete files
    24109
    25110
  • trunk/MagicSoft/Mars/mdata/MDataPhrase.cc

    r8717 r8719  
    321321        idx++;
    322322    }
    323 
     323    /*
     324
     325    // * HOW DO WE PROCESS THE FILTERS?
     326    // * DO WE NEED THIS FOR MData derived classes? Is there any need for it?
     327    // * MAYBE FIRST FILTERS (MF?) MUST REPLACE {name[class]} BEFORE
     328    //   THE DATA PHRASSE IS CREATED?
     329    // --> MFDataPhrase must have a list of MFilter. In Process first
     330    //     all self created MFilter are processed (see MF). Then
     331    //     they are evaluated and the result is given to the MDataPhrase.
     332    //     Can this be done using MDataMember? We replace {Name[class]}
     333    //     by Name.IsExpressionTrue and we need a way that MDataPhrase
     334    //     gets the coresponding pointer.
     335    // --> Alternatively we can create a MDataPhrase which allows
     336    //     Pre/Processing
     337    //
     338    // We convert {Name[Class]} to Name.IsExpressionTrue. To process these
     339    // data/filters we need a request from MFDataPhrase (new virtual
     340    // memeber function?)
     341    //
     342    // {} Is alreaqdy used in ReadEnv.
     343    //
     344    // Enhance ReadEnv to allow Cut1.5 to be just a class.
     345    //
     346    // The difference between MFDataPhrase is
     347    //   MFDataPhrase only knows MDataPhrase, while
     348    //   MF also knows a filter-class.
     349    //
     350
     351    p = 0;
     352
     353    // And now we check for other phrases or filters
     354    // They are defined by a [, a pribtable character and
     355    // any numer of word characters (a-zA-Z0-9_) and a closing ]
     356    reg = TPRegexp("{[A-Za-z}\\w+(\\[[A-Za-z]\\w+\\])?}");
     357    while (1)
     358    {
     359        // If some indices are already existing
     360        // initialize them by a MDataValue
     361        idx = CheckForVariable(phrase, idx);
     362
     363        // Check whether expression is found
     364        if (reg.Match(phrase, mods, p, 130, &pos)==0)
     365            break;
     366
     367        // Get expression from phrase
     368        TString expr = phrase(pos[0], pos[1]-pos[0]);
     369
     370        // Zerlegen: {Name[Class]}
     371
     372        // Create a new MData object of kind
     373        MData *dat = (MData*)GetNewObject(cls, MData::Class());
     374        if (!dat)
     375            return "";
     376        dat->SetName(name);
     377
     378        // Add a corresponding MDataMember to our list
     379        fMembers.AddLast(dat);
     380
     381        // Make the expression "Regular expression proofed"
     382        expr.ReplaceAll("[", "\\[");
     383        expr.ReplaceAll("]", "\\]");
     384
     385        // Find other occurances of arg by this regexp
     386        // and start next search behind first match
     387        p = pos[0] + Substitute(phrase, expr, idx);
     388
     389        // Step forward to the next argument
     390        idx++;
     391    }
     392 */
    324393    // Now we have to check if there are additional indices [idx]
    325394    // This is mainly important if the rule has indices only!
  • trunk/MagicSoft/Mars/mhbase/MHn.cc

    r8709 r8719  
    317317}
    318318
     319// --------------------------------------------------------------------------
     320//
     321// Set additional scale factors for the current histogram
     322//
    319323void MHn::SetScale(Double_t x, Double_t y, Double_t z) const
    320324{
     
    323327}
    324328
     329// --------------------------------------------------------------------------
     330//
     331// Enable or disable displaying log-scale for the current histogram.
     332// Normally it is retrieved from the corresponding MBinning
     333//
    325334void MHn::SetLog(Bool_t x, Bool_t y, Bool_t z) const
    326335{
     
    328337        fHist[fNum-1]->SetLog(x, y, z);
    329338}
     339
     340// --------------------------------------------------------------------------
     341//
     342// Set the axis range in Finalize automatically to the histogram region
     343// containing contents. This is the default for the x-axis.
     344// This function can be used to enable this behaviour also for the other
     345// axis, or disable it for the x-axis of the current histogram.
     346//
    330347void MHn::SetAutoRange(Bool_t x, Bool_t y, Bool_t z) const
    331348{
     
    334351}
    335352
     353// --------------------------------------------------------------------------
     354//
     355// Call Sumw2 for trhe current histogram, enabling errors.
     356//
    336357void MHn::Sumw2() const
    337358{
     
    340361}
    341362
     363// --------------------------------------------------------------------------
     364//
     365// Force the given binning(s) for the current histogram. The binnings
     366// do not get owned. The user is responsible for deleting them.
     367//
    342368void MHn::SetBinnings(MBinning *x, MBinning *y, MBinning *z) const
    343369{
  • trunk/MagicSoft/Mars/mhflux/MHDisp.cc

    r7616 r8719  
    7070//
    7171MHDisp::MHDisp(const char *name, const char *title)
    72     : fDisp(0), fDeviation(0), fSmearing(-1), fWobble(kFALSE),
     72    : fDisp(0), fDeviation(0), fSrcAnti(0), fSmearing(-1), fWobble(kFALSE),
    7373    fScaleMin(0.325), fScaleMax(0.475)
    7474{
     
    8181    fHist.SetName("Alpha");
    8282    fHist.SetTitle("3D-plot of ThetaSq vs x, y");
    83     fHist.SetXTitle("x [\\circ]");
    84     fHist.SetYTitle("y [\\circ]");
     83    fHist.SetXTitle("dx [\\circ]");
     84    fHist.SetYTitle("dy [\\circ]");
    8585    fHist.SetZTitle("Eq.cts");
    8686
     
    112112    }
    113113
     114    if (fWobble)
     115    {
     116        fSrcAnti = (MSrcPosCam*)plist->FindObject("MSrcPosAnti", "MSrcPosCam");
     117        if (!fSrcAnti)
     118        {
     119            *fLog << err << "MSrcPosAnti [MSrcPosCam] not found... abort." << endl;
     120            return kFALSE;
     121        }
     122
     123        *fLog << inf << "Wobble mode initialized. " << endl;
     124    }
     125
    114126    fDeviation = (MPointingDev*)plist->FindObject("MPointingDev");
    115127    if (!fDeviation)
     
    132144// --------------------------------------------------------------------------
    133145//
    134 // Calculate the delta angle between fSrcPos->GetXY() and v.
    135 // Return result in deg.
    136 //
    137 Double_t MHDisp::DeltaPhiSrc(const TVector2 &v) const
    138 {
    139     return TMath::Abs(fSrcPos->GetXY().DeltaPhi(v))*TMath::RadToDeg();
    140 }
    141 
    142 // --------------------------------------------------------------------------
    143 //
    144146// Fill the histogram. For details see the code or the class description
    145147//
     
    162164    TVector2 pos1 = hil->GetMean()*fMm2Deg + hil->GetNormAxis()*fDisp->GetVal();
    163165
     166    const TVector2 src = fSrcPos->GetXY()*fMm2Deg;
     167
    164168    Double_t w0 = 1;
    165169    if (fWobble)
    166170    {
    167         const Double_t delta = DeltaPhiSrc(pos1);
     171        const TVector2 anti = fSrcAnti->GetXY()*fMm2Deg;
    168172
    169173        // Skip off-data not in the same half than the source (here: anti-source)
     
    171175        if (!fHistOff)
    172176        {
    173             if (delta>180-25)
     177            Double_t r = anti.Mod()>0.2*1.7 ? 0.2*1.7 : anti.Mod();
     178
     179            // In wobble mode processing the off-data, the anti-source
     180            // position is our source position. Check if this is a possible
     181            // gamma. If it is, do not fill it into our off-data histogram
     182            if ((pos1-anti).Mod()<r)
    174183                return kTRUE;
    175184
     
    181190            // increased uncertainty
    182191            // FIXME: The delta stuff could be replaced by a 2*antitheta cut...
    183             w0 = delta>25 ? 1 : 2;
    184         }
     192            //w0 = delta>25 ? 1 : 2;
     193
     194            w0 = (pos1+anti).Mod()<r ? 2 : 1;
     195        }
     196
     197        // When processing off-data the anti-source is the real source
     198        const TVector2 srcpos = fHistOff ? src : anti;
    185199
    186200        // Define by the source position which histogram to fill
    187         if (DeltaPhiSrc(fFormerSrc)>90)
     201        if (TMath::Abs(srcpos.DeltaPhi(fFormerSrc))*TMath::RadToDeg()>90)
    188202            fHalf = !fHalf;
    189         fFormerSrc = fSrcPos->GetXY();
     203        fFormerSrc = srcpos;
    190204    }
    191205
     
    202216        {
    203217            // m: Position of the camera center in the FS plot
    204             m = fSrcPos->GetXY().Rotate(-rho)*fMm2Deg;
     218            m = src.Rotate(-rho);
    205219            pos1 -= m;
    206220        }
     
    410424    const TAxis &axey = *h2.GetYaxis();
    411425
    412     const Double_t rmax = (fWobble ? axex.GetXmax()-0.4 : axex.GetXmax()) - axex.GetBinWidth(1);
     426    const Double_t rmax = (fWobble ? axex.GetXmax()/*-0.7*/ : axex.GetXmax()) - axex.GetBinWidth(1);
    413427
    414428    for (int x=1; x<=axex.GetNbins(); x++)
  • trunk/MagicSoft/Mars/mhflux/MHDisp.h

    r7616 r8719  
    2525    MPointingDev *fDeviation; //!
    2626    //MSrcPosCam   *fAxis;      //!
     27    MSrcPosCam   *fSrcAnti; //!
     28
    2729
    2830    TH2D         fHistBg;
     
    4143    // MHDisp
    4244    Double_t GetOffSignal(TH1 &h) const;
    43     Double_t DeltaPhiSrc(const TVector2 &v) const;
    4445
    4546    void Update();
  • trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc

    r8709 r8719  
    493493    if (hasold)
    494494    {
    495         *fLog << " Old Spectrum:  " << GetFormulaSpecOldX();
     495        *fLog << " Old Spectrum:             " << GetFormulaSpecOldX();
    496496        if (fEnergyMin>=0 && fEnergyMax>0)
    497497            *fLog << "   (I=" << GetSpecOldIntegral() << ")";
     
    500500    if (hasnew)
    501501    {
    502         *fLog << " New Spectrum:  " << GetFormulaSpecNewX();
     502        *fLog << " New Spectrum:             " << GetFormulaSpecNewX();
    503503        if (fEnergyMin>=0 && fEnergyMax>0)
    504504            *fLog << "   (I=" << GetSpecNewIntegral() << ")";
     
    506506    }
    507507    if (fFunc)
    508         *fLog << " Weight func:  " << fFunc->GetTitle()   << endl;
     508        *fLog << " Weight func:              " << fFunc->GetTitle()   << endl;
    509509}
    510510
  • trunk/MagicSoft/Mars/mjobs/MJCut.cc

    r8709 r8719  
    550550        return kFALSE;
    551551    }
     552
     553    if (!HasWritePermission(GetOutputFile(set.GetNumAnalysis())))
     554        return kFALSE;
    552555
    553556    CheckEnv();
  • trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc

    r8709 r8719  
    10091009    spectrum.SetMarkerStyle(kFullDotMedium);
    10101010    spectrum.SetTitle("Differential flux times E^{2}");
    1011     spectrum.SetYTitle("E^{2}#cdot dN/dE [N#cdot TeV/sm^{2}]");
     1011    spectrum.SetYTitle("E^{2}·dN/dE [N·TeV/sm^{2}]");
    10121012    spectrum.SetDirectory(0);
    10131013    spectrum.DrawCopy();
     
    13161316    }
    13171317
     1318    if (!HasWritePermission(GetPathOut()))
     1319        return kFALSE;
     1320
    13181321    CheckEnv();
    13191322
     
    13241327    *fLog << "Compile Monte Carlo Sample (data set " << set.GetName() << ")" << endl;
    13251328    *fLog << endl;
     1329
     1330    if (fDisplay)
     1331        fDisplay->SetWindowName(fName);
    13261332
    13271333    // Setup everything which is read from the ganymed file
     
    16161622    tlist2.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime);
    16171623
    1618     MEvtLoop loop2("FillMonteCarlo"); // ***** fName *****
     1624    MEvtLoop loop2(fName); // ***** fName *****
    16191625    loop2.SetParList(&plist);
    16201626    loop2.SetDisplay(fDisplay);
     
    16851691        cont.Add(fDisplay);
    16861692
    1687     return WriteContainer(cont, "", "RECREATE");
    1688 }
     1693    if (!WriteContainer(cont, "", "RECREATE"))
     1694    {
     1695        *fLog << err << GetDescriptor() << ": Writing result failed." << endl;
     1696        return kFALSE;
     1697    }
     1698
     1699    *fLog << all << GetDescriptor() << ": Done." << endl;
     1700    *fLog << endl << endl;
     1701
     1702    return kTRUE;
     1703}
  • trunk/MagicSoft/Mars/mjobs/MJob.cc

    r8644 r8719  
    329329//
    330330// Checks whether write permissions to fname exists including
    331 // the fOverwrite data amember.
     331// the fOverwrite data member. Empty file names return kTRUE
    332332//
    333333Bool_t MJob::HasWritePermission(TString fname) const
     
    346346    }
    347347
    348     if (!fOverwrite)
     348    if (fOverwrite)
    349349        return kTRUE;
    350350
  • trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.cc

    r8704 r8719  
    4343//    opt.Train("rf-disp.root", set, 30000); // Number of train events
    4444//
     45//    // Two of the displayed histograms show the cut efficiency for
     46//    // a given Theta-Cut. The default is 0.215. It can be overwritten
     47//    // by
     48//    opt.SetThetaCut(0.165);
     49//
    4550//
    4651// Random Numbers:
     
    227232Bool_t MJTrainDisp::Train(const char *out, const MDataSet &set, Int_t num)
    228233{
    229     SetTitle(Form("TrainDisp: %s", out));
     234    SetTitle(Form("Train%s: %s", fNameOutput.Data(), out));
    230235
    231236    if (fDisplay)
     
    282287
    283288    // ------------------------ Train RF --------------------------
    284     MRanForestCalc rf("TrainDisp", fTitle);
     289    MRanForestCalc rf("Train", fTitle);
    285290    rf.SetNumTrees(fNumTrees);
    286291    rf.SetNdSize(fNdSize);
     
    292297    rf.SetFileName(out);
    293298    rf.SetDebug(fDebug>1);
    294     rf.SetNameOutput("Disp");
     299    rf.SetNameOutput(fNameOutput);
     300    rf.SetFunction(fResultFunction);
    295301
    296302    /*
     
    319325
    320326    MParameterD par("ThetaSquaredCut");
    321     par.SetVal(0.215*0.215);
     327    par.SetVal(fThetaCut*fThetaCut);
    322328    plist.AddToList(&par);
    323329
  • trunk/MagicSoft/Mars/mjtrain/MJTrainDisp.h

    r8656 r8719  
    1717
    1818    TString fTrainParameter;
     19    TString fResultFunction;
     20
     21    Float_t fThetaCut;
     22
     23    // To be moved to a base class
     24    TString fNameOutput;
    1925
    2026    void DisplayHist(TCanvas &c, Int_t i, MH3 &mh3) const;
     
    2228
    2329public:
    24     MJTrainDisp() : fTrainParameter(fgTrainParameter) { }
     30    MJTrainDisp() : fTrainParameter(fgTrainParameter), fResultFunction("x"), fThetaCut(0.215), fNameOutput("Disp") { }
    2531
    2632    void SetTrainParameter(const char *txt) { fTrainParameter=txt; }
     33
     34    void SetThetaCut(Float_t cut=0.215) { fThetaCut=cut; }
    2735
    2836    Bool_t Train(const char *out, const MDataSet &set, Int_t num);
  • trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.cc

    r8704 r8719  
    8989Bool_t MJTrainEnergy::Train(const char *out, const MDataSet &set, Int_t num)
    9090{
    91     SetTitle(Form("TrainEnergy: %s", out));
     91    SetTitle(Form("Train%s: %s", fNameOutput.Data(), out));
    9292
    9393    if (fDisplay)
     
    128128    if (fEnableWeights)
    129129        train.AddColumn("MWeight.fVal");
    130     train.AddColumn("MMcEvt.fImpact/100");
    131     train.AddColumn("MMcEvt.fTelescopeTheta*TMath::RadToDeg()");
    132130    train.AddColumn(fTrainParameter);
    133 
    134131
    135132    // ----------------------- Fill Matrix RF ----------------------
     
    147144
    148145    // ------------------------ Train RF --------------------------
    149     MRanForestCalc rf("TrainEnergy", fTitle);
     146    MRanForestCalc rf("Train", fTitle);
    150147    rf.SetNumTrees(fNumTrees);
    151148    rf.SetNdSize(fNdSize);
    152149    rf.SetNumTry(fNumTry);
    153     rf.SetNumObsoleteVariables(3);
     150    rf.SetNumObsoleteVariables(1);
    154151    rf.SetLastDataColumnHasWeights(fEnableWeights);
    155152    rf.SetDisplay(fDisplay);
     
    157154    rf.SetFileName(out);
    158155    rf.SetDebug(fDebug>1);
    159     rf.SetNameOutput("MEnergyEst");
     156    rf.SetNameOutput(fNameOutput);
    160157    rf.SetFunction(fResultFunction);
    161158
     
    175172
    176173    gLog.Separator("Test");
     174
     175    MH::SetPalette("pretty");
    177176
    178177    MParList  plist;
  • trunk/MagicSoft/Mars/mjtrain/MJTrainEnergy.h

    r8704 r8719  
    1414    TString fResultFunction;
    1515
     16    // To be moved to a base class
     17    TString fNameOutput;
     18
    1619public:
    17     MJTrainEnergy() { SetTrainLin(); }
     20    MJTrainEnergy() : fNameOutput("MEnergyEst") { SetTrainLin(); }
    1821
    1922    void SetTrainLog() { SetTrainFunc("log10(MMcEvt.fEnergy)", "pow(10, x)"); }
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc

    r8636 r8719  
    178178            *fLog << inf;
    179179            *fLog << "MSourcePos [MPointPos] not found... The source position" << endl;
    180             *fLog << "set in MSrcPosCam will be set to (0/0)  or in the case" << endl;
     180            *fLog << "set in MSrcPosCam will be set to  (0/0)  or in the case" << endl;
    181181            *fLog << "of  Monte Carlo set to the appropriate wobble position." << endl;
    182182            return kTRUE;
     
    331331
    332332    return kTRUE;
    333 }
    334 
    335 // --------------------------------------------------------------------------
    336 //
    337 // Loc0LocToCam
    338 //
    339 // Input :   (theta0, phi0)   direction for the position (0,0) in the camera 
    340 //           ( theta,  phi)   some other direction
    341 //
    342 // Output :  (X, Y)      position in the camera corresponding to (theta, phi)
    343 //
    344 TVector2 MSrcPosCalc::CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const
    345 {
    346     const Double_t theta0 = pos0.Theta();
    347     const Double_t phi0   = pos0.Phi();
    348 
    349     const Double_t theta  = pos.Theta();
    350     const Double_t phi    = pos.Phi();
    351 
    352     //--------------------------------------------
    353 
    354     /* --- OLD ---
    355      const Double_t YC0 = TMath::Cos(theta0)*TMath::Tan(theta)*TMath::Cos(phi-phi0) - TMath::Sin(theta0);
    356      const Double_t YC1 = TMath::Cos(theta0) + TMath::Sin(theta0)*TMath::Tan(theta);
    357      const Double_t YC  = YC0 / YC1;
    358 
    359      const Double_t XC0 =  TMath::Cos(theta0) - YC*TMath::Sin(theta0);
    360      const Double_t XC  = -TMath::Sin(phi-phi0) * TMath::Tan(theta) * XC0;
    361      */
    362 
    363     /* --- NEW ---  Same as MSrcPosCorrect::CalcXYinCamera */
    364     const Double_t XC0 = TMath::Sin(theta)*TMath::Sin(phi-phi0);
    365     const Double_t XC1 = TMath::Cos(theta0)*TMath::Cos(theta);
    366     const Double_t XC2 = TMath::Sin(theta0)*TMath::Sin(theta)*TMath::Cos(phi-phi0);
    367 
    368     const Double_t YC0 = TMath::Sin(theta0)*TMath::Cos(theta);
    369     const Double_t YC1 = TMath::Cos(theta0)*TMath::Sin(theta)*TMath::Cos(phi-phi0);
    370 
    371     const Double_t XC  =  - XC0     / (XC1 + XC2);
    372     const Double_t YC  = (-YC0+YC1) / (XC1 + XC2);
    373 
    374     //--------------------------------------------
    375     return TVector2(XC, YC);
    376333}
    377334
     
    428385
    429386    // Calculate source position in camera, and convert to mm:
    430     TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
     387    TVector2 v = MAstro::GetDistOnPlain(pos0, pos, -fGeom->GetCameraDist()*1000);
    431388
    432389    if (fDeviation)
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h

    r8636 r8719  
    5353    void     SetSrcPos(TVector2 v=TVector2()) const;
    5454    TVector2 Rotate(TVector2 v, Int_t pass, Int_t num) const;
    55     TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const;
    5655    TString  GetRaDec(const MPointingPos &pos) const;
    5756    Bool_t   GetCoordinate(TString str, Double_t &ret) const;
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc

    r7388 r8719  
    1818!   Author(s): Thomas Bretz 6/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2005
     20!   Copyright: MAGIC Software Development, 2000-2007
    2121!
    2222!
     
    2727// MSrcPosCorrect
    2828//
    29 // For more details see Process()
    30 //
    31 //////////////////////////////////////////////////////////////////////////////
    32 #include "MSrcPosCorrect.h"
    33 
    34 #include <TVector2.h>
    35 
    36 #include "MParList.h"
    37 
    38 #include "MLog.h"
    39 #include "MLogManip.h"
    40 
    41 #include "MGeomCam.h"
    42 #include "MSrcPosCam.h"
    43 #include "MRawRunHeader.h"
    44 #include "MReportStarguider.h"
    45 
    46 ClassImp(MSrcPosCorrect);
    47 
    48 using namespace std;
    49 
    50 // --------------------------------------------------------------------------
    51 //
    52 MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title)
    53     : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL)
    54      , fDx(-14.24) , fDy(-9.495)
    55 
    56 {
    57     fName  = name  ? name  : "MSrcPosCorrect";
    58     fTitle = title ? title : "Calculates the source position in the camera";
    59 }
    60 
    61 // --------------------------------------------------------------------------
    62 //
    63 // Search and if necessary create MSrcPosCam in the parameter list. Search
    64 // MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam
    65 // did not exist before and has been created here, it will contain as source
    66 // position the camera center (0,0).
    67 // In the case that MSourcePos is found, go ahead in searching the rest of
    68 // necessary containers. The source position will be calculated for each
    69 // event in Process.
    70 //
    71 Int_t MSrcPosCorrect::PreProcess(MParList *pList)
    72 {
    73     fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
    74     if (!fSrcPosCam)
    75     {
    76         *fLog << err << "MSrcPosCam not found... aborting." << endl;
    77         return kFALSE;
    78     }
    79 
    80     fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam");
    81 
    82     fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis");
    83     if (!fAxis)
    84         return kFALSE;
    85 
    86     return kTRUE;
    87 }
    88 
    89 // --------------------------------------------------------------------------
    90 //
    91 // Checking for file type. If the file type is Monte Carlo the
    92 // source position is arbitrarily determined from the MC headers.
    93 //
    94 Bool_t MSrcPosCorrect::ReInit(MParList *plist)
    95 {
    96     MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
    97     if (!run)
    98     {
    99         *fLog << err << "MRawRunHeader not found... aborting." << endl;
    100         return kFALSE;
    101     }
    102 
    103     fRunType   = run->GetRunType();
    104     fRunNumber = run->GetRunNumber();
    105 
    106     if (fRunNumber<56161 && fRunNumber>53832)
    107     {
    108         *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl;
    109         *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl;
    110     }
    111 
    112     return kTRUE;
    113 }
    114 
    115 // --------------------------------------------------------------------------
    116 //
    117 // Performs source position correction in the camera.
     29// Performs a misfocussing correction for source and anti-source position
     30// in the camera, i.e. it is assumed that the telscope is pointing well
     31// (all starguider and other corrections are already applied to the
     32// source positon) but the mirror is not focussing to the center of
     33// the camera.
     34//
    11835// Due to missfocussing a shift of
    11936//    dx=0.048deg and dy=0.034deg
     
    12138//    dx=14.24mm and dy=9.495mm
    12239// is added between run 53832 (excl) and 56161 (excl)
     40//
    12341//
    12442// See also: Runbook
     
    15371//   W-Comae
    15472//
     73//
     74// For more details see Process()
     75//
     76// Input:
     77//   MSrcPosCam
     78//   MSrcPosAnti [MSrcPosCam]
     79//
     80// Output:
     81//   OpticalAxis [MSrcPosCam]
     82//   MSrcPosCam
     83//   MSrcPosAnti [MSrcPosCam]
     84//
     85//////////////////////////////////////////////////////////////////////////////
     86#include "MSrcPosCorrect.h"
     87
     88#include <TVector2.h>
     89
     90#include "MParList.h"
     91
     92#include "MLog.h"
     93#include "MLogManip.h"
     94
     95#include "MGeomCam.h"
     96#include "MSrcPosCam.h"
     97#include "MRawRunHeader.h"
     98#include "MReportStarguider.h"
     99
     100ClassImp(MSrcPosCorrect);
     101
     102using namespace std;
     103
     104// --------------------------------------------------------------------------
     105//
     106MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title)
     107    : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL)
     108     , fDx(-14.24) , fDy(-9.495)
     109
     110{
     111    fName  = name  ? name  : "MSrcPosCorrect";
     112    fTitle = title ? title : "Calculates the source position in the camera";
     113}
     114
     115// --------------------------------------------------------------------------
     116//
     117// Search and if necessary create MSrcPosCam in the parameter list. Search
     118// MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam
     119// did not exist before and has been created here, it will contain as source
     120// position the camera center (0,0).
     121// In the case that MSourcePos is found, go ahead in searching the rest of
     122// necessary containers. The source position will be calculated for each
     123// event in Process.
     124//
     125Int_t MSrcPosCorrect::PreProcess(MParList *pList)
     126{
     127    fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
     128    if (!fSrcPosCam)
     129    {
     130        *fLog << err << "MSrcPosCam not found... aborting." << endl;
     131        return kFALSE;
     132    }
     133
     134    fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam");
     135
     136    fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis");
     137    if (!fAxis)
     138        return kFALSE;
     139
     140    return kTRUE;
     141}
     142
     143// --------------------------------------------------------------------------
     144//
     145// Checking for file type. If the file type is Monte Carlo the
     146// source position is arbitrarily determined from the MC headers.
     147//
     148Bool_t MSrcPosCorrect::ReInit(MParList *plist)
     149{
     150    MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
     151    if (!run)
     152    {
     153        *fLog << err << "MRawRunHeader not found... aborting." << endl;
     154        return kFALSE;
     155    }
     156
     157    fRunType   = run->GetRunType();
     158    fRunNumber = run->GetRunNumber();
     159
     160    if (fRunNumber<56161 && fRunNumber>53832)
     161    {
     162        *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl;
     163        *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl;
     164    }
     165
     166    return kTRUE;
     167}
     168
     169// --------------------------------------------------------------------------
     170//
     171// The offset fDx/fDy is subtracted from the source position. The anti-
     172// source position is shifted away from the camera-center and rotated
     173// around the camera center according to this correction, because it
     174// should always be symmetric w.r.t. the camera-center, but it is not
     175// necessary on the other side of the camera (e.g. three off-regions).
     176//
    155177Int_t MSrcPosCorrect::Process()
    156178{
     
    158180        return kTRUE;
    159181
    160     TVector2 d;
    161     if (fRunNumber<56161 && fRunNumber>53832)
    162     {
    163         // dx=-0.048deg, dy=0.034deg, d=0.059deg
    164         static const TVector2 dxy(fDx, fDy);
    165 
    166         d -= dxy;
    167     }
    168 
    169     fAxis->SetXY(d);
    170     fSrcPosCam->Add(d);
    171     if (fSrcPosAnti)
    172     {
    173         d *= -1; // Anti-Source position should always be symetric
    174         fSrcPosAnti->Add(d);
    175     }
     182    if (fRunNumber<=53832 || fRunNumber>=56161)
     183        return kTRUE;
     184
     185    // dx=-0.048deg, dy=0.034deg, d=0.059deg
     186    const TVector2 dxy(-fDx, -fDy);
     187
     188    const TVector2 s1(fSrcPosCam->GetXY());
     189    const TVector2 a1(fSrcPosAnti->GetXY());
     190    const TVector2 s2 = s1 + dxy;
     191
     192
     193    // Anti-Source position should always be symetric w.r.t. camera center
     194    TVector2 a2;
     195    a2.SetMagPhi(a1.Mod()+s2.Mod()-s1.Mod(), a1.Phi()+s2.DeltaPhi(s1));
     196
     197    fAxis->SetXY(dxy);
     198    fSrcPosCam->SetXY(s2);
     199    fSrcPosAnti->SetXY(s2);
    176200
    177201    return kTRUE;
    178202}
    179203
     204// --------------------------------------------------------------------------
     205//
     206// MSrcPosCorrect.Dx: -14.24
     207// MSrcPosCorrect.Dy: -9.495
     208//
     209// For a detailed description see the class reference.
     210//
    180211Int_t MSrcPosCorrect::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    181212{
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.h

    r7388 r8719  
    1414{
    1515private:
    16     MSrcPosCam *fSrcPosCam;   //!
    17     MSrcPosCam *fSrcPosAnti;  //!
    18     MSrcPosCam *fAxis;        //!
     16    MSrcPosCam *fSrcPosCam;   //! Source position
     17    MSrcPosCam *fSrcPosAnti;  //! Anti source position
     18    MSrcPosCam *fAxis;        //! New "center of camera"
    1919
    20     MGeomCam   *fGeom;        //!
     20    MGeomCam   *fGeom;        //! Camera geometry
    2121
    2222    UShort_t fRunType;        //! Run Type to decide where to get pointing position from
    23     UInt_t   fRunNumber;
     23    UInt_t   fRunNumber;      //! Current run number
    2424
    25     Float_t fDx;
    26     Float_t fDy;
     25    Float_t fDx;              // [mm] Correction in x
     26    Float_t fDy;              // [mm] Correction in y
    2727
    2828    // MTask
     
    3636    MSrcPosCorrect(const char *name=NULL, const char *title=NULL);
    3737
    38     ClassDef(MSrcPosCorrect, 0) // Corrects MSrcPOsCam for missfocussing
     38    ClassDef(MSrcPosCorrect, 0) // Corrects MSrcPosCam for missfocussing
    3939};
    4040
  • trunk/MagicSoft/Mars/sponde.cc

    r8709 r8719  
    144144    const TString kOutfile = arg.GetArgumentStr(2);
    145145
     146    if (kOutfile.IsNull() && kBatch)
     147    {
     148        gLog << err << "Writing no outputfile but running in batch mode is nonsense." << endl;
     149        return 2;
     150    }
     151
    146152    if (gSystem->AccessPathName(kInfile, kFileExists))
    147153    {
     
    211217    }
    212218
    213     MJSpectrum job(Form("MJSpectrum #%d", seq.GetNumAnalysis()));
     219    MJSpectrum job(Form("Spectrum - %s", seq.GetName()));
    214220    job.SetEnv(&env);
    215221    job.SetEnvDebug(kDebugEnv);
     
    221227    job.ForceTheta(kForceTheta);
    222228
    223     if (!job.HasWritePermission(kOutfile))
    224         return 2;
    225 
    226229    if (!job.Process(seq))
    227230    {
Note: See TracChangeset for help on using the changeset viewer.