00001
00002 #include "ChopEvaluation.h"
00003 #include "UgliGeometry/UgliGeomHandle.h"
00004 #include "Calibrator/Calibrator.h"
00005
00006
00007
00008
00009
00010
00011 ChopEvaluation::ChopEvaluation() :
00012 fNuMatch(50,0),
00013 fNuMatch_cal(50,0),
00014 fNuMatch_fid(50,0),
00015 fNuMatch_calt(50,0),
00016 fNuMatch_caltfid(50,0)
00017 {
00018 Reset();
00019 }
00020
00021
00022 void ChopEvaluation::Reset()
00023 {
00024 fTdcBeg = -1;
00025 fTdcEnd = -1;;
00026 fSigcor = 0;
00027 fSigcor_cal = 0;
00028 fSigcor_fid = 0;
00029 fMeanTime = 0;
00030 fBigTdc = 0;
00031 fBigTdcE = 0;
00032 fBigPlane = 0;
00033 fBigPlaneE = 0;
00034 fPlanes = 0;
00035 fStrips = 0;
00036 fCalStrips = 0;
00037 fBestNeutrino1 = -1;
00038 fBestNeutrino2 = -1;
00039
00040 for(int i=0;i<kNProf;i++) {
00041 fProfile[i].i=i;
00042 fProfile[i].p=0;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 }
00055
00056 void ChopEvaluation::Evaluate(
00057 const std::vector<CandDigitHandle>& inList,
00058 const Truthifier& truth,
00059 const std::vector<int>& inNeutrinos,
00060 const std::vector<double>& inNeutrinoTZero,
00061 double inTCut
00062 )
00063 {
00064
00065
00066
00067 if(inList.size()==0) return;
00068
00069 UgliGeomHandle ugli(*(inList[0].GetVldContext()));
00070
00071 fTdcBeg = truth.GetRawDigit(inList[0])->GetTDC();
00072 fTdcEnd = truth.GetRawDigit(inList[0])->GetTDC();
00073 fPlaneBeg = inList[0].GetPlexSEIdAltL().GetPlane();
00074 fPlaneEnd = inList[0].GetPlexSEIdAltL().GetPlane();
00075 fDigits = inList.size();
00076 std::map<PlexStripEndId,int> hitStrips;
00077 std::map<PlexStripEndId,int>::iterator hitStripsItr;
00078
00079
00080
00081
00082 for(UInt_t idig=0;idig<inList.size();idig++) {
00083 CandDigitHandle cdh = inList[idig];
00084 int tdc = truth.GetRawDigit(inList[idig])->GetTDC();
00085 int plane = cdh.GetPlexSEIdAltL().GetPlane();
00086 PlexStripEndId seid = cdh.GetPlexSEIdAltL().GetBestSEId();
00087
00088 if(tdc<fTdcBeg) fTdcBeg = tdc;
00089 if(tdc>fTdcEnd) fTdcEnd = tdc;
00090 if(plane<fPlaneBeg) fPlaneBeg = plane;
00091 if(plane>fPlaneEnd) fPlaneEnd = plane;
00092 hitStrips[seid]+=1;
00093 }
00094 fStrips = hitStrips.size();
00095 for(hitStripsItr=hitStrips.begin(); hitStripsItr!=hitStrips.end(); hitStripsItr++)
00096 if(hitStripsItr->first.GetPlane()<121) fCalStrips +=1;
00097
00098
00099 fTdcProfile.resize(fTdcEnd-fTdcBeg+1,0);
00100 fPlaneProfile.resize(300,0);
00101
00102 fNuMatch. resize(inNeutrinos.size(),(double)0.);
00103 fNuMatch_cal. resize(inNeutrinos.size(),(double)0.);
00104 fNuMatch_fid. resize(inNeutrinos.size(),(double)0.);
00105 fNuMatch_calt. resize(inNeutrinos.size(),(double)0.);
00106 fNuMatch_caltfid.resize(inNeutrinos.size(),(double)0.);
00107 fNuMatch_strips. resize(inNeutrinos.size(),(double)0.);
00108 fNuMatch_calstrips.resize(inNeutrinos.size(),(double)0.);
00109
00110 std::vector<std::map<PlexStripEndId,int> > nuStrips(inNeutrinos.size());
00111 std::map<PlexStripEndId,int>::iterator stripItr;
00112
00113
00114 for(UInt_t idig=0;idig<inList.size();idig++) {
00115 CandDigitHandle cdh = inList[idig];
00116 int tdc = truth.GetRawDigit(cdh)->GetTDC();
00117 float sig = cdh.GetCharge(CalDigitType::kSigCorr);
00118 int plane = cdh.GetPlexSEIdAltL().GetPlane();
00119 PlexStripEndId seid = cdh.GetPlexSEIdAltL().GetBestSEId();
00120 PlaneView::PlaneView_t view = cdh.GetPlexSEIdAltL().GetBestSEId().GetPlaneView();
00121 float tpos = ugli.GetStripHandle(cdh.GetPlexSEIdAltL().GetBestSEId()).GetTPos();
00122
00123 bool cal = (plane<121);
00124 bool fid = false;
00125 if(plane>20&&plane<90) {
00126 if( ( (view==PlaneView::kU) && (tpos > -0.3) && (tpos < 2.4) ) ||
00127 ( (view==PlaneView::kV) && (tpos > -2.4) && (tpos < 0.3) ) ) {
00128 fid = true;
00129 }
00130 }
00131
00132
00133 fSigcor += sig;
00134 if(cal) fSigcor_cal += sig;
00135 if(fid) fSigcor_fid += sig;
00136
00137 fMeanTime = fMeanTime + sig*(double)tdc;
00138
00139 fTdcProfile[tdc-fTdcBeg] += sig;
00140 fPlaneProfile[plane] += sig;
00141
00142 for(UInt_t inu=0;inu<inNeutrinos.size();inu++) {
00143 int neu = inNeutrinos[inu];
00144 float frac = truth.IsDigitFromNeutrino(neu,cdh);
00145 float fract = truth.IsDigitFromNeutrino(neu,cdh,
00146 inNeutrinoTZero[inu]+inTCut);
00147
00148 fNuMatch[inu]+=frac*sig;
00149 if(cal) fNuMatch_cal[inu] += frac*sig;
00150 if(fid) fNuMatch_fid[inu] += frac*sig;
00151 if(cal) fNuMatch_calt[inu] += fract*sig;
00152 if(fid) fNuMatch_caltfid[inu] += fract*sig;
00153
00154 if(fract>0) nuStrips[inu][seid]++;
00155 }
00156
00157
00158 }
00159
00160
00161
00162
00163
00164 fMeanTime = fMeanTime/fSigcor;
00165
00166
00167 for(UInt_t itdc=0; itdc<fTdcProfile.size(); itdc++) {
00168 int tdc = itdc+fTdcBeg;
00169
00170 if(fTdcProfile[itdc]>fBigTdcE) {
00171 fBigTdcE = fTdcProfile[itdc];
00172 fBigTdc = tdc;
00173 }
00174 }
00175
00176
00177 for(UInt_t itdc=0; itdc<fTdcProfile.size(); itdc++) {
00178 int tdc = itdc+fTdcBeg;
00179 int i = tdc - fBigTdc;
00180 int elem = i+5;
00181 if( (elem>=0) &&(elem<kNProf) ) {
00182 fProfile[elem].p = fTdcProfile[itdc];
00183 fProfile[elem].i = elem;
00184 }
00185 }
00186
00187
00188 for(UInt_t p=0;p<fPlaneProfile.size();p++) {
00189 if(fPlaneProfile[p]>fBigPlaneE) {
00190 fBigPlaneE = fPlaneProfile[p];
00191 fBigPlane = p;
00192 }
00193 if(fPlaneProfile[p]>0) fPlanes++;
00194 }
00195
00196
00197 for(UInt_t inu=0;inu<inNeutrinos.size();inu++) {
00198 for(stripItr=nuStrips[inu].begin(); stripItr!=nuStrips[inu].end(); stripItr++) {
00199 fNuMatch_strips[inu] += 1;
00200 if(stripItr->first.GetPlane()<121)
00201 fNuMatch_calstrips[inu] += 1;
00202 }
00203 }
00204
00205
00206 fBestNeutrino1 = -1;
00207 fBestNeutrino2 = -1;
00208 double best_size = 0;
00209 double best_size2 = 0;
00210 for(UInt_t inu=0;inu<inNeutrinos.size();inu++) {
00211 if(fNuMatch_calt[inu]>best_size) {
00212 fBestNeutrino1 = inu;
00213 best_size = fNuMatch_calt[inu];
00214 }
00215 }
00216
00217 for(UInt_t inu=0;inu<inNeutrinos.size();inu++) {
00218 if(
00219 (fNuMatch_calt[inu]>best_size2)
00220 &&((int)inu!=fBestNeutrino1)
00221 ) {
00222 fBestNeutrino2 = inu;
00223 best_size2 = fNuMatch_calt[inu];
00224 }
00225 }
00226 }