BesMucDigit Class Reference

#include <BesMucDigit.hh>

List of all members.

Public Member Functions

 BesMucDigit ()
 ~BesMucDigit ()
void SetHit (BesMucHit *hit)
G4int GetTrackIndex ()
G4int GetPart ()
G4int GetSeg ()
G4int GetGap ()
G4VPhysicalVolume * GetNearestStrip ()
G4int GetNearestStripNo ()
G4VPhysicalVolume * GetStrip (G4int i)
G4float GetStripPos (G4VPhysicalVolume *pvStrip)
G4int IsNearest (G4int i)

Private Attributes

BesMucHitm_pHit
G4float m_Pos
G4float m_Pos2
G4LogicalVolume * m_lvGap
G4String m_lvGapName
G4VPhysicalVolume * m_pvStripDigit


Detailed Description

Definition at line 23 of file BesMucDigit.hh.


Constructor & Destructor Documentation

BesMucDigit::BesMucDigit (  ) 

Definition at line 21 of file BesMucDigit.cc.

00022 {
00023 }

BesMucDigit::~BesMucDigit (  ) 

Definition at line 25 of file BesMucDigit.cc.

00026 {
00027 }


Member Function Documentation

G4int BesMucDigit::GetGap (  )  [inline]

Definition at line 40 of file BesMucDigit.hh.

References BesMucHit::GetGap(), and m_pHit.

Referenced by BesMucDigitizer::Digitize(), and BesMucSD::ProcessHits().

00040 { return m_pHit->GetGap(); }

G4VPhysicalVolume * BesMucDigit::GetNearestStrip (  ) 

Definition at line 53 of file BesMucDigit.cc.

References GetNearestStripNo(), GetStrip(), and m_pvStripDigit.

Referenced by BesMucEfficiency::SetHit().

00054 {
00055   m_pvStripDigit = GetStrip( GetNearestStripNo() );
00056   if(!m_pvStripDigit) {
00057     G4cerr << "Nearest Strip is not found." << G4endl;
00058   }
00059 
00060   return m_pvStripDigit;
00061 }

G4int BesMucDigit::GetNearestStripNo (  ) 

Definition at line 63 of file BesMucDigit.cc.

References BesMucHit::GetGap(), BesMucHit::GetPart(), BesMucHit::GetSeg(), BesMucHit::GetStrip(), GetStrip(), GetStripPos(), BesMucHit::GetTrackID(), IsNearest(), m_pHit, m_Pos, and m_Pos2.

Referenced by BesMucDigitizer::Digitize(), GetNearestStrip(), BesMucSD::ProcessHits(), and BesMucEfficiency::SetHit().

00064 {
00065  if(m_pHit->GetTrackID()!=-1){
00066   G4float posStrip0 = GetStripPos( GetStrip(0) );
00067   G4float posStrip1 = GetStripPos( GetStrip(1) );
00068   G4float width = posStrip1 - posStrip0;
00069   //G4cout << "posStrip0 " << posStrip0 << " posStrip1 " << posStrip1 << G4endl;
00070 
00071   G4int iGuessStrip = G4int( (m_Pos - posStrip0)/width + 0.5 );
00072   // confine iGuessStrip to an extend before check IsNearest.
00073   if(iGuessStrip < 0) {
00074     iGuessStrip = 0;
00075   } 
00076   else if(iGuessStrip >= 112) {
00077     iGuessStrip = 112;
00078   }
00079   //G4cout << "m_pos=" << m_Pos << "firstly, I guess: " << iGuessStrip << G4endl;
00080   
00081   G4int step = IsNearest(iGuessStrip);
00082   while(step != 0) {
00083     //G4cout << "guess " << iGuessStrip << " wrong , iGuess " << step << G4endl;
00084     iGuessStrip += step;
00085     step = IsNearest(iGuessStrip);
00086   }
00087   //G4cout << " guess " << iGuessStrip << " right " << G4endl;
00088 
00089   //deal with barrel segment 2 gap%2!=0
00090   G4int part = m_pHit->GetPart();
00091   G4int seg  = m_pHit->GetSeg();
00092   G4int gap  = m_pHit->GetGap();
00093   //G4cout<<" in Digit   iGuessStrip = "<< iGuessStrip <<G4endl;
00094   if(part == 1 && seg == 2 &&gap%2 != 0 && iGuessStrip > 79 ){
00095     if(iGuessStrip > 79 && iGuessStrip <= 95 && m_Pos2 < 0) iGuessStrip += 16 ;
00096     if(iGuessStrip > 95 && iGuessStrip <= 111 && m_Pos2 > 0) iGuessStrip -= 16 ;
00097     //G4cout<<" in barrel segment 2 and gap%2!=0, and strip > 79  strip="<< iGuessStrip<<" posx="<<m_Pos2<<" "<<" posy="<<m_Pos<<G4endl;
00098   }
00099 
00100   return iGuessStrip;
00101  }
00102  else return m_pHit->GetStrip();
00103 }

