00001 #include "PhotonFastBlueModel.h"
00002 #include "PhotonTransportMaker.h"
00003 #include "MessageService/MsgService.h"
00004 #include "Plex/PlexHandle.h"
00005 #include <cmath>
00006
00007 CVSID( "$Id: PhotonFastBlueModel.cxx,v 1.12 2006/12/01 19:59:25 rhatcher Exp $" );
00008
00009 ClassImp(PhotonFastBlueModel)
00010
00011 PhotonTransportMakerProxy<PhotonFastBlueModel>
00012 gPhotonFastBlueModelProxy("photonFastBlueModel");
00013
00015
00016 PhotonFastBlueModel::PhotonFastBlueModel() :
00017 fFastBlueSpectrumTable("PHOTONFASTBLUESPECTRUM")
00018 {
00019 Configure(PhotonConfiguration());
00020
00021 if (fFastBlueSpectrumTable.GetNumRows()<1) {
00022 MSG("Photon",Msg::kError) << "Can't find data for table PHOTONFASTBLUESPECTRUM Aborting!\n";
00023 assert(0);
00024 }
00025 SetBluePrescaleFactor(0.20676);
00026 }
00027
00029
00030 void
00031 PhotonFastBlueModel::Configure( const Registry& r )
00032 {
00033 MSG("Photon",Msg::kDebug) << "Configuring FastBlueModelModel." << std::endl;
00034 double tmpd;
00035 if (r.Get("ScintDecayTime",tmpd)) fScintDecayTime = tmpd;
00036 if (r.Get("FibreRadius",tmpd)) fFibreRadius = tmpd;
00037 if (r.Get("ReflectorScintReflec",tmpd)) fReflectorScintReflec = tmpd;
00038 SetBluePrescaleFactor(0.20676);
00039 }
00040
00041 void
00042 PhotonFastBlueModel::Reset( const VldContext& cx )
00043 {
00044
00045 fFastBlueSpectrumTable.Reset(cx);
00046 }
00047
00048
00049 Double_t PhotonFastBlueModel::GenTime(void)
00050 {
00051
00052
00053
00054
00055
00056
00057
00058
00059 const double kLambda1 = 0.846807;
00060 const double kLambda2 = 0.067829;
00061 const double kArea1 = 410.350066;
00062 const double kArea2 = 28.261422;
00063
00064 float tt;
00065 if( fRandom->Rndm()*(kArea1+kArea2) < kArea1 )
00066 tt = fRandom->Exp(kLambda1);
00067 else
00068 tt = fRandom->Exp(kLambda2);
00069
00070 return tt * Munits::ns;
00071 }
00072
00073 Double_t PhotonFastBlueModel::GenDx(void)
00074 {
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 const double kLorentzWidth1 = 0.017853;
00085 const double kArea1 = 8.178052;
00086 const double kLorentzWidth2 = 0.001309;
00087 const double kArea2 = 0.864215;
00088 const double kLambda3 = 1.000000;
00089 const double kArea3 = 0.000000;
00090
00091 const double kArea = kArea1+kArea2+kArea3;
00092
00093 double choose = fRandom->Rndm() * kArea;
00094
00095 if( choose < kArea1 ) {
00096 return tan(fRandom->Rndm() * TMath::Pi()) * kLorentzWidth1;
00097
00098 } else if ( choose < (kArea2+kArea1) ) {
00099 return tan(fRandom->Rndm() * TMath::Pi()) * kLorentzWidth2;
00100
00101 } else {
00102 double absdx = fRandom->Exp(kLambda3);
00103 if(fRandom->Rndm()>0.5) return -absdx;
00104 return absdx;
00105 }
00106 return 0;
00107 }
00108
00109 Bool_t
00110 PhotonFastBlueModel::ScintPhotonToFibreHit( const DigiScintHit* hit,
00111 const UgliStripHandle& inStrip,
00112 DigiPhoton* &outPhoton )
00113 {
00114 outPhoton = NULL;
00115
00116
00117 double along = fRandom->Rndm();
00118 double tstart = hit->T1() + along*(hit->T2() - hit->T1()) + fRandom->Exp(fScintDecayTime);
00119 double xstart = hit->X1() + along*(hit->X2() - hit->X1());
00120
00121 double dt, dx;
00122 do {
00123 dt = GenTime();
00124 dx = GenDx();
00125 } while (dt*Munits::c_light/1.6 < fabs(dx));
00126 double t = tstart + dt;
00127 double x = xstart + dx;
00128
00129 double wavelength = fFastBlueSpectrumTable.Pick(fRandom->Rndm()) * Munits::nm;
00130
00131
00132
00133
00134
00135 if ( fabs(x) > inStrip.GetHalfLength() ) {
00136
00137
00138 StripEnd::StripEnd_t end = (x>0)?StripEnd::kPositive:StripEnd::kNegative;
00139 if(inStrip.IsMirrored(end)) {
00140 if(fRandom->Rndm()>fReflectorScintReflec) {
00141 return false;
00142 } else {
00143
00144 if(x>0)
00145 x = inStrip.GetHalfLength() - x;
00146 else
00147 x = -inStrip.GetHalfLength() -x;
00148 }
00149
00150 } else {
00151
00152 return false;
00153 }
00154 }
00155
00156 if(inStrip.WlsBypass() > 0.) {
00157
00158
00159 if( ( (x + inStrip.GetHalfLength()) > inStrip.PartialLength(StripEnd::kNegative) )
00160 && ( (inStrip.GetHalfLength() - x) > inStrip.PartialLength(StripEnd::kPositive) )
00161 ) {
00162
00163 return false;
00164 }
00165
00166 }
00167
00168 outPhoton = new DigiPhoton(hit,
00169 wavelength, t,
00170 x, 0, inStrip.GetHalfThickness()-fFibreRadius*2.0,
00171 0, 0, 1.0);
00172
00173
00174 return true;
00175 }
00176
00177
00178