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

Legend:

Unmodified
Added
Removed
  • 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.