Managed::ClusterSaver Class Reference

#include <ClusterSaver.h>

List of all members.

Public Member Functions

 ClusterSaver ()
 ~ClusterSaver ()
void Reset ()
Managed::ManagedClusterGetCluster (int cid)
void FillClusterMap (std::map< double, std::map< double, std::pair< double, int > > > *cluster_map)
int SaveCluster (Managed::ManagedCluster *cluster)
std::map< double, std::map
< double, int > > * 
GetClusterMap (int view=0)
void DumpClusters ()
std::map< std::pair< int, int >
, double > 
GetStripEnergy ()
void recomputeBounds ()

Public Attributes

std::map< double, std::map
< double, int > > 
cluster_map
std::map< double, std::map
< double, int > > 
cluster_map_u
std::map< double, std::map
< double, int > > 
cluster_map_v
std::vector
< Managed::ManagedCluster
clusters
double maxz
double minz
double maxt
double mint
double minu
double maxu
double minv
double maxv
int nClusters
int save_id

Private Member Functions

void RebuildClusterMaps ()
 ClassDef (ClusterSaver, 1)

Private Attributes

int needMapRebuild
std::vector< int > clusters_to_delete

Detailed Description

Definition at line 17 of file ClusterSaver.h.


Constructor & Destructor Documentation

ClusterSaver::ClusterSaver (  ) 

Definition at line 7 of file ClusterSaver.cxx.

00008 {
00009                 Reset();
00010                 
00011 }

ClusterSaver::~ClusterSaver (  ) 

Definition at line 14 of file ClusterSaver.cxx.

References cluster_map, cluster_map_u, cluster_map_v, clusters, and clusters_to_delete.

00015 {
00016 
00017                 cluster_map.clear();
00018                 clusters.clear();       
00019                 cluster_map_u.clear();
00020                 cluster_map_v.clear();  
00021                 
00022                 clusters_to_delete.clear();
00023 }


Member Function Documentation

Managed::ClusterSaver::ClassDef ( ClusterSaver  ,
 
) [private]
void ClusterSaver::DumpClusters (  ) 

Definition at line 124 of file ClusterSaver.cxx.

References cluster_map, clusters, Managed::ManagedCluster::dt, Managed::ManagedCluster::dz, Managed::ManagedCluster::e, GetCluster(), RebuildClusterMaps(), Managed::ManagedCluster::t, Managed::ManagedCluster::view, and Managed::ManagedCluster::z.

00125 {
00126 
00127         RebuildClusterMaps();
00128 /*      
00129         printf("array dump\n");
00130         for(int i=0;i<clusters.size();i++)
00131         {               ManagedCluster *mc = &clusters[i];
00132                         if(!mc){printf("missing cluster id %d\n",i);continue;}
00133                         printf("%d  z %f t %f e %f dz %f dt %f view %d \n",i,mc->z,mc->t,mc->e,mc->dz,mc->dt,mc->view); 
00134         }
00135 */
00136         std::map<double, std::map<double, int> >::iterator p_iter;
00137         std::map<double, int>::iterator s_iter;
00138 
00139         printf("dumping clusters... %d found in array\n",(int)clusters.size());
00140            
00141         for(p_iter=cluster_map.begin();p_iter!=cluster_map.end(); p_iter++)
00142         {
00143                 std::map<double, int>::iterator s_iter;
00144                 for(s_iter=p_iter->second.begin();s_iter!=p_iter->second.end(); s_iter++)
00145                 {
00146                         ManagedCluster *mc = GetCluster(s_iter->second);
00147                         if(!mc){printf("missing cluster id %d\n",s_iter->second);continue;}
00148                         printf("z %f t %f e %f dz %f dt %f view %d \n",mc->z,mc->t,mc->e,mc->dz,mc->dt,mc->view);
00149                         printf("id %d\n",s_iter->second);
00150         
00151                 }
00152         }
00153 
00154         printf("done....\n\n");
00155 }

void ClusterSaver::FillClusterMap ( std::map< double, std::map< double, std::pair< double, int > > > *  cluster_map  ) 

Definition at line 197 of file ClusterSaver.cxx.

References clusters.

00198 {
00199         for(unsigned int i=0;i<clusters.size();i++)
00200         {
00201                 (*cluster_map)[clusters[i].z][clusters[i].t]=std::pair<double,int>(clusters[i].e, clusters[i].view);
00202         }
00203 
00204 }

Managed::ManagedCluster * ClusterSaver::GetCluster ( int  cid  ) 

Definition at line 184 of file ClusterSaver.cxx.

References clusters.

Referenced by ChainView::DrawClusters(), HoughView::DrawClusters(), DumpClusters(), Managed::ClusterManager::GetCluster(), Managed::ClusterManager::GetSavedCluster(), and LongMuonFinder::MakeParticle3D().

