Changeset 896 for trunk/MagicSoft/Mars


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r895 r896  
    1818   * macros/MagicHillas.C:
    1919     - changed to new stilish histogram fillers.
     20
     21   * mhist/MHMcRate.cc:
     22     - some simplifications to the constructors
     23     - some accelerations of the rate calculation
    2024
    2125
  • trunk/MagicSoft/Mars/mhist/MHMcRate.cc

    r874 r896  
    2828#include "MLog.h"
    2929
    30 ClassImp(MHMcRate)
     30ClassImp(MHMcRate);
     31
     32void MHMcRate::Init(const char *name, const char *title)
     33{
     34    *fName  = name  ? name  : "MMcTriggerRate";
     35    *fTitle = title ? title : "Task to calc the collection area ";
     36
     37    fPartId=0;              // Type of particle
     38
     39    fEnergyMax=0.0;         // Maximum Energy in GeV
     40    fEnergyMin=1000000.0;   // Minimum Energy in GeV
     41
     42    fThetaMax=0.0;          // Maximum theta angle of run
     43    fThetaMin=370.0;        // Minimum theta angle of run
     44    fPhiMax=0.0;            // Maximum phi angle of run
     45    fPhiMin=370.0;          // Minimum phi angle of run
     46
     47    fImpactMax=0.0;         // Maximum impact parameter
     48    fImpactMin=100000.0;    // Minimum impact parameter
     49
     50    fBackTrig=-1.0;         // Number of triggers from background
     51    fBackSim=-1.0;          // Number of simulated showers for the background
     52
     53    fTrigRate= -1.0;        // Trigger rate in Hz
     54    fTrigRateError= -1.0;   // Estimated error for the trigger rate in Hz
     55}
    3156
    3257// --------------------------------------------------------------------------
     
    3560//  fills all member data with initial values
    3661//
    37 MHMcRate::MHMcRate (const char *name, const char *title)
    38 {
    39   *fName  = name  ? name  : "MMcTriggerRate";
    40   *fTitle = title ? title : "Task to calc the collection area ";
    41 
    42   fPartId=0;              // Type of particle
    43  
    44   fEnergyMax=0.0;         // Maximum Energy in GeV
    45   fEnergyMin=1000000.0;   // Minimum Energy in GeV
    46  
    47   fThetaMax=0.0;          // Maximum theta angle of run
    48   fThetaMin=370.0;        // Minimum theta angle of run
    49   fPhiMax=0.0;            // Maximum phi angle of run
    50   fPhiMin=370.0;          // Minimum phi angle of run
    51  
    52   fImpactMax=0.0;         // Maximum impact parameter
    53   fImpactMin=100000.0;    // Minimum impact parameter
    54  
    55   fBackTrig=-1.0;         // Number of triggers from background
    56   fBackSim=-1.0;          // Number of simulated showers for the background
    57  
    58   fSpecIndex=0.0;         // dn/dE = k * e^{- fSpecIndex}
    59   fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
    60  
    61   fShowRate= -1.0;        // Showers rate in Hz
    62   fShowRateError=0.0;     // Estimated error of shower rate in Hz
    63  
    64   fTrigRate= -1.0;        // Trigger rate in Hz
    65   fTrigRateError= -1.0;   // Estimated error for the trigger rate in Hz
    66 }
     62MHMcRate::MHMcRate(const char *name, const char *title)
     63{
     64    Init(name, title);
     65
     66    fSpecIndex=0.0;         // dn/dE = k * e^{- fSpecIndex}
     67    fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
     68
     69    fShowRate= -1.0;        // Showers rate in Hz
     70    fShowRateError=0.0;     // Estimated error of shower rate in Hz
     71}
    6772
    6873// --------------------------------------------------------------------------
     
    7277//  incident showers to ShowRate
    7378//
    74 MHMcRate::MHMcRate (Float_t ShowRate,
    75                   const char *name, const char *title)
    76 {
    77 
    78   *fName  = name  ? name  : "MMcTriggerRate";
    79   *fTitle = title ? title : "Task to calc the collection area ";
    80 
    81   fPartId=0;              // Type of particle
    82  
    83   fEnergyMax=0.0;         // Maximum Energy in GeV
    84   fEnergyMin=1000000.0;   // Minimum Energy in GeV
    85  
    86   fThetaMax=0.0;          // Maximum theta angle of run
    87   fThetaMin=370.0;        // Minimum theta angle of run
    88   fPhiMax=0.0;            // Maximum phi angle of run
    89   fPhiMin=370.0;          // Minimum phi angle of run
    90  
    91   fImpactMax=0.0;         // Maximum impact parameter
    92   fImpactMin=100000.0;    // Minimum impact parameter
    93  
    94   fBackTrig=-1.0;         // Number of triggers from background
    95   fBackSim=-1.0;          // Number of simulated showers for the background
    96  
    97   fSpecIndex=0.0;         // dn/dE = k * e^{- fSpecIndex}
    98   fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
    99  
    100   fShowRate= ShowRate;               // Showers rate in Hz
    101   fShowRateError=sqrt(ShowRate);     // Estimated error of shower rate in Hz
    102  
    103   fTrigRate= -1.0;        // Trigger rate in Hz
    104   fTrigRateError= -1.0;   // Estimated error for the trigger rate in Hz
    105 }
     79MHMcRate::MHMcRate(Float_t showrate,
     80                   const char *name, const char *title)
     81{
     82    Init(name, title);
     83
     84    fSpecIndex=0.0;         // dn/dE = k * e^{- fSpecIndex}
     85    fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
     86
     87    fShowRate= showrate;               // Showers rate in Hz
     88    fShowRateError=sqrt(showrate);     // Estimated error of shower rate in Hz
     89}
    10690
    10791// --------------------------------------------------------------------------
     
    11195//  spectral index and the initial flux to SpecIndex and Flux0
    11296//
    113 MHMcRate::MHMcRate (Float_t SpecIndex, Float_t Flux0,
    114                   const char *name, const char *title)
    115 {
    116   *fName  = name  ? name  : "MMcTriggerRate";
    117   *fTitle = title ? title : "Task to calc the collection area ";
    118 
    119   fPartId=0;              // Type of particle
    120  
    121   fEnergyMax=0.0;         // Maximum Energy in GeV
    122   fEnergyMin=1000000.0;   // Minimum Energy in GeV
    123  
    124   fThetaMax=0.0;          // Maximum theta angle of run
    125   fThetaMin=370.0;        // Minimum theta angle of run
    126   fPhiMax=0.0;            // Maximum phi angle of run
    127   fPhiMin=370.0;          // Minimum phi angle of run
    128  
    129   fImpactMax=0.0;         // Maximum impact parameter
    130   fImpactMin=100000.0;    // Minimum impact parameter
    131  
    132   fBackTrig=-1.0;         // Number of triggers from background
    133   fBackSim=-1.0;          // Number of simulated showers for the background
    134  
    135   fSpecIndex=SpecIndex;   // dn/dE = k * e^{- fSpecIndex}
    136   fFlux0=Flux0;           // dn/dE = fFlux0 * E^{-a}
    137  
    138   fShowRate= -1.0;       
    139   fShowRateError=0.0;     
    140  
    141   fTrigRate= -1.0;        // Trigger rate in Hz
    142   fTrigRateError= -1.0;   // Estimated error for the trigger rate in Hz
    143 }
    144 
    145 // --------------------------------------------------------------------------
    146 //
    147 //  default constructor
    148 //
    149 MHMcRate::~MHMcRate()
    150 {
    151 }
     97MHMcRate::MHMcRate(Float_t specindex, Float_t flux0,
     98                   const char *name, const char *title)
     99{
     100    Init(name, title);
     101
     102    fSpecIndex=specindex;   // dn/dE = k * e^{- fSpecIndex}
     103    fFlux0=flux0;           // dn/dE = fFlux0 * E^{-a}
     104
     105    fShowRate= -1.0;
     106    fShowRateError=0.0;
     107}
    152108
    153109// --------------------------------------------------------------------------
     
    156112//
    157113void MHMcRate:: SetParticle(UShort_t part)
    158 { 
    159   fPartId=part;
    160 } 
     114{
     115    fPartId=part;
     116}
    161117
    162118// --------------------------------------------------------------------------
     
    164120//  Set the information about trigger due only to the background conditions
    165121//
    166 void MHMcRate::SetBackground (Float_t Showers, Float_t Triggers)
    167 { 
    168   fBackTrig=Showers;      // Number of triggers from background
    169   fBackSim=Triggers;      // Number of simulated showers for the background
    170 } 
     122void MHMcRate::SetBackground (Float_t showers, Float_t triggers)
     123{
     124    fBackTrig=showers;      // Number of triggers from background
     125    fBackSim=triggers;      // Number of simulated showers for the background
     126}
    171127
    172128// --------------------------------------------------------------------------
     
    174130//  update the limits for energy, theta, phi and impact parameter
    175131//
    176 void MHMcRate::Boundaries(Float_t Energy, Float_t Theta,
    177                          Float_t Phi, Float_t Impact)
     132void MHMcRate::Boundaries(Float_t energy, Float_t theta,
     133                          Float_t phi, Float_t impact)
    178134{
    179135  // It updates the limit values
    180136
    181   if(fThetaMax<Theta) fThetaMax=Theta;
    182   if(fThetaMin>Theta) fThetaMin=Theta;
    183 
    184   if(fPhiMax<Phi) fPhiMax=Phi;
    185   if(fPhiMin>Phi) fPhiMin=Phi;
    186 
    187   if(fImpactMax<Impact) fImpactMax=Impact;
    188   if(fImpactMin>Impact) fImpactMin=Impact;
    189 
    190   if(fEnergyMax<Energy) fEnergyMax=Energy;
    191   if(fEnergyMin>Energy) fEnergyMin=Energy;
     137  if (fThetaMax<theta) fThetaMax=theta;
     138  if (fThetaMin>theta) fThetaMin=theta;
     139
     140  if (fPhiMax<phi) fPhiMax=phi;
     141  if (fPhiMin>phi) fPhiMin=phi;
     142
     143  if (fImpactMax<impact) fImpactMax=impact;
     144  if (fImpactMin>impact) fImpactMin=impact;
     145
     146  if (fEnergyMax<energy) fEnergyMax=energy;
     147  if (fEnergyMin>energy) fEnergyMin=energy;
    192148
    193149}
     
    199155void MHMcRate::CalcRate(Float_t trig, Float_t anal, Float_t simu)
    200156{
    201   // It computes the trigger rate
    202 
    203   // First one computes the rate of incident showers.
    204   fShowRate=fFlux0/(fSpecIndex-1)*
    205     (-pow(fEnergyMax,1-fSpecIndex)+pow(fEnergyMin,1-fSpecIndex));
    206 
    207   if (fPartId!=1)
    208     fShowRate=fShowRate*(fPhiMax-fPhiMin)*
    209       (cos(fThetaMax)-cos(fThetaMin));
    210 
    211   fShowRate=fShowRate*PI_NUMBER*(fImpactMax/100.0*fImpactMax/100.0-
    212                                    fImpactMin/100.0*fImpactMin/100.0);
    213 
    214   fShowRateError=sqrt(fShowRate);
    215 
    216   // Then the trigger rate and its error is evaluated
    217   if(fBackTrig<0){
    218     fTrigRateError=sqrt((trig*fShowRate*fShowRate/(simu*simu))+
    219                     ((1.0-anal*160.0e-9)*
    220                      (1.0-anal*160.0e-9)*1/
    221                      (fBackSim*fBackSim*160.0e-9*fBackSim*160.0e-9)));
    222     fBackTrig=0;
    223   }
    224   else
    225     fTrigRateError=sqrt((trig*fShowRate*fShowRate/(simu*simu))+
    226                        ((1.0-anal*160.0e-9)*
    227                         (1.0-anal*160.0e-9)*fBackTrig/
    228                         (fBackSim*160.0e-9*fBackSim*160.0e-9)));
    229  
    230   fTrigRate=trig*fShowRate/simu+
    231       (1.0-anal*160.0e-9)*fBackTrig/
    232       (fBackSim*160.0e-9);
    233 
    234 } 
     157    // It computes the trigger rate
     158
     159    // First one computes the rate of incident showers.
     160    const Double_t specidx = 1.0-fSpecIndex;
     161
     162    const Double_t epowmax = pow(fEnergyMax, specidx);
     163    const Double_t epowmin = pow(fEnergyMin, specidx);
     164
     165    fShowRate = fFlux0/specidx*(epowmax-epowmin);
     166
     167    if (fPartId!=1)
     168        fShowRate *= (fPhiMax-fPhiMin)*(cos(fThetaMax)-cos(fThetaMin));
     169
     170    const Double_t impactdiff = fImpactMax-fImpactMin;
     171
     172    fShowRate *= TMath::Pi()*(impactdiff/100.0*impactdiff/100.0);
     173
     174    fShowRateError = sqrt(fShowRate);
     175
     176    const Double_t anal2 = 1.0-anal*160.0e-9;
     177    const Double_t back2 = fBackSim*160.0e-9;
     178
     179    // Then the trigger rate and its error is evaluated
     180    if(fBackTrig<0){
     181        fTrigRateError = sqrt((trig*fShowRate*fShowRate/(simu*simu)) +
     182                              (anal2*anal2*1/(fBackSim*back2*back2)));
     183        fBackTrig=0;
     184    }
     185    else
     186        fTrigRateError = sqrt((trig*fShowRate*fShowRate/(simu*simu)) +
     187                              (anal2*anal2*fBackTrig/(back2*back2)));
     188
     189    fTrigRate = trig*fShowRate/simu + anal2*fBackTrig/back2;
     190}
    235191
    236192// --------------------------------------------------------------------------
     
    240196void MHMcRate::Print()
    241197{
    242   *fLog<<"Incident rate "<<fShowRate<<" Hz "<<endl;
    243   *fLog<<endl<<"Trigger Rate "<<fTrigRate<<" +- "<<fTrigRateError<<" Hz"<<endl;
    244 
     198    *fLog << "Incident rate " << fShowRate << " Hz " << endl;
     199    *fLog << "Trigger Rate " << fTrigRate << " +- " << fTrigRateError << " Hz" << endl;
    245200}
    246201
     
    251206void MHMcRate::Draw(Option_t* option)
    252207{
    253   *fLog<<"To be iplemented"<<endl;
     208  *fLog << "To be iplemented" << endl;
    254209}
  • trunk/MagicSoft/Mars/mhist/MHMcRate.h

    r873 r896  
    3939  Float_t fTrigRateError;   // Estimated error for the trigger rate in Hz
    4040
     41  void Init(const char *name, const char *title);
     42
    4143 public:
    4244 
Note: See TracChangeset for help on using the changeset viewer.