Ignore:
Timestamp:
07/10/01 12:41:13 (23 years ago)
Author:
jlopez
Message:
*** empty log message ***
File:
1 edited

Legend:

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