Changeset 2268 for trunk


Ignore:
Timestamp:
07/07/03 16:22:51 (21 years ago)
Author:
moralejo
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2267 r2268  
    11                                                 -*-*- END OF LINE -*-*-
     2
     3 2003/07/06: Abelardo Moralejo
     4
     5   * mhistmc/MHMcCT1CollectionArea.[h,cc]
     6     - Added possibility of using a logarithmic or linear scale in
     7       energy. The function MHMcCT1CollectionArea::SetEaxis sets
     8       what should be filled in the energy axis (either the energy
     9       or its decimal logarithm).
     10
     11   * macros/CT1collarea.C
     12     - Added example on how to use the new function
     13       MHMcCT1CollectionArea::SetEaxis
    214
    315 2003/07/06: Thomas Bretz
  • trunk/MagicSoft/Mars/macros/CT1collarea.C

    r2261 r2268  
    2424\* ======================================================================== */
    2525
     26#include "/home/magic/Mars/mhistmc/MHMcCT1CollectionArea.h"
    2627
    2728void CT1collarea(TString filename="MC_SC4.root", TString outname="")
    2829{
     30
    2931    //
    3032    // first we have to create our empty lists
     
    4749    MBinning binsx("BinningE");
    4850
    49     //    binsx.SetEdges(30,2.,5.);
    50     //    Double_t xedge[10] =
    51     //    {2.50515, 2.69897, 2.89763, 3.09691, 3.30103, 3.49969, 3.69984, 3.89982, 4.10003, 4.29994};
    52 
    53 
     51    /*
    5452    Double_t xedge[15] = {2.47712, 2.64345, 2.82607, 3., 3.17609, 3.35218, 3.52892, 3.70415, 3.88024, 4.05652, 4.23274, 4.40875, 4.58478, 4.76080, 4.90309};
    55 
    5653    const TArrayD xed;
    5754    xed.Set(15,xedge);
    5855    binsx.SetEdges(xed);
     56    collarea->SetEaxis(kLog10Energy);
     57    */
     58
     59    //
     60    // SetEaxis tells MHMcCT1CollectionArea whether the variable to histogram
     61    // is the Energy (argument is kEnergy) or its decimal logarithm
     62    // (kLog10Energy). Of course this depends on how the energy binning is
     63    // defined via the object binsx.
     64    //
     65    binsx.SetEdgesLog(14,300,1.e5);
     66    collarea->SetEaxis(kEnergy);
     67
    5968
    6069    MBinning binsy("BinningTheta");
  • trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.cc

    r2261 r2268  
    6666  fTitle = title ? title : "Collection Area vs. log10 Energy";
    6767
     68  fEaxis = kLog10Energy;
     69
    6870  fHistAll = new TH2D;
    6971  fHistSel = new TH2D;
     
    9395  fHistCol->SetYTitle("theta [deg]");
    9496  fHistCol->SetZTitle("A [m^{2}]");
     97
    9598}
    9699
     
    130133    fHistCol->Sumw2();
    131134
     135    if (fEaxis == kEnergy)
     136      {
     137        fTitle = "Collection Area vs. Energy";
     138        fHistCol->SetTitle(fTitle);
     139        fHistAll->SetTitle("All showers - Theta vs Energy distribution");
     140        fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
     141        fHistCol->SetXTitle("E [GeV]");
     142        fHistAll->SetXTitle("E [GeV]");
     143        fHistSel->SetXTitle("E [GeV]");
     144      }
     145
    132146    return kTRUE;
    133147}
     
    142156  MMcEvt &mcevt = *(MMcEvt*)par;
    143157
    144   fHistSel->Fill(log10(mcevt.GetEnergy()), kRad2Deg*mcevt.GetTelescopeTheta(), w);
     158  if (fEaxis == kLog10Energy)
     159    fHistSel->Fill(log10(mcevt.GetEnergy()), kRad2Deg*mcevt.GetTelescopeTheta(), w);
     160  else
     161    fHistSel->Fill(mcevt.GetEnergy(), kRad2Deg*mcevt.GetTelescopeTheta(), w);
     162
    145163  return kTRUE;
    146164}
     
    193211
    194212  c.cd(1);
     213  if (fEaxis == kEnergy)
     214    gPad->SetLogx();
    195215  fHistCol->SetDirectory(NULL);
    196216  fHistCol->DrawCopy(option);
    197217
    198218  c.cd(2);
     219  if (fEaxis == kEnergy)
     220    gPad->SetLogx();
    199221  fHistSel->SetDirectory(NULL);
    200222  fHistSel->DrawCopy(option);
    201223
    202224  c.cd(3);
     225  if (fEaxis == kEnergy)
     226    gPad->SetLogx();
    203227  fHistAll->SetDirectory(NULL);
    204228  fHistAll->DrawCopy(option);
     
    435459      for (Int_t i=1; i <= fHistAll->GetNbinsX(); i++)
    436460        {
    437           Float_t e1 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i));
    438           Float_t e2 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i+1));
     461          Float_t e1;
     462          Float_t e2;
     463
     464          if (fEaxis == kLog10Energy)
     465            {
     466              e1 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i));
     467              e2 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i+1));
     468            }
     469          else
     470            {
     471              e1 = fHistAll->GetXaxis()->GetBinLowEdge(i);
     472              e2 = fHistAll->GetXaxis()->GetBinLowEdge(i+1);
     473            }
    439474
    440475          Float_t events = 0.;
  • trunk/MagicSoft/Mars/mhistmc/MHMcCT1CollectionArea.h

    r2043 r2268  
    55#include "MH.h"
    66#endif
     7
     8enum {
     9  kLog10Energy,
     10  kEnergy
     11};
    712
    813class TH2D;
     
    1520    TH2D *fHistCol; //  the collection area
    1621
     22    Byte_t  fEaxis;
     23
    1724public:
    1825    MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL);
     
    2431    void DrawAll(Option_t *option="");
    2532    void DrawSel(Option_t *option="");
     33
     34    void SetEaxis(Byte_t x) { fEaxis = x; }
    2635
    2736    const TH2D *GetHist() const { return fHistCol; }
Note: See TracChangeset for help on using the changeset viewer.