SimPmt Class Reference

#include <SimPmt.h>

Inheritance diagram for SimPmt:
SimPmtM16 SimPmtM64 SimPmtUTM16 SimPmtGenericM64 SimPmtM64Full SimPmtM16UTTimed SimPmtM64Oxford SimPmtM64ToyNL

List of all members.

Public Types

enum  EPmtType { kUnknown = 0, kM16 = 1, kM64 = 2 }
typedef enum SimPmt::EPmtType Pmt_t

Public Member Functions

 SimPmt (PlexPixelSpotId tube, VldContext context, TRandom *random=NULL, Int_t nPixels=0, Int_t nSpots=0)
virtual ~SimPmt ()
virtual void Reset (const VldContext &newContext)
virtual void AddDigiPE (const DigiPE *digipe)
virtual void SimulatePmt (void)
virtual Pmt_t GetType () const
virtual PlexPixelSpotId GetTubeId () const
virtual PlexPixelSpotId GetPixelSpotId (int pixel, int spot=1) const
virtual Int_t GetPixelNumber (const PlexPixelSpotId &psid) const
virtual Int_t GetSpotNumber (const PlexPixelSpotId &psid) const
virtual Int_t GetNumberOfPixels (void) const
virtual Int_t GetNumberOfSpots (void) const
SimPmtTimeBucketGetBucket (Int_t ibucket=0) const
virtual Float_t GetPe (int pixel, int spot=1, int bucket=0) const
virtual Float_t GetPeXtalk (int pixel, int spot=1, int bucket=0) const
virtual Float_t GetCharge (int pixel, int bucket=0) const
virtual Float_t GetTime (int pixel, int bucket=0) const
virtual DigiSignalCreateSignal (int pixel, int bucket=0) const
virtual Int_t GetTotalHitPixels (Bool_t with_xtalk) const
virtual Float_t GetTotalPe (void) const
virtual Float_t GetTotalCharge (void) const
virtual Float_t GetDynodeGain () const
virtual Float_t GetDynodeCharge (void) const
virtual Float_t GetDynodeTime (void) const
virtual Float_t GetDynodeCharge (int bucket) const
virtual Float_t GetDynodeTime (int bucket) const
virtual void Print (Option_t *="") const
const std::vector< DigiPE * > & GetCreatedDigiPEs ()
virtual Int_t TimeToBucket (Double_t)
virtual Double_t BucketToStartTime (Int_t)
virtual Double_t BucketToStopTime (Int_t)
virtual Float_t GetBucketDuration (Int_t=0)
virtual void Config (Registry &config)
virtual void SetAfterpulseModel (SimAfterpulseModel *model)

Static Public Member Functions

static void PrintConfig (Option_t *="")

Protected Member Functions

Float_t GenPoisson (Float_t lambda, Float_t x)
Float_t RandomGenPoisson (Float_t lambda)
Bool_t GetGainAndWidth (int pixel, int spot, Double_t &gain, Double_t &width)
virtual void SimulateAfterpulsing ()
virtual void SimulateOpticalXtalk ()
virtual void SimulateCharges ()
virtual void SimulateDarkNoise ()
virtual void SimulateNonlinearity ()
virtual void SimulateChargeCrosstalk ()
virtual Float_t GetPixelGain (Int_t pixel, Int_t spot=1)
virtual Float_t GetPixelSecondaryEmmisionRatio (Int_t pixel, Int_t spot=1)
virtual Float_t GenChargeFromPE (Int_t pixel, Int_t spot, Float_t pe)
virtual Float_t GenDarkNoiseCharge (Int_t pixel, Float_t timeWindow)
virtual Float_t GenNonlinearCharge (Int_t pixel, Float_t inCharge)
virtual Float_t GenOpticalCrosstalk (Int_t injPixel, Int_t injSpot, Int_t xtalkPixel, Float_t injPE)
virtual Float_t GenElectricalCrosstalk (Int_t injPixel, Int_t xtalkPixel, Float_t injCharge)
virtual void MoveOpticalPE (UInt_t npe, SimPixelTimeBucket &fromPixel, Int_t fromSpot, SimPixelTimeBucket &toPixel, Int_t toSpot)
virtual void CopyPEtoPEXtalk (void)

Protected Attributes

Int_t fNPixels
Int_t fNSpots
PlexPixelSpotId fTube
VldContext fContext
TRandom * fRandom
SimAfterpulseModelfSimAfterpulseModel
 Random number generator.
Float_t fTotalCharge
Float_t fDynodeTime

Static Protected Attributes

static Bool_t fsPmtDoOpticalCrosstalk = true
static Bool_t fsPmtDoChargeCrosstalk = true
static Bool_t fsPmtDoNonlinearity = true
static Bool_t fsPmtDoDarkNoise = true
static Double_t fsPmtScaleOpticalCrosstalk = 1.0
static Double_t fsPmtScaleChargeCrosstalk = 1.0
static Double_t fsPmtScaleAdjacentChargeCrosstalk = 1.0
static Double_t fsPmtScaleDiagonalChargeCrosstalk = 1.0
static Double_t fsPmtScaleAdjacentOpticalCrosstalk = 1.0
static Double_t fsPmtScaleDiagonalOpticalCrosstalk = 1.0
static Bool_t fsPmtApplyGainDrift = true
static Bool_t fsPmtHamamatsuPixelNumbering = false
static Double_t fsVaGain
static Double_t fsQieDacCharge
static Bool_t fsRebuildGainMap = true

Private Types

typedef std::pair< Int_t,
SimPmtTimeBucket * > 
BucketPair_t
typedef std::map< Int_t,
SimPmtTimeBucket * > 
BucketMap_t

Private Member Functions

 ClassDef (SimPmt, 1)

Private Attributes

BucketMap_t fTimeBuckets
std::vector< DigiPE * > fCreatedDigiPEs

Friends

class SimPmtBucketIterator

Detailed Description

Definition at line 38 of file SimPmt.h.


Member Typedef Documentation

typedef std::map<Int_t,SimPmtTimeBucket*> SimPmt::BucketMap_t [private]

Definition at line 201 of file SimPmt.h.

typedef std::pair<Int_t,SimPmtTimeBucket*> SimPmt::BucketPair_t [private]

Definition at line 200 of file SimPmt.h.


Member Enumeration Documentation

Enumerator:
kUnknown 
kM16 
kM64 

Definition at line 43 of file SimPmt.h.

00043                         {
00044     kUnknown = 0,
00045     kM16 = 1,
00046     kM64 = 2
00047   } Pmt_t;


Constructor & Destructor Documentation

SimPmt::SimPmt ( PlexPixelSpotId  tube,
VldContext  context,
TRandom *  random = NULL,
Int_t  nPixels = 0,
Int_t  nSpots = 0 
)

Definition at line 28 of file SimPmt.cxx.

References Reset().

00033   : fNPixels(nPixels),
00034     fNSpots(nSpots),
00035     fTube(tube),
00036     fContext(context),
00037     fRandom(random),
00038     fSimAfterpulseModel(0)
00039 {
00040   if(random == NULL) fRandom = gRandom;
00041  
00042   SimPmt::Reset(context);
00043 }

SimPmt::~SimPmt (  )  [virtual]

Definition at line 46 of file SimPmt.cxx.

References fCreatedDigiPEs, fTimeBuckets, and n.

00047 {
00048   BucketMap_t::iterator itr(fTimeBuckets.begin()),itrEnd(fTimeBuckets.end());
00049   for (; itr != itrEnd; ++itr) 
00050     delete itr->second; 
00051   fTimeBuckets.clear();
00052 
00053   UInt_t n= fCreatedDigiPEs.size();
00054   for(UInt_t i=0;i<n;i++) delete fCreatedDigiPEs[i];
00055 }


