Changeset 893 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
07/23/01 13:54:06 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r892 r893  
    11                                                                  -*-*- END -*-*-
     2 2001/07/23: Thomas Bretz
     3 
     4   * mmontecarlo/MMcThresholdCalc.[cc,h]:
     5     - changed PreProcess action to new stylish lists of containers
     6
     7   * mhist/Makefile:
     8     - removed MEnergies.cc
     9
     10   * mhist/HistLinkDef.h:
     11     - removed MEnergies.cc
     12
     13
     14
    215 2001/07/20: Thomas Bretz
    316 
  • trunk/MagicSoft/Mars/mhist/HistLinkDef.h

    r887 r893  
    1111#pragma link C++ class MHStarMap;
    1212#pragma link C++ class MHMcEnergy;
    13 #pragma link C++ class MHMcEnergies;
    1413#pragma link C++ class MHMcCollectionArea;
    1514#pragma link C++ class MHMcRate;
  • trunk/MagicSoft/Mars/mhist/Makefile

    r887 r893  
    3939           MHMcCollectionArea.cc \
    4040           MHMcEnergy.cc \
    41            MHMcEnergies.cc \
    4241           MHMcRate.cc
    4342
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc

    r867 r893  
    5858// Default Constructor.
    5959//
    60 MMcThresholdCalc::MMcThresholdCalc(const UInt_t dim, const char* name,
     60// Specify the number of trigger conditions you want to use.
     61// The default is 0.
     62//
     63// dim < 0: use only condition number dim (eg "MMcTrig;3")
     64// dim = 0: use only condition without a number ("MMcTrig")
     65// dim > 0: use conditions up to dim
     66//
     67MMcThresholdCalc::MMcThresholdCalc(const Int_t dim, const char* name,
    6168                                   const char* title) : fDimension(dim)
    6269{
    6370    *fName  = name  ? name  : "MMcThresholdCalc";
    6471    *fTitle = title ? title : "Task to calculate the energy threshold from Monte Carlo";
    65 
    66     // Arrays of MMcTrig* and MHMcEnergy* are created in order to be
    67     // able to work with root files with several trigger conditions.
    68     fMcTrig     = new MMcTrig*[fDimension];
    69     fHMcEnergy  = new MHMcEnergy*[fDimension];
    70     fMustDelete = new Bool_t[fDimension];
    71 
    72     for (unsigned int i=0; i<fDimension; i++)
    73         fMustDelete[i]=kFALSE;
    7472}
    7573
    7674// -------------------------------------------------------------------------
    7775//
    78 // Default Destructor.
     76// Destructor.
    7977//
    8078MMcThresholdCalc::~MMcThresholdCalc()
    8179{
    82     for (unsigned int i=0; i<fDimension; i++)
    83         if (fMustDelete[i])
    84             delete fHMcEnergy[i];
     80    if (fMcTrig)
     81        delete fMcTrig;
    8582
    86     delete fMcTrig;
    87     delete fHMcEnergy;
    88     delete fMustDelete;
     83    if (fEnergy)
     84        delete fEnergy;
    8985}
    9086
     
    9591Bool_t MMcThresholdCalc::PreProcess(MParList* pList)
    9692{
     93    //
    9794    // This task takes into accout if the root file has one trigger
    9895    // condition (MMcTrig) or severl of them (MMcTrig;#.)
     
    105102    }
    106103
    107     char auxname[15]="MMcTrig"; // string to write container names
    108104
    109     for (unsigned int i=0; i<fDimension; i++)
     105    const UInt_t from = fDimension<=0 ? -fDimension : 0;
     106
     107    if (fDimension<=0)
     108        fDimension = -fDimension;
     109
     110    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, fDimension));
     111    if (fMcTrig->GetEntriesFast() != fDimension)
    110112    {
    111         if (fDimension>1)
    112             sprintf(auxname+7, ";%i", i+1);
    113 
    114         fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
    115         if (fMcTrig[i])
    116             continue;
    117 
    118         *fLog << dbginf << "'MMcTrig";
    119         if (fDimension>1)
    120             *fLog << ";" << i+1;
    121         *fLog << "' not found... aborting." << endl;
    122 
     113        *fLog << dbginf << "Error: Not all requested MMcTrig objects are available...aborting." << endl;
    123114        return kFALSE;
    124115    }
    125116
    126     strcpy(auxname, "MHMcEnergy");
    127     for (unsigned int i=0; i<fDimension; i++)
    128     {
    129         if (fDimension>1&&i!=0)
    130             sprintf(auxname+10, ";%i", i);
    131 
    132         fHMcEnergy[i] = (MHMcEnergy*)pList->FindObject(auxname);
    133         if (fHMcEnergy[i])
    134             continue;
    135 
    136         *fLog << dbginf << "'" << auxname << "' not found in list... creating." << endl;
    137 
    138         fHMcEnergy[i] = new MHMcEnergy(fDimension>1&&i!=0 ? i : 0);
    139         fMustDelete[i] = kTRUE;
    140         pList->AddToList(fHMcEnergy[i]);
    141     }
     117    fEnergy = new TObjArray(pList->FindCreateObjList("MHMcEnergy", from, fDimension));
     118    if (fMcTrig->GetEntriesFast() != fDimension)
     119        return kFALSE;
    142120
    143121    return kTRUE;
     
    156134    const Float_t reciproc = 1./energy;
    157135
    158     for (unsigned int i=0; i<fDimension; i++)
    159         if (fMcTrig[i]->GetFirstLevel()>0)
    160             fHMcEnergy[i]->Fill(lg10, reciproc);
     136    for (Int_t i=0; i<fDimension; i++)
     137        if (GetTrig(i)->GetFirstLevel()>0)
     138            GetHEnergy(i)->Fill(lg10, reciproc);
    161139
    162140    return kTRUE;
     
    170148Bool_t MMcThresholdCalc::PostProcess()
    171149{
    172     for (unsigned int i=0; i<fDimension; i++)
     150    for (Int_t i=0; i<fDimension; i++)
    173151    {
    174       Float_t peak;
    175       Float_t sigma;
     152        MHMcEnergy &hist = *GetHEnergy(i);
    176153
    177       fHMcEnergy[i]->Fit(1, 3);
    178      
    179       peak  = fHMcEnergy[i]->GetGaussPeak();
    180       sigma = fHMcEnergy[i]->GetGaussSigma();
    181       fHMcEnergy[i]->Fit(peak - 2.   *sigma, peak + 2.   *sigma);
    182        
    183       peak  = fHMcEnergy[i]->GetGaussPeak();
    184       sigma = fHMcEnergy[i]->GetGaussSigma();
    185       fHMcEnergy[i]->Fit(peak - fSqrt2*sigma, peak + fSqrt2*sigma);
     154        Float_t peak;
     155        Float_t sigma;
     156
     157        hist.Fit(1, 3);
     158
     159        peak  = hist.GetGaussPeak();
     160        sigma = hist.GetGaussSigma();
     161        hist.Fit(peak - 2.   *sigma, peak + 2.   *sigma);
     162
     163        peak  = hist.GetGaussPeak();
     164        sigma = hist.GetGaussSigma();
     165        hist.Fit(peak - fSqrt2*sigma, peak + fSqrt2*sigma);
    186166    }
    187167    return kTRUE;
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h

    r866 r893  
    1313#include "MTask.h"
    1414#endif
     15#ifndef ROOT_TObjArray
     16#include "TObjArray.h"
     17#endif
    1518
    1619class MMcEvt;
     
    2124{
    2225private:
    23     UInt_t fDimension;
     26    Int_t fDimension;
    2427
    2528    const MMcEvt  *fMcEvt;       // Container with Monte Carlo information
    26     MMcTrig      **fMcTrig;      // Container with Monte Carlo trigger information
    27     MHMcEnergy   **fHMcEnergy;   // Container where we save the energy (threshold)
    2829
    29     Bool_t        *fMustDelete;  // delete indicator for selfcreated energy hists
     30    TObjArray    *fMcTrig;       // Container with Monte Carlo trigger information
     31    TObjArray    *fEnergy;       // Container where we save the energy (threshold)
    3032
    3133    const static Float_t fSqrt2; // sqrt(2)
    3234
     35    MMcTrig    *GetTrig   (UInt_t i) { return (MMcTrig*)   (*fMcTrig)[i]; }
     36    MHMcEnergy *GetHEnergy(UInt_t i) { return (MHMcEnergy*)(*fEnergy)[i]; }
     37
    3338public:
    3439
    35     MMcThresholdCalc(const UInt_t dim = 1,
     40    MMcThresholdCalc(const Int_t dim = 0,
    3641                     const char* name = NULL, const char* title = NULL);
    3742    ~MMcThresholdCalc();
Note: See TracChangeset for help on using the changeset viewer.