00001
00002
00003
00004
00005
00006
00007
00008 #include <iostream>
00009 #include <cmath>
00010 #include "TMath.h"
00011 #include "TClonesArray.h"
00012 #include "AttenCorr.h"
00013 #include "StandardNtuple/NtpStRecord.h"
00014 #include "CandNtupleSR/NtpSRStrip.h"
00015 #include "UgliGeometry/UgliGeomHandle.h"
00016
00017 using std::cout;
00018 using std::endl;
00019
00020 static const float MEAN_ATTEN = 0.326;
00021 static const float ND_CORRECTION = 1.;
00022 static const float REFLECTIVITY = 0.8;
00023
00024 AttenCorr::AttenCorr()
00025 {
00026 Reset();
00027 }
00028
00029 AttenCorr::~AttenCorr()
00030 {
00031 }
00032
00033
00034
00035 void AttenCorr::Reset(){
00036
00037 qpeE=-100;
00038 qpeW=-100;
00039 lE=-1;
00040 lW=-1;
00041 halflength=-1;
00042 wlspigtail_w=-1;
00043 wlspigtail_e=-1;
00044 clearfiber_w=-1;
00045 clearfiber_e=-1;
00046 centeru=-1;
00047 centerv=-1;
00048 qpeWcor=-100;
00049 qpeEcor=-100;;
00050 attenE=-1;
00051 attenW=-1;
00052
00053 }
00054
00055
00056 void AttenCorr::Setup(const NtpStRecord* record,const NtpSRStrip* strip,unsigned short qtype){
00057
00058 Reset();
00059
00060
00061 UgliGeomHandle ugh(record->GetHeader().GetVldContext());
00062 detector = record->GetHeader().GetVldContext().GetDetector();
00063 PlexStripEndId pseid(record->GetHeader().GetVldContext().GetDetector()
00064 ,strip->plane, strip->strip);
00065 UgliStripHandle stripgeom(ugh.GetStripHandle(pseid));
00066
00067
00068 if (qtype == 0) {
00069 qpeE=strip->ph0.pe;
00070 qpeW=strip->ph1.pe;
00071 }
00072 if (qtype == 5) {
00073 qpeE = strip->ph0.sigcor;
00074 qpeW = strip->ph1.sigcor;
00075 }
00076 halflength = stripgeom.GetHalfLength();
00077 wlspigtail_w = stripgeom.WlsPigtail(StripEnd::kWest);
00078 wlspigtail_e = stripgeom.WlsPigtail(StripEnd::kEast);
00079 clearfiber_w = stripgeom.ClearFiber(StripEnd::kWest);
00080 clearfiber_e = stripgeom.ClearFiber(StripEnd::kEast);
00081 const TVector3 globalpos(stripgeom.GlobalPos(0));
00082 centerv = .7071067812*(globalpos.Y()-globalpos.X());
00083 centeru = .7071067812*(globalpos.Y()+globalpos.X());
00084
00085
00086
00087
00088
00089
00090
00091
00092 }
00093
00094
00095 void AttenCorr::CalcPECorr(const int){
00096
00097 float lwlsE = 0;
00098 float lwlsW = 0;
00099 float fE = 0;
00100 float fW = 0;
00101
00102 if(detector==0x02 || detector==0x04){
00103
00104 lwlsE = wlspigtail_e + lE;
00105 lwlsW = wlspigtail_w + lW;
00106 fE = 1./( 0.666*exp(-lwlsE/7.05)+ 0.333*exp(-lwlsE/1.05));
00107 fW = 1./( 0.666*exp(-lwlsW/7.05)+ 0.333*exp(-lwlsW/1.05));
00108 fE = fE*exp(+(clearfiber_e/10.));
00109 fW = fW*exp(+(clearfiber_w/10.));
00110 qpeEcor = qpeE*fE*MEAN_ATTEN;
00111 qpeWcor = qpeW*fW*MEAN_ATTEN;
00112 qpecor = (qpeEcor+qpeWcor)*ND_CORRECTION;
00113
00114 attenE=fE;
00115 attenW=fW;
00116
00117 } else if(detector==0x01){
00118
00119 lwlsW = wlspigtail_w + lW;
00120 lwlsE = 4*halflength - fabs(lW) + wlspigtail_w;
00121
00122 fW = 1.*(0.666*exp(-lwlsW/7.05)+ 0.333*exp(-lwlsW/1.05));
00123
00124
00125 fE = 1.*(0.666*exp(-lwlsE/7.05)+ 0.333*exp(-lwlsE/1.05))*REFLECTIVITY;
00126 float fCor = 2./((fE+fW)*exp(-clearfiber_w/10.));
00127 fCor=fCor*1.587;
00128
00129
00130
00131
00132
00133 qpeWcor = qpeW*fCor*MEAN_ATTEN;
00134 qpecor = qpeWcor*ND_CORRECTION;
00135
00136 attenE=0;
00137 attenW=fCor;
00138
00139 }
00140
00141
00142 }
00143
00144
00145
00146 void AttenCorr::CalcCorr(const NtpStRecord* record,const NtpSRStrip* strip,Float_t meanUTPos, Float_t meanVTPos, unsigned short qtype){
00147
00148 Setup(record,strip,qtype);
00149
00150 if(strip->planeview==2){
00151
00152 lE = centerv + halflength - meanVTPos;
00153 lW = meanVTPos - (centerv - halflength);
00154 }else{
00155 lE = meanUTPos - (centeru - halflength);
00156 lW = centeru+halflength -meanUTPos;
00157 }
00158
00159
00160
00161
00162 CalcPECorr(detector);
00163
00164
00165
00166
00167 }