Member Function Documentation

void SimPmt::AddDigiPE ( const DigiPE digipe  )  [virtual]

Definition at line 76 of file SimPmt.cxx.

References SimPmtTimeBucket::AddDigiPE(), fDynodeTime, GetBucket(), GetPixelNumber(), DigiPE::GetPixelSpotId(), GetSpotNumber(), DigiPE::GetTime(), SimPmtTimeBucket::SetDynodeTime(), and TimeToBucket().

Referenced by SimulateAfterpulsing().

00077 {
00078   //
00079   // Add a DigiPE to the PMT.
00080   //
00081 
00082   if(!digipe) return;
00083 
00084   double time = digipe->GetTime();
00085   // First, find what bucket it goes into.
00086   int bucket = this->TimeToBucket(time);
00087   
00088   // Put the DigiPE in the bucket.
00089   // This bit of hocus-pocus does several things:
00090   // - makes the bucket if it doesn't exist.
00091   // - Translates the pixel and spot numbers to the range 1..N
00092   int pix =  GetPixelNumber(digipe->GetPixelSpotId());
00093   int spot = GetSpotNumber(digipe->GetPixelSpotId());
00094   GetBucket(bucket).AddDigiPE(digipe, pix, spot);
00095 
00096   // In addition, set the dynode time.
00097   GetBucket(bucket).SetDynodeTime(time);
00098   if(time<fDynodeTime) fDynodeTime = time;
00099 }

virtual Double_t SimPmt::BucketToStartTime ( Int_t   )  [inline, virtual]

Reimplemented in SimPmtM16UTTimed, and SimPmtM64.

Definition at line 110 of file SimPmt.h.

References Munits::ns.

Referenced by SimVaTimedElectronics::ReadoutPmt().

00110 { return -500*Munits::ns; };

virtual Double_t SimPmt::BucketToStopTime ( Int_t   )  [inline, virtual]

Reimplemented in SimPmtM16UTTimed, and SimPmtM64.

Definition at line 111 of file SimPmt.h.

References Munits::ns.

Referenced by SimVaTimedElectronics::ReadoutPmt().

00111 { return  500*Munits::ns; };

SimPmt::ClassDef ( SimPmt  ,
 
) [private]
void SimPmt::Config ( Registry config  )  [virtual]

Reimplemented in SimPmtM16UTTimed, SimPmtM64Full, and SimPmtM64Oxford.

Definition at line 757 of file SimPmt.cxx.

References fsPmtApplyGainDrift, fsPmtDoChargeCrosstalk, fsPmtDoDarkNoise, fsPmtDoNonlinearity, fsPmtDoOpticalCrosstalk, fsPmtHamamatsuPixelNumbering, fsPmtScaleAdjacentChargeCrosstalk, fsPmtScaleAdjacentOpticalCrosstalk, fsPmtScaleChargeCrosstalk, fsPmtScaleDiagonalChargeCrosstalk, fsPmtScaleDiagonalOpticalCrosstalk, fsPmtScaleOpticalCrosstalk, fsQieDacCharge, fsRebuildGainMap, fsVaGain, and Registry::Get().

Referenced by SimDetector::Config().

00758 {
00759   Int_t tbool;
00760   if(config.Get("pmtDoOpticalCrosstalk",tbool)) fsPmtDoOpticalCrosstalk = tbool;
00761   if(config.Get("pmtDoChargeCrosstalk",tbool))  fsPmtDoChargeCrosstalk = tbool;
00762   if(config.Get("pmtDoNonlinearity",tbool))     fsPmtDoNonlinearity = tbool;
00763   if(config.Get("pmtDoDarkNoise",tbool))        fsPmtDoDarkNoise = tbool;
00764   if(config.Get("pmtApplyGainDrift",tbool))     fsPmtApplyGainDrift = tbool;
00765 
00766   config.Get("pmtScaleOpticalCrosstalk",fsPmtScaleOpticalCrosstalk);
00767   config.Get("pmtScaleChargeCrosstalk", fsPmtScaleChargeCrosstalk);
00768   //Added by G. Pawloski to scale Adjacent and Diagonal separately
00769   config.Get("pmtScaleAdjacentChargeCrosstalk", fsPmtScaleAdjacentChargeCrosstalk);
00770   config.Get("pmtScaleDiagonalChargeCrosstalk", fsPmtScaleDiagonalChargeCrosstalk);
00771   config.Get("pmtScaleAdjacentOpticalCrosstalk", fsPmtScaleAdjacentOpticalCrosstalk);
00772   config.Get("pmtScaleDiagonalOpticalCrosstalk", fsPmtScaleDiagonalOpticalCrosstalk);
00773 
00774   config.Get("vaGain",fsVaGain);
00775   config.Get("qieDacCharge",fsQieDacCharge);
00776 
00777   if(config.Get("pmtRebuildGainMap",tbool)) fsRebuildGainMap = tbool;
00778 
00779   if(config.Get("pmtHamamatsuPixelNumbering",tbool))  fsPmtHamamatsuPixelNumbering = tbool;
00780 
00781 }

void SimPmt::CopyPEtoPEXtalk ( void   )  [protected, virtual]

Definition at line 733 of file SimPmt.cxx.

References SimPixelTimeBucket::AddPEXtalk(), fNPixels, fNSpots, SimPixelTimeBucket::GetDigiPE(), SimPixelTimeBucket::GetDigiPEXtalk(), SimPmtTimeBucket::GetPixelBucket(), and it.

Referenced by SimPmtM64::SimulateOpticalXtalk(), SimulateOpticalXtalk(), SimulatePmt(), SimPmtUTM16::SimulatePmt(), and SimPmtM64Oxford::SimulatePmt().

00734 {
00735   // Iterate over all time buckets.
00736   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00737     SimPmtTimeBucket& pmttb = it.Bucket();
00738 
00739     // Iterate over pixels.
00740     for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00741       SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00742       
00743       // Iterate over spots.
00744       for(Int_t spot = 1; spot<= fNSpots; spot++) {
00745         SimPixelTimeBucket::PeList_t &fromPeList = pixtb.GetDigiPE(spot);
00746         SimPixelTimeBucket::PeList_t &toPeList =   pixtb.GetDigiPEXtalk(spot);
00747 
00748         pixtb.AddPEXtalk(spot,(Float_t)(fromPeList.size()));
00749         toPeList.insert(fromPeList.begin(),fromPeList.end());   
00750       }
00751     }
00752   }
00753 }

DigiSignal * SimPmt::CreateSignal ( int  pixel,
int  bucket = 0 
) const [virtual]

Definition at line 152 of file SimPmt.cxx.

References SimPixelTimeBucket::CreateSignal(), GetBucket(), and SimPmtTimeBucket::GetPixelBucket().

Referenced by SimVaElectronics::ReadoutPmt().

00153 {
00154   return GetBucket(bucket).GetPixelBucket(pixel).CreateSignal();
00155 }

Float_t SimPmt::GenChargeFromPE ( Int_t  pixel,
Int_t  spot,
Float_t  pe 
) [protected, virtual]

Reimplemented in SimPmtM16, SimPmtM64, and SimPmtM64Oxford.

Definition at line 588 of file SimPmt.cxx.

References GetPixelGain(), GetPixelSecondaryEmmisionRatio(), and RandomGenPoisson().

Referenced by SimulateCharges().

