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

CellListKG.cxx

Go to the documentation of this file.
00001 
00002 // Cluster3D package
00003 //
00004 // CellListKG.cxx
00005 //
00006 // CellListKG - list of cells
00007 //
00008 // Author:  Katarzyna Grzelak K.Grzelak1@physics.ox.ac.uk
00009 //
00011 #include <cstdlib>
00012 #include <cmath>
00013 
00014 #include "Cluster3D/CellListKG.h"
00015 #include "Algorithm/AlgConfig.h"
00016 #include "Cluster3D/StripListKG.h"
00017 #include "MessageService/MsgService.h" // needed for CVS
00018 #include "Cluster3D/StripKG.h"
00019 #include "Cluster3D/PlaneKG.h"
00020 
00021 ClassImp(CellListKG)
00022 
00023 CVSID("$Id: CellListKG.cxx,v 1.6 2009/02/28 21:46:11 gmieg Exp $");
00024 
00025 CellListKG::CellListKG(){
00026 //
00027 //  Purpose:  Default constructor
00028 //
00029   MSG("Cluster3D", Msg::kDebug)
00030     << "Default constructor " << endl;
00031 }
00032 
00033 //............................................................................
00034 
00035 void CellListKG::GetCells(vector<CellKG> &allcell) const{
00036 //
00037 //  Purpose:  Return STL vector with cells
00038 //
00039 //  Arguments: vector<CellKG> &allcell out - cells
00040 //              
00041 //  Return:  n/a
00042 //
00043 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00044 //
00045 //
00046 //  Program Notes:-
00047 //  =============
00048 //
00049 
00050     allcell=allcells;
00051 }
00052 
00053 //............................................................................
00054 
00055 UInt_t CellListKG::GetNCells() const{
00056 //
00057 //  Purpose:  Returns number of cells 
00058 //
00059 //  Arguments: n/a
00060 //                         
00061 //  Return:  allcells.size()  -  number of cells 
00062 //
00063 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00064 //
00065 //
00066 //  Program Notes:-
00067 //  =============
00068 //
00069   return allcells.size();
00070 }
00071 
00072 //............................................................................
00073 
00074 void CellListKG::CreateCells(AlgConfig &ac, StripListKG &all1){
00075 //
00076 //  Purpose:  Create cells
00077 //
00078 //  Arguments: 
00079 //              
00080 //  Return:  n/a
00081 //
00082 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00083 //
00084 //
00085 //  Program Notes:-
00086 //  =============
00087 //
00088 
00089 
00090   Int_t cellnb=0;
00091 
00092   Int_t nstrips=all1.GetNStrips();
00093 
00094   vector<PlaneKG> allpl;
00095 
00096   allpl.clear();  
00097 
00098   for(Int_t i=0;i<nstrips;++i){
00099 
00100     Int_t ithPlaneNb=all1.GetStripPlane(i);
00101     
00102     PlaneKG p;
00103 
00104     if(i==0){
00105       p.Create(all1,ithPlaneNb);
00106       allpl.push_back(p);
00107     }
00108     else{
00109        Int_t i1thPlaneNb=all1.GetStripPlane(i-1);
00110        if(ithPlaneNb != i1thPlaneNb){
00111          p.Create(all1,ithPlaneNb);
00112          allpl.push_back(p);
00113        }    
00114     }
00115   }
00116 
00117   const Int_t crosstalk = ac.GetInt("xTalk");
00118   const Int_t cdist = ac.GetInt("maxDist");
00119   const Int_t timing = ac.GetInt("timeInfo");
00120 
00121   Int_t fNbStpInNextPl=0;
00122   Int_t fNbStpInThisPl=0;
00123 
00124   for(Int_t i=0;i<nstrips;++i){
00125 
00126     Int_t ithPlaneNb=all1.GetStripPlane(i);
00127     Int_t ithPlaneXTalk=all1.GetStripXTalk(i);
00128     Int_t ithStripNb=all1.GetStripStrip(i);
00129 
00130     MSG("Cluster3D", Msg::kDebug) << "i= " << i 
00131         << " ithPlaneNb  = " << ithPlaneNb
00132         << " ithStripNb  = " << ithStripNb
00133         << " ithPlaneXTalk  = " << ithPlaneXTalk << endl;
00134 
00135     fNbStpInThisPl=all1.NbStpInPlane(ithPlaneNb,allpl);
00136 
00137     if(crosstalk && ithPlaneXTalk){
00138       continue;
00139     }
00140  
00141     Float_t t1t2,timPos,hBox;
00142     Float_t t1t2f,timPosf,hBoxf;
00143 
00144     Int_t counter=0;
00145 
00146     for(Int_t j=i+1;j<nstrips;++j){
00147 
00148     Int_t jthPlaneNb=all1.GetStripPlane(j);
00149     Int_t jthPlaneXTalk=all1.GetStripXTalk(j);
00150     Int_t jthStripNb=all1.GetStripStrip(j);
00151 
00152      if(crosstalk && jthPlaneXTalk){
00153        continue;
00154      }
00155 
00156      // Strips are sorted wedlug planes
00157 
00158      if( abs(ithPlaneNb-jthPlaneNb) > cdist ){
00159        break;
00160      }
00161 
00162      if(all1.OppViewNeighbours(ithPlaneNb,jthPlaneNb,cdist)){
00163       ++counter;
00164 
00165       fNbStpInNextPl=all1.NbStpInPlane(jthPlaneNb,allpl);
00166 
00167  
00168           Bool_t oneStp; 
00169           // if 1 or 2 strips per plane -> widen the time window 
00170           if(fNbStpInNextPl==1 && timing){
00171              oneStp=true;
00172              all1.GetTimePos(j,ac,oneStp,t1t2, timPos, hBox);
00173           }
00174           else{
00175              oneStp=false;
00176              all1.GetTimePos(j,ac,oneStp,t1t2, timPos, hBox);
00177           }
00178 
00179 
00180           if(fNbStpInThisPl==1 && timing){
00181              oneStp=true;
00182              all1.GetTimePos(i,ac,oneStp,t1t2f, timPosf, hBoxf);
00183           }
00184           else{
00185              oneStp=false;
00186              all1.GetTimePos(i,ac,oneStp,t1t2f, timPosf, hBoxf);
00187           }
00188 
00189 
00190           if( ( ithStripNb < Int_t(timPos+hBox+1) 
00191              && ithStripNb > Int_t(timPos-hBox-1)
00192              && jthStripNb < Int_t(timPosf+hBoxf+1)
00193              && jthStripNb > Int_t(timPosf-hBoxf-1) ) 
00194              ){ 
00195               CellKG c1,c2;
00196 
00197               if(c1.Create(i,j,all1,1,allcells,cellnb)){
00198                 allcells.push_back(c1);
00199               }
00200               if(c2.Create(i,j,all1,2,allcells,cellnb)){
00201                 allcells.push_back(c2);
00202               }                
00203           }              
00204             // Plots
00205 
00206           // All strips from this plane checked
00207           if(counter==fNbStpInNextPl) break; 
00208      }
00209     //else{
00210     //  continue;
00211     //}      
00212 
00213     // End of inner loop
00214     }
00215 
00216     // If no cell was created (no strips in opposite plane/s)
00217     // create one long cell
00218     if(counter==0){
00219       CellKG c;
00220 
00221       if(c.Create(i,all1,allcells,cellnb)){
00222           allcells.push_back(c);
00223       }      
00224     }
00225     
00226   // End of outer loop 
00227   }
00228   for(UInt_t ij=0;ij<allcells.size();++ij){
00229      MSG("Cluster3D", Msg::kDebug)
00230                         << "allcells[ij].index= "
00231                         << allcells[ij].index
00232                         << " allcells[ij].plane= "
00233                         << allcells[ij].plane 
00234                          << " allcells[ij].v= "
00235                         << allcells[ij].v
00236                          << " allcells[ij].u= "
00237                         << allcells[ij].u
00238                         << endl;
00239 
00240   }
00241 }
00242 //............................................................................
00243 
00244 Bool_t CellListKG::IsNeighbour(Int_t index1, Int_t index2, Int_t plnDistInp, Int_t stpDistInp){
00245 //
00246 //  Purpose:  Are c1 and c2 cells neighbours ?
00247 //
00248 //  Arguments: index1      out - STL index of the first cell
00249 //             index2      out - STL index of the second cell
00250 //  Return:  true/false
00251 //
00252 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00253 //
00254 //
00255 //  Program Notes:-
00256 //  =============
00257 //
00258 
00259   const Float_t plnDist = plnDistInp*(5.94*0.01+0.01);
00260   const Float_t stpDist = stpDistInp*(4.1*0.01+0.01);
00261 
00262   Float_t distU = 0.;
00263   if( (fabs(this->GetCellU(index1)) == 9999) || (fabs(this->GetCellU(index2)) == 9999) ){
00264     distU = -9999;
00265   }    
00266   else{  
00267     distU = fabs((this->GetCellU(index1))-(this->GetCellU(index2)));
00268   }
00269 
00270   Float_t distV = 0.;
00271   if( (fabs(this->GetCellV(index1)) == 9999) || (fabs(this->GetCellV(index2)) == 9999) ){
00272     distV = -9999;
00273   }    
00274   else{  
00275     distV = fabs((this->GetCellV(index1))-(this->GetCellV(index2)));
00276   }
00277 
00278   Float_t distZ = fabs((this->GetCellZ(index1))-(this->GetCellZ(index2)));
00279 
00280   // To treat correctly a gap between modules
00281 
00282   Int_t c1pos=this->GetCellPlane(index1);
00283   Int_t c2pos=this->GetCellPlane(index2);
00284 
00285   Bool_t gap = false;
00286 
00287 
00288   if( (c1pos == 248 && c2pos == 250) || (c2pos == 248 && c1pos == 250) ){
00289     gap=true;
00290   } 
00291 
00292 
00293   // Jesli c1=c2. W przyszlosci powinno sie to robic po indeksach celi
00294   if((fabs(distU-stpDist)<0.001) && (fabs(distV-stpDist)<0.001) 
00295      && (fabs(distZ-plnDist)<0.001) ){
00296     return false;
00297   }  
00298 
00299   if( gap && (distU < stpDist) && (distV < stpDist) ){
00300     return true;
00301   }
00302   else{
00303      if((distU < stpDist) && (distV < stpDist) && (distZ < plnDist) ){
00304        return true;
00305      }
00306      else{
00307        return false;
00308      }
00309   }    
00310 }
00311 
00312 //............................................................................
00313 
00314 Int_t CellListKG::GetCellIndex(UInt_t index) const{
00315 //
00316 //  Purpose:  Return cell index  
00317 //
00318 //  Arguments:
00319 //           index        in  -  index of a cell in STL vector     
00320 //              
00321 //  Return: Cell number 
00322 //
00323 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00324 //
00325 //
00326 //  Program Notes:-
00327 //  =============
00328 //
00329 
00330   return allcells[index].index;
00331 }
00332 
00333 //............................................................................
00334 
00335 Int_t CellListKG::GetCellPlane(UInt_t index) const{
00336 //
00337 //  Purpose:  Return plane number of a cell  
00338 //
00339 //  Arguments:
00340 //           index        in  -  index of a cell in STL vector     
00341 //              
00342 //  Return: Plane number
00343 //
00344 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00345 //
00346 //
00347 //  Program Notes:-
00348 //  =============
00349 //
00350 
00351   return allcells[index].plane;
00352 }
00353 
00354 //............................................................................
00355 
00356 Float_t CellListKG::GetCellU(UInt_t index) const{
00357 //
00358 //  Purpose:  Return u position of a cell  
00359 //
00360 //  Arguments:
00361 //           index        in  -  index of a cell in STL vector     
00362 //              
00363 //  Return: U coordinate
00364 //
00365 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00366 //
00367 //
00368 //  Program Notes:-
00369 //  =============
00370 //
00371 
00372   return allcells[index].u;
00373 }
00374 
00375 //............................................................................
00376 
00377 Float_t CellListKG::GetCellV(UInt_t index) const{
00378 //
00379 //  Purpose:  Return v position of a cell  
00380 //
00381 //  Arguments:
00382 //           index        in  -  index of a cell in STL vector     
00383 //              
00384 //  Return: V coordinate
00385 //
00386 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00387 //
00388 //
00389 //  Program Notes:-
00390 //  =============
00391 //
00392 
00393   return allcells[index].v;
00394 }
00395 
00396 //............................................................................
00397 
00398 Float_t CellListKG::GetCellZ(UInt_t index) const{
00399 //
00400 //  Purpose:  Return z position of a cell  
00401 //
00402 //  Arguments:
00403 //           index        in  -  index of a cell in STL vector     
00404 //              
00405 //  Return: Z coordinate
00406 //
00407 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00408 //
00409 //
00410 //  Program Notes:-
00411 //  =============
00412 //
00413 
00414   return allcells[index].z;
00415 }
00416 
00417 //............................................................................
00418 
00419 Int_t CellListKG::GetCellView(UInt_t index) const{
00420 //
00421 //  Purpose:  Return plane view  
00422 //
00423 //  Arguments:
00424 //           index        in  -  index of a cell in STL vector     
00425 //              
00426 //  Return: Plane view
00427 //
00428 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00429 //
00430 //
00431 //  Program Notes:-
00432 //  =============
00433 //
00434 
00435   return allcells[index].planeview;
00436 }
00437 
00438 //............................................................................
00439 
00440 UInt_t CellListKG::GetCellElem1(UInt_t index) const{
00441 //
00442 //  Purpose:  Return index of a first strip ehich makes a cell  
00443 //
00444 //  Arguments:
00445 //           index        in  -  index of a cell in STL vector     
00446 //              
00447 //  Return: index of a first strip 
00448 //
00449 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00450 //
00451 //
00452 //  Program Notes:-
00453 //  =============
00454 //
00455 
00456   return allcells[index].elem1;
00457 }
00458 
00459 //............................................................................
00460 
00461 UInt_t CellListKG::GetCellElem2(UInt_t index) const{
00462 //
00463 //  Purpose:  Return index of a second strip ehich makes a cell  
00464 //
00465 //  Arguments:
00466 //           index        in  -  index of a cell in STL vector     
00467 //              
00468 //  Return: index of a second strip 
00469 //
00470 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00471 //
00472 //
00473 //  Program Notes:-
00474 //  =============
00475 //
00476 
00477   return allcells[index].elem2;
00478 }

Generated on Mon Feb 15 11:06:31 2010 for loon by  doxygen 1.3.9.1