ATLAS Offline Software
IParticleCollHandle_Electron.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class IParticleCollHandle_Electron //
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::Electron);
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_Electron"+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_Electron::init 1"<<std::endl;
116  // std::cout<<"Calling VP1StdCollection::init with m_d->collSettingsButton (ElectronCollectionSettingsButton)="<<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_Electron::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  throw std::runtime_error("Electron - No collSettingsButton set!");
170  }
171  return *m_d->collSettingsButton;
172 }
173 
174 //____________________________________________________________________
176 {
177  if (!m_d->shouldLoad){
178  messageVerbose("not loading Electron collection - contains associated objects.");
179  return true;
180  }
181  messageVerbose("loading Electron collection");
182 
183  //Get collection:
184  const xAOD::ElectronContainer * coll(nullptr);
185 
186  #if defined BUILDVP1LIGHT
187  // Retrieve objects from the event
188  if( !(systemBase()->getEvent())->retrieve( coll, name().toStdString()).isSuccess() ) {
189  QString errMsg = "Failed to retrieve " + name();
190  message("Error: Could not retrieve collection with key="+name());
191  return false;
192  }
193  #else
194  if (!VP1SGAccessHelper(systemBase()).retrieve(coll, name())) {
195  message("Error: Could not retrieve track particle collection with key="+name());
196  return false;
197  }
198  #endif // BUILDVP1LIGHT
199 
200  // // Retrieve the xAOD particles:
201  // const xAOD::ElectronContainer* xaod = evtStore()->retrieve<const xAOD::ElectronContainer>( m_ElectronCollection );
202 
203  // Check that the auxiliary store association was made successfully:
204  if( ! coll->hasStore() ) {
205  message("No auxiliary store got associated to the Electron container with key: " +name());
206  }
207 
208  // This is needed for now, until the issues around the DV code are
209  // sorted out...
210  const_cast< xAOD::ElectronContainer* >( coll )->setStore(
211  ( SG::IAuxStore* ) coll->getConstStore() );
212 
213  //Make appropriate trk::track handles:
214  // hintNumberOfTracksInEvent(coll->size());
216  for ( it = coll->begin() ; it != itEnd; ++it) {
218  if (!*it) {
219  messageDebug("WARNING: Ignoring null Electron pointer.");
220  continue;
221  }
222  if ((*it)->charge()==0.0) {
223  messageDebug("WARNING: Ignoring Electron which claims to be neutral (charge()==0.0).");
224  continue;
225  }
227  std::cout << "elHandle ---> " << elH->electron().eta() << ", "
228  << elH->electron().nTrackParticles() << ", "
229  << elH->electron().trackParticle(0) << std::endl;
230  addHandle(elH);
231  }
232 
233  return true;
234 }
235 
236 //____________________________________________________________________
238 {
239  messageVerbose("IParticleCollHandle_Electron::cut()");
240 
241  if (!IParticleCollHandleBase::cut(handle))
242  return false;
243 
244  //FIXME - add cuts on tracksummary etc.
245 
246  return true;
247 }
248 
250  messageVerbose("IParticleCollHandle_Electron::showParametersChanged to "+str(val));
252 }
253 
255  messageVerbose("IParticleCollHandle_Electron::propagationOptionsChanged");
257 }
258 
259 void IParticleCollHandle_Electron::dumpToJSON( std::ofstream& str) const {
260  str << "\""<<name().toLatin1().data()<<"\":{";
261 
262  unsigned int num=0;
263  for (auto handle : getHandlesList() ) {
264  if (handle->visible()) {
265  if (num) str <<",\n";
266  handle->dumpToJSON(str);
267  }
268  }
269 
270  str << "}";
271 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IParticleCollHandle_Electron.h
ElectronCollectionSettingsButton
Definition: ElectronCollectionSettingsButton.h:14
IParticleCollHandle_Electron::IParticleCollHandle_Electron
IParticleCollHandle_Electron(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_Electron.cxx:75
IParticleCollHandle_Electron::~IParticleCollHandle_Electron
virtual ~IParticleCollHandle_Electron()
Definition: IParticleCollHandle_Electron.cxx:103
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
AODHandleBase
Definition: AODHandleBase.h:43
IParticleHandle_Electron::electron
const xAOD::Electron & electron() const
Definition: IParticleHandle_Electron.cxx:75
ObjectType
ObjectType
Definition: BaseObject.h:11
AODSysCommonData
Definition: AODSysCommonData.h:42
IParticleCollHandle_Electron::m_d
Imp * m_d
Definition: IParticleCollHandle_Electron.h:62
IParticleCollHandle_Electron::propagationOptionsChanged
void propagationOptionsChanged()
Definition: IParticleCollHandle_Electron.cxx:254
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
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
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
IParticleCollHandle_Electron::resetCachedValuesCuts
void resetCachedValuesCuts()
Definition: IParticleCollHandle_Electron.cxx:153
skel.it
it
Definition: skel.GENtoEVGEN.py:396
IParticleCollHandle_Electron::availableCollections
static QStringList availableCollections(IVP1System *)
Definition: IParticleCollHandle_Electron.cxx:53
IParticleCollHandle_Electron
Definition: IParticleCollHandle_Electron.h:26
VP1StdCollection::init
virtual void init(VP1MaterialButtonBase *button=0)
Definition: VP1StdCollection.cxx:73
IParticleCollHandle_Electron::Imp::shouldLoad
bool shouldLoad
Definition: IParticleCollHandle_Electron.cxx:65
xAOD::Electron_v1::trackParticle
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
Definition: Electron_v1.cxx:55
IParticleCollHandle_Electron::Imp::possiblyUpdateGUI
void possiblyUpdateGUI()
Definition: IParticleCollHandle_Electron.cxx:67
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
xAOD::Electron_v1::nTrackParticles
size_t nTrackParticles() const
Return the number xAOD::TrackParticles that match the electron candidate.
Definition: Electron_v1.cxx:44
AODCollHandleBase::common
const AODSysCommonData * common() const
Definition: AODCollHandleBase.h:88
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
ElectronCollectionSettingsButton::trackLightModel
SoLightModel * trackLightModel() const
Definition: ElectronCollectionSettingsButton.cxx:318
ElectronCollectionSettingsButton::cutAllowedPhi
QList< VP1Interval > cutAllowedPhi() const
Definition: ElectronCollectionSettingsButton.cxx:548
IParticleCollHandleBase::getHandlesList
QList< AODHandleBase * > getHandlesList() const
Definition: IParticleCollHandleBase.cxx:139
IVP1System
Definition: IVP1System.h:36
IParticleCollHandle_Electron::showParametersChanged
void showParametersChanged(bool)
Definition: IParticleCollHandle_Electron.cxx:249
ElectronContainer.h
ElectronCollectionSettingsButton::trackDrawStyle
SoDrawStyle * trackDrawStyle() const
Definition: ElectronCollectionSettingsButton.cxx:313
AODSystemController
Definition: AODSystemController.h:43
VP1StdCollection::visibilityChanged
void visibilityChanged(bool)
TEvent.h
Init.h
AODCollHandleBase::name
const QString & name() const
Definition: AODCollHandleBase.cxx:130
IParticleCollHandle_Electron::Imp
Definition: IParticleCollHandle_Electron.cxx:60
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
Derived DataVector<T>.
Definition: DataVector.h:794
AODSysCommonData.h
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
AODCollHandleBase::setupSettingsFromController
void setupSettingsFromController(const AODSystemController *)
Definition: AODCollHandleBase.cxx:112
IParticleHandle_Electron.h
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
ElectronCollectionSettingsButton.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IParticleCollHandle_Electron::collSettingsButton
const ElectronCollectionSettingsButton & collSettingsButton() const
Definition: IParticleCollHandle_Electron.cxx:166
ElectronCollectionSettingsButton::cutAllowedEta
VP1Interval cutAllowedEta() const
Definition: ElectronCollectionSettingsButton.cxx:540
IParticleCollHandle_Electron::dumpToJSON
virtual void dumpToJSON(std::ofstream &) const
Definition: IParticleCollHandle_Electron.cxx:259
IParticleCollHandle_Electron::Imp::theclass
IParticleCollHandle_Electron * theclass
Definition: IParticleCollHandle_Electron.cxx:62
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
VP1MaterialButtonBase
Definition: VP1MaterialButton.h:25
IParticleCollHandle_Electron::Imp::collSettingsButton
ElectronCollectionSettingsButton * collSettingsButton
Definition: IParticleCollHandle_Electron.cxx:64
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
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
IParticleCollHandle_Electron::Imp::updateGUICounter
int updateGUICounter
Definition: IParticleCollHandle_Electron.cxx:63
IParticleCollHandle_Electron::setupSettingsFromControllerSpecific
virtual void setupSettingsFromControllerSpecific(const AODSystemController *)
For extensions specific to this collection.
Definition: IParticleCollHandle_Electron.cxx:130
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IParticleCollHandle_Electron::load
virtual bool load()
Definition: IParticleCollHandle_Electron.cxx:175
ElectronCollectionSettingsButton::cutAllowedPt
VP1Interval cutAllowedPt() const
Definition: ElectronCollectionSettingsButton.cxx:504
IParticleCollHandleBase::addHandle
void addHandle(AODHandleBase *)
Definition: IParticleCollHandleBase.cxx:111
ElectronCollectionSettingsButton::setMaterialText
void setMaterialText(const QString &)
Definition: ElectronCollectionSettingsButton.cxx:110
calibdata.cd
cd
Definition: calibdata.py:51
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
xAOD::Egamma_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: Egamma_v1.cxx:70
AODCollHandleBase::update3DObjectsOfAllHandles
void update3DObjectsOfAllHandles()
Definition: AODCollHandleBase.cxx:223
str
Definition: BTagTrackIpAccessor.cxx:11
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
IParticleCollHandle_Electron::cut
virtual bool cut(AODHandleBase *)
Definition: IParticleCollHandle_Electron.cxx:237
IParticleCollHandleBase
Base class for collections holding AOD objects of iParticle type Handles pt etc cuts Local data:
Definition: IParticleCollHandleBase.h:50
VP1SGAccessHelper.h
IParticleCollHandle_Electron::init
virtual void init(VP1MaterialButtonBase *matBut=0)
Definition: IParticleCollHandle_Electron.cxx:111
IVP1System.h
IParticleHandle_Electron
Definition: IParticleHandle_Electron.h:27
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
VP1SGContentsHelper.h