00589 {
00590   //
00591   // Does a single charge simulation.
00592   //
00593   
00594   // First version, by Nathaniel.
00595   // Uses the generalized poisson to get the job done.
00596 
00597   if(pe<=0) return 0;
00598 
00599   // The secondary emmission ratio is directly related to the width of the 1pe peak.
00600   Float_t secemm = GetPixelSecondaryEmmisionRatio(pixel,spot);
00601 
00602   // Choose a random number from the spectrum with a peak at the number of expected 2nary pes.
00603   Float_t mean2ndaryPe = pe * secemm;
00604   Float_t secondary_pe = RandomGenPoisson(mean2ndaryPe);
00605 
00606   // convert this into charge.
00607   return (secondary_pe / secemm)
00608     * GetPixelGain(pixel,spot)                   // Gain of pixel
00609     * 1.6e2;                                     // Convert 10^6 e -> fempto Coulombs  
00610 
00611 }

Float_t SimPmt::GenDarkNoiseCharge ( Int_t  pixel,
Float_t  timeWindow 
) [protected, virtual]

Reimplemented in SimPmtM16, SimPmtM64, and SimPmtUTM16.

Definition at line 613 of file SimPmt.cxx.

Referenced by SimulateDarkNoise().

00615 {
00616   //
00617   // Dark noise simulation.
00618   //
00619   // Return the charge (in coulombs) that results from opening an integration gate of duration timeWindow (in Munits).
00620   // (This should return zero most of the time).
00621   //
00622   
00623   // No simulation yet.
00624   return 0; 
00625 }

Float_t SimPmt::GenElectricalCrosstalk ( Int_t  injPixel,
Int_t  xtalkPixel,
Float_t  injCharge 
) [protected, virtual]

Reimplemented in SimPmtM16, and SimPmtM64.

Definition at line 661 of file SimPmt.cxx.

Referenced by SimulateChargeCrosstalk().

00664 {
00665   //
00666   // Electrical crosstalk simulation.
00667   //
00668   // If inCharge femtoCoulombs of charge are seen on the anode of injPixel, then
00669   // this returns the quantity of charge that will be leaked to xtalkPixel.
00670   // This may be a random quantity, or a fixed fraction, depending on the model.
00671 
00672  return 0; 
00673 }

Float_t SimPmt::GenNonlinearCharge ( Int_t  pixel,
Float_t  inCharge 
) [protected, virtual]

Reimplemented in SimPmtM16, SimPmtM64, SimPmtM64Oxford, and SimPmtM64ToyNL.

Definition at line 628 of file SimPmt.cxx.

Referenced by SimulateNonlinearity().

00630 {
00631   //
00632   // Nonlinearity Simulation.
00633   //
00634   // Given a charge on the anode, this routine applies
00635   // the nonlinearity for the PMT to give a new output charge.
00636   // 
00637   // For a completely linear response, return inCharge.
00638   
00639   return inCharge; 
00640 }

Float_t SimPmt::GenOpticalCrosstalk ( Int_t  injPixel,
Int_t  injSpot,
Int_t  xtalkPixel,
Float_t  injPE 
) [protected, virtual]

Reimplemented in SimPmtM16, and SimPmtUTM16.

Definition at line 642 of file SimPmt.cxx.

Referenced by SimulateOpticalXtalk().

00646 {
00647   // 
00648   // Optical crosstalk simulation.
00649   //
00650   // If injPE photoelectrons of light are injected into injPixel and injSpot,
00651   // this routine returns the number of the photoelectrons that will leak into
00652   // the xtalkPixel.  Note that this should probably be a random integer..
00653   //
00654   
00655   // Return 0 for no crosstalk.
00656   
00657   return 0; 
00658 
00659 }

Float_t SimPmt::GenPoisson ( Float_t  lambda,
Float_t  x 
) [protected]

A generalized verision of the Poissonian distribution, where x! -> Gamma(x+1) This is a real dist'n, as opposed to the discrete Poisson dist'n.

Properties:

P(x) = GP(x) for x = integer

int(GP(x), x=0..inf) = 1

Definition at line 230 of file SimPmt.cxx.

Referenced by RandomGenPoisson().

00231 {
00245 
00246   // For the usual compilers:
00247   //return  exp(-lambda + x*log(lambda)-lgamma(x+1.0));
00248 
00249   // For ROOT:
00250   return  exp(-lambda + x*log(lambda)-TMath::LnGamma(x+1.0));
00251 }

SimPmtTimeBucket & SimPmt::GetBucket ( Int_t  ibucket = 0  )  const [inline]

Definition at line 300 of file SimPmt.h.

References fNPixels, fNSpots, fTimeBuckets, and it.

Referenced by AddDigiPE(), CreateSignal(), GetCharge(), GetDynodeCharge(), GetDynodeTime(), GetPe(), GetPeXtalk(), GetTime(), SimVaTimedElectronics::ReadoutPmt(), SimPmtM64Oxford::SimulateAnodeEffects(), and SimPmtM64Full::SimulateCharges().

00301 {
00302   // Don't know if this should be const or not, really,
00303   // since it can create new objects.
00304   // However, it doesn't _change_ anything, so it's probably OK.
00305   
00306   BucketMap_t::iterator it = fTimeBuckets.find(ibucket);
00307   if(it == fTimeBuckets.end()) {
00308     BucketPair_t newpair(ibucket,new SimPmtTimeBucket(fNPixels,fNSpots));
00309     it = (fTimeBuckets.insert(newpair)).first;
00310   }
00311   return *(it->second);
00312 }

virtual Float_t SimPmt::GetBucketDuration ( Int_t  = 0  )  [inline, virtual]

Reimplemented in SimPmtM16UTTimed, and SimPmtM64.

Definition at line 112 of file SimPmt.h.

References Munits::ns.

Referenced by SimulateDarkNoise().

00112 { return 1000*Munits::ns; };

Float_t SimPmt::GetCharge ( int  pixel,
int  bucket = 0 
) const [virtual]

Definition at line 133 of file SimPmt.cxx.

References GetBucket(), SimPixelTimeBucket::GetCharge(), and SimPmtTimeBucket::GetPixelBucket().

Referenced by SimPmtUTM16::Print(), SimPmtM16::Print(), SimPmtM64::Print(), and SimVaElectronics::ReadoutPmt().

00134 {
00135   // 
00136   //  Get charge (in couloms) on pixel, at time bucket.
00137   // 
00138 
00139   return GetBucket(bucket).GetPixelBucket(pixel).GetCharge();
00140 }

const std::vector<DigiPE*>& SimPmt::GetCreatedDigiPEs (  )  [inline]

Definition at line 104 of file SimPmt.h.

References fCreatedDigiPEs.

00104 { return fCreatedDigiPEs; };

virtual Float_t SimPmt::GetDynodeCharge ( int  bucket  )  const [inline, virtual]

Definition at line 97 of file SimPmt.h.

References GetBucket(), GetDynodeGain(), and SimPmtTimeBucket::GetTotalCharge().

00097 { return GetBucket(bucket).GetTotalCharge() * GetDynodeGain(); };

virtual Float_t SimPmt::GetDynodeCharge ( void   )  const [inline, virtual]

Definition at line 95 of file SimPmt.h.

References fTotalCharge, and GetDynodeGain().

Referenced by SimVaTimedElectronics::ReadoutDetector(), and SimVaElectronics::ReadoutDetector().

00095 { return fTotalCharge * GetDynodeGain(); };

virtual Float_t SimPmt::GetDynodeGain (  )  const [inline, virtual]

Reimplemented in SimPmtM16, SimPmtM64, and SimPmtUTM16.

Definition at line 94 of file SimPmt.h.

Referenced by GetDynodeCharge().

00094 { return 0.8; }; // Gain relative to anode.

