Changeset 1783 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
02/21/03 18:09:36 (22 years ago)
Author:
moralejo
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1782 r1783  
    11
    22                                                         -*-*- END -*-*-
     3 2003/02/21: Abelardo Moralejo
     4
     5    * mmontecarlo/MMcTriggerRateCalc.[h,cc]
     6      - adapted to new camera files, added warnings.
     7      - added ReInit procedure to read relevant info from from the run headers
     8
     9    * mhist/MHMcRate.[h,cc]
     10      - adapted accordingly. Added Set functions for several members.
     11
     12    * mmc/MMcCorsikaRunHeader.h
     13      - added Get functions for fELowLim, fEUppLim and fSlopeSpec.
     14
     15    * mmain/MMontecarlo.cc, macros/trigrate.C
     16      - adapted to changes above, changed MReadTree to MReadMarsFile to
     17        be able to read the run headers.
     18
    319 2003/02/21: Antonio Stamerra
    420
  • trunk/MagicSoft/Mars/macros/trigrate.C

    r1543 r1783  
    124124    //    analised trigger conditions should be set (BgR[])
    125125    //
    126     MReadTree reader("Events", filename);
     126
     127    MReadMarsFile reader("Events", filename);
    127128    tasklist.AddToList(&reader);
    128129
     
    141142    cout << "Number of Trigger conditions: " << num << endl;
    142143
    143     MMcTriggerRateCalc rate(dim, kPROTON, BgR, numnsbevents);
     144    MMcTriggerRateCalc rate(dim, BgR, numnsbevents);
     145
    144146    tasklist.AddToList(&rate);
    145147
  • trunk/MagicSoft/Mars/mhist/MHMcRate.cc

    r1534 r1783  
    1818!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
    1919!   Author(s): Harald Kornmayer 1/2001
     20!   Author(s): Abelardo Moralejo 2/2003
     21!
     22!   Explanations on the rate calculation can be found in
     23!   chapter 7 of the following diploma thesis:
     24!   http://www.pd.infn.it/magic/tesi2.ps.gz (in Italian)
    2025!
    2126!   Copyright: MAGIC Software Development, 2000-2001
     
    3843    fPartId=0;               // Type of particle
    3944
    40     fEnergyMax=0.0;          // Maximum Energy in GeV
    41     fEnergyMin=1000000.0;    // Minimum Energy in GeV
    42 
     45    fEnergyMax=0.0;          // Maximum Energy (TeV)
     46    fEnergyMin=1000000.0;    // Minimum Energy (TeV)
     47
     48    fSolidAngle = -1.;       // Solid angle within which incident directions
     49                             // are distributed
    4350    fThetaMax=0.0;           // Maximum theta angle of run
    4451    fThetaMin=370.0;         // Minimum theta angle of run
     
    119126// --------------------------------------------------------------------------
    120127//
    121 //  Set the information about trigger due only to the background conditions
     128//  Set the information about trigger due only to the Night Sky Background:
    122129//
    123130void MHMcRate::SetBackground (Float_t showers, Float_t triggers)
     
    184191
    185192    if (fShowerRate <= 0)
    186         fShowerRate = fFlux0/specidx*(epowmin-epowmax);
     193      fShowerRate = fFlux0/specidx*(epowmax-epowmin);
     194
     195    if (fSolidAngle < 0.)
     196      fSolidAngle = (fPhiMax-fPhiMin)*(cos(fThetaMin)-cos(fThetaMax));
    187197
    188198    if (fPartId!=1)
    189         fShowerRate *= (fPhiMax-fPhiMin)*(cos(fThetaMax)-cos(fThetaMin));
    190 
    191     const Double_t impactdiff = fImpactMax-fImpactMin;
    192 
    193     fShowerRate *= TMath::Pi()*(impactdiff/100.0*impactdiff/100.0);
     199      fShowerRate *= fSolidAngle;
     200
     201    fShowerRate *= TMath::Pi()*(fImpactMax/100.0*fImpactMax/100.0 -
     202                                fImpactMin/100.0*fImpactMin/100.0);
    194203
    195204    fShowerRateError = sqrt(fShowerRate);
  • trunk/MagicSoft/Mars/mhist/MHMcRate.h

    r1663 r1783  
    1212    UShort_t fPartId;           // Type of particle
    1313
    14     Float_t fEnergyMax;         // Maximum Energy in GeV
    15     Float_t fEnergyMin;         // Minimum Energy in GeV
     14    Float_t fEnergyMax;         // Maximum Energy in TeV
     15    Float_t fEnergyMin;         // Minimum Energy in TeV
    1616
    1717    Float_t fThetaMax;          // Maximum theta angle of run
     
    2020    Float_t fPhiMin;            // Minimum phi angle of run
    2121
    22     Float_t fImpactMax;         // Maximum impact parameter
    23     Float_t fImpactMin;         // Minimum impact parameter
     22    Float_t fSolidAngle;        // Solid angle within which incident directions
     23                                // are distributed (sr)
     24
     25    Float_t fImpactMax;         // Maximum impact parameter (cm)
     26    Float_t fImpactMin;         // Minimum impact parameter (cm)
    2427
    2528    Float_t fBackTrig;          // Number of triggers from background
     
    5053    void SetIncidentRate(Float_t showerrate);
    5154
     55    void SetImpactMax(Float_t Impact) {fImpactMax=Impact;}
     56    void SetImpactMin(Float_t Impact) {fImpactMin=Impact;}
     57
     58    void SetThetaMax(Float_t Theta) {fThetaMax=Theta;}
     59    void SetThetaMin(Float_t Theta) {fThetaMin=Theta;}
     60    void SetPhiMax(Float_t Phi) {fPhiMax=Phi;}
     61    void SetPhiMin(Float_t Phi) {fPhiMin=Phi;}
     62
     63    void SetSolidAngle(Float_t Solid) {fSolidAngle=Solid;}
     64    void SetEnergyMax(Float_t Energy) {fEnergyMax=Energy;}
     65    void SetEnergyMin(Float_t Energy) {fEnergyMin=Energy;}
     66
    5267    void UpdateBoundaries(Float_t energy, Float_t theta, Float_t phi, Float_t impact);
    5368
  • trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc

    r1668 r1783  
    349349    //    analised trigger conditions should be set (BgR[])
    350350    //
    351     MReadTree read("Events", fInputFile);
     351    MReadMarsFile read("Events", fInputFile);
    352352    tlist.AddToList(&read);
    353353
    354     Float_t BgR[10]={660, 4, 0, 0, 0, 0, 0, 0, 0, 0};
    355 
    356     MMcTriggerRateCalc crate(dim, 14, BgR, 100000);
     354    // We calculate only shower rate (not including NSB-only triggers)
     355    Float_t* BgR = new Float_t[dim];
     356    memset(BgR, 0, num*sizeof(Float_t));
     357
     358    MMcTriggerRateCalc crate(dim, BgR, 100000);
    357359    tlist.AddToList(&crate);
    358360
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc

    r1376 r1783  
    3838#include "MMcEvt.hxx"
    3939#include "MMcTrig.hxx"
     40#include "MMcRunHeader.hxx"
     41#include "MMcCorsikaRunHeader.h"
    4042
    4143ClassImp(MMcTriggerRateCalc);
    4244
    43 void MMcTriggerRateCalc::Init(int dim, int part, float *trigbg,
    44                               float simbg,
     45void MMcTriggerRateCalc::Init(int dim, float *trigbg, float simbg,
    4546                              const char *name, const char *title)
    4647{
     
    5152    fMcRate = NULL;
    5253
     54    fTrigNSB = trigbg;
     55    fSimNSB = simbg;
     56
     57    fPartId = -1;
     58
    5359    fShowers = 0;
    54     fAnalShow = simbg;
    55 
    56     fPartId=part;
     60    fAnalShow = 0;
    5761
    5862    fFirst = dim>0 ?   1 : -dim;
     
    6064
    6165    fNum = fLast-fFirst+1;
    62 
    6366    fTrigger = new float[fNum];
    6467
    6568    for (UInt_t i=0;i<fNum;i++)
    66         fTrigger[i] = dim&&trigbg ? trigbg[i] : 0;
    67 
     69      fTrigger[i]=0;
     70
     71    AddToBranchList("MMcEvt.fPartId");
    6872    AddToBranchList("MMcEvt.fImpact");
    6973    AddToBranchList("MMcEvt.fEnergy");
     
    7276    AddToBranchList("MMcEvt.fPhotElfromShower");
    7377    AddToBranchList("MMcTrig", "fNumFirstLevel", fFirst, fLast);
     78
     79}
     80
     81// ReInit: read run header to get some info later:
     82
     83Bool_t MMcTriggerRateCalc::ReInit(MParList *pList)
     84{
     85    fMcRunHeader = (MMcRunHeader*) pList->FindObject("MMcRunHeader");
     86    if (!fMcRunHeader)
     87    {
     88        *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
     89        return kFALSE;
     90    }
     91
     92    fMcCorRunHeader = (MMcCorsikaRunHeader*) pList->FindObject("MMcCorsikaRunHeader");
     93    if (!fMcCorRunHeader)
     94    {
     95        *fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl;
     96        return kFALSE;
     97    }
     98
     99    if (fMcRunHeader->GetAllEvtsTriggered())
     100        fShowers += fMcRunHeader->GetNumSimulatedShowers();
     101
     102    if (fMcRunHeader->GetAllEvtsTriggered())
     103      {
     104        *fLog << endl << all << endl <<
     105          "WARNING: the input data file contains only the" << endl <<
     106          "events that triggered. I will assume the standard value" << endl <<
     107          "for maximum impact parameter (400 m)" <<endl;
     108
     109
     110        if (fTrigNSB[0] > 0)
     111          *fLog << endl << all <<
     112            "WARNING: NSB rate can be overestimated by up to 5%." << endl <<
     113            "For a precise estimate of the total rate including NSB" << endl <<
     114            "accidental triggers I need a file containing all event headers."
     115                << endl;
     116        else
     117          *fLog << endl << all <<
     118            "WARNING: calculating only shower rate (no NSB accidental triggers)" << endl;
     119      }
     120
     121    *fLog << endl << all <<
     122      "WARNING: I will assume the standard maximum off axis angle" << endl <<
     123      "(5 degrees) for the original showers" << endl;
     124
     125    for (UInt_t i=0; i<fNum; i++)
     126      {
     127        if (fMcRunHeader->GetAllEvtsTriggered())
     128          {
     129            GetRate(i)->SetImpactMin(0.);
     130            GetRate(i)->SetImpactMax(40000.);   // in cm
     131          }
     132        GetRate(i)->SetSolidAngle(2.390941702e-2);  // sr
     133
     134        //
     135        // Set limits of energy range, coverting from GeV to TeV:
     136        //
     137        GetRate(i)->SetEnergyMin(fMcCorRunHeader->GetELowLim()/1000.);
     138        GetRate(i)->SetEnergyMax(fMcCorRunHeader->GetEUppLim()/1000.);
     139
     140      }
     141
     142    return kTRUE;
    74143}
    75144
     
    79148//
    80149//      dim:     fDimension
    81 //      part:    fPartId
    82 //      *trigbg: number of shower from bacground that triggers
     150//      *trigbg: number of NSB triggers for
    83151//               a given trigger condition.
    84 //      simbg:   Number of simulated showers for the background
     152//      simbg:   Number of simulated events for the NSB
    85153//      rate:    rate of incident showers
    86154//
    87155
    88 MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim, int part,
     156MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim,
    89157                                       float *trigbg, float simbg,
    90158                                       const char *name, const char *title)
    91159{
    92     Init(dim, part, trigbg, simbg, name, title);
     160    Init(dim, trigbg, simbg, name, title);
    93161}
    94162
     
    99167//
    100168//      dim:     fDimension
    101 //      part:    fPartId
    102 //      *trigbg: number of shower from bacground that triggers
     169//      *trigbg: number of NSB triggers for
    103170//               a given trigger condition.
    104 //      simbg:   Number of simulated showers for the background
    105 //
    106 MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, int part, float *trigbg,
    107                                        float simbg,
     171//      simbg:   Number of simulated events for the NSB
     172//
     173MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, float *trigbg,float simbg,
    108174                                       const char *name, const char *title)
    109175{
    110     Init(dim, part, trigbg, simbg, name, title);
     176    Init(dim, trigbg, simbg, name, title);
    111177}
    112178
     
    160226    }
    161227
     228    for (UInt_t i=0;i<fNum;i++)
     229      {
     230        MHMcRate &rate = *GetRate(i);
     231
     232        if (fTrigNSB)
     233          rate.SetBackground(fTrigNSB[i], fSimNSB);
     234        else
     235          rate.SetBackground(0., fSimNSB);
     236      }
     237
     238    return kTRUE;
     239}
     240
     241// --------------------------------------------------------------------------
     242//
     243//  The Process-function counts the number of simulated showers, the
     244//  number of analised showers and the number of triggers. It also updates
     245//  the limits for theta, phi, energy and impact parameter in the
     246//  MHMcRate container.
     247//
     248Bool_t MMcTriggerRateCalc::Process()
     249{
     250    //
     251    //  Counting analysed showers (except in the case in which the file
     252    //  contains only events that triggered, since then we do not know
     253    //  how many showers were analysed).
     254    //
     255
     256    if ( ! fMcRunHeader->GetAllEvtsTriggered() &&
     257         fMcEvt->GetPhotElfromShower() )
     258      fAnalShow++;
     259
     260    //
     261    // Set PartId and check it is the same for all events
     262    //
     263    if (fPartId < 0)
     264      fPartId = fMcEvt->GetPartId();
     265    else if (fPartId != fMcEvt->GetPartId())
     266      {
     267        *fLog << err << dbginf << "Incident particle type seems to change";
     268        *fLog << "from " << fPartId << " to " << fMcEvt->GetPartId() << endl;
     269        *fLog << "in input data files... aborting." << endl;
     270        return kFALSE;
     271      }
     272
     273    //
     274    //  Getting angles, energy and impact parameter to set boundaries
     275    //
     276    const Float_t theta = fMcEvt->GetTheta();
     277    const Float_t phi   = fMcEvt->GetPhi();
     278    const Float_t param = fMcEvt->GetImpact();
     279    const Float_t ener  = fMcEvt->GetEnergy()/1000.0;
     280
     281    //
     282    //  Counting number of triggers
     283    //
     284    for (UInt_t i=0; i<fNum; i++)
     285    {
     286        if (GetTrig(i)->GetFirstLevel())
     287            fTrigger[i] ++;
     288
     289        if ( ! fMcRunHeader->GetAllEvtsTriggered())
     290          GetRate(i)->UpdateBoundaries(ener, theta, phi, param);
     291    }
     292
     293    return kTRUE;
     294}
     295
     296// --------------------------------------------------------------------------
     297//
     298//  The PostProcess-function calculates and shows the trigger rate
     299//
     300Bool_t MMcTriggerRateCalc::PostProcess()
     301{
    162302    for (UInt_t i=0; i<fNum; i++)
    163303    {
     
    168308        {
    169309        case kPROTON:
    170             rate.SetFlux(0.1091, 2.75);
    171             break;
     310          if (fMcCorRunHeader->GetSlopeSpec() != -2.75)
     311            {
     312              *fLog << err << dbginf <<
     313                "Spectrum slope as read from  input file ("<<
     314                fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected one (-2.75) for protons" << endl << "... aborting." << endl;
     315              return kFALSE;
     316            }
     317          rate.SetFlux(0.1091, 2.75);
     318          break;
    172319        case kHELIUM:
    173             rate.SetFlux(0.0660, 2.62);
    174             break;
     320          if (fMcCorRunHeader->GetSlopeSpec() != -2.62)
     321            {
     322              *fLog << err << dbginf <<
     323                "Spectrum slope as read from  input file ("<<
     324                fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected one (-2.75) for Helium" << endl << "... aborting." << endl;
     325              return kFALSE;
     326            }
     327          rate.SetFlux(0.0660, 2.62);
     328          break;
    175329        default:
    176             *fLog << err << dbginf << "Unknown incident flux parameters for ";
    177             *fLog << fPartId<< " particle Id ... aborting." << endl;
    178             return kFALSE;
     330          *fLog << err << dbginf << "Unknown incident flux parameters for ";
     331          *fLog << fPartId<< " particle Id ... aborting." << endl;
     332          return kFALSE;
    179333        }
    180         rate.SetBackground(fTrigger[i], fAnalShow);
    181 
    182         fTrigger[i]=0;
    183     }
    184 
    185     fAnalShow=0.0;
    186 
    187     return kTRUE;
    188 }
    189 
    190 // --------------------------------------------------------------------------
    191 //
    192 //  The Process-function counts the number of simulated showers, the
    193 //  number of analised showers and the number of triggers. It also updates
    194 //  the limits for theta, phi, energy and impact parameter in the
    195 //  MHMcRate container.
    196 //
    197 Bool_t MMcTriggerRateCalc::Process()
    198 {
    199     //
    200     //  Counting analysed and simulated showers
    201     //
    202     fShowers++;
    203     if (fMcEvt->GetPhotElfromShower())
    204         fAnalShow++;
    205 
    206     //
    207     //  Getting angles, energy and impact parameter to set boundaries
    208     //
    209     const Float_t theta = fMcEvt->GetTheta();
    210     const Float_t phi   = fMcEvt->GetPhi();
    211     const Float_t param = fMcEvt->GetImpact();
    212     const Float_t ener  = fMcEvt->GetEnergy()/1000.0;
    213 
    214     //
    215     //  Counting number of triggers
    216     //
    217     for (UInt_t i=0; i<fNum; i++)
    218     {
    219         if (GetTrig(i)->GetFirstLevel())
    220             fTrigger[i] ++;
    221 
    222         GetRate(i)->UpdateBoundaries(ener, theta, phi, param);
    223     }
    224 
    225     return kTRUE;
    226 }
    227 
    228 // --------------------------------------------------------------------------
    229 //
    230 //  The PostProcess-function calculates and shows the trigger rate
    231 //
    232 Bool_t MMcTriggerRateCalc::PostProcess()
    233 {
     334    }
     335
    234336    //
    235337    // Computing trigger rate
  • trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h

    r1376 r1783  
    1111class MParList;
    1212class MMcEvt;
     13class MMcRunHeader;
     14class MMcCorsikaRunHeader;
    1315class MMcTrig;
    1416class MHMcRate;
     
    2224    TObjArray *fMcTrig;
    2325
     26    MMcRunHeader *fMcRunHeader;
     27    MMcCorsikaRunHeader *fMcCorRunHeader;
     28
    2429    UInt_t     fNum;           // decoded dimension
    2530    UInt_t     fFirst;
    2631    UInt_t     fLast;
    2732
    28     Float_t*    fTrigger;   // Number of triggered showers
     33    Float_t*   fTrigNSB;   // Number of triggers due to NSB alone
     34    Float_t    fSimNSB;    // Number of simulated NSB-only events
    2935
     36    Float_t*   fTrigger;       // Number of triggered showers
    3037    Float_t    fShowers;       // Number of simulated showers
    3138    Float_t    fAnalShow;      // Number of analysed showers
     
    3340    Int_t      fPartId;        // Incident particle that generates showers
    3441
    35     void Init(int dim, int part, float *trigbg,
     42    void Init(int dim, float *trigbg,
    3643              float simbg, const char *name, const char *title);
    3744
     
    4047
    4148public:
    42     MMcTriggerRateCalc(int dim=0, int part=14, float *trigbg=NULL,
    43                        float simbg=100000,
     49    MMcTriggerRateCalc(int dim=0, float *trigbg=NULL, float simbg=100000,
    4450                       const char *name=NULL, const char *title=NULL);
    4551
    46     MMcTriggerRateCalc(float rate, int dim, int part, float *trigbg,
    47                        float simbg,
     52    MMcTriggerRateCalc(float rate, int dim, float *trigbg, float simbg,
    4853                       const char *name=NULL, const char *title=NULL);
    4954
    5055    ~MMcTriggerRateCalc();
     56
     57    Bool_t ReInit(MParList *plist);
    5158
    5259    Bool_t PreProcess(MParList *pList);
Note: See TracChangeset for help on using the changeset viewer.