Changeset 4921 for trunk/MagicSoft


Ignore:
Timestamp:
09/10/04 14:32:14 (20 years ago)
Author:
stamerra
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4916 r4921  
    1919
    2020                                                 -*-*- END OF LINE -*-*-
     21
     22 2004/09/10: Antonio Stamerra
     23
     24   * mreport/MReportTrigger.[h,cc]:
     25     - updated to read IPRs and to fill MTrigger{xxx} containers
     26
     27   * mreport/Makefile:
     28     - added include for mtrigger   
     29
     30   * Makefile:
     31     - added mtrigger directory
     32
     33   * NEWS:
     34     - updated
     35
    2136
    2237 2004/09/10: Thomas Bretz
  • trunk/MagicSoft/Mars/Makefile

    r4756 r4921  
    5959          mraw \
    6060          mcamera \
     61          mtrigger \
    6162          mpointing \
    6263          mreport \
  • trunk/MagicSoft/Mars/NEWS

    r4840 r4921  
    11                                                               -*-*- END -*-*-
    22 *** Version <cvs>
     3
     4   - The Report for the trigger section in the CC run summary has been
     5     updated, and now the IPRs (Individual Pixel Rates) are available.
    36
    47   - new macros for database interaction: filldotrun.C, filldotrbk.C
  • trunk/MagicSoft/Mars/mreport/MReportTrigger.cc

    r4575 r4921  
    1717!
    1818!   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
     19!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it>
     20!
    2021!   Copyright: MAGIC Software Development, 2000-2003
    2122!
     
    2829//
    2930// This is the class interpreting and storing the TRIGGER-REPORT information.
     31//  Updated to add IPR; data format follows TDAS 00-07 ver.6.3 jul-04
     32//  http://hegra1.mppmu.mpg.de/MAGIC/private/software/doc/control/tdas0007_v6.3.ps.gz
     33// 
     34//  *Input:
     35//
     36//  The report is divided into 8 sections:
     37//  - the cell rates                       (32 fields)
     38//  - L1 and L2 table name                 ( 2 fields)
     39//  - prescaling factors                  (2x8 fields)
     40//  - livetime and deadtime               (5x4 fields)
     41//  - L2 output bit rates                (20 integers)
     42//  - global rates (before/after presc.)    (2 floats)
     43//  - 18 dummy fields                      (18 fields)
     44//  - IPR                    (325 hexs + 397 integers)
     45//
     46//  *Output:
     47//
     48//  The values read from the report string are used to fill the following
     49//  containers:
     50//  - MTriggerIPR        (Individual Pixel Rates)
     51//  - MTriggerCell       (Rate of trigger cells)
     52//  - MTriggerBit        (Output Bits from prescaler (before and after presc.)
     53//  - MTriggerPrescFact  (Prescaling factors for each bit)
     54//  - MTriggerLiveTime   (Values of counters for dead/livetime)
    3055//
    3156//////////////////////////////////////////////////////////////////////////////
    3257#include "MReportTrigger.h"
    3358
     59#include "MParList.h"
     60
    3461#include "MLogManip.h"
    3562
     63#include "MTriggerIPR.h"
     64#include "MTriggerCell.h"
     65#include "MTriggerBit.h"
     66#include "MTriggerPrescFact.h"
     67#include "MTriggerLiveTime.h"
     68
     69#include "MReportFileRead.h"
     70
    3671ClassImp(MReportTrigger);
    3772
     
    4277// Default construtor. Initialize identifier to "TRIGGER-REPORT"
    4378//
    44 MReportTrigger::MReportTrigger() : MReport("TRIGGER-REPORT"), fPrescalerRates(19)
     79MReportTrigger::MReportTrigger() : MReport("TRIGGER-REPORT")
    4580{
    4681    fName  = "MReportTrigger";
     
    5085// --------------------------------------------------------------------------
    5186//
    52 // Interprete the body of the TRIGGER-REPORT string
    53 //
    54 Int_t MReportTrigger::InterpreteBody(TString &str, Int_t ver)
    55 {
    56     str = str.Strip(TString::kLeading);
    57 
     87// FindCreate the following objects:
     88//  - MTriggerIPR
     89//  - MTriggerCell
     90//  - MTriggerBit
     91//  - MTriggerPrescFact
     92//  - MTriggerLiveTime
     93//
     94Bool_t MReportTrigger::SetupReading(MParList &plist)
     95{
     96  fIPR = (MTriggerIPR*)plist.FindCreateObj("MTriggerIPR");
     97  if (!fIPR)
     98    return kFALSE;
     99
     100  fCell = (MTriggerCell*)plist.FindCreateObj("MTriggerCell");
     101  if (!fCell)
     102    return kFALSE;
     103
     104  fBit = (MTriggerBit*)plist.FindCreateObj("MTriggerBit");
     105  if (!fBit)
     106    return kFALSE;
     107
     108  fPrescFactor = (MTriggerPrescFact*)plist.FindCreateObj("MTriggerPrescFact");
     109  if (!fPrescFactor)
     110    return kFALSE;
     111
     112  fLiveTime = (MTriggerLiveTime*)plist.FindCreateObj("MTriggerLiveTime");
     113  if (!fLiveTime)
     114    return kFALSE;
     115
     116 
     117  return MReport::SetupReading(plist);
     118}
     119
     120
     121// --------------------------------------------------------------------------
     122//
     123// Interprete the Cell rates section of the report
     124//  Read 32 floats separated with a blank
     125//
     126Bool_t MReportTrigger::InterpreteCell(TString &str)
     127{
     128  Int_t len=0, n, i=0;
     129  Int_t gsNCells=32;
     130
     131  for (i=0;i<gsNCells;i++)
     132    {
     133      n = sscanf(str.Data(), " %f %n", &fCell->fCellRate[i], &len);
     134      if (n!=1)
     135        {
     136          *fLog << warn << "WARNING - Cell Scaler Value #" << i << " missing." << endl;
     137          return kCONTINUE;
     138        }
     139      str.Remove(0, len); // Remove cell rates from report string
     140    }
     141
     142  str=str.Strip(TString::kLeading); 
     143
     144  return kTRUE;
     145}
     146
     147// --------------------------------------------------------------------------
     148//
     149// Interprete the Prescaling factors section of the report
     150//
     151Bool_t MReportTrigger::InterpretePrescFact(TString &str)
     152{
     153  Int_t len=0, n, i=0;
     154  Int_t gsNPrescFacts=8;
     155 
     156  str.Remove(0, 1);
     157
     158  for (i=0;i<gsNPrescFacts;i++)
     159    {
    58160    const Int_t ws = str.First(' ');
    59161    if (ws<=0)
    60     {
    61         *fLog << warn << "WARNING - Cannot determin name of trigger table." << endl;
     162       {
     163         *fLog << warn << "WARNING - Cannot determine Prescaling factor #" << i << " descriptor" << endl;
     164        return kCONTINUE;
     165       }
     166    TString descriptor = str(0, ws);
     167    //*fLog  << descriptor <<endl;
     168    str.Remove(0, ws);
     169     
     170      n = sscanf(str.Data(), " %li %n", &fPrescFactor->fPrescFact[i], &len);
     171      if (n!=1)
     172        {
     173          *fLog << warn << "WARNING - prescaler factor " << i << " missing." << endl;
     174          return kCONTINUE;
     175        }
     176      str.Remove(0, len); // Remove Prescal. factors from report string
     177      // *fLog << warn << fPrescFactor->fPrescFact[i]<<endl;
     178    }
     179  str=str.Strip(TString::kLeading); 
     180 
     181  return kTRUE;
     182}
     183
     184// --------------------------------------------------------------------------
     185//
     186// Interprete the Scaler with Live-Deadtime section of the report
     187//  Read 4x5 integers separated with a blank
     188//
     189Bool_t MReportTrigger::InterpreteLiveTime(TString &str)
     190{
     191  Int_t len, n, i=0;
     192  Int_t gsNScalers=5;
     193  Int_t  dLSB, dMSB,lLSB, lMSB;
     194
     195  for (i=0;i<gsNScalers;i++)
     196    {
     197      n = sscanf(str.Data(), " %d %d %d %d %n", &lLSB, &lMSB,&dLSB, &dMSB, &len);
     198      if (n!=4)
     199        {
     200          *fLog << warn << "WARNING - Live-Deadtime Scaler Value #" << i << " missing." << endl;
     201          return kCONTINUE;
     202        }
     203
     204      str.Remove(0, len); // Remove Live-Deadtimes from string
     205
     206      //convert to seconds and fill container
     207      // (FIXME! only the MSB (seconds is now considered)
     208      (fLiveTime->fLiveTime)[i] = lMSB;
     209      (fLiveTime->fDeadTime)[i] = dMSB;     
     210    }
     211
     212  str=str.Strip(TString::kLeading); 
     213
     214  return kTRUE;
     215}
     216
     217// --------------------------------------------------------------------------
     218//
     219// Interprete the Bit rates section of the report
     220// 20 integers. First and last two are not used
     221//
     222Bool_t MReportTrigger::InterpreteBit(TString &str)
     223{
     224  Int_t len, n, i=0;
     225  Int_t gsNBits=20;
     226 
     227  for (i=0;i<gsNBits;i++)
     228    {
     229      n = sscanf(str.Data(), " %f %n", &fBit->fBit[i], &len);
     230      if (n!=1)
     231        {
     232          *fLog << warn << "WARNING - Bit rate #" << i << " missing." << endl;
     233          return kCONTINUE;
     234        }
     235      str.Remove(0, len); // Remove output bit rates from string
     236    }
     237
     238  str=str.Strip(TString::kLeading); 
     239
     240  return kTRUE;
     241}
     242
     243// --------------------------------------------------------------------------
     244//
     245// Interprete the L1 and L2 table names
     246// 1String + 1Int +1 String
     247//
     248Bool_t MReportTrigger::InterpreteL1L2Table(TString &str)
     249{
     250    const Int_t wsL1 = str.First(' ');
     251 
     252    if (wsL1<=0)
     253       {
     254        *fLog << warn << "WARNING - Cannot determine name of L1 trigger table." << endl;
     255        return kCONTINUE;
     256       }
     257   
     258    TString L1tablename = str(0, wsL1);
     259    str.Remove(0, wsL1);
     260
     261    // remove an integer between names
     262    Int_t len;
     263    Int_t mi;
     264    Int_t n=sscanf(str.Data(), "%d %n", &mi, &len);
     265    if (n!=1)
     266      {
     267        *fLog << warn << "WARNING - Not enough arguments." << endl;
     268        return kCONTINUE;
     269    }
     270    str.Remove(0, len);
     271
     272    // L2 tablename
     273    const Int_t wsL2 = str.First(' ');
     274 
     275    if (wsL2<=0)
     276      {
     277        *fLog << warn << "WARNING - Cannot determine name of L2 trigger table." << endl;
     278        return kCONTINUE;
     279      }   
     280    TString L2tablename = str(0, wsL2);
     281    str.Remove(0,wsL2);
     282    str.Strip(TString::kBoth);
     283   
     284    return kTRUE;
     285}
     286
     287// --------------------------------------------------------------------------
     288//
     289// Interprete an unused section of the report
     290// 18 integers
     291//
     292Bool_t MReportTrigger::InterpreteDummy(TString &str)
     293{
     294  Int_t len, n, i=0;
     295  Int_t gsNDummies=18;
     296  Int_t dummy; 
     297
     298  for (i=0;i<gsNDummies;i++)
     299    {
     300      n = sscanf(str.Data(), " %d %n", &dummy, &len);
     301      if (n!=1)
     302        {
     303          *fLog << warn << "WARNING - Dummy #" << i << " missing." << endl;
     304          return kCONTINUE;
     305        }
     306      str.Remove(0, len); // Remove dummies from report string
     307
     308    }
     309
     310  str=str.Strip(TString::kLeading); 
     311
     312
     313  return kTRUE;
     314}
     315
     316// --------------------------------------------------------------------------
     317//
     318// Interprete the IPR section of the report
     319//   sep-04
     320//   The IPR are saved as 340 (=number of pixs in trigger area) hex numbers
     321//   and as 397 (= #pixs in inner region) dec numbers.
     322//   Only the dec numbers are now saved in the MTriggerIPR container.
     323// 
     324
     325Bool_t MReportTrigger::InterpreteIPR(TString &str)
     326{
     327
     328  Int_t gsNhexIPR=340; //number of IPR saved in hex format
     329  Int_t gsNdecIPR=397; //number of IPR saved in dec format
     330 
     331  // Read Individual pixel rates in hex format
     332  const char *pos = str.Data();
     333  const char *end = str.Data() + gsNhexIPR*8;
     334 
     335  Int_t i=0,n,len;
     336  short dummy;
     337  while (pos < end)
     338    {
     339      const Char_t hex[9] = { pos[0], pos[1], pos[2], pos[3],pos[4],pos[5],pos[6],pos[7],0 };
     340      n = sscanf(hex, "%hx", &dummy);
     341      pos+=8;
     342      if (n!=1)
     343        {
     344          *fLog << warn << "WARNING - Rate #" << i << " missing." << endl;
     345          return kFALSE;
     346        }
     347    }
     348   
     349  str.Remove(0, end-str.Data()); // Remove IPR hex  from report string
     350  str.Strip(TString::kBoth);
     351 
     352  // ------ 
     353  // Read Individual pixel rates in dec format
     354  // and save them in the MTriggerIPR container
     355 
     356  for (i=0;i<gsNdecIPR;i++)
     357    {
     358      n = sscanf(str.Data(), " %ld %n", &fIPR->fIPR[i], &len);
     359      if (n!=1)
     360        {
     361          *fLog << warn << "WARNING - IPR dec #" << i << " missing." << endl;
     362          return kCONTINUE;
     363        }
     364      str.Remove(0, len); // Remove IPR dec from report string     
     365    }
     366 
     367  str=str.Strip(TString::kLeading); 
     368
     369  return kTRUE;
     370}
     371
     372
     373// --------------------------------------------------------------------------
     374//
     375// Interprete the body of the TRIGGER-REPORT string
     376//  Read comments for details
     377//
     378Int_t MReportTrigger::InterpreteBody(TString &str, Int_t ver )
     379{
     380
     381    str = str.Strip(TString::kLeading);
     382 
     383    // Extract trigger table name
     384    const Int_t ws = str.First(' ');
     385 
     386   if (ws<=0)
     387    {
     388        *fLog << warn << "WARNING - Cannot determine name of trigger table." << endl;
    62389        return kCONTINUE;
    63390    }
     
    66393    str.Remove(0, ws);
    67394
     395    // Check the Version of CC file, and takes care of the differences
     396    // introduced in the format of the report.
     397
     398    //if (ver<)....
     399       
     400    // Check the length of the report to take care of the differences
     401    // introduced in the format of the report (!Preliminary! the
     402    // Version number of the CC file should be used instead)
     403
     404    if (str.Length() < 1000)
     405      {
     406        *fLog << warn << " TRIGGER-REPORT: old report without IPRs" <<endl;
     407        return InterpreteOldBody(str);
     408      }
     409
     410    // Read the cell rates (32 fields)
     411    if (!InterpreteCell(str))
     412      return kCONTINUE;
     413
     414    // Read L1 and L2 table name (2 fields)
     415    if (!InterpreteL1L2Table(str))
     416      return kCONTINUE;   
     417
     418    // Read prescaling factors  (2x8 fields)
     419    if (!InterpretePrescFact(str))
     420      return kCONTINUE;
     421   
     422    // Read livetime and deadtime (5x4 fields)
     423    if (!InterpreteLiveTime(str))
     424      return kCONTINUE;
     425
     426    // Read L2 outout bit rates
     427    if (!InterpreteBit(str))
     428      return kCONTINUE;
     429
     430    // Read global rates (before and after prescaling)
    68431    Int_t len, n;
     432    n = sscanf(str.Data(), " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);
     433    if (n!=2)
     434    {
     435         *fLog << warn << "WARNING - Couldn't read Trigger rates." << endl;
     436        return kFALSE;
     437    }
     438    str.Remove(0,len);
     439    str.Strip(TString::kBoth);
     440
     441    // Read 18 dummy fields
     442    if (!InterpreteDummy(str))
     443      return kCONTINUE;
     444
     445    // Read IPR
     446    if (!InterpreteIPR(str))
     447      return kCONTINUE;
     448
     449 
     450
     451  //    str.Remove(0,len);
     452  //  str.Strip(TString::kBoth);
     453
     454  //*fLog << warn << " str=" << str << endl;
     455
     456    return str==(TString)"OVER" ? kTRUE : kCONTINUE;
     457}
     458
     459
     460// --------------------------------------------------------------------------
     461//
     462// Interprete the body of the TRIGGER-REPORT string
     463//  for OLD runs (older than may-04)
     464//
     465Bool_t MReportTrigger::InterpreteOldBody(TString &str)
     466{
     467
     468  Int_t len, n;
     469  Float_t fPrescalerRates[100];
    69470
    70471    const char *pos = str.Data();
    71472    for (int i=0; i<19; i++)
    72     {
     473      {
    73474        n = sscanf(pos, " %f %n", &fPrescalerRates[i], &len);
    74475        if (n!=1)
    75         {
     476          {
    76477            *fLog << warn << "WARNING - Scaler Value #" << i << " missing." << endl;
    77478            return kCONTINUE;
    78         }
     479          }
    79480        pos += len;
    80     }
    81     n = sscanf(pos, " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);
    82     if (n!=2)
    83     {
     481      }
     482
     483    n = sscanf(pos, " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);    if (n!=2)
     484      {
    84485        *fLog << warn << "WARNING - Couldn't read Trigger rates." << endl;
    85486        return kFALSE;
    86     }
     487      }
    87488    pos += len;
    88489    for (int i=0; i<11; i++)
    89     {
     490      {
    90491        Float_t dummy;
    91492        n = sscanf(pos, " %f %n", &dummy/*fRates[i]*/, &len);
    92493        if (n!=1)
    93         {
     494          {
    94495            *fLog << warn << "WARNING - Rate #" << i << " missing." << endl;
    95496            return kFALSE;
    96         }
     497          }
    97498        pos += len;
    98     }
     499      }
    99500    str.Remove(0, pos-str.Data());
    100501    str.Strip(TString::kBoth);
    101 
     502   
    102503    return str==(TString)"OVER" ? kTRUE : kCONTINUE;
    103504}
  • trunk/MagicSoft/Mars/mreport/MReportTrigger.h

    r4575 r4921  
    55#include "MReport.h"
    66#endif
    7 #ifndef MARS_MCamEvent
    8 #include "MCamEvent.h"
     7
     8#ifndef ROOT_TArrayL
     9#include <TArrayL.h>
    910#endif
    1011
    11 #ifndef ROOT_TArrayF
    12 #include <TArrayF.h>
    13 #endif
     12class MTriggerIPR;
     13class MTriggerCell;
     14class MTriggerBit;
     15class MTriggerPrescFact;
     16class MTriggerLiveTime;
    1417
    15 class MReportTrigger : public MReport, public MCamEvent
     18class MReportTrigger : public MReport
    1619{
    1720private:
    18     Float_t fL2BeforePrescaler; // L2 trigger rate before prescaler
    19     Float_t fL2AfterPrescaler;  // L2 trigger rate after prescaler
     21 
     22  Float_t fL2BeforePrescaler; //! L2 trigger rate before prescaler
     23  Float_t fL2AfterPrescaler;  //! L2 trigger rate after prescaler
     24 
     25  MTriggerBit *fBit;        //! container of the L2 prescaler rates
     26  MTriggerIPR *fIPR;        //! container of the IPR
     27  MTriggerCell *fCell;      //! container of the L1 cell trigger rates
     28  MTriggerPrescFact *fPrescFactor;  //! container of the L2 prescaling factors
     29  MTriggerLiveTime *fLiveTime; //! container of the scaler live-deadtime
     30 
     31  Bool_t SetupReading(MParList &plist);
    2032
    21     TArrayF fPrescalerRates;    //[Hz] L2 prescaler rates
    22     //TArrayF fRates;           //[Hz] currently undefined
     33  Bool_t InterpreteIPR(TString &str);
     34  Bool_t InterpreteCell(TString &str);
     35  Bool_t InterpreteBit(TString &str);
     36  Bool_t InterpretePrescFact(TString &str);
     37  Bool_t InterpreteLiveTime(TString &str);
     38  Bool_t InterpreteDummy(TString &str);
     39  Bool_t InterpreteL1L2Table(TString &str);
    2340
    24     Int_t InterpreteBody(TString &str, Int_t ver);
     41  Int_t InterpreteBody(TString &str, Int_t ver);
     42 
     43  Bool_t InterpreteOldBody(TString &str);
    2544
    2645public:
     
    3049    Float_t GetL2AfterPrescaler() const { return fL2AfterPrescaler; }
    3150
    32     Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
    33     {
    34         if(idx>18)
    35             return kFALSE;
    36 
    37         val = fPrescalerRates[idx];
    38         return kTRUE;
    39     }
    40 
    41     void DrawPixelContent(Int_t num) const
    42     {
    43     }
    44 
    4551    ClassDef(MReportTrigger, 1) // Class for TRIGGER-REPORT information
    46 };
     52 };
    4753
    4854#endif
  • trunk/MagicSoft/Mars/mreport/Makefile

    r4575 r4921  
    1919#  connect the include files defined in the config.mk file
    2020#
    21 INCLUDES = -I. -I../mbase -I../mastro -I../mcamera -I../mgui
     21INCLUDES = -I. -I../mbase -I../mastro -I../mcamera -I../mgui -I../mtrigger
    2222# mgui - MCameraDC <MCamEvent>
    2323
Note: See TracChangeset for help on using the changeset viewer.