MakeAlignmentModule Class Reference

#include <MakeAlignmentModule.h>

Inheritance diagram for MakeAlignmentModule:
JobCModule

List of all members.

Public Member Functions

 MakeAlignmentModule ()
virtual ~MakeAlignmentModule ()
void BeginJob ()
JobCResult Ana (const MomNavigator *mom)
void EndJob ()

Private Member Functions

bool ReadRecord (const NtpAlignmentRecord *ntprec)
void ProcessRecord (const NtpAlignmentRecord *ntprec)
bool RecalculateResiduals ()
bool GetTrackQuality (const NtpAlignmentRecord *ntprec)
double FitTrackLessOne (vector< AlignmentStrip >::const_iterator begin, vector< AlignmentStrip >::const_iterator end, vector< AlignmentStrip >::const_iterator skip)
void ConvertToLocal (AlignmentStrip &astrip, PlexStripEndId &plexid, UgliGeomHandle &ugh, UgliStripHandle &ush)
void PrintJobStatistics ()
void PrintAlignmentStrip (const AlignmentStrip &astrip)

Private Attributes

AlignmentAlgorithmfAlgorithm
AlignmentHistogramsfHistogram
AlignmentRunSummary fRunSummary
const VldTimeStamp fNearCoilOn
TFile * fRootFile
int fIteration
VldContext fValidityContext
int fCurrentRun
int fCurrentSubRun
int fNProcessedSubruns
const int fNSubRunsPerSubset
vector< AlignmentStripfTrackVStrip
vector< AlignmentStripfTrackUStrip
vector< AlignmentStripfCandVStrip
vector< AlignmentStripfCandUStrip
const Double_t fMaxTrackChargeCut
const Double_t fMinTrackChargeCut
const Double_t fMaxSigmaOfTPosCut
const Double_t fTrackChargeRatioCut
const Double_t fMinCosZCut
const Double_t fMinTrackStripChargeCut
const Double_t fMaxTrackStripChargeCut
const Int_t fSpecialNDRunNumber
bool fRecalculateResidual
bool fApplyCuts
const unsigned int fStatisticalSubsetSize
unsigned int fNFailedFit
unsigned int fNRecords
unsigned int fNPassedRecords
unsigned int fNSubsetRecords
unsigned int fNFailedRead
unsigned int fNMissedVPlane
unsigned int fNMissedUPlane
unsigned int fTotalVPlaneHits
unsigned int fTotalUPlaneHits
unsigned int fFailedCut
unsigned int fNHitsOutsideStrip
unsigned int fNFailedCutMaxVStripCharge
unsigned int fNFailedCutMaxUStripCharge
Double_t fMissedVPlaneMeanCharge
Double_t fMissedUPlaneMeanCharge
Double_t fMissedVPlaneChargeSigma
Double_t fMissedUPlaneChargeSigma
unsigned int fNFailedTrackChargeCut
unsigned int fNFailedStripChargeCut
unsigned int fNFailedCosZCut
unsigned int fNFailedChargeRatioCut
unsigned int fNFailedSigmaTPosCut
TStopwatch fTimer
TStopwatch fTimerInterval

Detailed Description

Definition at line 51 of file MakeAlignmentModule.h.


Constructor & Destructor Documentation

MakeAlignmentModule::MakeAlignmentModule (  ) 

Definition at line 44 of file MakeAlignmentModule.cxx.

00045    :fAlgorithm(0),
00046     fHistogram(0),
00047     fNearCoilOn(2004, 12, 9, 0, 0, 0), //Time when ND coil was first turned on
00048     fIteration(0),                      //Alignment iteration number
00049     fCurrentRun(0),
00050     fCurrentSubRun(0),
00051     fNProcessedSubruns(0),
00052     fNSubRunsPerSubset(41),
00053     fMaxTrackChargeCut(60000.0),        //cut on max 2d track charge used for alignment
00054     fMinTrackChargeCut(4000.0),         //cut on min 2d track charge used for alignment
00055     fMaxSigmaOfTPosCut(0.03),           //cut on uncertainty in tpos from 2d track fit
00056     fTrackChargeRatioCut(0.5),          //min 3d track's charge ratio to total snarl charge
00057     fMinCosZCut(0.25),                  //min fabs(cosz) of 3d track angle with Z axis
00058     fMinTrackStripChargeCut(100.0),     //min charge in a alternative track strip 
00059     fMaxTrackStripChargeCut(5000.0),    //max charge in a hit alignment strip
00060     fSpecialNDRunNumber(5845),          //ND run # used in 1st ND alignment with magnetic field
00061     fRecalculateResidual(false),
00062     fApplyCuts(false),
00063     fStatisticalSubsetSize(1000000),    //Number of records in a statistical subset
00064     fNFailedFit(0),
00065     fNRecords(0),
00066     fNPassedRecords(0),
00067     fNSubsetRecords(0),
00068     fNFailedRead(0),
00069     fNMissedVPlane(0),
00070     fNMissedUPlane(0),
00071     fTotalVPlaneHits(0),
00072     fTotalUPlaneHits(0),
00073     fFailedCut(0),
00074     fNHitsOutsideStrip(0),
00075     fNFailedCutMaxVStripCharge(0),
00076     fNFailedCutMaxUStripCharge(0),
00077     fMissedVPlaneMeanCharge(0.0),
00078     fMissedUPlaneMeanCharge(0.0),
00079     fMissedVPlaneChargeSigma(0.0),
00080     fMissedUPlaneChargeSigma(0.0),
00081     fNFailedTrackChargeCut(0),
00082     fNFailedStripChargeCut(0),
00083     fNFailedCosZCut(0),
00084     fNFailedChargeRatioCut(0),
00085     fNFailedSigmaTPosCut(0)
00086 {
00087 }

virtual MakeAlignmentModule::~MakeAlignmentModule (  )  [inline, virtual]

