CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

TotemT1Organization Class Reference

#include <SimG4CMS/Forward/interface/TotemT1Organization.h>

Inheritance diagram for TotemT1Organization:
TotemVDetectorOrganization TotemT1NumberingScheme

List of all members.

Public Types

enum  ObjectType {
  Undefined = 0, Upper = 1, Lower = 2, InternalUpper = 3,
  InternalLower = 4, Frame1 = 5, Frame2Left = 6, Frame2Right = 7,
  Frame3Left = 8, Frame3Right = 9, Frame4Left = 10, Frame4Right = 11,
  Frame5 = 12, Triangle6Left = 13, Triangle6Right = 14, MaxObjectTypes = 15
}

Public Member Functions

int FromObjectTypeToInt (ObjectType objectType)
int FromObjectTypeToInt (ObjectType objectType, int layer)
int GetCurrentCSC (void) const
int GetCurrentDetectorPosition (void) const
int GetCurrentLayer (void) const
ObjectType GetCurrentObjectType (void) const
int GetCurrentPlane (void) const
int GetCurrentUnitID (void) const
uint32_t GetUnitID (const G4Step *aStep)
uint32_t GetUnitID (const G4Step *aStep) const
void SetCurrentCSC (int currentCSC)
void SetCurrentDetectorPosition (int currentDetectorPosition)
void SetCurrentLayer (int currentLayer)
void SetCurrentObjectType (ObjectType currentObjectType)
void SetCurrentPlane (int currentPlane)
void SetCurrentUnitID (int currentUnitID)
 TotemT1Organization ()
virtual ~TotemT1Organization ()

Private Member Functions

void _checkDataUpdate (void) const
void _checkUnitIDUpdate (void) const
void _FromDataToUnitID (void)
void _FromUnitIDToData (void)

Private Attributes

int _currentCSC
int _currentDetectorPosition
int _currentLayer
ObjectType _currentObjectType
int _currentPlane
int _currentUnitID
bool _needUpdateData
bool _needUpdateUnitID

Detailed Description

Description: This class manages the UnitID that labels TotemT1 sensitive volumes

Usage: Used in TotemSD to get unique ID of sensitive detector element

Definition at line 30 of file TotemT1Organization.h.


Member Enumeration Documentation

Enumerator:
Undefined 
Upper 
Lower 
InternalUpper 
InternalLower 
Frame1 
Frame2Left 
Frame2Right 
Frame3Left 
Frame3Right 
Frame4Left 
Frame4Right 
Frame5 
Triangle6Left 
Triangle6Right 
MaxObjectTypes 

Definition at line 36 of file TotemT1Organization.h.


Constructor & Destructor Documentation

TotemT1Organization::TotemT1Organization ( )

Definition at line 27 of file TotemT1Organization.cc.

                                           :  _needUpdateUnitID(false),
                                                _needUpdateData(false),
                                                _currentUnitID(-1),
                                                _currentPlane(-1),
                                                _currentCSC(-1),
                                                _currentLayer(-1),
                                                _currentObjectType(Undefined) {

  edm::LogInfo("ForwardSim") << "Creating TotemT1Organization";
}
TotemT1Organization::~TotemT1Organization ( ) [virtual]

Definition at line 38 of file TotemT1Organization.cc.

                                            {
}

Member Function Documentation

void TotemT1Organization::_checkDataUpdate ( void  ) const [private]

Definition at line 236 of file TotemT1Organization.cc.

References _FromUnitIDToData(), _needUpdateData, and LogDebug.

Referenced by GetCurrentCSC(), GetCurrentDetectorPosition(), GetCurrentLayer(), GetCurrentObjectType(), and GetCurrentPlane().

                                                       {

  if (_needUpdateData) {
#ifdef SCRIVI
    LogDebug("ForwardSim") << "Data update needed.";
#endif
    const_cast<TotemT1Organization *>(this)->_FromUnitIDToData();
  } else {
#ifdef SCRIVI
    LogDebug("ForwardSim") << "Data update not needed.";
#endif
  }
}
void TotemT1Organization::_checkUnitIDUpdate ( void  ) const [private]

Definition at line 223 of file TotemT1Organization.cc.

References _FromDataToUnitID(), _needUpdateUnitID, and LogDebug.

Referenced by GetCurrentUnitID().

                                                         {
  if (_needUpdateUnitID) {
#ifdef SCRIVI
    LogDebug("ForwardSim") << "UnitID update needed.";
#endif
    const_cast<TotemT1Organization *>(this)->_FromDataToUnitID();
  } else {
#ifdef SCRIVI
    LogDebug("ForwardSim") << "UnitID update not needed.";
#endif
  }
}
void TotemT1Organization::_FromDataToUnitID ( void  ) [private]

