source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/detector/electronics/include/FrontEndChip.hh @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 5.3 KB
Line 
1// Euso simulation
2// class FrontEndChip
3// simulate the front end chip response
4// 10-4-2001 M.P. created
5
6#ifndef __FRONTENDCHIP_HH_
7#define __FRONTENDCHIP_HH_
8
9
10#include <vector>
11#include <map>
12
13#include "EsafMsgSource.hh"
14#include "EsafConfigurable.hh"
15#include "Config.hh"
16#include "euso.hh"
17
18class PmtSignal;
19class Photomultiplier;
20class ChipGtuData;
21class AnalogFrontEnd;
22
23// trigger types for front end chip
24// 0 = Basic trigger with independent pixels
25// 1 = group pixels in 2x2 matrices for trigger only
26// 2 = same as before with overlap
27//
28enum ChipTriggerType {
29    kStandardChipTrigger         = 0,
30    kGroups2x2ChipTrigger        = 1,   // standard is always present as well!
31    kGroups2x2OverlapChipTrigger = 2
32};
33
34const Int_t kMaxFeChannels=1000;
35
36class FrontEndChip : public EsafConfigurable, public EsafMsgSource {
37public:
38
39    // one front end chip can handle more than one pmt
40    FrontEndChip( Int_t channels = 0 );
41   
42    // dtor
43    virtual ~FrontEndChip();
44
45    // reset static variables
46    static void ResetClass();
47
48    // number of front end chip channels
49    inline Int_t Channels() const { return NumSide()*NumSide(); }
50
51    // number of channel in one side
52    inline Int_t NumSide() const { return fNumSide; }
53
54    // rows and columns
55    inline Int_t Row(Int_t ch) const {return (ch / NumSide() );}
56    inline Int_t Column(Int_t ch) const {return (ch - Row(ch)*NumSide());}
57    inline Int_t ChanRowCol(Int_t r,Int_t c) const {return (r*NumSide()+c);}
58
59    // chip number
60    inline Int_t Id() const {return fId;}
61
62    // unique channel id for the whole detector
63    Int_t UniqueChanId(Int_t ch);
64
65    // get pmt according to front end channel number
66    Photomultiplier* Pmt(Int_t ch = 0) const;
67
68    // get pmt channel number
69    Int_t PmtChannel(Int_t ch) const;
70       
71    // attach pmt(s)
72    void AssociatePmts(Photomultiplier *p1, Photomultiplier *p2 =0, 
73            Photomultiplier *p3 =0, Photomultiplier *p4 =0);
74
75    // attached analog front end object
76    inline void SetAfee(AnalogFrontEnd* af) {fAfee=af;}
77    inline AnalogFrontEnd* Afee() {return fAfee;}
78
79    // get the time of the last hit
80    inline Double_t LastHitTime() const {return fLastTime;}
81
82    // get the time of the first hit
83    inline Double_t FirstHitTime() const {return fFirstTime;}
84   
85    // add a list of PmtSignal into FE channel ch
86    void Add(vector<PmtSignal*>*, Int_t ch);
87
88    // reset chip data to be ready for next event
89    void Reset();
90
91    // return the number of pixels with activity
92    Int_t NumActivePixels() const;
93
94    // is empty ?
95    inline Bool_t IsEmpty() const {return fEmpty;}
96    inline void SetEmpty(Bool_t val=kTRUE) {fEmpty=val;}
97
98    // dump signals on stream
99    void DumpSignals(Int_t ch=-1,ostream& os=cout);
100   
101    // GTU signal. At each Gtu the chip response is computed
102    // and sent to the digital and trigger electronics
103    // start and end are the edges of this Gtu
104        // if doNG is true, night glow background is added
105    ChipGtuData* Gtu(Int_t GtuId, Double_t start, Double_t end, Bool_t doNG, Bool_t doEmptyGTUs=kTRUE);
106
107    // trigger type
108    ChipTriggerType GetTriggerType() const {return fgTriggerType;}
109
110    // macrocell row and column offsets
111    inline void SetCellRowColOffset(Int_t r,Int_t c) {fCellRowOffset=r;
112                                                      fCellColOffset=c;}
113    inline Int_t GetCellRowOffset() const { return fCellRowOffset;}
114    inline Int_t GetCellColOffset() const { return fCellColOffset;}
115 
116    // get pixel row and column
117    void GetPixelCellRowCol(Int_t ch, Int_t& r, Int_t& c) const; 
118
119    inline Int_t GetNumPmts() const { return fNumPmts; } 
120
121    // set night glow parameters
122    inline void SetNightGlowRate( Double_t r ) { fNightGlowRate=r; }
123    inline Double_t GetNightGlowRate() const { return fNightGlowRate; }
124
125    virtual Bool_t ClearMemory();
126    // physically release the memory allocated by the arrays of this object
127private:
128
129    // list of hits in each channel
130    vector<PmtSignal*>* fSignals[kMaxFeChannels];
131   
132    // pointer to Pmt
133    map<Int_t,Photomultiplier*> pPmts;
134    Int_t fNumPmts;
135    Int_t fNumPmtChannels;
136   
137    // pointer to analog front end object
138    AnalogFrontEnd* fAfee;
139   
140    Int_t fNumSide;                    // number of this front end channels
141    Int_t fId;                         // number of this chip
142    static Int_t fgChipCounter;        // chip counter
143
144    Double_t fFirstTime, fLastTime;
145    Bool_t fEmpty;
146
147    // macrocell row and column offsets for this chip
148    Int_t fCellRowOffset, fCellColOffset;
149
150    void TimeSort();                    // sort pmt signals by time
151 
152    Bool_t fSorted;
153    inline Bool_t IsSorted() const {return fSorted;}
154    inline void SetSorted(Bool_t val=kTRUE) {fSorted=val;}
155   
156    static Double_t fgResolvTime;
157    static Double_t fgCurrentGain;
158    static Double_t fgCurrentThreshold;
159    static Int_t fgCounterThreshold;
160    static ChipTriggerType fgTriggerType;
161   
162    Double_t fEffectiveGain[kMaxFeChannels];
163    Double_t fEffectiveThreshold[kMaxFeChannels];
164
165    static Int_t fgTotalHits;      // number of DETECTED PMT signals
166    static Int_t fgTotalSignals;   // number of PMT signals
167
168    Double_t fNightGlowRate;        // rate per channel
169   
170    EsafConfigClass(Electronics,FrontEndChip)
171
172    ClassDef(FrontEndChip,0)
173};
174
175//
176// inline members implementation
177//
178
179#endif
Note: See TracBrowser for help on using the repository browser.