CMS 3D CMS Logo

List of all members | 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

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) const override
 
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 ()
 
 ~TotemT1Organization () override
 
- Public Member Functions inherited from TotemVDetectorOrganization
 TotemVDetectorOrganization ()
 
virtual ~TotemVDetectorOrganization ()
 

Private Member Functions

void _checkDataUpdate (void) const
 
void _checkUnitIDUpdate (void) const
 
void _FromDataToUnitID (void)
 
void _FromUnitIDToData (void)
 
uint32_t getUnitID (const G4Step *aStep)
 

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 28 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 32 of file TotemT1Organization.h.

Constructor & Destructor Documentation

TotemT1Organization::TotemT1Organization ( )
TotemT1Organization::~TotemT1Organization ( )
override

Definition at line 38 of file TotemT1Organization.cc.

38 {}

Member Function Documentation

void TotemT1Organization::_checkDataUpdate ( void  ) const
private

Definition at line 217 of file TotemT1Organization.cc.

References _FromUnitIDToData(), _needUpdateData, and LogDebug.

Referenced by getCurrentCSC(), getCurrentDetectorPosition(), getCurrentLayer(), getCurrentObjectType(), and getCurrentPlane().

217  {
218  if (_needUpdateData) {
219 #ifdef SCRIVI
220  LogDebug("ForwardSim") << "Data update needed.";
221 #endif
222  const_cast<TotemT1Organization*>(this)->_FromUnitIDToData();
223  } else {
224 #ifdef SCRIVI
225  LogDebug("ForwardSim") << "Data update not needed.";
226 #endif
227  }
228 }
#define LogDebug(id)
void TotemT1Organization::_checkUnitIDUpdate ( void  ) const
private

Definition at line 204 of file TotemT1Organization.cc.

References _FromDataToUnitID(), _needUpdateUnitID, and LogDebug.

Referenced by getCurrentUnitID().

204  {
205  if (_needUpdateUnitID) {
206 #ifdef SCRIVI
207  LogDebug("ForwardSim") << "UnitID update needed.";
208 #endif
209  const_cast<TotemT1Organization*>(this)->_FromDataToUnitID();
210  } else {
211 #ifdef SCRIVI
212  LogDebug("ForwardSim") << "UnitID update not needed.";
213 #endif
214  }
215 }
#define LogDebug(id)
void TotemT1Organization::_FromDataToUnitID ( void  )
private

Definition at line 278 of file TotemT1Organization.cc.

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

Referenced by _checkUnitIDUpdate().

278  {
279  int currDP, currPL, currCSC, currLA, currOT;
280 #ifdef SCRIVI
281  LogDebug("ForwardSim") << " CURRENT DETECTOR POSITION (0-3) " << _currentDetectorPosition;
282 #endif
283  switch (_currentDetectorPosition) {
284  case 0:
285  currDP = 0;
286  break;
287  case 1:
288  currDP = 1;
289  break;
290  case 2:
291  currDP = 2;
292  break;
293  case 3:
294  currDP = 3;
295  break;
296  case 4:
297  currDP = 4;
298  break;
299  default:
301  currDP = 0;
302  edm::LogInfo("ForwardSim") << "Invalid _currentDetectorPosition value (" << _currentDetectorPosition
303  << "). Now is \"Undefined\"";
304  }
305 
306  if (_currentPlane < -1) {
307  edm::LogInfo("ForwardSim") << "Invalid _currentPlane value (" << _currentPlane << "). Now is -1";
308  _currentPlane = -1;
309  }
310  currPL = _currentPlane + 1;
311 
312  if (_currentCSC < -1 || _currentCSC > 5) {
313  edm::LogInfo("ForwardSim") << "Invalid _currentCSC value (" << _currentCSC << "). Now is -1";
314  _currentCSC = -1;
315  }
316  currCSC = _currentCSC + 1;
317 
318  if (_currentLayer < -1) {
319  edm::LogInfo("ForwardSim") << "Invalid _currentLayer value (" << _currentLayer << "). Now is -1";
320  _currentLayer = -1;
321  }
322  currLA = _currentLayer + 1;
323 
325 
326  // currDP: 0..2 (3)
327  // currPL: 0..infty
328  // currCSC: 0..6 (7)
329  // currLA: 0..infty
330  // currOT: 0..MaxObjectTypes-1 (MaxObjectTypes)
331 
332  TotemNumberMerger merger;
333  int currPLA(merger.Merge(currPL, currLA));
334 
335  _currentUnitID = currDP * 100000 + 5 * (currCSC + 7 * (currOT + MaxObjectTypes * (currPLA)));
336 #ifdef SCRIVI
337  LogDebug("ForwardSim") << "currDP=" << currDP << ", currPL=" << currPL << ", currCSC=" << currCSC
338  << ", currLA=" << currLA << ", currOT=" << currOT << ", currPLA=" << currPLA
339  << ", _currentUnitID=" << _currentUnitID;
340 #endif
341 
342  _needUpdateUnitID = false;
343 }
#define LogDebug(id)
unsigned long Merge(unsigned long value1, unsigned long value2) const
int fromObjectTypeToInt(ObjectType objectType)
void TotemT1Organization::_FromUnitIDToData ( void  )
private

