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)
 
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)
 

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 29 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 35 of file TotemT1Organization.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file TotemT1Organization.cc.

37  {
38 }

Member Function Documentation

void TotemT1Organization::_checkDataUpdate ( void  ) const
private

Definition at line 235 of file TotemT1Organization.cc.

References _FromUnitIDToData(), _needUpdateData, and LogDebug.

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

235  {
236 
237  if (_needUpdateData) {
238 #ifdef SCRIVI
239  LogDebug("ForwardSim") << "Data update needed.";
240 #endif
241  const_cast<TotemT1Organization *>(this)->_FromUnitIDToData();
242  } else {
243 #ifdef SCRIVI
244  LogDebug("ForwardSim") << "Data update not needed.";
245 #endif
246  }
247 }
#define LogDebug(id)
void TotemT1Organization::_checkUnitIDUpdate ( void  ) const
private

Definition at line 222 of file TotemT1Organization.cc.

References _FromDataToUnitID(), _needUpdateUnitID, and LogDebug.

Referenced by GetCurrentUnitID().

222  {
223  if (_needUpdateUnitID) {
224 #ifdef SCRIVI
225  LogDebug("ForwardSim") << "UnitID update needed.";
226 #endif
227  const_cast<TotemT1Organization *>(this)->_FromDataToUnitID();
228  } else {
229 #ifdef SCRIVI
230  LogDebug("ForwardSim") << "UnitID update not needed.";
231 #endif
232  }
233 }
#define LogDebug(id)
void TotemT1Organization::_FromDataToUnitID ( void  )
private

Definition at line 299 of file TotemT1Organization.cc.

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

Referenced by _checkUnitIDUpdate().

299  {
300  int currDP, currPL, currCSC, currLA, currOT;
301 #ifdef SCRIVI
302  LogDebug("ForwardSim") << " CURRENT DETECTOR POSITION (0-3) "
304 #endif
305  switch(_currentDetectorPosition) {
306  case 0:
307  currDP=0;
308  break;
309  case 1:
310  currDP=1;
311  break;
312  case 2:
313  currDP=2;
314  break;
315  case 3:
316  currDP=3;
317  break;
318  case 4:
319  currDP=4;
320  break;
321  default:
323  currDP=0;
324  edm::LogInfo("ForwardSim") << "Invalid _currentDetectorPosition value ("
326  << "). Now is \"Undefined\"";
327  }
328 
329  if (_currentPlane<-1) {
330  edm::LogInfo("ForwardSim") << "Invalid _currentPlane value ("
331  << _currentPlane << "). Now is -1";
332  _currentPlane=-1;
333  }
334  currPL=_currentPlane+1;
335 
336  if (_currentCSC<-1 || _currentCSC>5) {
337  edm::LogInfo("ForwardSim") << "Invalid _currentCSC value (" << _currentCSC
338  << "). Now is -1";
339  _currentCSC=-1;
340  }
341  currCSC=_currentCSC+1;
342 
343  if (_currentLayer<-1) {
344  edm::LogInfo("ForwardSim") << "Invalid _currentLayer value ("
345  << _currentLayer << "). Now is -1";
346  _currentLayer=-1;
347  }
348  currLA=_currentLayer+1;
349 
351 
352  // currDP: 0..2 (3)
353  // currPL: 0..infty
354  // currCSC: 0..6 (7)
355  // currLA: 0..infty
356  // currOT: 0..MaxObjectTypes-1 (MaxObjectTypes)
357 
358  TotemNumberMerger merger;
359  int currPLA(merger.Merge(currPL,currLA));
360 
361  _currentUnitID=currDP*100000+5*(currCSC+7*(currOT+MaxObjectTypes*(currPLA)));
362 #ifdef SCRIVI
363  LogDebug("ForwardSim") << "currDP=" << currDP << ", currPL=" << currPL
364  << ", currCSC=" << currCSC << ", currLA=" << currLA
365  << ", currOT=" << currOT << ", currPLA=" << currPLA
366  << ", _currentUnitID=" << _currentUnitID;
367 #endif
368 
369  _needUpdateUnitID=false;
370 }
#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 249 of file TotemT1Organization.cc.

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

Referenced by _checkDataUpdate().

