Changeset 984 for trunk/MagicSoft


Ignore:
Timestamp:
10/24/01 13:57:43 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

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

    r971 r984  
    2424
    2525
    26 void trigrate(int dim=0, char *filename = "/big0/Maggi/CamData/Gamma/gamma_15_on.root" )
     26void trigrate(int dim=0, char *filename = "data/camera.root" )
    2727{
    2828    // This macro has two input parameter:
     
    6767    // Check if the list really contains the right number of histograms
    6868    //
    69     if (hists.GetEntriesFast() != dim)
     69    if (hists.GetEntriesFast() != dim && dim)
    7070        return;
    7171
     
    8383    //
    8484    MReadTree reader("Events", filename);
     85    reader.UseLeaf("fImpact");
     86    reader.UseLeaf("fEnergy");
     87    reader.UseLeaf("fPhi");
     88    reader.UseLeaf("fTheta");
     89    reader.UseLeaf("fNumFirstLevel");
     90    reader.UseLeaf("fPhotElfromShower");
    8591    tasklist.AddToList(&reader);
    8692
     
    8894    cout << "Number of Trigger conditions: " << dim << endl;
    8995
    90     MMcTriggerRateCalc rate(dim, 14, BgR, 100000, 2.75, 10.91e-2);
     96    MMcTriggerRateCalc rate(dim, 14, BgR, 100000);
    9197    tasklist.AddToList(&rate);
    9298
     
    104110
    105111    TIter Next(&hists);
    106     MHMcRate *rate=NULL;
    107     while ((rate=(MHMcRate*)Next()))
    108         rate->Print();
     112    MHMcRate *r=NULL;
     113    while ((r=(MHMcRate*)Next()))
     114        r->Print();
    109115}
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r959 r984  
    457457//  from 1 to from.
    458458//
    459 TObjArray MParList::FindObjectList(const char *name, const UInt_t from, const UInt_t to) const
     459TObjArray MParList::FindObjectList(const char *name, UInt_t first, const UInt_t last) const
    460460{
    461461    TObjArray list;
    462462
    463     if (to>0 && to<=from)
    464     {
    465         *fLog << dbginf << "Cannot create entries backwards (to<from)...skipped." << endl;
     463    if (first>0 && last<first)
     464    {
     465        *fLog << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
    466466        return list;
    467467    }
     
    472472    strcpy(auxname, name);
    473473
     474    if (first==0 && last!=0)
     475        first = 1;
     476
    474477    //
    475478    // If only 'from' is specified the number of entries are ment
    476479    //
    477     const Bool_t exc = from>0 && to==0;
    478 
    479     const UInt_t first = exc ?    0 : from;
    480     const UInt_t last  = exc ? from : to;
    481 
    482     for (UInt_t num=first; num<last; num++)
    483     {
    484         if (from!=0 || to!=0)
    485             sprintf(auxname+len, ";%d", num+1);
     480    for (UInt_t i=first; i<=last; i++)
     481    {
     482        if (first!=0 || last!=0)
     483            sprintf(auxname+len, ";%d", i);
    486484
    487485        TObject *obj = FindObject(auxname);
     
    505503//  from 1 to from.
    506504//
    507 TObjArray MParList::FindCreateObjList(const char *cname, const UInt_t from, const UInt_t to, const char *oname)
     505TObjArray MParList::FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
    508506{
    509507    TObjArray list;
    510508
    511     if (to>0 && to<=from)
    512     {
    513         *fLog << dbginf << "Cannot create entries backwards (to<from)...skipped." << endl;
     509    if (first>0 && last<first)
     510    {
     511        *fLog << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
    514512        return list;
    515513    }
     
    523521    // If only 'from' is specified the number of entries are ment
    524522    //
    525     const Bool_t exc = from>0 && to==0;
    526 
    527     const UInt_t first = exc ?    0 : from;
    528     const UInt_t last  = exc ? from : to;
    529 
    530     for (UInt_t num=first; num<last; num++)
    531     {
    532         if (from!=0 || to!=0)
    533             sprintf(auxname+len, ";%d", num+1);
     523    if (first==0 && last!=0)
     524        first = 1;
     525
     526    for (UInt_t i=first; i<=last; i++)
     527    {
     528        if (first!=0 || last!=0)
     529            sprintf(auxname+len, ";%d", i);
    534530
    535531        TObject *obj = FindCreateObj(auxname, oname);
     
    558554//  compiled programs if you are not 100% sure what you are doing.
    559555//
    560 TObjArray MParList::CreateObjList(const char *cname, const UInt_t from, const UInt_t to, const char *oname)
     556TObjArray MParList::CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
    561557{
    562558    TObjArray list;
     559
     560    if (first>0 && last<first)
     561    {
     562        gLog << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
     563        return list;
     564    }
    563565
    564566    //
     
    584586    // If only 'from' is specified the number of entries are ment
    585587    //
    586     const Bool_t exc = from>0 && to==0;
    587 
    588     const UInt_t first = exc ?    0 : from;
    589     const UInt_t last  = exc ? from : to;
    590 
    591     for (UInt_t num=first; num<last; num++)
    592     {
    593         if (from!=0 || to!=0)
    594             sprintf(auxname+len, ";%d", num+1);
     588    if (first==0 && last!=0)
     589        first = 1;
     590
     591    for (UInt_t i=first; i<=last; i++)
     592    {
     593        if (first!=0 || last!=0)
     594            sprintf(auxname+len, ";%d", i);
    595595
    596596        //
  • trunk/MagicSoft/Mars/mbase/MParList.h

    r959 r984  
    2020#include "MParContainer.h"
    2121#endif
     22
     23#include <TObjArray.h>
    2224
    2325class MLog;
     
    4951    MParContainer *FindCreateObj(const char *classname, const char *objname=NULL);
    5052
    51     TObjArray FindObjectList(const char *name, const UInt_t from, const UInt_t to=0) const;
    52     TObjArray FindCreateObjList(const char *cname, const UInt_t from, const UInt_t to=0, const char *oname=NULL);
     53    TObjArray FindObjectList(const char *name, UInt_t first, const UInt_t last) const;
     54    TObjArray FindObjectList(const char *name, const UInt_t num) const
     55    {
     56        return FindObjectList(name, 0, num);
     57    }
    5358
    54     static TObjArray CreateObjList(const char *cname, const UInt_t from, const UInt_t to=0, const char *oname=NULL);
     59    TObjArray FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
     60    TObjArray FindCreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
     61    {
     62        return FindCreateObjList(cname, 0, num, oname);
     63    }
     64
     65    static TObjArray CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
     66    static TObjArray CreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
     67    {
     68        return CreateObjList(cname, 0, num, oname);
     69    }
    5570
    5671    void Reset();
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc

    r983 r984  
    103103    }
    104104
     105    UInt_t from = fDimension>0 ?          1 : -fDimension;
     106    UInt_t to   = fDimension>0 ? fDimension : -fDimension;
    105107
    106     const UInt_t from = fDimension<=0 ? -fDimension : 0;
     108    fNum = to-from+1;
    107109
    108     if (fDimension<=0)
    109         fDimension = -fDimension;
     110    Int_t num;
    110111
    111     if (fDimension==0)
    112         fDimension=1;
    113 
    114     fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, fDimension));
    115     if (fMcTrig->GetEntriesFast() != fDimension)
     112    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, to));
     113    num = fMcTrig->GetEntriesFast();
     114    if (num != fNum)
    116115    {
    117         *fLog << dbginf << "Error: Not all requested MMcTrig objects are available...aborting." << endl;
     116        *fLog << dbginf << fNum << " MMcTrig objects requested, ";
     117        *fLog << num << " are available... aborting." << endl;
    118118        return kFALSE;
    119119    }
    120120
    121     fEnergy = new TObjArray(pList->FindCreateObjList("MHMcEnergy", from, fDimension));
    122     if (fMcTrig->GetEntriesFast() != fDimension && fDimension)
     121    fEnergy = new TObjArray(pList->FindCreateObjList("MHMcEnergy", from, to));
     122    num = fMcTrig->GetEntriesFast();
     123    if (num != fNum)
    123124    {
    124         *fLog << dbginf << "Error: Not all requested MHMcEnergy objects are available...aborting." << endl;
     125        *fLog << dbginf << fNum << " MHMcEnergy objects requested, ";
     126        *fLog << num << " are available... aborting." << endl;
    125127        return kFALSE;
    126128    }
     
    141143    const Float_t reciproc = 1./energy;
    142144
    143     for (Int_t i=0; i<fDimension; i++)
     145    for (Int_t i=0; i<fNum; i++)
    144146        if (GetTrig(i)->GetFirstLevel()>0)
    145147            GetHEnergy(i)->Fill(lg10, reciproc);
     
    155157Bool_t MMcThresholdCalc::PostProcess()
    156158{
    157     for (Int_t i=0; i<fDimension; i++)
     159    for (Int_t i=0; i<fNum; i++)
    158160    {
    159161        MHMcEnergy &hist = *GetHEnergy(i);
  • trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h

    r893 r984  
    2525private:
    2626    Int_t fDimension;
     27    Int_t fNum;
    2728
    2829    const MMcEvt  *fMcEvt;       // Container with Monte Carlo information
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc

    r983 r984  
    4343    *fTitle = title ? title : "Task to calc the trigger rate ";
    4444
    45     fDimension=dim;
     45    fDimension = dim;
    4646
    4747    for (int i=0;i<10;i++)
     
    111111    }
    112112
    113     const UInt_t from = fDimension<=0 ? -fDimension : 0;
    114 
    115     if (fDimension<=0)
    116         fDimension = -fDimension;
    117 
    118     if (fDimension==0)
    119         fDimension=1;
    120 
    121     fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, fDimension));
    122     if (fMcTrig->GetEntriesFast() != fDimension)
    123     {
    124         *fLog << dbginf << "Error: Not all requested MMcTrig objects are available...aborting." << endl;
     113    UInt_t from = fDimension>0 ?          1 : -fDimension;
     114    UInt_t to   = fDimension>0 ? fDimension : -fDimension;
     115
     116    fNum = to-from+1;
     117
     118    Int_t num;
     119
     120    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, to));
     121    num = fMcTrig->GetEntriesFast();
     122    if (num != fNum)
     123    {
     124        *fLog << dbginf << fNum << " MMcTrig objects requested, ";
     125        *fLog << num << " are available... aborting." << endl;
    125126        return kFALSE;
    126127    }
    127128
    128     fMcRate = new TObjArray(pList->FindObjectList("MHMcRate", from, fDimension));
    129     if (fMcRate->GetEntriesFast() != fDimension)
    130     {
    131         *fLog << dbginf << "Error: Not all requested MHMcRate objects are available...aborting." << endl;
     129    fMcRate = new TObjArray(pList->FindObjectList("MHMcRate", from, to));
     130    num = fMcRate->GetEntriesFast();
     131    if (num != fNum)
     132    {
     133        *fLog << dbginf << fNum << " MHMcRate objects requested, ";
     134        *fLog << num << " are available... aborting." << endl;
    132135        return kFALSE;
    133136    }
    134137
    135     for (int i=0; i<fDimension; i++)
     138    for (int i=0; i<fNum; i++)
    136139    {
    137140        MHMcRate &rate = *GetRate(i);
     
    175178    //  Counting number of triggers
    176179    //
    177     for (int i=0; i<fDimension; i++)
     180    for (int i=0; i<fNum; i++)
    178181    {
    179182        fTrigger[i] += GetTrig(i)->GetFirstLevel();
     
    194197    // Computing trigger rate
    195198    //
    196     for (int i=0; i<fDimension; i++)
     199    for (int i=0; i<fNum; i++)
    197200        GetRate(i)->CalcRate(fTrigger[i], fAnalShow, fShowers);
    198201
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h

    r983 r984  
    2727    Int_t      fDimension;     // Information about the trigger conditions
    2828                               // in the root file to be read.
     29    Int_t      fNum;           // decoded dimension
    2930
    3031    Float_t    fTrigger[10];   // Number of triggered showers
     
    3839
    3940    MHMcRate *GetRate(UInt_t i) const { return (MHMcRate*)((*fMcRate)[i]); }
    40     MMcTrig *GetTrig(UInt_t i) const { return (MMcTrig*)((*fMcTrig)[i]); }
     41    MMcTrig  *GetTrig(UInt_t i) const { return (MMcTrig*)((*fMcTrig)[i]); }
    4142
    4243public:
Note: See TracChangeset for help on using the changeset viewer.