ATLAS Offline Software
VP1AODSystem.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 VP1AODSystem //
9 // //
10 // //
12 
13 // Local
17 #include "AODCollHandleBase.h"
18 #ifndef BUILDVP1LIGHT
20 #endif
26 #include "MissingEtCollHandle.h"
27 #include "VertexCollHandle.h"
28 #include "AODSysCommonData.h"
29 #include "AODCollWidget.h"
30 
31 //VP1
35 #include "VP1Base/VP1Serialise.h"
36 #include "VP1Base/VP1Deserialise.h"
37 #include "VP1Utils/VP1DetInfo.h"
38 #ifndef BUILDVP1LIGHT
41 #endif
42 
43 // SoCoin (see if we can shift this to external file?)
44 #include <Inventor/nodes/SoSeparator.h>
45 #include <Inventor/nodes/SoMaterial.h>
46 #include <Inventor/nodes/SoSwitch.h>
47 #include <Inventor/nodes/SoComplexity.h>
48 #include <Inventor/nodes/SoLineSet.h>
49 #include <Inventor/nodes/SoVertexProperty.h>
50 #include "Inventor/nodes/SoDrawStyle.h"
51 #include "Inventor/nodes/SoLightModel.h"
52 #include <Inventor/nodes/SoCylinder.h>
53 #include <Inventor/SoPath.h>
54 #include <Inventor/nodes/SoFont.h>
55 
56 // Std
57 #include <sstream>
58 #include <typeinfo>
59 
60 #ifndef BUILDVP1LIGHT
61  // Athena
62  #include "StoreGate/StoreGateSvc.h"
64 #endif
65 
66 // Qt
67 #include <QTreeWidget>
68 
69 // XAOD
72 #include "xAODCore/tools/IOStats.h"
73 
74 // ROOT include(s):
75 #include <TFile.h>
76 #include <TError.h>
77 
78 
80 public:
81  VP1AODSystem * theclass = nullptr;
82  AODSysCommonData * common = nullptr;
84  // AODHandleSelectionManager * ascObjSelManager;
85 
86  SoSeparator * totmomsep = nullptr;
87  SoLineSet * totmomline = nullptr;
89  double totmass = 0.0;
90 
91 
92  // TrackCommonFlags::SELECTIONMODE selMode;
93 
94  //Return value is number of track handles used for input (e.g. those without valid momentum info are ignored)
95  unsigned calcTotalMomentumOfSelectedHandles(Amg::Vector3D& totmom, Amg::Vector3D& totpos, double& mass);
96 
97  // template <class T>
98  // QList<IParticleCollHandleBase*> createSpecificCollections(xAOD::Type::ObjectType type) {
99  // QList<IParticleCollHandleBase*> l;
100  // for (const QString& name : T::availableCollections(theclass)) {
101  // T * col = new T(common,name,type);
102  // col->init();
103  // l << col;
104  // }
105  // return l;
106  // }
107  template <class T>
109  QList<AODCollHandleBase*> l;
110  for (const QString& name : T::availableCollections(theclass)) {
111  T * col = new T(common,name,type);
112  col->init();
113  l << col;
114  }
115  return l;
116  }
117 
118  /*
119  * here we load the different systems (Muon, Jet, TrackParticle, ...)
120  *
121  * types from:
122  * http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Event/xAOD/xAODBase/Root/ObjectType.cxx
123  *
124  */
125  QList<AODCollHandleBase*> createCollections() {
126  QList<AODCollHandleBase*> l;
127  l << createSpecificCollections<IParticleCollHandle_TrackParticle>(xAOD::Type::TrackParticle);
128  l << createSpecificCollections<IParticleCollHandle_Jet>(xAOD::Type::Jet);
129  l << createSpecificCollections<IParticleCollHandle_Muon>(xAOD::Type::Muon);
130  l << createSpecificCollections<IParticleCollHandle_Electron>(xAOD::Type::Electron);
131  l << createSpecificCollections<IParticleCollHandle_CaloCluster>(xAOD::Type::CaloCluster); // Calorimeter Clusters
132  l << createSpecificCollections<MissingEtCollHandle>(xAOD::Type::Other);
133  l << createSpecificCollections<VertexCollHandle>(xAOD::Type::Vertex);
134  return l;
135  }
136 };
137 
138 //____________________________________________________________________
141 "System showing all (x)AOD objects.",
142 "Edward.Moyse@cern.ch, Riccardo.maria.bianchi@cern.ch, Sebastian.Andreas.Merkt@cern.ch"), m_d(new Imp)
143 
144 {
145  m_d->theclass = this;
146  m_d->selObjects = 0;
147  m_d->common = 0;
148  m_d->totmomsep = 0;
149  m_d->totmomline = 0;
150  m_d->totmomgev = Amg::Vector3D(0,0,0);
151 }
152 
153 //____________________________________________________________________
155 {
156  if(m_d) {
157  if(m_d->common) {
158  if(m_d->common->controller()) {
159  if (m_d->common->controller()->objBrowser()) {
160  m_d->common->controller()->objBrowser()->close();
161  }
162  }
163  }
164  }
165  delete m_d; m_d=0;
166 }
167 
168 //____________________________________________________________________
170 {
171  messageVerbose("systemcreate");
173 
174 #ifndef BUILDVP1LIGHT
175  //Get available extrapolators:
176  QString tooltype("Trk::ExtrapolationEngine");
177  VP1AvailableToolsHelper availTools(this);
178  availTools.addMonitoredType(tooltype);
179  QStringList existingExtrapolators = availTools.availableTools();
180 
181  for (const QString& value : existingExtrapolators)
183 
184  VP1ToolAccessHelper toolaccess(this);
185  Trk::IExtrapolationEngine * extrapolator = toolaccess.getToolPointer<Trk::IExtrapolationEngine>("Trk::ExtrapolationEngine/AtlasExtrapolation",false/*silent*/,true/*create if not exists*/);
186  m_d->common->setExtrapolator(extrapolator);
187 #endif
188 
189 #ifdef BUILDVP1LIGHT
190  // Load event from xAOD once AODSystem is created
191  emit signalLoadEvent(this);
192 #endif // BUILDVP1LIGHT
193 
194  // m_d->common->controller()->initTools();
195 }
196 
197 //____________________________________________________________________
199 {
200  messageVerbose("systemuncreate");
201  if (m_d->totmomsep) {
202  m_d->totmomsep->unref();
203  m_d->totmomsep=0;
204  }
205  if (m_d->totmomline) {
206  m_d->totmomline->unref();
207  m_d->totmomline = 0;
208  }
209  delete m_d->common; m_d->common = 0;
210 }
211 
212 //____________________________________________________________________
214 {
215  messageVerbose("buildController start");
216  AODSystemController * controller = new AODSystemController(this);
217  m_d->common = new AODSysCommonData(this,controller);//Fixme: Do this on-demand in buildeventscenegraph!!
218  controller->setCommonData(m_d->common);
219 
220  // connect(controller,SIGNAL(selectionModeChanged(TrackCommonFlags::SELECTIONMODE)),this,SLOT(updateSelectionMode()));
221  // updateSelectionMode();
222  // connect(controller,SIGNAL(showTotMomentumOnMultiTrackSelectionChanged(bool)),this,SLOT(updateShownTotMomentum()));
223  // updateShownTotMomentum();
224 
225  messageVerbose("buildController end");
226  return controller;
227 }
228 
229 //____________________________________________________________________
231 {
232  // Note: 'sg' is not used here, so it's commented out to prevent compiler warnings
233 
234  messageVerbose("VP1AODSystem::buildEventSceneGraph start");
235 
236  // set complexity to a lower value, so that e.g. the straws are manageable
237  // SoComplexity * complexity = new SoComplexity;
238  // complexity->value.setValue(0.9f);//Fixme: Hardcoded here and elsewhere (fixme: Recheck all complexity values!)
239  // root->addChild(complexity);
240  // root->addChild(m_d->common->controller()->ascObjDrawStyle());
241  // root->addChild(m_d->common->controller()->ascObjComplexity());//this will be inherited to the tracks
242  // // (but giving no effect)
243 
246  m_d->selObjects->ref();
248 
249  // reset last selected trk
252 
253  // if (!m_d->common->m_textSep) {
254  // // FIXME!
255  // // std::cout<<"Making new Text sep"<<std::endl;
256  // m_d->common->m_textSep = new SoSeparator;
257  // m_d->common->m_textSep->setName("TextSep");
258  // m_d->common->m_textSep->ref();
259  // }
260  // root->addChild(m_d->common->m_textSep);
261 
262  // Fixme - what if font is missing?
263  // SoFont *myFont = new SoFont;
264  // myFont->name.setValue("Arial");
265  // myFont->size.setValue(13.0);
266  // m_d->common->m_textSep->addChild(myFont);
267 
268  messageVerbose("createCollections start");
269 
270  //Create collection list based on contents of event store, populate gui and apply states:
272 
273  //Add collections to event scenegraph:
275  // std::cout<<"Add collswitch="<<col->collSwitch()<< " to EventSceneGraph"<<std::endl;
276  m_d->selObjects->addChild(col->collSwitch());
277  }
278 
279  root->addChild(m_d->selObjects);
280  if (!m_d->totmomsep) {
281  m_d->totmomsep = new SoSeparator;
282  m_d->totmomsep->ref();
283  }
284  // m_d->totmomsep->addChild(m_d->common->controller()->trackDrawStyle());
285  root->addChild(m_d->totmomsep);
286 
287  messageVerbose("buildEventSceneGraph end");
288 }
289 
290 
291 //____________________________________________________________________
293 {
294  messageVerbose("systemErase begin");
295 
297  if (m_d->common->controller()->objBrowser()) m_d->common->controller()->objBrowser()->clear();
298 
299  // m_d->common->clearEventData();
300  if (m_d->selObjects) {
302  m_d->selObjects->unref();
303  m_d->selObjects=0;
304  }
305 
306  if (m_d->totmomsep)
307  m_d->totmomsep->removeAllChildren();
308 
309  // if (m_d->common->m_textSep) // FIXME!
310  // m_d->common->m_textSep->removeAllChildren();
311 
312  m_d->totmomgev = Amg::Vector3D(0,0,0);
313 
314  // if (verbose()) {
315  // if (AODHandleBase::numberOfInstances()!=0)
316  // message("Warning: "+str(AODHandleBase::numberOfInstances())
317  // +" instances of AODHandleBase alive at end of systemerase(). "
318  // "(ignore this warning if there is more than one track system instance).");
319  // if (AODHandleBase::numberOfInstances()!=0)
320  // message("Warning: "+str(AODHandleBase::numberOfInstances())
321  // +" instances of AODHandleBase alive at end of systemerase(). "
322  // "(ignore this warning if there is more than one track system instance).");
323  // }
324 
325  messageVerbose("systemErase end");
326 }
327 
328 //____________________________________________________________________
330 {
331  messageDebug("VP1AODSystem::saveState()");
332 
333  //Version & base state:
334  VP1Serialise serialise(1/*version*/,this);
335 
336  messageDebug("saving the base class...");
337  serialise.save(IVP13DSystemSimple::saveState());//Info from base class
338 
339  // Actual state info:
340  messageDebug("saving the controller...");
343 
344  messageDebug("saving the collectionWidget...");
346 
347 
348 
349  serialise.disableUnsavedChecks();//We do the testing in the controller
350 
351  return serialise.result();
352 }
353 
354 //____________________________________________________________________
356 {
357  messageDebug("VP1AODSystem::restoreFromState()");
358  //Version & base state:
359  VP1Deserialise state(ba,this);
360  if (state.version()==0) {
361  //We simply won't support .vp1 files from the old track system.
362  message("Warning: State data has obsolete format - ignoring!");
363  return;
364  }
365  if (state.version()!=1) {
366  message("Warning: State data has wrong format - ignoring!");
367  return;
368  }
369 
371 
372  IVP13DSystemSimple::restoreFromState(state.restoreByteArray());
373 
374  m_d->common->controller()->restoreSettings(state.restoreByteArray());
375 
377 
378  state.disableUnrestoredChecks();//We do the testing in the controller
379 }
380 
381 //____________________________________________________________________
383 {
384  // VisibleObjectToMaterialHelper<Trk::Track>* trackhelper(dynamic_cast< VisibleObjectToMaterialHelper<Trk::Track>* >(sender()));
385  // if (trackhelper) {
386  // //Fixme: For now we re-encode in a vector, to get old signal/slot signatures. We should change that!
387  // // -> and remember not to put const in front of the so materials!!
388  // std::vector< std::pair<const Trk::Track*, const SoMaterial*> > vistracks;
389  // vistracks.reserve(trackhelper->visibleObjects().size());
390  // std::map<const Trk::Track*,SoMaterial*>::const_iterator it, itE = trackhelper->visibleObjects().end();
391  // for (it = trackhelper->visibleObjects().begin();it!=itE;++it)
392  // vistracks.push_back(std::pair<const Trk::Track*, const SoMaterial*>(it->first,it->second));
393  // messageVerbose("Emitting visibleTracksChanged (with nvistracks = "+QString::number(vistracks.size())+")" );
394  // emit visibleTracksChanged(vistracks);
395  // return;
396  // }
397  // VisibleObjectToMaterialHelper<Trk::Segment>* segmenthelper(dynamic_cast<VisibleObjectToMaterialHelper<Trk::Segment>*>(sender()));
398  // if (segmenthelper) {
399  // //Fixme: For now we re-encode in a vector, to get old signal/slot signatures. We should change that!
400  // // -> and remember not to put const in front of the so materials!!
401  // std::vector< std::pair<const Trk::Segment*, const SoMaterial*> > vissegments;
402  // vissegments.reserve(segmenthelper->visibleObjects().size());
403  // std::map<const Trk::Segment*,SoMaterial*>::const_iterator it, itE = segmenthelper->visibleObjects().end();
404  // for (it = segmenthelper->visibleObjects().begin();it!=itE;++it)
405  // vissegments.push_back(std::pair<const Trk::Segment*, const SoMaterial*>(it->first,it->second));
406  // messageVerbose("Emitting visibleSegmentsChanged (with nvissegments = "+QString::number(vissegments.size())+")" );
407  // emit visibleSegmentsChanged(vissegments);
408  // return;
409  // }
410  message("unexpected signal received in visibleObjectsChanged slot");
411 }
412 
413 
414 //____________________________________________________________________
416 {
417  messageVerbose("updateSelectionMode start");
418  // if (!m_d->selObjects||!m_d->ascObjSelManager) {
419  // messageVerbose("updateSelectionMode Warning: Ignoring due to null pointers.");
420  // return;
421  // }
422  deselectAll();
423  // m_d->ascObjSelManager->deselectAll();
424  // m_d->selMode = m_d->common->controller()->selectionMode();//NB: Don't abort if unchanged (we call this method to init)
425 
426  // if (m_d->selMode==TrackCommonFlags::TRACKFIT) {
427  // messageVerbose("updateSelectionMode => TRACKFIT");
428  // m_d->selObjects->policy = SoCooperativeSelection::SINGLE;
429  // m_d->ascObjSelManager->setMode(AscObjSelectionManager::SHIFT);
430  // } else if (m_d->selMode==TrackCommonFlags::MULTITRACK) {
431  // messageVerbose("updateSelectionMode => MULTITRACK");
432  // m_d->selObjects->policy = SoCooperativeSelection::TOGGLE;
433  // m_d->ascObjSelManager->setMode(AscObjSelectionManager::SINGLE);
434  // } else {
435  // if (m_d->selMode!=TrackCommonFlags::SINGLEOBJECT)
436  // message("updateSelectionMode ERROR: Unexpected selection mode flag");
437  // messageVerbose("updateSelectionMode => SINGLEOBJECT");
438  m_d->selObjects->policy = SoCooperativeSelection::SINGLE;
439  // m_d->ascObjSelManager->setMode(AscObjSelectionManager::SINGLE);
440  // }
441  messageVerbose("updateSelectionMode end");
442 }
443 
444 //____________________________________________________________________
445 void VP1AODSystem::userPickedNode(SoNode* pickedNode, SoPath* /*pickedPath*/)
446 {
447  messageVerbose("userPickedNode");
448  if (pickedNode==m_d->totmomline) {
449  message("Total momentum of selected tracks [GeV]: p = "+str(m_d->totmomgev)+", m = "+str(m_d->totmass/1000));
450  return;
451  }
452 
453  message("Unknown object clicked");
454 }
455 
456 //____________________________________________________________________
458 {
459  messageVerbose("userSelectedSingleNode");
460 
461  if (sel!=m_d->selObjects) {
462  message("userSelectedSingleNode - ERROR, sel=!d->selObjects");
463  return;
464  }
465 
466  AODHandleBase* handle = m_d->common->getHandleFromNode(pickedPath);
467  if (!handle) handle = m_d->common->getHandleFromNode(node);
468  if (!handle) {
469  message("ERROR: Unknown handle from path or node.");
470  }
471 
472  if (handle) message(handle->clicked());
473 
474  // AODHandleBase* pickedHandle(0);
475  // if (!m_d->ascObjSelManager->handleUserSelectedSingleNode(sel,node,pickedPath,pickedHandle)) {
476  // if (sel==m_d->selObjects) {
477  // //Hack to get selections working when representing tracks with tubes:
478  // if (node->getTypeId().isDerivedFrom(SoCylinder::getClassTypeId())) {
479  // pickedPath->pop();
480  // node=pickedPath->getTail();
481  // }
482  // AODHandleBase * handle = m_d->common->getHandleFromNode(node);
483  // if (!handle) {
484  // message("ERROR: Unknown track.");
485  // return;
486  // }
487  // TrackHandle_TrkTrack * handle_trktrack = dynamic_cast<TrackHandle_TrkTrack *>(handle);
488  // if (handle_trktrack&&m_d->selMode==TrackCommonFlags::TRACKFIT) {
489  // messageVerbose("userSelectedSingleNode - find measurements for track fit");
490  //
491  // QList<AODHandleBase*> trackmeas = handle_trktrack->getVisibleMeasurements();
492  //
493  // if (trackmeas.size()==0) message("In refit mode, but no visible measurements found so can't do anything. Perhaps they're not enabled in 'Details'?");
494  // QList<AODHandleBase*> currentsel = m_d->ascObjSelManager->currentSelection();
495  // //If at least one of the track measurements is unselected, we
496  // //select them all. Otherwise we deselect them.
497  // bool oneunselected(false);
498  // for (AODHandleBase* meas : trackmeas) {
499  // if (!currentsel.contains(meas)) {
500  // oneunselected = true;
501  // break;
502  // }
503  // }
504  // QList<const Trk::PrepRawData*> prdSet;
505  // if (oneunselected) {
506  // messageVerbose("userSelectedSingleNode - selecting " +QString::number(trackmeas.size()) + " measurements.");
507  // m_d->ascObjSelManager->ensureSelected(trackmeas);
508  //
509  // // Add PRDs. Need to be careful as they might not exist.
510  // for (AODHandleBase* meas : trackmeas) {
511  // AscObj_TSOS* tsosAsc = dynamic_cast<AscObj_TSOS*>(meas);
512  // if (tsosAsc && tsosAsc->rioOnTrack() && tsosAsc->rioOnTrack()->prepRawData()) prdSet.append(tsosAsc->rioOnTrack()->prepRawData());
513  // }
514  // } else {
515  // messageVerbose("userSelectedSingleNode - deselecting " +QString::number(trackmeas.size()) + " measurements.");
516  // m_d->ascObjSelManager->ensureDeselected(trackmeas);
517  // }
518  // setSelectedPRDs(prdSet); // FIXME - maybe I should append/remove from existing list?
519  //
520  // m_d->selObjects->deselectAll();
521  // } else {
522  // if (m_d->common->controller()->printInfoOnSingleSelection()){
523  // message(handle->clicked());
524  // messageVerbose("Emitting newTrackSelected ");
525  // m_d->common->setLastSelectedHandle(handle);
526  // emit newTrackSelected(*handle);
527  // m_d->common->controller()->setNumberOfSelectedPRDsAndTracks(m_d->selectedPRDs.count(),1); // FIXME - we can do this more cleanly?
528  // }
529  // }
530  // } else {
531  // message("ERROR: Unknown selection.");
532  // return;
533  // }
534  // }
535  // if (m_d->common->controller()->orientAndZoomOnSingleSelection()) {
536  // if (!pickedHandle||!pickedHandle->initiatesOwnZooms()) {
537  // std::set<SoCamera*> cameras = getCameraList();
538  // std::set<SoCamera*>::iterator it,itE = cameras.end();
539  // for (it=cameras.begin();it!=itE;++it)
540  // VP1CameraHelper::animatedZoomToPath(*it,sel,pickedPath,2.0,1.0);
541  // }
542  // }
543 }
544 
545 //____________________________________________________________________
547 {
548  messageVerbose("userClickedOnBgd");
549  // if (m_d->ascObjSelManager)
550  // m_d->ascObjSelManager->userClickedOnBgd();
551  // m_d->common->setLastSelectedHandle(0);
552 }
553 
554 //____________________________________________________________________
556 {
557  messageVerbose("userDeselectedSingleNode");
558 }
559 
560 //____________________________________________________________________
561 unsigned VP1AODSystem::Imp::calcTotalMomentumOfSelectedHandles(Amg::Vector3D& /*totmom*/, Amg::Vector3D& /*totpos*/, double& /*mass*/)
562 {
563  // TODO: to be implemented?
564 
565 
566 
567 
568  // totmom = Amg::Vector3D(0,0,0);
569  // totpos = Amg::Vector3D(0,0,0);
570  // mass = 0;
571  // if (!selObjects)
572  // return 0;
573  // unsigned nused(0);
574  // double totenergy(0);
575  // for (int i = 0; i < selObjects->getList()->getLength(); ++i) {
576  // SoFullPath *fPath = static_cast<SoFullPath *>((*(selObjects->getList()))[i]);
577  // AODHandleBase * handle = common->trackHandle(fPath?fPath->getTail():0);
578  // if (!handle)
579  // continue;
580  // Amg::Vector3D mom = handle->momentum();
581  // if (mom.mag2()==0.0)
582  // continue;
583  // //Fixme: Get actual position of perigee!!
584  // const Amg::Vector3D * pos = handle->startPoint();
585  // if (!pos)
586  // continue;
587  // ++nused;
588  // totmom += mom;
589  // totpos += *pos;
590  // mass = handle->hasMass() ? handle->mass() : 0;
591  // totenergy += sqrt(mom.mag2() + mass*mass);
592  // }
593  // if (nused>1) {
594  // double msq = totenergy*totenergy - totmom.mag2();
595  // mass = (msq<0?-1.0:1.0)*sqrt(fabs(msq));
596  // totpos /= nused;
597  // }
598  // return nused;
599  return 0;
600 }
601 
603  return m_d->selObjects;
604 }
605 
606 
607 //____________________________________________________________________
609 {
610  // messageVerbose("updateShownTotMomentum");
611  // if (!m_d->common->controller()->showTotMomentumOnMultiTrackSelection()) {
612  // //ensure detach:
613  // messageVerbose(" => detach");
614  // if (m_d->totmomsep&&m_d->totmomline&&m_d->totmomsep->findChild(m_d->totmomline)>-1)
615  // m_d->totmomsep->removeChild(m_d->totmomline);
616  // return;
617  // }
618  // Amg::Vector3D totmom;
619  // Amg::Vector3D totpos;
620  // double totmass;
621  // unsigned nused = m_d->calcTotalMomentumOfSelectedHandles(totmom,totpos,totmass);
622  // if (nused==0) {
623  // //ensure detach:
624  // messageVerbose(" => detach");
625  // if (m_d->totmomsep&&m_d->totmomline&&m_d->totmomsep->findChild(m_d->totmomline)>-1)
626  // m_d->totmomsep->removeChild(m_d->totmomline);
627  // } else {
628  // //ensure correct lineset:
629  // Amg::Vector3D p2 = totpos+totmom.unit()*1*CLHEP::m;
630  // if (!m_d->totmomline) {
631  // m_d->totmomline = new SoLineSet;
632  // m_d->totmomline->ref();
633  // SoVertexProperty * vertices = new SoVertexProperty;
634  // m_d->totmomline->vertexProperty = vertices;
635  // m_d->totmomline->numVertices.set1Value(0,2);
636  //
637  // }
638  // SoVertexProperty * vertices = static_cast<SoVertexProperty*>(m_d->totmomline->vertexProperty.getValue());
639  // vertices->vertex.set1Value(0,totpos.x(),totpos.y(),totpos.z());
640  // vertices->vertex.set1Value(1,p2.x(),p2.y(),p2.z());
641  // m_d->totmomgev = totmom / CLHEP::GeV;
642  // m_d->totmass = totmass;
643  // //ensure attach:
644  // messageVerbose(" => attach");
645  // if (m_d->totmomsep&&m_d->totmomline&&m_d->totmomsep->findChild(m_d->totmomline)<0)
646  // m_d->totmomsep->addChild(m_d->totmomline);
647  // return;
648  // }
649 }
650 
651 //____________________________________________________________________
652 void VP1AODSystem::userChangedSelection(SoCooperativeSelection* sel, QSet<SoNode*> /*nodes*/, QSet<SoPath*>/*paths*/)
653 {
654  messageVerbose("userChangedSelection begin");
655  if (sel!=m_d->selObjects)
656  return;
657  messageVerbose("userChangedSelection => selObjects!!");
658  //
659  //
660  // if (m_d->common->controller()->printTotMomentumOnMultiTrackSelection()) {
661  // Amg::Vector3D totmom;
662  // Amg::Vector3D totpos;
663  // double totmass;
664  // if (m_d->calcTotalMomentumOfSelectedHandles(totmom,totpos,totmass)>0) {
665  // Amg::Vector3D totmomgev = totmom;
666  // totmomgev /= CLHEP::GeV;
667  // message("Total momentum [GeV] : "+str(totmomgev));//Fixme: Eta/phi/etc...
668  // message("Total mass [GeV] : "+str(totmass/CLHEP::GeV));//Fixme: Eta/phi/etc...
669  // }
670  // }
671  //
672  // updateShownTotMomentum();
673 }
674 
675 #ifndef BUILDVP1LIGHT
676 //____________________________________________________________________
677 void VP1AODSystem::updateAssociatedObjects(const QList<const xAOD::TrackParticle*>& trackparticles)
678 {
679  messageVerbose("updateAssociatedObjects TrackParticle");
680 
681  IParticleCollHandle_TrackParticle* newcoll = new IParticleCollHandle_TrackParticle( m_d->common, "TrackParticlesFromMuons", xAOD::Type::Muon, false );
682 
683  for (auto tp : trackparticles){
685  newcoll->addHandle( newhandle );
686  }
687 
688  newcoll->init();
689  // TrackCollHandle_RefittedTracks * newtrackcoll =
690  // new TrackCollHandle_RefittedTracks(m_d->common,
691  // m_d->common->controller()->nameOfNewlyFittedCollections(),
692  // fittedtracks);
693 
694  QList<IParticleCollHandle_TrackParticle*> newcolls;
695  newcolls << newcoll;
696 
697 
698  m_d->common->controller()->collWidget()->addCollections(newcolls);
699 
700  for (IParticleCollHandle_TrackParticle* col : newcolls) {
701  m_d->selObjects->addChild(col->collSwitch());
702  col->setVisible(true);
703  }
704  messageVerbose("updateAssociatedObjects TrackParticle end");
705 
706 }
707 #endif // BUILDVP1LIGHT
708 
709 // void VP1AODSystem::updateAssociatedObjects(QList<xAOD::CaloCluster*>& clusters)
710 // {
711 // messageVerbose("updateAssociatedObjects CaloCluster");
712 // std::cout<<"Got "<<clusters.size() << " from " <<typeid(sender()).name()<<std::endl;
713 //
714 // }
715 #ifndef BUILDVP1LIGHT
716 //____________________________________________________________________
717 void VP1AODSystem::updateAssociatedObjects(const QList<const xAOD::MuonSegment*>& segments)
718 {
719  messageVerbose("updateAssociatedObjects Segment");
720  std::cout<<"Got "<<segments.size() << " from " <<typeid(sender()).name()<<std::endl;
721 
722 }
723 #endif // BUILDVP1LIGHT
724 
725 //____________________________________________________________________
727 {
728 
729  // Format should be as follows:
730  // { "Type1Name" : { "Coll1name": {coll1data}, "Coll2name": {coll2data} } , "Type2Name" : { "Coll1name": {coll1data}, "Coll2name": {coll2data} } }
731  // "Coll1name": {coll1data} is handled by the appropriate collHandle, called by ahandle->dumpToJSON(outfile);
732  // All the outer dressing is done here i.e.
733  // { "Type1Name" : { xxx, xxx }, "Type2Name" : { xxx, xxx } }
734 
735  std::ofstream outfile ("EventDump.json");
736  if (outfile.is_open()){
737  outfile << "{";
738  outfile<< "\"event number\":234, \"run number\":234,\n"; //FIXME - make this into a metadata section?
739 
740  xAOD::Type::ObjectType lastType = xAOD::Type::EventInfo; // Set to this value because nothing that follows should use it i.e. can distinguish first loop.
741 
742  for (auto col : m_d->common->controller()->collWidget()->visibleStdCollections() ){
743  AODCollHandleBase* ahandle = dynamic_cast<AODCollHandleBase*>(col);
744  if (!ahandle){
745  message("WAAAAH! Not an AODCollHandleBase! Should never happen!");
746  continue;
747  }
748 
749  //unsigned int collNum=0; // Count of collection numbers
750  // std::cout<<"collNum="<<collNum++<<std::endl;
751 
752  if (ahandle->xAODType()!=lastType) {
753  // std::cout<<"Last type = "<<lastType<<", new type="<<ahandle->xAODType()<<std::endl;
754  // New type, so Terminate the 'type' enclosure add a new level of JSON enclosure.
755  if (lastType != xAOD::Type::EventInfo) {
756  // std::cout<<"Not first loop, so do add },"<<std::endl;
757  outfile << "},\n"; // This is the }, marked *},* : { "Type1Name" : { xxx, xxx } , "Type2Name" : { xxx, xxx } *},*. Don't do this on the first loop!
758  }
759  lastType=ahandle->xAODType();
760 
761  // Format is "TYPE":{ coll1, coll2, coll3 }
762  // Here we do just "TYPE":{
763  outfile << "\""<<ahandle->xAODType()<<"\" : {";
764  // std::cout<<"Dumping: "<< "\""<<ahandle->xAODType()<<"\" : {"<<std::endl;
765  } else {
766  // std::cout<<"Not the first loop, so add comma"<<std::endl;
767  // This is the comma marked *,*: { "Type1Name" : { xxx, xxx } *,* "Type2Name" : { xxx, xxx } }. Don't do this on the first loop!
768  outfile <<",";
769  }
770  // Dump collection
771  ahandle->dumpToJSON(outfile);
772 
773  }
774 
775  outfile << "}\n}\n"; // First closes last TYPE, second closes overall object
776  } else {
777  message("WAAAAH! Problem opening EventDump.json for output!");
778  }
779  message("Wrote visible objects to \'EventDump.json\'");
780 }
VP1Serialise.h
AODSystemController::setCommonData
void setCommonData(AODSysCommonData *)
set pointer to the common data
Definition: AODSystemController.cxx:298
IParticleHandle_TrackParticle.h
AODSysCommonData::getHandleFromNode
AODHandleBase * getHandleFromNode(SoNode *node)
Definition: AODSysCommonData.cxx:79
IParticleCollHandle_Electron.h
AODSystemController::objBrowser
QTreeWidget * objBrowser() const
Returns a pointer to the Track Object Browser (if it exists)
Definition: AODSystemController.cxx:290
VP1AODSystem::Imp::totmomgev
Amg::Vector3D totmomgev
Definition: VP1AODSystem.cxx:88
IParticleCollHandle_TrackParticle
Definition: IParticleCollHandle_TrackParticle.h:25
AODSysCommonData::setExtrapolator
void setExtrapolator(Trk::IExtrapolationEngine *e)
Definition: AODSysCommonData.h:56
VP1AvailableToolsHelper.h
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
VP1AvailableToolsHelper::addMonitoredType
void addMonitoredType(const QString &, const QStringList &ignoreList=QStringList())
Definition: VP1AvailableToolsHelper.cxx:102
IVP13DSystemSimple
Definition: IVP13DSystemSimple.h:24
AODHandleBase
Definition: AODHandleBase.h:43
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
AODCollHandleBase
Base class for all AOD object collections This class primarily handles setting up the interface,...
Definition: AODCollHandleBase.h:57
VP1AODSystem::userClickedOnBgd
void userClickedOnBgd()
Definition: VP1AODSystem.cxx:546
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
VP1AODSystem
Definition: VP1AODSystem.h:34
ObjectType
ObjectType
Definition: BaseObject.h:11
AODSysCommonData
Definition: AODSysCommonData.h:42
VP1CameraHelper.h
VP1AODSystem::systemuncreate
void systemuncreate()
Definition: VP1AODSystem.cxx:198
VP1AODSystem::VP1AODSystem
VP1AODSystem(const QString &name="Analysis")
Definition: VP1AODSystem.cxx:139
AODCollWidget.h
EventInfo
EventInfo
Definition: EventTPCnv.cxx:47
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1CollectionWidget::setCollections
void setCollections(const QList< VP1Collection * > &, bool applySavedStates=true)
Definition: VP1CollectionWidget.cxx:258
AODSystemController.h
AuxContainerBase.h
SoCooperativeSelection::activePolicy
SoSFEnum activePolicy
Definition: SoCooperativeSelection.h:49
VP1Controller::restoreSettings
void restoreSettings(const QByteArray &)
Definition: VP1Controller.cxx:387
AODSysCommonData::controller
const AODSystemController * controller() const
Definition: AODSysCommonData.h:50
ParticleTest.tp
tp
Definition: ParticleTest.py:25
VP1AODSystem::systemcreate
void systemcreate(StoreGateSvc *detstore)
Definition: VP1AODSystem.cxx:169
VP1AODSystem::Imp::calcTotalMomentumOfSelectedHandles
unsigned calcTotalMomentumOfSelectedHandles(Amg::Vector3D &totmom, Amg::Vector3D &totpos, double &mass)
Definition: VP1AODSystem.cxx:561
athena.value
value
Definition: athena.py:124
IParticleCollHandle_Muon.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VisibleObjectToMaterialHelper.h
IParticleCollHandle_TrackParticle::init
virtual void init(VP1MaterialButtonBase *matBut=0)
Definition: IParticleCollHandle_TrackParticle.cxx:111
VP1AODSystem::updateSelectionMode
void updateSelectionMode()
Definition: VP1AODSystem.cxx:415
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
VP1CollectionWidget::clear
void clear(bool deleteCollections=true, bool deleteGuiElements=false)
Definition: VP1CollectionWidget.cxx:81
IOStats.h
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1AODSystem::Imp
Definition: VP1AODSystem.cxx:79
VP1Controller::saveSettings
QByteArray saveSettings() const
Definition: VP1Controller.cxx:405
AODCollHandleBase::dumpToJSON
virtual void dumpToJSON(std::ofstream &) const
Definition: AODCollHandleBase.h:96
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
VP1AODSystem::userDeselectedSingleNode
void userDeselectedSingleNode(SoCooperativeSelection *, SoNode *, SoPath *)
Definition: VP1AODSystem.cxx:555
VP1AODSystem::updateShownTotMomentum
void updateShownTotMomentum()
Definition: VP1AODSystem.cxx:608
IVP1System::state
State state() const
Definition: IVP1System.cxx:129
IVP1System::saveState
virtual QByteArray saveState()
Definition: IVP1System.cxx:294
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
VP1AODSystem::Imp::totmass
double totmass
Definition: VP1AODSystem.cxx:89
VP1DetInfo.h
VP1AODSystem::Imp::totmomsep
SoSeparator * totmomsep
Definition: VP1AODSystem.cxx:86
IVP13DSystem::registerSelectionNode
void registerSelectionNode(SoCooperativeSelection *)
Definition: IVP13DSystem.cxx:257
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
ReadStats.h
VertexCollHandle.h
VP1AODSystem::saveState
QByteArray saveState()
Definition: VP1AODSystem.cxx:329
AODSystemController
Definition: AODSystemController.h:43
sel
sel
Definition: SUSYToolsTester.cxx:97
VP1AODSystem::userSelectedSingleNode
void userSelectedSingleNode(SoCooperativeSelection *, SoNode *, SoPath *)
Definition: VP1AODSystem.cxx:457
VP1AODSystem::updateAssociatedObjects
void updateAssociatedObjects(const QList< const xAOD::TrackParticle * > &)
Definition: VP1AODSystem.cxx:677
IVP1System::name
const QString & name() const
Definition: IVP1System.cxx:50
AODSysCommonData::setLastSelectedHandle
void setLastSelectedHandle(AODHandleBase *h)
Definition: AODSysCommonData.cxx:116
VP1AODSystem.h
IVP13DSystemSimple::ensureBuildController
void ensureBuildController()
Definition: IVP13DSystemSimple.cxx:90
VP1AODSystem::userChangedSelection
void userChangedSelection(SoCooperativeSelection *, QSet< SoNode * >, QSet< SoPath * >)
Definition: VP1AODSystem.cxx:652
VP1Deserialise
Definition: VP1Deserialise.h:44
AODSysCommonData.h
VP1AODSystem::visibleObjectsChanged
void visibleObjectsChanged()
Definition: VP1AODSystem.cxx:382
VP1AODSystem::Imp::totmomline
SoLineSet * totmomline
Definition: VP1AODSystem.cxx:87
SoCooperativeSelection::ACTIVE
@ ACTIVE
Definition: SoCooperativeSelection.h:41
SoCooperativeSelection.h
VP1AODSystem::dumpToJSON
void dumpToJSON()
Definition: VP1AODSystem.cxx:726
IVP1System::messageDebug
void messageDebug(const QString &) const
Definition: IVP1System.cxx:347
VP1AODSystem::Imp::theclass
VP1AODSystem * theclass
Definition: VP1AODSystem.cxx:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1CollectionWidget::visibleStdCollections
QList< VP1StdCollection * > visibleStdCollections() const
Definition: VP1CollectionWidget.cxx:330
AODCollHandleBase::xAODType
xAOD::Type::ObjectType xAODType() const
Dummy implementation does nothing.
Definition: AODCollHandleBase.h:97
IParticleCollHandle_Jet.h
VP1CollectionWidget::collections
const QList< VP1Collection * > & collections() const
Definition: VP1CollectionWidget.cxx:61
AODHandleBase::clicked
virtual QStringList clicked() const =0
Called when user selects the node (stringlist is displayed in messagebox).
IParticleHandle_TrackParticle
Definition: IParticleHandle_TrackParticle.h:27
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
query_example.col
col
Definition: query_example.py:7
VP1CollectionWidget::addCollections
void addCollections(const QList< VP1Collection * > &, bool applySavedStates=true)
Definition: VP1CollectionWidget.cxx:237
AODCollHandleBase.h
VP1AODSystem::Imp::createCollections
QList< AODCollHandleBase * > createCollections()
Definition: VP1AODSystem.cxx:125
VP1AODSystem::systemerase
void systemerase()
Definition: VP1AODSystem.cxx:292
Muon
struct TBPatternUnitContext Muon
MissingEtCollHandle.h
IParticleCollHandle_CaloCluster.h
VP1AODSystem::Imp::common
AODSysCommonData * common
Definition: VP1AODSystem.cxx:82
Trk::IExtrapolationEngine
Definition: IExtrapolationEngine.h:36
VP1CollectionWidget
Definition: VP1CollectionWidget.h:32
VP1ToolAccessHelper.h
VP1AODSystem::Imp::createSpecificCollections
QList< AODCollHandleBase * > createSpecificCollections(xAOD::Type::ObjectType type)
Definition: VP1AODSystem.cxx:108
IVP13DSystem::unregisterSelectionNode
void unregisterSelectionNode(SoCooperativeSelection *)
Definition: IVP13DSystem.cxx:281
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IParticleCollHandle_TrackParticle.h
IParticleCollHandleBase::addHandle
void addHandle(AODHandleBase *)
Definition: IParticleCollHandleBase.cxx:111
VP1ToolAccessHelper
Definition: VP1ToolAccessHelper.h:29
VP1AODSystem::userPickedNode
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Reimplementing methods declared in IVP13DSystem.
Definition: VP1AODSystem.cxx:445
VP1AvailableToolsHelper::availableTools
QStringList availableTools() const
Definition: VP1AvailableToolsHelper.cxx:239
str
Definition: BTagTrackIpAccessor.cxx:11
VP1StdCollection
Definition: VP1StdCollection.h:31
VP1AvailableToolsHelper
Definition: VP1AvailableToolsHelper.h:30
IParticleCollHandleBase.h
VP1AODSystem::m_d
Imp * m_d
Definition: VP1AODSystem.h:78
IExtrapolationEngine.h
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
VP1AODSystem::~VP1AODSystem
virtual ~VP1AODSystem()
Definition: VP1AODSystem.cxx:154
VP1AODSystem::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition: VP1AODSystem.cxx:230
StoreGateSvc.h
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
VP1AODSystem::restoreFromState
void restoreFromState(QByteArray)
Definition: VP1AODSystem.cxx:355
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
IVP13DSystem::deselectAll
virtual void deselectAll(SoCooperativeSelection *exception_sel=0)
Definition: IVP13DSystem.cxx:331
VP1AODSystem::buildController
QWidget * buildController()
Definition: VP1AODSystem.cxx:213
IVP1System::messageVerbose
void messageVerbose(const QString &) const
Definition: IVP1System.cxx:354
VP1AODSystem::Imp::selObjects
SoCooperativeSelection * selObjects
Definition: VP1AODSystem.cxx:83
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
node
Definition: memory_hooks-stdcmalloc.h:74
AODSystemController::collWidget
AODCollWidget * collWidget() const
Return widget which fills the collection selection list in the GUI (i.e. which finds and lists the av...
Definition: AODSystemController.cxx:196
common
Definition: common.py:1
SoCooperativeSelection
Definition: SoCooperativeSelection.h:29
VP1ToolAccessHelper::getToolPointer
toolT * getToolPointer(const QString &toolname, bool silent=false, bool createIfNotExists=false)
IVP1System::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1System.cxx:302
VP1AODSystem::selObjects
SoCooperativeSelection * selObjects() const
Definition: VP1AODSystem.cxx:602