Changeset 8680 for trunk/MagicSoft


Ignore:
Timestamp:
08/20/07 11:04:58 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/.rootrc

    r8037 r8680  
    4545Root.Html.SearchEngine:      http://magic.astro.uni-wuerzburg.de/mars/search.html
    4646Root.Html.ViewCVS:           http://www.astro.uni-wuerzburg.de/cgi-bin/viewcvs.cgi/
     47
     48#############################################################################
     49#                                                                           #
     50# Some default changes                                                      #
     51#                                                                           #
     52#############################################################################
     53
     54#Canvas.HighLightColor:  3
     55#Canvas.MoveOpaque:      0
     56#Canvas.ResizeOpaque:    0
     57Canvas.ShowEventStatus: Yes
     58#Canvas.ShowToolBar:     Yes
     59#Canvas.ShowEditor:      Yes
     60#Canvas.AutoExec:        No
  • trunk/MagicSoft/Mars/Changelog

    r8679 r8680  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2007/08/20 Thomas Bretz
     22
     23   * .rootrc:
     24     - added some comments about defaults
     25     - set the ShowEventStatus for the canvases to yes as default
     26
     27   * sponde.cc:
     28     - removed the refill option (it was just a dummy)
     29     - removed the accurate option. It didn't give more accurate
     30       results at all
     31
     32   * mbase/MStatusDisplay.[h,cc]:
     33     - added an update option to SetProgressBarPosition
     34
     35   * mhflux/MMcSpectrumWeight.[h,cc]:
     36     - allow to give a container name to GetFormula*
     37     - changed default for spectral slope from -9 to -99
     38     - allow to give integral range to GetSpec*Integral
     39     - added a new member function CompeleteEnergySpectrum which completes
     40       a simulated spectrum starting at an energy fEnergyMin down to
     41       an energy emin.
     42     - added two options ("new" and "old") to Print function
     43     - do not stop anymore if lower energy boundary changes
     44
     45   * mjobs/MJSpectrum.[h,cc]:
     46     - cleaned the code in general
     47     - removed fRefill (was not used in the code at all)
     48     - added MJSpectrum to global ListOfCleanups to handle
     49       the display more properly
     50     - removed reading of the first (it was the second!)
     51       MMcCorsikaRunHeader. It is now read for each file individually
     52     - The read monte carlo events are now weighted with the mc
     53       production area (events per area)
     54     - incomplete (to lower energies) spectra are completed
     55     - removed accurate mode, it was not more accurate
     56     - we fit the spectrum now from the first to the last bin
     57     - for comparison crab and 1553 are plotted
     58     - changed the processing such that first the MCs are processed
     59       and then the spectrum is refilled
     60     - now the MC distribution from OriginalMC is read only once
     61     - added new tab showing the basic event distribution
     62
     63
    2064
    2165 2007/08/19 Thomas Bretz
  • trunk/MagicSoft/Mars/NEWS

    r8679 r8680  
    223223     give any improvement in accuracy, only decreased execution speed.
    224224
     225   - sponde: the so called "simple"-mode has been removed. It didn't
     226     give any improvement in simple.
     227
     228   - sponde: the so called "refill"-mode has been removed. It was anyhow
     229     not implemented.
     230
    225231   - sponde: now checks whether the theta distribution of your on-data
    226232     and the theta-distribution of your Monte Carlo sample (after
     
    236242     different maximum impact parameters.
    237243
     244   - sponde: If MC files with different lower energy limits are used
     245     the primary MC spectrum is artificially completed down to the
     246     lowest energy used at all. WARNING: that this gives correct
     247     collection areas ONLY if none of the events in this region would
     248     survive your cuts at all.
     249
    238250   - sponde: the output file now contains more information about
    239251     the spectrum (eg. the full 2D collection area histogram).
     
    248260     The same information you get from the error bars of the weighted
    249261     histograms, but this is less intuitive.
     262
     263   - sponde: The spectrum plots now show the crab- and 1553-spectrum
     264     for comparison. It is not meant to show these curves in
     265     publications, they are only for production.
     266
     267   - sponde: The OriginalMC tree with the events produced by corsika
     268     is now processed only once
    250269
    251270
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r8678 r8680  
    602602// is assumed to be (0,1)
    603603//
    604 void MStatusDisplay::SetProgressBarPosition(Float_t p)
     604void MStatusDisplay::SetProgressBarPosition(Float_t p, Bool_t upd)
    605605{
    606606    fBar->SetPosition(p);
     607    if (upd)
     608        gClient->ProcessEventsFor(fBar);
    607609}
    608610
     
    685687    // p==NULL means: Take gClient->GetRoot() if not in batch mode
    686688    // see TGWindow::TGWindow()
     689
     690    // Make sure that the display is removed via RecursiveRemove
     691    // from whereever possible.
     692    SetBit(kMustCleanup);
    687693
    688694    //
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r8642 r8680  
    168168     void SetUpdateTime(Long_t t);
    169169
    170      void SetProgressBarPosition(Float_t p);
     170     void SetProgressBarPosition(Float_t p, Bool_t upd=kFALSE);
    171171     TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
    172172
  • trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc

    r8674 r8680  
    1919!   Author(s): Marcos Lopez 10/2003 <mailto:marcos@gae.ucm.es>
    2020!
    21 !   Copyright: MAGIC Software Development, 2000-2006
     21!   Copyright: MAGIC Software Development, 2000-2007
    2222!
    2323!
     
    4040//  Method:
    4141//  -------
    42 //                                 
     42//
    4343//   - Corsika spectrun: dN/dE = A * E^(a)
    4444//     with a = fOldSlope, and A = N/integral{E*de} from ELowLim to EUppLim
     
    7272//    MMcEvt
    7373//    MMcCorsikaRunHeader
     74//    [MPointingPos]
     75//    [MHillas]
    7476//
    7577//  Output Container:
     
    8183#include <TF1.h>
    8284#include <TH1.h>
     85#include <TH2.h>
     86#include <TH3.h>
    8387#include <TSpline.h>
    8488
     
    109113    fNameMcEvt   = "MMcEvt";
    110114
    111     fNewSlope    = -9;
    112     fOldSlope    = -9;
     115    fNewSlope    = -99;
     116    fOldSlope    = -99;
    113117
    114118    fEnergyMin   = -1;
     
    210214// The slope is returned as %.3f
    211215//
    212 TString MMcSpectrumWeight::GetFormulaSpecOld() const
    213 {
    214     return Form("pow(%s.fEnergy, %.3f)", fNameMcEvt.Data(), fOldSlope);
     216TString MMcSpectrumWeight::GetFormulaSpecOld(const char *name) const
     217{
     218    return Form("pow(%s.fEnergy, %.3f)", name, fOldSlope);
    215219}
    216220
     
    225229// unchanged.
    226230//
    227 TString MMcSpectrumWeight::GetFormulaSpecNew() const
    228 {
    229     TString str = fFormula.IsNull() ? Form("pow(%s.fEnergy, %.3f)", fNameMcEvt.Data(), fNewSlope) : fFormula.Data();
     231TString MMcSpectrumWeight::GetFormulaSpecNew(const char *name) const
     232{
     233    TString str = fFormula.IsNull() ? Form("pow(%s.fEnergy, %.3f)", name, fNewSlope) : fFormula.Data();
    230234    if (!fFormula.IsNull())
    231         str.ReplaceAll("X", Form("(%s.fEnergy)", fNameMcEvt.Data()));
     235        str.ReplaceAll("X", Form("(%s.fEnergy)", name));
    232236
    233237    return str;
     
    258262// Example: 0.3712780019*(pow(MMcEvt.fEnergy,-2.270))/(pow(MMcEvt.fEnergy,-2.600))
    259263//
    260 TString MMcSpectrumWeight::GetFormulaWeights() const
     264TString MMcSpectrumWeight::GetFormulaWeights(const char *name) const
    261265{
    262266    if (GetFormulaSpecOld()==GetFormulaSpecNew())
     
    268272    const Double_t norm = fNorm*iold/inew;
    269273
    270     return Form("%.16e*(%s)/(%s)", norm, GetFormulaSpecNew().Data(), GetFormulaSpecOld().Data());
     274    return Form("%.16e*(%s)/(%s)", norm, GetFormulaSpecNew(name).Data(), GetFormulaSpecOld(name).Data());
    271275}
    272276
     
    276280// GetFormulaSpecNewX() describing the destination spectrum
    277281//
    278 Double_t MMcSpectrumWeight::GetSpecNewIntegral() const
     282Double_t MMcSpectrumWeight::GetSpecNewIntegral(Double_t emin, Double_t emax) const
    279283{
    280284    TF1 funcnew("Dummy", GetFormulaSpecNewX());
    281     return funcnew.Integral(fEnergyMin, fEnergyMax);
     285    return funcnew.Integral(emin, emax);
    282286}
    283287
     
    287291// GetFormulaSpecOldX() describing the simulated spectrum
    288292//
    289 Double_t MMcSpectrumWeight::GetSpecOldIntegral() const
     293Double_t MMcSpectrumWeight::GetSpecOldIntegral(Double_t emin, Double_t emax) const
    290294{
    291295    TF1 funcold("Dummy", GetFormulaSpecOldX());
    292     return funcold.Integral(fEnergyMin, fEnergyMax);
     296    return funcold.Integral(emin, emax);
    293297}
    294298
     
    357361    if (fEnergyMax>fEnergyMin && !fAllowChange)
    358362    {
     363        if (TMath::Abs(fEnergyMax-rh.GetEUppLim())>1e-10)
     364        {
     365            *fLog << err;
     366            *fLog << "ERROR - The maximum simulated Monte Carlo energy is not allowed to change (";
     367            *fLog << "(" << fEnergyMax << " --> " << rh.GetEUppLim() << ")... abort." << endl;
     368            return kFALSE;
     369        }
     370
    359371        if (TMath::Abs(fOldSlope-rh.GetSlopeSpec())>1e-10)
    360372        {
     
    364376            return kFALSE;
    365377        }
    366         if (TMath::Abs(fEnergyMin-rh.GetELowLim())>1e-10)
    367         {
    368             *fLog << err;
    369             *fLog << "ERROR - The minimum simulated Monte Carlo energy is not allowed to change ";
    370             *fLog << "(" << fEnergyMin << " --> " << rh.GetELowLim() << ")... abort." << endl;
    371             return kFALSE;
    372         }
    373         if (TMath::Abs(fEnergyMax-rh.GetEUppLim())>1e-10)
    374         {
    375             *fLog << err;
    376             *fLog << "ERROR - The maximum simulated Monte Carlo energy is not allowed to change (";
    377             *fLog << "(" << fEnergyMax << " --> " << rh.GetEUppLim() << ")... abort." << endl;
    378             return kFALSE;
    379         }
    380         return kTRUE;
     378
     379        // No change happened
     380        if (TMath::Abs(fEnergyMin-rh.GetELowLim())<=1e-10)
     381            return kTRUE;
     382
     383        // The lower energy limit has changed
     384        *fLog << warn;
     385        *fLog << "The minimum simulated Monte Carlo energy has changed from ";
     386        *fLog << fEnergyMin << "GeV to " << rh.GetELowLim() << "GeV." << endl;
     387        fEnergyMin = rh.GetELowLim();
    381388    }
    382389
     
    385392    fEnergyMax = rh.GetEUppLim();
    386393
    387     if (fNewSlope==-9)
    388     {
    389         *fLog << inf << "The new slope of the power law is undefined (-9)... no weighting applied." << endl;
     394    if (fNewSlope==-99)
     395    {
     396        *fLog << inf << "A new slope for the power law has not been defined... no weighting applied." << endl;
    390397        fNewSlope = fOldSlope;
    391398    }
     
    403410// ---------------------------------------------------------------------------
    404411//
     412// completes a simulated spectrum starting at an energy fEnergyMin down to
     413// an energy emin.
     414//
     415// It is assumed that the contents of MMcSpectrumWeight for the new spectrum
     416// correctly describe the spectrum within the histogram, and fEnergyMin
     417// and fEnergyMax correctly describe the range.
     418//
     419// In the 1D case it is assumed that the x-axis is a zenith angle binning.
     420// In the 2D case the x-axis is assumed to be zenith angle, the y-axis
     421// to be energy.
     422//
     423void MMcSpectrumWeight::CompleteEnergySpectrum(TH1 &h, Double_t emin) const
     424{
     425    if (h.InheritsFrom(TH3::Class()))
     426    {
     427        *fLog << "ERROR - MMcSpctrumWeight::CompleteEnergySpectrum doesn't support TH3." << endl;
     428        return;
     429    }
     430
     431    if (fEnergyMin <= emin)
     432        return;
     433
     434    const Double_t norm = GetSpecNewIntegral();
     435
     436    if (!h.InheritsFrom(TH2::Class()))
     437    {
     438        h.Scale(GetSpecNewIntegral(emin, fEnergyMax)/norm);
     439        return;
     440    }
     441
     442    const TAxis &axey = *h.GetYaxis();
     443
     444    const Int_t first = axey.FindFixBin(emin);
     445    const Int_t last  = axey.FindFixBin(fEnergyMin);
     446
     447    for (int x=1; x<=h.GetNbinsX(); x++)
     448    {
     449         const Double_t f = h.Integral(x, x, -1, 9999)/norm;
     450
     451        for (int y=first; y<=last; y++)
     452        {
     453            const Double_t lo = axey.GetBinLowEdge(y)  <emin       ? emin       : axey.GetBinLowEdge(y);
     454            const Double_t hi = axey.GetBinLowEdge(y+1)>fEnergyMin ? fEnergyMin : axey.GetBinLowEdge(y+1);
     455
     456            h.AddBinContent(h.GetBin(x, y), f*GetSpecNewIntegral(lo, hi));
     457        }
     458    }
     459}
     460
     461// ---------------------------------------------------------------------------
     462//
    405463// The current contants are printed
    406464//
    407465void MMcSpectrumWeight::Print(Option_t *o) const
    408466{
     467    const TString opt(o);
     468
     469    const Bool_t hasnew = opt.Contains("new") || opt.IsNull();
     470    const Bool_t hasold = opt.Contains("old") || opt.IsNull();
     471
    409472    *fLog << all << GetDescriptor() << endl;
    410     *fLog << " Simulated energy range:   " << fEnergyMin << "GeV - " << fEnergyMax << "GeV" << endl;
    411     *fLog << " Simulated spectral slope: " << fOldSlope << endl;
    412     *fLog << " New spectral slope:       " << fNewSlope << endl;
     473
     474    if (hasold)
     475    {
     476        *fLog << " Simulated energy range:   " << fEnergyMin << "GeV - " << fEnergyMax << "GeV" << endl;
     477        *fLog << " Simulated spectral slope: ";
     478        if (fOldSlope==-99)
     479            *fLog << "undefined" << endl;
     480        else
     481            *fLog << fOldSlope << endl;
     482    }
     483    if (hasnew)
     484    {
     485        *fLog << " New spectral slope:       ";
     486        if (fNewSlope==-99)
     487            *fLog << "undefined" << endl;
     488        else
     489            *fLog << fNewSlope << endl;
     490    }
    413491    *fLog << " Additional user norm.:    " << fNorm << endl;
    414492    *fLog << " Spectra are normalized:   " << (fNormEnergy<0?"by integral":Form("at %.1fGeV", fNormEnergy)) << endl;
    415     *fLog << " Old Spectrum:     " << GetFormulaSpecOldX() << "   (I=" << GetSpecOldIntegral() << ")" << endl;
    416     *fLog << " New Spectrum:     " << GetFormulaSpecNewX() << "   (I=" << GetSpecNewIntegral() << ")" << endl;
     493    if (hasold)
     494    {
     495        *fLog << " Old Spectrum: " << GetFormulaSpecOldX();
     496        if (fEnergyMin>=0 && fEnergyMax>0)
     497            *fLog << "   (I=" << GetSpecOldIntegral() << ")";
     498        *fLog << endl;
     499    }
     500    if (hasnew)
     501    {
     502        *fLog << " New Spectrum: " << GetFormulaSpecNewX();
     503        if (fEnergyMin>=0 && fEnergyMax>0)
     504            *fLog << "   (I=" << GetSpecNewIntegral() << ")";
     505        *fLog << endl;
     506    }
    417507    if (fFunc)
    418         *fLog << " Weight function:  " << fFunc->GetTitle()   << endl;
     508        *fLog << " Weight func:  " << fFunc->GetTitle()   << endl;
    419509}
    420510
     
    436526}
    437527
     528/*
     529 * This could be used to improve the Zd-weighting within a bin.
     530 * Another option is to use more bins, or both.
     531 * Note that it seems unnecessary, because the shape within the
     532 * theta-bins should be similar in data and Monte Carlo... hopefully.
     533 *
     534void MMcSpectrumWeight::InitZdWeights()
     535{
     536    TH2D w(*fWeightsZd);
     537
     538    for (int i=1; i<=w.GetNbinsX(); i++)
     539    {
     540         const Double_t tmin = w.GetBinLowEdge(i)  *TMath::DegToRad();
     541         const Double_t tmax = w.GetBinLowEdge(i+1)*TMath::DegToRad();
     542
     543         const Double_t wdth  = tmax-tmin;
     544         const Double_t integ = cos(tmin)-cos(tmax);
     545
     546         w.SetBinContent(i, w.GetBinContent(i)*wdth/integ);
     547    }
     548
     549    //  const Int_t i = fWeightsZd->GetXaxis()->FindFixBin(fPointing->GetZd());
     550    //  const Double_t theta = fPointing->GetZd()*TMath::DegToRad();
     551    //  w = sin(theta)*w.GetBinContent(i);
     552}
     553*/
     554
    438555// ----------------------------------------------------------------------------
    439556//
     
    447564    if (fWeightsZd)
    448565    {
    449         /*
    450          const Int_t i = fWeightsZd->GetXaxis()->FindFixBin(fPointing->GetZd());
    451 
    452          Double_t tmin = fWeightsZd->GetXaxis()->GetBinLowEdge(i)  *TMath::DegToRad();
    453          Double_t tmax = fWeightsZd->GetXaxis()->GetBinLowEdge(i+1)*TMath::DegToRad();
    454          Double_t wdth = fWeightsZd->GetXaxis()->GetBinWidth(i)    *TMath::DegToRad();
    455 
    456          Double_t cont = fWeightsZd->GetBinContent(i);
    457 
    458          Double_t integ = cos(tmin)-cos(tmax);
    459 
    460          w = sin(tmax)*cont/integ*wdth;
    461          */
    462 
    463566        const Int_t i = fWeightsZd->GetXaxis()->FindFixBin(fPointing->GetZd());
    464567        w = fWeightsZd->GetBinContent(i);
     
    472575
    473576    const Double_t e = fMcEvt->GetEnergy();
     577
    474578    fWeight->SetVal(fFunc->Eval(e)*w);
    475579
  • trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.h

    r7688 r8680  
    7777
    7878    // Getter
    79     TString GetFormulaSpecOld() const;
    80     TString GetFormulaSpecNew() const;
    81     TString GetFormulaWeights() const;
     79    TString GetFormulaSpecOld(const char *name) const;
     80    TString GetFormulaSpecNew(const char *name) const;
     81    TString GetFormulaWeights(const char *name) const;
     82    TString GetFormulaSpecOld() const { return GetFormulaSpecOld(fNameMcEvt); }
     83    TString GetFormulaSpecNew() const { return GetFormulaSpecNew(fNameMcEvt); }
     84    TString GetFormulaWeights() const { return GetFormulaWeights(fNameMcEvt); }
    8285
    8386    TString GetFormulaSpecOldX() const { return ReplaceX(GetFormulaSpecOld()); }
     
    8588    TString GetFormulaWeightsX() const { return ReplaceX(GetFormulaWeights()); }
    8689
    87     Double_t GetSpecNewIntegral() const;
    88     Double_t GetSpecOldIntegral() const;
     90    Double_t GetSpecNewIntegral(Double_t emin, Double_t emax) const;
     91    Double_t GetSpecOldIntegral(Double_t emin, Double_t emax) const;
     92
     93    Double_t GetSpecNewIntegral() const { return GetSpecNewIntegral(fEnergyMin, fEnergyMax); }
     94    Double_t GetSpecOldIntegral() const { return GetSpecOldIntegral(fEnergyMin, fEnergyMax); }
    8995
    9096    Double_t CalcSpecNew(Double_t e) const;
     
    9399    Double_t GetEnergyMin() const { return fEnergyMin; }
    94100    Double_t GetEnergyMax() const { return fEnergyMax; }
     101
     102    // Functions
     103    void CompleteEnergySpectrum(TH1 &h, Double_t emin) const;
    95104
    96105    // TObject
  • trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc

    r8676 r8680  
    1818!   Author(s): Thomas Bretz, 4/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2005
     20!   Copyright: MAGIC Software Development, 2000-2007
    2121!
    2222!
     
    6262#include "../mhflux/MHAlpha.h"
    6363#include "../mhflux/MHCollectionArea.h"
    64 //#include "../mhflux/MHThreshold.h"
    6564#include "../mhflux/MHEnergyEst.h"
    6665#include "../mhflux/MMcSpectrumWeight.h"
     
    8079#include "MFillH.h"
    8180#include "MHillasCalc.h"
    82 //#include "MSrcPosCalc.h"
    8381#include "MContinue.h"
    8482
     
    8987MJSpectrum::MJSpectrum(const char *name, const char *title)
    9088    : fCutQ(0), fCut0(0),fCut1(0), fCut2(0), fCut3(0), fCutS(0),
    91     fEstimateEnergy(0), fCalcHadronness(0), fRefill(kFALSE),
    92     /*fSimpleMode(kTRUE),*/ fForceTheta(kFALSE),
    93     fRawMc(kFALSE), fNoThetaWeights(kFALSE)
     89    fEstimateEnergy(0), fCalcHadronness(0),  fForceTheta(kFALSE)
    9490{
    9591    fName  = name  ? name  : "MJSpectrum";
    9692    fTitle = title ? title : "Standard program to calculate spectrum";
    97 }
    98 
     93
     94    // Make sure that fDisplay is maintained properly
     95    // (i.e. removed via RecursiveRemove if closed)
     96    gROOT->GetListOfCleanups()->Add(this);
     97}
     98
     99// --------------------------------------------------------------------------
     100//
     101// Delete all the fCut* data members and fCalcHadronness/fEstimateEnergy
     102//
    99103MJSpectrum::~MJSpectrum()
    100104{
     
    128132}
    129133
     134// --------------------------------------------------------------------------
     135//
     136// Read a MTask named name into task from the open file. If this task is
     137// required mustexist can be set. Depending on success kTRUE or kFALSE is
     138// returned. If the task is a MContinue SetAllowEmpty is called.
     139// The name of the task is set to name.
     140//
    130141Bool_t MJSpectrum::ReadTask(MTask* &task, const char *name, Bool_t mustexist) const
    131142{
     143    // If a task is set delete task
    132144    if (task)
    133145    {
     
    136148    }
    137149
     150    // Try to get task from file
    138151    task = (MTask*)gFile->Get(name);
    139152    if (!task)
     
    144157        return kFALSE;
    145158    }
     159
     160    // Check if task inherits from MTask
    146161    if (!task->InheritsFrom(MTask::Class()))
    147162    {
     
    151166    }
    152167
     168    // Set name of task
    153169    task->SetName(name);
    154170
     171    // SetAllowEmpty for MContinue tasks
    155172    if (dynamic_cast<MContinue*>(task))
    156173        dynamic_cast<MContinue*>(task)->SetAllowEmpty();
     
    159176}
    160177
     178// --------------------------------------------------------------------------
     179//
     180// Print setup used for the MC processing, namely MAlphaFitter ans all fCut*.
     181//
    161182void MJSpectrum::PrintSetup(const MAlphaFitter &fit) const
    162183{
     
    194215    }
    195216
    196     // Read the first corsika RunHeader from the MC files
    197     TChain chain("RunHeaders");
    198     if (!set.AddFilesOn(chain))
    199         return kFALSE;
    200 
    201     MMcCorsikaRunHeader *h=0;
    202     chain.SetBranchAddress("MMcCorsikaRunHeader.", &h);
    203     chain.GetEntry(1);
    204 
    205     if (!h)
    206     {
    207         *fLog << err << "ERROR - Couldn't read MMcCorsikaRunHeader from DataSet." << endl;
    208         return kFALSE;
    209     }
    210 
    211     // Propagate the run header to MMcSpectrumWeight
    212     if (!w.Set(*h))
    213     {
    214         *fLog << err << "ERROR - Initializing MMcSpectrumWeight failed." << endl;
    215         return kFALSE;
    216     }
    217 
    218     // Print new setup of MMcSpectrumWeight
    219     w.Print();
     217    w.Print("new");
     218
    220219    return kTRUE;
    221220}
     
    281280}
    282281
     282// --------------------------------------------------------------------------
     283//
     284// return maximum value of MMcRunHeader.fImpactMax stored in the RunHeaders
     285// of the files from the MC dataset
     286//
     287Bool_t MJSpectrum::AnalyzeMC(const MDataSet &set, Float_t &impactmax, Float_t &emin/*, Float_t emax*/) const
     288{
     289    if (fDisplay)
     290        fDisplay->SetStatusLine1("Analyzing Monte Carlo headers...");
     291
     292    // ----- Create chain -----
     293    *fLog << inf << "Getting files... " << flush;
     294    TChain chain("RunHeaders");
     295    if (!set.AddFilesOn(chain))
     296        return kFALSE;
     297    *fLog << "done. " << endl;
     298
     299    *fLog << all;
     300    *fLog << "Searching for maximum impact... " << flush;
     301    impactmax = chain.GetMaximum("MMcRunHeader.fImpactMax");
     302    *fLog << "found " << impactmax/100 << "m" << endl;
     303
     304    *fLog << "Searching for minimum lower energy limit... " << flush;
     305    emin = chain.GetMinimum("MMcCorsikaRunHeader.fELowLim");
     306    *fLog << "found " << emin << "GeV" << endl;
     307
     308    *fLog << "Searching for maximum lower energy limit... " << flush;
     309    const Float_t emin2 = chain.GetMaximum("MMcCorsikaRunHeader.fELowLim");
     310    *fLog << "found " << emin2 << "GeV" << endl;
     311
     312    if (emin2>emin)
     313    {
     314        *fLog << warn;
     315        *fLog << "WARNING - You are using files with different lower limits for the simulated" << endl;
     316        *fLog << "          energy, i.e. that the collection area and your correction" << endl;
     317        *fLog << "          coefficients between " << emin << "GeV and ";
     318        *fLog << emin2 << "GeV might be wrong." << endl;
     319    }
     320
     321/*
     322    *fLog << "Getting maximum energy... " << flush;
     323    emax = chain.GetMaximum("MMcCorsikaRunHeader.fEUppLim");
     324    *fLog << "found " << emax << "GeV" << endl;
     325 */
     326    return kTRUE;
     327}
     328
    283329Bool_t MJSpectrum::ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &weight) const
    284330{
     
    286332    fLog->Separator("Compiling original MC distribution");
    287333
    288     // The name of the input container is MMcEvtBasic
    289     weight.SetNameMcEvt("MMcEvtBasic");
    290     // Get the corresponding rule for the weights
    291     const TString w(weight.GetFormulaWeights());
    292     // Set back to MMcEvt
    293     weight.SetNameMcEvt();
    294 
    295     *fLog << inf << "Using weights: " << w << endl;
    296     *fLog << "Please stand by, this may take a while..." << endl;
    297 
    298     if (fDisplay)
    299         fDisplay->SetStatusLine1("Getting maximum impact...");
    300 
    301     // ----- Create chain -----
    302     *fLog << "Getting files... " << flush;
    303     TChain chain("RunHeaders");
    304     if (!set.AddFilesOn(chain))
    305         return kFALSE;
    306     *fLog << "done. " << endl;
    307 
    308     *fLog << "Getting maximum impact... " << flush;
    309     const Double_t impactmax = chain.GetMaximum("MMcRunHeader.fImpactMax");
    310     *fLog << "found " << impactmax/100 << "m" << endl;
    311 
    312     *fLog << "Getting files... " << flush;
     334    Float_t impactmax=0, Emin=0;
     335    if (!AnalyzeMC(set, impactmax, Emin))
     336        return kFALSE;
     337
     338    *fLog << inf << "Getting files... " << flush;
    313339    MDirIter iter;
    314340    if (!set.AddFilesOn(iter))
    315341        return kFALSE;
    316342    *fLog << "done. " << endl;
     343
     344    const Int_t tot = iter.GetNumEntries();
    317345
    318346    // Prepare histogram
     
    339367
    340368    if (fDisplay)
    341         fDisplay->SetStatusLine1("Reading OriginalMC");
     369        fDisplay->SetStatusLine1("Reading OriginalMC distribution...");
    342370
    343371    TH1 *hfill = (TH1*)h.Clone(h.InheritsFrom(TH2::Class())?"ThetaEMC":"ThetaMC");
    344372    hfill->SetDirectory(0);
    345373
     374    *fLog << all << "Compiling simulated source spectrum... please stand by, this may take a while." << endl;
     375
     376    Double_t evts = 0;
     377    Int_t    num  = 0;
     378
     379    // Reading this with a eventloop is five times slower :(
    346380    TString fname;
    347     while (1)
    348     {
     381    while (fDisplay)
     382    {
     383        if (fDisplay)
     384            fDisplay->SetProgressBarPosition(Float_t(num++)/tot);
     385
     386        // Get next filename
    349387        fname = iter.Next();
    350388        if (fname.IsNull())
    351389            break;
    352390
     391        if (fDisplay)
     392            fDisplay->SetStatusLine2(fname);
     393
     394        // open file
    353395        TFile file(fname);
    354396        if (file.IsZombie())
     
    358400        }
    359401
     402        // Get tree OriginalMC
     403        TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC"));
     404        if (!t)
     405        {
     406            *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl;
     407            return kFALSE;
     408        }
     409        if (t->GetEntries()==0)
     410        {
     411            *fLog << warn << "WARNING - OriginalMC of " << fname << " empty." << endl;
     412            continue;
     413        }
     414
     415        // Get tree RunHeaders
    360416        TTree *rh = dynamic_cast<TTree*>(file.Get("RunHeaders"));
    361417        if (!rh)
     
    364420            return kFALSE;
    365421        }
    366 
    367422        if (rh->GetEntries()!=1)
    368423        {
     
    371426        }
    372427
    373         TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC"));
    374         if (!t)
     428        // Get corsika run header
     429        MMcCorsikaRunHeader *head=0;
     430        rh->SetBranchAddress("MMcCorsikaRunHeader.", &head);
     431        rh->GetEntry(0);
     432        if (!head)
    375433        {
    376             *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl;
     434            *fLog << err << "ERROR - Couldn't read MMcCorsikaRunHeader from " << fname << "." << endl;
    377435            return kFALSE;
    378436        }
    379437
     438        // Get the maximum impact parameter of this file. Due to different
     439        // production areas an additional scale-factor is applied.
     440        //
     441        // Because it is assumed that the efficiency outside the production
     442        // area is nearly zero no additional weight has to be applied to the
     443        // events after cuts.
     444        const Double_t impact = rh->GetMaximum("MMcRunHeader.fImpactMax");
     445        const Double_t scale  = impactmax/impact;
     446 
     447        // Propagate the run header to MMcSpectrumWeight
     448        if (!weight.Set(*head))
     449        {
     450            *fLog << err << "ERROR - Initializing MMcSpectrumWeight failed." << endl;
     451            return kFALSE;
     452        }
     453
     454        // Get the corresponding rule for the weights
     455        const TString weights(weight.GetFormulaWeights("MMcEvtBasic"));
     456
     457        // No we found everything... go on reading contents
    380458        *fLog << inf << "Reading OriginalMC of " << fname << endl;
    381 
    382         if (t->GetEntries()==0)
    383         {
    384             *fLog << warn << "WARNING - OriginalMC of " << fname << " empty." << endl;
    385             continue;
    386         }
    387 
    388         // Why does it crash if closed within loop (no update?)
    389         //if (fDisplay)
    390         //    fDisplay->SetStatusLine2(fname);
    391 
    392         // Normalize by deviding through production area
    393         const Double_t impact  = rh->GetMaximum("MMcRunHeader.fImpactMax");
    394         const Double_t scale   = impactmax/impact;
    395         const TString  weights = Form("%.16e*(%s)", scale*scale, w.Data());
    396459
    397460        // Fill histogram from tree
     
    403466        }
    404467        hfill->SetDirectory(0);
     468
     469        evts += hfill->GetEntries();
     470
     471        // ----- Complete incomplete energy ranges -----
     472        // ----- and apply production area weights -----
     473        weight.CompleteEnergySpectrum(*hfill, Emin);
     474
     475        hfill->Scale(scale*scale);
     476
     477        // Add weighted data from file to final histogram
    405478        h.Add(hfill);
    406479    }
    407480    delete hfill;
    408481
    409     *fLog << "Total number of events from file: " << h.GetEntries() << endl;
     482    *fLog << all << "Total number of events from files in Monte Carlo dataset: " << evts << endl;
    410483    if (fDisplay)
    411484        fDisplay->SetStatusLine2("done.");
    412485
    413     if (h.GetEntries()>0)
     486    if (!fDisplay || h.GetEntries()>0)
    414487        return kTRUE;
    415488
    416     *fLog << err << "ERROR - Histogram with original MC distribution empty..." << endl;
    417 
     489    *fLog << err << "ERROR - Histogram with distribution from OriginalMC empty..." << endl;
    418490    return kFALSE;
    419491}
    420492
    421 Bool_t MJSpectrum::GetThetaDistribution(TH1D &temp1, TH1D &temp2) const
    422 {
     493void MJSpectrum::GetThetaDistribution(TH1D &temp1, TH2D &hist2) const
     494{
     495    TH1D &temp2 = *hist2.ProjectionX();
     496
    423497    // Display some stuff
    424498    if (fDisplay)
     
    430504        c.cd(1);
    431505        gPad->SetBorderMode(0);
     506        gPad->SetGridx();
     507        gPad->SetGridy();
    432508        temp1.DrawCopy();
    433509
     
    435511        c.cd(2);
    436512        gPad->SetBorderMode(0);
     513        gPad->SetGridx();
     514        gPad->SetGridy();
    437515        temp2.SetName("NVsTheta");
    438516        temp2.DrawCopy("hist");
     
    440518        c.cd(4);
    441519        gPad->SetBorderMode(0);
     520        gPad->SetGridx();
     521        gPad->SetGridy();
    442522
    443523        c.cd(3);
    444524        gPad->SetBorderMode(0);
     525        gPad->SetGridx();
     526        gPad->SetGridy();
    445527    }
    446528
    447529    // Calculate the Probability
    448530    temp1.Divide(&temp2);
    449     temp1.Scale(fNoThetaWeights ? 1./temp1.GetMaximum() : 1./temp1.Integral());
     531    temp1.Scale(1./temp1.Integral());
    450532
    451533    // Some cosmetics: Name, Axis, etc.
     
    456538        temp1.DrawCopy("hist");
    457539
    458     return kTRUE;
     540    delete &temp2;
    459541}
    460542
     
    492574    }
    493575
     576    // Check whether histogram is empty
    494577    if (proj.GetMaximum()==0)
    495578    {
     
    497580        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap" << endl;
    498581        *fLog << "        with the Zenith Angle distribution of your observation." << endl;
    499         *fLog << "        Maybe the energy binning is not defined or wrong." << endl;
     582        *fLog << "        Maybe the energy binning is undefined or wrong (from ";
     583        *fLog << h2.GetYaxis()->GetXmin() << "GeV to " << h2.GetYaxis()->GetXmax() << "GeV)" << endl;
    500584        theta->SetLineColor(kRed);
    501585        return kFALSE;;
    502586    }
    503587
     588    // scale histogram and set new maximum for display
    504589    proj.Scale(theta->GetMaximum()/proj.GetMaximum());
    505590    theta->SetMaximum(1.05*TMath::Max(theta->GetMaximum(), proj.GetMaximum()));
    506591
     592    // draw project
    507593    proj.Draw("same");
    508594
     
    688774    fill0.SetFilter(&sel1);
    689775
    690     if (!fRawMc)
     776    //if (!fRawMc)
    691777        tlist1.AddToList(&sel1);
    692778    tlist1.AddToList(&fill0);
     
    767853TArrayD MJSpectrum::FitSpectrum(TH1D &spectrum) const
    768854{
    769     TF1 f("f", "[1]*(x/1e3)^[0]", 10, 3e4);
    770     f.SetParameter(0, -2.5);
    771     f.SetParameter(1, spectrum.GetBinContent(spectrum.GetXaxis()->FindFixBin(1000)));
     855    Axis_t lo, hi;
     856    MH::GetRangeUser(spectrum, lo, hi);
     857
     858    TF1 f("f", "[1]*(x/500)^[0]", lo, hi);
     859    f.SetParameter(0, -3.0);
     860    f.SetParameter(1, spectrum.GetMaximum());
    772861    f.SetLineColor(kBlue);
    773     spectrum.Fit(&f, "NI", "", 80, 1150); // M skipped
     862    f.SetLineWidth(2);
     863    spectrum.Fit(&f, "NIR"); // M skipped
    774864    f.DrawCopy("same");
    775865
     
    881971    spec = (TH1D*)spectrum.DrawCopy();
    882972
    883     // Calculate Spectrum * E^2
    884     for (int i=0; i<spectrum.GetNbinsX(); i++)
    885     {
    886         const Double_t e = TMath::Sqrt(spectrum.GetBinLowEdge(i+1)*spectrum.GetBinLowEdge(i+2))*1e-3;
    887 
    888         spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)*e*e);
    889         spectrum.SetBinError(  i+1, spectrum.GetBinError(i+1)  *e*e);
    890     }
     973    TF1 fc("Crab", "7.0e-6*(x/300)^(-2.31-0.26*log10(x/300))", 100, 6000);
     974    fc.SetLineStyle(7);
     975    fc.SetLineWidth(2);
     976    fc.SetLineColor(14);
     977    fc.DrawCopy("same");
     978
     979    TF1 fa("PG1553", "1.8e-6*(x/200)^-4.21", 90, 600);
     980    static_cast<const TAttLine&>(fc).Copy(fa);
     981    fa.DrawCopy("same");
    891982
    892983    // Display dN/dE*E^2 for conveinience
     
    896987    gPad->SetGrid();
    897988
     989    // Calculate Spectrum * E^2
     990    for (int i=0; i<spectrum.GetNbinsX(); i++)
     991    {
     992        const Double_t e = TMath::Sqrt(spectrum.GetBinLowEdge(i+1)*spectrum.GetBinLowEdge(i+2))*1e-3;
     993
     994        spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)*e*e);
     995        spectrum.SetBinError(  i+1, spectrum.GetBinError(i+1)  *e*e);
     996    }
     997
    898998    spectrum.SetName("FluxStd");
    899999    spectrum.SetMarkerStyle(kFullDotMedium);
    9001000    spectrum.SetTitle("Differential flux times E^{2}");
    901     spectrum.SetYTitle("E^{2}dN/dE [N TeV/sm^{2}]");
     1001    spectrum.SetYTitle("E^{2}#cdot dN/dE [N#cdot TeV/sm^{2}]");
    9021002    spectrum.SetDirectory(0);
    9031003    spectrum.DrawCopy();
     1004
     1005    TF1 fc2("Crab*E^2", "x^2*Crab*1e-6", 100, 6000);
     1006    static_cast<const TAttLine&>(fc).Copy(fc2);
     1007    fc2.DrawCopy("same");
     1008
     1009    TF1 fa2("PG1553*E^2", "x^2*PG1553*1e-6", 100, 6000);
     1010    static_cast<const TAttLine&>(fc).Copy(fa2);
     1011    fa2.DrawCopy("same");
    9041012
    9051013    // Fit Spectrum
     
    9431051    return res;
    9441052  */
    945 /*
    946     // Plot other spectra  from Whipple
    947     f.SetParameter(0, -2.45);
    948     f.SetParameter(1, 3.3e-7);
    949     f.SetRange(300, 8000);
    950     f.SetLineColor(kBlack);
    951     f.SetLineStyle(kDashed);
    952     f.DrawCopy("same");
    953 
    954     // Plot other spectra  from Cangaroo
    955     f.SetParameter(0, -2.53);
    956     f.SetParameter(1, 2.0e-7);
    957     f.SetRange(7000, 50000);
    958     f.SetLineColor(kBlack);
    959     f.SetLineStyle(kDashed);
    960     f.DrawCopy("same");
    961 
    962     // Plot other spectra  from Robert
    963     f.SetParameter(0, -2.59);
    964     f.SetParameter(1, 2.58e-7);
    965     f.SetRange(150, 1500);
    966     f.SetLineColor(kBlack);
    967     f.SetLineStyle(kDashed);
    968     f.DrawCopy("same");
    969 
    970     // Plot other spectra  from HEGRA
    971     f.SetParameter(0, -2.61);
    972     f.SetParameter(1, 2.7e-7);
    973     f.SetRange(1000, 20000);
    974     f.SetLineColor(kBlack);
    975     f.SetLineStyle(kDashed);
    976     f.DrawCopy("same");
    977  */
    9781053}
    9791054
     
    11791254    *fLog << endl;
    11801255
     1256    // Setup everything which is read from the ganymed file
    11811257    MBinning bins1("BinningAlpha");
    11821258    MBinning bins2("BinningEnergyEst");
     
    11911267    MBinning binsa("BinningAsym");
    11921268    MBinning binsb("BinningConc1");
    1193 
    11941269
    11951270    MAlphaFitter fit;
     
    12091284    plist.AddToList(&fit);
    12101285
    1211     TH1D temp1, size;
    1212     const Float_t ontime = ReadInput(plist, temp1, size);
     1286    // Read from the ganymed file
     1287    TH1D htheta, size;
     1288    const Float_t ontime = ReadInput(plist, htheta, size);
    12131289    if (ontime<0)
    12141290    {
     
    12171293    }
    12181294
    1219     plist.AddToList(&bins2);
    1220 
    1221     // Initialize weighting to a new spectrum
    1222     // as defined in the resource file
     1295    // Set Zenith angle binning to binning from the ganymed-file
     1296    bins3.SetEdges(htheta, 'x');
     1297
     1298    // Read energy binning from resource file
     1299    if (!CheckEnv(bins2))
     1300    {
     1301        *fLog << err << "ERROR - Reading energy binning from resources failed." << endl;
     1302        return kFALSE;
     1303    }
     1304    plist.AddToList(&bins2); // For later use in MC processing
     1305
     1306    // Initialize weighting to a new spectrum as defined in the resource file
    12231307    MMcSpectrumWeight weight;
    12241308    if (!InitWeighting(set, weight))
    12251309        return kFALSE;
    12261310
    1227     bins3.SetEdges(temp1, 'x');
    1228 
    1229     // Read the MC distribution as produced by corsika into
    1230     // temp2 (1D) and apply the weights previously determined
    1231     TH1D temp2(temp1);
    1232     if (!ReadOrigMCDistribution(set, temp2, weight))
    1233         return kFALSE;
    1234 
    1235     // Calculate the weights according to the zenith angle distribution
    1236     // of the raw-data which have to be applied to the MC events
    1237     if (!GetThetaDistribution(temp1, temp2))
    1238         return kFALSE;
    1239 
    1240     // Tell the weighting task about the ZA-weights
    1241     if (!fNoThetaWeights)
    1242         weight.SetWeightsZd(&temp1);
     1311    // Print Theta and energy binning for cross-checks
     1312    *fLog << all << endl;
     1313    bins2.Print();
     1314    bins3.Print();
     1315
     1316    // Now we read the MC distribution as produced by corsika
     1317    // vs zenith angle and energy.
     1318    // Weight for the new energy spectrum defined in MMcSpectumWeight
     1319    // are applied.
     1320    // Also correction for different lower energy bounds and
     1321    // different production areas (impact parameters) are applied.
     1322    TH2D hist;
     1323    hist.UseCurrentStyle();
     1324    MH::SetBinning(&hist, &bins3, &bins2);
     1325    if (!ReadOrigMCDistribution(set, hist, weight))
     1326        return kFALSE;
     1327
     1328    // Check if user has closed the display
     1329    if (!fDisplay)
     1330        return kTRUE;
     1331
     1332    // Display histograms and calculate za-weights into htheta
     1333    GetThetaDistribution(htheta, hist);
     1334
     1335    // Give the zenoith angle weights to the weighting task
     1336    weight.SetWeightsZd(&htheta);
     1337
     1338    // No we apply the the zenith-angle-weights to the corsika produced
     1339    // MC distribution. Unfortunately this must be done manually
     1340    // because we are multiplying column by column
     1341    for (int y=0; y<hist.GetNbinsY(); y++)
     1342        for (int x=0; x<hist.GetNbinsX(); x++)
     1343        {
     1344            hist.SetBinContent(x, y, hist.GetBinContent(x, y)*htheta.GetBinContent(x));
     1345            hist.SetBinError(x, y,   hist.GetBinError(x, y)  *htheta.GetBinContent(x));
     1346        }
     1347
     1348    // Display the resulting distribution and check it matches
     1349    // the observation time distribution (this could be false
     1350    // for example if you miss MCs of some zenith angles, which you have
     1351    // data for)
     1352    if (!DisplayResult(hist))
     1353        return kFALSE;
     1354
     1355    // -------------- Fill excess events versus energy ---------------
    12431356
    12441357    // Refill excess histogram to determin the excess events
     
    12471360        return kFALSE;
    12481361
    1249     // Print the setup and result of the MAlphaFitter
    1250     // Print used cuts
     1362    // Print the setup and result of the MAlphaFitter, print used cuts
    12511363    PrintSetup(fit);
    1252 
    1253     TH2D hist;
    1254     MH3 mh1("MMcEvtBasic.fTelescopeTheta*kRad2Deg", "MMcEvtBasic.fEnergy");
    1255     //if (fSimpleMode)
    1256     {
    1257         // Now we read the MC distribution as produced by corsika again
    1258         // with the spectral weights applied into a histogram vs.
    1259         // zenith angle and energy
    1260         hist.UseCurrentStyle();
    1261         MH::SetBinning(&hist, &bins3/*temp1.GetXaxis()*/, &bins2/*excess.GetXaxis()*/);
    1262         if (!ReadOrigMCDistribution(set, hist, weight))
    1263             return kFALSE;
    1264 
    1265         // No we apply the the zenith-angle-weights to the corsika produced
    1266         // MC distribution. Unfortunately this must be done manually
    1267         // because we are multiplying column by column
    1268         if (!fRawMc)
    1269         {
    1270             for (int y=0; y<hist.GetNbinsY(); y++)
    1271                 for (int x=0; x<hist.GetNbinsX(); x++)
    1272                 {
    1273                     hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x));
    1274                     hist.SetBinError(x, y,   hist.GetBinError(x, y)  *temp1.GetBinContent(x));
    1275                 }
    1276         }
    1277     }/*
    1278     else
    1279     {
    1280         // This rereads the original MC spectrum and aplies both
    1281         // weights, spectral weights and ZA-weights.
    1282         weight.SetNameMcEvt("MMcEvtBasic");
    1283         if (!IntermediateLoop(plist, mh1, temp1, set, weight))
    1284             return kFALSE;
    1285         weight.SetNameMcEvt();
    1286     }*/
    1287 
    1288     if (!DisplayResult(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/))
    1289         return kFALSE;
    12901364
    12911365    // ------------------------- Final loop --------------------------
     
    13041378
    13051379    // Selector to get correct (final) theta-distribution
    1306     temp1.SetXTitle("MPointingPos.fZd");
    1307 
    1308     MH3 mh3(temp1);
    1309 
    1310     MFEventSelector2 sel2(mh3);
    1311     sel2.SetHistIsProbability();
    1312 
    1313     MContinue contsel(&sel2);
    1314     contsel.SetInverted();
     1380    //temp1.SetXTitle("MPointingPos.fZd");
     1381    //
     1382    //MH3 mh3(temp1);
     1383    //
     1384    //MFEventSelector2 sel2(mh3);
     1385    //sel2.SetHistIsProbability();
     1386    //
     1387    //MContinue contsel(&sel2);
     1388    //contsel.SetInverted();
    13151389
    13161390    // Get correct source position
     
    13181392
    13191393    // Calculate corresponding Hillas parameters
    1320     /*
    1321      MHillasCalc hcalc1;
    1322      MHillasCalc hcalc2("MHillasCalcAnti");
    1323      hcalc1.SetFlags(MHillasCalc::kCalcHillasSrc);
    1324      hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc);
    1325      hcalc2.SetNameHillasSrc("MHillasSrcAnti");
    1326      hcalc2.SetNameSrcPosCam("MSrcPosAnti");
    1327      */
     1394    //MHillasCalc hcalc1;
     1395    //MHillasCalc hcalc2("MHillasCalcAnti");
     1396    //hcalc1.SetFlags(MHillasCalc::kCalcHillasSrc);
     1397    //hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc);
     1398    //hcalc2.SetNameHillasSrc("MHillasSrcAnti");
     1399    //hcalc2.SetNameSrcPosCam("MSrcPosAnti");
    13281400
    13291401    // Fill collection area and energy estimator (unfolding)
     
    13311403    MHCollectionArea area0("TriggerArea");
    13321404    MHCollectionArea area1;
    1333     area0.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);
    1334     area1.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);
     1405    area0.SetHistAll(hist);
     1406    area1.SetHistAll(hist);
    13351407
    13361408    MHEnergyEst      hest;
     
    13711443    MFillH fill7a("MHNewParMCPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
    13721444    MFillH fill8a("ExcessMC       [MH3]",           "",             "FillExcessMC");
     1445    fill0a.SetNameTab("EvtDist");
    13731446    fill1a.SetNameTab("PreCut");
    13741447    fill2a.SetNameTab("PostCut");
     
    13991472    // be thrown away according to the theta distribution
    14001473    // it is enabled here
    1401     if (!fRawMc && fNoThetaWeights)
    1402         tlist2.AddToList(&contsel);
     1474    //if (!fRawMc && fNoThetaWeights)
     1475    //    tlist2.AddToList(&contsel);
    14031476    //tlist2.AddToList(&calc);
    14041477    //tlist2.AddToList(&hcalc1);
  • trunk/MagicSoft/Mars/mjobs/MJSpectrum.h

    r8676 r8680  
    3333    MTask *fCalcHadronness;
    3434
    35     Bool_t fRefill;
    36     //Bool_t fSimpleMode;
    3735    Bool_t fForceTheta;
    38     Bool_t fRawMc;
    39     Bool_t fNoThetaWeights;
    4036
    4137    // Read Input
    42     Bool_t  ReadTask(MTask* &task, const char *name, Bool_t mustexist=kTRUE) const;
    43     Float_t ReadInput(MParList &plist, TH1D &h1, TH1D &size);
    44     Bool_t  ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &w) const;
    45     Bool_t  GetThetaDistribution(TH1D &temp1, TH1D &temp2) const;
    46     Bool_t  Refill(MParList &plist, TH1D &h) /*const*/;
    47     Bool_t  InitWeighting(const MDataSet &set, MMcSpectrumWeight &w) const;
     38    Bool_t   ReadTask(MTask* &task, const char *name, Bool_t mustexist=kTRUE) const;
     39    Float_t  ReadInput(MParList &plist, TH1D &h1, TH1D &size);
     40    Bool_t   AnalyzeMC(const MDataSet &set, Float_t &impactmax, Float_t &emin/*, Float_t emax*/) const;
     41    Bool_t   ReadOrigMCDistribution(const MDataSet &set, TH1 &h, MMcSpectrumWeight &w) const;
     42    void     GetThetaDistribution(TH1D &temp1, TH2D &temp2) const;
     43    Bool_t   Refill(MParList &plist, TH1D &h) /*const*/;
     44    Bool_t   InitWeighting(const MDataSet &set, MMcSpectrumWeight &w) const;
    4845
    4946    // Display Output
     
    6360    Bool_t Process(const MDataSet &set);
    6461
    65     void EnableRefilling(Bool_t b=kTRUE)  { fRefill=b; }
    66     //void EnableSimpleMode(Bool_t b=kTRUE) { fSimpleMode=b; }
    67     void EnableRawMc(Bool_t b=kTRUE)      { fRawMc=b; }
    68     void ForceTheta(Bool_t b=kTRUE)       { fForceTheta=b; }
     62    void ForceTheta(Bool_t b=kTRUE) { fForceTheta=b; }
    6963
    7064    void SetEnergyEstimator(const MTask *task);
  • trunk/MagicSoft/Mars/sponde.rc

    r7094 r8680  
    11EstimateEnergy.Rule: (0.380075+(MPointingPos.fZd*MPointingPos.fZd*0.00109028))*pow(MHillas.fSize,0.892462)
    22
     3BinningSize.Raw:        18   49   63600 log
     4BinningEnergyEst.Raw:   18   53   35800 log
     5
    36#MMcSpectrumWeight.NewSlope: -2.26
Note: See TracChangeset for help on using the changeset viewer.