Changeset 8674 for trunk/MagicSoft


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8673 r8674  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2007/08/18 Thomas Bretz
     22
     23   * sponde.cc:
     24     - added new option --force-theta
     25
     26   * mbase/MEnv.[h,cc], mjobs/MSequence.[h,cc], mjobs/MDataSet.[h,cc]:
     27     - GetName noe returns only the filename not the whole path. The
     28       old behaviour made it impossible to access the container from
     29       the file.
     30     - GetRcName now returns the whole path/name.
     31     - Print now outputs also path and file-name
     32
     33   * mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc:
     34     - fixed typos in comments
     35
     36   * mhflux/MHCollectionArea.cc:
     37     - reset fCorsikaVersion to 0 in PreProcess
     38     - print old and new Cosika version if mismatch is found
     39
     40   * mhflux/MMcSpectrumWeight.cc:
     41     - replaced the %.16f by %.16e. This is more accurate in cases
     42       with high exponents
     43     - added some sample/test code to weight the Zenith Angle
     44       according to the sin-distribution produced by Corsika.
     45       Currently not in use
     46
     47   * mjobs/MJSpectrum.cc:
     48     - removed the simple/accurate mode. There is now reason why
     49       the previous "accurate"-mode should be more accurate at all.
     50       It is only slower
     51     - Reading the OriginalMC tree now is done such that the
     52       events are properly weighted by the production area. This
     53       allowes to use different impact paramters from dfferent files.
     54     - a check has been implemented which compared the zenith angle
     55       distribution of the data and the resulting monte carlo data.
     56       Execution of the program can be forced with a new option.
     57     - write more information to output file.
     58
     59
    2060
    2161 2007/08/17 Thomas Bretz
  • trunk/MagicSoft/Mars/NEWS

    r8671 r8674  
    221221     contents where exchanged.... fixed.
    222222
     223   - sponde: the so called "accurate"-mode has been removed. It didn't
     224     give any improvement in accuracy, only decreased execution speed.
     225
     226   - sponde: now checks whether the theta distribution of your on-data
     227     and the theta-distribution of your Monte Carlo sample (after
     228     weighting) fits. If it doesn't fit properly (eg. the Monte Carlo
     229     sample is incomplete) execution is stopped. Execution can be forced
     230     using the new option --force-theta. Use this option with care!
     231
     232   - sponde: Proper collection areas can now be constructed also from
     233     Monte Carlo samples generated with different maximum impact
     234     parameters. Note that in previous version you neither got
     235     a warning or failure, nor was there any obvious sign that the
     236     collection area was overestimated due to usage of files with
     237     different maximum impact parameters.
     238
     239   - sponde: the output file now contains more information about
     240     the spectrum (eg. the full 2D collection area histogram).
     241     Note, that this information can only be written to the file
     242     if it is stored automatically via command line argument.
     243     If you only store the status display from within the display
     244     the information is lost.
     245
    223246
    224247
  • trunk/MagicSoft/Mars/mbase/MEnv.cc

    r8539 r8674  
    7171    if (GetEntries()<=0 && !fname.IsNull() && fname!=name)
    7272        ReadFile(fname, kEnvLocal);;
     73}
     74
     75//---------------------------------------------------------------------------
     76//
     77// Make sure that the name used for writing doesn't contain a full path
     78//
     79const char *MEnv::GetName() const
     80{
     81    const char *pos = strrchr(GetRcName(), '/');
     82    return pos>0 ? pos+1 : GetRcName();
    7383}
    7484
     
    847857//---------------------------------------------------------------------------
    848858//
     859// Add name and full path to output
     860//
     861void MEnv::PrintEnv(EEnvLevel level) const
     862{
     863    cout << "# Path: " << GetRcName() << endl;
     864    cout << "# Name: " << GetName() << endl;
     865    TEnv::PrintEnv(level);
     866}
     867
     868//---------------------------------------------------------------------------
     869//
    849870// Print resources which have never been touched (for debugging)
    850871//
  • trunk/MagicSoft/Mars/mbase/MEnv.h

    r8582 r8674  
    3838    const char *GetValue(const char *name, const char *dflt);
    3939
    40     const char *GetName() const { return GetRcName(); }
     40    const char *GetName() const { return strrchr(GetRcName(), '/')?strrchr(GetRcName(), '/')+1:GetRcName(); }
    4141
    4242    Int_t       GetColor(const char *name, Int_t dftl);
     
    6767    void        AddEnv(const TEnv &env, Bool_t overwrite=kTRUE);
    6868
     69    void        PrintEnv(EEnvLevel level = kEnvAll) const;
    6970    void        Print(Option_t *option) const { TEnv::Print(option); }
    70     void        Print() const { TEnv::PrintEnv(kEnvLocal); } //*MENU*
     71    void        Print() const { PrintEnv(kEnvLocal); } //*MENU*
    7172
    7273    void PrintUntouched() const;
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r8226 r8674  
    267267//  list gets a new address. Therefor we reset all the autodel flags.
    268268//
    269 //  MAKE SURE THAT ALL YOPUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY
     269//  MAKE SURE THAT ALL YOUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY
    270270//
    271271Bool_t MReadTree::Notify()
     
    295295    // list gets a new address. Therefor we reset all the autodel flags.
    296296    //
    297     // MAKE SURE THAT ALL YOPUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY
     297    // MAKE SURE THAT ALL YOUR CUSTOM STREAMERS TAKE CARE OF ALL MEMORY
    298298    //
    299299    TIter NextB(fTree->GetListOfBranches());
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r8642 r8674  
    3535// There is a special mode of operation which opens a new file for each new
    3636// file read by the reading task (opening the new file is initiated by
    37 // ReInit()) For more details se the corresponding constructor.
     37// ReInit()) For more details see the corresponding constructor.
    3838//
    3939// Memory based trees
  • trunk/MagicSoft/Mars/mhflux/MHCollectionArea.cc

    r8673 r8674  
    183183    MH::SetBinning(&fHistAll, &binst, &binse);
    184184
    185     fMcAreaRadius = -1;
     185    fMcAreaRadius   = -1;
     186    fCorsikaVersion =  0;
    186187
    187188    return kTRUE;
     
    205206
    206207    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
    207         *fLog << warn << "Warning - Read files have different Corsika versions..." << endl;
     208    {
     209        *fLog << warn;
     210        *fLog << "Warning - Read files have different Corsika versions..." << endl;
     211        *fLog << "          Last file=" << fCorsikaVersion << "   New file=" << runheader->GetCorsikaVersion() << endl;
     212    }
    208213    fCorsikaVersion = runheader->GetCorsikaVersion();
    209214
     
    285290        //                         GetCollectionAreaAbs(), fMcAreaRadius);
    286291        const TString txt = Form("r_{max}=%.0fm --> A_{max}=%.0fm^{2}",
    287                                  GetCollectionAreaAbs(), fMcAreaRadius);
     292                                 fMcAreaRadius, GetCollectionAreaAbs());
    288293
    289294        TLatex text(0.31, 0.95, txt);
  • trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc

    r8047 r8674  
    254254// are equal only fNorm is returned.
    255255//
    256 // The normalization constant is returned as %.16f
     256// The normalization constant is returned as %.16e
    257257//
    258258// Example: 0.3712780019*(pow(MMcEvt.fEnergy,-2.270))/(pow(MMcEvt.fEnergy,-2.600))
     
    261261{
    262262    if (GetFormulaSpecOld()==GetFormulaSpecNew())
    263         return Form("%.16f", fNorm);
     263        return Form("%.16e", fNorm);
    264264
    265265    const Double_t iold = fNormEnergy<0 ? GetSpecOldIntegral() : CalcSpecOld(fNormEnergy);
     
    268268    const Double_t norm = fNorm*iold/inew;
    269269
    270     return Form("%.16f*(%s)/(%s)", norm, GetFormulaSpecNew().Data(), GetFormulaSpecOld().Data());
     270    return Form("%.16e*(%s)/(%s)", norm, GetFormulaSpecNew().Data(), GetFormulaSpecOld().Data());
    271271}
    272272
     
    447447    if (fWeightsZd)
    448448    {
     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
    449463        const Int_t i = fWeightsZd->GetXaxis()->FindFixBin(fPointing->GetZd());
    450464        w = fWeightsZd->GetBinContent(i);
  • trunk/MagicSoft/Mars/mjobs/MDataSet.cc

    r8666 r8674  
    274274}
    275275
     276//---------------------------------------------------------------------------
     277//
     278// Make sure that the name used for writing doesn't contain a full path
     279//
     280const char *MDataSet::GetName() const
     281{
     282    const char *pos = strrchr(GetRcName(), '/');
     283    return pos>0 ? pos+1 : GetRcName();
     284}
     285
     286
    276287// --------------------------------------------------------------------------
    277288//
     
    299310        return;
    300311    }
     312    gLog << "# Path: " << GetRcName() << endl;
     313    gLog << "# Name: " << GetName() << endl;
     314    gLog << endl;
    301315    gLog << "AnalysisNumber: " << fNumAnalysis << endl << endl;
    302316
  • trunk/MagicSoft/Mars/mjobs/MDataSet.h

    r8666 r8674  
    6767    MDataSet(Int_t num=(UInt_t)-1) : fNumAnalysis(num) { }
    6868    MDataSet(const char *fname, TString sequences="", TString data="");
     69
     70    const char *GetName() const;
     71    const char *GetRcName() const { return fName; }
    6972
    7073    void Copy(TObject &obj) const
     
    153156
    154157    // TObject
    155     void Print(Option_t *o="") const; //*MENU*
     158    void Print(Option_t *o) const;
     159    void Print() const { Print(); } //*MENU*
    156160
    157161    ClassDef(MDataSet, 2)
  • trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc

    r8665 r8674  
    4747#include "MLogManip.h"
    4848
     49#include "MDirIter.h"
     50
    4951#include "MStatusArray.h"
    5052#include "MStatusDisplay.h"
     
    8890    : fCutQ(0), fCut0(0),fCut1(0), fCut2(0), fCut3(0), fCutS(0),
    8991    fEstimateEnergy(0), fCalcHadronness(0), fRefill(kFALSE),
    90     fSimpleMode(kTRUE), fRawMc(kFALSE), fNoThetaWeights(kFALSE)
     92    /*fSimpleMode(kTRUE),*/ fForceTheta(kFALSE),
     93    fRawMc(kFALSE), fNoThetaWeights(kFALSE)
    9194{
    9295    fName  = name  ? name  : "MJSpectrum";
     
    291294
    292295    *fLog << inf << "Using weights: " << w << endl;
    293     *fLog << "Please stand by, this may take a while..." << flush;
     296    *fLog << "Please stand by, this may take a while..." << endl;
    294297
    295298    if (fDisplay)
    296         fDisplay->SetStatusLine1("Compiling MC distribution...");
     299        fDisplay->SetStatusLine1("Getting maximum impact...");
    297300
    298301    // Create chain
    299     TChain chain("OriginalMC");
     302    *fLog << "Getting files... " << flush;
     303    TChain chain("RunHeaders");
    300304    if (!set.AddFilesOn(chain))
    301305        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;
     313    MDirIter iter;
     314    if (!set.AddFilesOn(iter))
     315        return kFALSE;
     316    *fLog << "done. " << endl;
    302317
    303318    // Prepare histogram
    304319    h.Reset();
    305320    h.Sumw2();
    306 
    307     // Fill histogram from chain
    308     h.SetDirectory(gROOT);
    309321    if (h.InheritsFrom(TH2::Class()))
    310322    {
     
    312324        h.SetXTitle("\\Theta [\\circ]");
    313325        h.SetYTitle("E [GeV]");
    314         h.SetZTitle("Counts");
    315         chain.Draw("MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC", w, "goff");
     326        h.SetZTitle(Form("Counts normalized to r=%.0fm", impactmax/100));
    316327    }
    317328    else
     
    319330        h.SetNameTitle("ThetaMC", "Event-Distribution vs Theta for MC (produced)");
    320331        h.SetXTitle("\\Theta [\\circ]");
    321         h.SetYTitle("Counts");
    322         chain.Draw("MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC", w, "goff");
     332        h.SetYTitle(Form("Counts normalized to r=%.0fm", impactmax/100));
    323333    }
    324334    h.SetDirectory(0);
    325335
    326     *fLog << "done." << endl;
     336    const TString cont = h.InheritsFrom(TH2::Class()) ?
     337        "MMcEvtBasic.fEnergy:MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaEMC" :
     338        "MMcEvtBasic.fTelescopeTheta*TMath::RadToDeg()>>ThetaMC";
     339
     340    if (fDisplay)
     341        fDisplay->SetStatusLine1("Reading OriginalMC");
     342
     343    TH1 *hfill = (TH1*)h.Clone(h.InheritsFrom(TH2::Class())?"ThetaEMC":"ThetaMC");
     344    hfill->SetDirectory(0);
     345
     346    TString fname;
     347    while (1)
     348    {
     349        fname = iter.Next();
     350        if (fname.IsNull())
     351            break;
     352
     353        TFile file(fname);
     354        if (file.IsZombie())
     355        {
     356            *fLog << err << "ERROR - Couldn't open file " << fname << endl;
     357            return kFALSE;
     358        }
     359
     360        TTree *rh = dynamic_cast<TTree*>(file.Get("RunHeaders"));
     361        if (!rh)
     362        {
     363            *fLog << err << "ERROR - File " << fname << " doesn't contain tree RunHeaders." << endl;
     364            return kFALSE;
     365        }
     366
     367        if (rh->GetEntries()!=1)
     368        {
     369            *fLog << err << "ERROR - RunHeaders of " << fname << " doesn't contain exactly one entry." << endl;
     370            return kFALSE;
     371        }
     372
     373        TTree *t = dynamic_cast<TTree*>(file.Get("OriginalMC"));
     374        if (!t)
     375        {
     376            *fLog << err << "ERROR - File " << fname << " doesn't contain tree OriginalMC." << endl;
     377            return kFALSE;
     378        }
     379
     380        *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());
     396
     397        // Fill histogram from tree
     398        hfill->SetDirectory(&file);
     399        t->Draw(cont, weights, "goff");
     400        hfill->SetDirectory(0);
     401        h.Add(hfill);
     402    }
     403    delete hfill;
     404
     405    *fLog << "Total number of events from file: " << h.GetEntries() << endl;
    327406    if (fDisplay)
    328407        fDisplay->SetStatusLine2("done.");
     
    333412    *fLog << err << "ERROR - Histogram with original MC distribution empty..." << endl;
    334413
    335     return h.GetEntries()>0;
     414    return kFALSE;
    336415}
    337416
     
    412491    {
    413492        *fLog << err;
    414         *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap";
    415         *fLog << "        with the the Zenith Angle distribution of your observation.";
     493        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos doesn't overlap" << endl;
     494        *fLog << "        with the Zenith Angle distribution of your observation." << endl;
     495        *fLog << "        Maybe the energy binning is not defined or wrong." << endl;
    416496        theta->SetLineColor(kRed);
    417497        return kFALSE;;
     
    424504
    425505    // Compare both histograms
    426     const Double_t prob = proj.Chi2Test(theta, "");
     506    *fLog << inf << "Comparing theta distributions for data and MCs." << endl;
     507    const Double_t prob = proj.Chi2Test(theta, "P");
    427508    if (prob==1)
    428509        return kTRUE;
     
    431512    {
    432513        *fLog << inf;
    433         *fLog << "The Zenith Angle distribution of your Monte Carlos fits well";
    434         *fLog << "with the the Zenith Angle distribution of your observation.";
     514        *fLog << "The Zenith Angle distribution of your Monte Carlos fits well" << endl;
     515        *fLog << "with the Zenith Angle distribution of your observation." << endl;
     516        *fLog << "The probability for identical Theta distributions is " << prob << endl;
    435517        return kTRUE;
    436518    }
    437519
    438     // <0.01: passen gar nicht
    439     // ==1: passen perfekt
    440     // >0.99: passer sehr gut
    441 
    442520    if (prob<0.01)
    443521    {
    444522        *fLog << err;
    445         *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos does not fit";
    446         *fLog << "        with the the Zenith Angle distribution of your observation.";
     523        *fLog << "ERROR - The Zenith Angle distribution of your Monte Carlos does not fit" << endl;
     524        *fLog << "        with the Zenith Angle distribution of your observation." << endl;
     525        *fLog << "        The probability for identical Theta distributions is " << prob << endl;
     526        if (!fForceTheta)
     527            *fLog << "        To force processing use --force-theta (with care!)" << endl;
    447528        theta->SetLineColor(kRed);
    448         return kFALSE;
     529        return fForceTheta;
    449530    }
    450531
    451532    *fLog << warn;
    452     *fLog << "WARNING - The Zenith Angle distribution of your Monte Carlos doesn't fits well";
    453     *fLog << "          with the the Zenith Angle distribution of your observation.";
     533    *fLog << "WARNING - The Zenith Angle distribution of your Monte Carlos doesn't fits well" << endl;
     534    *fLog << "          with the Zenith Angle distribution of your observation." << endl;
     535    *fLog << "          The probability for identical Theta distributions is " << prob << endl;
    454536    return kTRUE;
    455537}
     
    11671249    TH2D hist;
    11681250    MH3 mh1("MMcEvtBasic.fTelescopeTheta*kRad2Deg", "MMcEvtBasic.fEnergy");
    1169     if (fSimpleMode)
     1251    //if (fSimpleMode)
    11701252    {
    11711253        // Now we read the MC distribution as produced by corsika again
     
    11891271                }
    11901272        }
    1191     }
     1273    }/*
    11921274    else
    11931275    {
     
    11981280            return kFALSE;
    11991281        weight.SetNameMcEvt();
    1200     }
    1201 
    1202     if (!DisplayResult(fSimpleMode ? hist : (TH2D&)mh1.GetHist()))
     1282    }*/
     1283
     1284    if (!DisplayResult(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/))
    12031285        return kFALSE;
    12041286
     
    12451327    MHCollectionArea area0("TriggerArea");
    12461328    MHCollectionArea area1;
    1247     area0.SetHistAll(fSimpleMode ? hist : (TH2D&)mh1.GetHist());
    1248     area1.SetHistAll(fSimpleMode ? hist : (TH2D&)mh1.GetHist());
     1329    area0.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);
     1330    area1.SetHistAll(/*fSimpleMode ?*/ hist /*: (TH2D&)mh1.GetHist()*/);
    12491331
    12501332    MHEnergyEst      hest;
     
    14001482    TObjArray cont;
    14011483    cont.Add((TObject*)GetEnv());
     1484    cont.Add(&area0);
     1485    cont.Add(&area1);
     1486    cont.Add(&hest);
     1487    cont.Add(const_cast<TEnv*>(GetEnv()));
    14021488
    14031489    if (fDisplay)
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r8434 r8674  
    478478}
    479479
     480//---------------------------------------------------------------------------
     481//
     482// Make sure that the name used for writing doesn't contain a full path
     483//
     484const char *MSequence::GetName() const
     485{
     486    const char *pos = strrchr(GetRcName(), '/');
     487    return pos>0 ? pos+1 : GetRcName();
     488}
     489
     490
    480491// --------------------------------------------------------------------------
    481492//
     
    490501        return;
    491502    }
     503    gLog << "# Path: " << GetRcName() << endl;
     504    gLog << "# Name: " << GetName() << endl;
     505    gLog << endl;
    492506    gLog << "Sequence:       " << fSequence << endl;
    493507    if (fMonteCarlo)
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r8434 r8674  
    7878
    7979    // TObject
    80     void Print(Option_t *o="") const; //*MENU*
     80    void Print(Option_t *o) const;
     81    void Print() const { Print(); } //*MENU*
     82
     83    const char *GetName() const;
     84    const char *GetRcName() const { return fName; }
    8185
    8286    // Genaral interface
  • trunk/MagicSoft/Mars/sponde.cc

    r8673 r8674  
    6868    gLog << "   --print-files             Print Files taken from Sequences ('+' found, '-' missing)" << endl;
    6969    gLog << "   --config=sponde.rc        Resource file [default=sponde.rc]" << endl;
     70    gLog << "   --force-theta             Force execution even with non-fitting theta distributions." << endl;
    7071    gLog << endl;
    7172    gLog << "   --version, -V             Show startup message with version number" << endl;
     
    122123    const Bool_t  kRefill        =  arg.HasOnlyAndRemove("--refill");
    123124//    const Bool_t  kSimple        = !arg.HasOnlyAndRemove("--accurate");
     125    const Bool_t  kForceTheta    =  arg.HasOnlyAndRemove("--force-theta");
    124126    const Bool_t  kRawMc         =  arg.HasOnlyAndRemove("--raw-mc");
    125127
     
    223225    job.SetPathIn(kInfile);
    224226
     227    job.ForceTheta(kForceTheta);
    225228    job.EnableRefilling(kRefill);
    226229//    job.EnableSimpleMode(kSimple);
Note: See TracChangeset for help on using the changeset viewer.