Definition at line 56 of file MakeAlignmentModule.h.

00056 {};


Member Function Documentation

JobCResult MakeAlignmentModule::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 149 of file MakeAlignmentModule.cxx.

References fAlgorithm, fApplyCuts, fCandUStrip, fCandVStrip, fCurrentRun, fCurrentSubRun, fFailedCut, fHistogram, AlignmentRunSummary::Fill(), fNFailedRead, fNPassedRecords, fNProcessedSubruns, fNRecords, fNSubRunsPerSubset, fNSubsetRecords, fRecalculateResidual, fRootFile, fRunSummary, fSpecialNDRunNumber, fTimerInterval, fTrackUStrip, fTrackVStrip, fValidityContext, VldContext::GetDetector(), MomNavigator::GetFragment(), RecRecordImp< T >::GetHeader(), RecDataHeader::GetRun(), RecDataHeader::GetSubRun(), GetTrackQuality(), RecHeader::GetVldContext(), JobCResult::kAOK, Msg::kError, Msg::kInfo, Detector::kNear, MSG, ProcessRecord(), ReadRecord(), RecalculateResiduals(), and run().

00150 {
00151    fNRecords++;        
00152 
00153    NtpAlignmentRecord* ntprec = dynamic_cast<NtpAlignmentRecord*>(mom->GetFragment("NtpAlignmentRecord"));
00154    if(!ntprec) return JobCResult::kAOK;   
00155 
00156    const RecCandHeader candheader = ntprec->GetHeader();
00157    const int run    = candheader.GetRun();
00158    const int subrun = candheader.GetSubRun();
00159    VldContext vldc  = candheader.GetVldContext();
00160 
00161    if(fNRecords % 10000 == 0)
00162    {
00163       MsgFormat f("%10d");      
00164       MSG("Align", Msg::kInfo) << "Found NtpAlignmentRecord #" << f(fNRecords)
00165                                << " run #" << run << ", subrun #" << subrun
00166                                << ", cpu time = " << fTimerInterval.RealTime() <<endl;
00167       fTimerInterval.Reset();
00168       fTimerInterval.Start();
00169    }    
00170 
00171    if(!fAlgorithm && !fHistogram)
00172    { 
00173       fValidityContext = vldc;
00174       fHistogram = new AlignmentHistograms(fRootFile, fValidityContext);
00175       fAlgorithm = new AlignmentAlgorithm(fRootFile, fValidityContext);
00176    }
00177    
00178    if(fValidityContext.GetDetector() != vldc.GetDetector())
00179    {
00180       MSG("Align", Msg::kError) << "The data in current record is for the different detector!" << endl;
00181       return JobCResult::kAOK;
00182    } else
00183       fValidityContext = vldc;   
00184 
00185    //Fill run summary object
00186    fRunSummary.Fill(ntprec); 
00187 
00188    if(fApplyCuts && !GetTrackQuality(ntprec))
00189    {
00190       fFailedCut++;
00191       return JobCResult::kAOK;   
00192    }      
00193       
00194    //Read residuals and other strips' info to vectors of AlignmentStrips
00195    if(!ReadRecord(ntprec))
00196    {
00197       fFailedCut++;
00198       fNFailedRead++;
00199       return JobCResult::kAOK;      
00200    }   
00201 
00202    if(fRecalculateResidual && !RecalculateResiduals()) 
00203    {
00204       return JobCResult::kAOK;
00205    }
00206    
00207    ProcessRecord(ntprec);
00208 
00209    fHistogram -> FillPlanePlex(fTrackVStrip, fCandVStrip);
00210    fHistogram -> FillPlanePlex(fTrackUStrip, fCandUStrip);
00211 
00212    fNPassedRecords++;
00213    fNSubsetRecords++;
00214    
00215    if(fCurrentRun != run || fCurrentSubRun != subrun)
00216    {
00217       fCurrentRun    = run;
00218       fCurrentSubRun = subrun;
00219       fNProcessedSubruns++;      
00220       if(fNProcessedSubruns % fNSubRunsPerSubset == 0)
00221       {
00222          if(fCurrentRun != fSpecialNDRunNumber ||
00223             fValidityContext.GetDetector() != Detector::kNear)
00224          {
00225             fAlgorithm -> ResetSubset(fValidityContext, fNSubsetRecords);
00226             fNSubsetRecords = 0;
00227          }      
00228       }
00229       if(fCurrentRun == fSpecialNDRunNumber &&
00230          fValidityContext.GetDetector() == Detector::kNear)
00231          if(fCurrentSubRun == 0 || fCurrentSubRun == 24)
00232          {
00233             fAlgorithm -> ResetSubset(fValidityContext, fNSubsetRecords);
00234             fNSubsetRecords = 0;
00235          }
00236    }
00237    
00238    return JobCResult::kAOK;   
00239 }

void MakeAlignmentModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 89 of file MakeAlignmentModule.cxx.

References fApplyCuts, fIteration, fRecalculateResidual, fRootFile, fTimer, fTimerInterval, Msg::kDebug, Msg::kFatal, Msg::kInfo, Msg::kWarning, and MSG.

