ROOT logo
#ifndef HEMCRAW_H
#define HEMCRAW_H


/////////////////////////////////////////////////////////////
//
//  HEmcRaw
//
//  Event data structure for HADES Electromagnetic Calorimeter (EMC).
//  first sketch bei I.Koenig 2017,
//  continued by JAM (j.adamczewski@gsi.de) 23-apr-2018
//
/////////////////////////////////////////////////////////////


#include "TObject.h"

#define NTIMESEMCRAW 10

class HEmcHit_t : public TObject
{
private:

    Float_t fLeadingEdgeTime;
    Float_t fTrailingEdgeTime;

public:
    HEmcHit_t(Float_t leading=0., Float_t trailing=0.):
	fLeadingEdgeTime(leading), fTrailingEdgeTime(trailing){}


    Float_t getLeadingTime() const { return fLeadingEdgeTime; }
    Float_t getTrailingTime() const { return fTrailingEdgeTime; }

    void  setTimes(Float_t leading, Float_t trailing)  { fLeadingEdgeTime = leading; fTrailingEdgeTime = trailing; }
    void  setTimes(HEmcHit_t& hit)  { fLeadingEdgeTime = hit.getLeadingTime(); fTrailingEdgeTime = hit.getTrailingTime(); }

    Float_t getToT() const
    {
	if(fLeadingEdgeTime==0 || fTrailingEdgeTime==0)
	    return -1; // detect incomplete edges
	return (fTrailingEdgeTime - fLeadingEdgeTime);
    }
    void clear() { fLeadingEdgeTime = 0; fTrailingEdgeTime = 0;}

    ClassDef(HEmcHit_t, 1) // object keeping leading and trailing edge times
};



class HEmcRaw : public TObject {
private:
    Char_t  fSector;           // sector number
    UChar_t fCell;             // cell number
    Char_t  fRow;               // row number (0..14)
    Char_t  fColumn;            // column number (0..16)

    HEmcHit_t fFastHits[NTIMESEMCRAW];
    HEmcHit_t fSlowHits[NTIMESEMCRAW];
    UInt_t fnFast;
    UInt_t fnSlow;

public:
    HEmcRaw() :fSector(-1),fCell(0),fRow(0),fColumn(0) {clearHits();}
    virtual ~HEmcRaw() {}

    Char_t   getSector()           const { return fSector; }
    UChar_t  getCell()             const { return fCell; }
    Char_t   getRow(void)          const {return fRow;}
    Char_t   getColumn(void)       const {return fColumn;}
    UInt_t   getFastMultiplicity() const { return fnFast; }
    UInt_t   getSlowMultiplicity() const { return fnSlow; }
    Float_t  getFastTimeLeading(UInt_t n) const;
    Float_t  getFastTimeTrailing(UInt_t n) const;
    Float_t  getSlowTimeLeading(UInt_t n) const;
    Float_t  getSlowTimeTrailing(UInt_t n) const;
    Float_t  getFastWidth(UInt_t n) const;
    Float_t  getSlowWidth(UInt_t n) const;
    void     getFastTimeAndWidth(UInt_t n, Float_t& s, Float_t& c) const;
    void     getSlowTimeAndWidth(UInt_t n, Float_t& s, Float_t& c) const;
    void     getAddress(Int_t& s, Int_t& c, Char_t& ro, Char_t& co) const;
    void     setSector(Char_t s)        { fSector = s; }
    void     setCell(UChar_t c)         { fCell   = c; }
    void     setRow(Char_t r)           { fRow    = r;}
    void     setColumn(Char_t c)        { fColumn = c;}
    void     setAddress(Int_t s, Int_t c, Char_t ro, Char_t co);
    void     clear() ;
    void     clearHits();
    void     addFastHit(HEmcHit_t theHit)                  { if(fnFast<NTIMESEMCRAW) { fFastHits[fnFast].setTimes(theHit); fnFast++;} }
    void     addFastHit(Float_t leading, Float_t trailing) { if(fnFast<NTIMESEMCRAW) { fFastHits[fnFast].setTimes(leading,trailing); fnFast++;}}
    void     addSlowHit(HEmcHit_t theHit)                  { if(fnSlow<NTIMESEMCRAW) { fSlowHits[fnSlow].setTimes(theHit); fnSlow++;} }
    void     addSlowHit(Float_t leading, Float_t trailing) { if(fnSlow<NTIMESEMCRAW) { fSlowHits[fnSlow].setTimes(leading,trailing); fnSlow++;}  }


    ClassDef(HEmcRaw, 1) // raw data of EMC detector using TRB3 for readout
};