virtual Float_t SimPmt::GetDynodeTime ( int  bucket  )  const [inline, virtual]

Definition at line 98 of file SimPmt.h.

References GetBucket(), and SimPmtTimeBucket::GetDynodeTime().

00098 { return GetBucket(bucket).GetDynodeTime(); };

virtual Float_t SimPmt::GetDynodeTime ( void   )  const [inline, virtual]

Definition at line 96 of file SimPmt.h.

References fDynodeTime.

Referenced by SimVaElectronics::ReadoutDetector(), and SimVaElectronics::ReadoutPmt().

00096 { return fDynodeTime; };

Bool_t SimPmt::GetGainAndWidth ( int  pixel,
int  spot,
Double_t &  gain,
Double_t &  width 
) [protected]

Return true for good data, false for default or guestimate data. Give outGain as a unitless value (i.e. nominal = 10^6) Give outWidth as a fractional width.

Definition at line 319 of file SimPmt.cxx.

References PlexPixelSpotId::AsString(), PlexStripEndId::AsString(), Calibrator::DecalGainAndWidth(), Munits::e_SI, fContext, fsPmtApplyGainDrift, fsQieDacCharge, fsVaGain, Calibrator::GetDriftCorrected(), GetPixelSpotId(), PlexHandle::GetStripEndId(), GetTubeId(), Calibrator::Instance(), PlexStripEndId::IsValid(), Msg::kDebug, ElecType::kQIE, and MSG.

Referenced by SimPmtM64Oxford::CalStageGains(), SimPmtM16::GenChargeFromPE(), and SimPmtUTM16::InitSECValues().

00320 {
00324 
00325   PlexPixelSpotId psid = GetPixelSpotId(pixel,spot);
00326   FloatErr adcgain, adcwidth;
00327   Calibrator::Instance().DecalGainAndWidth(adcgain,adcwidth,psid);
00328 
00329   // Set the fractional width.
00330   outWidth =adcwidth/adcgain;
00331   
00332   float driftedGain = adcgain;
00333   if(fsPmtApplyGainDrift) {
00334     PlexHandle plex(fContext);
00335     PlexStripEndId seid = plex.GetStripEndId(psid);
00336     if(seid.IsValid()) {
00337       driftedGain = Calibrator::Instance().GetDriftCorrected(adcgain,seid);
00338       if(driftedGain != adcgain)
00339         MSG("DetSim",Msg::kDebug) << "Drifted gain on " << psid.AsString() 
00340                                   << " " << seid.AsString() 
00341                                   << " by " << driftedGain/adcgain << endl;      
00342     }
00343   }
00344   
00345   // convert into gain units (i.e. unitless)
00346   float elecgain = 1.0/fsVaGain;
00347   if(GetTubeId().GetElecType()==ElecType::kQIE) elecgain = fsQieDacCharge;
00348   outGain = driftedGain * elecgain / Munits::e_SI;
00349 
00350    return true;
00351 }

virtual Int_t SimPmt::GetNumberOfPixels ( void   )  const [inline, virtual]

Definition at line 79 of file SimPmt.h.

References fNPixels.

Referenced by SimVaElectronics::ReadoutPmt(), SimQieElectronics::ReadoutPmt(), and SimVaTimedElectronics::ReadoutPmt().

00079 { return fNPixels; };

virtual Int_t SimPmt::GetNumberOfSpots ( void   )  const [inline, virtual]

Definition at line 80 of file SimPmt.h.

References fNSpots.

Referenced by SimVaElectronics::ReadoutPmt(), and SimVaTimedElectronics::ReadoutPmt().

00080 { return fNSpots; };

Float_t SimPmt::GetPe ( int  pixel,
int  spot = 1,
int  bucket = 0 
) const [virtual]

Definition at line 103 of file SimPmt.cxx.

References GetBucket(), SimPixelTimeBucket::GetPE(), SimPmtTimeBucket::GetPixelBucket(), and SimPixelTimeBucket::GetTotalPE().

Referenced by SimPmtUTM16::Print(), SimPmtM16::Print(), and SimPmtM64::Print().

00104 {
00105   // 
00106   //  Get signal PE on pixel, spot at time bucket.
00107   //  Use spot = 0 to get total of all spots.
00108   // 
00109   if(spot == 0 ) {
00110     // Get total.
00111     return GetBucket(bucket).GetPixelBucket(pixel).GetTotalPE();
00112   }
00113 
00114   return GetBucket(bucket).GetPixelBucket(pixel).GetPE(spot);
00115 }

Float_t SimPmt::GetPeXtalk ( int  pixel,
int  spot = 1,
int  bucket = 0 
) const [virtual]

Definition at line 117 of file SimPmt.cxx.

References GetBucket(), SimPixelTimeBucket::GetPEXtalk(), SimPmtTimeBucket::GetPixelBucket(), and SimPixelTimeBucket::GetTotalPEXtalk().

Referenced by SimPmtUTM16::Print(), and SimVaElectronics::ReadoutPmt().

00118 {
00119   // 
00120   //  Get signal PE on pixel, spot at time bucket.
00121   //  Use spot = 0 to get total of all spots.
00122   // 
00123   if(spot == 0 ) {
00124     // Get total.
00125     return GetBucket(bucket).GetPixelBucket(pixel).GetTotalPEXtalk();
00126   }
00127 
00128   return GetBucket(bucket).GetPixelBucket(pixel).GetPEXtalk(spot);
00129 }

Float_t SimPmt::GetPixelGain ( Int_t  pixel,
Int_t  spot = 1 
) [inline, protected, virtual]

Reimplemented in SimPmtGenericM64.

Definition at line 241 of file SimPmt.h.

Referenced by GenChargeFromPE().

00242 { 
00243   return 1.0; // Units of 10^6.
00244 }

Int_t SimPmt::GetPixelNumber ( const PlexPixelSpotId psid  )  const [inline, virtual]

Definition at line 271 of file SimPmt.h.

References fsPmtHamamatsuPixelNumbering, and PlexPixelSpotId::GetPixel().

Referenced by AddDigiPE().

00272 {
00273   //
00274   // Extract the pixel number from the psid,
00275   // which would be a trivial plex operation
00276   // if it weren't for the fact that the database is stupid.
00277   //
00278   if(fsPmtHamamatsuPixelNumbering) 
00279     return (psid.GetPixel());
00280   else
00281     return 1+(psid.GetPixel());
00282 }

Float_t SimPmt::GetPixelSecondaryEmmisionRatio ( Int_t  pixel,
Int_t  spot = 1 
) [inline, protected, virtual]

Reimplemented in SimPmtGenericM64.

Definition at line 246 of file SimPmt.h.

Referenced by GenChargeFromPE().

00247 {
00248   return 4.5; 
00249 }

PlexPixelSpotId SimPmt::GetPixelSpotId ( int  pixel,
int  spot = 1 
) const [inline, virtual]

Definition at line 253 of file SimPmt.h.

References fsPmtHamamatsuPixelNumbering, fTube, PlexPixelSpotId::SetPixel(), and PlexPixelSpotId::SetSpot().

Referenced by GetGainAndWidth(), SimVaTimedElectronics::ReadoutDetector(), SimQieElectronics::ReadoutDetector(), SimVaElectronics::ReadoutDetector(), SimVaElectronics::ReadoutPmt(), SimQieElectronics::ReadoutPmt(), and SimVaTimedElectronics::ReadoutPmt().

00254 {
00255   //
00256   // Apply pixel and spot numbers to tube ID.
00257   // Hack the numbers around because the
00258   // database is stupid.
00259   //
00260   PlexPixelSpotId psid = fTube;
00261   if(fsPmtHamamatsuPixelNumbering)
00262     psid.SetPixel(pixel);
00263   else
00264     psid.SetPixel(pixel-1);
00265 
00266   psid.SetSpot(spot);
00267   return psid;
00268 }

