Ignore:
Timestamp:
10/11/06 08:55:36 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc

    r7650 r8047  
    176176    fLog->Separator("Initialize energy weighting");
    177177
     178    // Read Resources
    178179    if (!CheckEnv(w))
    179180    {
     
    182183    }
    183184
     185    // Read the first corsika RunHeader from the MC files
    184186    TChain chain("RunHeaders");
    185187    set.AddFilesOn(chain);
     
    195197    }
    196198
     199    // Propagate the run header to MMcSpectrumWeight
    197200    if (!w.Set(*h))
    198201    {
     
    201204    }
    202205
     206    // Print new setup of MMcSpectrumWeight
    203207    w.Print();
    204208    return kTRUE;
     
    266270    fLog->Separator("Compiling original MC distribution");
    267271
     272    // The name of the input container is MMcEvtBasic
    268273    weight.SetNameMcEvt("MMcEvtBasic");
     274    // Get the corresponding rule for the weights
    269275    const TString w(weight.GetFormulaWeights());
     276    // Set back to MMcEvt
    270277    weight.SetNameMcEvt();
    271278
     
    282289    // Prepare histogram
    283290    h.Reset();
     291    h.Sumw2();
    284292
    285293    // Fill histogram from chain
     
    331339        gPad->SetBorderMode(0);
    332340        temp2.SetName("NVsTheta");
    333         temp2.DrawCopy();
     341        temp2.DrawCopy("hist");
    334342
    335343        c.cd(4);
     
    349357    temp1.SetYTitle("Probability");
    350358    if (fDisplay)
    351         temp1.DrawCopy();
     359        temp1.DrawCopy("hist");
    352360
    353361    return kTRUE;
     
    580588    case 0:
    581589        {
    582             const TString fmt0 = Form("(%%%sf#pm%%%sf)\\bullet10^{%%d}",   f1, f1);
     590            const TString fmt0 = Form("(%%%sf#pm%%%sf)\\bullet10^{%%d}",  f1, f1);
    583591            const TString fmt1 = Form("(\\frac{E}{TeV})^{%%%sf#pm%%%sf}", f0, f0);
    584592
     
    638646TArrayD MJSpectrum::DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const
    639647{
     648    // Create copies of the histograms
    640649    TH1D collarea(area.GetHEnergy());
    641650    TH1D spectrum(excess);
    642651    TH1D weights;
     652
     653    // Get spill-over corrections from energy estimation
    643654    hest.GetWeights(weights);
    644655
     656    // Print effective on-time
    645657    cout << "Effective On time: " << ontime << "s" << endl;
    646658
     659    // Setup spectrum plot
     660    spectrum.SetNameTitle("Preliminary", "N/sm^{2} versus Energy (before unfolding)");
     661    spectrum.SetYTitle("N/sm^{2}");
    647662    spectrum.SetDirectory(NULL);
    648663    spectrum.SetBit(kCanDelete);
     664
     665    // Divide by collection are and on-time
    649666    spectrum.Scale(1./ontime);
    650667    spectrum.Divide(&collarea);
    651     spectrum.SetNameTitle("Preliminary", "N/sm^{2} versus Energy (before unfolding)");
    652     spectrum.SetYTitle("N/sm^{2}");
    653 
     668
     669    // Draw spectrum before applying spill-over corrections
    654670    TCanvas &c1 = fDisplay->AddTab("Spectrum");
    655671    c1.Divide(2,2);
     
    679695    weights.DrawCopy();
    680696
     697    // Apply spill-over correction (done't take the errors into account)
     698    // They are supposed to be identical with the errors of the
     699    // collection area and cancel out.
    681700    //spectrum.Multiply(&weights);
    682701    spectrum.SetNameTitle("Flux", "Spectrum (after unfolding)");
     
    840859
    841860    //h2->Scale(1./ontime);   //h2->Integral());
    842     h3->Scale(scale);    //h3->Integral());
     861    h3->Scale(scale);         //h3->Integral());
    843862
    844863    h2->SetMaximum(1.05*TMath::Max(h2->GetMaximum(), h3->GetMaximum()));
     
    10011020    plist.AddToList(&bins2);
    10021021
     1022    // Initialize weighting to a new spectru
     1023    // m as defined in the resource file
    10031024    MMcSpectrumWeight weight;
    10041025    if (!InitWeighting(set, weight))
    10051026        return kFALSE;
    10061027
     1028    // Print the setup of the MAlphaFitter
    10071029    PrintSetup(fit);
    10081030    bins3.SetEdges(temp1, 'x');
    10091031
     1032    // Read the MC distribution as produced by corsika into
     1033    // temp2 (1D) and apply the weights previously determined
    10101034    TH1D temp2(temp1);
    10111035    if (!ReadOrigMCDistribution(set, temp2, weight))
    10121036        return kFALSE;
    10131037
     1038    // Calculate the weights according to the zenith angle distribution
     1039    // of the raw-data which have to be applied to the MC events
    10141040    if (!GetThetaDistribution(temp1, temp2))
    10151041        return kFALSE;
    10161042
     1043    // Tell the weighting task about the ZA-weights
    10171044    if (!fNoThetaWeights)
    10181045        weight.SetWeightsZd(&temp1);
    10191046
     1047    // Refill excess histogram to determin the excess events
    10201048    TH1D excess;
    10211049    if (!Refill(plist, excess))
     
    10261054    if (fSimpleMode)
    10271055    {
     1056        // Now we read the MC distribution as produced by corsika again
     1057        // with the spectral weights applied into a histogram vs.
     1058        // zenith angle and energy
    10281059        hist.UseCurrentStyle();
    10291060        MH::SetBinning(&hist, &bins3/*temp1.GetXaxis()*/, &bins2/*excess.GetXaxis()*/);
     
    10311062            return kFALSE;
    10321063
     1064        // No we apply the the zenith-angle-weights to the corsika produced
     1065        // MC distribution. Unfortunately this must be done manually
     1066        // because we are multiplying column by column
    10331067        if (!fRawMc)
    10341068        {
    10351069            for (int y=0; y<hist.GetNbinsY(); y++)
    10361070                for (int x=0; x<hist.GetNbinsX(); x++)
     1071                {
    10371072                    hist.SetBinContent(x, y, hist.GetBinContent(x, y)*temp1.GetBinContent(x));
    1038             //hist.SetEntries(hist.Integral());
     1073                    hist.SetBinError(x, y,   hist.GetBinError(x, y)  *temp1.GetBinContent(x));
     1074                }
    10391075        }
    10401076    }
    10411077    else
    10421078    {
     1079        // This rereads the original MC spectrumand aaplies both
     1080        // weights spectral weights and ZA-weights.
    10431081        weight.SetNameMcEvt("MMcEvtBasic");
    10441082        if (!IntermediateLoop(plist, mh1, temp1, set, weight))
     
    11461184
    11471185    tlist2.AddToList(&read);
     1186    // If no weighting should be applied but the events should
     1187    // be thrown away according to the theta distribution
     1188    // it is enabled here
    11481189    if (!fRawMc && fNoThetaWeights)
    11491190        tlist2.AddToList(&contsel);
Note: See TracChangeset for help on using the changeset viewer.