/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcTrkRecon/MdcTrkRecon-00-03-45/src/MdcSegGrouperCsmc.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: MdcSegGrouperCsmc.cxx,v 1.7 2009/12/16 09:02:47 zhangy Exp $
00004 //
00005 // Description:
00006 //     
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Authors:
00012 //
00013 // Copyright (C)  1996  The Board of Trustees of  
00014 // 
00015 // History:
00016 //      Migration for BESIII MDC
00017 // The Leland Stanford Junior University.  All Rights Reserved.
00018 //------------------------------------------------------------------------
00019 #include <assert.h>
00020 #include "MdcGeom/BesAngle.h"
00021 #include "CLHEP/Alist/AList.h" 
00022 #include "MdcGeom/MdcSuperLayer.h"
00023 #include "MdcGeom/MdcDetector.h"
00024 #include "MdcTrkRecon/MdcSegGrouperCsmc.h"
00025 #include "MdcTrkRecon/MdcSegList.h"
00026 #include "MdcTrkRecon/MdcSeg.h"
00027 #include "MdcTrkRecon/MdcSegInfoCsmc.h"
00028 #include "MdcTrkRecon/mdcWrapAng.h"
00029 #include "MdcTrkRecon/MdcTrack.h"
00030 #include "MdcTrkRecon/GmsList.h"
00031 #include "TrkBase/TrkExchangePar.h"
00032 
00033 //Constructor
00034 //------------------------------------------------------------------------
00035 MdcSegGrouperCsmc::MdcSegGrouperCsmc(const MdcDetector *gm, int debug) : 
00036   MdcSegGrouper(gm, gm->nAxialSuper()-1, debug) {
00037 //------------------------------------------------------------------------
00038                     
00039   lTestGroup = false;
00040   lTestSingle = false;
00041 
00042   isValid = new bool * [nPly()];
00043   for (int j = 0; j < nPly(); j++) {
00044     isValid[j] = 0;
00045   } 
00046 }
00047 
00048 //------------------------------------------------------------------------
00049 void 
00050 MdcSegGrouperCsmc::fillWithSegs( const MdcSegList *inSegs) {
00051 //------------------------------------------------------------------------
00052   // Prepare for axial finding
00053   // Store the segments (pointers, actually), sorting by phi0 
00054   for (int isuper = 0; isuper < _gm->nSuper(); isuper++) {
00055     const GmsList *inList = inSegs->oneList(isuper);
00056     if (inList->count() == 0) continue;
00057     
00058     MdcSeg *inSeg = (MdcSeg *) inList->first();
00059     // Only load axial segments
00060     if (inSeg->superlayer()->whichView() != 0) continue;
00061 
00062     while (inSeg != 0) {
00063       // Create an info object within the seg to store info
00064       MdcSegInfoCsmc *info = new MdcSegInfoCsmc;
00065       inSeg->setInfo(info);
00066       info->calcStraight(inSeg);  // calc. origin-dependent info
00067 
00068       // Loop over the segs already stored, looking for the right place 
00069       //   to stick the new one
00070       int isInserted = 0;
00071       for (int iseg = 0; iseg < (int) segList[isuper].length(); iseg++) {
00072         MdcSeg *aSeg = segList[isuper][iseg];
00073         if ( ((MdcSegInfoCsmc *)aSeg->info())->phi0() < info->phi0()) 
00074           continue;  
00075         segList[isuper].insert(inSeg, iseg);
00076         isInserted = 1;
00077         break;
00078       }  // end of loop over existing segs
00079       if (isInserted == 0) segList[isuper].append(inSeg);
00080 
00081       inSeg = (MdcSeg *) inSeg->next();
00082     }  // end loop over new segs
00083   }  //  end loop over superlayers
00084 
00085 }
00086 
00087 //-------------------------------------------------------------------------
00088 int 
00089 MdcSegGrouperCsmc::incompWithSeg(const MdcSeg *refSeg, 
00090                                    const MdcSeg *testSeg) {
00091 //-------------------------------------------------------------------------
00092 
00093   return 0;
00094   // Returns 0 if valid, -1 if invalid, +1 if invalid and no more valid 
00095   //   ones possible in this slayer (assumes they're ordered)
00096   if (testSeg == 0) return 0;
00097  
00098   // Test phi0 match
00099   MdcSegInfoCsmc *refInfo = (MdcSegInfoCsmc *) refSeg->info();
00100   MdcSegInfoCsmc *testInfo = (MdcSegInfoCsmc *) testSeg->info();
00101   double sigPhi0 = (refInfo->sigPhi0() > testInfo->sigPhi0() ? 
00102                     refInfo->sigPhi0() : testInfo->sigPhi0());
00103   double refPhi0 = refInfo->phi0();
00104   double testPhi0 =  testInfo->phi0();
00105   double corrPhi0 = mdcWrapAng(refPhi0, testPhi0);
00106   if (refPhi0 - corrPhi0 > 6. * sigPhi0) return -1;
00107   if (corrPhi0 - refPhi0 > 6. * sigPhi0) { 
00108     if (testPhi0 > refPhi0) return  1;  
00109     else return -1; // => testPhi0>2pi & refPhi0<2pi
00110   }
00111 
00112   // Test d0 match
00113   // use larger error of the two
00114   double sigD0 = (refInfo->sigD0() > testInfo->sigD0() ? 
00115                     refInfo->sigD0() : testInfo->sigD0());
00116   double refD0 = refInfo->d0();
00117   double testD0 = testInfo->d0();
00118   if (fabs(refD0 - testD0) > 6. * sigD0) return -2;
00119 
00120   return 0;
00121 }
00122 //-------------------------------------------------------------------------
00123 int 
00124 MdcSegGrouperCsmc::incompWithGroup(MdcSeg **segGroup, const MdcSeg *testSeg, 
00125                             int iply) {
00126 //-------------------------------------------------------------------------
00127 
00128   return 0;
00129 }
00130 
00131 //---------------------------------------------------------------------
00132 void 
00133 MdcSegGrouperCsmc::resetComb(const class MdcSeg *seed) {
00134 //---------------------------------------------------------------------
00135   
00136   // Delete existing list of valid/invalid segs
00137   if (isValid != 0) {
00138     int i;
00139     for (i = 0; i < nDeep; i++) {
00140       delete [] isValid[i];
00141       isValid[i] = 0;
00142     }
00143   }
00144 
00145   _seed = seed;
00146   //Grab the seglist for each slayer
00147   int islay = 0;
00148   int iply = 0;
00149   nPlyFilled = 0;
00150   nNull = 0;
00151   const MdcSuperLayer *seedSlay = 0;
00152   if (seed != 0) seedSlay = seed->superlayer();
00153 
00154   // Set up all sorts of stuff for fast grouping of segs in nextGroup()
00155   for (const MdcSuperLayer *thisSlay = _gm->firstSlay(); thisSlay != 0;
00156        thisSlay = thisSlay->next()) {
00157     bool noGoodYet = true;
00158     islay++;
00159 
00160     if (thisSlay == seedSlay) continue;
00161     if (thisSlay->whichView() != 0) continue;
00162     firstGood[iply] = 0;
00163     // Loop over the segs, marking start & end of valid region for this seed
00164     firstBad[iply] = 0;
00165     if (segList[islay-1].length() != 0) 
00166       isValid[iply] = new bool[segList[islay-1].length()];
00167     for (int i = 0; i < (int) segList[islay-1].length(); i++) {
00168       MdcSeg *aSeg = segList[islay-1][i];
00169       int invalid = incompWithSeg(seed, aSeg);
00170       isValid[iply][i] = true;
00171       if (invalid < 0) {
00172         firstBad[iply] = i;
00173         isValid[iply][i] = false;
00174         if (noGoodYet) firstGood[iply] = i+1;
00175       }
00176       else if (invalid > 0) {
00177         // No more valid segs in this slayer
00178         firstBad[iply] = i;
00179         for (int j = i; j < (int) segList[islay-1].length(); j++) 
00180           isValid[iply][j] = false;
00181         break;
00182       }
00183       else {
00184         firstBad[iply] = i+1;
00185         noGoodYet = false;
00186       }
00187     }
00188     //    if (thisSlay->whichView() != 0) continue;
00189     //    firstGood[iply] = 0;
00190     //    // Loop over the segs, marking start & end of valid region
00191     //    firstBad[iply] = 0;
00192     //    firstBad[iply] = segList[islay-1].length();
00193 
00194 
00195     if (firstGood[iply] > firstBad[iply]) firstGood[iply] = firstBad[iply];
00196     if (firstGood[iply] == firstBad[iply]) {
00197       // If there are no valid segs for this ply, skip it
00198       continue;
00199     }
00200     // Associate correct seglist with this ply
00201     combList[iply] = &segList[islay-1];
00202     leaveGap[iply] = false;
00203     iply++;
00204   }
00205   nPlyFilled = iply;
00206   resetSegCounters();
00207   maxNull = nPlyFilled - 2;
00208   maxNull++;
00209 }
00210 //---------------------------------------------------------------------
00211 MdcTrack* 
00212 MdcSegGrouperCsmc::storePar(MdcTrack* trk, double parms[2], double chi2, 
00213                             TrkContext& context, double t0){
00214 //---------------------------------------------------------------------
00215   assert(trk == 0);
00216   BesAngle foundPhi0(parms[1]);
00217   TrkExchangePar par(parms[0], foundPhi0.Rad(), 0., 0., 0.);
00218   return new MdcTrack(_gm->nSuper(), par, chi2, context, t0);
00219 }

Generated on Tue Nov 29 23:13:34 2016 for BOSS_7.0.2 by  doxygen 1.4.7