Definition at line 300 of file TotemT1Organization.cc.

References _currentCSC, _currentDetectorPosition, _currentLayer, _currentObjectType, _currentPlane, _currentUnitID, _needUpdateUnitID, FromObjectTypeToInt(), LogDebug, MaxObjectTypes, and TotemNumberMerger::Merge().

Referenced by _checkUnitIDUpdate().

                                                  {
  int currDP, currPL, currCSC, currLA, currOT;
#ifdef SCRIVI
  LogDebug("ForwardSim") << " CURRENT DETECTOR POSITION (0-3) " 
                         <<_currentDetectorPosition;
#endif
  switch(_currentDetectorPosition)  {
  case 0:
    currDP=0;
    break;
  case 1:
    currDP=1;
    break;
  case 2:
    currDP=2;
    break;
  case 3:
    currDP=3;
    break;
  case 4:
    currDP=4;
    break;
  default:
    _currentDetectorPosition=0;
    currDP=0;
    edm::LogInfo("ForwardSim") << "Invalid _currentDetectorPosition value (" 
                               << _currentDetectorPosition
                               << "). Now is \"Undefined\"";
  }
 
  if (_currentPlane<-1) {
    edm::LogInfo("ForwardSim") << "Invalid _currentPlane value (" 
                               << _currentPlane << "). Now is -1";
    _currentPlane=-1;
  }
  currPL=_currentPlane+1;
  
  if (_currentCSC<-1 || _currentCSC>5)  {
    edm::LogInfo("ForwardSim") << "Invalid _currentCSC value (" << _currentCSC
                               << "). Now is -1";
    _currentCSC=-1;
  }
  currCSC=_currentCSC+1;
  
  if (_currentLayer<-1)  {
    edm::LogInfo("ForwardSim") << "Invalid _currentLayer value (" 
                               << _currentLayer << "). Now is -1";
    _currentLayer=-1;
  }
  currLA=_currentLayer+1;
 
  currOT=FromObjectTypeToInt(_currentObjectType);
 
  // currDP:  0..2 (3)
  // currPL:  0..infty
  // currCSC: 0..6 (7)
  // currLA:  0..infty
  // currOT:  0..MaxObjectTypes-1 (MaxObjectTypes)

  TotemNumberMerger merger;
  int currPLA(merger.Merge(currPL,currLA));
 
  _currentUnitID=currDP*100000+5*(currCSC+7*(currOT+MaxObjectTypes*(currPLA)));
#ifdef SCRIVI
  LogDebug("ForwardSim") << "currDP=" << currDP << ", currPL=" << currPL  
                         << ", currCSC=" << currCSC << ", currLA=" << currLA  
                         << ", currOT=" << currOT << ", currPLA=" << currPLA  
                         << ", _currentUnitID=" << _currentUnitID;
#endif
 
  _needUpdateUnitID=false;
}
void TotemT1Organization::_FromUnitIDToData ( void  ) [private]

Definition at line 250 of file TotemT1Organization.cc.

References _currentCSC, _currentDetectorPosition, _currentLayer, _currentObjectType, _currentPlane, _currentUnitID, _needUpdateData, LogDebug, MaxObjectTypes, TotemNumberMerger::Split(), and confdb::splitter().

Referenced by _checkDataUpdate().

                                                  {

  int currDP, currCSC, currOT, currPLA;
  unsigned long currPL, currLA;
 
  // currDP:  0..4 (5)
  // currPL:  0..infty
  // currCSC: 0..6 (7)
  // currLA:  0..infty
  // currOT:  0..MaxObjectTypes-1 (MaxObjectTypes)

  currDP  = (_currentUnitID/100000) % 5;// 3;
  currCSC = (_currentUnitID/5)%7;
  currOT  = (_currentUnitID/(5*7))%MaxObjectTypes;
  currPLA =  _currentUnitID/(5*7*MaxObjectTypes);
 
  TotemNumberMerger splitter;
  splitter.Split(currPLA,currPL,currLA);
 
#ifdef SCRIVI
  LogDebug("ForwardSim") << "currDP=" << currDP << ", currPL=" << currPL  
                         << ", currCSC=" << currCSC << ", currLA=" << currLA  
                         << ", currOT=" << currOT << ", currPLA=" << currPLA  
                         << ", _currentUnitID=" << _currentUnitID;
#endif
  _currentPlane=currPL-1;
  _currentCSC=currCSC-1;
  _currentLayer=currLA-1;
  _currentObjectType=static_cast<ObjectType>(currOT);

  switch(currDP) {
  case 0: 
    _currentDetectorPosition=0;
    break;
  case 1: 
    _currentDetectorPosition=1;
    break;
  case 2: 
    _currentDetectorPosition=2;
    break;
  case 3:
    _currentDetectorPosition=3;
    break;
  case 4:
    _currentDetectorPosition=4;
    break;
  } 
  _needUpdateData=false;
}
int TotemT1Organization::FromObjectTypeToInt ( ObjectType  objectType,
int  layer 
)

