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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.