Changeset 861


Ignore:
Timestamp:
07/10/01 12:41:13 (23 years ago)
Author:
jlopez
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/getThreshold.C

    r855 r861  
    1 void getThreshold( char* filename = "data/oscar_protons.root")
     1void getThreshold( char* filename = "/hdb1/users/jlopez/temp_loop.root")
    22{
    33    //
    4     // This macro fill the container MMcEnerThre using the task
    5     // MMcEnerThreCalc and shows the results.
     4    // This macro fill the container MHMcEnergies using the task
     5    // MMcThresholdCalc and shows the results.
    66    //
    77    MParList  parlist;
     
    1212    //
    1313    // Setup the parameter list
    14     // - You need create the container MMcEnerThre.
     14    // - You need create the container MHMcEnergies.
    1515    //    + You need to put the number of trigger conditions when
    1616    //      you declarete the MHMcEnergies
     
    1818    //      taking only the trigger information from MMcTrig
    1919    //
    20     const UInt_t numtriggerconditions = 1;
     20    const UInt_t numtriggerconditions = 5;
    2121
    2222    MHMcEnergies *hists = new MHMcEnergies(numtriggerconditions);
     
    4949    // Now you can display the results
    5050    //
    51     for (UInt_t i=0; i<numtriggerconditions; i++)
     51    for (UInt_t i=0; i<numtriggerconditions; i++) {
    5252        ((*hists)[i]).Draw();
     53        if (getchar()=='q') break;
     54    }
    5355}
  • trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc

    r859 r861  
    2323\* ======================================================================== */
    2424
     25/////////////////////////////////////////////////////////////////////////////
     26//
     27//  MHMcEnergies
     28//
     29// This class holds and array of MHMcEnergy objects in order to be able
     30// to compute the threshold for each of the different trigger conditions
     31// in a root file.
     32//
     33////////////////////////////////////////////////////////////////////////////
    2534#include "MHMcEnergies.h"
    2635
     
    3039ClassImp(MHMcEnergies);
    3140
     41// --------------------------------------------------------------------------
     42//
     43// Default Constructor.
     44//
    3245MHMcEnergies::MHMcEnergies(const UInt_t count, const char *name, const char *title)
    3346    : fNum(count)
    3447{
    35     //
    36     //   default constructor
    37     //
    3848    char aux[25]="MHMcEnergies";
    3949    sprintf(aux+12, "[%i]", fNum);
     
    4858}
    4959
     60// --------------------------------------------------------------------------
     61//
     62// Default Destructor.
     63//
    5064MHMcEnergies::~MHMcEnergies()
    5165{
    5266    delete fHists;
    5367}
    54 
     68// --------------------------------------------------------------------------
     69//
     70// Add to the parameter list all the MHMcEnergy objects contained in the array.
     71//
    5572void MHMcEnergies::AddEntriesToList(MParList *plist)
    5673{
  • trunk/MagicSoft/Mars/mhist/MHMcEnergies.h

    r855 r861  
    2020{
    2121private:
    22     UInt_t        fNum;
    23     TClonesArray *fHists; // histograms
     22    UInt_t        fNum;   // Num of histograms
     23    TClonesArray *fHists; // Array with the energy histograms
    2424
    2525public:
     
    3636
    3737#endif
     38
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc

    r859 r861  
    2323\* ======================================================================== */
    2424
     25/////////////////////////////////////////////////////////////////////////////
     26//
     27//  MHMcEnergy
     28//
     29// This class holds the information ( histogram and fit function ) 
     30// about the energy threshold for a particular trigger condition.
     31//
     32////////////////////////////////////////////////////////////////////////////
    2533#include "MHMcEnergy.h"
    2634
     
    3442ClassImp(MHMcEnergy);
    3543
     44// -------------------------------------------------------------------------
     45//
     46//  Default Constructor.
     47//
    3648MHMcEnergy::MHMcEnergy(const UInt_t idx, const char *name, const char *title)
    3749{
    38     //
    39     //   default constructor
    40     //
    4150    char aux[15]="MHMcEnergy";
    4251
     
    5867    if (idx>0)
    5968        sprintf(aux+10, ";%i", idx);
    60     hLogEner = new TH1F(aux, "", 100, 0.5, 4.5);
     69    hLogEner = new TH1F(aux, "", 40, 0.5, 4.5);
    6170    hLogEner->SetXTitle("log(E) [GeV]");
    6271    hLogEner->SetYTitle("dN/dE");
    63     //hLogEner->SetBins(60);
    6472}
    6573
     74//-------------------------------------------------------------------------
     75//
     76//  Defualt Destructor
     77//
    6678MHMcEnergy::~MHMcEnergy()
    6779{
     
    7082}
    7183
     84//--------------------------------------------------------------------------
     85//
     86//  Fill the histogram with the log10 of the energy for triggered events.
     87//
    7288void MHMcEnergy::Fill(Float_t log10E, Float_t w)
    7389{
     
    7591}
    7692
     93// -------------------------------------------------------------------------
     94//
     95// Fitting function
     96//
    7797void MHMcEnergy::Fit(Axis_t xxmin, Axis_t xxmax)
    7898{
    7999    //
    80100    // 0: don't draw the function (it is drawn together with the histogram)
    81     // +: add these function to the list of fits. Don't delete the last fit.
     101    // Q: quiet mode
    82102    //
    83     // FIXME: R means: use the range specified in the function (xxmin, xxmax are ignored!)
    84     //        Q means: quiet (why?)
    85     //
    86     //
    87     hLogEner->Fit(fLogEner->GetName(), "Q0+", "", xxmin, xxmax);
     103    hLogEner->Fit(fLogEner->GetName(), "Q0", "", xxmin, xxmax);
    88104}
    89105
     106// ------------------------------------------------------------------------
     107//
     108// Drawing function. It creates its own canvas.
     109//
    90110void MHMcEnergy::Draw(Option_t *option)
    91111{
     
    111131}
    112132
     133// --------------------------------------------------------------------------
     134//
     135// Set the number of bins in the histogran.
     136//
     137void MHMcEnergy::SetBins(Int_t nbins)
     138{
     139  hLogEner->SetBins(nbins,0.5,4.5);
     140}
     141// --------------------------------------------------------------------------
     142//
     143// Write the threshold and its error in the standard output
     144//
    113145void MHMcEnergy::Print(Option_t*)
    114146{
     
    116148}
    117149
     150// -------------------------------------------------------------------------
     151//
     152//  Return the threshold
     153//
    118154Float_t MHMcEnergy::GetThreshold() const
    119155{
     
    123159}
    124160
     161// -------------------------------------------------------------------------
     162//
     163// Return the error of the threshold.
     164//
    125165Float_t MHMcEnergy::GetThresholdErr() const
    126166{
     
    129169    const Float_t p1err = fLogEner->GetParError(1);
    130170
     171    // The error has into accuont the error in the fit
    131172    return pow(10, p1) * p1err * lg10;
    132173}
    133174
     175// -------------------------------------------------------------------------
     176//
     177// Return the peak of the fitted gaussan function.
     178//
    134179Float_t MHMcEnergy::GetGaussPeak() const
    135180{
     
    137182}
    138183
     184// -------------------------------------------------------------------------
     185//
     186// Return the sigma of the fitted gaussan function.
     187//
    139188Float_t MHMcEnergy::GetGaussSigma() const
    140189{
     
    142191}
    143192
     193
     194
     195
  • trunk/MagicSoft/Mars/mhist/MHMcEnergy.h

    r851 r861  
    3232    void Fill(Float_t log10E, Float_t w);
    3333    void Fit(Axis_t xxmin, Axis_t xxmax);
     34    void SetBins(Int_t nbins = 100);
    3435
    3536    void Draw(Option_t* option = "");
    3637    void Print(Option_t* option = NULL);
    3738
    38     ClassDef(MHMcEnergy, 1)  // Histogram container for montecarlo energy
     39    ClassDef(MHMcEnergy, 1)  // Histogram container for montecarlo energy threshold
    3940};
    4041
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc

    r859 r861  
    2424\* ======================================================================== */
    2525
    26 /////////////////////////////////////////////////////////////////////////////
    27 //                                                                         //
    28 //  MMcThresholdCalc                                                       //
    29 //                                                                         //
    30 //  Input Containers:                                                      //
    31 //   MMcEvt                                                                //
    32 //                                                                         //
    33 //  Output Containers:                                                     //
    34 //   MMcTrig;*, MHMcEnergy;*                                               //
    35 //                                                                         //
     26///////////////////////////////////////////////////////////////////////////
     27//
     28//  MMcThresholdCalc
     29//                                                                         
     30//  Input Containers:
     31//   MMcEvt, MMcTrig;*
     32//
     33//  Output Containers:
     34//   MHMcEnergies
     35//
    3636/////////////////////////////////////////////////////////////////////////////
    3737
     
    5252ClassImp(MMcThresholdCalc)
    5353
     54// --------------------------------------------------------------------------
     55//
     56// Default Constructor.
     57//
    5458MMcThresholdCalc::MMcThresholdCalc(const UInt_t dim, const char* name,
    5559                                   const char* title) : fDimension(dim)
     
    5862    *fTitle = title ? title : "Task to calculate the energy threshold from Monte Carlo";
    5963
     64    // Arrays of MMcTrig* and MHMcEnergy* are created in order to be
     65    // able to work with root files with several trigger conditions.
    6066    fMcTrig     = new MMcTrig*[fDimension];
    6167    fHMcEnergy  = new MHMcEnergy*[fDimension];
     
    6672}
    6773
     74// -------------------------------------------------------------------------
     75//
     76// Default Destructor.
     77//
    6878MMcThresholdCalc::~MMcThresholdCalc()
    6979{
     
    8191    // connect Monte Carlo data with this task
    8292
     93    // This task has into accout if the root file has one trigger
     94    // condition (MMcTrig) or severl of them (MMcTrig;#.)
     95
    8396    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
    8497    if (!fMcEvt)
     
    93106    {
    94107        if (fDimension>1)
    95             sprintf(auxname+7, ";%i", i+1);
     108            sprintf(auxname+7, ";%i.", i+1);
    96109
    97110        fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
     
    110123    for (unsigned int i=0; i<fDimension; i++)
    111124    {
    112         if (fDimension>1)
    113             sprintf(auxname+10, ";%i", i+1);
     125        if (fDimension>1&&i!=0)
     126            sprintf(auxname+10, ";%i", i);
    114127
    115128        fHMcEnergy[i] = (MHMcEnergy*)pList->FindObject(auxname);
     
    119132        *fLog << dbginf << "'" << auxname << "' not found in list... creating." << endl;
    120133
    121         fHMcEnergy[i] = new MHMcEnergy(fDimension>1 ? i+1 : 0);
     134        fHMcEnergy[i] = new MHMcEnergy(fDimension>1&&i!=0 ? i : 0);
    122135        fMustDelete[i] = kTRUE;
    123136        pList->AddToList(fHMcEnergy[i]);
     
    129142Bool_t MMcThresholdCalc::Process()
    130143{
     144
     145    // The histograms are filled with log10 of the energy for triggered
     146    // events and weighted with 1/E because it is needed the dN/dE vs. logE
     147    // distribution to get the energy threshold.
     148
    131149    const Float_t energy   = fMcEvt->GetEnergy();
    132150    const Float_t lg10     = log10(energy);
     
    147165{
    148166    // fit the energy distribution to get the threshold
     167    // Some iterations are done to be sure the fit parameters converge.
    149168
    150169    const Float_t sqrt2 = sqrt(2);
     
    152171    for (unsigned int i=0; i<fDimension; i++)
    153172    {
    154         MHMcEnergy &h = *fHMcEnergy[i];
     173      Float_t peak;
     174      Float_t sigma;
    155175
    156         const Float_t peak  = h.GetGaussPeak();
    157         const Float_t sigma = h.GetGaussSigma();
    158 
    159         h.Fit(1, 3);
    160         h.Fit(peak - 2.   *sigma, peak + 2.   *sigma);
    161         h.Fit(peak - sqrt2*sigma, peak + sqrt2*sigma);
     176      fHMcEnergy[i]->Fit(1, 3);
     177     
     178      peak  = fHMcEnergy[i]->GetGaussPeak();
     179      sigma = fHMcEnergy[i]->GetGaussSigma();
     180      fHMcEnergy[i]->Fit(peak - 2.   *sigma, peak + 2.   *sigma);
     181       
     182      peak  = fHMcEnergy[i]->GetGaussPeak();
     183      sigma = fHMcEnergy[i]->GetGaussSigma();
     184      fHMcEnergy[i]->Fit(peak - sqrt2*sigma, peak + sqrt2*sigma);
    162185    }
    163186    return kTRUE;
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h

    r859 r861  
    3939    Bool_t PostProcess();
    4040
    41     ClassDef(MMcThresholdCalc, 0) // Task to fill the energy threshold information
     41    ClassDef(MMcThresholdCalc, 0) // Task to compute the energy threshold
    4242};
    4343
Note: See TracChangeset for help on using the changeset viewer.