G4int BesMucDigit::GetPart (  )  [inline]

Definition at line 38 of file BesMucDigit.hh.

References BesMucHit::GetPart(), and m_pHit.

Referenced by BesMucDigitizer::Digitize(), and BesMucSD::ProcessHits().

00038 { return m_pHit->GetPart(); }

G4int BesMucDigit::GetSeg (  )  [inline]

Definition at line 39 of file BesMucDigit.hh.

References BesMucHit::GetSeg(), and m_pHit.

Referenced by BesMucDigitizer::Digitize(), and BesMucSD::ProcessHits().

00039 { return m_pHit->GetSeg(); }

G4VPhysicalVolume * BesMucDigit::GetStrip ( G4int  i  ) 

Definition at line 106 of file BesMucDigit.cc.

References m_lvGap.

Referenced by GetNearestStrip(), GetNearestStripNo(), and IsNearest().

00107 {
00108   // If no strip get, return 0.
00109   // If i > daughtersNo, there will be run error.
00110   G4LogicalVolume *lvStripPlane = m_lvGap->GetDaughter(0)->GetLogicalVolume();
00111   G4int daughtersNo = lvStripPlane->GetNoDaughters();
00112   
00113   if(i >= 0 && i < daughtersNo) {
00114     G4VPhysicalVolume*  pvStrip = lvStripPlane->GetDaughter(i);
00115     G4String strStrip = pvStrip->GetLogicalVolume()->GetName();
00116     //G4cout << "length " << strStrip.length() << G4endl;
00117     //if(strStrip.length() == 30) { //use name length to determine whether it is a strip
00118 
00119     if (strStrip.find("s") == 10) { //"Strip" at 23 of "logicalMucPart1Seg0Gap0Strip111" 
00120       //"s" at 10 of lMucP0S0G0s001
00121       return pvStrip;
00122     }
00123     //return pvStrip;
00124   }
00125   
00126   return 0;
00127 }

G4float BesMucDigit::GetStripPos ( G4VPhysicalVolume *  pvStrip  ) 

Definition at line 129 of file BesMucDigit.cc.

References BesMucHit::GetGap(), BesMucHit::GetPart(), m_pHit, boss::pos, and subSeperate::temp.

Referenced by GetNearestStripNo(), and IsNearest().

00130 {
00131   G4float pos = 1.0e38;
00132   if (!pvStrip) return pos;
00133   
00134   G4int part = m_pHit->GetPart();
00135   G4int gap  = m_pHit->GetGap();
00136 
00137   pos = pvStrip->GetObjectTranslation().x();
00138   if ( (part == 1 && gap%2 != 0) || (part != 1 && gap%2 == 0) ) {
00139     pos = pvStrip->GetObjectTranslation().y();
00140   }
00141 
00142   G4String striptype= pvStrip->GetLogicalVolume()->GetSolid()->GetEntityType();
00143 //  G4String striplenght= pvStrip->GetLogicalVolume()->GetName();
00144   G4Box *temp;
00145   temp=(G4Box *)pvStrip->GetLogicalVolume()->GetSolid();
00146   G4double length=temp->GetXHalfLength();
00147 //  std::ostream length;
00148 //  pvStrip->GetLogicalVolume()->GetSolid()->StreamInfo( length);
00149 
00150   G4float  box1,box2,box3;
00151 //  length>>box1>>box2>>box3;
00152   //G4cout<<length<<" "<<striptype<<"         in GetStripPos   "<<pvStrip->GetObjectTranslation().x()<<" "<<pvStrip->GetObjectTranslation().y()<<" "<<pvStrip->GetObjectTranslation().z()<<G4endl;
00153   return pos; 
00154 } 

G4int BesMucDigit::GetTrackIndex (  )  [inline]

Definition at line 37 of file BesMucDigit.hh.

References BesMucHit::GetTrackIndex(), and m_pHit.

Referenced by BesMucDigitizer::Digitize().

00037 { return m_pHit->GetTrackIndex(); }

G4int BesMucDigit::IsNearest ( G4int  i  ) 

Definition at line 158 of file BesMucDigit.cc.

References abs, GetStrip(), GetStripPos(), and m_Pos.

Referenced by GetNearestStripNo().

