ATLAS Offline Software
Loading...
Searching...
No Matches
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"
44#endif // BUILDVP1LIGHT
45
46//____________________________________________________________________
47#if defined BUILDVP1LIGHT
49 {
50 return sys->getObjectList(xAOD::Type::Electron);
51 }
52#else
57#endif // BUILDVP1LIGHT
58
59//____________________________________________________________________
61public:
66
67 void possiblyUpdateGUI() {//Fixme: to IParticleCollHandleBase
68 if (!((updateGUICounter++)%50)) {
69 theclass->systemBase()->updateGUI();
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;
81 m_d->collSettingsButton=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;
114 m_d->collSettingsButton = new ElectronCollectionSettingsButton;
115 m_d->collSettingsButton->setMaterialText(name());
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
126 collSwitch()->addChild(m_d->collSettingsButton->trackLightModel());
127 collSwitch()->addChild(m_d->collSettingsButton->trackDrawStyle());
128}
129
131 //cuts
132 connect(m_d->collSettingsButton,SIGNAL(cutAllowedPtChanged(const VP1Interval&)),this,SLOT(setCutAllowedPt(const VP1Interval&)));
133 setCutAllowedPt(m_d->collSettingsButton->cutAllowedPt());
134 //
135
136 connect(m_d->collSettingsButton,SIGNAL(cutAllowedEtaChanged(const VP1Interval&)),this,SLOT(setCutAllowedEta(const VP1Interval&)));
137 setCutAllowedEta(m_d->collSettingsButton->cutAllowedEta());
138 //
139
140 connect(m_d->collSettingsButton,SIGNAL(cutAllowedPhiChanged(const QList<VP1Interval>&)),this,SLOT(setCutAllowedPhi(const QList<VP1Interval>&)));
141 setCutAllowedPhi(m_d->collSettingsButton->cutAllowedPhi());
142
143 // Propagation
144 connect(m_d->collSettingsButton,SIGNAL(propagationOptionsChanged()), this,SLOT(propagationOptionsChanged()));
145
146 // Parameters
147 connect(m_d->collSettingsButton,SIGNAL(showParametersChanged(bool)), this,SLOT(showParametersChanged(bool)));
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
158 setCutAllowedPt(m_d->collSettingsButton->cutAllowedPt());
159 setCutAllowedEta(m_d->collSettingsButton->cutAllowedEta());
160 setCutAllowedPhi(m_d->collSettingsButton->cutAllowedPhi());
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) {
217 m_d->possiblyUpdateGUI();
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
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}
const AODSysCommonData * common() const
void setupSettingsFromController(const AODSystemController *)
const QString & name() const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
IParticleCollHandleBase(AODSysCommonData *, const QString &name, xAOD::Type::ObjectType)
void setCutAllowedPt(const VP1Interval &)
virtual bool cut(AODHandleBase *)
QList< AODHandleBase * > getHandlesList() const
void setCutAllowedPhi(const QList< VP1Interval > &)
void setCutAllowedEta(const VP1Interval &)
ElectronCollectionSettingsButton * collSettingsButton
virtual void dumpToJSON(std::ofstream &) const
virtual void init(VP1MaterialButtonBase *matBut=0)
virtual void setupSettingsFromControllerSpecific(const AODSystemController *)
For extensions specific to this collection.
static QStringList availableCollections(IVP1System *)
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) ...
const ElectronCollectionSettingsButton & collSettingsButton() const
const xAOD::Electron & electron() const
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
void messageVerbose(const QString &) const
void message(const QString &) const
IVP1System * systemBase() const
void messageDebug(const QString &) const
QStringList getKeys() const
virtual void init(VP1MaterialButtonBase *button=0)
SoSwitch * collSwitch() const
Add this somewhere in your scenegraph (do not add any children here!)
void visibilityChanged(bool)
QString text() const
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
size_t nTrackParticles() const
Return the number xAOD::TrackParticles that match the electron candidate.
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ Electron
The object is an electron.
Definition ObjectType.h:46
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".