ConvergenceMaster Class Reference

#include <ConvergenceMaster.h>

List of all members.

Classes

class  MaskStep

Public Types

typedef Int_t Count_t
typedef UShort_t Mask_t
typedef std::vector< Mask_tViewMask_t

Public Member Functions

 ConvergenceMaster (Int_t nhitsinviewmin=4)
 ~ConvergenceMaster ()
void BuildMasks (const DataFT &data)
void SetNHitsInViewMin (Int_t n)
Bool_t NextStep ()
Bool_t MaskIsValid () const
void SetMaskIsValid (Bool_t valid)
void SetConverged ()
void SetDiverged ()
Count_t GetNPlanesCur () const
Count_t GetNPlanesMin () const
Count_t GetNPlanesMax () const
const ViewMask_tGetMaskUCur () const
const ViewMask_tGetMaskVCur () const

Private Types

typedef ViewMask_t::iterator ViewMaskItr
typedef
ViewMask_t::reverse_iterator 
ViewMaskRItr
typedef ViewMask_t::const_iterator ViewMaskCItr
typedef
ViewMask_t::const_reverse_iterator 
ViewMaskCRItr
typedef std::vector< ViewMask_tViewMaskVec_t
typedef std::list< ViewMask_tViewMaskList_t
typedef ViewMaskList_t::iterator ViewMaskListItr
typedef
ViewMaskList_t::const_iterator 
ViewMaskListCItr
typedef std::vector< MaskStepMaskList_t
typedef MaskList_t::iterator MaskListItr
typedef MaskList_t::const_iterator MaskListCItr

Private Member Functions

void PrintMasks () const
void SetInitialMask ()
void BuildMaskSteps (const ViewMaskList_t &maskU, const ViewMaskList_t &maskV)
void BuildViewMasks (const ViewMask_t &maskIn, ViewMaskList_t &maskList)
Bool_t UnsetEverySecond (ViewMask_t &mask)
void PadMaskLists (ViewMaskList_t &maskU, ViewMaskList_t &maskV)
void PadWithLastElement (ViewMaskList_t &maskList, UInt_t n)
Bool_t IncrementPlaneCount ()
Bool_t DecrementPlaneCount ()
Bool_t NextMask (Count_t planeCount)

Private Attributes

Int_t fNHitsInViewMin
MaskList_t fMaskList
MaskListItr fMaskCur
Bool_t fMaskIsValid

Detailed Description

ConvergencMaster - class guiding the sequence in which fits are attemmpted. During the initial iterations many of the track hits are "masked out" and ignored by the fitter. As the iterations progress ConvergenceMaster keeps unmasking the hits until the longest possible part of the track (starting at the vertex) is fit using all hits. The "masks" are stored in vectors and organized in "binary levels" where a "next" level mask is obtained by removing every other hit from a "current" level mask.

Author:
Sergei avva@fnal.gov

Definition at line 26 of file ConvergenceMaster.h.


Member Typedef Documentation

Definition at line 29 of file ConvergenceMaster.h.

typedef UShort_t ConvergenceMaster::Mask_t

Definition at line 31 of file ConvergenceMaster.h.

typedef std::vector<MaskStep> ConvergenceMaster::MaskList_t [private]

Definition at line 99 of file ConvergenceMaster.h.

typedef MaskList_t::const_iterator ConvergenceMaster::MaskListCItr [private]

Definition at line 101 of file ConvergenceMaster.h.

typedef MaskList_t::iterator ConvergenceMaster::MaskListItr [private]

Definition at line 100 of file ConvergenceMaster.h.

typedef std::vector<Mask_t> ConvergenceMaster::ViewMask_t

Definition at line 32 of file ConvergenceMaster.h.

typedef ViewMask_t::const_iterator ConvergenceMaster::ViewMaskCItr [private]

Definition at line 37 of file ConvergenceMaster.h.

typedef ViewMask_t::const_reverse_iterator ConvergenceMaster::ViewMaskCRItr [private]

Definition at line 38 of file ConvergenceMaster.h.

typedef ViewMask_t::iterator ConvergenceMaster::ViewMaskItr [private]

Definition at line 35 of file ConvergenceMaster.h.

typedef std::list<ViewMask_t> ConvergenceMaster::ViewMaskList_t [private]

Definition at line 40 of file ConvergenceMaster.h.

