Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DigiSignal.h

Go to the documentation of this file.
00001 #ifndef DIGISIGNAL_H
00002 #define DIGISIGNAL_H
00003 
00004 #include <TObject.h>
00005 #include <TRef.h>
00006 #include <map>
00007 #include <vector>
00008 #include <iostream>
00009 #include "DigiScintHit.h"
00010 
00011 class DigiPE;
00012 
00013 class DigiSignal : public TObject
00014 {
00015  public:
00016   enum EDigiPmtTruth {
00017     kUnknown          = 0x00,   // Can happen: known cause is 0 charge
00018                                 // but random noise passes sparsification thresh.
00019     kGenuine          = 0x01,   // A real hit from real gosh-darn physics.
00020     kDarkNoise        = 0x02,   // Dark noise from the tube.
00021     kFibreLight       = 0x04,   // Random [singles] from a fibre. 
00022     kCrosstalk        = 0x08,   // A generic crosstalk hit.
00023     kCrosstalkOptical = 0x10,   // A crosstalk hit, specifically from
00024     kLeakFromNextBucket = 0x20,  // The next bucket leaked charge back to this one
00025     kLeakFromPrevBucket = 0x40,  // The prev bucket leaked charge forward to this one
00026     kAfterpulse         = 0x80   // This PE is an afterpulse
00027   };
00028   
00029   typedef Int_t                                 DigiPmtTruth_t;
00030   typedef std::vector<const DigiPE*>            PEList_t;
00031   typedef std::vector<TRef>                     HitList_t;
00032   typedef std::vector<Float_t>                  HitWeightList_t;
00033 
00034   DigiSignal();
00035   DigiSignal( Float_t charge, 
00036               PEList_t& pes,
00037               HitList_t& hits,
00038               HitWeightList_t& weights,
00039               DigiPmtTruth_t truth);
00040   DigiSignal( const DigiSignal& rhs );
00041   ~DigiSignal();
00042 
00043   // Getters.
00044   UInt_t               GetId()     const { return fSignalId; };
00045   Double_t             GetCharge() const { return fCharge; }; // in Munits
00046   const PEList_t&      GetPes()    const { return fPes; };
00047   const DigiPmtTruth_t GetTruth()  const { return fTruth; };
00048 
00049   // Some more pedantic get routines, to make code more readable.
00050   Int_t                GetNumPe()  const { return fNumPe; };
00051 
00052   UInt_t               GetNumberOfHits() const;
00053   const DigiScintHit*  GetHit( UInt_t hit ) const;
00054   Float_t              GetHitWeight( UInt_t hit ) const;
00055   Float_t              GetTotalHitWeight() const;
00056   const DigiScintHit*  GetBiggestHit() const;
00057 
00058   // Setters.
00059   void SetCharge(Double_t charge)         { fCharge = charge; };
00060   void AddDigiPE(const DigiPE* digipe); // Adds hits from the PE as well as the PE itself.
00061   void AddHit(const DigiScintHit* hitptr, Double_t weight = 0);  // Add just a hit.
00062   void SetTruth( DigiPmtTruth_t in)       { fTruth = in; };
00063   void SetTruthBit( DigiPmtTruth_t in )   { fTruth |= in; };
00064   void ClearTruthBit( DigiPmtTruth_t in ) { fTruth &= ( 0xFFFF - in ); };
00065   void Merge( DigiSignal& other) ; // Adds the other digiSignal to this one.
00066 
00067   // Printing.
00068   virtual void               Print(Option_t* option = "") const;
00069   virtual const char*        AsString(Option_t* option = "") const;
00070   friend  std::ostream& operator<<(std::ostream& os, const DigiSignal& s);
00071   virtual std::ostream&      FormatToOStream(std::ostream& os,
00072                                              Option_t *option="") const;
00073 
00074  private:  
00075   UInt_t         fSignalId;
00076   Float_t        fCharge; // in fC.
00077   PEList_t       fPes; // ! Temporary storage only
00078   Int_t          fNumPe;
00079   HitList_t       fHits;
00080   HitWeightList_t fHitWeights;
00081   DigiPmtTruth_t fTruth;  
00082 
00083   ClassDef(DigiSignal,4);
00084 };
00085 
00086 
00087 // Utility functions:
00088 const char* AsString(DigiSignal::DigiPmtTruth_t truth);
00089 
00090 
00091 // Inlines:
00092 inline UInt_t
00093 DigiSignal::GetNumberOfHits() const
00094 { 
00095   return fHits.size(); 
00096 }
00097 
00098 inline const DigiScintHit*  
00099 DigiSignal::GetHit( UInt_t hit ) const
00100 { 
00101   return dynamic_cast<const DigiScintHit*>(fHits[hit].GetObject());
00102 }
00103 
00104 inline Float_t
00105 DigiSignal::GetHitWeight( UInt_t hit ) const 
00106 {
00107   return fHitWeights[hit];
00108 }
00109 
00110 inline Float_t
00111 DigiSignal::GetTotalHitWeight( ) const
00112 {
00113   return (Float_t) GetNumPe();
00114 }
00115 
00116 
00117 
00118 inline const DigiScintHit*
00119 DigiSignal::GetBiggestHit() const
00120 { 
00121   UInt_t n = fHits.size();
00122   if(n==0) return 0;
00123   float biggest_weight = fHitWeights[0];
00124   UInt_t index =0;
00125   for(UInt_t i=0; i<n; i++) {
00126     if(fHitWeights[i] > biggest_weight) index = i;
00127   }
00128 
00129   return GetHit(index);
00130 }
00131 
00132 
00133 #endif

Generated on Mon Feb 15 11:06:37 2010 for loon by  doxygen 1.3.9.1