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

AlgFitTrackSA.cxx

Go to the documentation of this file.
00001 //_____________________________________________________________________________
00028 
00029 #include <cassert>
00030 #include <vector>
00031 
00032 #include "TStopwatch.h"
00033 
00034 #include "MessageService/MsgService.h"
00035 #include "Plex/PlexPlaneId.h"
00036 #include "RecoBase/CandTrackHandle.h"
00037 
00038 #include "Swimmer/SwimSwimmer.h"
00039 
00040 #include "CandFitTrackSA/AlgFitTrackSA.h"
00041 #include "CandFitTrackSA/CandFitTrackSAHandle.h"
00042 #include "CandFitTrackSA/FitContext.h"
00043 #include "CandFitTrackSA/FitStateFactory.h"
00044 #include "CandFitTrackSA/Ntp/NtpFitSA.h"
00045 #include "CandFitTrackSA/TracerSA.h"
00046 #include "CandFitTrackSA/TrackContext.h"
00047 #include "CandFitTrackSA/TrackFilter.h"
00048 #include "CandFitTrackSA/TrackFilterFactory.h"
00049 #include "CandFitTrackSA/TrackSegmentMaker.h"
00050 
00051 #include "CandFitTrackSA/TrackSegmentMakerDummy.h"
00052 #include "CandFitTrackSA/TrackEstimatorFixed.h"
00053 
00054 CVSID("$Id: AlgFitTrackSA.cxx,v 1.33 2006/02/04 21:47:35 avva Exp $");
00055 
00056 using std::vector;
00057 
00058 ClassImp(AlgFitTrackSA)
00059 
00060 AlgFitTrackSA::AlgFitTrackSA() :
00061     fFilter(0), fSegmentMaker(0), 
00062     fEstimator(0), fSwimmer(0)
00063 {
00064     TracerSA trace("AlgFitTrackSA::AlgFitTrackSA()");
00065 }
00066 
00067 
00068 AlgFitTrackSA::~AlgFitTrackSA()
00069 {
00070     TracerSA trace("AlgFitTrackSA::~AlgFitTrackSA()");        
00071     delete fSegmentMaker; fSegmentMaker = 0;
00072     delete fEstimator; fEstimator = 0;
00073     delete fSwimmer; fSwimmer = 0;
00074 }
00075 
00079 void AlgFitTrackSA::RunAlg(AlgConfig& ac,
00080                             CandHandle& ch, CandContext& candTrackContext)
00081 {
00082     TracerSA trace("AlgFitTrackSA::RunAlg(AlgConfig& , CandHandle& , CandContext& )");
00083 
00084     CandFitTrackSAHandle& cftsah = (CandFitTrackSAHandle&) ch;
00085     TrackContext trackContext(candTrackContext);
00086 
00087     // todo on first call
00088     static Bool_t first = kTRUE;
00089     if ( first ) {
00090         first = kFALSE;
00091         // create filter, segment maker, estimator and swimmer
00092         // and configure them
00093         
00094         // TrackFilter 
00095         const char* filterName = ac.GetCharString("TrackFilter");
00096         fFilter = TrackFilterFactory::Instance().GetTrackFilter(filterName);
00097         fFilter->Config(ac); 
00098         
00099         // Segment Maker
00100         fSegmentMaker = new TrackSegmentMakerDummy();
00101         fSegmentMaker->Config(ac); 
00102         
00103         // TrackExtimator        
00104         fEstimator = new TrackEstimatorFixed();
00105         fEstimator->Config(ac);
00106         
00107         // Swimmer
00108         fSwimmer = new SwimSwimmer(trackContext.GetVldContext());
00109     }
00110             
00111     // check if the track passes filter (return otherwise)
00112     // (don't really have to configure fiter every time)
00113     if ( ! fFilter->Pass(trackContext) ) {
00114         MSG("FitTrackSA",Msg::kVerbose) 
00115            << "Track failed cuts, skipping." << "\n";
00116         return;
00117     }
00118     
00119     // split track into segments
00120     vector<TrackContext> segments;
00121     Int_t status = fSegmentMaker->MakeSegments(trackContext, segments);
00122     assert( status == 0 && "Couldn't make segments!" );
00123     
00124     // loop over track segments and fit each one
00125     typedef vector<TrackContext>::const_iterator TCItr;
00126     for ( TCItr it = segments.begin(); it != segments.end(); ++it) {
00127         NtpFitSA ntp = DoFit(ac, *it);
00128         // Add ntuple to CandFitTrackSA 
00129         cftsah.AddNtpFitSA(ntp);
00130     }
00131  
00132     // that's all
00133     return;   
00134 }
00135 
00136 
00140 NtpFitSA AlgFitTrackSA::DoFit(const AlgConfig& ac, const TrackContext& trackContext)
00141 {
00142     TracerSA trace("AlgFitTrackSA::DoFit(const TrackContext& )");
00143         
00144     FitContext fit(ac, trackContext, fEstimator, fSwimmer);
00145 
00146     FitStateFactory& fitStateFactory = FitStateFactory::Instance();
00147     
00148     // Start timer
00149     TStopwatch timer;
00150     timer.Start();
00151     
00152     // main loop -> iterate until fit goes into "Final" state
00153     while ( fit.fState != fitStateFactory.GetFitState("Final") ) {
00154         fit.Iterate();
00155     }
00156     
00157     fit.Iterate();    
00158     
00159     // stop timer and save cputime
00160     timer.Stop();
00161     fit.SetCpu(timer.CpuTime());
00162     
00163     return fit.MakeNtpFitSA();
00164 }
00165 

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