Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TrackSegmentCamAtNu.cxx

Go to the documentation of this file.
00001 
00002 // Package: AtNuReco
00003 //
00004 // TrackSegmentCamAtNu.cxx
00005 //
00006 // chapman@hep.phy.cam.ac.uk
00007 // blake@hep.phy.cam.ac.uk
00009 #include "AtNuReco/TrackSegmentCamAtNu.h"
00010 #include "AtNuReco/ClusterCamAtNu.h"
00011 #include "AtNuReco/HitCamAtNu.h"
00012 #include "math.h"
00013 
00014 ClassImp(TrackSegmentCamAtNu)
00015  
00016 CVSID("$Id: TrackSegmentCamAtNu.cxx,v 1.1 2009/01/25 16:55:49 blake Exp $");
00017 
00018 
00020 TrackSegmentCamAtNu::TrackSegmentCamAtNu(ClusterCamAtNu* clustm, ClusterCamAtNu* clust0, ClusterCamAtNu* clustp):
00021   fSeedSegment(0), fPartner(0), fUID(0), fBegPlane(999), fEndPlane(-999), fBegVtxZ(999.), 
00022   fEndVtxZ(-999.), fTrkFlag(0), fTmpTrkFlag(0), fPlaneView(-1), fNPlanes(0), 
00023   fBegTime(0.), fEndTime(0.), StripWidth(4.108e-2)
00024 {
00025   fPlaneView=clust0->GetPlaneView();
00026   fBegTime=clust0->GetBegTime();
00027   fEndTime=clust0->GetEndTime();
00028 
00029   this->AddCluster(clustm); this->AddCluster(clust0); this->AddCluster(clustp);
00030 }
00032 
00033 
00035 TrackSegmentCamAtNu::~TrackSegmentCamAtNu()
00036 {
00037   ClustersInSegment.clear();
00038   fBegAssociatedSegList.clear();
00039   fEndAssociatedSegList.clear();
00040   fBegPreferredSegList.clear();
00041   fEndPreferredSegList.clear();
00042   fBegMatchedSegList.clear();
00043   fEndMatchedSegList.clear();
00044 }
00046 
00047 
00049 void TrackSegmentCamAtNu::AddCluster(ClusterCamAtNu* clust)
00050 {
00051   if(clust) {
00052     if(this->ContainsCluster(clust)==false) 
00053       {
00054         ClustersInSegment.push_back(clust);
00055         if( fBegPlane > clust->GetPlane()){ fBegPlane = clust->GetPlane(); fBegVtxZ =  clust->GetZPos(); }
00056         if( fEndPlane < clust->GetPlane()){ fEndPlane = clust->GetPlane(); fEndVtxZ =  clust->GetZPos(); }
00057         
00058         if( clust->GetBegTime()<fBegTime ) { fBegTime=clust->GetBegTime(); }
00059         if( clust->GetEndTime()>fEndTime ) { fEndTime=clust->GetEndTime(); }
00060       }
00061   }
00062   
00063   return;
00064 }
00066 
00067 
00069 bool TrackSegmentCamAtNu::ContainsCluster(ClusterCamAtNu* clust)
00070 {
00071   for(unsigned int i=0; i<ClustersInSegment.size(); ++i) {
00072     if(clust==ClustersInSegment[i]) {return true;}
00073   }
00074 
00075   return false;
00076 }
00078 
00079 
00081 ClusterCamAtNu* TrackSegmentCamAtNu::GetCluster(unsigned int i)
00082 {
00083   if(i<ClustersInSegment.size()) {return ClustersInSegment[i];}
00084   
00085   else {return 0;}
00086 }
00088 
00089 
00091 void TrackSegmentCamAtNu::AddSegment(TrackSegmentCamAtNu* segment)
00092 {
00093   for(unsigned int i=0; i<segment->GetEntries(); ++i) {
00094     this->AddCluster(segment->GetCluster(i));    
00095   }
00096 
00097   return;
00098 }
00100 
00101 
00103 unsigned int TrackSegmentCamAtNu::GetEntries() const
00104 {
00105   return ClustersInSegment.size();
00106 }
00108 
00109 
00111 int TrackSegmentCamAtNu::GetBegPlane() const
00112 {
00113   return fBegPlane;
00114 }
00116 
00117 
00119 int TrackSegmentCamAtNu::GetEndPlane() const
00120 {
00121   return fEndPlane;
00122 }
00124 
00125 
00127 bool TrackSegmentCamAtNu::IsAssoc(TrackSegmentCamAtNu* segment)
00128 {
00129   unsigned int i;
00130   bool assoc=false;
00131   bool flag=false; 
00132   TrackSegmentCamAtNu* Seg1 = this;
00133   TrackSegmentCamAtNu* Seg2 = segment;
00134 
00135   //If the two clusters overlap at all
00136   if(Seg1->GetEndPlane()>=Seg2->GetBegPlane()){
00137     flag=true;
00138     //All clusters in Seg1 in planes overlapping Seg2 should also be in Seg2
00139     for(i=0;i<Seg1->GetEntries();i++){
00140       ClusterCamAtNu* clr = Seg1->GetCluster(i);
00141       if(clr->GetPlane()>=Seg2->GetBegPlane()){ 
00142         if(!(Seg2->ContainsCluster(clr))){
00143           flag=false; 
00144           break; //one mismatch is too many
00145         }
00146       }
00147     }
00148     if(flag)//only bother with 2nd check if 1st was ok
00149       {
00150         //All clusters in Seg2 in planes overlapping Seg1 should also be in Seg1
00151         for(i=0;i<Seg2->GetEntries();i++){
00152           ClusterCamAtNu* clr = Seg2->GetCluster(i);
00153           if(clr->GetPlane()<=Seg1->GetEndPlane()){ 
00154             if(!(Seg1->ContainsCluster(clr))){
00155               flag=false; 
00156               break; //one mismatch is too many 
00157             }
00158           }
00159         }
00160       }
00161     //If this is true and they overlap by more than one plane then they are associated
00162     if(Seg1->GetEndPlane()>Seg2->GetBegPlane()){ if(flag) assoc=true; }
00163   }
00164     //If the segments overlap by 1 or fewer planes need to do some more work...    
00165   if(Seg1->GetEndPlane()<=Seg2->GetBegPlane()){
00166     int idb=0,idb0=0;
00167     int bpln=Seg2->GetEndPlane()+1;
00168     //find the first (lowest plane no) two clusters in the second segment
00169     for(i=0;i<Seg2->GetEntries();i++){
00170       ClusterCamAtNu* clr = Seg2->GetCluster(i);
00171       if(clr->GetPlane()<bpln && clr->GetPlane()>Seg2->GetBegPlane()+2){
00172         bpln=clr->GetPlane(); idb=i;
00173       }
00174       else{ if(clr->GetPlane()==Seg2->GetBegPlane()) idb0=i; }
00175     }
00176     ClusterCamAtNu* clrb = Seg2->GetCluster(idb); ClusterCamAtNu* clrb0 = Seg2->GetCluster(idb0);
00177     double bBegTPos = clrb->GetBegTPos(); double bEndTPos = clrb->GetEndTPos();
00178     double b0BegTPos = clrb0->GetBegTPos(); double b0EndTPos = clrb0->GetEndTPos();
00179 
00180     int ide=0,ide0=0;
00181     int epln=Seg1->GetBegPlane()-1;
00182     //find the last (highest plane no) two clusters in the first segment
00183     for(i=0;i<Seg1->GetEntries();i++){
00184       ClusterCamAtNu* clr = Seg1->GetCluster(i);
00185       if(clr->GetPlane()>epln && clr->GetPlane()<Seg1->GetEndPlane()-2){
00186         epln=clr->GetPlane(); ide=i;
00187       }
00188       else{ if(clr->GetPlane()==Seg1->GetEndPlane()) ide0=i; }
00189     }
00190     ClusterCamAtNu* clre = Seg1->GetCluster(ide); ClusterCamAtNu* clre0 = Seg1->GetCluster(ide0);
00191     double eBegTPos = clre->GetBegTPos(); double eEndTPos = clre->GetEndTPos();
00192     double e0BegTPos = clre0->GetBegTPos(); double e0EndTPos = clre0->GetEndTPos();
00193     //Look at how these clusters overlap stripwise    
00194     if( ( bEndTPos-b0BegTPos>-2*StripWidth && b0EndTPos-bBegTPos>-2*StripWidth && eEndTPos-e0BegTPos>-2*StripWidth && e0EndTPos-eBegTPos>-2*StripWidth )
00195         || ( ( bBegTPos-b0BegTPos>-2*StripWidth && e0BegTPos-eBegTPos>-2*StripWidth ) || ( bEndTPos-b0EndTPos>-2*StripWidth && e0EndTPos-eEndTPos>-2*StripWidth ) )
00196         || ( ( bBegTPos-b0BegTPos<2*StripWidth && e0BegTPos-eBegTPos<2*StripWidth ) || ( bEndTPos-b0EndTPos<2*StripWidth && e0EndTPos-eEndTPos<2*StripWidth ) ) 
00197         ){
00198       //if the segments overlap by 1 plane then we can now say if they are associated or not
00199       if(Seg2->GetBegPlane()==Seg1->GetEndPlane()){ if(flag) assoc=true; }
00200       else{
00201         double z1,z2,t1,t2,dt1,dt2,dir1,dir2,dirtmp,win;
00202         z1=Seg1->GetEndZPos();  z2=Seg2->GetBegZPos();
00203         t1=Seg1->GetEndTPos();  t2=Seg2->GetBegTPos();
00204         dir1=Seg1->GetEndDir(); dt1=t2-t1-dir1*(z2-z1); 
00205         dir2=Seg2->GetBegDir(); dt2=t2-t1-dir2*(z2-z1); 
00206         win=0.1+0.35*(z2-z1);   dirtmp=(1+dir1*dir2)/(sqrt(1+dir1*dir1)*sqrt(1+dir2*dir2));
00207         
00208         if( ( (dt1>-win&&dt1<win)||(dt2>-win&&dt2<win) ) && ( dirtmp>0.65 ) ) assoc=true; 
00209       }
00210     }
00211   }
00212   return assoc;
00213 }
00215 
00216 
00217 
00219 double TrackSegmentCamAtNu::GetBegTPos()
00220 {
00221   double tot=0.0,begt=0.0;
00222   //Loop over clusters in segment
00223   unsigned int nclusters = this->GetEntries();
00224   unsigned int nhits = 0;
00225   HitCamAtNu* hit=0;
00226   for( unsigned int i=0; i<nclusters; ++i)
00227     {//find the clusters on the first plane in the segment
00228       if(ClustersInSegment[i]->GetPlane()==fBegPlane)
00229         {
00230           nhits = ClustersInSegment[i]->GetEntries();
00231 
00232           //loop over hits in cluster
00233           for(unsigned int j=0;j<nhits;++j)
00234             {
00235               hit = ClustersInSegment[i]->GetHit(j);
00236               if(hit)
00237                 {
00238                   begt+=hit->GetTPos();
00239                   tot+=1.0;
00240                 }
00241             }
00242         }
00243     }
00244   if(tot>0) return (begt/tot); 
00245   else return 0;
00246 }
00248 
00249 
00250 
00252 double TrackSegmentCamAtNu::GetEndTPos()
00253 {
00254   double tot=0.0,endt=0.0;
00255   //Loop over clusters in segment
00256   unsigned int nclusters = this->GetEntries();
00257   unsigned int nhits = 0;
00258   HitCamAtNu* hit=0;
00259   for( unsigned int i=0; i<nclusters; ++i)
00260     {//find the clusters on the first plane in the segment
00261       if(ClustersInSegment[i]->GetPlane()==fEndPlane)
00262         {
00263           nhits = ClustersInSegment[i]->GetEntries();
00264 
00265           //loop over hits in cluster
00266           for(unsigned int j=0;j<nhits;++j)
00267             {
00268               hit = ClustersInSegment[i]->GetHit(j);
00269               if(hit)
00270                 {
00271                   endt+=hit->GetTPos();
00272                   tot+=1.0;
00273                 }
00274             }
00275         }
00276     }
00277   if(tot>0) return (endt/tot); 
00278   else return 0;
00279 }
00281 
00282 
00283 
00285 double TrackSegmentCamAtNu::GetBegDir()
00286 {
00287   double z=0.0,t=0.0;
00288   double sw=0.0,swx=0.0,swx2=0.0;
00289   double swy=0.0,swyx=0.0;
00290   unsigned int nclusters = this->GetEntries();
00291   unsigned int nhits = 0;
00292   HitCamAtNu* hit=0;
00293   for( unsigned int i=0; i<nclusters; ++i)
00294     {//find the clusters on the first plane in the segment
00295       if(ClustersInSegment[i]->GetPlane()<fBegPlane+10)
00296         {
00297           nhits = ClustersInSegment[i]->GetEntries();
00298 
00299           //loop over hits in cluster
00300           for(unsigned int j=0;j<nhits;++j)
00301             {
00302               hit = ClustersInSegment[i]->GetHit(j);
00303               if(hit)
00304                 {
00305                   z=hit->GetZPos(); t=hit->GetTPos();
00306                   sw+=1.0; swx+=z; swx2+=z*z; 
00307                   swy+=t; swyx+=t*z;;
00308                 }
00309             }
00310         }
00311     }
00312   if((swx*swx-sw*swx2)!=0) {return (swx*swy-sw*swyx)/(swx*swx-sw*swx2);}
00313   else return 0;
00314 }
00316 
00317 
00319 double TrackSegmentCamAtNu::GetEndDir()
00320 {
00321   double z=0.0,t=0.0;
00322   double sw=0.0,swx=0.0,swx2=0.0;
00323   double swy=0.0,swyx=0.0;
00324   unsigned int nclusters = this->GetEntries();
00325   unsigned int nhits = 0;
00326   HitCamAtNu* hit=0;
00327   for( unsigned int i=0; i<nclusters; ++i)
00328     {//find the clusters on the first plane in the segment
00329       if(ClustersInSegment[i]->GetPlane()>fEndPlane-10)
00330         {
00331           nhits = ClustersInSegment[i]->GetEntries();
00332 
00333           //loop over hits in cluster
00334           for(unsigned int j=0;j<nhits;++j)
00335             {
00336               hit = ClustersInSegment[i]->GetHit(j);
00337               if(hit)
00338                 {
00339                   z=hit->GetZPos(); t=hit->GetTPos();
00340                   sw+=1.0; swx+=z; swx2+=z*z; 
00341                   swy+=t; swyx+=t*z;;
00342                 }
00343             }
00344         }
00345     }
00346   
00347   if((swx*swx-sw*swx2)!=0) {return (swx*swy-sw*swyx)/(swx*swx-sw*swx2);}
00348   else return 0;
00349 }
00351 
00352 
00354 double TrackSegmentCamAtNu::GetBegZPos() const
00355 {
00356   return fBegVtxZ;
00357 }
00359 
00360 
00362 double TrackSegmentCamAtNu::GetEndZPos() const
00363 {
00364   return fEndVtxZ;
00365 }
00367 
00368 
00370 void TrackSegmentCamAtNu::AddAssocSegToBeg(TrackSegmentCamAtNu* seg) //void AddTriToBeg(TrackSegmentCamAtNu* seg);
00371 {
00372   fBegAssociatedSegList.push_back(seg);
00373   return;
00374 }
00376 
00377 
00379 void TrackSegmentCamAtNu::AddAssocSegToEnd(TrackSegmentCamAtNu* seg) //void AddTriToEnd(TrackSegmentCamAtNu* seg);
00380 {
00381   fEndAssociatedSegList.push_back(seg);
00382   return;
00383 }
00385 
00386 
00388 TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetAssocSegBeg(unsigned int i)//TrackSegmentCamAtNu* GetTriBeg(unsigned int i);
00389 {
00390   if(i<fBegAssociatedSegList.size()) {return fBegAssociatedSegList[i];}
00391   else return 0;
00392 }
00394 
00395 
00397 TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetAssocSegEnd(unsigned int i)//TrackSegmentCamAtNu* GetTriEnd(unsigned int i);
00398 {
00399   if(i<fEndAssociatedSegList.size()) {return fEndAssociatedSegList[i];}
00400   else return 0;
00401 }
00403 
00404 
00406 void TrackSegmentCamAtNu::AddPrefSegToBeg(TrackSegmentCamAtNu* seg)//void AddAssocTriToBeg(TrackSegmentAtNu* segment);
00407 {
00408   fBegPreferredSegList.push_back(seg);
00409   return;
00410 }
00412 
00413 
00415 void TrackSegmentCamAtNu::AddPrefSegToEnd(TrackSegmentCamAtNu* seg)//void AddAssocTriToEnd(TrackSegmentAtNu* segment);
00416 {
00417   fEndPreferredSegList.push_back(seg);
00418   return;
00419 }
00421 
00422 
00424 TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetPrefSegBeg(unsigned int i)//TrackSegmentAtNu* GetAssocTriBegAt(Int_t i);
00425 {
00426   if(i<fBegPreferredSegList.size()) {return fBegPreferredSegList[i];}
00427   else return 0;
00428 }
00430 
00431 
00433 TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetPrefSegEnd(unsigned int i)//TrackSegmentAtNu* GetAssocTriEndAt(Int_t i);
00434 {
00435   if(i<fEndPreferredSegList.size())  {return fEndPreferredSegList[i];}
00436   else return 0;
00437 }
00439 
00440 
00442 void TrackSegmentCamAtNu::AddMatchSegToBeg(TrackSegmentCamAtNu* seg)//void AddSegToBeg(TrackSegmentAtNu* segment);
00443 {
00444   fBegMatchedSegList.push_back(seg);
00445   return;
00446 }
00448 
00449 
00451 void TrackSegmentCamAtNu::AddMatchSegToEnd(TrackSegmentCamAtNu* seg)//void AddSegToEnd(TrackSegmentAtNu* segment)
00452 {
00453   fEndMatchedSegList.push_back(seg);
00454   return;
00455 }
00457 
00458 
00460 TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetMatchSegBeg(unsigned int i)//TrackSegmentAtNu* GetSegBegAt(Int_t i)
00461 {
00462   if(i<fBegMatchedSegList.size()) {return fBegMatchedSegList[i];}
00463   else return 0;
00464 }
00466 
00467 
00469 TrackSegmentCamAtNu* TrackSegmentCamAtNu::GetMatchSegEnd(unsigned int i)//TrackSegmentAtNu* GetSegEndAt(Int_t i)
00470 {
00471   if(i<fEndMatchedSegList.size()) {return fEndMatchedSegList[i];}
00472   else return 0;
00473 }
00475 
00476 
00478 int TrackSegmentCamAtNu::GetPlaneView() const
00479 {
00480   return fPlaneView;
00481 }
00483 
00484 
00486 double TrackSegmentCamAtNu::GetScore(vector<TrackSegmentCamAtNu*> *BegSegBank, vector<TrackSegmentCamAtNu*> *EndSegBank)
00487 {
00488   int begplane2, begplane1, endplane1, endplane2;
00489   int nplane, plane;
00490   
00491   vector<ClusterCamAtNu*> TempContainer;
00492   bool IsInTemp;
00493 
00494   
00495   //Store the beginning and end of the segment locally
00496   begplane1=this->GetBegPlane();
00497   endplane1=this->GetEndPlane();
00498   begplane2=this->GetBegPlane();
00499   endplane2=this->GetEndPlane();
00500   //
00501   //  begplane2============begplane1===========endplane1============endplane2
00502   //            BegSegBank             this              EndSegBank
00503   //
00504 
00505   // Store pointers to all clusters
00506   unsigned int nclusters = this->GetEntries();  
00507   for(unsigned int i=0; i<nclusters; ++i) {
00508     TempContainer.push_back(this->GetCluster(i));
00509   }
00510 
00511   unsigned int nsegments;
00512   unsigned int nclustersintemp;
00513   int tempplane;
00514   if(BegSegBank) {
00515     nsegments = (*BegSegBank).size();
00516     for(unsigned int j=0; j<nsegments; ++j) {
00517       //looking for the earliest plane in the Beginning Segments
00518       tempplane = (*BegSegBank)[j]->GetBegPlane();
00519       if(tempplane<begplane2) begplane2=tempplane;
00520       //Loop over clusters in this segment and add any we don't have
00521       nclusters=(*BegSegBank)[j]->GetEntries();
00522       for(unsigned int k=0; k<nclusters; ++k) {
00523         ClusterCamAtNu* clust = (*BegSegBank)[j]->GetCluster(k);
00524         
00525         IsInTemp=false;
00526         nclustersintemp = TempContainer.size();
00527         for(unsigned int l=0; l<nclustersintemp; ++l) {
00528           if(TempContainer[l]==clust) {IsInTemp=true; break;}
00529         }
00530         if(IsInTemp==false) {TempContainer.push_back(clust);}
00531       }
00532     }
00533   }
00534 
00535   if(EndSegBank) {
00536     nsegments = (*EndSegBank).size();
00537     for(unsigned int j=0; j<nsegments; ++j) {
00538       //looking for the latest plane in the End Segments
00539       tempplane = (*EndSegBank)[j]->GetEndPlane();
00540       if(tempplane>endplane2) endplane2=tempplane;
00541       //Loop over clusters in this segment and add any we don't have
00542       nclusters = (*EndSegBank)[j]->GetEntries();
00543       for(unsigned int k=0; k<nclusters; ++k) {
00544         ClusterCamAtNu* clust = (*EndSegBank)[j]->GetCluster(k);
00545         
00546         IsInTemp=false;
00547         nclustersintemp = TempContainer.size();
00548         for(unsigned int l=0; l<nclustersintemp; ++l) {
00549           if(TempContainer[l]==clust) {IsInTemp=true; break;}
00550         }
00551         if(IsInTemp==false) {TempContainer.push_back(clust);}
00552       }
00553     }
00554   }
00555 
00556   //Convert planes to a single view co-ordinate system where begplane2 = 0;
00557   begplane1-=begplane2; begplane1/=2;
00558   endplane1-=begplane2; endplane1/=2;
00559   endplane2-=begplane2; endplane2/=2;
00560 
00561   //calculate the number of planes we will be considering
00562   nplane=1+endplane2;
00563   double* T = new double[nplane];
00564   double* Z = new double[nplane];
00565   double* W = new double[nplane];
00566   for(int i=0; i<nplane; ++i) {T[i]=0.; Z[i]=0.; W[i]=0.;}
00567 
00568   int km, kp;  
00569   double m,c;
00570   double dt2,sn;
00571   double score, dstraightness, straightness, expected;
00572   double sw, swz, swt, swzt, swzz;
00573   unsigned int nhits;
00574 
00575   nclusters = TempContainer.size();
00576 
00577   for(unsigned int k=0; k<nclusters; ++k) {
00578     ClusterCamAtNu* clust = TempContainer[k];
00579     //Convert clust->GetPlane() to a single view co-ordinate system where begplane2 = 0;
00580     plane=(clust->GetPlane()-begplane2)/2;
00581 
00582     if(!(plane<0 || plane>=nplane)) {
00583       sw=0.; swz=0.; swt=0.;
00584       nhits = clust->GetEntries();
00585       for(unsigned int k1=0; k1<nhits; ++k1) {
00586         HitCamAtNu* hit = clust->GetHit(k1);
00587         
00588         swz+=hit->GetCharge()*hit->GetZPos();
00589         swt+=hit->GetCharge()*hit->GetTPos();
00590         sw+=hit->GetCharge();
00591       }
00592       
00593       if(sw>0.){
00594         Z[plane]=swz/sw; T[plane]=swt/sw;
00595         // Weight segments on planes spanned by seed segment. 
00596         // Deweight segments on other planes.
00597         if( plane+1>begplane1 && plane-1<endplane1 ) {W[plane]=5.;} 
00598         else {W[plane]=0.5;}
00599       }
00600     }
00601   }
00602     
00603     
00604   score=0.; straightness=0.; expected=0.;
00605   
00606   
00607   for(int k=0; k<nplane; ++k) {
00608 
00609     if(W[k]>0.){
00610       swz=0.; swt=0.; swzz=0.; swzt=0.; sw=0.; sn=0.;
00611       dstraightness=0.;
00612 
00613       km=k-5; kp=k+5;
00614             
00615       if(km<0) {km=0;}
00616       if(kp>nplane-1) {kp=nplane-1;}
00617       
00618 
00619       // Fit this section
00620       for(int k1=km; k1<kp+1; ++k1){
00621         if(W[k1]>0.) {
00622           swz+=W[k1]*Z[k1]; swt+=W[k1]*T[k1]; 
00623           swzz+=W[k1]*Z[k1]*Z[k1]; swzt+=W[k1]*Z[k1]*T[k1]; 
00624           sw+=W[k1]; sn+=1.;
00625         }
00626       }
00627       
00628       // Calculate deviation from fit at this plane
00629       if(sn>2.){
00630         m=(sw*swzt-swz*swt)/(sw*swzz-swz*swz);
00631         c=(swt*swzz-swz*swzt)/(sw*swzz-swz*swz);
00632 
00633         dt2=pow(T[k]-(m*Z[k]+c),2);
00634 
00635         if(dt2<1.e-5) {straightness+=1;}
00636         else {straightness+=dt2/1.e-5;}
00637         expected+=1;
00638       }
00639     }
00640   }
00641 
00642   // Protect against divide by zero
00643   if(expected==0) {expected=1; straightness=1;}
00644 
00645   score = 1.e4 + double(TempContainer.size()) - pow(straightness/expected,0.5);
00646 
00647   
00648   MSG("AlgTrackCamAtNuList", Msg::kVerbose) << " nclusters " << double(TempContainer.size()) 
00649                                         << " straightness " << pow(straightness/expected,0.5) 
00650                                         << " Score " << score 
00651                                         << " begplane " << this->GetBegPlane() << " endplane " << this->GetEndPlane()
00652                                         << " begtpos " << this->GetBegTPos() << " endtpos " << this->GetEndTPos() << endl;
00653 
00654 //   MSG("AlgTrackCamAtNuList", Msg::kVerbose) << "Clusters involved: " << endl;
00655   
00656 //   for(unsigned int i=0; i<TempContainer.size(); ++i) {
00657 //     MSG("AlgTrackCamAtNuList", Msg::kVerbose) << "plane " << TempContainer[i]->GetPlane() << " begtpos " << TempContainer[i]->GetBegTPos() 
00658 //                                        << " endtpos " << TempContainer[i]->GetEndTPos() << endl;
00659 //   }
00660 
00661 //   MSG("AlgTrackCamAtNuList", Msg::kVerbose) << "----------------------" << endl;
00662 
00663 
00664   if(score<0.) {score=0.;}
00665  
00666   if(T) {delete [] T;}
00667   if(Z) {delete [] Z;}
00668   if(W) {delete [] W;}
00669 
00670   return score;
00671 }

Generated on Mon Feb 15 11:07:43 2010 for loon by  doxygen 1.3.9.1