00090 { 
00091    MSG("Align", Msg::kDebug) << "MakeAlignmentModule::BeginJob()"<< endl;
00092    MSG("Align", Msg::kInfo) << "Initializing variables and histograms..." << endl;
00093 
00094    const char* strENV_ALIGN_ITER = getenv("ENV_ALIGN_ITER");
00095    if ( strENV_ALIGN_ITER == 0 || strlen(strENV_ALIGN_ITER) == 0 )
00096    {
00097       MSG("Align", Msg::kFatal) << "ENV_ALIGN_ITER is not set!" <<endl
00098                                 << " Program is terminating now." <<endl;
00099       abort();
00100    } else 
00101       fIteration = atoi(strENV_ALIGN_ITER);
00102    
00103    string alignmentpath;
00104    const char* strENV_ALIGN_DIR = getenv("ENV_ALIGN_DIR");
00105    if ( strENV_ALIGN_DIR == 0 || strlen(strENV_ALIGN_DIR) == 0 )
00106    {
00107       MSG("Align", Msg::kFatal) << "ENV_ALIGN_DIR is not set!"
00108                                 << " Program is terminating now." <<endl;
00109       abort();
00110    } else
00111       alignmentpath = string(strENV_ALIGN_DIR);
00112    
00113    const char* strENV_ALIGN_APPLYCUTS = getenv("ENV_ALIGN_APPLYCUTS");
00114    if ( strENV_ALIGN_APPLYCUTS == 0 || strlen(strENV_ALIGN_APPLYCUTS) == 0 )
00115    {
00116       MSG("Align", Msg::kWarning) << "ENV_ALIGN_APPLYCUTS is not set!"
00117                                   << " Using default value: fApplyCuts=false" <<endl;
00118    } else 
00119       if(atoi(strENV_ALIGN_APPLYCUTS) == 1)
00120          fApplyCuts = true;
00121       
00122    const char* strENV_ALIGN_RECALCULATE = getenv("ENV_ALIGN_RECALCULATE");
00123    if ( strENV_ALIGN_RECALCULATE == 0 || strlen(strENV_ALIGN_RECALCULATE) == 0 )
00124    {
00125       MSG("Align", Msg::kWarning) << "ENV_ALIGN_RECALCULATE is not set!"
00126                                   << " Using default value: fRecalculateResidual=false" <<endl;
00127    } else 
00128       if(atoi(strENV_ALIGN_RECALCULATE)==1)
00129          fRecalculateResidual = true;
00130 
00131    MSG("Align", Msg::kInfo) << endl << "fIteration = " << fIteration << endl
00132                             << "Alignment path: " << alignmentpath << endl
00133                             << "fApplyCuts = " << fApplyCuts <<endl
00134                             << "fRecalculateResidual = " << fRecalculateResidual <<endl << endl;
00135    
00136    stringstream ss;
00137    if(fApplyCuts)
00138       ss << alignmentpath << "/new_alignment_" << fIteration << ".root";
00139    else
00140       ss << alignmentpath << "/new_alignment_no_cuts_" << fIteration << ".root";         
00141    
00142    fRootFile = new TFile(ss.str().c_str(),"RECREATE");
00143    
00144    fTimer.Start();
00145    fTimerInterval.Start();
00146 }

void MakeAlignmentModule::ConvertToLocal ( AlignmentStrip astrip,
PlexStripEndId plexid,
UgliGeomHandle ugh,
UgliStripHandle ush 
) [private]

Definition at line 578 of file MakeAlignmentModule.cxx.

References fNHitsOutsideStrip, UgliStripHandle::GetHalfLength(), PlexPlaneId::GetPlaneView(), AlignmentStrip::ghitpos, UgliStripHandle::GlobalToLocal(), AlignmentStrip::goodhit, PlaneView::kU, StripEnd::kWest, AlignmentStrip::length, AlignmentStrip::lhitpos, AlignmentStrip::pigtail, AlignmentStrip::residual, AlignmentStrip::tpos, UgliGeomHandle::uvz2xyz(), AlignmentStrip::wlsbypass, UgliStripHandle::WlsBypass(), UgliStripHandle::WlsPigtail(), and AlignmentStrip::zpos.

Referenced by ReadRecord().

00582 {
00583    // calculate the position of strip ends in (strip) local co-ordinates
00584    // x = distance along the strip, y=distance in +tpos coordinate
00585    // the "logical" strip is the one as-if there were no coil/bypass
00586    Double_t halflen = ush.GetHalfLength();
00587    //   TVector3 localCenter(0,0,0);  // center of the "logical" strip
00588    //   TVector3 localEastEnd(-halflen,0,0);
00589    TVector3 localWestEnd(+halflen, 0.0, 0.0);
00590    //   TVector3 localHitLPos(astrip.lhitpos,0,0);
00591    
00592    // calculate the positions in global XYZ space
00593    //TVector3 xyz0 = ush.LocalToGlobal(localCenter);
00594    //TVector3 xyzE = ush.LocalToGlobal(localEastEnd);
00595    //TVector3 xyzW = ush.LocalToGlobal(localWestEnd);
00596 
00597    Double_t u = 0.0, v = 0.0;
00598 
00599    if(plexid.GetPlaneView() == PlaneView::kU){
00600       v = astrip.ghitpos;
00601       u = astrip.residual + astrip.tpos;
00602    } else {
00603       u = astrip.ghitpos;
00604       v = astrip.residual + astrip.tpos;
00605    }
00606    
00607 
00608    TVector3 ghituvz(u, v, astrip.zpos);
00609    TVector3 ghitxyz = ugh.uvz2xyz(ghituvz);
00610    TVector3 lhitxyz = ush.GlobalToLocal(ghitxyz);
00611       
00612    astrip.length = 2.0*halflen;
00613    astrip.lhitpos = lhitxyz.x();
00614    astrip.pigtail = ush.WlsPigtail(StripEnd::kWest);
00615    astrip.wlsbypass = ush.WlsBypass();
00616 
00617    if(fabs(lhitxyz.x()) > halflen){
00618       astrip.goodhit = false;
00619       fNHitsOutsideStrip++;
00620    }
00621 }

void MakeAlignmentModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 241 of file MakeAlignmentModule.cxx.

References fAlgorithm, fHistogram, AlignmentRunSummary::FillSummaryTree(), fNSubsetRecords, fRootFile, fRunSummary, fValidityContext, JobCModule::GetName(), Msg::kInfo, MSG, and PrintJobStatistics().

