ATLAS Offline Software
Loading...
Searching...
No Matches
VP1AODSystem.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
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
64#endif
65
66// Qt
67#include <QTreeWidget>
68
69// XAOD
73
74// ROOT include(s):
75#include <TFile.h>
76#include <TError.h>
77
78
80public:
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)
182 messageVerbose(value);
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//____________________________________________________________________
230void VP1AODSystem::buildEventSceneGraph(StoreGateSvc* /*sg*/, SoSeparator *root)
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
244 m_d->selObjects = new SoCooperativeSelection;
245 m_d->selObjects->activePolicy = SoCooperativeSelection::ACTIVE;
246 m_d->selObjects->ref();
247 registerSelectionNode(m_d->selObjects);
248
249 // reset last selected trk
250 m_d->common->setLastSelectedHandle(0);
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:
271 m_d->common->controller()->collWidget()->setCollections(m_d->createCollections());
272
273 //Add collections to event scenegraph:
274 for (VP1StdCollection* col : m_d->common->controller()->collWidget()->collections<VP1StdCollection>()){
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
296 m_d->common->controller()->collWidget()->clear();
297 if (m_d->common->controller()->objBrowser()) m_d->common->controller()->objBrowser()->clear();
298
299 // m_d->common->clearEventData();
300 if (m_d->selObjects) {
301 unregisterSelectionNode(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...");
342 serialise.save(m_d->common->controller()->saveSettings());
343
344 messageDebug("saving the collectionWidget...");
345 serialise.save(static_cast<VP1CollectionWidget*>(m_d->common->controller()->collWidget()));
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
373
374 m_d->common->controller()->restoreSettings(state.restoreByteArray());
375
376 state.restore(static_cast<VP1CollectionWidget*>(m_d->common->controller()->collWidget()));
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//____________________________________________________________________
445void 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//____________________________________________________________________
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//____________________________________________________________________
652void VP1AODSystem::userChangedSelection(SoCooperativeSelection* sel, const 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//____________________________________________________________________
677void 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//____________________________________________________________________
717void 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}
Base class for all AOD object collections This class primarily handles setting up the interface,...
xAOD::Type::ObjectType xAODType() const
Dummy implementation does nothing.
virtual void dumpToJSON(std::ofstream &) const
virtual QStringList clicked() const =0
Called when user selects the node (stringlist is displayed in messagebox).
void setCommonData(AODSysCommonData *)
set pointer to the common data
virtual void init(VP1MaterialButtonBase *matBut=0)
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
void unregisterSelectionNode(SoCooperativeSelection *)
virtual void deselectAll(SoCooperativeSelection *exception_sel=0)
void registerSelectionNode(SoCooperativeSelection *)
void messageVerbose(const QString &) const
virtual void restoreFromState(QByteArray)
void messageDebug(const QString &) const
const QString & name() const
State state() const
void message(const QString &) const
virtual QByteArray saveState()
The Athena Transient Store API.
Extrapolation engine interface for Charged and Neutral parameters, it serves as the Master extrapolat...
QList< AODCollHandleBase * > createCollections()
SoSeparator * totmomsep
QList< AODCollHandleBase * > createSpecificCollections(xAOD::Type::ObjectType type)
VP1AODSystem * theclass
Amg::Vector3D totmomgev
SoCooperativeSelection * selObjects
unsigned calcTotalMomentumOfSelectedHandles(Amg::Vector3D &totmom, Amg::Vector3D &totpos, double &mass)
SoLineSet * totmomline
void updateShownTotMomentum()
void updateAssociatedObjects(const QList< const xAOD::TrackParticle * > &)
VP1AODSystem(const QString &name="Analysis")
void userSelectedSingleNode(SoCooperativeSelection *, SoNode *, SoPath *)
virtual ~VP1AODSystem()
QWidget * buildController()
void userChangedSelection(SoCooperativeSelection *, const QSet< SoNode * > &, QSet< SoPath * >)
void userDeselectedSingleNode(SoCooperativeSelection *, SoNode *, SoPath *)
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Reimplementing methods declared in IVP13DSystem.
void restoreFromState(QByteArray)
SoCooperativeSelection * selObjects() const
void systemcreate(StoreGateSvc *detstore)
void updateSelectionMode()
void systemuncreate()
void visibleObjectsChanged()
QByteArray saveState()
void userClickedOnBgd()
void addMonitoredType(const QString &, const QStringList &ignoreList=QStringList())
toolT * getToolPointer(const QString &toolname, bool silent=false, bool createIfNotExists=false)
Definition node.h:24
Eigen::Matrix< double, 3, 1 > Vector3D
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ TrackParticle
The object is a charged track particle.
Definition ObjectType.h:43
@ Jet
The object is a jet.
Definition ObjectType.h:40
@ EventInfo
The object is an event information one.
Definition ObjectType.h:91
@ Other
An object not falling into any of the other categories.
Definition ObjectType.h:34
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Vertex
The object is a vertex.
Definition ObjectType.h:59