inline void HEmcRaw::clear(void) {
    fSector = -1;
    fCell = 0;
    fRow = 0;
    fColumn = 0;
    for(Int_t i=0;i<NTIMESEMCRAW; i++){
         fFastHits[i].clear();
         fSlowHits[i].clear();
    }
    fnFast = 0;
    fnSlow = 0;
}

inline void HEmcRaw::clearHits(void) {
    for(Int_t i=0;i<NTIMESEMCRAW; i++){
         fFastHits[i].clear();
         fSlowHits[i].clear();
    }
    fnFast = 0;
    fnSlow = 0;
}

inline void HEmcRaw::getAddress(Int_t& s, Int_t& c, Char_t& ro, Char_t& co) const {
    s = fSector;
    c = fCell;
    ro= fRow;
    co= fColumn;
}

inline void HEmcRaw::setAddress(Int_t s, Int_t c,Char_t ro, Char_t co) {
    fSector = static_cast<Char_t>(s);
    fCell   = static_cast<UChar_t>(c);
    fRow    = ro;
    fColumn = co;
}

#endif /* ! HEMCRAW_H */
 hemcraw.h:1
 hemcraw.h:2
 hemcraw.h:3
 hemcraw.h:4
 hemcraw.h:5
 hemcraw.h:6
 hemcraw.h:7
 hemcraw.h:8
 hemcraw.h:9
 hemcraw.h:10
 hemcraw.h:11
 hemcraw.h:12
 hemcraw.h:13
 hemcraw.h:14
 hemcraw.h:15
 hemcraw.h:16
 hemcraw.h:17
 hemcraw.h:18
 hemcraw.h:19
 hemcraw.h:20
 hemcraw.h:21
 hemcraw.h:22
 hemcraw.h:23
 hemcraw.h:24
 hemcraw.h:25
 hemcraw.h:26
 hemcraw.h:27
 hemcraw.h:28
 hemcraw.h:29
 hemcraw.h:30
 hemcraw.h:31
 hemcraw.h:32
 hemcraw.h:33
 hemcraw.h:34
 hemcraw.h:35
 hemcraw.h:36
 hemcraw.h:37
 hemcraw.h:38
 hemcraw.h:39
 hemcraw.h:40
 hemcraw.h:41
 hemcraw.h:42
 hemcraw.h:43
 hemcraw.h:44
 hemcraw.h:45
 hemcraw.h:46
 hemcraw.h:47
 hemcraw.h:48
 hemcraw.h:49
 hemcraw.h:50
 hemcraw.h:51
 hemcraw.h:52
 hemcraw.h:53
 hemcraw.h:54
 hemcraw.h:55
 hemcraw.h:56
 hemcraw.h:57
 hemcraw.h:58
 hemcraw.h:59
 hemcraw.h:60
 hemcraw.h:61
 hemcraw.h:62
 hemcraw.h:63
 hemcraw.h:64
 hemcraw.h:65
 hemcraw.h:66
 hemcraw.h:67
 hemcraw.h:68
 hemcraw.h:69
 hemcraw.h:70
 hemcraw.h:71
 hemcraw.h:72
 hemcraw.h:73
 hemcraw.h:74
 hemcraw.h:75
 hemcraw.h:76
 hemcraw.h:77
 hemcraw.h:78
 hemcraw.h:79
 hemcraw.h:80
 hemcraw.h:81
 hemcraw.h:82
 hemcraw.h:83
 hemcraw.h:84
 hemcraw.h:85
 hemcraw.h:86
 hemcraw.h:87
 hemcraw.h:88
 hemcraw.h:89
 hemcraw.h:90
 hemcraw.h:91
 hemcraw.h:92
 hemcraw.h:93
 hemcraw.h:94
 hemcraw.h:95
 hemcraw.h:96
 hemcraw.h:97
 hemcraw.h:98
 hemcraw.h:99
 hemcraw.h:100
 hemcraw.h:101
 hemcraw.h:102
 hemcraw.h:103
 hemcraw.h:104
 hemcraw.h:105
 hemcraw.h:106
 hemcraw.h:107
 hemcraw.h:108
 hemcraw.h:109
 hemcraw.h:110
 hemcraw.h:111
 hemcraw.h:112
 hemcraw.h:113
 hemcraw.h:114
 hemcraw.h:115
 hemcraw.h:116
 hemcraw.h:117
 hemcraw.h:118
 hemcraw.h:119
 hemcraw.h:120
 hemcraw.h:121
 hemcraw.h:122
 hemcraw.h:123
 hemcraw.h:124
 hemcraw.h:125
 hemcraw.h:126
 hemcraw.h:127
 hemcraw.h:128
 hemcraw.h:129
 hemcraw.h:130
 hemcraw.h:131
 hemcraw.h:132
 hemcraw.h:133
 hemcraw.h:134