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

StraightTrackAlignment Class Reference

#include <StraightTrackAlignment.h>

List of all members.

Public Types

typedef std::list< UgliStripHandleStraightTrack

Public Member Functions

 StraightTrackAlignment ()
 ~StraightTrackAlignment ()
void Init (UgliGeomHandle &geom_handle, const char *histname=0)
void AddTrack (const CandTrackHandle &track_handle)
double ApplyTrack (StraightTrack st, PlaneView::PlaneView_t view)
double ApplyAllTracks ()
double ApplyAllTracks (PlaneView::PlaneView_t the_view)
void ApplyAllOffsets (void)

Private Types

typedef std::map< PlexScintMdlId,
ScintModule * > 
ScintModuleLookup

Private Member Functions

 StraightTrackAlignment (const StraightTrackAlignment &rhs)
StraightTrackAlignmentoperator= (const StraightTrackAlignment &rhs)
ScintModuleLookupScintModule (UgliStripHandle ush)
double FitTrackLessOne (StraightTrack::iterator lit, StraightTrack::iterator end, StraightTrack::iterator skip)

Private Attributes

std::list< StraightTrackfTracks [2]
ScintModuleLookup fSMLookup
AlignHistsfHister
int fMinPlanes
int fNplanes
int fNmdlperplane
const char * fHistName


Member Typedef Documentation

typedef std::map<PlexScintMdlId, ScintModule*> StraightTrackAlignment::ScintModuleLookup [private]
 

Definition at line 68 of file StraightTrackAlignment.h.

typedef std::list<UgliStripHandle> StraightTrackAlignment::StraightTrack
 

Definition at line 35 of file StraightTrackAlignment.h.

Referenced by AddTrack().


Constructor & Destructor Documentation

StraightTrackAlignment::StraightTrackAlignment  ) 
 

Definition at line 20 of file StraightTrackAlignment.cxx.

00021     : fHister(0)
00022       ,fMinPlanes(14)            // hard code for now.
00023       ,fHistName(0)
00024 {
00025 }

StraightTrackAlignment::~StraightTrackAlignment  ) 
 

Definition at line 27 of file StraightTrackAlignment.cxx.

00028 {
00029     if (fHister) delete fHister;
00030 }

StraightTrackAlignment::StraightTrackAlignment const StraightTrackAlignment rhs  )  [private]
 


Member Function Documentation

void StraightTrackAlignment::AddTrack const CandTrackHandle track_handle  ) 
 

Definition at line 60 of file StraightTrackAlignment.cxx.

References fTracks, CandHandle::GetDaughterIterator(), CandHandle::GetNDaughters(), PlexPlaneId::GetPlaneView(), CandStripHandle::GetStripEndId(), CandHandle::GetVldContext(), and StraightTrack.

Referenced by AlignmentModule::Ana().

00061 {
00062     int nhits = track_handle.GetNDaughters();
00063     if (nhits < fMinPlanes) return;
00064 
00065 //    cerr << nhits << " hits\n";
00066 
00067     UgliGeomHandle ugh(*(track_handle.GetVldContext()));
00068     CandStripHandleItr sitr(track_handle.GetDaughterIterator());
00069     
00070     StraightTrack st[2];
00071     CandStripHandle* csh = 0;
00072     while ((csh = sitr())) {
00073         cerr << ".";
00074         PlexStripEndId seid = csh->GetStripEndId();
00075         int view = 0;
00076         if (seid.GetPlaneView() != PlaneView::kV) view = 1;
00077         st[view].push_back(ugh.GetStripHandle(seid));
00078     }
00079     cerr << endl;
00080 
00081     if (st[0].size()) {
00082         fTracks[0].push_back(st[0]);
00083     }
00084     if (st[1].size()) {
00085         fTracks[1].push_back(st[1]);
00086     }
00087 }

void StraightTrackAlignment::ApplyAllOffsets void   ) 
 

Definition at line 205 of file StraightTrackAlignment.cxx.

References ScintModule::ClearStatistics(), fHister, fSMLookup, AlignHists::IncrementIteration(), and ScintModule::UpdateOffsets().

Referenced by AlignmentModule::EndJob().