00185 {
00186         ManagedCluster * c =0;
00187         for(unsigned int i=0;i<clusters.size();i++)
00188         {
00189                 if(clusters[i].id==cid)c=&clusters[i];
00190         }
00191 
00192         return c;
00193 }

std::map< double, std::map< double, int > > * ClusterSaver::GetClusterMap ( int  view = 0  ) 

Definition at line 63 of file ClusterSaver.cxx.

References cluster_map, cluster_map_u, cluster_map_v, needMapRebuild, and RebuildClusterMaps().

Referenced by ChainView::DrawClusters(), and HoughView::DrawClusters().

00064 {
00065 
00066         //need rebuild?
00067         
00068         if(needMapRebuild)RebuildClusterMaps();
00069 
00070 
00071 
00072         if(view==2)return &cluster_map_u;
00073         if(view==3)return &cluster_map_v;
00074         return &cluster_map;
00075 }

std::map< std::pair< int, int >, double > ClusterSaver::GetStripEnergy (  ) 

Definition at line 207 of file ClusterSaver.cxx.

References clusters.

Referenced by Finder::Process().

00208 {
00209         std::map<std::pair<int,int>, double> ret;
00210 
00211         for(unsigned int i=0;i<clusters.size();i++)
00212         {
00213                 for(unsigned int j=0;j<clusters[i].hitplane.size();j++)
00214                 {
00215                         if(clusters[i].GetStatus()<=-10)continue;
00216 
00217                         //printf("id %d p %d s %d e %f\n",clusters[i].id,clusters[i].hitplane[j],clusters[i].hitstrip[j],clusters[i].hite[j]);
00218         
00219                         ret[std::pair<int,int>(clusters[i].hitplane[j],clusters[i].hitstrip[j])]+=clusters[i].hite[j];
00220 
00221                 }
00222         }
00223         return ret;
00224 }

void ClusterSaver::RebuildClusterMaps (  )  [private]

Definition at line 79 of file ClusterSaver.cxx.

References cluster_map, cluster_map_u, cluster_map_v, clusters, clusters_to_delete, and needMapRebuild.

Referenced by DumpClusters(), and GetClusterMap().

00080 {
00081 
00082 
00083         if(clusters_to_delete.size()>0)
00084         {
00085                 std::vector<Managed::ManagedCluster> cluster_temp;
00086                 for(unsigned int i=0;i<clusters.size();i++)
00087                 {
00088                         int keep=1;
00089                         for(unsigned int j=0;j<clusters_to_delete.size();j++)
00090                         {
00091                                 if(clusters_to_delete[j]==clusters[i].id)
00092                                 {
00093                                         keep=0;
00094                                         break;
00095                                 }
00096                         }
00097                         if(!keep)continue;
00098                         
00099                         cluster_temp.push_back(clusters[i]);
00100                 }
00101         
00102                 clusters=cluster_temp;
00103                 cluster_temp.clear();
00104                 clusters_to_delete.clear();
00105         }
00106 
00107         cluster_map.clear();
00108         cluster_map_u.clear();
00109         cluster_map_v.clear();
00110 
00111         for(unsigned int i=0;i<clusters.size();i++)
00112         {
00113                 cluster_map[clusters[i].z][clusters[i].t]=clusters[i].id;
00114                 if(clusters[i].view==2)cluster_map_u[clusters[i].z][clusters[i].t]=clusters[i].id;
00115                 if(clusters[i].view==3)cluster_map_v[clusters[i].z][clusters[i].t]=clusters[i].id;                                                              
00116         }
00117 
00118         needMapRebuild=0;
00119 }

void ClusterSaver::recomputeBounds (  ) 

Definition at line 227 of file ClusterSaver.cxx.

References clusters, Managed::ManagedCluster::e, MuELoss::e, maxt, maxu, maxv, maxz, mint, minu, minv, minz, nClusters, Managed::ManagedCluster::t, Managed::ManagedCluster::view, and Managed::ManagedCluster::z.

Referenced by Finder::Process().

00228 {
00229 
00230                 mint=100000;
00231                 maxt=-100000;
00232                 minz=100000;
00233                 maxz=-100000;
00234                 minu=100000;
00235                 maxu=-100000;
00236                 minv=100000;
00237                 maxv=-100000;
00238                 nClusters=0;
00239 
00240         for(unsigned int i=0;i<clusters.size();i++)
00241         {
00242                 for(unsigned int j=0;j<clusters[i].hitplane.size();j++)
00243                 {
00244                         if(clusters[i].GetStatus()<=-10)continue;
00245 
00246                         ManagedCluster c = clusters[i];
00247                         if(c.e<1e-6)continue;
00248 
00249                         nClusters++;
00250 
00251                         if(c.z<minz)minz=c.z;
00252                         if(c.z>maxz)maxz=c.z;
00253                         if(c.view==2)
00254                         {               
00255                                 if(c.t<minu)minu=c.t;
00256                                 if(c.t>maxu)maxu=c.t;
00257                         }
00258                         if(c.view==3)
00259                         {
00260                                 if(c.t<minv)minv=c.t;
00261                                 if(c.t>maxv)maxv=c.t;
00262                         }
00263 
00264                         if(c.t<mint)mint=c.t;
00265                         if(c.t>maxt)maxt=c.t;
00266 
00267                     
00268 
00269                 }
00270         }
00271 
00272 }

