Changeset 898


Ignore:
Timestamp:
07/23/01 17:02:49 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mmontecarlo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc

    r878 r898  
    3030#include "MParList.h"
    3131
     32#include "MHMcRate.h"
     33#include "MMcEvt.hxx"
    3234#include "MMcTrig.hxx"
    33 #include "MHMcRate.h"
    34 
    35 ClassImp(MMcTriggerRateCalc)
    36 
    37 // --------------------------------------------------------------------------
    38 //
    39 //  default constructor
    40 //  set member data to initial values
    41 //
    42 MMcTriggerRateCalc::MMcTriggerRateCalc (const char *name, const char *title)
    43 {
    44   //  default constructor
    45   *fName  = name  ? name  : "MMcTriggerRateCalc";
    46   *fTitle = title ? title : "Task to calc the trigger rate";
    47 
    48   fDimension=0;
    49   for (int i=0;i<10;i++){
    50   fTrigger[i]=0;
    51   }
    52   fShowers = 0;
    53   fAnalShow = 100000;
    54 
    55   fPartId=14;
    56 
    57   fSpecInd=2.75;
    58   fFlux0=10.92e-2;
    59 }
     35
     36ClassImp(MMcTriggerRateCalc);
     37
     38void MMcTriggerRateCalc::Init(int dim, int part, float *trigbg,
     39                              float simbg, float spec, float flux0,
     40                              const char *name, const char *title)
     41{
     42    *fName  = name  ? name  : "MMcTriggerRateCalc";
     43    *fTitle = title ? title : "Task to calc the trigger rate ";
     44
     45    fDimension=dim;
     46
     47    for (int i=0;i<10;i++)
     48        fTrigger[i] = dim&&trigbg ? trigbg[i] : 0;
     49
     50    fShowers = 0;
     51    fAnalShow = simbg;
     52
     53    fPartId=part;
     54
     55    fSpecInd=spec;
     56    fFlux0=flux0;
     57}
    6058
    6159// --------------------------------------------------------------------------
     
    7068//      rate: rate of incident showers
    7169//
    72 MMcTriggerRateCalc::MMcTriggerRateCalc (int dim, int part, float *trigbg,
    73                                 float simbg, float rate,
    74                                 const char *name, const char *title)
    75 {
    76   *fName  = name  ? name  : "MMcTriggerRateCalc";
    77   *fTitle = title ? title : "Task to calc the trigger rate ";
    78 
    79   fDimension=dim;
    80 
    81   for (int i=0;i<10;i++){
    82   fTrigger[i]=trigbg[i];
    83   }
    84 
    85   fShowers = 0;
    86   fAnalShow = simbg;
    87 
    88   fPartId=part;
    89 
    90   fSpecInd=rate;
    91   fFlux0=0;
    92 }
     70
     71MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim, int part,
     72                                       float *trigbg, float simbg,
     73                                       const char *name, const char *title)
     74{
     75    Init(dim, part, trigbg, simbg, rate, 0, name, title);
     76}
     77
    9378
    9479// --------------------------------------------------------------------------
     
    10186//               a given trigger condition.
    10287//      simbg: Number of simulated showers for the bacground
    103 //      spec: sSpecInd
     88//      spec: spectral index
    10489//      flux0; fFlux0
    10590//
    106 MMcTriggerRateCalc::MMcTriggerRateCalc (int dim, int part, float *trigbg,
    107                                 float simbg, float spec, float flux0,
    108                                 const char *name, const char *title)
    109 {
    110   *fName  = name  ? name  : "MMcTriggerRateCalc";
    111   *fTitle = title ? title : "Task to calc the trigger rate ";
    112 
    113   fDimension=dim;
    114 
    115   for (int i=0;i<10;i++){
    116   fTrigger[i]=trigbg[i];
    117   }
    118 
    119   fShowers = 0;
    120   fAnalShow = simbg;
    121 
    122   fPartId=part;
    123 
    124   fSpecInd=spec;
    125   fFlux0=flux0;
    126 }
     91
     92MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, int part, float *trigbg,
     93                                       float simbg, float spec, float flux0,
     94                                       const char *name, const char *title)
     95{
     96    Init(dim, part, trigbg, simbg, spec, flux0, name, title);
     97}
     98
    12799
    128100// --------------------------------------------------------------------------
     
    136108Bool_t MMcTriggerRateCalc::PreProcess (MParList *pList)
    137109{
    138   // connect the raw data with this task
    139   int i;               // bucle variable
    140   char auxname[15];    // string to write container names
    141 
    142   fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
    143   if (!fMcEvt)
    144   {
    145     *fLog << dbginf << "MMcEvt not found... aborting." << endl;
    146     return kFALSE;
    147   }
    148 
    149   if(fDimension>0)
    150     for(i=0;i<fDimension;i++){
    151       sprintf(auxname,"MMcTrig;%i",i+1);
    152       fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
    153       if (!fMcTrig[i])
    154         {
    155           *fLog << dbginf << "MMcTrig not found... aborting." << endl;
    156           return kFALSE;
    157         }
    158       sprintf(auxname,"MHMcRate;%i",i+1);
    159       fMcRate[i] = (MHMcRate*)pList->FindCreateObj(auxname);
    160       if (!fMcTrig[i])
    161         {
    162           return kFALSE;
    163         }
    164       fMcRate[i]->SetParticle(fPartId);
    165       fMcRate[i]->SetBackground(fTrigger[i],fAnalShow);
    166       fTrigger[i]=0;
    167     }
    168   else if (fDimension==0)
    169     { 
    170       fMcTrig[0] = (MMcTrig*)pList->FindObject("MMcTrig");
    171       if (!fMcTrig[0])
    172         {
    173           *fLog << dbginf << "MMcTrig not found... aborting." << endl;
    174           return kFALSE;
    175         }
    176       fMcRate[0] = (MHMcRate*)pList->FindCreateObj("MHMcRate");
    177       if (!fMcTrig[0])
    178         {
    179           return kFALSE;
    180         }
    181       fMcRate[0]->SetParticle(fPartId);
    182       fMcRate[0]->SetBackground(fTrigger[0],fAnalShow);
    183       fTrigger[0]=0;
    184       fDimension=1;
    185     }   
    186   else
    187      {
    188       sprintf(auxname,"MMcTrig;%i.",-fDimension);
    189       fMcTrig[0] = (MMcTrig*)pList->FindObject(auxname);
    190       if (!fMcTrig[0])
    191         {
    192           *fLog << dbginf << "MMcTrig not found... aborting." << endl;
    193           return kFALSE;
    194         }
    195      sprintf(auxname,"MHMcRate;%i.",-fDimension);
    196      fMcRate[0] = (MHMcRate*)pList->FindCreateObj(auxname);
    197       if (!fMcTrig[0])
    198         {
    199           return kFALSE;
    200         }
    201       fMcRate[0]->SetParticle(fPartId);
    202       fMcRate[0]->SetBackground(fTrigger[0],fAnalShow);
    203       fTrigger[0]=0;
    204       fDimension=1;
    205     }
    206  
    207   fAnalShow=0.0;
    208   *fLog<<dbginf<< "Pre Process done"<<endl;
    209  
    210   return kTRUE ;
    211  
    212 }
     110    // connect the raw data with this task
     111
     112    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
     113    if (!fMcEvt)
     114    {
     115        *fLog << dbginf << "MMcEvt not found... aborting." << endl;
     116        return kFALSE;
     117    }
     118
     119    const UInt_t from = fDimension<=0 ? -fDimension : 0;
     120
     121    if (fDimension<=0)
     122        fDimension = -fDimension;
     123
     124    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, fDimension));
     125    if (fMcTrig->GetEntriesFast() != fDimension)
     126    {
     127        *fLog << dbginf << "Error: Not all requested MMcTrig objects are available...aborting." << endl;
     128        return kFALSE;
     129    }
     130
     131    fMcRate = new TObjArray(pList->FindObjectList("MHMcRate", from, fDimension));
     132    if (fMcRate->GetEntriesFast() != fDimension)
     133    {
     134        *fLog << dbginf << "Error: Not all requested MHMcRate objects are available...aborting." << endl;
     135        return kFALSE;
     136    }
     137
     138    for (int i=0; i<fDimension; i++)
     139    {
     140        MHMcRate &rate = *GetRate(i);
     141
     142        rate.SetParticle(fPartId);
     143        rate.SetBackground(fTrigger[i], fAnalShow);
     144
     145        fTrigger[i]=0;
     146    }
     147
     148    fAnalShow=0.0;
     149
     150    return kTRUE;
     151}
    213152
    214153// --------------------------------------------------------------------------
     
    219158//  MHMcRate container.
    220159//
    221 Bool_t MMcTriggerRateCalc::Process ()
    222 {
    223   Float_t Ener, Theta, Phi, Param;
    224 
    225   //  Counting analysed and simulated showers
    226 
    227   fShowers++;
    228   if (fMcEvt->GetPhotElfromShower()) fAnalShow++;
    229 
    230   //  Getting angles, energy and impact parameter to set boundaries
    231 
    232   Theta=fMcEvt->GetTheta();
    233   Phi=fMcEvt->GetPhi();
    234   Param=fMcEvt->GetImpact();
    235   Ener=fMcEvt->GetEnergy()/1000.0;
    236 
    237   //  Counting number of triggers
    238 
    239   for(int i=0;i<fDimension;i++){
    240   fTrigger[i]=fTrigger[i]+fMcTrig[i]->GetFirstLevel();
    241   fMcRate[i]->Boundaries(Ener, Theta, Phi, Param);
    242   }
    243 
    244   return kTRUE ;
     160Bool_t MMcTriggerRateCalc::Process ()
     161{
     162    //  Counting analysed and simulated showers
     163
     164    fShowers++;
     165    if (fMcEvt->GetPhotElfromShower())
     166        fAnalShow++;
     167
     168    //  Getting angles, energy and impact parameter to set boundaries
     169
     170    const Float_t theta=fMcEvt->GetTheta();
     171    const Float_t phi  =fMcEvt->GetPhi();
     172    const Float_t param=fMcEvt->GetImpact();
     173    const Float_t ener =fMcEvt->GetEnergy()/1000.0;
     174
     175    //  Counting number of triggers
     176
     177    for (int i=0; i<fDimension; i++)
     178    {
     179        fTrigger[i] += GetTrig(i)->GetFirstLevel();
     180
     181        GetRate(i)->UpdateBoundaries(ener, theta, phi, param);
     182    }
     183
     184    return kTRUE;
    245185}
    246186
     
    249189//  The PostProcess-function calculates and shows the trigger rate
    250190//
    251 Bool_t MMcTriggerRateCalc::PostProcess ()
    252 {
    253   // Computing trigger rate and showing it
    254   for(int i=0;i<fDimension;i++){
    255     fMcRate[i]->CalcRate(fTrigger[i],fAnalShow,fShowers);
    256     fMcRate[i]->Print();
    257     fMcRate[i]->Draw("S");
    258   }
    259 
    260   return kTRUE ;
    261 }
    262 
    263 
    264 
     191Bool_t MMcTriggerRateCalc::PostProcess ()
     192{
     193    // Computing trigger rate and showing it
     194    for(int i=0; i<fDimension; i++)
     195    {
     196        MHMcRate &rate = *GetRate(i);
     197
     198        rate.CalcRate(fTrigger[i], fAnalShow, fShowers);
     199        rate.Print();
     200        rate.Draw("S");
     201    }
     202
     203    return kTRUE;
     204}
     205
     206
     207
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h

    r877 r898  
    22#define MTRIGGERRATECALC_H
    33
     4#ifndef MAGIC_H
     5#include "MAGIC.h"
     6#endif
     7#ifndef ROOT_TObjArray
     8#include <TObjArray.h>
     9#endif
    410#ifndef MTASK_H
    511#include "MTask.h"
    612#endif
    713
    8 #include "MMcEvt.hxx"
    9 
    1014class MParList;
    11 class MMcTrig ;
    1215class MMcEvt;
     16class MMcTrig;
    1317class MHMcRate;
    1418
    15 class MMcTriggerRateCalc : public MTask {
    16  private:
    17   MMcTrig         *fMcTrig[10]  ; //!
    18   MMcEvt          *fMcEvt;        //!
     19class MMcTriggerRateCalc : public MTask
     20{
     21private:
     22    MMcEvt    *fMcEvt;        //!
    1923
    20   MHMcRate         *fMcRate[10] ;  //!
     24    TObjArray *fMcRate;
     25    TObjArray *fMcTrig;
    2126
    22   Int_t           fDimension;     // Information about the trigger conditions
    23                                   // in the root file to be read.
     27    Int_t      fDimension;     // Information about the trigger conditions
     28    // in the root file to be read.
    2429
    25   Float_t         fTrigger[10];   // Number of triggered showers
    26   Float_t         fShowers;       // Number of simulated showers
    27   Float_t         fAnalShow;      // Number of analysed showers
     30    Float_t    fTrigger[10];   // Number of triggered showers
     31    Float_t    fShowers;       // Number of simulated showers
     32    Float_t    fAnalShow;      // Number of analysed showers
    2833
    29   Int_t           fPartId;        // Incident particle that generates showers
     34    Int_t      fPartId;        // Incident particle that generates showers
    3035
    31   Float_t         fSpecInd;       // Spectral indec of the simualtion
    32   Float_t         fFlux0;         // Flux 0 for the differential flux
     36    Float_t    fSpecInd;       // Spectral indec of the simualtion
     37    Float_t    fFlux0;         // Flux 0 for the differential flux
    3338
    34  public:   
    35   MMcTriggerRateCalc (const char *name=NULL, const char *title=NULL);
    36   MMcTriggerRateCalc (int dim, int part, float *trigbg, float simbg, float rate,
    37                   const char *name=NULL, const char *title=NULL);
    38   MMcTriggerRateCalc (int dim, int part, float *trigbg, float simbg, float spec,
    39                   float flux0, const char *name=NULL, const char *title=NULL);
     39    void Init(int dim, int part, float *trigbg,
     40              float simbg, float spec, float flux0,
     41              const char *name, const char *title);
    4042
    41   Bool_t PreProcess(MParList *pList);
    42   Bool_t Process() ;
    43   Bool_t PostProcess() ;
    44  
    45   ClassDef(MMcTriggerRateCalc, 0)       // Task to compute the trigger rate
     43    MHMcRate *GetRate(UInt_t i) const { return (MHMcRate*)((*fMcRate)[i]); }
     44    MMcTrig *GetTrig(UInt_t i) const { return (MMcTrig*)((*fMcTrig)[i]); }
    4645
     46public:
     47    MMcTriggerRateCalc(int dim=0, int part=14, float *trigbg=NULL,
     48                       float simbg=100000, float spec=2.75, float flux0=10.92e-2,
     49                       const char *name=NULL, const char *title=NULL);
     50
     51    MMcTriggerRateCalc(float rate, int dim, int part, float *trigbg,
     52                       float simbg,
     53                       const char *name=NULL, const char *title=NULL);
     54
     55    Bool_t PreProcess(MParList *pList);
     56    Bool_t Process();
     57    Bool_t PostProcess();
     58
     59    ClassDef(MMcTriggerRateCalc, 0)     // Task to compute the trigger rate
    4760};
    4861
Note: See TracChangeset for help on using the changeset viewer.