typedef ViewMaskList_t::const_iterator ConvergenceMaster::ViewMaskListCItr [private]

Definition at line 42 of file ConvergenceMaster.h.

typedef ViewMaskList_t::iterator ConvergenceMaster::ViewMaskListItr [private]

Definition at line 41 of file ConvergenceMaster.h.

typedef ViewMask_t::reverse_iterator ConvergenceMaster::ViewMaskRItr [private]

Definition at line 36 of file ConvergenceMaster.h.

typedef std::vector<ViewMask_t> ConvergenceMaster::ViewMaskVec_t [private]

Definition at line 39 of file ConvergenceMaster.h.


Constructor & Destructor Documentation

ConvergenceMaster::ConvergenceMaster ( Int_t  nhitsinviewmin = 4  ) 

ctor (does little - mask creation is in BuildMasks method)

Definition at line 34 of file ConvergenceMaster.cxx.

00034                                                          :
00035     fNHitsInViewMin(nhitsinviewmin)
00036 {
00037     TracerSA trace("ConvergenceMaster::ConvergenceMaster(Int_t)");
00038 }

ConvergenceMaster::~ConvergenceMaster (  ) 

dtor

Definition at line 43 of file ConvergenceMaster.cxx.

00044 {
00045 }


Member Function Documentation

void ConvergenceMaster::BuildMasks ( const DataFT data  ) 

Create mask arrays

build the "mask levels" for a given track.

Definition at line 51 of file ConvergenceMaster.cxx.

References BuildMaskSteps(), BuildViewMasks(), DataFT::GetUHitUse(), DataFT::GetVHitUse(), PadMaskLists(), PrintMasks(), and SetInitialMask().

Referenced by FitContext::FitContext().

00052 {
00053     TracerSA trace("ConvergenceMaster::BuildMasks(const DataFT& )");
00054     
00055     ViewMask_t uMask = data.GetUHitUse();
00056     ViewMaskList_t uMaskList;
00057     BuildViewMasks(uMask, uMaskList);    
00058 
00059     ViewMask_t vMask = data.GetVHitUse();
00060     ViewMaskList_t vMaskList;
00061     BuildViewMasks(vMask, vMaskList);    
00062 
00063     // make uMaskList, vMaskList equal size
00064     // by copying the last element of the shorter
00065     // list n times
00066     PadMaskLists(uMaskList, vMaskList);
00067     
00068     // make MaskStep objects - each MaskStep holds
00069     // masks for U and V and pointers to current
00070     // # of planes fit, max, min #planes, etc   
00071     BuildMaskSteps(uMaskList, vMaskList);
00072     
00073     SetInitialMask();
00074     
00075     PrintMasks();    
00076     return;
00077 }

void ConvergenceMaster::BuildMaskSteps ( const ViewMaskList_t uMaskList,
const ViewMaskList_t vMaskList 
) [private]

make "mask steps" - each mask step contains mask vectors for U and V views

Definition at line 135 of file ConvergenceMaster.cxx.

References fMaskList, and fNHitsInViewMin.

Referenced by BuildMasks().

00137 {
00138     TracerSA trace("ConvergenceMaster::BuildMaskSteps(const ViewMaskList_t&, const ViewMaskList_t&)");
00139 
00140     assert( uMaskList.size() == vMaskList.size() && 
00141             "U, V mask lists are not equal size!"    );
00142             
00143     ViewMaskListCItr itrU = uMaskList.begin();
00144     ViewMaskListCItr endU = uMaskList.end();
00145     ViewMaskListCItr itrV = vMaskList.begin();
00146     
00147     while ( itrU != endU ) {
00148         fMaskList.push_back(MaskStep( *itrU, *itrV, fNHitsInViewMin ) );
00149         ++itrU;
00150         ++itrV;
00151     }
00152     
00153     return;
00154 }    

void ConvergenceMaster::BuildViewMasks ( const ViewMask_t maskIn,
ViewMaskList_t maskList 
) [private]

create "mask levels" for one view. Each level is created by sequentially masking every other hit in the view.

Definition at line 161 of file ConvergenceMaster.cxx.

References UnsetEverySecond().

Referenced by BuildMasks().

00163 {
00164     TracerSA trace("ConvergenceMaster::BuildViewMasks(const ViewMask_t&, ViewMaskList_t&)");
00165     ViewMask_t mask(maskIn);
00166     
00167     maskList.push_front(mask);
00168     
00169     while ( UnsetEverySecond(mask) ) {
00170         maskList.push_front(mask);
00171     }
00172     
00173     return;
00174 }    

