CMS 3D CMS Logo

TotemT1Organization.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Forward
4 // Class : TotemT1Organization
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: R. Capra
10 // Created: Tue May 16 10:14:34 CEST 2006
11 //
12 
13 // system include files
14 
15 // user include files
19 
20 #include "G4VPhysicalVolume.hh"
21 #include "G4VTouchable.hh"
22 #include "globals.hh"
23 
24 //
25 // constructors and destructor
26 //
28  : _needUpdateUnitID(false),
29  _needUpdateData(false),
30  _currentUnitID(-1),
31  _currentPlane(-1),
32  _currentCSC(-1),
33  _currentLayer(-1),
34  _currentObjectType(Undefined) {
35  edm::LogInfo("ForwardSim") << "Creating TotemT1Organization";
36 }
37 
39 
40 //
41 // member functions
42 //
43 
44 uint32_t TotemT1Organization ::getUnitID(const G4Step* aStep) const {
45  return const_cast<TotemT1Organization*>(this)->getUnitID(aStep);
46 }
47 
48 uint32_t TotemT1Organization ::getUnitID(const G4Step* aStep) {
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 }
88 
91 #ifdef SCRIVI
92  LogDebug("ForwardSim") << "getCurrentUnitID()=" << _currentUnitID;
93  << endl;
94 #endif
95  return _currentUnitID;
96 }
97 
98 void TotemT1Organization ::setCurrentUnitID(int currentUnitID) {
99 #ifdef SCRIVI
100  LogDebug("ForwardSim") << "_currentUnitID=" << currentUnitID;
101 #endif
102  _currentUnitID = currentUnitID;
103  _needUpdateData = true;
104 }
105 
108 #ifdef SCRIVI
109  LogDebug("ForwardSim") << "getCurrentDetectorPosition()=" << _currentDetectorPosition;
110 #endif
112 }
113 
114 void TotemT1Organization ::setCurrentDetectorPosition(int currentDetectorPosition) {
115 #ifdef SCRIVI
116  LogDebug("ForwardSim") << "_currentDetectorPosition=" << currentDetectorPosition;
117 #endif
118  _currentDetectorPosition = currentDetectorPosition;
119  _needUpdateUnitID = true;
120 }
121 
124 
125 #ifdef SCRIVI
126  LogDebug("ForwardSim") << "getCurrentPlane()=" << _currentPlane;
127 #endif
128  return _currentPlane;
129 }
130 
132 #ifdef SCRIVI
133  LogDebug("ForwardSim") << "_currentPlane=" << currentPlane;
134 #endif
135  _currentPlane = currentPlane;
136  _needUpdateUnitID = true;
137 }
138 
141 #ifdef SCRIVI
142  LogDebug("ForwardSim") << "getCurrentCSC()=" << _currentCSC;
143 #endif
144  return _currentCSC;
145 }
146 
148 #ifdef SCRIVI
149  LogDebug("ForwardSim") << "_currentCSC=" << currentCSC;
150 #endif
151  _currentCSC = currentCSC;
152  _needUpdateUnitID = true;
153 }
154 
157 #ifdef SCRIVI
158  LogDebug("ForwardSim") << "getCurrentLayer()=" << _currentLayer;
159 #endif
160  return _currentLayer;
161 }
162 
164 #ifdef SCRIVI
165  LogDebug("ForwardSim") << "_currentLayer=" << currentLayer;
166 #endif
167  _currentLayer = currentLayer;
168  _needUpdateUnitID = true;
169 }
170 
173 #ifdef SCRIVI
174  LogDebug("ForwardSim") << "getCurrentObjectType()=" << _currentObjectType;
175 #endif
176  return _currentObjectType;
177 }
178 
180 #ifdef SCRIVI
181  LogDebug("ForwardSim") << "_currentObjectType=" << currentObjectType;
182 #endif
183  _currentObjectType = currentObjectType;
184  _needUpdateUnitID = true;
185 }
186 
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 }
195 
197  return fromObjectTypeToInt(objectType) + layer * MaxObjectTypes;
198 }
199 
200 //
201 // private member functions
202 //
203 
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 }
216 
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 }
229 
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 }
277 
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 }
splitter
Definition: splitter.py:1
TotemT1Organization::setCurrentCSC
void setCurrentCSC(int currentCSC)
Definition: TotemT1Organization.cc:147
MessageLogger.h
TotemT1Organization::_needUpdateData
bool _needUpdateData
Definition: TotemT1Organization.h:100
funct::false
false
Definition: Factorize.h:29
TotemT1Organization::setCurrentUnitID
void setCurrentUnitID(int currentUnitID)
Definition: TotemT1Organization.cc:98
TotemT1Organization::getCurrentObjectType
ObjectType getCurrentObjectType(void) const
Definition: TotemT1Organization.cc:171
TotemT1Organization::_currentUnitID
int _currentUnitID
Definition: TotemT1Organization.h:101
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TotemNumberMerger.h
TotemT1Organization::setCurrentLayer
void setCurrentLayer(int currentLayer)
Definition: TotemT1Organization.cc:163
TotemT1Organization::getCurrentPlane
int getCurrentPlane(void) const
Definition: TotemT1Organization.cc:122
TotemT1Organization::setCurrentDetectorPosition
void setCurrentDetectorPosition(int currentDetectorPosition)
Definition: TotemT1Organization.cc:114
TotemT1Organization::_currentDetectorPosition
int _currentDetectorPosition
Definition: TotemT1Organization.h:102
TotemT1Organization::getCurrentUnitID
int getCurrentUnitID(void) const
Definition: TotemT1Organization.cc:89
TotemT1Organization::TotemT1Organization
TotemT1Organization()
Definition: TotemT1Organization.cc:27
confdb.splitter
def splitter(iterator, n)
Definition: confdb.py:13
TotemT1Organization::_currentObjectType
ObjectType _currentObjectType
Definition: TotemT1Organization.h:106
TotemT1Organization::_FromDataToUnitID
void _FromDataToUnitID(void)
Definition: TotemT1Organization.cc:278
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
TotemNumberMerger::Merge
unsigned long Merge(unsigned long value1, unsigned long value2) const
Definition: TotemNumberMerger.cc:38
TotemT1Organization::ObjectType
ObjectType
Definition: TotemT1Organization.h:32
TotemT1Organization::getCurrentDetectorPosition
int getCurrentDetectorPosition(void) const
Definition: TotemT1Organization.cc:106
TotemT1Organization::getCurrentCSC
int getCurrentCSC(void) const
Definition: TotemT1Organization.cc:139
TotemT1Organization::fromObjectTypeToInt
int fromObjectTypeToInt(ObjectType objectType)
Definition: TotemT1Organization.cc:187
TotemT1Organization::setCurrentPlane
void setCurrentPlane(int currentPlane)
Definition: TotemT1Organization.cc:131
TotemT1Organization::_checkDataUpdate
void _checkDataUpdate(void) const
Definition: TotemT1Organization.cc:217
TotemT1Organization::MaxObjectTypes
Definition: TotemT1Organization.h:48
TotemT1Organization::_needUpdateUnitID
bool _needUpdateUnitID
Definition: TotemT1Organization.h:99
TotemT1Organization::_checkUnitIDUpdate
void _checkUnitIDUpdate(void) const
Definition: TotemT1Organization.cc:204
TotemT1Organization::getUnitID
uint32_t getUnitID(const G4Step *aStep) const override
Definition: TotemT1Organization.cc:44
TotemT1Organization::_currentCSC
int _currentCSC
Definition: TotemT1Organization.h:104
TotemT1Organization::_currentLayer
int _currentLayer
Definition: TotemT1Organization.h:105
TotemT1Organization::~TotemT1Organization
~TotemT1Organization() override
Definition: TotemT1Organization.cc:38
mps_fire.result
result
Definition: mps_fire.py:311
TotemT1Organization::_FromUnitIDToData
void _FromUnitIDToData(void)
Definition: TotemT1Organization.cc:230
TotemT1Organization::_currentPlane
int _currentPlane
Definition: TotemT1Organization.h:103
TotemT1Organization.h
TotemT1Organization::getCurrentLayer
int getCurrentLayer(void) const
Definition: TotemT1Organization.cc:155
cuy.ii
ii
Definition: cuy.py:590
TotemNumberMerger
Definition: TotemNumberMerger.h:28
TotemT1Organization::setCurrentObjectType
void setCurrentObjectType(ObjectType currentObjectType)
Definition: TotemT1Organization.cc:179