AGAPRO_TB_AGATA.h 9.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/***************************************************************************
 *   Copyright (C) 2004 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.             *
 ***************************************************************************/

21 22
#ifndef _TB_AGATA
#define _TB_AGATA
23

24
#include "CrystalFrame.h"
25

26
#include "AGAPRO_TB_Detector.h"
27 28 29

namespace AGAPRO {

30 31 32 33 34 35 36 37
/// ****** CRYSTAL ******///

class TB_AGATA_CRYSTAL : public TB_Detector
{
protected:

    static const int kNCC = ADF::CrystalInterface::kNbCores;
    static const int kNSG = ADF::CrystalInterface::kNbSegments;
38 39 40
    static const int kMaxTraceLenght = 100;
    static const int kCrystalTraceLenght = 100;
    static const int kCCrystalTraceLenght = 60;
41 42

  private:
43 44 45 46 47
      Float_t SegTraces[kNSG*kMaxTraceLenght];
      UShort_t SegTracesu[kNSG*kMaxTraceLenght];

      Float_t CoreTraces[kNCC*kMaxTraceLenght];
      UShort_t CoreTracesu[kNCC*kMaxTraceLenght];
48 49 50

      Float_t SegE[kNSG];
      Float_t CoreE[kNCC];
Jérémie Dudouet's avatar
Jérémie Dudouet committed
51
      Float_t CoreT[kNCC];
52 53 54 55

      ULong64_t   crystalId;
      ULong64_t   crystalTS;

56
      UInt_t   fTraceLenght;
57

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
      bool WarnedDone = false;

public:
    TB_AGATA_CRYSTAL(TString name="", TString ADFKey="");
    virtual ~TB_AGATA_CRYSTAL();

    void Init();
    void InitValues();
    void InitTree();
    void Process(Int_t idet);
};

/// ****** PSA ******///

class TB_AGATA_PSA : public TB_Detector
{
protected:

    static const Int_t MaxHits = 36; // Max number of hits in one event

    Int_t       nbHits;                             // Number of hits in the crystal
    Float_t     hitE[MaxHits];                      // Energie of the hit
    Float_t     hitX[MaxHits];                      // X position of the hit in the Crystal Frame
    Float_t     hitY[MaxHits];                      // Y position of the hit in the Crystal Frame
    Float_t     hitZ[MaxHits];                      // Z position of the hit in the Crystal Frame
    Float_t     hitGX[MaxHits];                     // Position x of hit with , in global frame
    Float_t     hitGY[MaxHits];                     // Position y of hit with , in global frame
    Float_t     hitGZ[MaxHits];                     // Position z of hit with , in global frame
    Int_t       hitSg[MaxHits];                     // Crystal ID in which a hit occurs

    Int_t       coreId;                             // crystal ID
    Float_t     coreE0;                             // Core energy, high gain
    Float_t     coreE1;                             // Core energy, low gain
    Float_t     coreT0;                             // Core time, high gain
    Float_t     coreT1;                             // Core time, low gain

    ULong64_t   coreTS;

public:
    TB_AGATA_PSA(TString name="", TString ADFKey="");
    virtual ~TB_AGATA_PSA();

    void Init();
    void InitValues();
    void InitTree();
    void Process(Int_t idet);
};

106
/// ****** Builder ******///
107

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
class TB_AGATA_Builder_CRYSTAL : public TB_Detector
{
protected:
    static const int kNCC = ADF::CrystalInterface::kNbCores;
    static const int kNSG = ADF::CrystalInterface::kNbSegments;

    static const int kMaxTraceLenght = 100;
    static const int kCrystalTraceLenght = 100;
    static const int kCCrystalTraceLenght = 60;

protected:

    static const Int_t MaxCore = 180; // Max number of cores in one event

    Int_t       nbCrystals;                            // for more than 1 frame (built event)
    Int_t       crystalId[MaxCore];                    // for each crystal fired its ID
    ULong64_t   crystalTS[MaxCore];                    // timestamp of cores

    Int_t   SegTracesSize;
    Float_t SegTraces[kNSG*kMaxTraceLenght*MaxCore];
    UShort_t SegTracesu[kNSG*kMaxTraceLenght*MaxCore];

    Int_t   CoreTracesSize;
    Float_t CoreTraces[kNCC*kMaxTraceLenght*MaxCore];
    UShort_t CoreTracesu[kNCC*kMaxTraceLenght*MaxCore];

    Int_t   SegESize;
    Float_t SegE[kNSG*MaxCore];

    Int_t   CoreESize;
    Float_t CoreE[kNCC*MaxCore];

    ULong64_t   EvtCrystalTS;

142
    UInt_t   fTraceLenght;
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

    bool WarnedDone = false;

public:
    TB_AGATA_Builder_CRYSTAL(TString name="", TString ADFKey="");
    virtual ~TB_AGATA_Builder_CRYSTAL();

