// Euso simulation // class FrontEndChip // simulate the front end chip response // 10-4-2001 M.P. created #ifndef __FRONTENDCHIP_HH_ #define __FRONTENDCHIP_HH_ #include #include #include "EsafMsgSource.hh" #include "EsafConfigurable.hh" #include "Config.hh" #include "euso.hh" class PmtSignal; class Photomultiplier; class ChipGtuData; class AnalogFrontEnd; // trigger types for front end chip // 0 = Basic trigger with independent pixels // 1 = group pixels in 2x2 matrices for trigger only // 2 = same as before with overlap // enum ChipTriggerType { kStandardChipTrigger = 0, kGroups2x2ChipTrigger = 1, // standard is always present as well! kGroups2x2OverlapChipTrigger = 2 }; const Int_t kMaxFeChannels = 256; class FrontEndChip : public EsafConfigurable, public EsafMsgSource { public: // one front end chip can handle more than one pmt FrontEndChip( Int_t channels = 64 ); // dtor virtual ~FrontEndChip(); // reset static variables static void ResetClass(); // number of front end chip channels inline Int_t Channels() const { return NumSide()*NumSide(); } // number of channel in one side inline Int_t NumSide() const { return fNumSide; } // rows and columns inline Int_t Row(Int_t ch) const {return (ch / NumSide() );} inline Int_t Column(Int_t ch) const {return (ch - Row(ch)*NumSide());} inline Int_t ChanRowCol(Int_t r,Int_t c) const {return (r*NumSide()+c);} // chip number inline Int_t Id() const {return fId;} // unique channel id for the whole detector Int_t UniqueChanId(Int_t ch); // get pmt according to front end channel number Photomultiplier* Pmt(Int_t ch = 0) const; // get pmt channel number Int_t PmtChannel(Int_t ch) const; // attach pmt(s) void AssociatePmts(Photomultiplier *p1, Photomultiplier *p2 =0, Photomultiplier *p3 =0, Photomultiplier *p4 =0); // attached analog front end object inline void SetAfee(AnalogFrontEnd* af) {fAfee=af;} inline AnalogFrontEnd* Afee() {return fAfee;} // get the time of the last hit inline Double_t LastHitTime() const {return fLastTime;} // get the time of the first hit inline Double_t FirstHitTime() const {return fFirstTime;} // add a list of PmtSignal into FE channel ch void Add(vector*, Int_t ch); // reset chip data to be ready for next event void Reset(); // return the number of pixels with activity Int_t NumActivePixels() const; // is empty ? inline Bool_t IsEmpty() const {return fEmpty;} inline void SetEmpty(Bool_t val=kTRUE) {fEmpty=val;} // dump signals on stream void DumpSignals(Int_t ch=-1,ostream& os=cout); // GTU signal. At each Gtu the chip response is computed // and sent to the digital and trigger electronics // start and end are the edges of this Gtu // if doNG is true, night glow background is added ChipGtuData* Gtu(Int_t GtuId, Double_t start, Double_t end, Bool_t doNG); // trigger type ChipTriggerType GetTriggerType() const {return fgTriggerType;} // macrocell row and column offsets inline void SetCellRowColOffset(Int_t r,Int_t c) {fCellRowOffset=r; fCellColOffset=c;} inline Int_t GetCellRowOffset() const { return fCellRowOffset;} inline Int_t GetCellColOffset() const { return fCellColOffset;} // get pixel row and column void GetPixelCellRowCol(Int_t ch, Int_t& r, Int_t& c) const; inline Int_t GetNumPmts() const { return fNumPmts; } // set night glow parameters inline void SetNightGlowRate( Double_t r ) { fNightGlowRate=r; } inline Double_t GetNightGlowRate() const { return fNightGlowRate; } private: // list of hits in each channel vector* fSignals[kMaxFeChannels]; // pointer to Pmt map pPmts; Int_t fNumPmts; Int_t fNumPmtChannels; // pointer to analog front end object AnalogFrontEnd* fAfee; Int_t fNumSide; // number of this front end channels Int_t fId; // number of this chip static Int_t fgChipCounter; // chip counter Double_t fFirstTime, fLastTime; Bool_t fEmpty; // macrocell row and column offsets for this chip Int_t fCellRowOffset, fCellColOffset; void TimeSort(); // sort pmt signals by time Bool_t fSorted; inline Bool_t IsSorted() const {return fSorted;} inline void SetSorted(Bool_t val=kTRUE) {fSorted=val;} static Double_t fgResolvTime; static Double_t fgCurrentGain; static Double_t fgCurrentThreshold; static Int_t fgCounterThreshold; static ChipTriggerType fgTriggerType; Double_t fEffectiveGain[kMaxFeChannels]; Double_t fEffectiveThreshold[kMaxFeChannels]; static Int_t fgTotalHits; // number of DETECTED PMT signals static Int_t fgTotalSignals; // number of PMT signals Double_t fNightGlowRate; // rate per channel EsafConfigClass(Electronics,FrontEndChip) ClassDef(FrontEndChip,0) }; // // inline members implementation // #endif