00206 {
00207     ScintModuleLookup::iterator mit, end = fSMLookup.end();
00208     for (mit = fSMLookup.begin(); mit != end; ++mit) {
00209         ScintModule* sm = mit->second;
00210         if (!sm) {
00211             cerr << "Bad ScintModule in lookup\n";
00212             continue;
00213         }
00214         sm->UpdateOffsets();
00215         sm->ClearStatistics();
00216     }
00217     if (fHister) fHister->IncrementIteration();
00218 }

double StraightTrackAlignment::ApplyAllTracks PlaneView::PlaneView_t  the_view  ) 
 

Definition at line 172 of file StraightTrackAlignment.cxx.

References ApplyTrack(), count, and fTracks.

00173 {
00174     int view = 0;
00175     if (the_view == PlaneView::kV) view = 1;
00176     list<StraightTrack>::iterator lit, end = fTracks[view].end();
00177 
00178     cerr << "Applying " << fTracks[view].size() << " tracks in view " 
00179          << view << endl;
00180 
00181     double tot = 0;
00182     int count = 0;
00183     for (lit=fTracks[view].begin(); lit != end; ++lit) {
00184         tot += this->ApplyTrack(*lit,the_view);
00185         ++ count;
00186     }
00187     cerr << "Done applying tracks\n";
00188     return count ? tot/count : 0;
00189 }

double StraightTrackAlignment::ApplyAllTracks  ) 
 

Definition at line 190 of file StraightTrackAlignment.cxx.

References fHister, fHistName, fNmdlperplane, and fNplanes.

Referenced by AlignmentModule::EndJob().

00191 {
00192     static bool been_here = false;
00193     if (! been_here) {
00194         fHister = new AlignHists(fNplanes,fNmdlperplane,fHistName);
00195         been_here = true;
00196     }
00197                                  
00198 
00199     double ret = 0;
00200     ret += this->ApplyAllTracks(PlaneView::kU);
00201     ret += this->ApplyAllTracks(PlaneView::kV);
00202     return ret/2.0;
00203 }

double StraightTrackAlignment::ApplyTrack StraightTrack  st,
PlaneView::PlaneView_t  view
 

Definition at line 142 of file StraightTrackAlignment.cxx.

References AlignHists::ApplyTrack(), count, fHister, FitTrackLessOne(), UgliScintMdlHandle::GetModuleNum(), PlexPlaneId::GetPlane(), and UgliScintMdlHandle::GetPlexPlaneId().

Referenced by ApplyAllTracks().

00144 {
00145     double tot = 0;
00146     StraightTrack::iterator lit, first=st.begin(), end = st.end();
00147 
00148     vector<int> planev, mdlv, stripv;
00149     vector<double> residv;
00150 
00151     int count = 0;
00152     for (lit = first; lit != end; ++lit) {
00153 //        cerr << ".";
00154         double resid = this->FitTrackLessOne(first,end,lit);
00155         if (fHister) {
00156             UgliScintMdlHandle usmh = (*lit).GetScintMdlHandle();
00157             PlexPlaneId ppid = usmh.GetPlexPlaneId();
00158             residv.push_back(resid);
00159             planev.push_back(ppid.GetPlane());
00160             stripv.push_back((*lit).GetSEId().GetStrip());
00161             mdlv.push_back(usmh.GetModuleNum());
00162         }
00163         tot += resid;
00164         ++count;
00165     }
00166     if (fHister) fHister->ApplyTrack(view,stripv,planev,mdlv,residv);
00167     
00168     return count ? tot/count : 0;
00169 }

double StraightTrackAlignment::FitTrackLessOne StraightTrack::iterator  lit,
StraightTrack::iterator  end,
StraightTrack::iterator  skip
[private]
 

Definition at line 94 of file StraightTrackAlignment.cxx.

References ScintModule::AccumResid(), count, ScintModule::GetOffset(), UgliStripHandle::GetTPos(), UgliStripHandle::GlobalPos(), and LookupScintModule().

Referenced by ApplyTrack().