    void Init();
    void InitValues();
    void InitTree();
    void Process(Int_t idet);
};


class TB_AGATA_Builder_PSA : public TB_Detector
158
{
159 160 161 162 163 164 165 166 167 168 169
    struct core_property
    {
        Float_t E;
        Int_t   Id;
        Float_t HighHitE;
        Float_t HighHitX;
        Float_t HighHitY;
        Float_t HighHitZ;
        Int_t HighHitId;
        ULong64_t HighHitTS;
    };
170 171 172

protected:

173 174
    map<TString, Bool_t > fAreNeighbours;

175 176 177 178 179 180 181 182 183 184 185
    static const Int_t MaxHits = 500; // Max number of hits in one event
    static const Int_t MaxCore = 180; // Max number of cores in one event

    Int_t       nbHits;                             // Number of hits in the array
    Float_t     hitE[MaxHits];                      // Energie of the hit
    Float_t     hitX[MaxHits];                      // X position of the hit in the Crystal Frame
    Float_t     hitY[MaxHits];                      // Y position of the hit in the Crystal Frame
    Float_t     hitZ[MaxHits];                      // Z position of the hit in the Crystal Frame
    Float_t     hitGX[MaxHits];                     // Position x of hit with , in global frame
    Float_t     hitGY[MaxHits];                     // Position y of hit with , in global frame
    Float_t     hitGZ[MaxHits];                     // Position z of hit with , in global frame
186 187
    Int_t       hitId[MaxHits];                     // Crystal ID in which a hit occurs
    Int_t       hitSg[MaxHits];                     // Segment ID in which a hit occurs
188 189

    Int_t       nbCores;                            // for more than 1 frame (built event)
190
    Int_t       nbHitsperCry[MaxCore];              // nb of hits epr crystal
191
    Int_t       coreId[MaxCore];                    // for each crystal fired its ID
192 193 194
    Float_t     coreE0[MaxCore];                    // Core energy, high gain
    Float_t     coreE1[MaxCore];                    // Core energy, low gain
    Float_t     coreT0[MaxCore];                    // Core time, high gain
195

196 197 198 199 200
    array<Float_t, MaxCore> MaxESeg;                // Maximum segment energy in the core
    array<Float_t, MaxCore> MaxCoreX;               // X position of the max segment energy
    array<Float_t, MaxCore> MaxCoreY;               // Y position of the max segment energy
    array<Float_t, MaxCore> MaxCoreZ;               // Z position of the max segment energy

201
    Int_t       nbAdd;                              // Addback multiplicity
202
    Int_t       AddId[MaxCore];                     // Addback crystal Id of the hit with highest energy
203
    Float_t     AddE[MaxCore];                      // Addback energy
204 205 206
    Float_t     AddX[MaxCore];                      // XYZ Position of the hit with highest energy
    Float_t     AddY[MaxCore];
    Float_t     AddZ[MaxCore];
207 208

    ULong64_t   coreTS[MaxCore];                    // timestamp of cores
209
    ULong64_t   AddTS[MaxCore];                     // timestamp of he hit with highest energy
210
    ULong64_t   TSHit;
211

212
public:
213 214
    TB_AGATA_Builder_PSA(TString name="", TString ADFKey="");
    virtual ~TB_AGATA_Builder_PSA();
215

216 217 218 219
    void Init();
    void InitValues();
    void InitTree();
    void Process(Int_t idet);
220 221

protected:
222 223 224 225
    static bool coreCompare(const core_property& firstElem, const core_property& secondElem) {
        return firstElem.E > secondElem.E;
    }
};
226

227
/// ****** Tracking ******///
228

229 230
class TB_AGATA_Tracking : public TB_Detector
{
231

232
protected:
233

234
    static const Int_t MaxTrackedGamma = 500;
235

236 237
    Int_t       nbTrack;                            // Current number of tracked gamma-rays
    Float_t     trackE[MaxTrackedGamma];            // Energies of the tracked gamma
238

239 240 241
    Float_t     trackX1[MaxTrackedGamma];           // X position of the first interaction point
    Float_t     trackY1[MaxTrackedGamma];           // Y position of the first interaction point
    Float_t     trackZ1[MaxTrackedGamma];           // Z position of the first interaction point
242 243 244 245 246 247
    Float_t     trackX2[MaxTrackedGamma];           // X position of the Second interaction point
    Float_t     trackY2[MaxTrackedGamma];           // Y position of the Second interaction point
    Float_t     trackZ2[MaxTrackedGamma];           // Z position of the Second interaction point

    Int_t       trackType[MaxTrackedGamma];         // Interaction type (1-photo 2-compt 3-pair)
    Float_t     trackFOM[MaxTrackedGamma];          // figure of merit
248

249 250
    Float_t     trackT[MaxTrackedGamma];            // time of the track gamma
    Int_t       trackCrystalID[MaxTrackedGamma];    // CrystalID of the first interaction point of the track
251

252
    ULong64_t   TSTrack;
253 254

public:
255 256
    TB_AGATA_Tracking(TString name="", TString ADFKey="");
    virtual ~TB_AGATA_Tracking();
257

258 259 260 261
    void Init();
    void InitValues();
    void InitTree();
    void Process(Int_t idet);
262 263 264 265 266
};

}

#endif