#include <DetectorAlignment.h>
|
|
Definition at line 50 of file DetectorAlignment.cxx. References MSG. 00051 :f2dTrackCharge(0.0), 00052 fCandVCharge(0.0), 00053 fCandUCharge(0.0), 00054 f2dTrackResidualRMS(0.0), 00055 fUncertaintyInTPosofStrips(0.0), 00056 fFita(0.0), 00057 fFitb(0.0), 00058 fSigmaOfa(0.0), 00059 fSigmaOfb(0.0), 00060 fCovab(0.0), 00061 fDeltaT(0.0) 00062 { 00063 MSG("Align", Msg::kInfo) << "Constructor DetectorAlignment()" << endl; 00064 }
|
|
|
Definition at line 487 of file DetectorAlignment.cxx. References fCandUStrip, fCandVStrip, fTrackTimes, fTrackUStrip, fTrackVStrip, and MSG. 00488 {
00489 MSG("Align", Msg::kInfo) << "Destructor ~DetectorAlignment()" << endl;
00490
00491 fTrackVStrip.clear();
00492 fTrackUStrip.clear();
00493 fCandVStrip.clear();
00494 fCandUStrip.clear();
00495 fTrackTimes.clear();
00496
00497 MSG("Align", Msg::kInfo) << "Destructor ~DetectorAlignment()... Done" << endl;
00498 }
|
|
||||||||||||
|
Definition at line 368 of file DetectorAlignment.cxx. References F, fCovab, fFita, fFitb, fSigmaOfa, fSigmaOfb, and MSG. Referenced by RunAlignment(). 00370 {
00371 MSG("Align", Msg::kVerbose) << "FitTrack..." << endl;
00372
00373 fFita = 0.0;
00374 fFitb = 0.0;
00375 fSigmaOfa = 0.0;
00376 fSigmaOfb = 0.0;
00377 fCovab = 0.0;
00378
00379 // Linear regression parameters least squares method. See for eg. Num Rec Ch 15
00380 // Fit y = ax + b, as in W. R. Leo, Techniques for ..., Section 4.7.2
00381 // x is strip's Z position, y is strip's transverse position (U or V).
00382 double A = 0.0, B=0.0, C=0.0, D=0.0, E=0.0, F=0.0, S=0.0;
00383
00384 for (vector<AlignmentStrip>::const_iterator run = begin; run != end; ++run){
00385 double x = run -> zpos;
00386 double y = run -> tpos;
00387 A += x;
00388 B += 1.0;
00389 C += y;
00390 D += x*x;
00391 E += x*y;
00392 F += y*y;
00393 }
00394
00395 double det = B*D - A*A; //determinant of error matrix
00396 if(det < 0.000001){
00397 MSG("Align", Msg::kError) << "Linear fit failed!" << endl;
00398 return -100.0;
00399 }
00400
00401 // The linear fit: y = ax + b
00402 double a = (E*B-C*A)/det;
00403 double b = (D*C-E*A)/det;
00404 fFita = a;
00405 fFitb = b;
00406 fSigmaOfa = pow(B/det, 0.5);
00407 fSigmaOfb = pow(D/det, 0.5);
00408 fCovab = -A/det;
00409
00410 double npoints = 0.0;
00411 for (vector<AlignmentStrip>::const_iterator run = begin; run != end; ++run){
00412 double x = run -> zpos;
00413 double y = run -> tpos;
00414 S += (y-a*x-b)*(y-a*x-b);
00415 npoints += 1.0;
00416 }
00417
00418 if( (npoints-2.0) < 0.9){
00419 MSG("Align", Msg::kError) << "Linear fit failed!" << endl;
00420 return -100.0;
00421 }
00422
00423 //error in fitted y and chi2 are mutualy exclusive
00424 S = S/(npoints-2.0);
00425
00426 MSG("Align", Msg::kVerbose) << "FitTrack Done!" << endl;
00427 return pow(S, 0.5); //return estimated error in y (transverse position)
00428 }
|
|
||||||||||||||||
|
Definition at line 325 of file DetectorAlignment.cxx. Referenced by MakeAlignmentTrack(). 00328 {
00329
00330 MSG("Align", Msg::kVerbose) << "FitTrackLessOne..." << endl;
00331 // Linear regression parameters least squares method. See for eg. Num Rec Ch 15
00332 // Fit y = ax + b, as in W. R. Leo, Techniques for ..., Section 4.7.2
00333 // x is strip's Z position, y is strip's transverse position (U or V).
00334 double A=0.0, B=0.0, C=0.0, D=0.0, E=0.0, F=0.0;
00335
00336 for (vector<AlignmentStrip>::const_iterator run = begin; run != end; ++run)
00337 if (run != skip){
00338 double x = run -> zpos;
00339 double y = run -> tpos;
00340 A += x;
00341 B += 1.0;
00342 C += y;
00343 D += x*x;
00344 E += x*y;
00345 F += y*y;
00346 }
00347
00348 double det = B*D - A*A; //determinant of error matrix
00349 if(det < 0.000001){
00350 MSG("Align", Msg::kError) << "Linear fit failed!" << endl;
00351 return -100.0;
00352 }
00353
00354 // The linear fit: y = ax + b
00355 double a = (E*B-C*A)/det;
00356 double b = (D*C-E*A)/det;
00357
00358 double skipped_x = skip -> zpos;
00359 double skipped_y = skip -> tpos;
00360 double predict = a*skipped_x + b;
00361
00362 MSG("Align", Msg::kVerbose) << "FitTrackLessOne Done!" << endl;
00363 return (predict - skipped_y);
00364
00365 }
|
|
|
Definition at line 237 of file DetectorAlignment.cxx. References AlignmentStrip::charge, fCandUCharge, fCandUStrip, fCandVCharge, fCandVStrip, CandStripHandle::GetBegTime(), CandStripHandle::GetCharge(), CandHandle::GetDaughterIterator(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStripEndId(), MSG, AlignmentStrip::plexseid, StripBelongsToUTrack(), and StripBelongsToVTrack(). Referenced by RunAlignment(). 00238 {
00239 MSG("Align", Msg::kVerbose) << "Separating CandStripHandles from track strips" <<endl
00240 << "cslh->GetNDaughters() = "<< cslh -> GetNDaughters()
00241 << ", cslh->GetTitle() = " << cslh -> GetTitle() <<endl;
00242
00243 MsgFormat ffmt("%10.9f");
00244 //store ony candidate handles that are not part of CandTrackSRHandle
00245 TIter sitr(cslh->GetDaughterIterator());
00246 while( CandStripHandle* csh = dynamic_cast<CandStripHandle*>(sitr()) ){
00247 MSG("Align", Msg::kVerbose) << "CandStrip: " << csh->GetStripEndId()
00248 << " time: " << ffmt(csh->GetBegTime())
00249 << " charge = " << csh->GetCharge(CalDigitType::kNone) <<endl;
00250 AlignmentStrip astrip(csh);
00251 if(csh->GetPlaneView() == PlaneView::kV){
00252 bool result = StripBelongsToVTrack(astrip);
00253 if(!result){
00254 fCandVStrip.push_back(astrip);
00255 fCandVCharge += astrip.charge;
00256 MSG("Align", Msg::kVerbose) <<"Adding candstrip " <<PlexStripEndId(astrip.plexseid)<<endl;
00257 }
00258 continue;
00259 }
00260
00261 if(csh->GetPlaneView() == PlaneView::kU){
00262 bool result = StripBelongsToUTrack(astrip);
00263 if(!result){
00264 fCandUStrip.push_back(astrip);
00265 fCandUCharge += astrip.charge;
00266 MSG("Align", Msg::kVerbose) <<"Adding candstrip " <<PlexStripEndId(astrip.plexseid)<<endl;
00267 }
00268 continue;
00269 }
00270 MSG("Align", Msg::kError) << "Strip is not in V or U view!!!"<<endl;
00271 }
00272 }
|
|
|
Definition at line 212 of file DetectorAlignment.cxx. References fTrackUStrip, fTrackVStrip, CandHandle::GetDaughterIterator(), CandHandle::GetNDaughters(), CandHandle::GetTitle(), MSG, and AlignmentStrip::plexseid. Referenced by RunAlignment(). 00213 {
00214 MSG("Align", Msg::kVerbose) << "Getting CandStripHandles from CandTrack: "
00215 << "tkh->GetNDaughters() = "
00216 << tkh->GetNDaughters()
00217 << ", tkh->GetTitle() = " << tkh->GetTitle()<<endl;
00218
00219 int nstrip = 0;
00220 TIter sitr(tkh->GetDaughterIterator());
00221 while( CandStripHandle* csh = dynamic_cast<CandStripHandle*>(sitr()) ){
00222 AlignmentStrip astrip(csh);
00223 nstrip++;
00224 MSG("Align", Msg::kVerbose) << "Adding " <<PlexStripEndId(astrip.plexseid)
00225 <<" to track record" <<endl;
00226 if( csh -> GetPlaneView() == PlaneView::kV)
00227 fTrackVStrip.push_back(astrip);
00228 else
00229 fTrackUStrip.push_back(astrip);
00230 }
00231
00232 MSG("Align", Msg::kVerbose) <<"Added "<<nstrip<<" track strips." << endl;
00233 return;
00234 }
|
|
||||||||||||
|
Definition at line 275 of file DetectorAlignment.cxx. References f2dTrackCharge, f2dTrackResidualRMS, fDeltaT, FitTrackLessOne(), fTrackTimes, and MSG. Referenced by RunAlignment(). 00277 {
00278 MSG("Align", Msg::kVerbose) << "MakeAlignmentTrack()..."<<endl;
00279
00280 vector<AlignmentStrip>::iterator itr;
00281 double size = 0.0;
00282
00283 vector<Double_t> begtime;
00284 vector<Double_t> endtime;
00285
00286 //Filing vectors with data from 2d track
00287 for (itr = begin; itr != end; ++itr) {
00288 size += 1.0;
00289 double residual = FitTrackLessOne(begin, end, itr);
00290 double charge = itr -> charge;
00291 itr -> residual = residual; //store residual in AlignStrip
00292 f2dTrackResidualRMS += residual*residual; //calculating "rms" of a current track
00293
00294 begtime.push_back(itr -> begtime);
00295 endtime.push_back(itr -> endtime);
00296
00297 //add charge as we iterate along 2d track:
00298 if(charge > 0.0)
00299 f2dTrackCharge += itr->charge;
00300 else
00301 MSG("Align", Msg::kVerbose) <<PlexStripEndId(itr->plexseid)<<" charge = "<<charge<<endl;
00302
00303 MSG("Align", Msg::kVerbose) <<PlexStripEndId(itr->plexseid)<<" residual = "<<residual<<endl;
00304 }
00305
00306 //sorting begtime and endtime to get time time interval of 2d track
00307 if(begtime.size()>0 && endtime.size()>0){
00308 sort(begtime.begin(), begtime.end());
00309 sort(endtime.begin(), endtime.end());
00310 fDeltaT = endtime[endtime.size()-1] - begtime[0];
00311 fTrackTimes.push_back(endtime[endtime.size()-1]);
00312 fTrackTimes.push_back(begtime[0]);
00313 }
00314
00315 if(size > 0.0)
00316 f2dTrackResidualRMS = pow(f2dTrackResidualRMS/size, 0.5);
00317
00318 MSG("Align", Msg::kVerbose) << "MakeAlignmentTrack() DONE!" << endl;
00319 return;
00320 }
|
|
||||||||||||||||
|
Definition at line 66 of file DetectorAlignment.cxx. References f2dTrackCharge, f2dTrackResidualRMS, fCandUCharge, fCandUStrip, fCandVCharge, fCandVStrip, fCovab, fDeltaT, fFita, fFitb, FitTrack(), fSigmaOfa, fSigmaOfb, fTrackTimes, fTrackUStrip, fTrackVStrip, fUncertaintyInTPosofStrips, GetCandStrips(), CandHandle::GetNDaughters(), GetTrackStrips(), MakeAlignmentTrack(), and MSG. 00069 {
00070
00071 if( !tkh || !cslh || !ntpalignrec)
00072 return false;
00073
00074 //clear vectors that store AlignmentStrips and track's time inteval
00075 fTrackVStrip.clear();
00076 fTrackUStrip.clear();
00077 fCandVStrip.clear();
00078 fCandUStrip.clear();
00079 fTrackTimes.clear();
00080
00081 //reset global variables to zero
00082 f2dTrackCharge = 0.0;
00083 fCandVCharge = 0.0;
00084 fCandUCharge = 0.0;
00085 f2dTrackResidualRMS = 0.0;
00086 fFita = 0.0;
00087 fFitb = 0.0;
00088 fSigmaOfa = 0.0;
00089 fSigmaOfb = 0.0;
00090 fUncertaintyInTPosofStrips = 0.0;
00091 fCovab = 0.0;
00092 fDeltaT = 0.0;
00093
00094 //Save strip data from CandTrackSR to vector<AlignmentStrip>, one for each view
00095 GetTrackStrips(tkh);
00096
00097 //Save data from candidate strips to vector<AlignmentStrip>, one for each view
00098 //Ignore strips that belong to a track
00099 GetCandStrips(cslh);
00100
00101 //Get directional cosines for 3d track
00102 ntpalignrec -> hcosu = tkh -> GetHoughDirCosU();
00103 ntpalignrec -> hcosv = tkh -> GetHoughDirCosV();
00104 ntpalignrec -> hcosz = tkh -> GetHoughDirCosZ();
00105
00106 //Fit V view track with a straight line and save fit information
00107 vector<AlignmentStrip>::iterator begitr = fTrackVStrip.begin();
00108 vector<AlignmentStrip>::iterator enditr = fTrackVStrip.end();
00109 fUncertaintyInTPosofStrips = FitTrack(begitr, enditr);
00110
00111 //V view: calculate residuals, track charge and residual rms
00112 MakeAlignmentTrack(begitr, enditr);
00113
00114 //Fill ntuples record for V view track
00115 ntpalignrec -> vcharge = f2dTrackCharge;
00116 ntpalignrec -> vcandcharge = fCandVCharge;
00117 ntpalignrec -> vtrackrms = f2dTrackResidualRMS;
00118 ntpalignrec -> vfita = fFita;
00119 ntpalignrec -> vfitb = fFitb;
00120 ntpalignrec -> vsigmaofa = fSigmaOfa;
00121 ntpalignrec -> vsigmaofb = fSigmaOfb;
00122 ntpalignrec -> vsigmaoftpos = fUncertaintyInTPosofStrips;
00123 ntpalignrec -> vcovab = fCovab;
00124 ntpalignrec -> vdt = fDeltaT;
00125
00126
00127 //reset global variables to zero
00128 f2dTrackCharge = 0.0;
00129 f2dTrackResidualRMS = 0.0;
00130 fFita = 0.0;
00131 fFitb = 0.0;
00132 fSigmaOfa = 0.0;
00133 fSigmaOfb = 0.0;
00134 fUncertaintyInTPosofStrips = 0.0;
00135 fCovab = 0.0;
00136 fDeltaT = 0.0;
00137
00138 //Fit U view track with a straight line and save fit information
00139 begitr = fTrackUStrip.begin();
00140 enditr = fTrackUStrip.end();
00141 fUncertaintyInTPosofStrips = FitTrack(begitr, enditr);
00142
00143 //U view: calculate residuals, track charge and residual rms
00144 MakeAlignmentTrack(begitr, enditr);
00145
00146 //Fill ntuples record for U view track
00147 ntpalignrec -> ucharge = f2dTrackCharge;
00148 ntpalignrec -> ucandcharge = fCandUCharge;
00149 ntpalignrec -> utrackrms = f2dTrackResidualRMS;
00150 ntpalignrec -> ufita = fFita;
00151 ntpalignrec -> ufitb = fFitb;
00152 ntpalignrec -> usigmaofa = fSigmaOfa;
00153 ntpalignrec -> usigmaofb = fSigmaOfb;
00154 ntpalignrec -> usigmaoftpos = fUncertaintyInTPosofStrips;
00155 ntpalignrec -> ucovab = fCovab;
00156 ntpalignrec -> udt = fDeltaT;
00157
00158 //Fill TClonesArrays with candidate strips and track strips
00159 TClonesArray& trackvstrips = *(ntpalignrec -> trackvstrip);
00160 for(unsigned int i = 0; i < fTrackVStrip.size(); ++i){
00161 NtpAlignTrackStrip* ntpalign = new(trackvstrips[i])NtpAlignTrackStrip(fTrackVStrip[i]);
00162 if(!ntpalign)
00163 MSG("Align", Msg::kError) <<"Failed to fill TClonesArray!" << endl;
00164 }
00165
00166 TClonesArray& trackustrips = *(ntpalignrec -> trackustrip);
00167 for(unsigned int i = 0; i < fTrackUStrip.size(); ++i){
00168 NtpAlignTrackStrip* ntpalign = new(trackustrips[i])NtpAlignTrackStrip(fTrackUStrip[i]);
00169 if(!ntpalign)
00170 MSG("Align", Msg::kError) <<"Failed to fill TClonesArray!" << endl;
00171 }
00172
00173 TClonesArray& candvstrips = *(ntpalignrec -> candvstrip);
00174 for(unsigned int i = 0; i < fCandVStrip.size(); ++i){
00175 NtpAlignCandStrip* ntpalign = new(candvstrips[i])NtpAlignCandStrip(fCandVStrip[i]);
00176 if(!ntpalign)
00177 MSG("Align", Msg::kError) <<"Failed to fill TClonesArray!" << endl;
00178 }
00179
00180 TClonesArray& candustrips = *(ntpalignrec -> candustrip);
00181 for(unsigned int i = 0; i < fCandUStrip.size(); ++i){
00182 NtpAlignCandStrip* ntpalign = new(candustrips[i])NtpAlignCandStrip(fCandUStrip[i]);
00183 if(!ntpalign)
00184 MSG("Align", Msg::kError) <<"Failed to fill TClonesArray!" << endl;
00185 }
00186
00187 ntpalignrec -> nstrip = cslh->GetNDaughters();
00188 ntpalignrec -> ntrackvstrip = fTrackVStrip.size();
00189 ntpalignrec -> ntrackustrip = fTrackUStrip.size();
00190 ntpalignrec -> ncandvstrip = fCandVStrip.size();
00191 ntpalignrec -> ncandustrip = fCandUStrip.size();
00192
00193 sort(fTrackTimes.begin(), fTrackTimes.end());
00194 if(fTrackTimes.size() > 0)
00195 ntpalignrec -> dt = fTrackTimes[fTrackTimes.size()-1]-fTrackTimes[0];
00196 else
00197 ntpalignrec -> dt = 0.0;
00198
00199 Int_t diff = cslh->GetNDaughters()-(fTrackVStrip.size()+fTrackUStrip.size()
00200 +fCandVStrip.size()+fCandUStrip.size());
00201 if(diff != 0){
00202 MSG("Align", Msg::kDebug)<< "# of cand and track strips do not add up! "
00203 << "diff = " << diff << endl;
00204 return false;
00205 }
00206
00207 return true;
00208 }
|
|
|
Definition at line 459 of file DetectorAlignment.cxx. References AlignmentStrip::begtime, AlignmentStrip::charge, fTrackUStrip, MSG, and AlignmentStrip::plexseid. Referenced by GetCandStrips(). 00460 {
00461 //if there is a track strip such that: PlexStripEndIds are the same
00462 // beggining times are within 1ns of each other
00463 //then return true
00464 //
00465 //otherwise return false
00466
00467 for(unsigned int i = 0; i < fTrackUStrip.size(); ++i){
00468 if(fTrackUStrip[i].plexseid == astrip.plexseid){
00469 double diff = fabs(fTrackUStrip[i].begtime - astrip.begtime);
00470 if(diff < 0.000000002){
00471 MsgFormat ffmt("%10.9f");
00472 MsgFormat fi("%3d");
00473 MSG("Align", Msg::kVerbose) << "Removing "
00474 << PlexStripEndId(astrip.plexseid) << " U track strip #"<<fi(i)<<endl
00475 << " Charge = " << astrip.charge
00476 << " lhs t = " << ffmt(fTrackUStrip[i].begtime)
00477 << " rhs t = " << ffmt(astrip.begtime)
00478 << " diff = "<< ffmt(diff) <<endl;
00479 return true;
00480 }
00481 }
00482 }
00483 return false;
00484 }
|
|
|
Definition at line 431 of file DetectorAlignment.cxx. References AlignmentStrip::begtime, AlignmentStrip::charge, fTrackVStrip, MSG, and AlignmentStrip::plexseid. Referenced by GetCandStrips(). 00432 {
00433 //if there is a track strip such that: PlexStripEndIds are the same
00434 // beggining times are within 10ns of each other
00435 //then return true
00436 //
00437 //otherwise return false
00438
00439 for(unsigned int i = 0; i < fTrackVStrip.size(); ++i){
00440 if(fTrackVStrip[i].plexseid == astrip.plexseid){
00441 double diff = fabs(fTrackVStrip[i].begtime - astrip.begtime);
00442 if(diff < 0.000000002){
00443 MsgFormat ffmt("%10.9f");
00444 MsgFormat fi("%3d");
00445 MSG("Align", Msg::kVerbose) << "Removing "
00446 << PlexStripEndId(astrip.plexseid) << " V track strip #"<<fi(i) <<endl
00447 << " Charge = " << astrip.charge
00448 << " lhs t = " << ffmt(fTrackVStrip[i].begtime)
00449 << " rhs t = " << ffmt(astrip.begtime)
00450 << " diff = "<< ffmt(diff) <<endl;
00451
00452 return true;
00453 }
00454 }
00455 }
00456 return false;
00457 }
|
|
|
Definition at line 79 of file DetectorAlignment.h. Referenced by MakeAlignmentTrack(), and RunAlignment(). |
|
|
Definition at line 82 of file DetectorAlignment.h. Referenced by MakeAlignmentTrack(), and RunAlignment(). |
|
|
Definition at line 81 of file DetectorAlignment.h. Referenced by GetCandStrips(), and RunAlignment(). |
|
|
Definition at line 75 of file DetectorAlignment.h. Referenced by GetCandStrips(), RunAlignment(), and ~DetectorAlignment(). |
|
|
Definition at line 80 of file DetectorAlignment.h. Referenced by GetCandStrips(), and RunAlignment(). |
|
|
Definition at line 74 of file DetectorAlignment.h. Referenced by GetCandStrips(), RunAlignment(), and ~DetectorAlignment(). |
|
|
Definition at line 88 of file DetectorAlignment.h. Referenced by FitTrack(), and RunAlignment(). |
|
|
Definition at line 89 of file DetectorAlignment.h. Referenced by MakeAlignmentTrack(), and RunAlignment(). |
|
|
Definition at line 84 of file DetectorAlignment.h. Referenced by FitTrack(), and RunAlignment(). |
|
|
Definition at line 85 of file DetectorAlignment.h. Referenced by FitTrack(), and RunAlignment(). |
|
|
Definition at line 86 of file DetectorAlignment.h. Referenced by FitTrack(), and RunAlignment(). |
|
|
Definition at line 87 of file DetectorAlignment.h. Referenced by FitTrack(), and RunAlignment(). |
|
|
Definition at line 77 of file DetectorAlignment.h. Referenced by MakeAlignmentTrack(), RunAlignment(), and ~DetectorAlignment(). |
|
|
Definition at line 72 of file DetectorAlignment.h. Referenced by GetTrackStrips(), RunAlignment(), StripBelongsToUTrack(), and ~DetectorAlignment(). |
|
|
Definition at line 71 of file DetectorAlignment.h. Referenced by GetTrackStrips(), RunAlignment(), StripBelongsToVTrack(), and ~DetectorAlignment(). |
|
|
Definition at line 83 of file DetectorAlignment.h. Referenced by RunAlignment(). |
1.3.9.1