00097 {
00098     // Linear regression parameters.  See for eg. Num Rec Ch 15.
00099     // x is Z, y is TPos (U or V).
00100     double S, Sx, Sy, Sxx, Sxy;
00101     S=Sx=Sy=Sxx=Sxy=0.0;
00102 
00103     int count = 0;
00104 
00105     for (;lit != end; ++lit) {
00106         if (lit == skip) continue;
00107 
00108         UgliStripHandle ush = (*lit);
00109         ScintModule* smod = this->LookupScintModule(ush);
00110 
00111         float x = ush.GlobalPos(0)(2);
00112         float y = ush.GetTPos() + smod->GetOffset();
00113         
00114         Sx += x;
00115         Sy += y;
00116         Sxx += x*x;
00117         Sxy += x*y;        
00118 
00119         ++count;
00120     }
00121     S = count;
00122 
00123     // Note, since I assume a constant uncertainty in the transverse
00124     // position measurement, it drops out of hte final result.
00125 
00126     // The linear fit: y = a + bx
00127     double delta = S*Sxx - Sx*Sx;
00128     double a = (Sxx*Sy - Sx*Sxy)/delta;
00129     double b = (S*Sxy - Sx*Sy)/delta;
00130 
00131     double predict = a + b*(*skip).GlobalPos(0)(2);
00132     predict -= (*skip).GetTPos();
00133     ScintModule* smod = this->LookupScintModule(*skip);
00134     if (smod) smod->AccumResid(predict);
00135     else {
00136         cerr << "Failed to lookup scint module!\n";
00137     }
00138     return predict;
00139 }

void StraightTrackAlignment::Init UgliGeomHandle geom_handle,
const char *  histname = 0
 

Definition at line 33 of file StraightTrackAlignment.cxx.

References fHistName, fNmdlperplane, fNplanes, and UgliGeomHandle::GetScintPlnHandleVector().

Referenced by AlignmentModule::Ana().

00034 {
00035     fHistName = histname;
00036     vector<UgliScintPlnHandle> planevec = ugh.GetScintPlnHandleVector();
00037     fNplanes = planevec.size();
00038     fNmdlperplane = planevec[0].GetScintMdlHandleVector().size();
00039 }

ScintModule * StraightTrackAlignment::LookupScintModule UgliStripHandle  ush  )  [private]
 

Definition at line 42 of file StraightTrackAlignment.cxx.

References fSMLookup, UgliScintMdlHandle::GetPlexScintMdlId(), and UgliStripHandle::GetScintMdlHandle().

Referenced by FitTrackLessOne().

00043 {
00044     UgliScintMdlHandle usmh = ush.GetScintMdlHandle();
00045     PlexScintMdlId smid = usmh.GetPlexScintMdlId();
00046 
00047     ScintModuleLookup::iterator it = fSMLookup.find(smid);
00048     if (it == fSMLookup.end()) {  // D.N.E.
00049         ScintModule* smod = new ScintModule(usmh);
00050         assert(smod);
00051         fSMLookup[smid] = smod;
00052         return smod;
00053     }
00054 
00055     assert(it->second);
00056     return it->second;
00057 }

StraightTrackAlignment& StraightTrackAlignment::operator= const StraightTrackAlignment rhs  )  [private]
 


Member Data Documentation

AlignHists* StraightTrackAlignment::fHister [private]
 

Definition at line 70 of file StraightTrackAlignment.h.

Referenced by ApplyAllOffsets(), ApplyAllTracks(), and ApplyTrack().

const char* StraightTrackAlignment::fHistName [private]
 

Definition at line 74 of file StraightTrackAlignment.h.

Referenced by ApplyAllTracks(), and Init().

int StraightTrackAlignment::fMinPlanes [private]
 

Definition at line 71 of file StraightTrackAlignment.h.

int StraightTrackAlignment::fNmdlperplane [private]
 

Definition at line 73 of file StraightTrackAlignment.h.

Referenced by ApplyAllTracks(), and Init().

int StraightTrackAlignment::fNplanes [private]
 

Definition at line 72 of file StraightTrackAlignment.h.

Referenced by ApplyAllTracks(), and Init().

ScintModuleLookup StraightTrackAlignment::fSMLookup [private]
 

Definition at line 69 of file StraightTrackAlignment.h.

Referenced by ApplyAllOffsets(), and LookupScintModule().

std::list<StraightTrack> StraightTrackAlignment::fTracks[2] [private]
 

Definition at line 65 of file StraightTrackAlignment.h.

Referenced by AddTrack(), and ApplyAllTracks().


The documentation for this class was generated from the following files:
Generated on Fri Mar 28 16:12:14 2008 for loon by  doxygen 1.3.9.1