Definition at line 214 of file TotemT1Organization.cc.

References FromObjectTypeToInt(), and MaxObjectTypes.

                                                                               {
  return FromObjectTypeToInt(objectType)+layer*MaxObjectTypes;
}
int TotemT1Organization::FromObjectTypeToInt ( ObjectType  objectType)

Definition at line 203 of file TotemT1Organization.cc.

References MaxObjectTypes, and query::result.

Referenced by _FromDataToUnitID(), and FromObjectTypeToInt().

                                                                    {

  int result(static_cast<int>(objectType));
  if (result<0 || result>=MaxObjectTypes) {
    result = 0;
    edm::LogInfo("ForwardSim") << "Invalid ObjectType value (" << objectType
                               << "). Now is \"Undefined\"";
  }
  return result;
}
int TotemT1Organization::GetCurrentCSC ( void  ) const

Definition at line 149 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentCSC, and LogDebug.

                                                   {

  _checkDataUpdate();
#ifdef SCRIVI
  LogDebug("ForwardSim") << "GetCurrentCSC()=" << _currentCSC;
#endif 
 return _currentCSC;
}
int TotemT1Organization::GetCurrentDetectorPosition ( void  ) const

Definition at line 111 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentDetectorPosition, and LogDebug.

                                                                 {

  _checkDataUpdate();
#ifdef SCRIVI
  LogDebug("ForwardSim") << "GetCurrentDetectorPosition()=" 
                         << _currentDetectorPosition;
#endif
 return _currentDetectorPosition;
}
int TotemT1Organization::GetCurrentLayer ( void  ) const

Definition at line 167 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentLayer, and LogDebug.

                                                     {

  _checkDataUpdate();
#ifdef SCRIVI
  LogDebug("ForwardSim") << "GetCurrentLayer()=" << _currentLayer;
#endif
  return _currentLayer;
}
TotemT1Organization::ObjectType TotemT1Organization::GetCurrentObjectType ( void  ) const

Definition at line 185 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentObjectType, and LogDebug.

                                                                                     {
  
 _checkDataUpdate();
#ifdef SCRIVI
 LogDebug("ForwardSim") << "GetCurrentObjectType()=" << _currentObjectType;
#endif
 return _currentObjectType;
}
int TotemT1Organization::GetCurrentPlane ( void  ) const

Definition at line 130 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentPlane, and LogDebug.

                                                     {

  _checkDataUpdate();

#ifdef SCRIVI
  LogDebug("ForwardSim") << "GetCurrentPlane()=" << _currentPlane;
#endif
 return _currentPlane;
}
int TotemT1Organization::GetCurrentUnitID ( void  ) const

Definition at line 92 of file TotemT1Organization.cc.

References _checkUnitIDUpdate(), _currentUnitID, and LogDebug.

Referenced by GetUnitID().

                                                      {

  _checkUnitIDUpdate();
#ifdef SCRIVI
 LogDebug("ForwardSim") << "GetCurrentUnitID()=" << _currentUnitID;
                                             << endl;
#endif
 return _currentUnitID;
}
uint32_t TotemT1Organization::GetUnitID ( const G4Step *  aStep) const [virtual]

Implements TotemVDetectorOrganization.

Definition at line 45 of file TotemT1Organization.cc.

References GetUnitID().

                                                                   {
  return const_cast<TotemT1Organization *>(this)->GetUnitID(aStep);
}
uint32_t TotemT1Organization::GetUnitID ( const G4Step *  aStep)

Definition at line 50 of file TotemT1Organization.cc.

References _currentCSC, _currentDetectorPosition, _currentLayer, _currentObjectType, _currentPlane, _needUpdateUnitID, GetCurrentUnitID(), LogDebug, and MaxObjectTypes.