Definition at line 230 of file TotemT1Organization.cc.

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

Referenced by _checkDataUpdate().

230  {
231  int currDP, currCSC, currOT, currPLA;
232  unsigned long currPL, currLA;
233 
234  // currDP: 0..4 (5)
235  // currPL: 0..infty
236  // currCSC: 0..6 (7)
237  // currLA: 0..infty
238  // currOT: 0..MaxObjectTypes-1 (MaxObjectTypes)
239 
240  currDP = (_currentUnitID / 100000) % 5; // 3;
241  currCSC = (_currentUnitID / 5) % 7;
242  currOT = (_currentUnitID / (5 * 7)) % MaxObjectTypes;
243  currPLA = _currentUnitID / (5 * 7 * MaxObjectTypes);
244 
246  splitter.Split(currPLA, currPL, currLA);
247 
248 #ifdef SCRIVI
249  LogDebug("ForwardSim") << "currDP=" << currDP << ", currPL=" << currPL << ", currCSC=" << currCSC
250  << ", currLA=" << currLA << ", currOT=" << currOT << ", currPLA=" << currPLA
251  << ", _currentUnitID=" << _currentUnitID;
252 #endif
253  _currentPlane = currPL - 1;
254  _currentCSC = currCSC - 1;
255  _currentLayer = currLA - 1;
256  _currentObjectType = static_cast<ObjectType>(currOT);
257 
258  switch (currDP) {
259  case 0:
261  break;
262  case 1:
264  break;
265  case 2:
267  break;
268  case 3:
270  break;
271  case 4:
273  break;
274  }
275  _needUpdateData = false;
276 }
#define LogDebug(id)
def splitter(iterator, n)
Definition: confdb.py:13
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
int TotemT1Organization::fromObjectTypeToInt ( ObjectType  objectType)

Definition at line 187 of file TotemT1Organization.cc.

References MaxObjectTypes, and mps_fire::result.

Referenced by _FromDataToUnitID(), and fromObjectTypeToInt().

187  {
188  int result(static_cast<int>(objectType));
189  if (result < 0 || result >= MaxObjectTypes) {
190  result = 0;
191  edm::LogInfo("ForwardSim") << "Invalid ObjectType value (" << objectType << "). Now is \"Undefined\"";
192  }
193  return result;
194 }
int TotemT1Organization::fromObjectTypeToInt ( ObjectType  objectType,
int  layer 
)

Definition at line 196 of file TotemT1Organization.cc.

References fromObjectTypeToInt(), and MaxObjectTypes.

196  {
197  return fromObjectTypeToInt(objectType) + layer * MaxObjectTypes;
198 }
int fromObjectTypeToInt(ObjectType objectType)
int TotemT1Organization::getCurrentCSC ( void  ) const

