Changeset 1787


Ignore:
Timestamp:
02/24/03 11:15:05 (22 years ago)
Author:
moralejo
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1786 r1787  
    66      - Fixed mistake when analysing camera files containing all events
    77        (including non-triggers): fShowers was always zero.
     8
     9    * macros/trigrate.C
     10      - Added some explanations. Style improvements in function GetNSBEvents.
    811
    912 2003/02/22: Wolfgang Wittek
  • trunk/MagicSoft/Mars/macros/trigrate.C

    r1783 r1787  
    2323!   Added one optional input parameter: a camera .root file containing
    2424!   pure NSB events. One such file is generated running the camera over an
    25 !   "empty" reflector file, with the NSB option on, and MINPHOT=0. The nsb
    26 !   files must contain the same trigger conditions as the proton file.
     25!   "empty" reflector file, with the NSB option on, and asking the camera
     26!   program (see camera program manual) to do the simulation even if no
     27!   photoelectron from the shower arrives at the camera. One also needs to
     28!   write to the output file all the events, both triggered and untriggered
     29!   (see again camera manual). These nsb camera files must contain the same
     30!   trigger conditions as the proton file.
     31!
    2732!   If no nsb file is supplied, the macro will assume no triggers from
    2833!   pure NSB fluctuations.
     
    3035\* ======================================================================== */
    3136
    32 Int_t GetNSBEvents(TString name, Float_t *BgR)
     37Float_t GetNSBEvents(TString name, Float_t *BgR, int dim)
    3338{
    3439    Int_t numnsbevents;
    3540
    36     TChain events("Events");
    37     events.Add(name);
     41    TFile bgfile(name);
     42    TTree *events = (TTree*) bgfile.Get("Events");
    3843
    3944    TH1F h("h","",5,.5,5.5);
    4045
    41     for (Int_t i = from; i <= to; i++)
     46    UInt_t from = dim>0 ?   1 : -dim;
     47    UInt_t to   = dim>0 ? dim : -dim;
     48
     49    for (UInt_t i = from; i <= to; i++)
    4250    {
    43         TString plot = "MMcTrig;";
    44         plot+=i;
    45         plot+=".fNumFirstLevel>>h";
     51      TString cond("MMcTrig;");
     52      cond += i;
     53      cond += ".";
     54      TBranch *b = events->GetBranch(cond);
     55      MMcTrig *mctrig;
     56      b->SetAddress(&mctrig);
    4657
    47         if (i == 0)
    48             plot = "MMcTrig.fNumFirstLevel>>h";
     58      Int_t tottrig = 0.;
     59     
     60      UInt_t imax = b->GetEntries();
    4961
    50         events.Draw(plot,"", "goff");
     62      for (UInt_t iev = 0; iev < imax; iev++)
     63        {       
     64          b->GetEvent(iev);
     65          tottrig += mctrig->GetFirstLevel();
     66        }
     67      // Set total number of L1 triggers:
     68      BgR[dim>0? i-1: 0] = (Float_t) tottrig;
    5169
    52         // Get total number of L1 triggers from histogram:
    53         BgR[dim>0? i-1: 0] = h.Integral()*h.GetMean();
     70      numnsbevents = (Float_t) imax;
     71    }
    5472
    55         numnsbevents = (Float_t) h.GetEntries();
    56     }
     73    cout << endl<<endl << numnsbevents << " " << BgR[0] << endl<<endl<<endl;
    5774
    5875    return numnsbevents;
     
    138155    Float_t numnsbevents = 5.e4; // some default value.
    139156    if (nsbfile)
    140         numnsbevents = GetNSBEvents(nsbfile, BgR);
     157      numnsbevents = GetNSBEvents(nsbfile, BgR, dim);
    141158
    142159    cout << "Number of Trigger conditions: " << num << endl;
Note: See TracChangeset for help on using the changeset viewer.