00159 {
00160   G4float posMax = 1.0e38;
00161   G4float posLeftStrip;
00162   G4float posRightStrip;
00163   G4float posCurrentStrip;
00164 
00165   G4VPhysicalVolume* pvLeftStrip    = GetStrip(i-1);
00166   G4VPhysicalVolume* pvRightStrip   = GetStrip(i+1);
00167   G4VPhysicalVolume* pvCurrentStrip = GetStrip(i);
00168 
00169   if(i < 0) {
00170     return i;
00171   }
00172   else if(i == 0) {
00173     posLeftStrip    = -1.0*posMax;
00174     posRightStrip   = GetStripPos( pvRightStrip );
00175   }
00176   else if(!pvCurrentStrip) {
00177     // i > Max.
00178     return -1;
00179   }
00180   else if(!pvRightStrip) {
00181     // i = Max.
00182     posLeftStrip  = GetStripPos( pvLeftStrip );
00183     posRightStrip = posMax;
00184   }
00185   else {
00186     // 0 < i < Max.
00187     posLeftStrip  = GetStripPos( pvLeftStrip );
00188     posRightStrip = GetStripPos( pvRightStrip );
00189   }
00190   posCurrentStrip = GetStripPos( pvCurrentStrip );
00191 
00192    G4float distCurrent = std::abs(m_Pos - posCurrentStrip);
00193    G4float distLeft    = std::abs(m_Pos - posLeftStrip);
00194    G4float distRight   = std::abs(m_Pos - posRightStrip);
00195 
00196   //G4cout << "left " << distLeft << " current " << distCurrent << " right " << distRight << G4endl;
00197 
00198   if( (distCurrent <= distLeft) && (distCurrent <= distRight) ) {
00199     return 0;
00200   }
00201   else if(distCurrent > distLeft) {
00202     return -1;
00203   }
00204   else {
00205     return 1;
00206   }
00207 
00208 }

void BesMucDigit::SetHit ( BesMucHit hit  ) 

Definition at line 29 of file BesMucDigit.cc.

References BesMucHit::GetGap(), BesMucHit::GetPart(), BesMucHit::GetPosLocal(), BesMucHit::GetSeg(), BesMucHit::GetTrackID(), BesMucHit::GetVolume(), m_lvGap, m_lvGapName, m_pHit, m_Pos, and m_Pos2.

Referenced by BesMucDigitizer::Digitize(), BesMucSD::ProcessHits(), and BesMucEfficiency::SetHit().

00030 {
00031   m_pHit = hit;
00032   
00033   G4int part = m_pHit->GetPart();
00034   G4int seg  = m_pHit->GetSeg();
00035   G4int gap  = m_pHit->GetGap();
00036   m_Pos = m_pHit->GetPosLocal().x();
00037   if ( (part == 1 && gap%2 != 0) || (part != 1 && gap%2 == 0) ) {
00038     m_Pos = m_pHit->GetPosLocal().y();
00039   }
00040 
00041   if(part == 1 && seg == 2 &&gap%2 != 0) m_Pos2 = m_pHit->GetPosLocal().x();
00042 
00043   G4VPhysicalVolume* pvGasChamber = m_pHit->GetVolume();
00044   if(m_pHit->GetTrackID()!=-1){
00045     m_lvGap     = pvGasChamber->GetMotherLogical();  //after update gdml, mother of gaschamber change to be aluminumbox, but i still use the name m_lvGap
00046   m_lvGapName = m_lvGap->GetName();
00047 
00048   //G4cout<<"in digit----"<<m_lvGapName<<"  "<<m_lvGap->GetDaughter(1)->GetLogicalVolume()->GetName()<<G4endl;
00049   }
00050 }


Member Data Documentation

G4LogicalVolume* BesMucDigit::m_lvGap [private]

Definition at line 52 of file BesMucDigit.hh.

Referenced by GetStrip(), and SetHit().

G4String BesMucDigit::m_lvGapName [private]

Definition at line 53 of file BesMucDigit.hh.

Referenced by SetHit().

BesMucHit* BesMucDigit::m_pHit [private]

Definition at line 49 of file BesMucDigit.hh.

Referenced by GetGap(), GetNearestStripNo(), GetPart(), GetSeg(), GetStripPos(), GetTrackIndex(), and SetHit().

G4float BesMucDigit::m_Pos [private]

Definition at line 50 of file BesMucDigit.hh.

Referenced by GetNearestStripNo(), IsNearest(), and SetHit().

G4float BesMucDigit::m_Pos2 [private]

Definition at line 51 of file BesMucDigit.hh.

Referenced by GetNearestStripNo(), and SetHit().

G4VPhysicalVolume* BesMucDigit::m_pvStripDigit [private]

Definition at line 54 of file BesMucDigit.hh.

Referenced by GetNearestStrip().


Generated on Tue Nov 29 23:17:33 2016 for BOSS_7.0.2 by  doxygen 1.4.7