#include <TrackReco.h>
Inheritance diagram for rpr::TrackReco:

Public Member Functions | |
| TrackReco (const char *version) | |
| void | Update (const cfg::Config &c) |
| virtual | ~TrackReco () |
| jobc::Result | Reco (edm::EventHandle &evt) |
| void | Connection (std::vector< recobase::TrackBase > &track, geo::View_t xychoice) |
| void | Matching (std::vector< recobase::TrackBase > &track, std::vector< recobase::TrackBase > &track3d) |
| void | CalcChi2Ndof (recobase::TrackBase &trk, double &chi2, int &ndof, geo::View_t xychoice) |
Private Attributes | |
| short | fDetGeom |
| geo::Geometry * | fGeo |
| float | fInterval |
| int | fGap |
|
|
Definition at line 26 of file TrackReco.cxx. References jobc::Module::SetCfgVersion().
00026 : 00027 jobc::Module("TrackReco"), 00028 fDetGeom(1), fGeo(0), fInterval(13.27), fGap(2) 00029 { 00030 this->SetCfgVersion(version); 00031 } |
|
|
Definition at line 35 of file TrackReco.cxx.
00036 {
00037 }
|
|
||||||||||||||||||||
|
Definition at line 380 of file TrackReco.cxx. References recobase::PlaneCluster::dT(), fGeo, recobase::RecoPoint::GetPC(), recobase::TrackBase::NRecoPt(), geo::Geometry::Plane(), recobase::PlaneCluster::Plane(), recobase::TrackBase::RecoPt(), recobase::RecoPoint::T(), recobase::PlaneCluster::Tpos(), geo::PlaneGeo::View(), and geo::View_t. Referenced by Connection().
00383 {
00384
00385 int pln0 = trk.RecoPt(0).GetPC()->Plane();
00386 int pln1 = trk.RecoPt(trk.NRecoPt()-1).GetPC()->Plane();
00387
00388 chi2 = 0.;
00389 ndof = 0;
00390
00391 for(int ipl=pln0; ipl<=pln1; ipl++){
00392
00393 if(fGeo->Plane(ipl).View() != xychoice) continue;
00394
00395 ndof++;
00396
00397 bool blank = true;
00398
00399 unsigned int i=0;
00400 while(i<trk.NRecoPt()&&blank) {
00401 if(trk.RecoPt(i).GetPC()->Plane() == ipl) {
00402 blank = false;
00403 chi2 +=
00404 pow((trk.RecoPt(i).GetPC()->Tpos() - trk.RecoPt(i).T(xychoice)) /
00405 trk.RecoPt(i).GetPC()->dT(), 2);
00406 }
00407 i++;
00408 }
00409 if(blank) chi2 += pow(2.,2);
00410 }
00411 }
|
|
||||||||||||
|
Definition at line 88 of file TrackReco.cxx. References CalcChi2Ndof(), recobase::TrackBase::Clear(), recobase::PlaneCluster::dT(), recobase::TrackBase::EndZ(), fGap, fGeo, fInterval, recobase::RecoPoint::GetPC(), geo::PlaneGeo::LocalToWorld(), recobase::TrackBase::NRecoPt(), geo::Geometry::Plane(), recobase::PlaneCluster::Plane(), recobase::TrackBase::Put(), recobase::TrackBase::RecoPt(), recobase::RecoPoint::SetPosT(), recobase::TrackBase::SetXY(), recobase::TrackBase::StartT(), recobase::TrackBase::StartZ(), recobase::TrackBase::T(), recobase::PlaneCluster::Tpos(), and geo::View_t. Referenced by Reco().
00090 {
00091 double local[3] = {0.,0.,0.};
00092 double world[3] = {0.,0.,0.};
00093 double chi2 = 0.;
00094 int ndof = 0;
00095 int ndof_single = 0;
00096
00097 vector<TrackBase> trkseg;
00098 vector<TrackBase>::iterator itr = track.begin();
00099 while(itr!=track.end()){
00100 if(itr->XY()==xychoice) {
00101 trkseg.push_back(*itr);
00102 track.erase(itr);
00103 }
00104 else {
00105 ++itr;
00106 }
00107 }
00108
00109 // connection of tracks
00110 while(trkseg.size()>0){
00111
00112 // find track segment at downstream
00113 double max_start_z = 0.;
00114 int isel_post = 0;
00115 for (unsigned int i=0; i<trkseg.size(); ++i) {
00116 if( trkseg[i].StartZ() > max_start_z ) {
00117 max_start_z = trkseg[i].StartZ();
00118 isel_post = i;
00119 }
00120 }
00121 TrackBase posttrk = trkseg[isel_post];
00122 itr = trkseg.begin() + isel_post;
00123 trkseg.erase(itr);
00124
00125 double z_min_post = posttrk.StartZ();
00126 double z_max_post = posttrk.EndZ();
00127 double z_min_pre = 0.;
00128 double z_max_pre = 0.;
00129
00130 float ex_min_dist=0.;
00131 while(1) {
00132 float min_dist=10000;
00133 int isel_pre = 0;
00134 for (unsigned int i=0; i<trkseg.size(); ++i) {
00135 float distance =
00136 sqrt(pow(trkseg[i].EndZ() - posttrk.StartZ(),2) +
00137 pow(trkseg[i].EndT(xychoice) - posttrk.StartT(xychoice),2));
00138 if(distance<min_dist && distance>ex_min_dist) {
00139 isel_pre = i;
00140 min_dist = distance;
00141 }
00142 }
00143 ex_min_dist = min_dist;
00144
00145 // Mimimum distance condition. 1 plane gap is allowed, 2 and more are not.
00146 if(min_dist>fInterval*(fGap+0.5)) break;
00147
00148 TrackBase pretrk = trkseg[isel_pre];
00149 z_min_pre = pretrk.StartZ();
00150 z_max_pre = pretrk.EndZ();
00151
00152 // Sum of chi^2 from two tracks before connection
00153 float chi2_sep = 0.;
00154 int ndof_sep = 0;
00155
00156 CalcChi2Ndof(pretrk, chi2, ndof, xychoice);
00157 chi2_sep += chi2;
00158 ndof_sep += ndof;
00159 ndof_single = ndof;
00160
00161 CalcChi2Ndof(posttrk, chi2, ndof, xychoice);
00162 chi2_sep += chi2;
00163 ndof_sep += ndof;
00164 if( ndof > ndof_single ) ndof_single = ndof;
00165
00166 // Slide joint point along both tracks and calculate minimum chi^2.
00167 double chi2_min = 100000.;
00168 double t_cross = 0., z_cross = 0.;
00169 TrackBase combtrk;
00170 TrackBase combtrk_save;
00171
00172 for(int nloop=0; nloop<2; nloop++) { // slide along (nloop==0)? pretrk: posttrk;
00173
00174 double z_min = (nloop==0)?
00175 z_min_pre : z_min_post;
00176 double z_max = (nloop==0)?
00177 z_max_pre : z_max_post;
00178
00179 for(double zc = z_min; zc<z_max; zc+=fInterval/2.){
00180
00181 // Crossing point of 2 tracks: (zc, tc)
00182 double tc = (nloop==0)?
00183 pretrk.T(zc, xychoice) : posttrk.T(zc, xychoice);
00184
00185 double dtdz0 = (zc != pretrk.StartZ() && zc != z_min_pre)?
00186 (tc - pretrk.T(z_min_pre, xychoice))/(zc - z_min_pre) : 0.;
00187 double dtdz1 = (zc != posttrk.EndZ() && z_max_post != zc)?
00188 (posttrk.T(z_max_post, xychoice) - tc)/(z_max_post - zc) : 0.;
00189
00190 // Make combined track
00191 combtrk.Clear();
00192 for(int ipl = pretrk.RecoPt(0).GetPC()->Plane();
00193 ipl < posttrk.RecoPt(posttrk.NRecoPt()-1).GetPC()->Plane();
00194 ipl++) {
00195 fGeo->Plane(ipl).LocalToWorld(local, world);
00196
00197 double t = (world[2] <= zc)?
00198 pretrk.StartT(xychoice) + dtdz0 * (world[2] - z_min_pre) :
00199 tc + dtdz1 * (world[2] - zc);
00200
00201 int ipre = -1;
00202 for(unsigned int i=0; i<pretrk.NRecoPt(); i++) {
00203 if(pretrk.RecoPt(i).GetPC()->Plane() == ipl) ipre = i;
00204 }
00205
00206 int ipost = -1;
00207 for(unsigned int i=0; i<posttrk.NRecoPt(); i++) {
00208 if(posttrk.RecoPt(i).GetPC()->Plane() == ipl) ipost = i;
00209 }
00210
00211 if(ipre<0 && ipost<0) continue;
00212
00213 RecoPoint recopt;
00214 if(ipre>=0 && ipost<0) { // Hit exists only in pre track
00215 recopt = pretrk.RecoPt(ipre);
00216 }
00217 else if (ipre<0 && ipost>=0) { // Hit exists only in post track
00218 recopt = posttrk.RecoPt(ipre);
00219 }
00220 else if (ipre>=0 && ipost>=0) { // Both in this plane
00221 recopt =
00222 (abs(pretrk.RecoPt(ipre).GetPC()->Tpos()-t)
00223 < abs(posttrk.RecoPt(ipost).GetPC()->Tpos()-t)) ?
00224 pretrk.RecoPt(ipre) : posttrk.RecoPt(ipost);
00225 }
00226
00227 recopt.SetPosT(t, xychoice);
00228
00229 if(abs(recopt.GetPC()->Tpos()-t)<2.*recopt.GetPC()->dT())
00230 combtrk.Put(recopt);
00231
00232 }
00233
00234 if(combtrk.NRecoPt()==0) continue;
00235 CalcChi2Ndof(combtrk, chi2, ndof, xychoice);
00236 double scat_angle = abs(atan(dtdz0)-atan(dtdz1))*180./3.1415;
00237 chi2 += pow(scat_angle/10.,2); // contribution from scattering angle: 10 deg as 1-sigma
00238 chi2 -= min(ndof - ndof_single, 4); // magic number: longer track is favored
00239
00240 if(ndof>0 && chi2/ndof<chi2_min) {
00241 combtrk_save = combtrk;
00242 chi2_min = chi2/ndof;
00243 t_cross = tc;
00244 z_cross = zc;
00245 }
00246 }
00247 }
00248
00249 if(chi2_min<1.2 || chi2_min<chi2_sep/ndof_sep){
00250 posttrk = combtrk_save;
00251 itr = trkseg.begin() + isel_pre;
00252 trkseg.erase(itr);
00253 }
00254
00255 }
00256 posttrk.SetXY(xychoice);
00257 track.push_back(posttrk);
00258 }
00259 }
|
|
||||||||||||
|
Definition at line 263 of file TrackReco.cxx. References recobase::TrackBase::Clear(), fGap, fInterval, recobase::TrackBase::Put(), recobase::RecoPoint::SetPos(), and recobase::RecoPoint::Z(). Referenced by Reco().
00265 {
00266 vector<bool> trkused;
00267 trkused.resize(track.size());
00268 for(unsigned int i=0; i<trkused.size(); i++) {
00269 trkused[i] = false;
00270 }
00271
00272 TrackBase trk;
00273
00274 // Construct 3D track from 2D tracks in X and Y view
00275 while(1){
00276 double min_mean_dist_frac = 10000;
00277 double min_mean_dist = 10000;
00278 int mean_frac_x = 0, mean_frac_y = 0;
00279 int mean_x = 0, mean_y = 0;
00280 for (unsigned int ix=0; ix<track.size(); ++ix) {
00281 for (unsigned int iy=0; iy<track.size(); ++iy) {
00282 if(ix!=iy&&track[ix].XY()==geo::kX&&track[iy].XY()==geo::kY) {
00283 bool used = false;
00284 if(trkused[ix]||trkused[iy]) used = true;
00285 if(used) continue;
00286
00287 double range_x = track[ix].EndZ() - track[ix].StartZ();
00288 double range_y = track[iy].EndZ() - track[iy].StartZ();
00289 double vtx_dist = abs(track[ix].StartZ() - track[iy].StartZ());
00290 double end_dist = abs(track[ix].EndZ() - track[iy].EndZ());
00291 double mean_dist = (vtx_dist+end_dist)/2.;
00292 double mean_dist_frac = mean_dist/((range_x+range_y)/2.);
00293
00294 if(mean_dist_frac<min_mean_dist_frac) {
00295 min_mean_dist_frac = mean_dist_frac;
00296 mean_frac_x = ix;
00297 mean_frac_y = iy;
00298 }
00299
00300 if(mean_dist<min_mean_dist) {
00301 min_mean_dist = mean_dist;
00302 mean_x = ix;
00303 mean_y = iy;
00304 }
00305
00306 }
00307 }
00308 }
00309
00310 // Conditions of matching x and y tracks:
00311 int matched_x = 0;
00312 int matched_y = 0;
00313
00314 if(min_mean_dist_frac<0.1) {
00315 // 1. Mean distance of vertex and end positions relative to the range
00316 matched_x = mean_frac_x;
00317 matched_y = mean_frac_y;
00318 }
00319 else if(min_mean_dist<fInterval*(fGap+0.25)) {
00320 // 2. Mean distance of vertex and end position (3+5) plane is OK, (5+5) is not.
00321 matched_x = mean_x;
00322 matched_y = mean_y;
00323 }
00324 else if(min_mean_dist_frac<0.3) {
00325 // 3. Mean distance of vertex and end position relative to the range -> Vertex or end position.
00326 double vtx_dist =
00327 fabs(track[mean_frac_x].StartZ() - track[mean_frac_y].StartZ());
00328
00329 double end_dist =
00330 fabs(track[mean_frac_x].EndZ() - track[mean_frac_y].EndZ());
00331
00332 if(vtx_dist<fInterval*(fGap+0.25)){
00333 matched_x = mean_frac_x;
00334 matched_y = mean_frac_y;
00335 }
00336 else if(end_dist<fInterval*(fGap+0.25)){
00337 matched_x = mean_frac_x;
00338 matched_y = mean_frac_y;
00339 }
00340 else {
00341 break;
00342 }
00343 }
00344 else {
00345 // If no condition is satisfied.
00346 break;
00347 }
00348
00349 trkused[matched_x] = true;
00350 trkused[matched_y] = true;
00351
00352 trk.Clear();
00353 RecoPoint recopt;
00354
00355 TVector3 xyz;
00356 for(unsigned int i=0; i<track[matched_x].NRecoPt(); i++) {
00357 recopt = track[matched_x].RecoPt(i);
00358 xyz.SetXYZ(track[matched_x].X(recopt.Z()),
00359 track[matched_y].Y(recopt.Z()),
00360 recopt.Z());
00361 recopt.SetPos(xyz);
00362 trk.Put(recopt);
00363 }
00364 for(unsigned int i=0; i<track[matched_y].NRecoPt(); i++) {
00365 recopt = track[matched_y].RecoPt(i);
00366 xyz.SetXYZ(track[matched_x].X(recopt.Z()),
00367 track[matched_y].Y(recopt.Z()),
00368 recopt.Z());
00369 recopt.SetPos(xyz);
00370 trk.Put(recopt);
00371 }
00372 track3d.push_back(trk);
00373
00374 } // While there are tracks which have closed vertex and/or end position.
00375
00376 }
|
|
|
Reimplemented from jobc::Module. Definition at line 49 of file TrackReco.cxx. References geo::PlaneGeo::Cell(), Connection(), fDetGeom, fGeo, fInterval, geo::CellGeo::GetCenter(), edm::EventHandle::Header(), geo::Geometry::Instance(), Matching(), geo::Geometry::Plane(), edm::EventHandle::Reco(), and jobc::Result.
00050 {
00051 if (!fGeo) fGeo = &geo::Geometry::Instance(evt.Header().Run(), fDetGeom);
00052
00053 // Gap between two planes
00054 double x1[3], x2[3];
00055 fGeo->Plane(0).Cell(0).GetCenter(x1);
00056 fGeo->Plane(2).Cell(0).GetCenter(x2);
00057 fInterval = x2[2] - x1[2];
00058
00059 // Get Track Sengemnts
00060 vector<const recobase::TrackBase*> trackseg(0);
00061 try{
00062 evt.Reco().Get("./Segment",trackseg);
00063 }
00064 catch(edm::Exception e) {
00065 return jobc::kFailed;
00066 }
00067
00068 vector<recobase::TrackBase> track;
00069 for(unsigned int itrk=0; itrk<trackseg.size(); itrk++)
00070 track.push_back(*trackseg[itrk]);
00071
00072 this->Connection(track, geo::kX);
00073 this->Connection(track, geo::kY);
00074
00075 vector<recobase::TrackBase> track3d;
00076 this->Matching(track, track3d);
00077
00078 evt.Reco().MakeFolder("./Final");
00079 for (unsigned int i=0; i<track3d.size(); ++i) {
00080 evt.Reco().Put(track3d[i],"./Final");
00081 }
00082
00083 return jobc::kPassed;
00084 }
|
|
|
Implements cfg::Observer. Definition at line 41 of file TrackReco.cxx. References fDetGeom, and fGap.
00042 {
00043 c("DetGeom"). Get(fDetGeom);
00044 c("Gap"). Get(fGap);
00045 }
|
|
|
Definition at line 45 of file TrackReco.h. |
|
|
Definition at line 48 of file TrackReco.h. Referenced by Connection(), Matching(), and Update(). |
|
|
Definition at line 46 of file TrackReco.h. Referenced by CalcChi2Ndof(), Connection(), and Reco(). |
|
|
Definition at line 47 of file TrackReco.h. Referenced by Connection(), Matching(), and Reco(). |
1.3.5