249  {
250 
251  int currDP, currCSC, currOT, currPLA;
252  unsigned long currPL, currLA;
253 
254  // currDP: 0..4 (5)
255  // currPL: 0..infty
256  // currCSC: 0..6 (7)
257  // currLA: 0..infty
258  // currOT: 0..MaxObjectTypes-1 (MaxObjectTypes)
259 
260  currDP = (_currentUnitID/100000) % 5;// 3;
261  currCSC = (_currentUnitID/5)%7;
262  currOT = (_currentUnitID/(5*7))%MaxObjectTypes;
263  currPLA = _currentUnitID/(5*7*MaxObjectTypes);
264 
266  splitter.Split(currPLA,currPL,currLA);
267 
268 #ifdef SCRIVI
269  LogDebug("ForwardSim") << "currDP=" << currDP << ", currPL=" << currPL
270  << ", currCSC=" << currCSC << ", currLA=" << currLA
271  << ", currOT=" << currOT << ", currPLA=" << currPLA
272  << ", _currentUnitID=" << _currentUnitID;
273 #endif
274  _currentPlane=currPL-1;
275  _currentCSC=currCSC-1;
276  _currentLayer=currLA-1;
277  _currentObjectType=static_cast<ObjectType>(currOT);
278 
279  switch(currDP) {
280  case 0:
282  break;
283  case 1:
285  break;
286  case 2:
288  break;
289  case 3:
291  break;
292  case 4:
294  break;
295  }
296  _needUpdateData=false;
297 }
#define LogDebug(id)
def splitter(iterator, n)
Definition: confdb.py:11
void Split(unsigned long source, unsigned long &value1, unsigned long &value2) const
int TotemT1Organization::FromObjectTypeToInt ( ObjectType  objectType)

Definition at line 202 of file TotemT1Organization.cc.

References MaxObjectTypes, and mps_fire::result.

Referenced by _FromDataToUnitID(), and FromObjectTypeToInt().

202  {
203 
204  int result(static_cast<int>(objectType));
205  if (result<0 || result>=MaxObjectTypes) {
206  result = 0;
207  edm::LogInfo("ForwardSim") << "Invalid ObjectType value (" << objectType
208  << "). Now is \"Undefined\"";
209  }
210  return result;
211 }
int TotemT1Organization::FromObjectTypeToInt ( ObjectType  objectType,
int  layer 
)

Definition at line 213 of file TotemT1Organization.cc.

References FromObjectTypeToInt(), and MaxObjectTypes.

213  {
214  return FromObjectTypeToInt(objectType)+layer*MaxObjectTypes;
215 }
int FromObjectTypeToInt(ObjectType objectType)
int TotemT1Organization::GetCurrentCSC ( void  ) const

Definition at line 148 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentCSC, and LogDebug.