Int_t SimPmt::GetSpotNumber ( const PlexPixelSpotId psid  )  const [inline, virtual]

Definition at line 286 of file SimPmt.h.

References PlexPixelSpotId::GetSpot().

Referenced by AddDigiPE().

00287 {
00288   //
00289   // Extract the pixel number from the psid,
00290   // which would be a trivial plex operation
00291   // if it weren't for the fact that the database is stupid.
00292   //
00293   return psid.GetSpot();
00294 }

Float_t SimPmt::GetTime ( int  pixel,
int  bucket = 0 
) const [virtual]

Definition at line 143 of file SimPmt.cxx.

References GetBucket(), SimPmtTimeBucket::GetPixelBucket(), and SimPixelTimeBucket::GetTime().

00144 {
00145   // 
00146   //  Get charge (in coulombs) on pixel, at time bucket.
00147   // 
00148 
00149   return GetBucket(bucket).GetPixelBucket(pixel).GetTime();
00150 }

Float_t SimPmt::GetTotalCharge ( void   )  const [virtual]

Return the total charge in pmt.

Definition at line 204 of file SimPmt.cxx.

References fNPixels, SimPixelTimeBucket::GetCharge(), SimPmtTimeBucket::GetPixelBucket(), and it.

Referenced by SimDetector::CompileStats(), SimVaElectronics::ReadoutPmt(), SimQieElectronics::ReadoutPmt(), and SimVaTimedElectronics::ReadoutPmt().

00205 {
00209   
00210   Float_t tot = 0;
00211   
00212   // Iterate over all time buckets.
00213   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00214     SimPmtTimeBucket& pmttb = it.Bucket();
00215     // Iterate over pixels.
00216       for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00217           SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00218           
00219           tot += pixtb.GetCharge();
00220       }
00221   }         
00222 
00223   return tot;
00224 }

Int_t SimPmt::GetTotalHitPixels ( Bool_t  with_xtalk  )  const [virtual]

Return the total number of pixels that got at least one digiPE

Returns it with or without crosstalk.

Definition at line 158 of file SimPmt.cxx.

References fNPixels, SimPmtTimeBucket::GetPixelBucket(), SimPixelTimeBucket::GetTotalPE(), SimPixelTimeBucket::GetTotalPEXtalk(), and it.

Referenced by SimDetector::CompileStats(), SimVaElectronics::ReadoutPmt(), SimQieElectronics::ReadoutPmt(), and SimVaTimedElectronics::ReadoutPmt().

00159 {
00164   int tot = 0;
00165   int tot_xtalk = 0;
00166   // Iterate over all time buckets.
00167   
00168   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00169     SimPmtTimeBucket& pmttb = it.Bucket();
00170     // Iterate over pixels.
00171       for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00172           SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00173 
00174           if(pixtb.GetTotalPE() >0)     tot++;   
00175           if(pixtb.GetTotalPEXtalk() >0) tot_xtalk++;
00176       }
00177   }         
00178   if(with_xtalk) return tot_xtalk;
00179   return tot;
00180 }

Float_t SimPmt::GetTotalPe ( void   )  const [virtual]

Return the total charge in pmt.

Definition at line 182 of file SimPmt.cxx.

References fNPixels, SimPmtTimeBucket::GetPixelBucket(), SimPixelTimeBucket::GetTotalPE(), and it.

Referenced by SimDetector::CompileStats().

00183 {
00187   
00188   Float_t tot = 0;
00189   
00190   // Iterate over all time buckets.
00191   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00192     SimPmtTimeBucket& pmttb = it.Bucket();
00193     // Iterate over pixels.
00194       for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00195           SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00196           
00197           tot += pixtb.GetTotalPE();
00198       }
00199   }         
00200 
00201   return tot;
00202 }

virtual PlexPixelSpotId SimPmt::GetTubeId (  )  const [inline, virtual]
virtual Pmt_t SimPmt::GetType (  )  const [inline, virtual]
void SimPmt::MoveOpticalPE ( UInt_t  npe,
SimPixelTimeBucket fromPixel,
Int_t  fromSpot,
SimPixelTimeBucket toPixel,
Int_t  toSpot 
) [protected, virtual]

Definition at line 676 of file SimPmt.cxx.

References SimPixelTimeBucket::AddPEXtalk(), fRandom, SimPixelTimeBucket::GetDigiPE(), SimPixelTimeBucket::GetDigiPEXtalk(), SimPixelTimeBucket::GetPE(), it, Msg::kDebug, and MSG.

Referenced by SimPmtM64::SimulateOpticalXtalk(), and SimulateOpticalXtalk().

00681 {
00682   //
00683   // Moves DigiPe from one pixel to another 
00684   // for use with optical crosstalk.
00685 
00686   // For efficiency.
00687   if(npe<=0) return;
00688 
00689   // Sanity check.
00690   // This can happen most likely for a single PE for which the 'mean' crosstalk is maybe 0.2%.
00691   // This gives a non-zero chance to get a poisson number of 2. 
00692   if(fromPixel.GetPE(fromSpot)<npe) {
00693     MSG("DetSim",Msg::kDebug) << "SimPmt::MoveOpticalPe() Optical crosstalk is bigger than injected light!" << endl;
00694     npe = (UInt_t)(fromPixel.GetPE(fromSpot)); // Set to max.
00695   }
00696 
00697   // Get the PE lists.
00698   SimPixelTimeBucket::PeList_t &fromPeList = fromPixel.GetDigiPE(fromSpot);
00699   SimPixelTimeBucket::PeList_t &toPeList =   toPixel.GetDigiPEXtalk(toSpot);
00700 
00701 
00702   // Even more sanity check.. COULD happen.
00703   // Happens most likely for a single PE on the pixel, which gets cross-talked
00704   // away to two neighboring pixels. The odds of this happening are about
00705   // one chance in 10,000, but there are an awful lot of pixels in an event.
00706   if(fromPeList.size() < npe) {
00707     MSG("DetSim",Msg::kDebug) << "SimPmt::MoveOpticalPe() Too much crosstalk! " 
00708                                 << fromPeList.size() << "pe available, " 
00709                                 << npe << " crosstalk requested." << endl;
00710     npe = fromPeList.size();
00711   }
00712   
00713 
00714   // For each moved pe
00715   for(UInt_t i=0; i<npe; i++) {
00716     // Pick a pe to move:
00717     Int_t whichPe = fRandom->Integer(fromPeList.size());
00718 
00719     // Go find it.
00720     SimPixelTimeBucket::PeList_t::iterator it;
00721     it=fromPeList.begin();
00722     for(int i=0;i<whichPe;i++) ++it;
00723 
00724     if(it!=fromPeList.end()) { // Even more sanity checks.
00725       toPeList.insert(*it); // Move it.
00726       toPixel.AddPEXtalk(toSpot,1); // Update number
00727       
00728       fromPeList.erase(it);    // Get rid of old copy: it's gone.
00729     }
00730   }
00731 }

virtual void SimPmt::Print ( Option_t *  = ""  )  const [inline, virtual]

Reimplemented in SimPmtM16, SimPmtM64, and SimPmtUTM16.

Definition at line 101 of file SimPmt.h.

Referenced by SimDetector::Print(), and SimQieElectronics::ReadoutPmt().

00101 {};

void SimPmt::PrintConfig ( Option_t *  = ""  )  [static]

Definition at line 783 of file SimPmt.cxx.

