Changeset 18482 for trunk/Mars/manalysis


Ignore:
Timestamp:
04/30/16 18:59:35 (9 years ago)
Author:
tbretz
Message:
Added a container class for the software trigger
Location:
trunk/Mars/manalysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/manalysis/MSoftwareTriggerCalc.cc

    r18480 r18482  
    2525//////////////////////////////////////////////////////////////////////////////
    2626//
    27 //   MSoftwareTrigger
     27//   MSoftwareTriggerCalc
    2828//
    2929//////////////////////////////////////////////////////////////////////////////
    30 #include "MSoftwareTrigger.h"
     30#include "MSoftwareTriggerCalc.h"
    3131
    3232#include <algorithm>
     
    3737#include "MParList.h"
    3838
    39 #include "MParameters.h"
    4039#include "MRawEvtData.h"
     40#include "MSoftwareTrigger.h"
    4141#include "MPedestalSubtractedEvt.h"
    4242
    43 ClassImp(MSoftwareTrigger);
     43ClassImp(MSoftwareTriggerCalc);
    4444
    4545using namespace std;
     
    4949// Default constructor.
    5050//
    51 MSoftwareTrigger::MSoftwareTrigger(const char *name, const char *title)
    52     : fRawEvt(0), fSignal(0), fTriggerSignal(0), fTriggerBaseline(0)
     51MSoftwareTriggerCalc::MSoftwareTriggerCalc(const char *name, const char *title)
     52    : fRawEvt(0), fSignal(0), fTrigger(0)
    5353{
    54     fName  = name  ? name  : "MSoftwareTrigger";
     54    fName  = name  ? name  : "MSoftwareTriggerCalc";
    5555    fTitle = title ? title : "Calculate the FACT trigger in software";
    5656}
     
    5858// --------------------------------------------------------------------------
    5959//
    60 Int_t MSoftwareTrigger::PreProcess(MParList *pList)
     60Int_t MSoftwareTriggerCalc::PreProcess(MParList *pList)
    6161{
    6262    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");//, AddSerialNumber(fNamePedestalSubtractedEvt));
     
    7474    }
    7575
    76     fTriggerSignal = (MParameterD*)pList->FindCreateObj("MParameterD","SoftwareTriggerSignal");
    77     if (!fTriggerSignal)
     76    fTrigger = (MSoftwareTrigger*)pList->FindCreateObj("MSoftwareTrigger");
     77    if (!fTrigger)
    7878        return kFALSE;
    7979
    80     fTriggerBaseline = (MParameterD*)pList->FindCreateObj("MParameterD","SoftwareTriggerBaseline");
    81     if (!fTriggerBaseline)
    82         return kFALSE;
    83 
    84     *fLog << flush << inf;
    8580    return kTRUE;
    8681}
     
    8883// --------------------------------------------------------------------------
    8984//
    90 Bool_t MSoftwareTrigger::ReInit(MParList *pList)
     85Bool_t MSoftwareTriggerCalc::ReInit(MParList *pList)
    9186{
    9287    // FIXME: Check number of samples!
     
    9691// --------------------------------------------------------------------------
    9792//
    98 Int_t MSoftwareTrigger::Process()
     93Int_t MSoftwareTriggerCalc::Process()
    9994{
    10095    const UShort_t *idx = fRawEvt->GetPixelIds();
     
    154149*/
    155150
    156     Float_t max = -50000;
     151    Float_t  max = -50000;
     152    UShort_t pos = 0;
     153    Short_t  patch = -1;
    157154
    158     const UInt_t nsum = buf.GetSize();
    159     for (Float_t *sum=buf.GetArray(); sum<buf.GetArray()+nsum; sum+=num)
     155    for (int i=0; i<160; i++)
    160156    {
    161157        int idx = 0;
    162158        Float_t v[4] = { 0, 0, 0, 0 };
    163159
     160        Float_t *sum=buf.GetArray() + num*i;
    164161        for (Float_t *ptr=sum+15; ptr<sum+num; ptr++)
    165162        {
     
    170167
    171168            const Float_t min = *std::min_element(v, v+4);
    172             if (min>max)
    173                 max = min;
     169            if (min<=max)
     170                continue;
     171
     172            max = min;
     173            pos = ptr-sum+beg;
     174            patch = i;
    174175        }
    175176    }
     
    179180    avg /= (num-15)*(1440-24);
    180181
    181     fTriggerSignal->SetVal(max);
    182     fTriggerSignal->SetReadyToSave();
    183 
    184     fTriggerBaseline->SetVal(avg);
    185     fTriggerBaseline->SetReadyToSave();
     182    fTrigger->SetData(patch, avg, pos, max);
     183    fTrigger->SetReadyToSave();
    186184
    187185    return kTRUE;
     
    190188// --------------------------------------------------------------------------
    191189//
    192 Int_t MSoftwareTrigger::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     190Int_t MSoftwareTriggerCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    193191{
    194192    return kTRUE;
  • trunk/Mars/manalysis/MSoftwareTriggerCalc.h

    r18480 r18482  
    1 #ifndef MARS_MSoftwareTrigger
    2 #define MARS_MSoftwareTrigger
     1#ifndef MARS_MSoftwareTriggerCalc
     2#define MARS_MSoftwareTriggerCalc
    33
    44#ifndef MARS_MTask
     
    77
    88class MRawEvtData;
    9 class MParameterD;
     9class MSoftwareTrigger;
    1010class MPedestalSubtractedEvt;
    1111
    12 class MSoftwareTrigger : public MTask
     12class MSoftwareTriggerCalc : public MTask
    1313{
    1414private:
    1515    MRawEvtData *fRawEvt;
    1616    MPedestalSubtractedEvt *fSignal;
    17     MParameterD *fTriggerSignal;
    18     MParameterD *fTriggerBaseline;
     17    MSoftwareTrigger *fTrigger;
    1918
    2019    Int_t  PreProcess(MParList *pList);
     
    2423
    2524public:
    26     MSoftwareTrigger(const char *name=NULL, const char *title=NULL);
     25    MSoftwareTriggerCalc(const char *name=NULL, const char *title=NULL);
    2726
    2827    virtual Bool_t InitArrays(Int_t) { return kTRUE; }
    2928
    30     ClassDef(MSoftwareTrigger, 0)   // Time And Charge Extractor Base Class
     29    ClassDef(MSoftwareTriggerCalc, 0)   // Time And Charge Extractor Base Class
    3130};
    3231
Note: See TracChangeset for help on using the changeset viewer.