void ClusterSaver::Reset (  ) 

Definition at line 159 of file ClusterSaver.cxx.

References cluster_map, cluster_map_u, cluster_map_v, clusters, clusters_to_delete, maxt, maxu, maxv, maxz, mint, minu, minv, minz, nClusters, needMapRebuild, and save_id.

00160 {
00161 
00162                 
00163                 cluster_map.clear();
00164                 clusters.clear();
00165                 cluster_map_u.clear();
00166                 cluster_map_v.clear();          
00167                 mint=100000;
00168                 maxt=-100000;
00169                 minz=100000;
00170                 maxz=-100000;
00171                 minu=100000;
00172                 maxu=-100000;
00173                 minv=100000;
00174                 maxv=-100000;
00175                 nClusters=0;
00176 
00177                 save_id=-1;
00178                 needMapRebuild=0;
00179                 clusters_to_delete.clear();             
00180 }

int ClusterSaver::SaveCluster ( Managed::ManagedCluster cluster  ) 

Definition at line 26 of file ClusterSaver.cxx.

References cluster_map, cluster_map_u, cluster_map_v, clusters, Managed::ManagedCluster::e, Managed::ManagedCluster::Finalize(), Managed::ManagedCluster::id, maxt, maxu, maxv, maxz, mint, minu, minv, minz, save_id, Managed::ManagedCluster::t, Managed::ManagedCluster::view, and Managed::ManagedCluster::z.

Referenced by Managed::ClusterManager::SaveCluster().

00027 {
00028 
00029         if(cluster->e<0.0001)return 0;//don't save an empty cluster
00030 
00031         Managed::ManagedCluster c = *cluster;
00032         c.id = --save_id;
00033         cluster_map[c.z][c.t]=c.id;
00034         c.Finalize();
00035         clusters.push_back(c);
00036         
00037         cluster_map[c.z][c.t]=c.id;
00038         
00039         if(c.view==2)cluster_map_u[c.z][c.t]=c.id;
00040         if(c.view==3)cluster_map_v[c.z][c.t]=c.id;
00041 
00042 
00043         if(c.z<minz)minz=c.z;
00044         if(c.z>maxz)maxz=c.z;
00045         if(c.view==2)
00046         {
00047                 if(c.t<minu)minu=c.t;
00048                 if(c.t>maxu)maxu=c.t;
00049         }
00050         if(c.view==3)
00051         {
00052                 if(c.t<minv)minv=c.t;
00053                 if(c.t>maxv)maxv=c.t;
00054         }
00055 
00056         if(c.t<mint)mint=c.t;
00057         if(c.t>maxt)maxt=c.t;
00058 
00059         return c.id;
00060 }


Member Data Documentation

std::map<double, std::map<double, int> > Managed::ClusterSaver::cluster_map
std::map<double, std::map<double, int> > Managed::ClusterSaver::cluster_map_u

Definition at line 33 of file ClusterSaver.h.

Referenced by GetClusterMap(), RebuildClusterMaps(), Reset(), SaveCluster(), and ~ClusterSaver().

std::map<double, std::map<double, int> > Managed::ClusterSaver::cluster_map_v

Definition at line 34 of file ClusterSaver.h.

Referenced by GetClusterMap(), RebuildClusterMaps(), Reset(), SaveCluster(), and ~ClusterSaver().

std::vector<int> Managed::ClusterSaver::clusters_to_delete [private]

Definition at line 66 of file ClusterSaver.h.

Referenced by RebuildClusterMaps(), Reset(), and ~ClusterSaver().

Definition at line 45 of file ClusterSaver.h.

Referenced by recomputeBounds(), Reset(), and SaveCluster().

Definition at line 48 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), Reset(), and SaveCluster().

Definition at line 50 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), Reset(), and SaveCluster().

Definition at line 43 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), Reset(), and SaveCluster().

Definition at line 46 of file ClusterSaver.h.

Referenced by recomputeBounds(), Reset(), and SaveCluster().

Definition at line 47 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), Reset(), and SaveCluster().

Definition at line 49 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), Reset(), and SaveCluster().

Definition at line 44 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), Reset(), and SaveCluster().

Definition at line 51 of file ClusterSaver.h.

Referenced by Finder::Process(), recomputeBounds(), and Reset().

Definition at line 64 of file ClusterSaver.h.

Referenced by GetClusterMap(), RebuildClusterMaps(), and Reset().

Definition at line 55 of file ClusterSaver.h.

Referenced by Reset(), and SaveCluster().


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

Generated on 22 Jul 2018 for loon by  doxygen 1.6.1