#include <CosmicTrack.h>
Inheritance diagram for ctrk::CosmicTrack:

Public Member Functions | |
| CosmicTrack (const char *version) | |
| ~CosmicTrack () | |
| void | Update (const cfg::Config &c) |
| jobc::Result | Reco (edm::EventHandle &evt) |
Private Member Functions | |
| void | SortHitsByPlaneCell (std::vector< const recobase::CellHit * > &hits) |
| jobc::Result | MakeClusters (geo::Geometry &geo, std::vector< const recobase::CellHit * > &hits, std::vector< recobase::Cluster * > &clusters) |
| jobc::Result | MakeTracks (geo::Geometry &geo, std::vector< recobase::Cluster * > &clusters, std::vector< recobase::Track * > &tracks) |
Private Attributes | |
| int | fMaxPlaneGap |
| int | fClusterCellSep |
| max # of planes that can be skipped for a single track to bridge | |
| double | fMaxEdgeDist |
| max separation in # of cells between clusters | |
| std::string | fOutputFolder |
| max distance to edge for starting point of track in cm | |
| std::string | fInputFolder |
| folder to put tracks and clusters in | |
Definition at line 21 of file CosmicTrack.h.
|
|
Definition at line 42 of file CosmicTrack.cxx. References jobc::Module::SetCfgVersion(). 00042 : 00043 jobc::Module("ctrk::CosmicTrack"), 00044 fMaxPlaneGap(0), 00045 fMaxEdgeDist(12.) 00046 { 00047 00048 this->SetCfgVersion(version); 00049 00050 }
|
|
|
Definition at line 53 of file CosmicTrack.cxx. 00053 { }
|
|
||||||||||||||||
|
loop over vector of hits and for each new plane look for the clusters of hits check and see if you are on a new plane, if so make clusters out of the vector divide the hits from the previous plane into clusters. clusters are separated by fClusterCellSep cells enough space between this cell and the rest of the cluster put the current vector into the planeClust vector and start a new vector now loop over all vectors in planeClust and make clusters out of them loop over all the clusters and set the position variables you know remember that only one view is in each cluster cause we made them by plane loop over the x view cells and get the signal weighted position end loop over x cells set the weight to the sum of the signal end if xcells loop over the y view cells and get the signal weighted position end loop over y cells set the weight to the sum of the signal end if ycells end loop over clusters Definition at line 161 of file CosmicTrack.cxx. References recobase::CellHit::Cell(), recobase::CellHit::PE(), recobase::CellHit::Plane(), geo::Geometry::Plane(), and recobase::CellHit::TNS(). Referenced by Reco(). 00164 {
00165
00167 std::vector<const recobase::CellHit *>::iterator itr = hits.begin();
00168 std::vector<const recobase::CellHit *>::iterator enditr = hits.end();
00169 std::vector<const recobase::CellHit *> cpvec;
00170 std::vector<const recobase::CellHit *> clustVec;
00171 std::vector< std::vector<const recobase::CellHit *> > planeClust;
00172 int prevPlane = (*itr)->Plane();
00173 while( itr != hits.end() ){
00174
00175 // std::cout << "on plane " << (*itr)->Plane() << std::endl;
00176
00179 if( (*itr)->Plane() != prevPlane){
00180 prevPlane = (*itr)->Plane();
00181
00184 std::vector<const recobase::CellHit *>::iterator pitr = cpvec.begin();
00185 int prevcell = (*pitr)->Cell();
00186 clustVec.clear();
00187 while( pitr != cpvec.end() ){
00188
00189 // std::cout << "looping over cells for plane " << (*pitr)->Plane()
00190 // << " on cell " << (*pitr)->Cell() << "/" << prevcell << std::endl;
00191
00195 if(abs(prevcell - (*pitr)->Cell()) > fClusterCellSep){
00196 // std::cout << "there are " << clustVec.size() << " cellhits on plane "
00197 // << (*pitr)->Plane() << std::endl;
00198 planeClust.push_back(clustVec);
00199 clustVec.clear();
00200 clustVec.push_back((*pitr));
00201 }
00202 else clustVec.push_back((*pitr));
00203
00204 prevcell = (*pitr)->Cell();
00205 pitr++;
00206 }
00207
00208 //put the cells into a vector
00209 planeClust.push_back(clustVec);
00210
00211 cpvec.clear();
00212 cpvec.push_back(*itr);
00213 }
00214 else cpvec.push_back(*itr);
00215
00216 itr++;
00217 }
00218
00220 for(unsigned int i = 0; i < planeClust.size(); ++i)
00221 clusters.push_back(new recobase::Cluster(planeClust[i]));
00222
00223 for(unsigned int i = 0; i < hits.size(); ++i){
00224 std::cout << hits[i]->Plane()
00225 << " " << hits[i]->Cell()
00226 << " " << hits[i]->TCPos()
00227 << " " << hits[i]->ZCPos()
00228 << " " << geo.Plane(hits[i]->Plane()).View()
00229 << " " << hits[i]->View() << std::endl;
00230 }
00231
00232
00236 double xyzl[] = {0., 0., 0.};
00237 double xyzw[3] = {0.};
00238 int xclus = 0;
00239 int yclus = 0;
00240 for(unsigned int i = 0; i < clusters.size(); ++i){
00241 double sumWeight = 0.;
00242 double sumTPosWeight = 0.;
00243 float weight = 0.;
00244 double time = 0.;
00245 double xyzt[4] = {0.};
00246
00247 if(clusters[i]->NXCell() > 0){
00248 ++xclus;
00251 for(int xc = 0; xc < clusters[i]->NXCell(); ++xc){
00252 recobase::CellHit cell((*clusters[i]->XCell(xc)));
00253 geo.Plane(cell.Plane()).Cell(cell.Cell()).LocalToWorld(xyzl, xyzw);
00254
00255 if(cell.PE(weight)){
00256 sumWeight += weight;
00257 sumTPosWeight += xyzw[0]*weight;
00258 }
00259 else{
00260 sumWeight += 1.;
00261 sumTPosWeight += xyzw[0];
00262 }
00263 if(!cell.TNS(time)) time = 0.;
00264
00265 }
00266
00267 xyzt[0] = sumTPosWeight/sumWeight;
00268 weight = sumWeight;
00269
00270 }
00271
00272 else if(clusters[i]->NYCell() > 0){
00273 ++yclus;
00274
00277 for(int yc = 0; yc < clusters[i]->NYCell(); ++yc){
00278 recobase::CellHit cell((*clusters[i]->YCell(yc)));
00279 geo.Plane(cell.Plane()).Cell(cell.Cell()).LocalToWorld(xyzl, xyzw);
00280 if(cell.PE(weight)){
00281 sumWeight += weight;
00282 sumTPosWeight += xyzw[1]*weight;
00283 }
00284 else{
00285 sumWeight += 1.;
00286 sumTPosWeight += xyzw[1];
00287 }
00288 if(!cell.TNS(time)) time = 0.;
00289 }
00290 xyzt[1] = sumTPosWeight/sumWeight;
00291 weight = sumWeight;
00292 }
00293
00294 xyzt[2] = xyzw[2];
00295 xyzt[3] = time;
00296 clusters[i]->SetXYZT(xyzt);
00297 clusters[i]->SetQ(weight);
00298 }
00299
00300 if(xclus < 2 || yclus < 2) return jobc::kFailed;
00301
00302 return jobc::kPassed;
00303 }
|
|
||||||||||||||||
|
separate the clusters into x and y get dx/dz and dy/dz as well as the intercepts in z loop over all the clusters. if the position of the cluster in the 2D view is within one cell width of the projected track, put it on the track set the position set the position Definition at line 307 of file CosmicTrack.cxx. References geo::Geometry::Plane(). Referenced by Reco(). 00310 {
00311
00313 std::vector<recobase::Cluster *> xcl;
00314 std::vector<recobase::Cluster *> ycl;
00315
00316 for(unsigned int i = 0; i < clusters.size(); ++i){
00317 if(clusters[i]->NXCell() > 0)
00318 xcl.push_back(clusters[i]);
00319 else if(clusters[i]->NYCell() > 0)
00320 ycl.push_back(clusters[i]);
00321 }
00322
00323 // std::cout << "done separating clusters" << std::endl
00324 // << xcl[xcl.size()-1]->X() << " " << xcl[xcl.size()-1]->Z()
00325 // << " " << xcl[0]->X() << " " << xcl[0]->Z() << " "
00326 // << ycl[ycl.size()-1]->Y() << " " << ycl[ycl.size()-1]->Z()
00327 // << " " << ycl[0]->Y() << " " << ycl[0]->Z() << std::endl;
00328
00330 double dxdz = (xcl[xcl.size()-1]->X() - xcl[0]->X());
00331 dxdz /= (xcl[xcl.size()-1]->Z() - xcl[0]->Z());
00332
00333 double dydz = (ycl[ycl.size()-1]->Y() - ycl[0]->Y());
00334 dydz /= (ycl[ycl.size()-1]->Z() - ycl[0]->Z());
00335
00336 double xint = xcl[0]->X() - dxdz*xcl[0]->Z();
00337 double yint = ycl[0]->Y() - dydz*ycl[0]->Z();
00338
00342 std::vector<const recobase::Cluster *> trkcls;
00343
00344 double cellWidth = 2.*geo.Plane(0).Cell(0).HalfD();
00345 double trkpos = 0.;
00346 double orthpos = 0.;
00347 for(unsigned int i = 0; i < xcl.size(); ++i){
00348 trkpos = xint + dxdz*xcl[i]->Z();
00349 orthpos = yint + dydz*xcl[i]->Z();
00350 double xyzt[] = {trkpos, orthpos, xcl[i]->Z(), xcl[i]->T()};
00352 xcl[i]->SetXYZT(xyzt);
00353 const recobase::Cluster* cl(xcl[i]);
00354 if(fabs(trkpos - xcl[i]->X()) < cellWidth) trkcls.push_back(cl);
00355 }
00356 for(unsigned int i = 0; i < ycl.size(); ++i){
00357 trkpos = yint + dydz*ycl[i]->Z();
00358 orthpos = xint + dxdz*ycl[i]->Z();
00359 double xyzt[] = {orthpos, trkpos, ycl[i]->Z(), ycl[i]->T()};
00361 ycl[i]->SetXYZT(xyzt);
00362 const recobase::Cluster* cl(ycl[i]);
00363 if(fabs(trkpos - ycl[i]->Y()) < cellWidth) trkcls.push_back(cl);
00364 }
00365
00366 sort(trkcls.begin(), trkcls.end(), zSort);
00367
00368 for(unsigned int i = 0; i < trkcls.size(); ++i)
00369 std::cout << "cluster on track " << trkcls[i]->X()
00370 << " " << trkcls[i]->Y() << " " << trkcls[i]->Z()
00371 << std::endl;
00372
00373 if(trkcls.size() < 1) return jobc::kFailed;
00374
00375 tracks.push_back(new recobase::Track(trkcls));
00376
00377 return jobc::kPassed;
00378 }
|
|
|
put the clusters and tracks for this event into the file clean up the memory Reimplemented from jobc::Module. Definition at line 69 of file CosmicTrack.cxx. References fOutputFolder, util::EDMUtils::GetGeometry(), MakeClusters(), MakeTracks(), edm::EventHandle::Reco(), and SortHitsByPlaneCell(). 00070 {
00071 jobc::Result res = jobc::kPassed;
00072
00073 geo::Geometry& geo = util::EDMUtils::GetGeometry(evt);
00074
00075 std::vector<const recobase::CellHit*> hits;
00076 try{ evt.Reco().Get(".",hits); }
00077 catch(...){
00078 std::cerr << "No hit list!" << std::endl;
00079 return jobc::kFailed;
00080 }
00081
00082 SortHitsByPlaneCell(hits);
00083
00084 std::vector<recobase::Cluster *> clusters;
00085 std::vector<recobase::Track *> tracks;
00086
00087 res = MakeClusters(geo, hits, clusters);
00088 if(res == jobc::kPassed){
00089 std::cout << "there are " << clusters.size() << " clusters" << std::endl;
00090
00091 res = MakeTracks(geo, clusters, tracks);
00092 }
00093
00095 if(!evt.Reco().GetFolder(fOutputFolder.c_str()))
00096 evt.Reco().MakeFolder(fOutputFolder.c_str());
00097
00098 unsigned int nclus = evt.Reco().PutVector(clusters, fOutputFolder.c_str());
00099 unsigned int ntrks = evt.Reco().PutVector(tracks, fOutputFolder.c_str());
00100
00101 if(nclus != clusters.size()){
00102 std::cerr << "CosmicTrack::Reco: wrong number of clusters saved: "
00103 << nclus << " instead of " << clusters.size() << std::endl;
00104 res = jobc::kFailed;
00105 }
00106 if(ntrks != tracks.size()){
00107 std::cerr << "CosmicTrack::Reco: wrong number of tracks saved: "
00108 << ntrks << " instead of " << tracks.size() << std::endl;
00109 res = jobc::kFailed;
00110 }
00111
00113 for(unsigned int i = 0; i < clusters.size(); ++i){
00114 if(clusters[i]){
00115 delete clusters[i];
00116 clusters[i] = 0;
00117 }
00118 }
00119
00120 for(unsigned int i = 0; i < tracks.size(); ++i){
00121 if(tracks[i]){
00122 delete tracks[i];
00123 tracks[i] = 0;
00124 }
00125 }
00126
00127 return res;
00128 }
|
|
|
first make sure the hits are sorted by plane now sort by cell within a plane check the plane of the current hit and if it is different from the previous hit, sort the previous plane's hits by cell location in vector 1 beyond previous plane end loop to sort hits by cell within each plane Definition at line 131 of file CosmicTrack.cxx. References cellSort(). Referenced by Reco(). 00132 {
00133
00135 sort(hits.begin(), hits.end(), planeSort);
00136
00138 std::vector<const recobase::CellHit *>::iterator citr = hits.begin();
00139 std::vector<const recobase::CellHit *>::iterator psitr = hits.begin();
00140 std::vector<const recobase::CellHit *>::iterator peitr = hits.begin();
00141
00142 int prevplane = -1;
00143 while( citr != hits.end() ){
00144
00147 if(prevplane != (*citr)->Plane() && citr != hits.begin() ){
00148 prevplane = (*citr)->Plane();
00149 peitr = citr;
00150 sort(psitr, peitr, cellSort);
00151 psitr = citr;
00152 }
00153
00154 ++citr;
00155 }
00156
00157 return;
00158 }
|
|
|
Implements cfg::Observer. Definition at line 56 of file CosmicTrack.cxx. References fClusterCellSep, fInputFolder, fMaxEdgeDist, fMaxPlaneGap, and fOutputFolder. 00057 {
00058
00059 c("MaxPlaneGap").Get(fMaxPlaneGap);
00060 c("MaxEdgeDist").Get(fMaxEdgeDist);
00061 c("ClusterCellSep").Get(fClusterCellSep);
00062 c("HitFolder").Get(fInputFolder);
00063 c("TrackFolder").Get(fOutputFolder);
00064
00065 std::cout << "Set Tracks to be saved in " << fOutputFolder.c_str() << std::endl;
00066 }
|
|
|
max # of planes that can be skipped for a single track to bridge
Definition at line 40 of file CosmicTrack.h. Referenced by Update(). |
|
|
folder to put tracks and clusters in
Definition at line 43 of file CosmicTrack.h. Referenced by Update(). |
|
|
max separation in # of cells between clusters
Definition at line 41 of file CosmicTrack.h. Referenced by Update(). |
|
|
Definition at line 39 of file CosmicTrack.h. Referenced by Update(). |
|
|
max distance to edge for starting point of track in cm
Definition at line 42 of file CosmicTrack.h. |
1.3.9.1