Definition at line 139 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentCSC, and LogDebug.

139  {
141 #ifdef SCRIVI
142  LogDebug("ForwardSim") << "getCurrentCSC()=" << _currentCSC;
143 #endif
144  return _currentCSC;
145 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::getCurrentDetectorPosition ( void  ) const

Definition at line 106 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentDetectorPosition, and LogDebug.

106  {
108 #ifdef SCRIVI
109  LogDebug("ForwardSim") << "getCurrentDetectorPosition()=" << _currentDetectorPosition;
110 #endif
112 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::getCurrentLayer ( void  ) const

Definition at line 155 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentLayer, and LogDebug.

155  {
157 #ifdef SCRIVI
158  LogDebug("ForwardSim") << "getCurrentLayer()=" << _currentLayer;
159 #endif
160  return _currentLayer;
161 }
#define LogDebug(id)
void _checkDataUpdate(void) const
TotemT1Organization::ObjectType TotemT1Organization::getCurrentObjectType ( void  ) const

Definition at line 171 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentObjectType, and LogDebug.

171  {
173 #ifdef SCRIVI
174  LogDebug("ForwardSim") << "getCurrentObjectType()=" << _currentObjectType;
175 #endif
176  return _currentObjectType;
177 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::getCurrentPlane ( void  ) const

Definition at line 122 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentPlane, and LogDebug.

122  {
124 
125 #ifdef SCRIVI
126  LogDebug("ForwardSim") << "getCurrentPlane()=" << _currentPlane;
127 #endif
128  return _currentPlane;
129 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::getCurrentUnitID ( void  ) const

Definition at line 89 of file TotemT1Organization.cc.

References _checkUnitIDUpdate(), _currentUnitID, and LogDebug.

Referenced by getUnitID().

89  {
91 #ifdef SCRIVI
92  LogDebug("ForwardSim") << "getCurrentUnitID()=" << _currentUnitID;
93  << endl;
94 #endif
95  return _currentUnitID;
96 }
#define LogDebug(id)
void _checkUnitIDUpdate(void) const
uint32_t TotemT1Organization::getUnitID ( const G4Step *  aStep) const
overridevirtual

Implements TotemVDetectorOrganization.

Definition at line 44 of file TotemT1Organization.cc.

44  {
45  return const_cast<TotemT1Organization*>(this)->getUnitID(aStep);
46 }
uint32_t getUnitID(const G4Step *aStep) const override
uint32_t TotemT1Organization::getUnitID ( const G4Step *  aStep)
private

Definition at line 48 of file TotemT1Organization.cc.

References _currentCSC, _currentDetectorPosition, _currentLayer, _currentObjectType, _currentPlane, _needUpdateUnitID, getCurrentUnitID(), cuy::ii, LogDebug, and MaxObjectTypes.

48  {
49  int currLAOT;
50  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
51  G4VPhysicalVolume* physVol;
52  int ii = 0;
53  for (ii = 0; ii < touch->GetHistoryDepth(); ii++) {
54  physVol = touch->GetVolume(ii);
55 
56 #ifdef SCRIVI
57  LogDebug("ForwardSim") << "physVol=" << physVol->GetName() << ", level=" << ii
58  << ", physVol->GetCopyNo()=" << physVol->GetCopyNo();
59 #endif
60 
61  if (physVol->GetName() == "TotemT1" && physVol->GetCopyNo() == 1)
63  if (physVol->GetName() == "TotemT1" && physVol->GetCopyNo() == 2)
65  }
66 
67  touch = aStep->GetPreStepPoint()->GetTouchable();
68  physVol = touch->GetVolume(0);
69 
70  currLAOT = physVol->GetCopyNo();
71  _currentObjectType = static_cast<ObjectType>(currLAOT % MaxObjectTypes);
72  _currentLayer = currLAOT / MaxObjectTypes;
73  _currentPlane = -1;
74  _currentCSC = -1;
75 
76  if (touch->GetVolume(1)) {
77  _currentCSC = touch->GetVolume(1)->GetCopyNo();
78  if (touch->GetVolume(2))
79  _currentPlane = touch->GetVolume(2)->GetCopyNo();
80  }
81 #ifdef SCRIVI
82  LogDebug("ForwardSim") << "CURRENT CSC " << _currentCSC << "\n"
83  << "CURRENT PLANE " << _currentPlane;
84 #endif
85  _needUpdateUnitID = true;
86  return getCurrentUnitID();
87 }
#define LogDebug(id)
int getCurrentUnitID(void) const
ii
Definition: cuy.py:590
void TotemT1Organization::setCurrentCSC ( int  currentCSC)

Definition at line 147 of file TotemT1Organization.cc.

References _currentCSC, _needUpdateUnitID, and LogDebug.

147  {
148 #ifdef SCRIVI
149  LogDebug("ForwardSim") << "_currentCSC=" << currentCSC;
150 #endif
151  _currentCSC = currentCSC;
152  _needUpdateUnitID = true;
153 }
#define LogDebug(id)
void TotemT1Organization::setCurrentDetectorPosition ( int  currentDetectorPosition)

Definition at line 114 of file TotemT1Organization.cc.

References _currentDetectorPosition, _needUpdateUnitID, and LogDebug.

Referenced by TotemT1NumberingScheme::TotemT1NumberingScheme().

114  {
115 #ifdef SCRIVI
116  LogDebug("ForwardSim") << "_currentDetectorPosition=" << currentDetectorPosition;
117 #endif
118  _currentDetectorPosition = currentDetectorPosition;
119  _needUpdateUnitID = true;
120 }
#define LogDebug(id)
void TotemT1Organization::setCurrentLayer ( int  currentLayer)

Definition at line 163 of file TotemT1Organization.cc.

References _currentLayer, _needUpdateUnitID, and LogDebug.

163  {
164 #ifdef SCRIVI
165  LogDebug("ForwardSim") << "_currentLayer=" << currentLayer;
166 #endif
167  _currentLayer = currentLayer;
168  _needUpdateUnitID = true;
169 }
#define LogDebug(id)
void TotemT1Organization::setCurrentObjectType ( ObjectType  currentObjectType)

Definition at line 179 of file TotemT1Organization.cc.

References _currentObjectType, _needUpdateUnitID, and LogDebug.

179  {
180 #ifdef SCRIVI
181  LogDebug("ForwardSim") << "_currentObjectType=" << currentObjectType;
182 #endif
183  _currentObjectType = currentObjectType;
184  _needUpdateUnitID = true;
185 }
#define LogDebug(id)
void TotemT1Organization::setCurrentPlane ( int  currentPlane)

Definition at line 131 of file TotemT1Organization.cc.

References _currentPlane, _needUpdateUnitID, and LogDebug.

131  {
132 #ifdef SCRIVI
133  LogDebug("ForwardSim") << "_currentPlane=" << currentPlane;
134 #endif
135  _currentPlane = currentPlane;
136  _needUpdateUnitID = true;
137 }
#define LogDebug(id)
void TotemT1Organization::setCurrentUnitID ( int  currentUnitID)

Definition at line 98 of file TotemT1Organization.cc.

References _currentUnitID, _needUpdateData, and LogDebug.

98  {
99 #ifdef SCRIVI
100  LogDebug("ForwardSim") << "_currentUnitID=" << currentUnitID;
101 #endif
102  _currentUnitID = currentUnitID;
103  _needUpdateData = true;
104 }
#define LogDebug(id)

Member Data Documentation

int TotemT1Organization::_currentCSC
private
int TotemT1Organization::_currentDetectorPosition
private
int TotemT1Organization::_currentLayer
private
ObjectType TotemT1Organization::_currentObjectType
private
int TotemT1Organization::_currentPlane
private
int TotemT1Organization::_currentUnitID
private
bool TotemT1Organization::_needUpdateData
private

Definition at line 100 of file TotemT1Organization.h.

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

bool TotemT1Organization::_needUpdateUnitID
private