References Munits::fC, fsPmtApplyGainDrift, fsPmtDoChargeCrosstalk, fsPmtDoDarkNoise, fsPmtDoNonlinearity, fsPmtDoOpticalCrosstalk, fsPmtHamamatsuPixelNumbering, fsPmtScaleAdjacentChargeCrosstalk, fsPmtScaleAdjacentOpticalCrosstalk, fsPmtScaleChargeCrosstalk, fsPmtScaleDiagonalChargeCrosstalk, fsPmtScaleDiagonalOpticalCrosstalk, fsPmtScaleOpticalCrosstalk, fsQieDacCharge, fsRebuildGainMap, and fsVaGain.

Referenced by SimDetector::Print().

00784 {
00785   printf("SimPmt Config: pmtDoOpticalCrosstalk    %s\n",fsPmtDoOpticalCrosstalk?"true":"false");
00786   printf("               pmtDoChargeCrosstalk     %s\n",fsPmtDoChargeCrosstalk?"true":"false");
00787   printf("               pmtDoNonlinearity        %s\n",fsPmtDoNonlinearity?"true":"false");
00788   printf("               pmtDoDarkNoise           %s\n",fsPmtDoDarkNoise?"true":"false");
00789   printf("               pmtScaleOpticalCrosstalk %f\n",fsPmtScaleOpticalCrosstalk);
00790   printf("               pmtScaleChargeCrosstalk  %f\n",fsPmtScaleChargeCrosstalk );
00791   //Added by G. Pawloski to scale Adjacent and Diagonal separately
00792   printf("               pmtScaleAdjacentChargeCrosstalk  %f\n",fsPmtScaleAdjacentChargeCrosstalk );
00793   printf("               pmtScaleDiagonalChargeCrosstalk  %f\n",fsPmtScaleDiagonalChargeCrosstalk );
00794   printf("               pmtScaleAdjacentOpticalCrosstalk  %f\n",fsPmtScaleAdjacentOpticalCrosstalk );
00795   printf("               pmtScaleDiagonalOpticalCrosstalk  %f\n",fsPmtScaleDiagonalOpticalCrosstalk );
00796   printf("               pmtApplyGainDrift        %s\n",fsPmtApplyGainDrift?"true":"false" ); 
00797   printf("               pmtHamamatsuPixelNumbering %s\n",fsPmtHamamatsuPixelNumbering?"true":"false");
00798   printf("               vaGain                   %f ADC/fC\n",fsVaGain*Munits::fC);
00799   printf("               qieDacCharge             %f fC/DAC\n",fsQieDacCharge/Munits::fC);
00800   printf("               pmtRebuildGainMap        %s\n",fsRebuildGainMap?"true":"false");
00801 }

Float_t SimPmt::RandomGenPoisson ( Float_t  lambda  )  [protected]

Random number generator for the generalized Poisson dist'n given above.

This generator is very efficient, using the ROOT Poisson generator to find an integer value, then applying a small correction based on a locally- normalized GenPoisson function.

Definition at line 254 of file SimPmt.cxx.

References MuELoss::a, fRandom, and GenPoisson().

Referenced by GenChargeFromPE(), SimPmtM64::GenChargeFromPE(), and SimPmtM16::GenChargeFromPE().

00255 {
00266 
00267   // Sanity check
00268   if(lambda<=0) return 0;
00269 
00270   // If lambda is large enough, just use a gaussian.
00271   if (lambda > 88) {
00272       return fRandom->Gaus(0,1)*TMath::Sqrt(lambda) + lambda;
00273   }
00274 
00275   // rp is an integer, chosen at random from the poisson dist'n.  
00276   // rp is the nearest integer to the REAL random number we want.  
00277   Float_t rp = fRandom->Poisson(lambda);
00278   
00279   // Now choose a random number between rp-0.5 and rp+0.5.
00280 
00281   Float_t ri = TMath::Nint(rp); // Just in case it's NOT an integer.
00282   Float_t a = ri - 0.5;
00283   Float_t b = ri + 0.5;
00284 
00285   // Find the maximum value of f() (where f is the gen poisson f'n) in
00286   // this range.  If the range contains lambda, the max is lambda.
00287   Float_t fmax;
00288   if((lambda>a)&&(lambda<b)) {
00289     fmax = GenPoisson(lambda,lambda);
00290   } else {
00291     // Find f(a) and f(b);
00292     Float_t fa = GenPoisson(lambda,a);
00293     Float_t fb = GenPoisson(lambda,b);
00294     if(fa>fb) fmax = fa;
00295     else      fmax = fb;
00296   }
00297 
00298   // Now, pick (weighted) number between (a,b]
00299   while(true) {
00300     Float_t x = fRandom->Rndm();
00301     x = x + a;   
00302     // i.e.  x = a + x*(b-a), but (b-a) =1;
00303     // x is a random number (non weighted) in (a,b]
00304 
00305     Float_t f = GenPoisson(lambda,x);
00306 
00307     // r is the probability that this number is good.
00308     // Note we chose r in the range (0,fmax), not (0,1).
00309     // This keeps us from haveing to re-pick in areas
00310     // where the function is small.
00311     Float_t r = fRandom->Rndm();
00312     r = r*fmax;
00313 
00314     if(r < f) return x;
00315   }
00316 }

void SimPmt::Reset ( const VldContext newContext  )  [virtual]

Reimplemented in SimPmtM64, SimPmtM64Oxford, and SimPmtUTM16.

Definition at line 57 of file SimPmt.cxx.

References PlexPixelSpotId::AsString(), fContext, fCreatedDigiPEs, fDynodeTime, fTimeBuckets, fTotalCharge, fTube, kPmtTime_Never, Msg::kVerbose, and MSG.

Referenced by SimDetector::Reset(), SimPmt(), and SimDetector::SortDigiPE().

00058 {
00059   //
00060   // Clear all data in this object.
00061   //
00062   MSG("DetSim",Msg::kVerbose) << "SimPmt::Reset() " << fTube.AsString() << endl;
00063   fContext = newContext;
00064   fTotalCharge = 0;
00065   fDynodeTime = kPmtTime_Never;
00066   BucketMap_t::iterator itr(fTimeBuckets.begin()),itrEnd(fTimeBuckets.end());
00067   for (; itr != itrEnd; ++itr) 
00068     delete itr->second; 
00069   fTimeBuckets.clear();
00070   UInt_t num= fCreatedDigiPEs.size();
00071   for(UInt_t i=0;i<num;i++) delete fCreatedDigiPEs[i];
00072 }

virtual void SimPmt::SetAfterpulseModel ( SimAfterpulseModel model  )  [inline, virtual]

Definition at line 126 of file SimPmt.h.

References fSimAfterpulseModel.

00126 { fSimAfterpulseModel = model; };

void SimPmt::SimulateAfterpulsing (  )  [protected, virtual]

Definition at line 373 of file SimPmt.cxx.

References AddDigiPE(), SimAfterpulseModel::ComputeAfterpulsePixelAndTime(), SimAfterpulseModel::ComputeAfterpulseProb(), fCreatedDigiPEs, fNPixels, fNSpots, fRandom, fSimAfterpulseModel, SimPixelTimeBucket::GetDigiPE(), SimPixelTimeBucket::GetPE(), SimPmtTimeBucket::GetPixelBucket(), DigiPE::GetPixelSpotId(), DigiPE::GetTime(), DigiPE::IsAfterpulse(), it, and DigiSignal::kAfterpulse.