00242 { 
00243    PrintJobStatistics();   
00244 
00245    if(fHistogram) delete fHistogram;
00246 
00247    if(fAlgorithm)
00248    {
00249       fAlgorithm -> ResetSubset(fValidityContext, fNSubsetRecords);
00250       fAlgorithm -> RunAlgorithm();
00251       delete fAlgorithm;
00252    }
00253 
00254    fRunSummary.FillSummaryTree(fRootFile);
00255 
00256    MSG("Align", Msg::kInfo) << "Saving root file " << fRootFile -> GetName() << endl;
00257    fRootFile -> Write();
00258    fRootFile -> Close();
00259 
00260    MSG("Align", Msg::kInfo) << "MakeAlignmentModule is done." << endl;
00261 }

double MakeAlignmentModule::FitTrackLessOne ( vector< AlignmentStrip >::const_iterator  begin,
vector< AlignmentStrip >::const_iterator  end,
vector< AlignmentStrip >::const_iterator  skip 
) [private]

Definition at line 534 of file MakeAlignmentModule.cxx.

References MuELoss::a, det, F, Msg::kVerbose, Msg::kWarning, MSG, and run().

Referenced by RecalculateResiduals().

00537 {
00538 
00539    
00540    MSG("Align", Msg::kVerbose) << "FitTrackLessOne..." << endl;
00541    // Linear regression parameters least squares method. See for eg. Num Rec Ch 15
00542    // Fit y = ax + b, as in W. R. Leo, Techniques for ..., Section 4.7.2
00543    // x is strip's Z position, y is strip's transverse position (U or V).
00544    double A=0.0, B=0.0, C=0.0, D=0.0, E=0.0, F=0.0;
00545 
00546    for (vector<AlignmentStrip>::const_iterator run = begin; run != end; ++run) 
00547       if (run != skip){
00548          double x = run -> zpos;
00549          double y = run -> tpos;
00550          A += x;
00551          B += 1.0;
00552          C += y;
00553          D += x*x;
00554          E += x*y;
00555          F += y*y;
00556       }
00557    
00558    double det = B*D - A*A; //determinant of error matrix
00559    if(fabs(det) < 0.000001){
00560       MSG("Align", Msg::kWarning) << "Linear fit failed!" << endl;
00561       return -100.0;
00562    }
00563    
00564    // The linear fit: y = ax + b
00565    double a  = (E*B-C*A)/det;
00566    double b  = (D*C-E*A)/det;
00567 
00568    double skipped_x = skip -> zpos;
00569    double skipped_y = skip -> tpos;
00570    double predict   = a*skipped_x + b;       
00571     
00572    MSG("Align", Msg::kVerbose) << "FitTrackLessOne Done!" << endl;
00573    return (predict - skipped_y);
00574     
00575 }

bool MakeAlignmentModule::GetTrackQuality ( const NtpAlignmentRecord ntprec  )  [private]

Definition at line 265 of file MakeAlignmentModule.cxx.

References fMaxSigmaOfTPosCut, fMaxTrackChargeCut, fMinCosZCut, fMinTrackChargeCut, fNFailedChargeRatioCut, fNFailedCosZCut, fNFailedSigmaTPosCut, fNFailedTrackChargeCut, fTrackChargeRatioCut, NtpAlignmentRecord::hcosz, NtpAlignmentRecord::ucharge, NtpAlignmentRecord::usigmaoftpos, NtpAlignmentRecord::vcharge, and NtpAlignmentRecord::vsigmaoftpos.

Referenced by Ana().

00266 {
00267    //Check that: 1) Ratio of track charge to total charge in the current 
00268    //            record is greater than fTrackChargeRatioCut
00269    //            2) Uncertainty in tpos of a fit is less that fSigmaOfTPosCut
00270    //            3) Charge of 2d tracks is less that fTrackChargeCut
00271 
00272    //Cut on 2d track charge
00273    if(ntprec->vcharge > fMaxTrackChargeCut || ntprec->vcharge < fMinTrackChargeCut ||
00274       ntprec->ucharge > fMaxTrackChargeCut || ntprec->ucharge < fMinTrackChargeCut)
00275    {
00276       fNFailedTrackChargeCut++;
00277       return false;
00278    }
00279 
00280    //Cut in tpos uncertainty from linear fit to a track
00281    if(ntprec->vsigmaoftpos > fMaxSigmaOfTPosCut || ntprec->usigmaoftpos > fMaxSigmaOfTPosCut)
00282    {
00283       fNFailedSigmaTPosCut++;
00284       return false;
00285    }
00286 
00287    //Cut on 3d track Hough cos with horizontal z axis
00288    if(fabs(ntprec->hcosz) < fMinCosZCut)
00289    {
00290       fNFailedCosZCut++;
00291       return false;
00292    }
00293 
00294    const double allcharge = ntprec -> vcharge + ntprec -> ucharge
00295       + ntprec -> vcandcharge + ntprec -> ucandcharge;
00296 
00297    if(allcharge < 1.0)
00298       return false;
00299    
00300    Double_t ratio = (ntprec -> vcharge + ntprec -> ucharge)/allcharge;
00301    
00302    if(ratio < fTrackChargeRatioCut)
00303    {
00304       fNFailedChargeRatioCut++;
00305       return false;
00306    }   
00307 
00308    return true;
00309 }

void MakeAlignmentModule::PrintAlignmentStrip ( const AlignmentStrip astrip  )  [private]

Definition at line 677 of file MakeAlignmentModule.cxx.

References AlignmentStrip::begtime, AlignmentStrip::charge, Msg::kVerbose, MSG, AlignmentStrip::ndigit, AlignmentStrip::plexseid, and AlignmentStrip::residual.

