00001 #include "PhotonCaldetNoise.h"
00002 #include "PhotonTransportMaker.h"
00003 #include "ScintPhoton.h"
00004 #include "MessageService/MsgService.h"
00005 #include "Plex/PlexHandle.h"
00006 #include "Digitization/DigiSignal.h"
00007
00008 CVSID( " $Id: PhotonCaldetNoise.cxx,v 1.4 2006/12/01 20:12:11 rhatcher Exp $" );
00009
00010 ClassImp(PhotonCaldetNoise)
00011 PhotonTransportMakerProxy<PhotonCaldetNoise>
00012 gPhotonCaldetNoiseProxy("photonCaldetNoise");
00013
00014
00016
00017 PhotonCaldetNoise::PhotonCaldetNoise()
00018 {
00019 Configure(PhotonConfiguration());
00020 }
00021
00023
00024 void
00025 PhotonCaldetNoise::Configure( const Registry& r )
00026 {
00027
00028 ScintPhoton::Configure(r);
00029
00030 MSG("Photon",Msg::kDebug) << "Configuring CaldetNoise." << std::endl;
00031
00032 double tmpd;
00033 if (r.Get("DarkNoiseRate",tmpd)) fDarkNoiseRate = tmpd;
00034 if (r.Get("GreenNoiseRate",tmpd)) fGreenNoiseRate = tmpd;
00035 if (r.Get("NoiseWindow",tmpd)) fNoiseWindow = tmpd;
00036 }
00037
00038 void
00039 PhotonCaldetNoise::Reset( const VldContext& )
00040 {
00041
00042 }
00043
00044
00045 void
00046 PhotonCaldetNoise::MakeNoise( std::vector<DigiPE*> &peList,
00047 Double_t t_start,
00048 Double_t t_end )
00049 {
00054
00055
00056 double t1 = t_start - fNoiseWindow*0.5;
00057 double t2 = t_end + fNoiseWindow*0.5;
00058 double dt = t2-t1;
00059
00060 MSG("Photon",Msg::kDebug) << "Computing noise for window at" << t1
00061 << " s for " << (t2-t1)/Munits::ns << " ns." << std::endl;
00062
00063 PlexHandle plex(fContext);
00064
00065 const std::vector<PlexPixelSpotId>& tubes = plex.GetAllTubes();
00066
00067
00068 Double_t pmtHits = (double)tubes.size() * dt * fDarkNoiseRate;
00069
00070 Int_t nPmtHits = fRandom->Poisson(pmtHits);
00071 MSG("Photon",Msg::kDebug) << "Creating " << nPmtHits << " dark noise hits.\n";
00072
00073
00074 for(int i=0; i<nPmtHits; i++) {
00075
00076 Int_t whichPmt = fRandom->Integer((int)tubes.size());
00077
00078 PlexPixelSpotId psid = tubes[whichPmt];
00079 if(psid.GetElecType()==ElecType::kQIE) {
00080 psid.SetPixel(fRandom->Integer(64));
00081 psid.SetSpot(1);
00082 }
00083 if(psid.GetElecType()==ElecType::kVA) {
00084 psid.SetPixel(fRandom->Integer(16));
00085 psid.SetSpot(fRandom->Integer(8)+1);
00086 }
00087 if(psid.IsValid()) {
00088 DigiPE* pe = new DigiPE( fRandom->Uniform(t1,t2),
00089 psid,
00090 DigiSignal::kDarkNoise );
00091 peList.push_back(pe);
00092 }
00093 }
00094
00095
00096 const std::vector<PlexStripEndId>& stripEnds = plex.GetAllStripEnds();
00097
00098
00099 Double_t fibreHits = (double)stripEnds.size() * dt * fGreenNoiseRate;
00100
00101 Int_t nGreenHits = fRandom->Poisson(fibreHits);
00102 MSG("Photon",Msg::kDebug) << "Creating " << nGreenHits << " green WLS noise hits.\n";
00103
00104
00105 for(int i=0; i<nGreenHits; i++) {
00106
00107 Int_t whichSeid = fRandom->Integer((int)stripEnds.size());
00108
00109 PlexPixelSpotId psid = plex.GetPixelSpotId(stripEnds[whichSeid]);
00110
00111 if(psid.IsValid()) {
00112 DigiPE* pe = new DigiPE( fRandom->Uniform(t1,t2),
00113 psid,
00114 DigiSignal::kFibreLight );
00115 peList.push_back(pe);
00116 }
00117 }
00118
00119
00120 }
00121
00122
00123 void PhotonCaldetNoise::Print(Option_t*option) const
00124 {
00125 if(option[0]=='n') {
00126 MSG("Photon",Msg::kInfo) << "-<NoiseMaker> PhotonCaldetNoise:-----" << endl;
00127
00128 }
00129 }
00130