00374 {
00375   //
00376   // Creates extra PE, and adds them at delayed times.
00377   //
00378 
00379   if(fSimAfterpulseModel==0) return;
00380 
00381   // Iterate over all time buckets.
00382   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00383     SimPmtTimeBucket& pmttb = it.Bucket();
00384 
00385     // Iterate over pixels
00386     for(Int_t injPix = 1; injPix <= fNPixels; injPix++) {      
00387       SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(injPix);
00388       
00389       // Iterate over all spots
00390       for(Int_t injSpot = 1; injSpot <= fNSpots; injSpot++ ) { 
00391         Float_t npe = pixtb.GetPE(injSpot);
00392         
00393         if(npe>0) {
00394           // Do this the easy, sloppy way: roll a number for every PE.
00395           SimPixelTimeBucket::PeList_t pelist = pixtb.GetDigiPE(injSpot);
00396           SimPixelTimeBucket::PeList_t::iterator it = pelist.begin();
00397           SimPixelTimeBucket::PeList_t::iterator end = pelist.end();
00398           for( ; it!=end; it++ ) {
00399             const DigiPE* sourcePe = it->second;
00400             // Don't afterpulse the afterpulsing...? Might be correct to do so.
00401             if(sourcePe->IsAfterpulse()) continue;
00402             
00403             Float_t prob = fSimAfterpulseModel->ComputeAfterpulseProb(sourcePe->GetPixelSpotId(),npe);
00404             if(fRandom->Uniform() < prob) {
00405               PlexPixelSpotId outpsid;
00406               Double_t outtime;
00407               fSimAfterpulseModel->ComputeAfterpulsePixelAndTime(
00408                                                                  sourcePe->GetPixelSpotId(),
00409                                                                  sourcePe->GetTime(),
00410                                                                  outpsid, outtime );
00411               DigiPE* newpe = new DigiPE(outtime, outpsid, DigiSignal::kAfterpulse );
00412               this->AddDigiPE(newpe);      // Add to simulation.
00413               fCreatedDigiPEs.push_back(newpe); // Add to ownership.
00414             }
00415           }
00416           
00417         }
00418       }
00419     }
00420   }
00421 }

void SimPmt::SimulateChargeCrosstalk (  )  [protected, virtual]

Definition at line 547 of file SimPmt.cxx.

References SimPixelTimeBucket::AddCharge(), Munits::fC, fNPixels, GenElectricalCrosstalk(), SimPixelTimeBucket::GetCharge(), SimPmtTimeBucket::GetPixelBucket(), it, DigiSignal::kCrosstalk, and SimPixelTimeBucket::SetTruthBit().

Referenced by SimulatePmt(), and SimPmtM64Oxford::SimulatePmt().

00548 {
00549   //
00550   // Simulates charge crosstalk.
00551   //
00552   // Currently just a simple fraction.
00553 
00554   // (Static for speed's sake.)
00555   static float sCharge[101]; // We have no PMT type with more than 64 pixels.
00556   assert(fNPixels<100);
00557 
00558   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00559     SimPmtTimeBucket& pmttb = it.Bucket();
00560     
00561     // Store old charges. 
00562     for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00563       sCharge[pix] = pmttb.GetPixelBucket(pix).GetCharge();
00564     }
00565 
00566     // Do crosstalk.
00567     for( Int_t xpix = 1; xpix <= fNPixels; xpix++ ) {
00568       for( Int_t injPix = 1; injPix <=fNPixels; injPix++ ) {
00569         
00570         SimPixelTimeBucket& thePixel =  pmttb.GetPixelBucket(xpix);
00571         Float_t xcharge = GenElectricalCrosstalk( injPix, xpix, sCharge[injPix] );
00572         thePixel.AddCharge(xcharge);
00573         // Set truth bit for significant charge only.
00574         if(xcharge>1.0*Munits::fC) 
00575           thePixel.SetTruthBit(DigiSignal::kCrosstalk);
00576 
00577       }
00578     }
00579   }
00580 }

void SimPmt::SimulateCharges (  )  [protected, virtual]

Reimplemented in SimPmtM64Full, SimPmtM64Oxford, and SimPmtUTM16.

Definition at line 482 of file SimPmt.cxx.

References SimPixelTimeBucket::AddCharge(), SimPmtTimeBucket::AddTotalCharge(), fNPixels, fNSpots, fTotalCharge, GenChargeFromPE(), SimPixelTimeBucket::GetCharge(), SimPixelTimeBucket::GetPEXtalk(), SimPmtTimeBucket::GetPixelBucket(), it, and SimPixelTimeBucket::SetCharge().

Referenced by SimulatePmt().

00483 {
00484   fTotalCharge = 0;
00485   // Iterate over all time buckets.
00486   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00487     SimPmtTimeBucket& pmttb = it.Bucket();
00488 
00489     // Iterate over pixels.
00490       for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00491           SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00492           
00493           pixtb.SetCharge(0);
00494           
00495           for(Int_t spot = 1; spot <= fNSpots; spot++) {
00496             
00497             // This bit of magic provides the Int_trinsic
00498             // width of the 1 PE peak in a nice way.
00499             Float_t charge = GenChargeFromPE(pix,spot, pixtb.GetPEXtalk(spot));
00500             pixtb.AddCharge(charge);
00501           } // spots
00502           fTotalCharge += pixtb.GetCharge();
00503           pmttb.AddTotalCharge(pixtb.GetCharge());
00504       } // pixels
00505   } // buckets.
00506 }

void SimPmt::SimulateDarkNoise (  )  [protected, virtual]

Definition at line 509 of file SimPmt.cxx.

References SimPixelTimeBucket::AddCharge(), fNPixels, GenDarkNoiseCharge(), GetBucketDuration(), SimPmtTimeBucket::GetPixelBucket(), and it.

Referenced by SimulatePmt(), SimPmtUTM16::SimulatePmt(), and SimPmtM64Oxford::SimulatePmt().

00510 {
00511   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00512     Int_t ibucket = it.BucketId();
00513     SimPmtTimeBucket& pmttb = it.Bucket();
00514     
00515     for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00516       SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00517       
00518       Float_t darkcharge = GenDarkNoiseCharge( pix, GetBucketDuration(ibucket) );
00519       pixtb.AddCharge(darkcharge);
00520     }
00521   }
00522   
00523 }

void SimPmt::SimulateNonlinearity (  )  [protected, virtual]

Reimplemented in SimPmtM64ToyNL.

Definition at line 526 of file SimPmt.cxx.

References fNPixels, GenNonlinearCharge(), SimPixelTimeBucket::GetCharge(), SimPmtTimeBucket::GetPixelBucket(), it, and SimPixelTimeBucket::SetCharge().

Referenced by SimulatePmt().

00527 {
00528   // 
00529   // Simulate nonlinearity.
00530   // No algorithm yet.
00531   //
00532   
00533   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00534     SimPmtTimeBucket& pmttb = it.Bucket();
00535     
00536     for(Int_t pix = 1; pix <= fNPixels; pix++) {      
00537       SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(pix);
00538       
00539       Float_t nonlin = GenNonlinearCharge( pix, pixtb.GetCharge() );
00540       pixtb.SetCharge(nonlin);
00541       
00542      }
00543    }
00544 }

void SimPmt::SimulateOpticalXtalk (  )  [protected, virtual]

Reimplemented in SimPmtM64.

Definition at line 423 of file SimPmt.cxx.

References CopyPEtoPEXtalk(), fNPixels, fNSpots, fRandom, GenOpticalCrosstalk(), SimPixelTimeBucket::GetPE(), SimPmtTimeBucket::GetPixelBucket(), it, DigiSignal::kCrosstalkOptical, MoveOpticalPE(), and SimPixelTimeBucket::SetTruthBit().

Referenced by SimulatePmt(), and SimPmtUTM16::SimulatePmt().

