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

StripListKG.cxx

Go to the documentation of this file.
00001 
00002 // Cluster3D package
00003 //
00004 // StripListKG.cxx
00005 //
00006 // StripListKG - list of strips
00007 //
00008 // Author:  Katarzyna Grzelak K.Grzelak1@physics.ox.ac.uk
00009 //
00011 #include <algorithm>
00012 #include <cstdlib>
00013 
00014 #include "Cluster3D/StripListKG.h"
00015 #include "Algorithm/AlgConfig.h"
00016 #include "MessageService/MsgService.h" // needed for CVS
00017 #include "Cluster3D/StripKG.h"
00018 #include "Cluster3D/PlaneKG.h"
00019 #include "RecoBase/CandStripHandle.h"     
00020 #include "RecoBase/CandSliceHandle.h"     
00021 #include "UgliGeometry/UgliGeomHandle.h"   // UgliGeom handling
00022 
00023 ClassImp(StripListKG)
00024 
00025 CVSID("$Id: StripListKG.cxx,v 1.4 2009/02/28 21:46:11 gmieg Exp $");
00026 
00027 //............................................................................
00028 
00029 Bool_t StripSortCriterion (const StripKG &s1, const StripKG &s2){
00030 //
00031 //  Purpose:  Rules how to sort STL vector of strips  
00032 //
00033 //  Arguments: 
00034 //            in   s1 - first strip
00035 //            in   s2 - second strip
00036 //
00037 //  Return:  boolean variable
00038 //
00039 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00040 //
00041 //
00042 //  Program Notes:-
00043 //  =============
00044 //
00045 // Strip is "less" than another strip if number of plane is smaller
00046 // 
00047   
00048       if(s1.plane == s2.plane){
00049          return (s1.strip < s2.strip);
00050       }
00051       else{
00052          return (s1.plane < s2.plane); 
00053       } 
00054 } 
00055 
00056 //............................................................................
00057 
00058 StripListKG::StripListKG():energyRaw(0.),energyPe(0.),energyGeV(0.){
00059 //
00060 //  Purpose:  Default constructor
00061 //
00062 }
00063 
00064 //............................................................................
00065 
00066 void StripListKG::GetStrips(vector<StripKG> &allstp) const{
00067 //
00068 //  Purpose:  Return STL vector of strips
00069 //
00070 //  Arguments: 
00071 //
00072 //  Return:  n/a
00073 //
00074 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00075 //
00076 //
00077 //  Program Notes:-
00078 //  =============
00079 //
00080 
00081     allstp=allstps;
00082 }
00083 
00084 //............................................................................
00085 
00086 UInt_t StripListKG::GetNStrips() const{
00087 //
00088 //  Purpose:  Return number of strips
00089 //
00090 //  Arguments: 
00091 //              
00092 //  Return:  
00093 //
00094 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00095 //
00096 //
00097 //  Program Notes:-
00098 //  =============
00099 //
00100 
00101   return allstps.size();
00102 }
00103 
00104 //............................................................................
00105 
00106 void StripListKG::SetEnergy(){
00107 //
00108 //  Purpose:  Sets energy
00109 //
00110 //  Arguments: 
00111 //              
00112 //  Return:  n/a
00113 //
00114 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00115 //
00116 //
00117 //  Program Notes:-
00118 //  =============
00119 //
00120   for(UInt_t i=0; i<allstps.size(); ++i){
00121     energyPe=energyPe+allstps[i].peE+allstps[i].peW;
00122     energyRaw=energyRaw+allstps[i].rawE+allstps[i].rawW; 
00123   } 
00124 }
00125 
00126 //............................................................................
00127 
00128 Double_t StripListKG::GetEnergy(Int_t whatKind) const{
00129 //
00130 //  Purpose:  Return energy
00131 //
00132 //  Arguments: 
00133 //              
00134 //  Return:  
00135 //
00136 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00137 //
00138 //
00139 //  Program Notes:-
00140 //  =============
00141 //
00142 
00143   if(whatKind==0){
00144     return energyRaw;
00145   }
00146   else if(whatKind==1){
00147     return energyPe;
00148   }
00149   else if(whatKind==2){
00150     return energyGeV;
00151   }
00152   else{
00153     return energyPe;
00154   }
00155 
00156   return energyPe;
00157 }
00158 
00159 //............................................................................
00160 
00161 Bool_t StripListKG::OppViewNeighbours(Int_t planeNbInp1, Int_t planeNbInp2, Int_t cdist){
00162 //
00163 //  Purpose:  Return 
00164 //
00165 //  Arguments: 
00166 //              
00167 //  Return:  n/a
00168 //
00169 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00170 //
00171 //
00172 //  Program Notes:-
00173 //  =============
00174 //
00175 
00176   Int_t dist = abs(planeNbInp1-planeNbInp2);
00177 
00178   if(dist%2!=0 && dist <= cdist){
00179     return true;
00180   }
00181   else{
00182     return false;
00183   }
00184 }
00185 
00186 //............................................................................
00187 
00188 Int_t StripListKG::NbStpInPlane(Int_t planeNbInp, const std::vector<PlaneKG> &p){
00189 //
00190 //  Purpose:  Return 
00191 //
00192 //  Arguments: 
00193 //              
00194 //  Return:  
00195 //
00196 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00197 //
00198 //
00199 //  Program Notes:-
00200 //  =============
00201 //
00202 
00203   Int_t flag=0;
00204   Int_t ile=0;
00205   for(UInt_t j=0; j<p.size(); ++j){
00206     if(planeNbInp==p[j].number){
00207       flag=1;
00208       ile = p[j].nstppplane;
00209       break;
00210     }
00211     else{
00212       continue;
00213     }
00214   }
00215   if(flag==1){
00216     return ile;
00217   }
00218   else{
00219     cout << "NbStpInPlane : Strip belongs to an unknown plane " << endl;
00220     return 0;
00221   }
00222 }
00223 
00224 //............................................................................
00225 
00226 void StripListKG::CreateStrips(AlgConfig &ac, const CandSliceHandle* slice, UgliGeomHandle *ugh){
00227 //
00228 //  Purpose:  Create strips
00229 //
00230 //  Arguments: 
00231 //              
00232 //  Return:  
00233 //
00234 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00235 //
00236 //
00237 //  Program Notes:-
00238 //  =============
00239 //
00240 
00241   const Int_t xtalkmod = ac.GetInt("xTalkMode");
00242 
00243 
00244   CandStripHandleItr stripItr(slice->GetDaughterIterator());
00245   //while (CandStripHandle *strip = stripItr()) {
00246   Int_t nstrips = slice->GetNStrip();
00247 
00248   MSG("Cluster3D", Msg::kDebug)
00249                         << "Create strip list"
00250                         << "nstrips = " << nstrips 
00251                         << endl;
00252 
00253   Int_t i=0;
00254   StripKG s;
00255   
00256   while (stripItr.IsValid()) {
00257 
00258      CandStripHandle *strip = stripItr.Ptr();
00259 
00260      s.Set(strip,ugh,i);    
00261      allstps.push_back(s); 
00262 
00263      ++i;  
00264      stripItr.Next();  
00265   }
00266   stable_sort(allstps.begin(),allstps.end(),StripSortCriterion);
00267 
00268   for(UInt_t ii=0;ii<allstps.size();++ii){
00269 
00270     if(xtalkmod==1){
00271         allstps[i].XTalk(ac);
00272     }
00273     else{
00274       if(FirstInPlane(ii) && LastInPlane(ii)){
00275          allstps[ii].XTalk(ac);
00276       }
00277       else if(FirstInPlane(ii)){
00278          Int_t dist1 = allstps[ii+1].strip-allstps[ii].strip;
00279          if(dist1>5){
00280             allstps[ii].XTalk(ac);
00281          }         
00282       }
00283       else if(LastInPlane(ii)){
00284          Int_t dist2 = allstps[ii].strip-allstps[ii-1].strip;
00285          if(dist2>5){
00286             allstps[ii].XTalk(ac);
00287          }
00288       }
00289       else{
00290          Int_t dist1 = allstps[ii+1].strip-allstps[ii].strip;
00291          Int_t dist2 = allstps[ii].strip-allstps[ii-1].strip;
00292          if(dist1>5 && dist2>5){
00293             allstps[ii].XTalk(ac);
00294          }
00295       } 
00296       MSG("Cluster3D", Msg::kDebug)
00297                         << " allstps[ii].plane= "
00298                         << allstps[ii].plane 
00299                         << " allstps[ii].strip= "
00300                         << allstps[ii].strip 
00301                         << " allstps[ii].xtalk= "
00302                         << allstps[ii].xtalk 
00303                         << endl;    
00304     }
00305   }
00306 }
00307 
00308 //............................................................................
00309 
00310 CandStripHandle* StripListKG::GetStripHandle(UInt_t index) const{
00311 //
00312 //  Purpose:  Return handle to a strip  
00313 //
00314 //  Arguments:
00315 //           index        in  -  index of a strip in STL vector     
00316 //              
00317 //  Return: CandStripHandle* handle
00318 //
00319 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00320 //
00321 //
00322 //  Program Notes:-
00323 //  =============
00324 //
00325 
00326   return allstps[index].handle;
00327 }
00328 
00329 //............................................................................
00330 
00331 Int_t StripListKG::GetStripIndex(UInt_t index) const{
00332 //
00333 //  Purpose:  Return strip index  
00334 //
00335 //  Arguments:
00336 //           index        in  -  index of a strip in STL vector     
00337 //              
00338 //  Return: Strip number 
00339 //
00340 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00341 //
00342 //
00343 //  Program Notes:-
00344 //  =============
00345 //
00346 
00347   return allstps[index].index;
00348 }
00349 
00350 //............................................................................
00351 
00352 Int_t StripListKG::GetStripStrip(UInt_t index) const{
00353 //
00354 //  Purpose:  Return strip number  
00355 //
00356 //  Arguments:
00357 //           index        in  -  index of a strip in STL vector     
00358 //              
00359 //  Return: Strip number 
00360 //
00361 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00362 //
00363 //
00364 //  Program Notes:-
00365 //  =============
00366 //
00367 
00368   return allstps[index].strip;
00369 }
00370 
00371 //............................................................................
00372 
00373 Int_t StripListKG::GetStripPlane(UInt_t index) const{
00374 //
00375 //  Purpose:  Return plane number of a strip 
00376 //
00377 //  Arguments:
00378 //           index        in  -  index of a strip in STL vector     
00379 //              
00380 //  Return: Plane number 
00381 //
00382 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00383 //
00384 //
00385 //  Program Notes:-
00386 //  =============
00387 //
00388 
00389   return allstps[index].plane;
00390 }
00391 
00392 //............................................................................
00393 
00394 Float_t StripListKG::GetStripTPos(UInt_t index) const{
00395 //
00396 //  Purpose:  Return transverse position of a strip 
00397 //
00398 //  Arguments:
00399 //           index        in  -  index of a strip in STL vector     
00400 //              
00401 //  Return: Transverse position  
00402 //
00403 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00404 //
00405 //
00406 //  Program Notes:-
00407 //  =============
00408 //
00409 
00410   return allstps[index].tpos;
00411 }
00412 
00413 //............................................................................
00414 
00415 Float_t StripListKG::GetStripZPos(UInt_t index) const{
00416 //
00417 //  Purpose:  Return z position of a strip 
00418 //
00419 //  Arguments:
00420 //           index        in  -  index of a strip in STL vector     
00421 //              
00422 //  Return: Z position  
00423 //
00424 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00425 //
00426 //
00427 //  Program Notes:-
00428 //  =============
00429 //
00430 
00431   return allstps[index].zpos;
00432 }
00433 
00434 //............................................................................
00435 
00436 Int_t StripListKG::GetStripView(UInt_t index) const{
00437 //
00438 //  Purpose:  Return plane view 
00439 //
00440 //  Arguments:
00441 //           index        in  -  index of a strip in STL vector     
00442 //              
00443 //  Return: Plane view  
00444 //
00445 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00446 //
00447 //
00448 //  Program Notes:-
00449 //  =============
00450 //
00451 
00452   return allstps[index].planeview;
00453 }
00454 
00455 //............................................................................
00456 
00457 Double_t StripListKG::GetStripRawE(UInt_t index) const{
00458 //
00459 //  Purpose:  Return energy in ADC 
00460 //
00461 //  Arguments:
00462 //           index        in  -  index of a strip in STL vector     
00463 //              
00464 //  Return: Energy in ADC for E strip end
00465 //
00466 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00467 //
00468 //
00469 //  Program Notes:-
00470 //  =============
00471 //
00472 
00473   return allstps[index].rawE;
00474 }
00475 
00476 //............................................................................
00477 
00478 Double_t StripListKG::GetStripRawW(UInt_t index) const{
00479 //
00480 //  Purpose:  Return energy in ADC 
00481 //
00482 //  Arguments:
00483 //           index        in  -  index of a strip in STL vector     
00484 //              
00485 //  Return: Energy in ADC for W strip end
00486 //
00487 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00488 //
00489 //
00490 //  Program Notes:-
00491 //  =============
00492 //
00493 
00494   return allstps[index].rawW;
00495 }
00496 
00497 //............................................................................
00498 
00499 Double_t StripListKG::GetStripPeE(UInt_t index) const{
00500 //
00501 //  Purpose:  Return energy in pe 
00502 //
00503 //  Arguments:
00504 //           index        in  -  index of a strip in STL vector     
00505 //              
00506 //  Return: Energy in pe for E end
00507 //
00508 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00509 //
00510 //
00511 //  Program Notes:-
00512 //  =============
00513 //
00514 
00515   return allstps[index].peE;
00516 }
00517 
00518 //............................................................................
00519 
00520 Double_t StripListKG::GetStripPeW(UInt_t index) const{
00521 //
00522 //  Purpose:  Return energy in pe 
00523 //
00524 //  Arguments:
00525 //           index        in  -  index of a strip in STL vector     
00526 //              
00527 //  Return: Energy in pe for W end
00528 //
00529 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00530 //
00531 //
00532 //  Program Notes:-
00533 //  =============
00534 //
00535 
00536   return allstps[index].peW;
00537 }
00538 
00539 //............................................................................
00540 
00541 Int_t StripListKG::GetStripXTalk(UInt_t index) const{
00542 //
00543 //  Purpose:  Return crosstalk flag for a strip 
00544 //
00545 //  Arguments:
00546 //           index        in  -  index of a strip in STL vector     
00547 //              
00548 //  Return:  XTalk flag 
00549 //
00550 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00551 //
00552 //
00553 //  Program Notes:-
00554 //  =============
00555 //
00556 
00557   return allstps[index].xtalk;
00558 }
00559 
00560 //............................................................................
00561 
00562 void StripListKG::GetTimePos(UInt_t index, AlgConfig &ac, Bool_t oneStp, Float_t &dt, Float_t &timpos, Float_t &halflength){
00563 //
00564 //  Purpose:  Return hit position from timing information for a strip 
00565 //
00566 //  Arguments:
00567 //           ac           in  -  AlgConfig 
00568 //           index        in  -  index of a strip in STL vector     
00569 //           oneStp       in  -  true = one hit per plane => use timing info
00570 //                               false = more than one hit => do not use timing
00571 //              
00572 //  Return:  
00573 //
00574 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00575 //
00576 //
00577 //  Program Notes:-
00578 //  =============
00579 //
00580 
00581   allstps[index].TimePos(ac, oneStp, dt, timpos, halflength);  
00582 }
00583 
00584 //............................................................................
00585 
00586 Bool_t StripListKG::FirstInPlane(UInt_t index){
00587 //
00588 //  Purpose:  Is this strip the first in plane ?
00589 //
00590 //  Arguments:
00591 //           index        in  - position in vector allstps     
00592 //              
00593 //  Return:  
00594 //
00595 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00596 //
00597 //
00598 //  Program Notes:-
00599 //  =============
00600 //
00601   if(index==0){
00602     return true;
00603   }
00604   else{
00605     if(allstps[index-1].plane != allstps[index].plane){
00606       return true;  
00607     }
00608     else{
00609       return false;
00610     }
00611   }
00612 }
00613 
00614 //............................................................................
00615 
00616 Bool_t StripListKG::LastInPlane(UInt_t index){
00617 //
00618 //  Purpose:  Is this strip the last in plane ?
00619 //
00620 //  Arguments:
00621 //           index        in  - position in vector allstps     
00622 //              
00623 //  Return:  
00624 //
00625 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00626 //
00627 //
00628 //  Program Notes:-
00629 //  =============
00630 //
00631   if(index == allstps.size()-1){
00632      return true; 
00633   }
00634   else{
00635     if(allstps[index].plane != allstps[index+1].plane){
00636       return true;  
00637     }
00638     else{
00639       return false;
00640     }
00641   }
00642 }
00643 
00644 //............................................................................
00645 
00646 void StripListKG::SetStripAmbiguity(UInt_t index){
00647 //
00648 //  Purpose:  to how many clusters strip belongs
00649 //
00650 //  Arguments: 
00651 //            index    in  - position in vector allstps     
00652 //              
00653 //  Return:  n/a
00654 //
00655 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00656 //
00657 //
00658 //  Program Notes:-
00659 //  =============
00660 //
00661 
00662   allstps[index].ambig=allstps[index].ambig+1;  
00663 
00664 }
00665 
00666 //............................................................................
00667 
00668 Int_t StripListKG::GetStripAmbiguity(UInt_t index) const{
00669 //
00670 //  Purpose:  to how many clusters strip belongs
00671 //
00672 //  Arguments:             
00673 //           index        in  -  index of a strip in STL vector     
00674 //              
00675 //  Return:  
00676 //
00677 //  Contact:   K.Grzelak1@physics.ox.ac.uk
00678 //
00679 //
00680 //  Program Notes:-
00681 //  =============
00682 //
00683 
00684   return allstps[index].ambig;  
00685 
00686 }

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