Referenced by GetUnitID().

                                                             {

  int currLAOT;
  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
  G4VPhysicalVolume* physVol;
  int ii =0;
  for ( ii = 0; ii < touch->GetHistoryDepth(); ii++ ){
    physVol = touch->GetVolume(ii);

#ifdef SCRIVI
    LogDebug("ForwardSim") << "physVol=" << physVol->GetName()
                           << ", level=" << ii  << ", physVol->GetCopyNo()=" 
                           << physVol->GetCopyNo();
#endif

    if(physVol->GetName() == "TotemT1" && 
       physVol->GetCopyNo()==1) _currentDetectorPosition = 1;
    if(physVol->GetName() == "TotemT1" && 
       physVol->GetCopyNo()==2) _currentDetectorPosition = 2;
  }

  touch = aStep->GetPreStepPoint()->GetTouchable();
  physVol=touch->GetVolume(0);
 
  currLAOT=physVol->GetCopyNo();
  _currentObjectType=static_cast<ObjectType>(currLAOT%MaxObjectTypes);
  _currentLayer=currLAOT/MaxObjectTypes;
  _currentPlane=-1;
  _currentCSC=-1;

  if (touch->GetVolume(1)) {
    _currentCSC=touch->GetVolume(1)->GetCopyNo();
    if (touch->GetVolume(2)) _currentPlane=touch->GetVolume(2)->GetCopyNo();
  }
#ifdef SCRIVI
  LogDebug("ForwardSim") << "CURRENT CSC "<<_currentCSC << "\n"
                         << "CURRENT PLANE "<<_currentPlane;
#endif
  _needUpdateUnitID=true;
  return GetCurrentUnitID();
}
void TotemT1Organization::SetCurrentCSC ( int  currentCSC)

Definition at line 158 of file TotemT1Organization.cc.

References _currentCSC, _needUpdateUnitID, and LogDebug.

                                                        {

#ifdef SCRIVI
  LogDebug("ForwardSim") << "_currentCSC=" << currentCSC;
#endif
  _currentCSC=currentCSC;
  _needUpdateUnitID=true; 
}
void TotemT1Organization::SetCurrentDetectorPosition ( int  currentDetectorPosition)

Definition at line 121 of file TotemT1Organization.cc.

References _currentDetectorPosition, _needUpdateUnitID, and LogDebug.

Referenced by TotemT1NumberingScheme::TotemT1NumberingScheme().

                                                                                  {

#ifdef SCRIVI
  LogDebug("ForwardSim") << "_currentDetectorPosition=" << currentDetectorPosition;
#endif
  _currentDetectorPosition=currentDetectorPosition;
  _needUpdateUnitID=true;
}
void TotemT1Organization::SetCurrentLayer ( int  currentLayer)

Definition at line 176 of file TotemT1Organization.cc.

References _currentLayer, _needUpdateUnitID, and LogDebug.

                                                            {

#ifdef SCRIVI
  LogDebug("ForwardSim") << "_currentLayer=" << currentLayer;
#endif
  _currentLayer=currentLayer;
  _needUpdateUnitID=true;
}
void TotemT1Organization::SetCurrentObjectType ( ObjectType  currentObjectType) [inline]

Definition at line 194 of file TotemT1Organization.cc.

References _currentObjectType, _needUpdateUnitID, and LogDebug.

                                                                            {

#ifdef SCRIVI
  LogDebug("ForwardSim") << "_currentObjectType=" << currentObjectType;
#endif
  _currentObjectType=currentObjectType;
  _needUpdateUnitID=true;
}
void TotemT1Organization::SetCurrentPlane ( int  currentPlane)

Definition at line 140 of file TotemT1Organization.cc.

References _currentPlane, _needUpdateUnitID, and LogDebug.

                                                            {

#ifdef SCRIVI
  LogDebug("ForwardSim") << "_currentPlane=" << currentPlane;
#endif
  _currentPlane=currentPlane;
  _needUpdateUnitID=true;
}
void TotemT1Organization::SetCurrentUnitID ( int  currentUnitID)

Definition at line 102 of file TotemT1Organization.cc.

References _currentUnitID, _needUpdateData, and LogDebug.

                                                              {

#ifdef SCRIVI
  LogDebug("ForwardSim") << "_currentUnitID=" << currentUnitID;
#endif
  _currentUnitID=currentUnitID;
  _needUpdateData=true;
}

Member Data Documentation

Definition at line 105 of file TotemT1Organization.h.

Referenced by _checkDataUpdate(), _FromUnitIDToData(), and SetCurrentUnitID().