00678 {   
00679    //Format msg service so that time and charge can be properly deisplayed
00680    MsgFormat ffmt("%10.9f");
00681    MsgFormat ffrt("%5.4f");
00682    MsgFormat fimt("%5d");
00683    
00684    MSG("Align", Msg::kVerbose) << PlexStripEndId(astrip.plexseid)
00685                                << " charge = " << fimt(astrip.charge)
00686                                << " begtime = " << ffmt(astrip.begtime)
00687                                << " ndigit = " << astrip.ndigit
00688                                << " residual = " << ffrt(astrip.residual) << endl;
00689 }

void MakeAlignmentModule::PrintJobStatistics (  )  [private]

Definition at line 625 of file MakeAlignmentModule.cxx.

References fApplyCuts, fFailedCut, fMissedUPlaneChargeSigma, fMissedUPlaneMeanCharge, fMissedVPlaneChargeSigma, fMissedVPlaneMeanCharge, fNFailedChargeRatioCut, fNFailedCosZCut, fNFailedCutMaxUStripCharge, fNFailedCutMaxVStripCharge, fNFailedFit, fNFailedRead, fNFailedSigmaTPosCut, fNFailedStripChargeCut, fNFailedTrackChargeCut, fNHitsOutsideStrip, fNMissedUPlane, fNMissedVPlane, fNPassedRecords, fNRecords, fTimer, fTotalUPlaneHits, fTotalVPlaneHits, Msg::kInfo, MSG, and size.

Referenced by EndJob().

00626 {
00627    MSG("Align", Msg::kInfo) << "MakeAlignmentModule::EndJob()"<< endl << endl;    
00628 
00629    MSG("Align", Msg::kInfo) << "Cpu time = " << fTimer.CpuTime() <<endl;
00630    MSG("Align", Msg::kInfo) << "Real time = " << fTimer.RealTime() <<endl;
00631    MSG("Align", Msg::kInfo) << "fNPassedRecords  = " << fNPassedRecords << endl;
00632    MSG("Align", Msg::kInfo) << "fNRecords  = " << fNRecords << endl;
00633    MSG("Align", Msg::kInfo) << "fFailedCut = " << fFailedCut << endl;
00634    MSG("Align", Msg::kInfo) << "fNFailedFit = " << fNFailedFit << endl;
00635    MSG("Align", Msg::kInfo) << "fNFailedRead = " << fNFailedRead << endl;
00636    MSG("Align", Msg::kInfo) << "fNMissedVPlane = " << fNMissedVPlane << endl;
00637    MSG("Align", Msg::kInfo) << "fNMissedUPlane = " << fNMissedUPlane << endl;
00638    MSG("Align", Msg::kInfo) << "fTotalVPlaneHits = " << fTotalVPlaneHits << endl;
00639    MSG("Align", Msg::kInfo) << "fTotalUPlaneHits = " << fTotalUPlaneHits << endl;
00640    MSG("Align", Msg::kInfo) << "fNHitsOutsideStrip = "      << fNHitsOutsideStrip << endl;
00641    if(fApplyCuts)
00642    {
00643       MSG("Align", Msg::kInfo) << "fNFailedCutMaxVStripCharge = " << fNFailedCutMaxVStripCharge <<endl;
00644       MSG("Align", Msg::kInfo) << "fNFailedCutMaxUStripCharge = " << fNFailedCutMaxUStripCharge <<endl;
00645       MSG("Align", Msg::kInfo) << "fNFailedTrackChargeCut  = " << fNFailedTrackChargeCut << endl;
00646       MSG("Align", Msg::kInfo) << "fNFailedCosZCut  = "        << fNFailedCosZCut << endl;
00647       MSG("Align", Msg::kInfo) << "fNFailedSigmaTPosCut  = "   << fNFailedSigmaTPosCut << endl;
00648       MSG("Align", Msg::kInfo) << "fNFailedChargeRatioCut  = " << fNFailedChargeRatioCut << endl;
00649       MSG("Align", Msg::kInfo) << "fNFailedStripChargeCut  = " << fNFailedStripChargeCut << endl;
00650    }
00651 
00652    MSG("Align", Msg::kInfo) << endl;
00653    
00654    if(fNMissedVPlane > 1){
00655       Double_t size = fNMissedVPlane;
00656       fMissedVPlaneMeanCharge = fMissedVPlaneMeanCharge/size;
00657       fMissedVPlaneChargeSigma = pow(fMissedVPlaneChargeSigma/size -
00658                                      fMissedVPlaneMeanCharge*fMissedVPlaneMeanCharge, 0.5);
00659       MSG("Align", Msg::kInfo) << "fMissedVPlaneMeanCharge = " << fMissedVPlaneMeanCharge
00660                                << " +/- " << fMissedVPlaneChargeSigma <<endl;
00661    }
00662    
00663    if(fNMissedUPlane > 1){
00664       Double_t size = fNMissedUPlane;
00665       fMissedUPlaneMeanCharge = fMissedUPlaneMeanCharge/size;
00666       fMissedUPlaneChargeSigma = pow(fMissedUPlaneChargeSigma/size -
00667                                      fMissedUPlaneMeanCharge*fMissedUPlaneMeanCharge, 0.5);
00668       MSG("Align", Msg::kInfo) << "fMissedUPlaneMeanCharge = " << fMissedUPlaneMeanCharge
00669                                << " +/- " << fMissedUPlaneChargeSigma <<endl;
00670    }     
00671 
00672     MSG("Align", Msg::kInfo) << endl;
00673 }

void MakeAlignmentModule::ProcessRecord ( const NtpAlignmentRecord ntprec  )  [private]

Definition at line 431 of file MakeAlignmentModule.cxx.

References fAlgorithm, fHistogram, fTrackUStrip, and fTrackVStrip.

Referenced by Ana().

