Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IParticleCollHandle_Muon.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_Muon //
9 // //
10 // //
12 
13 //Local
15 #include "IParticleHandle_Muon.h"
17 #include "AODSysCommonData.h"
18 
19 //xAOD
20 #include "xAODMuon/MuonContainer.h"
21 #include "xAODMuon/Muon.h"
22 
23 //VP1
24 #include "VP1Base/IVP1System.h"
25 #ifndef BUILDVP1LIGHT
28 #endif // BUILDVP1LIGHT
29 
30 //Qt
31 #include <QStringList>
32 
33 // SoCoin
34 #include <Inventor/C/errors/debugerror.h>
35 #include <Inventor/nodes/SoSeparator.h>
36 #include <Inventor/nodes/SoSwitch.h>
37 #include <Inventor/nodes/SoMaterial.h>
38 #include "Inventor/nodes/SoDrawStyle.h"
39 #include "Inventor/nodes/SoLightModel.h"
40 
41 #ifdef BUILDVP1LIGHT
42  #include <QSettings>
43  #include "xAODRootAccess/Init.h"
44  #include "xAODRootAccess/TEvent.h"
45 #endif // BUILDVP1LIGHT
46 
47 //____________________________________________________________________
48 #if defined BUILDVP1LIGHT
50  {
51  return sys->getObjectList(xAOD::Type::Muon);
52  }
53 #else
55  {
57  }
58 #endif // BUILDVP1LIGHT
59 
60 //____________________________________________________________________
62 public:
66 
67  unsigned int last_minimumQuality;
69 
70  void possiblyUpdateGUI() {//Fixme: to IParticleCollHandleBase
71  if (!((updateGUICounter++)%50)) {
73  }
74  }
75 };
76 
77 //____________________________________________________________________
79  const QString& name, xAOD::Type::ObjectType type)
81 {
82  m_d->theclass = this;
83  m_d->updateGUICounter = 0;
87 
88  //The object names should not contain all sorts of funky chars (mat button style sheets wont work for instance):
89  QString safetext(text());
90  safetext.replace(' ','_');
91  safetext.replace('[','_');
92  safetext.replace(']','_');
93  safetext.replace('/','_');
94  safetext.replace('.','_');
95  safetext.replace(',','_');
96  safetext.replace('<','_');
97  safetext.replace('>','_');
98  safetext.replace('&','_');
99 
100  // SoMaterial* mat
101  // = m_d->collSettingsButton->defaultParameterMaterial();
102  // mat->setName(("IParticleCollHandle_Muon"+safetext).toStdString().c_str()); // Useful for debugging
103  // m_d->collSettingsButton->setDefaultParameterMaterial(m_d->defaultParametersMaterial); FIXME
104 }
105 
106 //____________________________________________________________________
108 {
109  delete m_d;
110 }
111 
112 //____________________________________________________________________
114 {
115  // std::cout<<"IParticleCollHandle_Muon::init 1"<<std::endl;
118  // std::cout<<"Calling VP1StdCollection::init with m_d->collSettingsButton (MuonCollectionSettingsButton)="<<m_d->collSettingsButton<<std::endl;
119  VP1StdCollection::init(m_d->collSettingsButton);//this call is required. Passing in m_d->collSettingsButton means we have the more complex button.
120  setupSettingsFromController(common()->controller());
121  connect(this,SIGNAL(visibilityChanged(bool)),this,SLOT(collVisibilityChanged(bool)));
122 
123  // Connections back to system
124  connect(this,SIGNAL(shownAssociatedObjectsChanged(const QList<const xAOD::TrackParticle*>&)),systemBase(),SLOT(updateAssociatedObjects(const QList<const xAOD::TrackParticle*>&))) ;
125 
126  // std::cout<<"IParticleCollHandle_Muon::init 2"<<std::endl; // debug
127  // std::cout<<"swi: "<<collSwitch()<<std::endl;
128  // std::cout<<"sep: "<<collSep()<<std::endl;
129  // std::cout<<"mat: "<<material()<<std::endl;
130 
133 }
134 
136  //cuts
137  connect(m_d->collSettingsButton,SIGNAL(cutAllowedPtChanged(const VP1Interval&)),this,SLOT(setCutAllowedPt(const VP1Interval&)));
139  //
140 
141  connect(m_d->collSettingsButton,SIGNAL(cutAllowedEtaChanged(const VP1Interval&)),this,SLOT(setCutAllowedEta(const VP1Interval&)));
143  //
144 
145  connect(m_d->collSettingsButton,SIGNAL(cutAllowedPhiChanged(const QList<VP1Interval>&)),this,SLOT(setCutAllowedPhi(const QList<VP1Interval>&)));
147 
148  connect(m_d->collSettingsButton,SIGNAL(minimumQualityChanged(unsigned int)),this,SLOT(setMinimumQuality(unsigned int)));
150 
151  connect(m_d->collSettingsButton,SIGNAL(shownAssociatedObjectsChanged(MuonCollectionSettingsButton::ShownAssociatedObjects)),this,SLOT(updateShownAssociatedObjects()));
152 }
153 
154 
156 {
157  // TODO: it is not used so far! Check Other collections and update accordingly
158 
159  // kinetic cuts
163  // other settings
165 
166  // TODO: adding "shownAssociatedObjectsChanged" settings as well??
167 }
168 
169 
170 
172  if (!m_d->collSettingsButton){
173  messageVerbose("No collSettingsButton set! Can't call init(), so crash is imminent...");
174  throw std::runtime_error("Muon - No collSettingsButton set!");
175  }
176  return *m_d->collSettingsButton;
177 }
178 
179 //____________________________________________________________________
181 {
182  messageVerbose("loading Muon collection");
183 
184  //Get collection:
185  const xAOD::MuonContainer * coll(nullptr);
186 
187  #if defined BUILDVP1LIGHT
188  // Retrieve objects from the event
189  if( !(systemBase()->getEvent())->retrieve( coll, name().toStdString()).isSuccess() ) {
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 Muon collection with key="+name());
196  return false;
197  }
198  #endif // BUILDVP1LIGHT
199 
200  // // Retrieve the xAOD particles:
201  // const xAOD::MuonContainer* xaod = evtStore()->retrieve<const xAOD::MuonContainer>( m_MuonCollection );
202 
203  // Check that the auxiliary store association was made successfully:
204  if( ! coll->hasStore() ) {
205  message("No auxiliary store got associated to the Muon 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::MuonContainer* >( coll )->setStore(
211  ( SG::IAuxStore* ) coll->getConstStore() );
212 
213  QList<const xAOD::TrackParticle*> listOfTrackParticles;
214  //Make appropriate trk::track handles:
215  // hintNumberOfTracksInEvent(coll->size());
216  xAOD::MuonContainer::const_iterator it, itEnd = coll->end();
217  for ( it = coll->begin() ; it != itEnd; ++it) {
219  if (!*it) {
220  messageDebug("WARNING: Ignoring null Muon pointer.");
221  continue;
222  }
223  // if ((*it)->primaryTrackParticle()->charge()==0.0) {
224  // messageDebug("WARNING: Ignoring Muon which claims to be neutral (charge()==0.0).");
225  // continue;
226  // }
227  IParticleHandle_Muon* muonH = new IParticleHandle_Muon(this,*it);
228  addHandle(muonH );
229  //std::cout << "muons ---> " << muonH->muon().eta() // debug
230  // << ", " << muonH->muon().primaryTrackParticle() << std::endl;
231  if( muonH->muon().primaryTrackParticle() ) {
233  listOfTrackParticles << muonH->muon().primaryTrackParticle();
234  } else {
237  }
238  }
239  if(listOfTrackParticles.size()>0) {
240  emit shownAssociatedObjectsChanged(listOfTrackParticles);
241  }
242  return true;
243 }
244 
245 
246 //____________________________________________________________________
248 {
249  QString msg = "SEVERE WARNING! No 'primaryTrackParticle' information found within the Muons collection of the input file! As a consequence, several quantities cannot be calculated. Also, expect crashes... Please, check the data contained in your input data file.";
251  systemBase()->message(msg);
252  return;
253 }
255 {
257 }
258 
259 //____________________________________________________________________
261 {
262 
263  if (!IParticleCollHandleBase::cut(handle))
264  return false;
265 
266  IParticleHandle_Muon * muon = dynamic_cast<IParticleHandle_Muon*>(handle);
267  if (not muon) return false;
268  std::cout<<"muon: "<<muon<<"\t muon->quality()="<<muon->quality()<<" collSettingsButton().minimumQuality()="<<collSettingsButton().minimumQuality()<<std::endl;
269  if (static_cast<unsigned int>(muon->quality()) > collSettingsButton().minimumQuality() )
270  return false;
271  //Fixme: more? Or just use base class method and remove this?
272 
273  return true;
274 }
275 
278  return;
279  std::cout<<"IParticleCollHandle_Muon::setMinimumQuality : "<<quality<<" last = "<<m_d->last_minimumQuality<<std::endl;
280  bool relaxcut = quality > m_d->last_minimumQuality;
282 
283  if (relaxcut)
285  else
287 
288  // If we shift this to the base class, then we can probably put it into one of the check methods
290 }
291 
293 {
294  QList<const xAOD::TrackParticle*> listOfTrackParticles;
295  MuonCollectionSettingsButton::ShownAssociatedObjects so = collSettingsButton().shownAssociatedObjects();
296 
298  AODHandleBase * handle;
299  while ( (handle = getNextHandle() ) ) {
300  if (handle->visible()){
301  IParticleHandle_Muon* mhandle = dynamic_cast<IParticleHandle_Muon*>(handle);
302  if (mhandle && so) {
303  // Only add if bit set, and if link!=0;
305  listOfTrackParticles<<mhandle->muon().trackParticle( xAOD::Muon::Primary);
306  if (so.testFlag(MuonCollectionSettingsButton::TrackParticlesCB) && mhandle->muon().trackParticle( xAOD::Muon::CombinedTrackParticle) )
307  listOfTrackParticles<<mhandle->muon().trackParticle( xAOD::Muon::CombinedTrackParticle);
308  if (so.testFlag(MuonCollectionSettingsButton::TrackParticlesID) && mhandle->muon().trackParticle( xAOD::Muon::InnerDetectorTrackParticle) )
309  listOfTrackParticles<<mhandle->muon().trackParticle( xAOD::Muon::InnerDetectorTrackParticle);
310  if (so.testFlag(MuonCollectionSettingsButton::TrackParticlesMS) && mhandle->muon().trackParticle( xAOD::Muon::MuonSpectrometerTrackParticle) )
311  listOfTrackParticles<<mhandle->muon().trackParticle( xAOD::Muon::MuonSpectrometerTrackParticle);
312  if (so.testFlag(MuonCollectionSettingsButton::TrackParticlesME) && mhandle->muon().trackParticle( xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle) )
313  listOfTrackParticles<<mhandle->muon().trackParticle( xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
314  }
315  }
316  }
317  std::cout<<"IParticleCollHandle_Muon::updateAssociatedTrackParticles Emitting "<<listOfTrackParticles.size()<<" track particles."<<std::endl;
318  emit shownAssociatedObjectsChanged(listOfTrackParticles);
319 }
320 
322 {
323  std::cout<<"IParticleCollHandle_Muon::setShownAssociatedObjects : "<<std::endl;
325 }
326 
327 
328 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AODHandleBase::visible
bool visible() const
Definition: AODHandleBase.h:54
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
IParticleCollHandle_Muon::cut
virtual bool cut(AODHandleBase *)
Definition: IParticleCollHandle_Muon.cxx:260
MuonCollectionSettingsButton::TrackParticlesCB
@ TrackParticlesCB
Definition: MuonCollectionSettingsButton.h:58
AODHandleBase
Definition: AODHandleBase.h:43
MuonCollectionSettingsButton::setMaterialText
void setMaterialText(const QString &)
Definition: MuonCollectionSettingsButton.cxx:84
xAOD::Muon_v1::trackParticle
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be NULL) to the TrackParticle used in identification of this muon.
Definition: Muon_v1.cxx:486
IParticleCollHandle_Muon::collSettingsButton
const MuonCollectionSettingsButton & collSettingsButton() const
Definition: IParticleCollHandle_Muon.cxx:171
ObjectType
ObjectType
Definition: BaseObject.h:11
AODSysCommonData
Definition: AODSysCommonData.h:42
IParticleCollHandle_Muon::m_d
Imp * m_d
Definition: IParticleCollHandle_Muon.h:64
Muon.h
IParticleCollHandle_Muon::Imp::theclass
IParticleCollHandle_Muon * theclass
Definition: IParticleCollHandle_Muon.cxx:63
IParticleCollHandle_Muon::Imp::last_minimumQuality
unsigned int last_minimumQuality
Definition: IParticleCollHandle_Muon.cxx:67
MuonCollectionSettingsButton::cutAllowedPhi
QList< VP1Interval > cutAllowedPhi() const
Definition: MuonCollectionSettingsButton.cxx:495
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
skel.it
it
Definition: skel.GENtoEVGEN.py:407
VP1StdCollection::init
virtual void init(VP1MaterialButtonBase *button=0)
Definition: VP1StdCollection.cxx:73
IParticleCollHandle_Muon.h
VP1Msg::messageWarningAllRed
static void messageWarningAllRed(const QString &str, IVP1System *sys=0)
Definition: VP1Msg.cxx:70
IParticleCollHandle_Muon::Imp::possiblyUpdateGUI
void possiblyUpdateGUI()
Definition: IParticleCollHandle_Muon.cxx:70
IParticleCollHandle_Muon::setupSettingsFromControllerSpecific
virtual void setupSettingsFromControllerSpecific(const AODSystemController *)
For extensions specific to this collection.
Definition: IParticleCollHandle_Muon.cxx:135
IParticleCollHandle_Muon::Imp
Definition: IParticleCollHandle_Muon.cxx:61
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition: VP1HelperClassBase.cxx:65
IParticleCollHandleBase::setCutAllowedPt
void setCutAllowedPt(const VP1Interval &)
Definition: IParticleCollHandleBase.cxx:218
IParticleCollHandle_Muon::setMinimumQuality
void setMinimumQuality(unsigned int)
Definition: IParticleCollHandle_Muon.cxx:276
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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
IParticleCollHandle_Muon::Imp::updateGUICounter
int updateGUICounter
Definition: IParticleCollHandle_Muon.cxx:64
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
MuonCollectionSettingsButton::minimumQuality
unsigned int minimumQuality() const
Definition: MuonCollectionSettingsButton.cxx:295
InDet::ExclusiveOrigin::Primary
@ Primary
Definition: InDetTrackTruthOriginDefs.h:163
IParticleCollHandle_Muon::load
virtual bool load()
Definition: IParticleCollHandle_Muon.cxx:180
IParticleCollHandle_Muon::Imp::collSettingsButton
MuonCollectionSettingsButton * collSettingsButton
Definition: IParticleCollHandle_Muon.cxx:65
IVP1System
Definition: IVP1System.h:36
MuonCollectionSettingsButton::TrackParticlesME
@ TrackParticlesME
Definition: MuonCollectionSettingsButton.h:61
MuonCollectionSettingsButton::TrackParticlesID
@ TrackParticlesID
Definition: MuonCollectionSettingsButton.h:59
AODSystemController
Definition: AODSystemController.h:43
IParticleCollHandle_Muon::printMsgNoTrackParticle
void printMsgNoTrackParticle()
Definition: IParticleCollHandle_Muon.cxx:247
VP1StdCollection::visibilityChanged
void visibilityChanged(bool)
TEvent.h
IParticleCollHandle_Muon::~IParticleCollHandle_Muon
virtual ~IParticleCollHandle_Muon()
Definition: IParticleCollHandle_Muon.cxx:107
IParticleHandle_Muon::muon
const xAOD::Muon & muon() const
Definition: IParticleHandle_Muon.cxx:477
AODCollHandleBase::recheckCutStatusOfAllNotVisibleHandles
void recheckCutStatusOfAllNotVisibleHandles()
Definition: AODCollHandleBase.cxx:177
Init.h
AODCollHandleBase::name
const QString & name() const
Definition: AODCollHandleBase.cxx:130
VP1StdCollection::text
QString text() const
Definition: VP1StdCollection.cxx:132
IParticleCollHandle_Muon::updateAssociatedTrackParticles
void updateAssociatedTrackParticles()
Definition: IParticleCollHandle_Muon.cxx:292
IParticleCollHandleBase::cut
virtual bool cut(AODHandleBase *)
Definition: IParticleCollHandleBase.cxx:146
IParticleCollHandleBase::setCutAllowedEta
void setCutAllowedEta(const VP1Interval &)
Definition: IParticleCollHandleBase.cxx:259
MuonCollectionSettingsButton::TrackParticlesPrimary
@ TrackParticlesPrimary
Definition: MuonCollectionSettingsButton.h:57
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AODSysCommonData.h
IParticleHandle_Muon
Definition: IParticleHandle_Muon.h:22
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:240
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
VP1MaterialButtonBase
Definition: VP1MaterialButton.h:25
MuonContainer.h
Muon
struct TBPatternUnitContext Muon
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
IParticleCollHandleBase::handleIterationBegin
virtual void handleIterationBegin()
Definition: IParticleCollHandleBase.cxx:123
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
IParticleCollHandle_Muon::hasPrimaryTrackParticleInfo
bool hasPrimaryTrackParticleInfo()
Definition: IParticleCollHandle_Muon.cxx:254
VP1Interval
Definition: VP1Interval.h:23
IParticleCollHandle_Muon::init
virtual void init(VP1MaterialButtonBase *matBut=0)
Definition: IParticleCollHandle_Muon.cxx:113
MuonCollectionSettingsButton
Definition: MuonCollectionSettingsButton.h:16
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
IParticleCollHandle_Muon::Imp::hasPrimaryTrackParticleInfo
bool hasPrimaryTrackParticleInfo
Definition: IParticleCollHandle_Muon.cxx:68
IParticleCollHandle_Muon::resetCachedValuesCuts
void resetCachedValuesCuts()
Definition: IParticleCollHandle_Muon.cxx:155
IParticleCollHandleBase::getNextHandle
virtual AODHandleBase * getNextHandle()
Definition: IParticleCollHandleBase.cxx:130
IParticleCollHandle_Muon::shownAssociatedObjectsChanged
void shownAssociatedObjectsChanged(const QList< const xAOD::TrackParticle * > &)
python.TrackLeptonConfig.quality
quality
Definition: TrackLeptonConfig.py:16
MuonCollectionSettingsButton::shownAssociatedObjects
ShownAssociatedObjects shownAssociatedObjects() const
Definition: MuonCollectionSettingsButton.cxx:310
IParticleCollHandleBase::addHandle
void addHandle(AODHandleBase *)
Definition: IParticleCollHandleBase.cxx:111
IParticleCollHandle_Muon::availableCollections
static QStringList availableCollections(IVP1System *)
Definition: IParticleCollHandle_Muon.cxx:54
MuonCollectionSettingsButton::cutAllowedEta
VP1Interval cutAllowedEta() const
Definition: MuonCollectionSettingsButton.cxx:487
calibdata.cd
cd
Definition: calibdata.py:51
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
MuonCollectionSettingsButton::trackLightModel
SoLightModel * trackLightModel() const
Definition: MuonCollectionSettingsButton.cxx:269
MuonCollectionSettingsButton::TrackParticlesMS
@ TrackParticlesMS
Definition: MuonCollectionSettingsButton.h:60
xAOD::Muon_v1::primaryTrackParticle
const TrackParticle * primaryTrackParticle() const
Returns a pointer (which should not usually be NULL, but might be if the muon has been stripped of in...
Definition: Muon_v1.cxx:400
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
IParticleCollHandle_Muon::IParticleCollHandle_Muon
IParticleCollHandle_Muon(AODSysCommonData *, const QString &name, xAOD::Type::ObjectType type)
Definition: IParticleCollHandle_Muon.cxx:78
IParticleCollHandle_Muon::updateShownAssociatedObjects
void updateShownAssociatedObjects()
Definition: IParticleCollHandle_Muon.cxx:321
IParticleHandle_Muon.h
IParticleCollHandleBase
Base class for collections holding AOD objects of iParticle type Handles pt etc cuts Local data:
Definition: IParticleCollHandleBase.h:50
MuonCollectionSettingsButton::cutAllowedPt
VP1Interval cutAllowedPt() const
Definition: MuonCollectionSettingsButton.cxx:451
AODCollHandleBase::recheckCutStatusOfAllVisibleHandles
void recheckCutStatusOfAllVisibleHandles()
Definition: AODCollHandleBase.cxx:144
VP1SGAccessHelper.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
IVP1System.h
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
IParticleCollHandle_Muon
Definition: IParticleCollHandle_Muon.h:28
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
MuonCollectionSettingsButton::trackDrawStyle
SoDrawStyle * trackDrawStyle() const
Definition: MuonCollectionSettingsButton.cxx:264
VP1SGContentsHelper.h
MuonCollectionSettingsButton.h