Bool_t ConvergenceMaster::DecrementPlaneCount (  )  [private]

decrease length of the track segment to fit

Definition at line 316 of file ConvergenceMaster.cxx.

References fMaskCur.

Referenced by NextStep().

00317 {
00318     TracerSA trace("ConvergenceMaster::DecrementPlaneCount()");
00319     return fMaskCur->DecrementPlaneCount();            
00320 }

const ConvergenceMaster::ViewMask_t & ConvergenceMaster::GetMaskUCur (  )  const

get current "mask level" for U view

Definition at line 214 of file ConvergenceMaster.cxx.

References fMaskCur.

Referenced by FitStateInitial::Iterate(), FitStateDiverged::Iterate(), and FitStateConverged::Iterate().

00215 {
00216     TracerSA trace("ConvergenceMaster::GetMaskUCur()");
00217     return fMaskCur->GetMaskU();
00218 }

const ConvergenceMaster::ViewMask_t & ConvergenceMaster::GetMaskVCur (  )  const

get current "mask level" for V view

Definition at line 224 of file ConvergenceMaster.cxx.

References fMaskCur.

Referenced by FitStateInitial::Iterate(), FitStateDiverged::Iterate(), and FitStateConverged::Iterate().

00225 {
00226     TracerSA trace("ConvergenceMaster::GetMaskVCur()");
00227     return fMaskCur->GetMaskV();
00228 }

ConvergenceMaster::Count_t ConvergenceMaster::GetNPlanesCur (  )  const

return current track segment length

Definition at line 344 of file ConvergenceMaster.cxx.

References fMaskCur.

Referenced by FitStateIterating::Iterate(), FitStateInitial::Iterate(), and FitContext::Print().

00345 {
00346     TracerSA trace("ConvergenceMaster::GetNPlanesCur()");
00347     return fMaskCur->GetPlaneCountCur();
00348 } 

ConvergenceMaster::Count_t ConvergenceMaster::GetNPlanesMax (  )  const

return maximum (for this mask level) track segment length

Definition at line 364 of file ConvergenceMaster.cxx.

References fMaskCur.

00365 {
00366     TracerSA trace("ConvergenceMaster::GetNPlanesMax()");
00367     return fMaskCur->GetPlaneCountMax();
00368 }

ConvergenceMaster::Count_t ConvergenceMaster::GetNPlanesMin (  )  const

return minimum (for this mask level) track segment length

Definition at line 354 of file ConvergenceMaster.cxx.

References fMaskCur.

Referenced by FitStateIterating::Iterate(), and FitStateInitial::Iterate().

00355 {
00356     TracerSA trace("ConvergenceMaster::GetNPlanesMin()");
00357     return fMaskCur->GetPlaneCountMin();
00358 }

Bool_t ConvergenceMaster::IncrementPlaneCount (  )  [private]

increase length of the track segment to fit

Definition at line 306 of file ConvergenceMaster.cxx.

References fMaskCur.

Referenced by NextStep().

00307 {
00308     TracerSA trace("ConvergenceMaster::IncrementPlaneCount()");
00309     return fMaskCur->IncrementPlaneCount();            
00310 }

Bool_t ConvergenceMaster::MaskIsValid (  )  const [inline]

Definition at line 117 of file ConvergenceMaster.h.

References fMaskIsValid.

Referenced by FitStateDiverged::Iterate(), and FitStateConverged::Iterate().

00117 { return fMaskIsValid; };

Bool_t ConvergenceMaster::NextMask ( Count_t  planeCount  )  [private]

switch to the next mask level

Definition at line 326 of file ConvergenceMaster.cxx.

References fMaskCur, fMaskIsValid, and fMaskList.

Referenced by NextStep().

00327 {
00328     TracerSA trace("ConvergenceMaster::NextMask()");
00329     ++fMaskCur;
00330     
00331     if ( fMaskCur == fMaskList.end() ) return kFALSE;
00332     
00333     fMaskCur->SetPlaneCountCur(planeCount);            
00334     fMaskCur->SetPlaneCountLast(planeCount);            
00335     
00336     fMaskIsValid = kFALSE;
00337     return kTRUE;
00338 }