00424 {
00425   //
00426   // Puts extra PE into pixels they don't belong.
00427   //
00428  
00429   // Hack!
00430   // This can be uncommented to make a big dump file of the crosstalk.
00431   //static ofstream ofile("xtalk.dat");
00432 
00433   // Iterate over all time buckets.
00434   for(SimPmtBucketIterator it(*this); !it.End(); it.Next()) {
00435     SimPmtTimeBucket& pmttb = it.Bucket();
00436 
00437     // Iterate over the talked-to pixel
00438     for(Int_t xpix = 1; xpix<=fNPixels; xpix++) {  
00439       SimPixelTimeBucket& pixtb = pmttb.GetPixelBucket(xpix);
00440   
00441       // Iterate over talking pixels.
00442       for(Int_t injPix = 1; injPix <= fNPixels; injPix++) {      
00443         if(injPix!=xpix) {
00444           SimPixelTimeBucket& pixtb_inj = pmttb.GetPixelBucket(injPix);
00445 
00446           // Iterate over all talking spots
00447           for(Int_t injSpot = 1; injSpot <= fNSpots; injSpot++ ) { 
00448             if( pixtb_inj.GetPE(injSpot) > 0) { // There is charge in this spot.
00449               
00450               Float_t pe = GenOpticalCrosstalk(injPix, // Injected pixel
00451                                                injSpot,  // Injected spot
00452                                                xpix,     // xtalk pixel
00453                                                pixtb_inj.GetPE(injSpot) ); // number pe.
00454               
00455               // Debugging hack continued.
00456               //ofile << injPix << "\t"  << injSpot << "\t" 
00457               //            << xpix << "\t" << pixtb_inj.GetPE(injSpot) << "\t" << pe << endl;
00458               if(pe>0){
00459                 // Choose a spot at random:
00460                 Int_t toSpot = fRandom->Integer(fNSpots)+1;
00461                 MoveOpticalPE(TMath::Nint(pe),
00462                               pixtb_inj,injSpot,
00463                               pixtb,    toSpot );
00464 
00465                 pixtb.SetTruthBit(DigiSignal::kCrosstalkOptical);
00466               }
00467             }
00468           } // Itr over inj spot
00469           
00470         } // Itr over inj pixel
00471       } 
00472     }  // itr over xtalk pixel
00473 
00474     // Now we're done with all pixels in the bucket.
00475   } // it over buckets
00476   // whew!
00477 
00478   // Copy whatever didn't crosstalk.
00479   CopyPEtoPEXtalk();
00480 }

void SimPmt::SimulatePmt ( void   )  [virtual]

Reimplemented in SimPmtM64Oxford, and SimPmtUTM16.

Definition at line 358 of file SimPmt.cxx.

References CopyPEtoPEXtalk(), fsPmtDoChargeCrosstalk, fsPmtDoDarkNoise, fsPmtDoNonlinearity, fsPmtDoOpticalCrosstalk, SimulateChargeCrosstalk(), SimulateCharges(), SimulateDarkNoise(), SimulateNonlinearity(), and SimulateOpticalXtalk().

Referenced by SimDetector::SimulatePmts().

00359 {
00360   //
00361   // This routine, it's override, and it's helpers do the actual
00362   // job of simulating everything there is to simulate in the PMT.
00363 
00364   if(fsPmtDoOpticalCrosstalk) SimulateOpticalXtalk();     // Move single PEs around for crosstalk
00365   else CopyPEtoPEXtalk();  // A null operation.
00366   SimulateCharges();                                 // Simulate the dynode chain to get anode charge.
00367   if(fsPmtDoDarkNoise)        SimulateDarkNoise();        // Add some charge to some pixels by dark noise.
00368   if(fsPmtDoNonlinearity)     SimulateNonlinearity();     // Apply the nonlinearity
00369   if(fsPmtDoChargeCrosstalk)  SimulateChargeCrosstalk();  // Crosstalk some charge around.
00370 }

virtual Int_t SimPmt::TimeToBucket ( Double_t   )  [inline, virtual]

Reimplemented in SimPmtM16UTTimed, and SimPmtM64.

Definition at line 109 of file SimPmt.h.

Referenced by AddDigiPE().

00109 { return 0; }; // Override this.


Friends And Related Function Documentation

friend class SimPmtBucketIterator [friend]

Definition at line 40 of file SimPmt.h.


Member Data Documentation

Definition at line 163 of file SimPmt.h.

Referenced by GetGainAndWidth(), and Reset().

std::vector<DigiPE*> SimPmt::fCreatedDigiPEs [private]

Definition at line 205 of file SimPmt.h.

Referenced by GetCreatedDigiPEs(), Reset(), SimulateAfterpulsing(), and ~SimPmt().

Float_t SimPmt::fDynodeTime [protected]

Definition at line 173 of file SimPmt.h.

Referenced by AddDigiPE(), GetDynodeTime(), and Reset().

Int_t SimPmt::fNPixels [protected]
Int_t SimPmt::fNSpots [protected]
TRandom* SimPmt::fRandom [protected]

Random number generator.

Definition at line 165 of file SimPmt.h.

Referenced by SetAfterpulseModel(), and SimulateAfterpulsing().

Bool_t SimPmt::fsPmtApplyGainDrift = true [static, protected]

Definition at line 189 of file SimPmt.h.

Referenced by Config(), GetGainAndWidth(), and PrintConfig().

Bool_t SimPmt::fsPmtDoChargeCrosstalk = true [static, protected]
Bool_t SimPmt::fsPmtDoDarkNoise = true [static, protected]
Bool_t SimPmt::fsPmtDoNonlinearity = true [static, protected]
Bool_t SimPmt::fsPmtDoOpticalCrosstalk = true [static, protected]
Bool_t SimPmt::fsPmtHamamatsuPixelNumbering = false [static, protected]

Definition at line 190 of file SimPmt.h.

Referenced by Config(), GetPixelNumber(), GetPixelSpotId(), and PrintConfig().

Double_t SimPmt::fsPmtScaleAdjacentChargeCrosstalk = 1.0 [static, protected]
Double_t SimPmt::fsPmtScaleAdjacentOpticalCrosstalk = 1.0 [static, protected]
Double_t SimPmt::fsPmtScaleChargeCrosstalk = 1.0 [static, protected]
Double_t SimPmt::fsPmtScaleDiagonalChargeCrosstalk = 1.0 [static, protected]
Double_t SimPmt::fsPmtScaleDiagonalOpticalCrosstalk = 1.0 [static, protected]
Double_t SimPmt::fsPmtScaleOpticalCrosstalk = 1.0 [static, protected]
Double_t SimPmt::fsQieDacCharge [static, protected]

Definition at line 192 of file SimPmt.h.

Referenced by Config(), GetGainAndWidth(), and PrintConfig().

Bool_t SimPmt::fsRebuildGainMap = true [static, protected]

Definition at line 193 of file SimPmt.h.

Referenced by Config(), PrintConfig(), SimPmtM64Oxford::Reset(), and SimPmtUTM16::Reset().

Double_t SimPmt::fsVaGain [static, protected]

Definition at line 191 of file SimPmt.h.

Referenced by Config(), GetGainAndWidth(), SimPmtUTM16::M16ChargeNonLinearity(), and PrintConfig().

BucketMap_t SimPmt::fTimeBuckets [mutable, private]

Definition at line 202 of file SimPmt.h.

Referenced by GetBucket(), Reset(), and ~SimPmt().

Float_t SimPmt::fTotalCharge [protected]

The documentation for this class was generated from the following files:

Generated on 21 Oct 2017 for loon by  doxygen 1.6.1