AGAPRO_PreproHist.h 4.22 KB
Newer Older
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/***************************************************************************
 *   Copyright (C) 2018 by Jeremie Dudouet                                 *
 *   jeremie.dudouet(AT)csnsm.in2p3.fr                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef _PreproHist
#define _PreproHist

#include "AGAPRO_Histogramer.h"
#include "NarvalInterface.h"
#include "CrystalFrame.h"
#include "Trigger.h"
#include "CycleServer.h"

//! Post preprocessing histogramer
/*!
 */
namespace AGAPRO {

class PreproHist : public Histogramer
{
protected:      //Evt properties

    ULong64_t fFirstTS = 0;
    ULong64_t fLastTS = 0;

42
    UInt_t  fTraceLengthPSA;        // length of input traces
Jérémie Dudouet's avatar
Jérémie Dudouet committed
43 44 45 46 47

    // float version of the traces
    Float_t *fTracesSG[kNSG];
    Float_t *fTracesCC[kNCC];

48 49
    ADF::GeSegment *seg = nullptr;
    ADF::GeCore    *core = nullptr;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
50 51 52 53 54

    Float_t SegE[kNSG];       // in keV
    Float_t CoreE[kNCC];      // in keV
    Float_t SegBase[kNSG];       // in keV
    Float_t CoreBase[kNCC];      // in keV
55 56 57
    Float_t SegT0[kNSG];
    Float_t CoreT[kNCC];
    Float_t DeltaT;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
58

59 60 61
    Float_t fGatedRateEnergy = 0.;
    Float_t fGatedRateWidth = 0.;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
62 63 64 65
private:
    bool fPlotAmpli = false;
    bool fPlotAmplivsId = false;
    bool fPlotBaseline = false;
66
    bool fPlotT0 = false;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
67
    bool fPlotTimeStamps = false;
68
    bool fPlotGatedRates = false;
69
    bool fPlotDeltaT = false;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
70 71 72 73 74 75

    Float_t fNextCycleSec;
    Float_t fNextCycleMin;

    binning_TH1 fAmpliBinning;
    binning_TH1 fBaselineBinning;
76 77
    binning_TH1 fT0Binning;
    binning_TH1 fDeltaTBinning;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
78 79 80 81 82

    binning_TH2 fAmplivsIdBinning;

    Float_t     fMinSegAmpli;         // minimum segment amplitude to detect segment multiplicity

83
    enum class HistLib: int { Ampli, Ampli_vs_Id, Baseline, T0, TimeStamps, GatedRates, DeltaT };
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

    /// For T0 calculation (from PreprocessingFilterPSA.cpp

    const float tStep    = 10.f;        // ns/sample
    const float tScale   = tStep;       // 1ns/ch
    const int   speTTlen = int(100*tScale);
    const int   tGain    = 1;

    const float trigFraction = .05f; // start fitting stright line at this fraction of max amplitude (but not lower than trigLevel1)
    const int   trigChansSG  = 5;     // normally 4
    const float trigLevel1   = 10.f;  // lowered to 10 keV because of the gaussian smoothing performend before fitting the stright line
    const float calcTT_eminCC = 200.f;    // energy threshold when making the tCC-tSG analysis

    int      nSegFold;
    int      netChargeSegs[kNSG];
Jérémie Dudouet's avatar
Jérémie Dudouet committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

public:
    PreproHist();
    virtual ~PreproHist();

    virtual UInt_t Process();
    virtual Int_t SetInput();             //! to init your local variables with the ones from the buffers

    virtual void process_initialise ( UInt_t *error_code );   //! Constructor implementation

public:
    virtual UInt_t GetParameters(const std::string& confFile, Bool_t doList=false) override;

private:
    virtual void InitSMZ(Int_t id) override;

115 116
    int CalcT0();
    float FindTriggerTime (float *pTS, float trigFract, int trigChans, float &slope);   // stright line of parabola
Jérémie Dudouet's avatar
Jérémie Dudouet committed
117 118 119 120 121
};

}

#endif