Bool_t ConvergenceMaster::NextStep (  ) 

Depending on the result of previous iteration, choose the next mask level, track length to try.

Definition at line 259 of file ConvergenceMaster.cxx.

References DecrementPlaneCount(), fMaskCur, IncrementPlaneCount(), and NextMask().

Referenced by FitStateDiverged::Iterate(), and FitStateConverged::Iterate().

00260 {
00261     TracerSA trace("ConvergenceMaster::NextStep()");
00262     // possibilities
00263     // - cur step converged and not at max and prev < cur -> increment
00264     // - cur step converged and ( at max or prev > cur ) -> go to next mask
00265     // - cur step diverged and not at min and prev > cur -> decrement
00266     // - cur step diverged and ( at min or prev < cur ) -> go to next mask
00267     
00268     fMaskCur->Print();
00269         
00270     if (    fMaskCur->GetConvergedCur()     && 
00271             fMaskCur->GetPlaneCountCur() < fMaskCur->GetPlaneCountMax() && 
00272             fMaskCur->GetPlaneCountCur() >= fMaskCur->GetPlaneCountLast()   ) {
00273             
00274         return IncrementPlaneCount();
00275     
00276     } else if ( fMaskCur->GetConvergedCur()        && 
00277                 (fMaskCur->GetPlaneCountCur() == fMaskCur->GetPlaneCountMax()||  
00278                  fMaskCur->GetPlaneCountCur() <=  fMaskCur->GetPlaneCountLast()) 
00279                                                                             ) {
00280         
00281         return NextMask(fMaskCur->GetPlaneCountCur());
00282     
00283     } else if ( ! fMaskCur->GetConvergedCur() && 
00284                 fMaskCur->GetPlaneCountCur() > fMaskCur->GetPlaneCountMin()&&
00285                 fMaskCur->GetPlaneCountCur() <= fMaskCur->GetPlaneCountLast()
00286                                                                              ){
00287         
00288         return DecrementPlaneCount();
00289     
00290     } else if ( ! fMaskCur->GetConvergedCur() && 
00291                 ( fMaskCur->GetPlaneCountCur() == fMaskCur->GetPlaneCountMin() ||  
00292                   fMaskCur->GetPlaneCountCur() >=fMaskCur->GetPlaneCountLast())
00293                                                                             ){
00294         return NextMask(fMaskCur->GetPlaneCountCur());
00295     }
00296     
00297     assert ( ! "Should not get here!");
00298 
00299     return kTRUE;
00300 }

void ConvergenceMaster::PadMaskLists ( ViewMaskList_t uMaskList,
ViewMaskList_t vMaskList 
) [private]

if U and V masks have different number of "levels" - pad the shorter one with copies of the last element

Definition at line 84 of file ConvergenceMaster.cxx.

References PadWithLastElement().

Referenced by BuildMasks().

00086 {
00087     TracerSA trace("ConvergenceMaster::PadMaskLists(ViewMaskList_t&, ViewMaskList_t&)");
00088     UInt_t sizeU = uMaskList.size();
00089     UInt_t sizeV = vMaskList.size();
00090     
00091     // if size equal - nothing to do, return
00092     if ( sizeU == sizeV ) return;
00093 
00094     // pad one of the lists    
00095     if ( sizeU < sizeV ) {
00096         PadWithLastElement(uMaskList, sizeV-sizeU);
00097     } else {
00098         PadWithLastElement(vMaskList, sizeU-sizeV);
00099     }
00100     return;
00101 }

void ConvergenceMaster::PadWithLastElement ( ViewMaskList_t maskList,
UInt_t  n 
) [private]

extend vector by copying the last element n times

Definition at line 107 of file ConvergenceMaster.cxx.

Referenced by PadMaskLists().

00108 {
00109     TracerSA trace("ConvergenceMaster::PadWithLastElement(ViewMaskList_t&, UInt_t)");
00110     ViewMask_t last = *maskList.rbegin();
00111     
00112     for ( UInt_t i = 0; i < n; ++i ) {
00113         maskList.push_back(last);
00114     }
00115     
00116     return;
00117 } 

void ConvergenceMaster::PrintMasks (  )  const [private]

print masks (printing masks is useful to understand what is going on)

Definition at line 234 of file ConvergenceMaster.cxx.

References fMaskList, it, Msg::kDebug, and MSGSTREAM.

