ATLAS Offline Software
VP1CaloCellManager.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 #include <QCheckBox>
10 #include <QDoubleSpinBox>
11 
13  VP1CC_SoNode2CCMap* node2cc,
14  bool useEt,
15  const QPair<bool,double>& scale,
16  bool outline,
17  const VP1CC_GlobalCuts& globalCuts):
18  m_type(type),
19  m_node2cc(node2cc),
20  m_useEt(useEt),
21  m_scale(scale),
22  m_outline(outline),
23  m_globalCuts(globalCuts)
24 {
25  // Initialize private iterators
30 
32 }
33 
35 {
36  // Clear multimaps
38  while(it!=m_positiveCells.end()) {
39  if(it->second) {
40  delete it->second;
41  it->second = 0;
42  }
43  ++it;
44  }
45 
46  it = m_negativeCells.begin();
47  while(it!=m_negativeCells.end()) {
48  if(it->second) {
49  delete it->second;
50  it->second = 0;
51  }
52  ++it;
53  }
54 
55  m_positiveCells.clear();
56  m_negativeCells.clear();
57 }
58 
60 {
61  double energy = cell->getCaloCell()->energy();
62 
63  if(m_useEt)
64  energy = cell->energyToTransverse(energy);
65 
66  // We need to choose which map to add the new cell to according to its energy sign
68 
69  // This is going to be the new key in the map
70  double ccKey = fabs(energy);
71 
72  // Add new element to the map
73  useMap.emplace(ccKey,cell);
74 }
75 
76 // ----------------- Slots --------------------------
78 {
79  VP1CCIntervalMap::const_iterator it = intervals.find(m_type);
80  if(it!=intervals.end()) {
81  // Update scene with pos/neg cells
82  updateScene(it->first,true);
83  updateScene(it->second,false);
84  }
85 }
86 
87 void VP1CaloCellManager::scaleUpdated(const QPair<bool,double>& new_scale)
88 {
89  m_scale = new_scale;
90 
91  // Redraw objects with new scale
92  // Pos
94  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
95  }
96 
97  // Neg
99  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
100  }
101 }
102 
103 void VP1CaloCellManager::outlineUpdated(const bool& new_outline)
104 {
105  m_outline = new_outline;
106 
107  // Redraw objects with new outline settings
108  // Pos
110  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
111  }
112 
113  // Neg
115  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
116  }
117 }
118 
120 {
121  m_globalCuts = new_cuts;
123  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
125  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
126 }
127 
129 {
130  m_globalCuts.clipRadius=radius; // Adjust radius to match new value
132  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
134  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
135 }
136 
137 // ----------------- Private methods ------------------------
138 void VP1CaloCellManager::updateScene(const VP1Interval& newInterval, bool positive)
139 {
140  // We need to choose which map to work with, according to the value of 'positive' flag
141  VP1CCMultimap* useMap = 0;
142  VP1CCMultimapIterator* useItFirst = 0;
143  VP1CCMultimapIterator* useItLast = 0;
144  VP1Interval* currentInterval = 0;
145 
146  if(positive) {
147  useMap = &m_positiveCells;
148  useItFirst = &m_firstDisplayedPos;
149  useItLast = &m_lastDisplayedPos;
150  currentInterval = &m_intervals.first;
151  } else {
152  useMap = &m_negativeCells;
153  useItFirst = &m_firstDisplayedNeg;
154  useItLast = &m_lastDisplayedNeg;
155  currentInterval = &m_intervals.second;
156  }
157 
158  // If new iterval is equal to the existing one just check global cuts
159  if(*currentInterval==newInterval) {
160  for(VP1CCMultimapIterator it=*useItFirst; it!=*useItLast; ++it)
161  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
162  return;
163  }
164 
165  // If new interval is empty hide everything and update the current interval
166  if(newInterval.isEmpty()) {
167  for(VP1CCMultimapIterator it=*useItFirst; it!=*useItLast; ++it)
168  it->second->remove3DObjects(m_node2cc);
169  *currentInterval = newInterval;
170  *useItFirst = useMap->end();
171  *useItLast = useMap->end();
172  return;
173  }
174 
175  // If old interval was empty, find values for first & last iterators and
176  // display everything between them, taking into account global cuts
177  if(currentInterval->isEmpty()) {
178  *useItFirst = useMap->lower_bound(newInterval.lower());
179  if(newInterval.upper() == VP1Interval::inf())
180  *useItLast = useMap->end();
181  else
182  *useItLast = useMap->upper_bound(newInterval.upper());
183 
184  for(VP1CCMultimapIterator it=*useItFirst; it!=*useItLast; ++it)
185  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
186 
187  *currentInterval = newInterval;
188  return;
189  }
190 
191  // No one is empty.
192  VP1CCMultimapIterator newIterator;
193 
194  if(currentInterval->lower() != newInterval.lower() &&
195  currentInterval->upper() != newInterval.upper()) {
196  // This is unexpected!
197  // Hide everything what was there before and display new thresholds
198  for(VP1CCMultimapIterator it=*useItFirst; it!=*useItLast; ++it)
199  it->second->remove3DObjects(m_node2cc);
200 
201  *useItFirst = useMap->lower_bound(newInterval.lower());
202  if(newInterval.upper() == VP1Interval::inf())
203  *useItLast = useMap->end();
204  else
205  *useItLast = useMap->upper_bound(newInterval.upper());
206 
207  for(VP1CCMultimapIterator it=*useItFirst; it!=*useItLast; ++it)
208  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
209 
210  } else if (currentInterval->lower() != newInterval.lower()) {
211  // Adjust lower threshold
212  newIterator = useMap->lower_bound(newInterval.lower());
213 
214  if(currentInterval->lower() < newInterval.lower())
215  // May need to hide something
216  for(VP1CCMultimapIterator it=*useItFirst; it!=newIterator; ++it)
217  it->second->remove3DObjects(m_node2cc);
218  else
219  // May need to add new objects to the scene
220  for(VP1CCMultimapIterator it=newIterator; it!=*useItFirst; ++it)
221  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
222 
223  *useItFirst = newIterator;
224 
225  } else {
226 
227  // Adjust upper threshold
228  if(newInterval.upper() == VP1Interval::inf()) {
229  newIterator = useMap->end();
230 
231  // May need to add new objects to the scene
232  for(VP1CCMultimapIterator it=*useItLast; it!=newIterator; ++it)
233  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
234  } else {
235  newIterator = useMap->upper_bound(newInterval.upper());
236 
237  if(*useItLast == useMap->end() ||
238  currentInterval->upper() > newInterval.upper()) {
239  // May need to hide something
240  for(VP1CCMultimapIterator it=newIterator; it!=*useItLast; ++it)
241  it->second->remove3DObjects(m_node2cc);
242  } else {
243  // May need to add new objects to the scene
244  for(VP1CCMultimapIterator it=*useItLast; it!=newIterator; ++it)
245  it->second->updateScene(m_node2cc,m_useEt,m_scale,m_outline,m_globalCuts);
246  }
247  }
248  *useItLast = newIterator;
249  }
250 
251  *currentInterval = newInterval;
252 }
VP1CaloCellManager::m_positiveCells
VP1CCMultimap m_positiveCells
Definition: VP1CaloCellManager.h:84
VP1CaloCellManager::add
void add(VP1CaloCell *cell)
Definition: VP1CaloCellManager.cxx:59
VP1CaloCellManager::m_lastDisplayedNeg
VP1CCMultimapIterator m_lastDisplayedNeg
Definition: VP1CaloCellManager.h:91
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
VP1CaloCellManager::updateScene
void updateScene(const VP1Interval &newInterval, bool positive)
Definition: VP1CaloCellManager.cxx:138
VP1CaloCellManager::m_lastDisplayedPos
VP1CCMultimapIterator m_lastDisplayedPos
Definition: VP1CaloCellManager.h:89
VP1CCIntervalPair
QPair< VP1Interval, VP1Interval > VP1CCIntervalPair
Definition: VP1CaloCells.h:115
skel.it
it
Definition: skel.GENtoEVGEN.py:423
VP1CaloCellManager::m_node2cc
VP1CC_SoNode2CCMap * m_node2cc
Definition: VP1CaloCellManager.h:72
VP1CaloCellManager.h
VP1CC_GlobalCuts
Definition: VP1CaloCells.h:47
VP1Interval::upper
double upper() const
VP1CCIntervalMap
QMap< VP1CC_SelectionTypes, VP1CCIntervalPair > VP1CCIntervalMap
Definition: VP1CaloCells.h:119
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
VP1CaloCellManager::m_globalCuts
VP1CC_GlobalCuts m_globalCuts
Definition: VP1CaloCellManager.h:97
VP1CaloCellManager::m_firstDisplayedNeg
VP1CCMultimapIterator m_firstDisplayedNeg
Definition: VP1CaloCellManager.h:90
VP1CaloCellManager::m_scale
QPair< bool, double > m_scale
Definition: VP1CaloCellManager.h:78
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
VP1Interval::lower
double lower() const
VP1CaloCell
Definition: VP1CaloCells.h:160
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
VP1CaloCellManager::scaleUpdated
void scaleUpdated(const QPair< bool, double > &)
Definition: VP1CaloCellManager.cxx:87
VP1Interval::inf
static double inf()
Definition: VP1Interval.h:25
VP1CaloCellManager::globalCutsUpdated
void globalCutsUpdated(const VP1CC_GlobalCuts &)
Definition: VP1CaloCellManager.cxx:119
VP1CaloCellManager::m_outline
bool m_outline
Definition: VP1CaloCellManager.h:81
VP1CaloCellManager::m_useEt
bool m_useEt
Definition: VP1CaloCellManager.h:75
VP1CaloCellManager::~VP1CaloCellManager
~VP1CaloCellManager()
Definition: VP1CaloCellManager.cxx:34
VP1CaloCellManager::clipVolumeRadiusChanged
void clipVolumeRadiusChanged(double radius)
Definition: VP1CaloCellManager.cxx:128
VP1CaloCellManager::m_negativeCells
VP1CCMultimap m_negativeCells
Definition: VP1CaloCellManager.h:85
VP1CaloCellManager::selectionUpdated
void selectionUpdated(const VP1CCIntervalMap &)
Definition: VP1CaloCellManager.cxx:77
VP1CC_GlobalCuts::clipRadius
double clipRadius
Definition: VP1CaloCells.h:59
VP1CaloCellManager::m_type
VP1CC_SelectionTypes m_type
Definition: VP1CaloCellManager.h:69
VP1CaloCellManager::m_firstDisplayedPos
VP1CCMultimapIterator m_firstDisplayedPos
Definition: VP1CaloCellManager.h:88
VP1Interval::isEmpty
bool isEmpty() const
VP1CaloCellManager::outlineUpdated
void outlineUpdated(const bool &)
Definition: VP1CaloCellManager.cxx:103
CaloCellContainer.h
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
VP1Interval
Definition: VP1Interval.h:23
VP1CaloCellManager::m_intervals
VP1CCIntervalPair m_intervals
Definition: VP1CaloCellManager.h:94
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
VP1CCMultimap
std::multimap< double, VP1CaloCell * > VP1CCMultimap
Definition: VP1CaloCellManager.h:16
VP1CaloCellManager::VP1CaloCellManager
VP1CaloCellManager(VP1CC_SelectionTypes type, VP1CC_SoNode2CCMap *node2cc, bool useEt, const QPair< bool, double > &scale, bool outline, const VP1CC_GlobalCuts &globalCuts)
Definition: VP1CaloCellManager.cxx:12
VP1CC_SelectionTypes
VP1CC_SelectionTypes
Definition: VP1CaloCells.h:67
VP1CCMultimapIterator
VP1CCMultimap::iterator VP1CCMultimapIterator
Definition: VP1CaloCellManager.h:36
VP1CC_SoNode2CCMap
std::map< SoNode *, VP1CaloCell *, std::less< SoNode * > > VP1CC_SoNode2CCMap
Definition: VP1CaloCells.h:156