Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ChopEvaluation.cxx

Go to the documentation of this file.
00001 
00002 #include "ChopEvaluation.h"
00003 #include "UgliGeometry/UgliGeomHandle.h"
00004 #include "Calibrator/Calibrator.h"
00005 
00006 //ClassImp(ChopEvaluation);
00007 //ClassImp(NeutrinoInfo)
00008 //ClassImp(ChopNeutrinoLeaf)
00009 //ClassImp(ChopTreeLeaf)
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   fTdcProfile.clear();
00046   fPlaneProfile.clear();
00047   fNuMatch.clear();
00048   fNuMatch_cal.clear();
00049   fNuMatch_fid.clear();
00050   fNuMatch_calt.clear();
00051   fNuMatch_caltfid.clear();
00052   fStrips.clear();
00053   */
00054 }
00055 
00056 void ChopEvaluation::Evaluate(
00057                           const std::vector<CandDigitHandle>& inList, // digits to evaluate
00058                           const Truthifier& truth,                    // truth.
00059                           const std::vector<int>&    inNeutrinos,     // indecies of neutrinos in truth info
00060                           const std::vector<double>& inNeutrinoTZero, // time of first interaction of each nu
00061                           double inTCut
00062                           )  
00063 { 
00064   //
00065   //
00066   //
00067   if(inList.size()==0) return; // Null list.
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   // First pass. Get start and end times.
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   // resize arrays.
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);//,neuTrueStartTime[inu]+fParticleTimeout);        
00145       float fract = truth.IsDigitFromNeutrino(neu,cdh,
00146                                               inNeutrinoTZero[inu]+inTCut);//,neuTrueStartTime[inu]+fParticleTimeout);    
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   // Now finish evaluation..
00162   //
00163 
00164   fMeanTime = fMeanTime/fSigcor;
00165 
00166   // Loop on time buckets:
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   // Create profile.
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   // Loop on planes:
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   // Loop on neutrinos:
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 }

Generated on Mon Feb 15 11:06:31 2010 for loon by  doxygen 1.3.9.1