00432 {
00433    for(vector<AlignmentStrip>::const_iterator vit = fTrackVStrip.begin(); 
00434        vit != fTrackVStrip.end(); ++vit)
00435    {
00436       const AlignmentStrip &astrip = *vit;
00437       fAlgorithm -> Fill(astrip);
00438       fHistogram -> Fill(astrip, ntprec);
00439    }
00440 
00441    for(vector<AlignmentStrip>::const_iterator uit = fTrackUStrip.begin(); 
00442        uit != fTrackUStrip.end(); ++uit)
00443    {
00444       const AlignmentStrip &astrip = *uit;
00445       fAlgorithm -> Fill(astrip);
00446       fHistogram -> Fill(astrip, ntprec);
00447    }
00448 
00449 }

bool MakeAlignmentModule::ReadRecord ( const NtpAlignmentRecord ntprec  )  [private]

Definition at line 313 of file MakeAlignmentModule.cxx.

References NtpAlignmentRecord::candustrip, NtpAlignmentRecord::candvstrip, AlignmentStrip::charge, AlignmentStrip::charge_pc, ConvertToLocal(), fAlgorithm, fApplyCuts, fCandUStrip, fCandVStrip, fMaxTrackStripChargeCut, fNFailedCutMaxUStripCharge, fNFailedCutMaxVStripCharge, fNFailedStripChargeCut, fTotalUPlaneHits, fTotalVPlaneHits, fTrackUStrip, fTrackVStrip, fValidityContext, UgliStripHandle::GetLPosRelMdl(), PlexPlaneId::GetPlane(), UgliStripHandle::GetScintPlnHandle(), PlexStripEndId::GetStrip(), UgliGeomHandle::GetStripHandle(), UgliStripHandle::GetTPos(), UgliStripHandle::GetTPosRelMdl(), UgliPlnHandle::GetZ0(), AlignmentStrip::ghitpos, AlignmentStrip::lposrelmdl, AlignmentStrip::plane, AlignmentStrip::plexseid, AlignmentStrip::strip, AlignmentStrip::tpos, AlignmentStrip::tposrelmdl, NtpAlignmentRecord::trackustrip, NtpAlignmentRecord::trackvstrip, and AlignmentStrip::zpos.

Referenced by Ana().

00314 {
00315    fTrackVStrip.clear();
00316    fTrackUStrip.clear();
00317    fCandVStrip.clear();
00318    fCandUStrip.clear();
00319 
00320    UgliGeomHandle ugh(fValidityContext);
00321 
00322    for(unsigned int i = 0; i < ntprec -> ntrackvstrip; ++i)
00323    {
00324       NtpAlignTrackStrip* strip = dynamic_cast<NtpAlignTrackStrip*>(ntprec->trackvstrip->At(i));
00325       assert(strip);
00326       
00327       AlignmentStrip astrip(strip);
00328       if(fApplyCuts && astrip.charge > fMaxTrackStripChargeCut){
00329          fNFailedCutMaxVStripCharge++;
00330          fNFailedStripChargeCut++;
00331          return false;
00332       }
00333       
00334       PlexStripEndId plexid(astrip.plexseid);
00335       UgliStripHandle ush = ugh.GetStripHandle(plexid);
00336 
00337       astrip.plane = plexid.GetPlane();
00338       astrip.strip = plexid.GetStrip();
00339       astrip.tpos = ush.GetTPos();
00340       astrip.zpos = ush.GetScintPlnHandle().GetZ0();
00341       astrip.tposrelmdl = ush.GetTPosRelMdl();
00342       astrip.lposrelmdl = ush.GetLPosRelMdl();
00343       astrip.charge_pc  = astrip.charge * ntprec -> hcosz;
00344 
00345       //use fit results in opposite view to get longitudinal position
00346       astrip.ghitpos = (ntprec -> ufita)*astrip.zpos + ntprec -> ufitb;      
00347 
00348       ConvertToLocal(astrip, plexid, ugh, ush);
00349       fTrackVStrip.push_back(astrip);
00350    }
00351 
00352 
00353    for(unsigned int i = 0; i < ntprec -> ntrackustrip; ++i)
00354    {
00355       NtpAlignTrackStrip* strip = dynamic_cast<NtpAlignTrackStrip*>(ntprec->trackustrip->At(i));
00356       assert(strip);
00357       
00358       AlignmentStrip astrip(strip);      
00359       if(fApplyCuts && astrip.charge > fMaxTrackStripChargeCut){
00360          fNFailedCutMaxUStripCharge++;
00361          fNFailedStripChargeCut++;
00362          return false;
00363       }
00364 
00365       PlexStripEndId plexid(astrip.plexseid);
00366       UgliStripHandle ush = ugh.GetStripHandle(plexid);
00367 
00368       astrip.plane = plexid.GetPlane();
00369       astrip.strip = plexid.GetStrip(); 
00370       astrip.tpos = ush.GetTPos();
00371       astrip.zpos = ush.GetScintPlnHandle().GetZ0();
00372       astrip.tposrelmdl = ush.GetTPosRelMdl();
00373       astrip.lposrelmdl = ush.GetLPosRelMdl();
00374       astrip.charge_pc  = astrip.charge * ntprec -> hcosz;
00375 
00376       //use fit results in opposite view to get longitudinal position
00377       astrip.ghitpos = (ntprec -> vfita)*astrip.zpos + ntprec -> vfitb;
00378       
00379       ConvertToLocal(astrip, plexid, ugh, ush);
00380       fTrackUStrip.push_back(astrip);
00381    }
00382 
00383 
00384    for(unsigned int i = 0; i < ntprec -> ncandvstrip; ++i)
00385    {
00386       NtpAlignCandStrip* strip = dynamic_cast<NtpAlignCandStrip*>(ntprec->candvstrip->At(i));
00387       assert(strip);
00388       
00389       AlignmentStrip astrip(strip);
00390       PlexStripEndId plexid(astrip.plexseid);
00391       UgliStripHandle ush = ugh.GetStripHandle(plexid);
00392 
00393       astrip.tpos = ush.GetTPos();
00394       astrip.zpos = ush.GetScintPlnHandle().GetZ0();
00395       astrip.tposrelmdl = ush.GetTPosRelMdl();
00396       astrip.lposrelmdl = ush.GetLPosRelMdl();
00397       astrip.plane = plexid.GetPlane();
00398       astrip.strip = plexid.GetStrip();
00399       fCandVStrip.push_back(astrip);
00400 
00401       fAlgorithm -> FillCandStrip(astrip);
00402    }
00403 
00404    for(unsigned int i = 0; i < ntprec -> ncandustrip; ++i)
00405    {
00406       NtpAlignCandStrip* strip = dynamic_cast<NtpAlignCandStrip*>(ntprec->candustrip->At(i));
00407       assert(strip);
00408 
00409       AlignmentStrip astrip(strip);
00410       PlexStripEndId plexid(astrip.plexseid);
00411       UgliStripHandle ush = ugh.GetStripHandle(plexid);
00412 
00413       astrip.tpos = ush.GetTPos();
00414       astrip.zpos = ush.GetScintPlnHandle().GetZ0();
00415       astrip.tposrelmdl = ush.GetTPosRelMdl();
00416       astrip.lposrelmdl = ush.GetLPosRelMdl();
00417       astrip.plane = plexid.GetPlane();
00418       astrip.strip = plexid.GetStrip();
00419       fCandUStrip.push_back(astrip);
00420 
00421       fAlgorithm -> FillCandStrip(astrip);
00422    }
00423 
00424    fTotalVPlaneHits += fTrackVStrip.size();
00425    fTotalUPlaneHits += fTrackUStrip.size();
00426    return true;
00427 }

