ATLAS Offline Software
PRDCollHandle_TRT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "VP1Base/IVP13DSystem.h"
9 #include <QColor>
10 
13 
17 
18 //____________________________________________________________________
20 {
22 }
23 
24 //____________________________________________________________________
26 public:
27  //Keep specific lists of handles here... i.e. those with a HT for instance
28  // std::vector<PRDHandle_TRT*> prdhandles;
29  bool attempted_detmgrload = false;
30 
31  //We only load these on demand!
33  const TRT_ID * idhelper = nullptr;
34 
35  PRDCommonFlags::InDetPartsFlags indetpartsflags;
36  double minToT = 0.0;
37  double maxToT = 0.0;
38  int minLE = 0;
39  int maxLE = 0;
40  bool needToTCheck = false;
41  bool needLECheck = false;
42  bool requireHT = false;
43 };
44 
45 //____________________________________________________________________
47  : PRDCollHandleBase(PRDDetType::TRT,cd,key), m_d(new Imp), m_highlightHT(false), m_project(false),m_appropriateProjections(InDetProjFlags::NoProjections)
48 {
49  m_d->trtdetmgr = 0;
50  m_d->idhelper = 0;
51  m_d->attempted_detmgrload = false;
53  m_d->minToT = -0.5*3.125;
54  m_d->maxToT = 24.5*3.125;
55  m_d->minLE = 0;
56  m_d->maxLE = 23;
57  m_d->needToTCheck = false;
58  m_d->needLECheck = false;
59  m_d->requireHT = false;
60 }
61 
62 //____________________________________________________________________
64 {
65  delete m_d;
66 }
67 
68 //____________________________________________________________________
70 {
71  return QColor::fromRgbF(1.0, 1.0, 1.0);//white
72 
73 }
74 
75 //____________________________________________________________________
77 {
78  assert(dynamic_cast<const InDet::TRT_DriftCircle*>(prd));
79  return new PRDHandle_TRT(this,static_cast<const InDet::TRT_DriftCircle*>(prd));
80 }
81 
82 //____________________________________________________________________
84 {
85  PRDHandle_TRT * handle = static_cast<PRDHandle_TRT*>(handlebase);
86  assert(handle);
87 
88  if (m_d->needToTCheck) {
89  const double ToT = handle->driftCircle()->timeOverThreshold();
90  if (ToT<m_d->minToT)
91  return false;
92  if (ToT>m_d->maxToT)
93  return false;
94  }
95 
96  if (m_d->needLECheck) {
97  const int LE = handle->driftCircle()->driftTimeBin();//returns 0..24. 24 means no LT bits.
98  if (LE>=0&&LE<24) {
99  if (LE<m_d->minLE)
100  return false;
101  if (LE>m_d->maxLE)
102  return false;
103  }
104  }
105 
106 
108  if (handle->isBarrel()) {
110  return false;
111  } else {
113  return false;
114  }
115  }
116 
117  if (m_d->requireHT&&!handle->highLevel())
118  return false;
119 
120  return true;
121 }
122 
123 //____________________________________________________________________
124 void PRDCollHandle_TRT::setPartsFlags(PRDCommonFlags::InDetPartsFlags flags ) {
125  //NB: The code is this method is very similar in PRDCollHandle_Pixel::setPartsFlags, PRDCollHandle_SCT::setPartsFlags,
126  //PRDCollHandle_TRT::setPartsFlags and and PRDCollHandle_SpacePoints::setPartsFlags
127  //Fixme: base decision to recheck on visibility also!
128 
129  if (m_d->indetpartsflags==flags)
130  return;
131 
136  bool barrelChanged = (barrelPosChanged || barrelNegChanged);
137  bool endcapChanged = (endcapPosChanged || endcapNegChanged);
139 
142  for (;it!=itE;++it) {
143  PRDHandle_TRT* handle = static_cast<PRDHandle_TRT*>(*it);
144  if (handle->isBarrel()) {
145  if (barrelChanged&&(handle->isPositiveZ()?barrelPosChanged:barrelNegChanged))
146  recheckCutStatus(handle);
147  } else {
148  if (endcapChanged&&(handle->isPositiveZ()?endcapPosChanged:endcapNegChanged))
149  recheckCutStatus(handle);
150  }
151  }
152  largeChangesEnd();
153 }
154 
155 //____________________________________________________________________
157 {
158  double newminToT = (nbins-0.5)*3.125;
159  if (m_d->minToT==newminToT)
160  return;
161  bool cut_relaxed = (newminToT<m_d->minToT);
162  m_d->minToT=newminToT;
163  m_d->needToTCheck = (m_d->minToT>0.0||m_d->maxToT<24*3.125);
164  if (cut_relaxed)
166  else
168 }
169 
170 //____________________________________________________________________
172 {
173  double newmaxToT = (nbins+0.5)*3.125;
174  if (m_d->maxToT==newmaxToT)
175  return;
176  bool cut_relaxed = (newmaxToT>m_d->maxToT);
177  m_d->maxToT=newmaxToT;
178  m_d->needToTCheck = (m_d->minToT>0.0||m_d->maxToT<24*3.125);
179  if (cut_relaxed)
181  else
183 }
184 
185 //____________________________________________________________________
187 {
188  int newminLE = i-1;
189  if (m_d->minLE==newminLE)
190  return;
191  bool cut_relaxed = (newminLE<m_d->minLE);
192  m_d->minLE=newminLE;
193  m_d->needLECheck = (m_d->minLE>0||m_d->maxLE<23);
194  if (cut_relaxed)
196  else
198 }
199 
200 //____________________________________________________________________
202 {
203  int newmaxLE = i-1;
204  if (m_d->maxLE==newmaxLE)
205  return;
206  bool cut_relaxed = (newmaxLE>m_d->maxLE);
207  m_d->maxLE=newmaxLE;
208  m_d->needLECheck = (m_d->minLE>0||m_d->maxLE<23);
209  if (cut_relaxed)
211  else
213 }
214 
215 //____________________________________________________________________
217 {
218  if (m_d->requireHT==reqHT)
219  return;
220  m_d->requireHT=reqHT;
221  if (m_d->requireHT)
223  else
225  //NB: Since we assume the large majority are without HT, we do not
226  // base decision to recheck on presence of HT.
227 }
228 
229 //____________________________________________________________________
231 {
232  connect(controller,SIGNAL(projectTRTHitsChanged(bool)),this,SLOT(setProject(bool)));
233  setProject(controller->projectTRTHits());//Fixme: Do in pixel/sct as well!
234 
235  connect(controller,SIGNAL(highLightTRTHitsByHighThresholdChanged(bool)),this,SLOT(setHighLightHighThresholds(bool)));
237 
238  connect(controller,SIGNAL(inDetPartsFlagsChanged(PRDCommonFlags::InDetPartsFlags)),this,SLOT(setPartsFlags(PRDCommonFlags::InDetPartsFlags)));
239  setPartsFlags(controller->inDetPartsFlags());
240 
241  connect(controller,SIGNAL(trtMinToTChanged(unsigned)),this,SLOT(setMinToT(unsigned)));
242  setMinToT(controller->trtMinToT());
243 
244  connect(controller,SIGNAL(trtMaxToTChanged(unsigned)),this,SLOT(setMaxToT(unsigned)));
245  setMaxToT(controller->trtMaxToT());
246 
247  connect(controller,SIGNAL(trtMinLEChanged(unsigned)),this,SLOT(setMinLE(unsigned)));
248  setMinLE(controller->trtMinLE());
249 
250  connect(controller,SIGNAL(trtMaxLEChanged(unsigned)),this,SLOT(setMaxLE(unsigned)));
251  setMaxLE(controller->trtMaxLE());
252 
253  connect(controller,SIGNAL(trtRequireHTChanged(bool)),this,SLOT(setRequireHT(bool)));
254  setRequireHT(controller->trtRequireHT());
255 }
256 
257 //____________________________________________________________________
259 {
260  if (m_highlightHT==hl)
261  return;
262  m_highlightHT=hl;
263 
264  //Fixme: check PRDCollHandle::hasCustomHighlighting() before proceeding to loop here?.
265 
266  //call updateMaterial on all handles which have a high threshold.
269  for (;it!=itE;++it) {
270  if (static_cast<PRDHandle_TRT*>(*it)->highLevel())
271  (*it)->updateMaterial();
272  }
273  largeChangesEnd();
274 
275 }
276 
277 //____________________________________________________________________
278 void PRDCollHandle_TRT::setAppropriateProjection( InDetProjFlags::InDetProjPartsFlags f )
279 {
280  //Fixme: use message:
281  messageVerbose("setAppropriateProjection called.");
283  return;
284  messageVerbose("setAppropriateProjection => update needed.");
285 
286  InDetProjFlags::InDetProjPartsFlags changedparts = ( m_appropriateProjections ^ f );
288 
289  bool updateposbarrel = ( changedparts & InDetProjFlags::Barrel_AllPos );
290  bool updatenegbarrel = ( changedparts & InDetProjFlags::Barrel_AllNeg );
291  bool updateposendcap = ( changedparts & InDetProjFlags::EndCap_AllPos );
292  bool updatenegendcap = ( changedparts & InDetProjFlags::EndCap_AllNeg );
293  bool updatebarrel = updateposbarrel || updatenegbarrel;
294  bool updateendcap = updateposendcap || updatenegendcap;
295 
296  messageVerbose("setAppropriateProjection updating (brlA,brlC,ecA,ecC) = ("+str(updateposbarrel)+","+str(updatenegbarrel)
297  +","+str(updateposendcap)+","+str(updatenegendcap)+")");
298 
299  if (!updatebarrel&&!updateendcap) {
300  message("setAppropriateProjection WARNING: Unexpected flag value.");
301  return;
302  }
303 
304  common()->system()->deselectAll();
307  for (;it!=itE;++it) {
308  PRDHandle_TRT* handle = static_cast<PRDHandle_TRT*>(*it);
309  if (handle->isBarrel()) {
310  if (updatebarrel) {
311  if (handle->isPositiveZ()) {
312  if (updateposbarrel)
313  handle->update3DObjects();
314  } else {
315  if (updatenegbarrel)
316  handle->update3DObjects();
317  }
318  }
319  } else {
320  if (updateendcap) {
321  if (handle->isPositiveZ()) {
322  if (updateposendcap)
323  handle->update3DObjects();
324  } else {
325  if (updatenegendcap)
326  handle->update3DObjects();
327  }
328  }
329  }
330  }
331  largeChangesEnd();
332 
333 }
334 
335 //____________________________________________________________________
337 {
338  //Fixme: use message:
339  messageVerbose("setProject called with project = "+str(b));
340 
341  if (m_project==b) {
342  messageVerbose("setProject ==> No change.");
343  return;
344  }
345  m_project=b;
346  messageVerbose("setProject ==> Setting changed.");
347 
348  common()->system()->deselectAll();
351  for (;it!=itE;++it)
352  static_cast<PRDHandle_TRT*>(*it)->update3DObjects();
353  largeChangesEnd();
354 
355 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
InDetProjFlags::EndCap_AllNeg
@ EndCap_AllNeg
Definition: InDetProjFlags.h:67
PRDCollHandle_TRT::Imp::maxLE
int maxLE
Definition: PRDCollHandle_TRT.cxx:39
PRDCollHandle_TRT::setupSettingsFromControllerSpecific
virtual void setupSettingsFromControllerSpecific(PRDSystemController *) override
Definition: PRDCollHandle_TRT.cxx:230
PRDCollHandle_TRT::availableCollections
static QStringList availableCollections(IVP1System *)
Definition: PRDCollHandle_TRT.cxx:19
PRDSystemController::trtMinToT
unsigned trtMinToT() const
Definition: PRDSystemController.cxx:389
PRDCollHandle_TRT.h
PRDCollHandle_TRT::cut
virtual bool cut(PRDHandleBase *) override
Definition: PRDCollHandle_TRT.cxx:83
PRDHandle_TRT
Definition: PRDHandle_TRT.h:12
PRDSystemController::trtMaxToT
unsigned trtMaxToT() const
Definition: PRDSystemController.cxx:395
TRT_DetectorManager.h
PRDCollHandle_TRT::setProject
void setProject(bool)
Definition: PRDCollHandle_TRT.cxx:336
PRDCollHandle_TRT::Imp::attempted_detmgrload
bool attempted_detmgrload
Definition: PRDCollHandle_TRT.cxx:29
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
PRDCollHandleBase::recheckCutStatus
void recheckCutStatus(PRDHandleBase *)
Definition: PRDCollHandleBase.cxx:519
PRDCollHandle_TRT::setMaxLE
void setMaxLE(unsigned)
Definition: PRDCollHandle_TRT.cxx:201
InDet::TRT_DriftCircle::timeOverThreshold
double timeOverThreshold() const
returns Time over threshold in ns
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
PRDCollHandle_TRT::Imp
Definition: PRDCollHandle_TRT.cxx:25
PRDSystemController
Definition: PRDSystemController.h:34
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
PRDCollHandle_TRT::Imp::needLECheck
bool needLECheck
Definition: PRDCollHandle_TRT.cxx:41
skel.it
it
Definition: skel.GENtoEVGEN.py:396
PRDCollHandleBase::common
PRDSysCommonData * common() const
Definition: PRDCollHandleBase.h:49
PRDCollHandle_TRT::setHighLightHighThresholds
void setHighLightHighThresholds(bool)
Definition: PRDCollHandle_TRT.cxx:258
PRDCollHandle_TRT::setRequireHT
void setRequireHT(bool)
Definition: PRDCollHandle_TRT.cxx:216
VP1StdCollection::largeChangesBegin
virtual void largeChangesBegin()
Definition: VP1StdCollection.cxx:228
PRDSysCommonData
Definition: PRDSysCommonData.h:35
InDet::TRT_DriftCircle::driftTimeBin
int driftTimeBin() const
returns the leading edge bin defined as in TRT_LoLumRawData to be the first 0-1 transition
PRDHandle_TRT::driftCircle
const InDet::TRT_DriftCircle * driftCircle() const
Definition: PRDHandle_TRT.h:24
InDetProjFlags::Barrel_AllNeg
@ Barrel_AllNeg
Definition: InDetProjFlags.h:64
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
TruthTest.itE
itE
Definition: TruthTest.py:25
PRDCollHandle_TRT::Imp::idhelper
const TRT_ID * idhelper
Definition: PRDCollHandle_TRT.cxx:33
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
PRDSystemController::projectTRTHits
bool projectTRTHits() const
Definition: PRDSystemController.cxx:556
PRDHandle_TRT::isBarrel
bool isBarrel() const
Definition: PRDHandle_TRT.h:27
PRDCollHandleBase
Definition: PRDCollHandleBase.h:25
IVP1System
Definition: IVP1System.h:36
InDetProjFlags::Barrel_AllPos
@ Barrel_AllPos
Definition: InDetProjFlags.h:63
PRDSystemController::trtRequireHT
bool trtRequireHT() const
Definition: PRDSystemController.cxx:413
TRT
Definition: HitInfo.h:33
PRDSystemController::trtMaxLE
unsigned trtMaxLE() const
Definition: PRDSystemController.cxx:407
PRDCollHandle_TRT::Imp::maxToT
double maxToT
Definition: PRDCollHandle_TRT.cxx:37
PRDHandleBase::update3DObjects
void update3DObjects()
Definition: PRDHandleBase.cxx:257
lumiFormat.i
int i
Definition: lumiFormat.py:85
PRDSystemController::trtMinLE
unsigned trtMinLE() const
Definition: PRDSystemController.cxx:401
IVP13DSystem.h
SignEnum::LE
@ LE
Definition: SignEnums.h:21
PRDCollHandle_TRT::m_project
bool m_project
Definition: PRDCollHandle_TRT.h:53
PRDCollHandle_TRT::defaultColor
virtual QColor defaultColor() const override
Definition: PRDCollHandle_TRT.cxx:69
PRDCollHandle_TRT::Imp::trtdetmgr
const InDetDD::TRT_DetectorManager * trtdetmgr
Definition: PRDCollHandle_TRT.cxx:32
PRDCommonFlags::All
@ All
Definition: PRDCommonFlags.h:30
PRDCollHandle_TRT::Imp::needToTCheck
bool needToTCheck
Definition: PRDCollHandle_TRT.cxx:40
hist_file_dump.f
f
Definition: hist_file_dump.py:135
PRDCollHandle_TRT::Imp::indetpartsflags
PRDCommonFlags::InDetPartsFlags indetpartsflags
Definition: PRDCollHandle_TRT.cxx:35
PRDCollHandle_TRT::Imp::minLE
int minLE
Definition: PRDCollHandle_TRT.cxx:38
PRDCollHandle_TRT::Imp::minToT
double minToT
Definition: PRDCollHandle_TRT.cxx:36
VP1JobConfigInfo::hasTRTGeometry
static bool hasTRTGeometry()
Definition: VP1JobConfigInfo.cxx:129
PRDCollHandleBase::recheckCutStatusOfAllNotVisibleHandles
void recheckCutStatusOfAllNotVisibleHandles()
Definition: PRDCollHandleBase.cxx:603
TRT_DriftCircle.h
PRDDetType
Definition: PRDDetTypes.h:10
InDetProjFlags::EndCap_AllPos
@ EndCap_AllPos
Definition: InDetProjFlags.h:66
PRDHandle_TRT::isPositiveZ
bool isPositiveZ() const
Definition: PRDHandle_TRT.h:28
Trk::PrepRawData
Definition: PrepRawData.h:62
PRDCollHandle_TRT::m_d
Imp * m_d
Definition: PRDCollHandle_TRT.h:48
InDet::TRT_DriftCircleContainer
Trk::PrepRawDataContainer< TRT_DriftCircleCollection > TRT_DriftCircleContainer
Definition: TRT_DriftCircleContainer.h:27
TRT_DriftCircleContainer.h
PRDCollHandle_TRT::addPRD
virtual PRDHandleBase * addPRD(const Trk::PrepRawData *) override
Definition: PRDCollHandle_TRT.cxx:76
PRDSystemController::highLightTRTHitsByHighThreshold
bool highLightTRTHitsByHighThreshold()
Definition: PRDSystemController.cxx:517
PRDCollHandle_TRT::PRDCollHandle_TRT
PRDCollHandle_TRT(PRDSysCommonData *, const QString &key)
Definition: PRDCollHandle_TRT.cxx:46
PRDCollHandle_TRT::~PRDCollHandle_TRT
virtual ~PRDCollHandle_TRT()
Definition: PRDCollHandle_TRT.cxx:63
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
PRDSystemController.h
PRDCollHandle_TRT::setAppropriateProjection
void setAppropriateProjection(InDetProjFlags::InDetProjPartsFlags)
Definition: PRDCollHandle_TRT.cxx:278
InDetProjFlags
Definition: InDetProjFlags.h:23
PRDCollHandle_TRT::setMaxToT
void setMaxToT(unsigned)
Definition: PRDCollHandle_TRT.cxx:171
PRDCollHandle_TRT::setPartsFlags
void setPartsFlags(PRDCommonFlags::InDetPartsFlags)
Definition: PRDCollHandle_TRT.cxx:124
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
PRDCollHandle_TRT::setMinLE
void setMinLE(unsigned)
Definition: PRDCollHandle_TRT.cxx:186
VP1StdCollection::largeChangesEnd
virtual void largeChangesEnd()
Definition: VP1StdCollection.cxx:239
PRDCommonFlags::BarrelPositive
@ BarrelPositive
Definition: PRDCommonFlags.h:24
TRT_ID
Definition: TRT_ID.h:84
InDetDD::TRT_DetectorManager
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
Definition: TRT_DetectorManager.h:69
PRDCommonFlags::BarrelNegative
@ BarrelNegative
Definition: PRDCommonFlags.h:25
PRDCommonFlags::EndCapPositive
@ EndCapPositive
Definition: PRDCommonFlags.h:26
PRDHandle_TRT.h
PRDSysCommonData::system
IVP13DSystem * system() const
Definition: PRDSysCommonData.h:78
PRDCollHandleBase::recheckCutStatusOfAllVisibleHandles
void recheckCutStatusOfAllVisibleHandles()
Definition: PRDCollHandleBase.cxx:585
PRDSystemController::inDetPartsFlags
PRDCommonFlags::InDetPartsFlags inDetPartsFlags() const
Definition: PRDSystemController.cxx:378
PRDCollHandle_TRT::Imp::requireHT
bool requireHT
Definition: PRDCollHandle_TRT.cxx:42
calibdata.cd
cd
Definition: calibdata.py:51
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
VP1JobConfigInfo.h
PRDHandle_TRT::highLevel
bool highLevel() const
Definition: PRDHandle_TRT.h:29
PRDHandleBase
Definition: PRDHandleBase.h:35
PRDCollHandle_TRT::m_highlightHT
bool m_highlightHT
Definition: PRDCollHandle_TRT.h:52
PRDCommonFlags::EndCapNegative
@ EndCapNegative
Definition: PRDCommonFlags.h:27
PRDCollHandle_TRT::setMinToT
void setMinToT(unsigned)
Definition: PRDCollHandle_TRT.cxx:156
PRDCollHandleBase::getPrdHandles
std::vector< PRDHandleBase * > & getPrdHandles()
Definition: PRDCollHandleBase.cxx:507
IVP13DSystem::deselectAll
virtual void deselectAll(SoCooperativeSelection *exception_sel=0)
Definition: IVP13DSystem.cxx:331
VP1SGContentsHelper.h
PRDCollHandle_TRT::m_appropriateProjections
InDetProjFlags::InDetProjPartsFlags m_appropriateProjections
Definition: PRDCollHandle_TRT.h:54
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37