ATLAS Offline Software
IParticleCollHandle_TrackParticle.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class IParticleCollHandle_TrackParticle //
9 // //
10 // //
12 
13 //Local
17 #include "AODSysCommonData.h"
18 
19 //xAOD
21 
22 //VP1
23 #include "VP1Base/IVP1System.h"
24 #ifndef BUILDVP1LIGHT
27 #endif // BUILDVP1LIGHT
28 
29 //Qt
30 #include <QStringList>
31 
32 // SoCoin
33 #include <Inventor/C/errors/debugerror.h>
34 #include <Inventor/nodes/SoSeparator.h>
35 #include <Inventor/nodes/SoSwitch.h>
36 #include <Inventor/nodes/SoMaterial.h>
37 #include "Inventor/nodes/SoDrawStyle.h"
38 #include "Inventor/nodes/SoLightModel.h"
39 
40 #ifdef BUILDVP1LIGHT
41  #include <QSettings>
42  #include "xAODRootAccess/Init.h"
43  #include "xAODRootAccess/TEvent.h"
44 #endif // BUILDVP1LIGHT
45 
46 //____________________________________________________________________
47 #if defined BUILDVP1LIGHT
49  {
50  return sys->getObjectList(xAOD::Type::TrackParticle);
51  }
52 #else
54  {
56  }
57 #endif // BUILDVP1LIGHT
58 
59 //____________________________________________________________________
61 public:
65  bool shouldLoad;
66 
67  void possiblyUpdateGUI() {//Fixme: to IParticleCollHandleBase
68  if (!((updateGUICounter++)%50)) {
70  }
71  }
72 };
73 
74 //____________________________________________________________________
76  const QString& name, xAOD::Type::ObjectType type, bool shouldLoad)
78 {
79  m_d->theclass = this;
80  m_d->updateGUICounter = 0;
82  m_d->shouldLoad = shouldLoad;
83 
84  //The object names should not contain all sorts of funky chars (mat button style sheets wont work for instance):
85  QString safetext(text());
86  safetext.replace(' ','_');
87  safetext.replace('[','_');
88  safetext.replace(']','_');
89  safetext.replace('/','_');
90  safetext.replace('.','_');
91  safetext.replace(',','_');
92  safetext.replace('<','_');
93  safetext.replace('>','_');
94  safetext.replace('&','_');
95 
96  // SoMaterial* mat
97  // = m_d->collSettingsButton->defaultParameterMaterial();
98  // mat->setName(("IParticleCollHandle_TrackParticle"+safetext).toStdString().c_str()); // Useful for debugging
99  // m_d->collSettingsButton->setDefaultParameterMaterial(m_d->defaultParametersMaterial); FIXME
100 }
101 
102 //____________________________________________________________________
104 {
105  delete m_d;
106  // FIXME - check that we're not leaking handles if (!m_d->shouldLoad){
107 
108 }
109 
110 //____________________________________________________________________
112 {
113  // std::cout<<"IParticleCollHandle_TrackParticle::init 1"<<std::endl;
116  // std::cout<<"Calling VP1StdCollection::init with m_d->collSettingsButton (TrackParticleCollectionSettingsButton)="<<m_d->collSettingsButton<<std::endl;
117  VP1StdCollection::init(m_d->collSettingsButton);//this call is required. Passing in m_d->collSettingsButton means we have the more complex button.
118  setupSettingsFromController(common()->controller());
119  connect(this,SIGNAL(visibilityChanged(bool)),this,SLOT(collVisibilityChanged(bool)));
120 
121  // std::cout<<"IParticleCollHandle_TrackParticle::init 2"<<std::endl;
122  // std::cout<<"swi: "<<collSwitch()<<std::endl;
123  // std::cout<<"sep: "<<collSep()<<std::endl;
124  // std::cout<<"mat: "<<material()<<std::endl;
125 
128 }
129 
131  //cuts
132  connect(m_d->collSettingsButton,SIGNAL(cutAllowedPtChanged(const VP1Interval&)),this,SLOT(setCutAllowedPt(const VP1Interval&)));
134  //
135 
136  connect(m_d->collSettingsButton,SIGNAL(cutAllowedEtaChanged(const VP1Interval&)),this,SLOT(setCutAllowedEta(const VP1Interval&)));
138  //
139 
140  connect(m_d->collSettingsButton,SIGNAL(cutAllowedPhiChanged(const QList<VP1Interval>&)),this,SLOT(setCutAllowedPhi(const QList<VP1Interval>&)));
142 
143  // Propagation
145 
146  // Parameters
148  connect(m_d->collSettingsButton,SIGNAL(colourParametersByTypeChanged(bool)),this,SLOT(showParametersChanged(bool)));
149  // Just reusing the same slot, since it doesn
150 
151 }
152 
154 {
155  // TODO: it is not used so far! Check Other collections and update accordingly
156 
157  // kinetic cuts
161 
162  // TODO: adding "propagation" and "parameters" settings as well??
163 }
164 
165 
167  if (!m_d->collSettingsButton){
168  messageVerbose("No collSettingsButton set! Can't call init(), so crash is imminent...");
169  }
170  return *m_d->collSettingsButton;
171 }
172 
173 //____________________________________________________________________
175 {
176  if (!m_d->shouldLoad){
177  messageVerbose("not loading TrackParticle collection - contains associated objects.");
178  return true;
179  }
180  messageVerbose("loading TrackParticle collection");
181 
182  //Get collection:
183  const xAOD::TrackParticleContainer * coll(nullptr);
184 
185  #if defined BUILDVP1LIGHT
186  // Retrieve objects from the event
187  if( !(systemBase()->getEvent())->retrieve( coll, name().toStdString()).isSuccess() ) {
188  message("Error: Could not retrieve collection with key="+name());
189  return false;
190  }
191  #else
192  if (!VP1SGAccessHelper(systemBase()).retrieve(coll, name())) {
193  message("Error: Could not retrieve track particle collection with key="+name());
194  return false;
195  }
196  #endif // BUILDVP1LIGHT
197 
198  // // Retrieve the xAOD particles:
199  // const xAOD::TrackParticleContainer* xaod = evtStore()->retrieve<const xAOD::TrackParticleContainer>( m_TrackParticleCollection );
200 
201  // Check that the auxiliary store association was made successfully:
202  if( ! coll->hasStore() ) {
203  message("No auxiliary store got associated to the TrackParticle container with key: " +name());
204  }
205 
206  // This is needed for now, until the issues around the DV code are
207  // sorted out...
208  const_cast< xAOD::TrackParticleContainer* >( coll )->setStore(
209  ( SG::IAuxStore* ) coll->getConstStore() );
210 
211  //Make appropriate trk::track handles:
212  // hintNumberOfTracksInEvent(coll->size());
214  for ( it = coll->begin() ; it != itEnd; ++it) {
216  if (!*it) {
217  messageDebug("WARNING: Ignoring null TrackParticle pointer.");
218  continue;
219  }
220  if ((*it)->charge()==0.0) {
221  messageDebug("WARNING: Ignoring TrackParticle which claims to be neutral (charge()==0.0).");
222  continue;
223  }
225  }
226 
227  return true;
228 }
229 
230 //____________________________________________________________________
232 {
233  messageVerbose("IParticleCollHandle_TrackParticle::cut()");
234 
235  if (!IParticleCollHandleBase::cut(handle))
236  return false;
237 
238  //FIXME - add cuts on tracksummary etc.
239 
240  return true;
241 }
242 
244  messageVerbose("IParticleCollHandle_TrackParticle::showParametersChanged to "+str(val));
246 }
247 
249  messageVerbose("IParticleCollHandle_TrackParticle::propagationOptionsChanged");
251 }
252 
254  str << "\""<<name().toLatin1().data()<<"\":{";
255 
256  unsigned int num=0;
257  for (auto handle : getHandlesList() ) {
258  if (handle->visible()) {
259  if (num) str <<",\n";
260  handle->dumpToJSON(str);
261  }
262  }
263 
264  str << "}";
265 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IParticleHandle_TrackParticle.h
IParticleCollHandle_TrackParticle::Imp::collSettingsButton
TrackParticleCollectionSettingsButton * collSettingsButton
Definition: IParticleCollHandle_TrackParticle.cxx:64
IParticleCollHandle_TrackParticle
Definition: IParticleCollHandle_TrackParticle.h:25
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TrackParticleCollectionSettingsButton
Definition: TrackParticleCollectionSettingsButton.h:14
AODHandleBase
Definition: AODHandleBase.h:43
TrackParticleCollectionSettingsButton::cutAllowedEta
VP1Interval cutAllowedEta() const
Definition: TrackParticleCollectionSettingsButton.cxx:539
IParticleCollHandle_TrackParticle::Imp::theclass
IParticleCollHandle_TrackParticle * theclass
Definition: IParticleCollHandle_TrackParticle.cxx:62
ObjectType
ObjectType
Definition: BaseObject.h:11
AODSysCommonData
Definition: AODSysCommonData.h:42
IParticleCollHandle_TrackParticle::load
virtual bool load()
Definition: IParticleCollHandle_TrackParticle.cxx:174
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
IParticleCollHandle_TrackParticle::dumpToJSON
virtual void dumpToJSON(std::ofstream &) const
Definition: IParticleCollHandle_TrackParticle.cxx:253
VP1StdCollection::collSwitch
SoSwitch * collSwitch() const
Add this somewhere in your scenegraph (do not add any children here!)
Definition: VP1StdCollection.cxx:204
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
IParticleCollHandle_TrackParticle::propagationOptionsChanged
void propagationOptionsChanged()
Definition: IParticleCollHandle_TrackParticle.cxx:248
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TrackParticleCollectionSettingsButton::cutAllowedPhi
QList< VP1Interval > cutAllowedPhi() const
Definition: TrackParticleCollectionSettingsButton.cxx:547
IParticleCollHandle_TrackParticle::resetCachedValuesCuts
void resetCachedValuesCuts()
Definition: IParticleCollHandle_TrackParticle.cxx:153
VP1StdCollection::init
virtual void init(VP1MaterialButtonBase *button=0)
Definition: VP1StdCollection.cxx:73
IParticleCollHandle_TrackParticle::init
virtual void init(VP1MaterialButtonBase *matBut=0)
Definition: IParticleCollHandle_TrackParticle.cxx:111
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition: VP1HelperClassBase.cxx:65
IParticleCollHandleBase::setCutAllowedPt
void setCutAllowedPt(const VP1Interval &)
Definition: IParticleCollHandleBase.cxx:218
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
IParticleCollHandleBase::setCutAllowedPhi
void setCutAllowedPhi(const QList< VP1Interval > &)
Definition: IParticleCollHandleBase.cxx:284
AODCollHandleBase::common
const AODSysCommonData * common() const
Definition: AODCollHandleBase.h:88
TrackParticleCollectionSettingsButton.h
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
IParticleCollHandle_TrackParticle::Imp::shouldLoad
bool shouldLoad
Definition: IParticleCollHandle_TrackParticle.cxx:65
IParticleCollHandle_TrackParticle::collSettingsButton
const TrackParticleCollectionSettingsButton & collSettingsButton() const
Definition: IParticleCollHandle_TrackParticle.cxx:166
IParticleCollHandleBase::getHandlesList
QList< AODHandleBase * > getHandlesList() const
Definition: IParticleCollHandleBase.cxx:139
IParticleCollHandle_TrackParticle::~IParticleCollHandle_TrackParticle
virtual ~IParticleCollHandle_TrackParticle()
Definition: IParticleCollHandle_TrackParticle.cxx:103
IVP1System
Definition: IVP1System.h:36
AODSystemController
Definition: AODSystemController.h:43
VP1StdCollection::visibilityChanged
void visibilityChanged(bool)
TEvent.h
Init.h
IParticleCollHandle_TrackParticle::Imp::possiblyUpdateGUI
void possiblyUpdateGUI()
Definition: IParticleCollHandle_TrackParticle.cxx:67
TrackParticleCollectionSettingsButton::cutAllowedPt
VP1Interval cutAllowedPt() const
Definition: TrackParticleCollectionSettingsButton.cxx:503
VP1StdCollection::text
QString text() const
Definition: VP1StdCollection.cxx:132
IParticleCollHandleBase::cut
virtual bool cut(AODHandleBase *)
Definition: IParticleCollHandleBase.cxx:146
IParticleCollHandleBase::setCutAllowedEta
void setCutAllowedEta(const VP1Interval &)
Definition: IParticleCollHandleBase.cxx:259
DataVector< xAOD::TrackParticle_v1 >
AODSysCommonData.h
TrackParticleCollectionSettingsButton::trackLightModel
SoLightModel * trackLightModel() const
Definition: TrackParticleCollectionSettingsButton.cxx:317
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
AODCollHandleBase::setupSettingsFromController
void setupSettingsFromController(const AODSystemController *)
Definition: AODCollHandleBase.cxx:112
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IParticleCollHandle_TrackParticle::Imp
Definition: IParticleCollHandle_TrackParticle.cxx:60
IParticleHandle_TrackParticle
Definition: IParticleHandle_TrackParticle.h:27
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
VP1MaterialButtonBase
Definition: VP1MaterialButton.h:25
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
AODCollHandleBase::collVisibilityChanged
void collVisibilityChanged(bool)
Definition: AODCollHandleBase.cxx:393
VP1Interval
Definition: VP1Interval.h:23
IParticleCollHandle_TrackParticle::m_d
Imp * m_d
Definition: IParticleCollHandle_TrackParticle.h:60
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IParticleCollHandle_TrackParticle.h
TrackParticleCollectionSettingsButton::trackDrawStyle
SoDrawStyle * trackDrawStyle() const
Definition: TrackParticleCollectionSettingsButton.cxx:312
IParticleCollHandle_TrackParticle::cut
virtual bool cut(AODHandleBase *)
Definition: IParticleCollHandle_TrackParticle.cxx:231
IParticleCollHandleBase::addHandle
void addHandle(AODHandleBase *)
Definition: IParticleCollHandleBase.cxx:111
calibdata.cd
cd
Definition: calibdata.py:51
IParticleCollHandle_TrackParticle::availableCollections
static QStringList availableCollections(IVP1System *)
Definition: IParticleCollHandle_TrackParticle.cxx:53
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
AODCollHandleBase::update3DObjectsOfAllHandles
void update3DObjectsOfAllHandles()
Definition: AODCollHandleBase.cxx:223
IParticleCollHandle_TrackParticle::showParametersChanged
void showParametersChanged(bool)
Definition: IParticleCollHandle_TrackParticle.cxx:243
str
Definition: BTagTrackIpAccessor.cxx:11
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
IParticleCollHandle_TrackParticle::IParticleCollHandle_TrackParticle
IParticleCollHandle_TrackParticle(AODSysCommonData *, const QString &name, xAOD::Type::ObjectType type, bool shouldLoad=true)
shouldLoad is used to disable the call to load if the collhandle is for temporary (read: associated) ...
Definition: IParticleCollHandle_TrackParticle.cxx:75
IParticleCollHandle_TrackParticle::Imp::updateGUICounter
int updateGUICounter
Definition: IParticleCollHandle_TrackParticle.cxx:63
TrackParticleCollectionSettingsButton::setMaterialText
void setMaterialText(const QString &)
Definition: TrackParticleCollectionSettingsButton.cxx:110
IParticleCollHandle_TrackParticle::setupSettingsFromControllerSpecific
virtual void setupSettingsFromControllerSpecific(const AODSystemController *)
For extensions specific to this collection.
Definition: IParticleCollHandle_TrackParticle.cxx:130
IParticleCollHandleBase
Base class for collections holding AOD objects of iParticle type Handles pt etc cuts Local data:
Definition: IParticleCollHandleBase.h:50
VP1SGAccessHelper.h
IVP1System.h
TrackParticleContainer.h
AODCollHandleBase::name
QString name() const
Definition: AODCollHandleBase.cxx:130
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
VP1SGContentsHelper.h