148  {
149 
151 #ifdef SCRIVI
152  LogDebug("ForwardSim") << "GetCurrentCSC()=" << _currentCSC;
153 #endif
154  return _currentCSC;
155 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::GetCurrentDetectorPosition ( void  ) const

Definition at line 110 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentDetectorPosition, and LogDebug.

110  {
111 
113 #ifdef SCRIVI
114  LogDebug("ForwardSim") << "GetCurrentDetectorPosition()="
116 #endif
118 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::GetCurrentLayer ( void  ) const

Definition at line 166 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentLayer, and LogDebug.

166  {
167 
169 #ifdef SCRIVI
170  LogDebug("ForwardSim") << "GetCurrentLayer()=" << _currentLayer;
171 #endif
172  return _currentLayer;
173 }
#define LogDebug(id)
void _checkDataUpdate(void) const
TotemT1Organization::ObjectType TotemT1Organization::GetCurrentObjectType ( void  ) const

Definition at line 184 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentObjectType, and LogDebug.

184  {
185 
187 #ifdef SCRIVI
188  LogDebug("ForwardSim") << "GetCurrentObjectType()=" << _currentObjectType;
189 #endif
190  return _currentObjectType;
191 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::GetCurrentPlane ( void  ) const

Definition at line 129 of file TotemT1Organization.cc.

References _checkDataUpdate(), _currentPlane, and LogDebug.

129  {
130 
132 
133 #ifdef SCRIVI
134  LogDebug("ForwardSim") << "GetCurrentPlane()=" << _currentPlane;
135 #endif
136  return _currentPlane;
137 }
#define LogDebug(id)
void _checkDataUpdate(void) const
int TotemT1Organization::GetCurrentUnitID ( void  ) const

Definition at line 91 of file TotemT1Organization.cc.

References _checkUnitIDUpdate(), _currentUnitID, and LogDebug.

Referenced by GetUnitID().

91  {
92 
94 #ifdef SCRIVI
95  LogDebug("ForwardSim") << "GetCurrentUnitID()=" << _currentUnitID;
96  << endl;
97 #endif
98  return _currentUnitID;
99 }
#define LogDebug(id)
void _checkUnitIDUpdate(void) const
uint32_t TotemT1Organization::GetUnitID ( const G4Step *  aStep)

Definition at line 49 of file TotemT1Organization.cc.

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

Referenced by GetUnitID().

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

Implements TotemVDetectorOrganization.

Definition at line 44 of file TotemT1Organization.cc.

References GetUnitID().

44  {
45  return const_cast<TotemT1Organization *>(this)->GetUnitID(aStep);
46 }
uint32_t GetUnitID(const G4Step *aStep)
void TotemT1Organization::SetCurrentCSC ( int  currentCSC)

Definition at line 157 of file TotemT1Organization.cc.

References _currentCSC, _needUpdateUnitID, and LogDebug.

157  {
158 
159 #ifdef SCRIVI
160  LogDebug("ForwardSim") << "_currentCSC=" << currentCSC;
161 #endif
162  _currentCSC=currentCSC;
163  _needUpdateUnitID=true;
164 }
#define LogDebug(id)
void TotemT1Organization::SetCurrentDetectorPosition ( int  currentDetectorPosition)

Definition at line 120 of file TotemT1Organization.cc.

References _currentDetectorPosition, _needUpdateUnitID, and LogDebug.

Referenced by TotemT1NumberingScheme::TotemT1NumberingScheme().

120  {
121 
122 #ifdef SCRIVI
123  LogDebug("ForwardSim") << "_currentDetectorPosition=" << currentDetectorPosition;
124 #endif
125  _currentDetectorPosition=currentDetectorPosition;
126  _needUpdateUnitID=true;
127 }
#define LogDebug(id)
void TotemT1Organization::SetCurrentLayer ( int  currentLayer)

Definition at line 175 of file TotemT1Organization.cc.

References _currentLayer, _needUpdateUnitID, and LogDebug.

175  {
176 
177 #ifdef SCRIVI
178  LogDebug("ForwardSim") << "_currentLayer=" << currentLayer;
179 #endif
180  _currentLayer=currentLayer;
181  _needUpdateUnitID=true;
182 }
#define LogDebug(id)
void TotemT1Organization::SetCurrentObjectType ( ObjectType  currentObjectType)
inline

Definition at line 193 of file TotemT1Organization.cc.

References _currentObjectType, _needUpdateUnitID, and LogDebug.

193  {
194 
195 #ifdef SCRIVI
196  LogDebug("ForwardSim") << "_currentObjectType=" << currentObjectType;
197 #endif
198  _currentObjectType=currentObjectType;
199  _needUpdateUnitID=true;
200 }
#define LogDebug(id)
void TotemT1Organization::SetCurrentPlane ( int  currentPlane)

Definition at line 139 of file TotemT1Organization.cc.

References _currentPlane, _needUpdateUnitID, and LogDebug.

139  {
140 
141 #ifdef SCRIVI
142  LogDebug("ForwardSim") << "_currentPlane=" << currentPlane;
143 #endif
144  _currentPlane=currentPlane;
145  _needUpdateUnitID=true;
146 }
#define LogDebug(id)
void TotemT1Organization::SetCurrentUnitID ( int  currentUnitID)

Definition at line 101 of file TotemT1Organization.cc.

References _currentUnitID, _needUpdateData, and LogDebug.

101  {
102 
103 #ifdef SCRIVI
104  LogDebug("ForwardSim") << "_currentUnitID=" << currentUnitID;
105 #endif
106  _currentUnitID=currentUnitID;
107  _needUpdateData=true;
108 }
#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 104 of file TotemT1Organization.h.

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

bool TotemT1Organization::_needUpdateUnitID
private