00001 #ifndef TDetectorPulse_h
00002 #define TDetectorPulse_h
00003
00004 #include <vector>
00005 #include <string>
00006
00007 #include <TObject.h>
00008 #include <TH1.h>
00009
00010 #include "TAnalysedPulse.h"
00011 #include "TSetupData.h"
00012
00013
00014 #define TDP_GetField(ch, field)\
00015 return fParentPulse[ch]? \
00016 fParentPulse[ch]->Get##field():\
00017 definitions::DefaultValue
00018
00019 class TDetectorPulse : public TObject {
00020 public:
00021 enum ParentChannel_t { kFast, kSlow,kNumParents};
00022 struct Tag{};
00023
00024 public:
00025 TDetectorPulse();
00026 TDetectorPulse(const IDs::source& sourceID,
00027 int s_parentID, const TAnalysedPulse* s_parent,
00028 int f_parentID, const TAnalysedPulse* f_parent
00029 );
00030 virtual ~TDetectorPulse();
00031
00032 void Reset(Option_t* o = "");
00033
00034 double GetEnergy(ParentChannel_t ch=kSlow)const{
00035 TDP_GetField(ch,Energy); }
00036 double GetTime(ParentChannel_t ch=kFast)const{
00037 TDP_GetField(ch,Time); }
00038 double GetAmplitude(ParentChannel_t ch=kFast)const{
00039 TDP_GetField(ch,Amplitude); }
00040 double GetIntegral(ParentChannel_t ch=kFast)const{
00041 TDP_GetField(ch,Integral); }
00042 double GetPedestal(ParentChannel_t ch=kFast)const{
00043 TDP_GetField(ch,Pedestal); }
00044 const TAnalysedPulse* GetTAP(ParentChannel_t ch)const {return fParentPulse[ch];}
00045
00046 const IDs::source& GetSource() const { return fSource.GetValue(); }
00047
00048 bool IsPileUpSafe()const{return fPileUpSafe&&fCheckedForPileUp;};
00049 void SetPileUpSafe(const bool& val=true){fPileUpSafe=val;fCheckedForPileUp=true;};
00050 bool WasPileUpChecked()const{return fCheckedForPileUp;};
00051 void SetPileUpChecked(const bool& val=true){ fCheckedForPileUp=val;};
00052
00053 bool IsPairedPulse()const {return fParentPulse[kFast]&&fParentPulse[kSlow];}
00054 bool CouldBePaired()const {return fCouldBePaired;}
00055 bool IsGood()const {return ( !CouldBePaired() ) || IsPairedPulse();}
00056
00057 private:
00058 bool fCheckedForPileUp;
00059 bool fPileUpSafe;
00060 bool fCouldBePaired;
00061
00062 const TAnalysedPulse* fParentPulse[kNumParents];
00063 int fParentID[kNumParents];
00064
00065
00066 FlyWeight<IDs::source,TAnalysedPulse::Tag> fParentSource[kNumParents];
00067 FlyWeight<IDs::source,Tag> fSource;
00068
00069 ClassDef(TDetectorPulse, 2);
00070 };
00071
00072 #undef TDP_GetField
00073 #endif