Referenced by BuildMasks().

00235 {
00236     TracerSA trace("ConvergenceMaster::PrintMasks()");
00237 
00238     MaskListCItr beg = fMaskList.begin();
00239     MaskListCItr end = fMaskList.end();
00240       
00241     MsgStream *mftsa = &MSGSTREAM("FitTrackSA", Msg::kDebug);
00242     (*mftsa) << "\nmasks:\n";
00243 
00244     for (MaskListCItr it = beg; it!=end; ++it) {
00245         (*mftsa) << "Level " << it-beg << "\n";
00246         it->PrintMasks();
00247         (*mftsa) << "\n";       
00248     }
00249     
00250     return;
00251 }

void ConvergenceMaster::SetConverged (  )  [inline]

Definition at line 120 of file ConvergenceMaster.h.

References fMaskCur.

Referenced by FitStateIterating::Iterate().

00120 { fMaskCur->SetConverged(); };    

void ConvergenceMaster::SetDiverged (  )  [inline]

Definition at line 121 of file ConvergenceMaster.h.

References fMaskCur.

Referenced by FitStateIterating::Iterate().

00121 { fMaskCur->SetDiverged(); };

void ConvergenceMaster::SetInitialMask (  )  [private]

set the "maximal" mask level (between 4 and 7 hits used in each view) as the initial mask

Definition at line 124 of file ConvergenceMaster.cxx.

References fMaskCur, fMaskIsValid, and fMaskList.

Referenced by BuildMasks().

00125 {
00126     TracerSA trace("ConvergenceMaster::SetInitialMask()");
00127     fMaskCur = fMaskList.begin();
00128     fMaskIsValid = kTRUE;
00129 }

void ConvergenceMaster::SetMaskIsValid ( Bool_t  valid  )  [inline]

Definition at line 118 of file ConvergenceMaster.h.

References fMaskIsValid.

Referenced by FitStateDiverged::Iterate(), and FitStateConverged::Iterate().

00118 { fMaskIsValid = valid; };

void ConvergenceMaster::SetNHitsInViewMin ( Int_t  n  )  [inline]

Definition at line 112 of file ConvergenceMaster.h.

References fNHitsInViewMin.

Referenced by FitContext::FitContext().

00113                     { fNHitsInViewMin = n; } ;

Bool_t ConvergenceMaster::UnsetEverySecond ( ViewMask_t mask  )  [private]

"mask" every other hit

Definition at line 180 of file ConvergenceMaster.cxx.

References find(), fNHitsInViewMin, it, Msg::kDebug, and MSG.

Referenced by BuildViewMasks().

00181 { 
00182     TracerSA trace("ConvergenceMaster::UnsetEverySecond(vector<Int_t>&)");
00183     ViewMaskItr begin   = mask.begin();
00184     ViewMaskItr end     = mask.end();
00185     
00186     // if total number of hits is less than 7 - stop
00187     Int_t nhits = accumulate(begin, end, 0);
00188     MSG("FitTrackSA", Msg::kDebug) << "#hits = " << nhits << "\n";
00189     if ( nhits < (2*fNHitsInViewMin-1) ) return kFALSE;
00190     
00191     ViewMaskItr it = begin;
00192     while ( (it = find(it, end, 1)) != end ) {
00193         // skip this occurance of 1
00194         MSG("FitTrackSA", Msg::kDebug) << "found hit at " << it-begin << ", skipping\n";
00195         ++it;
00196         if ( it == end ) break;
00197         
00198         // find next 1, set it to 0
00199         it = find(it, end, 1);
00200         if ( it == end ) break;        
00201         MSG("FitTrackSA", Msg::kDebug) << "found hit at " << it-begin 
00202             << ", setting to 0\n";
00203         *it = 0;
00204         ++it;
00205         if ( it == end ) break;
00206     }
00207     return kTRUE;
00208 }    


Member Data Documentation

Definition at line 155 of file ConvergenceMaster.h.

Referenced by MaskIsValid(), NextMask(), SetInitialMask(), and SetMaskIsValid().

Definition at line 152 of file ConvergenceMaster.h.

Referenced by BuildMaskSteps(), NextMask(), PrintMasks(), and SetInitialMask().

Definition at line 150 of file ConvergenceMaster.h.

Referenced by BuildMaskSteps(), SetNHitsInViewMin(), and UnsetEverySecond().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1