bool MakeAlignmentModule::RecalculateResiduals (  )  [private]

Definition at line 452 of file MakeAlignmentModule.cxx.

References FitTrackLessOne(), fTrackUStrip, fTrackVStrip, fValidityContext, UgliGeomHandle::GetStripHandle(), UgliStripHandle::GlobalPos(), Msg::kError, AlignmentStrip::lhitpos, MSG, AlignmentStrip::plexseid, AlignmentStrip::residual, AlignmentStrip::tpos, UgliGeomHandle::xyz2uvz(), and AlignmentStrip::zpos.

Referenced by Ana().

00453 {
00454    
00455    UgliGeomHandle ugh(fValidityContext);
00456 
00457    for(unsigned int i = 0; i < fTrackVStrip.size(); ++i){
00458       AlignmentStrip &astrip = fTrackVStrip[i];
00459       PlexStripEndId plexid(astrip.plexseid);
00460       UgliStripHandle ush = ugh.GetStripHandle(plexid);    
00461       TVector3 local(astrip.lhitpos, 0, 0);
00462       TVector3 globalxyz = ush.GlobalPos(astrip.lhitpos);
00463       TVector3 globaluvz = ugh.xyz2uvz(globalxyz);
00464       double tpos = globaluvz.y();
00465       double zpos = globaluvz.z();
00466       if(fabs(astrip.tpos-tpos) > 0.001){
00467          MsgFormat f("%10.9f");
00468          MSG("Align",Msg::kError) << "global tpos - local tpos = " << f(astrip.tpos-tpos) <<endl;
00469       }
00470       if(fabs(astrip.zpos-zpos) > 0.001){
00471          MsgFormat f("%10.9f");
00472          MSG("Align",Msg::kError) << "zpos before - zpos after = " << f(astrip.zpos-zpos) <<endl;
00473       }
00474       astrip.tpos = globaluvz.y();
00475    }
00476    
00477    for(unsigned int i = 0; i < fTrackUStrip.size(); ++i){
00478       AlignmentStrip &astrip = fTrackUStrip[i];
00479       PlexStripEndId plexid(astrip.plexseid);
00480       UgliStripHandle ush = ugh.GetStripHandle(plexid);      
00481       TVector3 local(astrip.lhitpos, 0, 0);
00482       TVector3 globalxyz = ush.GlobalPos(astrip.lhitpos);
00483       TVector3 globaluvz = ugh.xyz2uvz(globalxyz);
00484       double tpos = globaluvz.x();
00485       double zpos = globaluvz.z();
00486       if(fabs(astrip.tpos-tpos) > 0.001){
00487          MsgFormat f("%10.9f");
00488          MSG("Align",Msg::kError) << "global tpos - local tpos = " << f(astrip.tpos-tpos) <<endl;
00489       }
00490       if(fabs(astrip.zpos-zpos) > 0.001){
00491          MsgFormat f("%10.9f");
00492          MSG("Align",Msg::kError) << "zpos before - zpos after = " << f(astrip.zpos-zpos) <<endl;
00493       }
00494 
00495       astrip.tpos = globaluvz.x();
00496    }
00497 
00498    for(vector<AlignmentStrip>::iterator vit = fTrackVStrip.begin(); 
00499        vit != fTrackVStrip.end(); ++vit){
00500       double residual = FitTrackLessOne(fTrackVStrip.begin(),   fTrackVStrip.end(), vit);
00501       if(fabs(residual) > 1.0)
00502          return false;
00503       AlignmentStrip &astrip = *vit;
00504       if(fabs(astrip.residual-residual) > 0.00001){
00505          MsgFormat ffrt("%7.6f");
00506          MSG("Align", Msg::kError) << "V residual diff after tpos correction for " 
00507                                    << PlexStripEndId(astrip.plexseid) << " = "
00508                                    << ffrt(residual - astrip.residual) << endl;
00509       }
00510       astrip.residual = residual;
00511    }
00512    
00513    for(vector<AlignmentStrip>::iterator uit = fTrackUStrip.begin(); 
00514        uit != fTrackUStrip.end(); ++uit){
00515       double residual = FitTrackLessOne(fTrackUStrip.begin(),   fTrackUStrip.end(), uit);
00516       if(fabs(residual) > 1.0)
00517          return false;
00518       AlignmentStrip &astrip = *uit;
00519       if(fabs(astrip.residual-residual) > 0.00001){
00520          MsgFormat ffrt("%7.6f");
00521          MSG("Align", Msg::kError) << "U residual diff after tpos correction for " 
00522                                    << PlexStripEndId(astrip.plexseid) << " = "
00523                                    << ffrt(residual - astrip.residual) << endl;
00524       }
00525 
00526       astrip.residual = residual;
00527    }
00528    return true;
00529 }


Member Data Documentation

Definition at line 85 of file MakeAlignmentModule.h.

Referenced by Ana(), EndJob(), ProcessRecord(), and ReadRecord().

Definition at line 117 of file MakeAlignmentModule.h.

Referenced by Ana(), BeginJob(), PrintJobStatistics(), and ReadRecord().

Definition at line 104 of file MakeAlignmentModule.h.

Referenced by Ana(), and ReadRecord().

Definition at line 103 of file MakeAlignmentModule.h.

Referenced by Ana(), and ReadRecord().

Definition at line 96 of file MakeAlignmentModule.h.

Referenced by Ana().

Definition at line 97 of file MakeAlignmentModule.h.

Referenced by Ana().

unsigned int MakeAlignmentModule::fFailedCut [private]

Definition at line 130 of file MakeAlignmentModule.h.

Referenced by Ana(), and PrintJobStatistics().

Definition at line 86 of file MakeAlignmentModule.h.

Referenced by Ana(), EndJob(), and ProcessRecord().

Definition at line 93 of file MakeAlignmentModule.h.

Referenced by BeginJob().

const Double_t MakeAlignmentModule::fMaxSigmaOfTPosCut [private]

Definition at line 108 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality().

const Double_t MakeAlignmentModule::fMaxTrackChargeCut [private]

Definition at line 106 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality().

Definition at line 112 of file MakeAlignmentModule.h.

Referenced by ReadRecord().

const Double_t MakeAlignmentModule::fMinCosZCut [private]

Definition at line 110 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality().

const Double_t MakeAlignmentModule::fMinTrackChargeCut [private]

Definition at line 107 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality().

Definition at line 111 of file MakeAlignmentModule.h.

Definition at line 138 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

Definition at line 136 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

Definition at line 137 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

Definition at line 135 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

Definition at line 89 of file MakeAlignmentModule.h.

Definition at line 143 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality(), and PrintJobStatistics().

unsigned int MakeAlignmentModule::fNFailedCosZCut [private]

Definition at line 142 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality(), and PrintJobStatistics().

Definition at line 133 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics(), and ReadRecord().

Definition at line 132 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics(), and ReadRecord().

unsigned int MakeAlignmentModule::fNFailedFit [private]

Definition at line 121 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

unsigned int MakeAlignmentModule::fNFailedRead [private]

Definition at line 125 of file MakeAlignmentModule.h.

Referenced by Ana(), and PrintJobStatistics().

Definition at line 144 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality(), and PrintJobStatistics().

Definition at line 141 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics(), and ReadRecord().

Definition at line 140 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality(), and PrintJobStatistics().

Definition at line 131 of file MakeAlignmentModule.h.

Referenced by ConvertToLocal(), and PrintJobStatistics().

unsigned int MakeAlignmentModule::fNMissedUPlane [private]

Definition at line 127 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

unsigned int MakeAlignmentModule::fNMissedVPlane [private]

Definition at line 126 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics().

unsigned int MakeAlignmentModule::fNPassedRecords [private]

Definition at line 123 of file MakeAlignmentModule.h.

Referenced by Ana(), and PrintJobStatistics().

Definition at line 98 of file MakeAlignmentModule.h.

Referenced by Ana().

unsigned int MakeAlignmentModule::fNRecords [private]

Definition at line 122 of file MakeAlignmentModule.h.

Referenced by Ana(), and PrintJobStatistics().

Definition at line 99 of file MakeAlignmentModule.h.

Referenced by Ana().

unsigned int MakeAlignmentModule::fNSubsetRecords [private]

Definition at line 124 of file MakeAlignmentModule.h.

Referenced by Ana(), and EndJob().

Definition at line 116 of file MakeAlignmentModule.h.

Referenced by Ana(), and BeginJob().

Definition at line 91 of file MakeAlignmentModule.h.

Referenced by Ana(), BeginJob(), and EndJob().

Definition at line 87 of file MakeAlignmentModule.h.

Referenced by Ana(), and EndJob().

Definition at line 114 of file MakeAlignmentModule.h.

Referenced by Ana().

const unsigned int MakeAlignmentModule::fStatisticalSubsetSize [private]

Definition at line 119 of file MakeAlignmentModule.h.

TStopwatch MakeAlignmentModule::fTimer [private]

Definition at line 146 of file MakeAlignmentModule.h.

Referenced by BeginJob(), and PrintJobStatistics().

Definition at line 147 of file MakeAlignmentModule.h.

Referenced by Ana(), and BeginJob().

unsigned int MakeAlignmentModule::fTotalUPlaneHits [private]

Definition at line 129 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics(), and ReadRecord().

unsigned int MakeAlignmentModule::fTotalVPlaneHits [private]

Definition at line 128 of file MakeAlignmentModule.h.

Referenced by PrintJobStatistics(), and ReadRecord().

Definition at line 109 of file MakeAlignmentModule.h.

Referenced by GetTrackQuality().

Definition at line 102 of file MakeAlignmentModule.h.

Referenced by Ana(), ProcessRecord(), ReadRecord(), and RecalculateResiduals().

Definition at line 101 of file MakeAlignmentModule.h.

Referenced by Ana(), ProcessRecord(), ReadRecord(), and RecalculateResiduals().

Definition at line 94 of file MakeAlignmentModule.h.

Referenced by Ana(), EndJob(), ReadRecord(), and RecalculateResiduals().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1