From 6c2fec1c6453de70aa56e6502f31f4fee97c8b4a Mon Sep 17 00:00:00 2001
From: Edward Moyse <edward.moyse@cern.ch>
Date: Tue, 7 Sep 2021 16:35:48 +0200
Subject: [PATCH] Add ability to filter tracks by detector element identifier.

Improve debugging output.
---
 graphics/VP1/VP1Base/src/PhiSectionWidget.cxx |  3 +
 .../VP1TrackSystems/TrackCollHandleBase.h     |  4 +-
 .../TrackCollectionSettingsButton.h           |  3 +
 .../VP1TrackSystems/TrackHandleBase.h         |  1 +
 .../VP1TrackSystems/TrackHandle_TrkTrack.h    |  1 +
 .../VP1TrackSystems/TrackSystemController.h   |  3 +
 .../VP1TrackSystems/src/AscObj_TSOS.cxx       |  1 +
 .../src/TrackCollHandleBase.cxx               | 26 ++++--
 .../src/TrackCollectionSettingsButton.cxx     | 18 ++++
 .../src/TrackHandle_TrkTrack.cxx              | 25 +++++
 .../src/TrackSystemController.cxx             | 12 +++
 .../src/pertrackcollectionsettings_form.ui    | 91 +++++++++++--------
 .../VP1TrackSystems/src/settings_cuts_form.ui | 63 ++++++++-----
 13 files changed, 182 insertions(+), 69 deletions(-)

diff --git a/graphics/VP1/VP1Base/src/PhiSectionWidget.cxx b/graphics/VP1/VP1Base/src/PhiSectionWidget.cxx
index ecc23cc998b7..19a4090caf7c 100644
--- a/graphics/VP1/VP1Base/src/PhiSectionWidget.cxx
+++ b/graphics/VP1/VP1Base/src/PhiSectionWidget.cxx
@@ -400,6 +400,9 @@ void PhiSectionWidget::mousePressEvent(QMouseEvent *event)
     return;
   }
   m_d->sectorstatus[isector]=!(m_d->sectorstatus.at(isector));
+  if(VP1Msg::verbose()){
+	 messageVerbose("Turning on sector"+QString::number(isector));
+  }
   m_d->cacheValid=false;
   m_d->checkForChanges();
 }
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollHandleBase.h b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollHandleBase.h
index 8a05d207301b..0fa8f28510d5 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollHandleBase.h
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollHandleBase.h
@@ -29,7 +29,7 @@
 #include "VP1TrackSystems/TrackSystemController.h"
 #include <QColor>
 #include <iostream>
-
+#include "Identifier/Identifier.h"
 
 class TrackSystemController;
 class TrackHandleBase;
@@ -195,6 +195,7 @@ public slots:
   void setMaterialEffectsOnTrackScale(double);
   void setParTubeErrorsDrawCylinders(bool);
   void setRequiredNHits(const QList<unsigned>&);
+  void setRequiredDetectorElement(const QString& id);
   void setOnlyVertexAssocTracks(bool);
   void extrapolateToThisVolumeChanged(void);
   void clipVolumeChanged(double);
@@ -222,6 +223,7 @@ private:
   VP1Interval m_cut_allowedEta;
   QList<VP1Interval> m_cut_allowedPhi;
   QList<unsigned> m_cut_requiredNHits;
+  QString m_requiredDetectorElement;
   bool m_cut_pt_allowall;
   bool m_cut_eta_allowall;
   bool m_cut_phi_allowall;
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollectionSettingsButton.h b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollectionSettingsButton.h
index 79f8ad3e3c5c..6ae319a2592c 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollectionSettingsButton.h
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackCollectionSettingsButton.h
@@ -41,6 +41,7 @@ public:
   //Cuts for number of hits per subsystem:
   QList<unsigned> cutRequiredNHits() const;//Empty list: no requirements. Otherwise a list
                                           // with a length of four (pixel,sct,trt,muon)
+  QString cutRequiredDetectorElement() const;  //Null string, no requirement. Otherwise the string is converted into an identifier.
   //Truth cuts:
   bool cutTruthFromIROnly() const;
   bool cutExcludeBarcodeZero() const;
@@ -63,6 +64,7 @@ public:
     void cutAllowedEtaChanged(const VP1Interval&);
     void cutAllowedPhiChanged(const QList<VP1Interval>&);
     void cutRequiredNHitsChanged(const QList<unsigned>&);
+    void cutRequiredDetectorElementChanged(const QString&);
     void cutTruthFromIROnlyChanged(bool);
     void cutExcludeBarcodeZeroChanged(bool);
     void cutTruthExcludeNeutralsChanged(bool);
@@ -96,6 +98,7 @@ public:
     void possibleChange_cutAllowedEta();
     void possibleChange_cutAllowedPhi();
     void possibleChange_cutRequiredNHits();
+    void possibleChange_cutRequiredDetectorElement();
     void possibleChange_cutTruthFromIROnly();
     void possibleChange_cutExcludeBarcodeZero();
     void possibleChange_cutTruthExcludeNeutrals();
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandleBase.h b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandleBase.h
index 6952361d6675..f9d54e85c544 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandleBase.h
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandleBase.h
@@ -151,6 +151,7 @@ protected:
 
   QList<AssociatedObjectHandleBase*> getAllAscObjHandles() const; //!< Return list of all AscObj handles. Not guaranteed to be filled unless tsoses are visible.
 
+  virtual bool containsDetElement(const QString&) const {return false; }
 private:
 
   // It is illegal to copy/assign a TrackHandleBase:
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandle_TrkTrack.h b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandle_TrkTrack.h
index 5cf284ee6852..be175384e9f2 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandle_TrkTrack.h
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackHandle_TrkTrack.h
@@ -52,6 +52,7 @@ public:
   virtual unsigned getNTGCHits() const { ensureInitSubSysHitInfo(); return m_nhits_tgc; }
   virtual unsigned getNCSCHits() const { ensureInitSubSysHitInfo(); return m_nhits_csc; }
   virtual const Trk::FitQuality* getFitQuality() const ;
+  virtual bool containsDetElement(const QString&) const;
 
   virtual void fillObjectBrowser(QList<QTreeWidgetItem *>& list); 
   void updateObjectBrowser();
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackSystemController.h b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackSystemController.h
index cc4f49600aba..51b0dfa391d7 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackSystemController.h
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/VP1TrackSystems/TrackSystemController.h
@@ -123,6 +123,7 @@ public:
   //Cuts for number of hits per subsystem:
   QList<unsigned> cutRequiredNHits() const;//Empty list: no requirements. Otherwise a list
                                            // with a length of four (pixel,sct,trt,muon)
+  QString cutRequiredDetectorElement() const;  //Null string, no requirement. Otherwise the string is converted into an identifier.
 
   void vertexCutsAllowed(bool); // called if vertex system is available.
   bool cutOnlyVertexAssocTracks() const;
@@ -216,6 +217,7 @@ signals:
   void cutAllowedEtaChanged(const VP1Interval&);
   void cutAllowedPhiChanged(const QList<VP1Interval>&);
   void cutRequiredNHitsChanged(const QList<unsigned>&);
+  void cutRequiredDetectorElementChanged(const QString&);
   void cutTruthFromIROnlyChanged(bool);
   void cutExcludeBarcodeZeroChanged(bool);
   void cutTruthExcludeNeutralsChanged(bool);
@@ -272,6 +274,7 @@ private slots:
   void possibleChange_cutAllowedEta();
   void possibleChange_cutAllowedPhi();
   void possibleChange_cutRequiredNHits();
+  void possibleChange_cutRequiredDetectorElement();
   void possibleChange_cutTruthFromIROnly();
   void possibleChange_cutExcludeBarcodeZero();
   void possibleChange_cutTruthExcludeNeutrals();
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/AscObj_TSOS.cxx b/graphics/VP1/VP1Systems/VP1TrackSystems/src/AscObj_TSOS.cxx
index 0e6b24337355..d728d2cd1ee5 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/AscObj_TSOS.cxx
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/AscObj_TSOS.cxx
@@ -1142,6 +1142,7 @@ QStringList AscObj_TSOS::clicked()
       std::ostringstream s;
       s << *(surface());
       l << QString(s.str().c_str()).split('\n');
+      s << "Identfier:"<<surface()->associatedDetectorElementIdentifier();
     }
   }
 
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollHandleBase.cxx b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollHandleBase.cxx
index 3d2d5d02054a..864eb1c0957d 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollHandleBase.cxx
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollHandleBase.cxx
@@ -112,6 +112,7 @@ TrackCollHandleBase::TrackCollHandleBase( TrackSysCommonData * cd,
     m_cut_allowedEta(VP1Interval()),
     m_cut_allowedPhi(QList<VP1Interval>()),
     m_cut_requiredNHits(QList<unsigned>()),
+    m_requiredDetectorElement(),
     m_cut_pt_allowall(false),
     m_cut_eta_allowall(false),
     m_cut_phi_allowall(false),
@@ -250,6 +251,9 @@ void TrackCollHandleBase::setupSettingsFromController(TrackSystemController* con
   connect(m_d->matButton,SIGNAL(cutRequiredNHitsChanged(const QList<unsigned>&)),this,SLOT(setRequiredNHits(const QList<unsigned>&)));
   setRequiredNHits(useDefaultCuts()?controller->cutRequiredNHits():m_d->matButton->cutRequiredNHits());
   
+  connect(controller,SIGNAL(cutRequiredDetectorElementChanged(const QString&)),this,SLOT(setRequiredDetectorElement(const QString&)));
+  connect(m_d->matButton,SIGNAL(cutRequiredDetectorElementChanged(const QString&)),this,SLOT(setRequiredDetectorElement(const QString&)));  
+
   connect(controller,SIGNAL(cutOnlyVertexAssocTracksChanged(bool)),this,SLOT(setOnlyVertexAssocTracks(bool)));
   connect(m_d->matButton,SIGNAL(cutOnlyVertexAssocTracksChanged(bool)),this,SLOT(setOnlyVertexAssocTracks(bool)));
   setOnlyVertexAssocTracks(useDefaultCuts()?controller->cutOnlyVertexAssocTracks():m_d->matButton->cutOnlyVertexAssocTracks());
@@ -314,7 +318,7 @@ bool TrackCollHandleBase::cut(TrackHandleBase* handle)
    if (m_cut_etaptphi_allwillfail)
     return false;
 
-  messageVerbose("TrackCollHandleBase::cut - checking hit cuts.");
+  // messageVerbose("TrackCollHandleBase::cut - checking hit cuts.");
   if (mightHaveSubSystemHitInfo()&&!m_cut_requiredNHits.isEmpty()&&handle->hasSubSystemHitInfo()) {
     //assert(m_cut_requiredNHits.count()==4); // for old code
     assert(m_cut_requiredNHits.count()==5);
@@ -323,17 +327,15 @@ bool TrackCollHandleBase::cut(TrackHandleBase* handle)
       if (handle->getNPixelHits()<m_cut_requiredNHits[0]) return false;
       if (handle->getNSCTHits()<m_cut_requiredNHits[1]) return false;
       if (handle->getNTRTHits()<m_cut_requiredNHits[2]) return false;
-    }
-    // Probably we should only be applying these to MS tracks?
-    messageVerbose("TrackCollHandleBase::cut : "+QString::number(handle->getNMuonPrecisionHits())+" / "+ QString::number(m_cut_requiredNHits[4]));
-    
+    } else {
+      messageVerbose("Not an ID track, so not applying ID cuts.");
+    }    
     if (handle->getNMuonHits()<m_cut_requiredNHits[3]) return false;
     if (handle->getNMuonPrecisionHits()<m_cut_requiredNHits[4]) return false;
   }
 
   if (!m_cut_pt_allowall||!m_cut_eta_allowall||!m_cut_phi_allowall)
   {
-//    Trk::GlobalMomentum mom(handle->momentum());
 	  Amg::Vector3D mom(handle->momentum());
     
     // convention is that if interval is real and negative, then P cut rather than pT
@@ -346,8 +348,7 @@ bool TrackCollHandleBase::cut(TrackHandleBase* handle)
       if (!m_cut_pt_allowall&& isPCut && !m_cut_allowedPtSq.contains(-mom.mag2()))
         return false;
         
-//      if (!m_cut_eta_allowall&&!m_cut_allowedEta.contains(mom.pseudoRapidity())){
-      if (!m_cut_eta_allowall&&!m_cut_allowedEta.contains(mom.eta())){ // migration to Amg (Eigen)
+      if (!m_cut_eta_allowall&&!m_cut_allowedEta.contains(mom.eta())){ 
         return false;
       }
       if (!m_cut_phi_allowall) {
@@ -364,6 +365,10 @@ bool TrackCollHandleBase::cut(TrackHandleBase* handle)
       }
     }
   }
+
+  // Cut on specific det element identifier
+  if (!m_requiredDetectorElement.isEmpty()) 
+    return handle->containsDetElement(m_requiredDetectorElement);
   
   if (cutOnlyVertexAssocTracks()){
     // std::cout<<"cutOnlyVertexAssocTracks: "<<handle<<",\t: "<<common()->system()->materialFromVertex(handle)<<std::endl;
@@ -867,6 +872,11 @@ void TrackCollHandleBase::setRequiredNHits(const QList<unsigned>& l)
   }
 }
 
+void TrackCollHandleBase::setRequiredDetectorElement(const QString& id){
+  m_requiredDetectorElement=id;
+  recheckCutStatusOfAllHandles();
+}
+
 //____________________________________________________________________
 void TrackCollHandleBase::setOnlyVertexAssocTracks(bool b){
   messageVerbose("setOnlyVertexAssocTracks changed to "+str(b));
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollectionSettingsButton.cxx b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollectionSettingsButton.cxx
index 6e87028de565..1d24de1a4748 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollectionSettingsButton.cxx
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackCollectionSettingsButton.cxx
@@ -54,6 +54,7 @@ public:
   VP1Interval last_cutAllowedEta;
   QList<VP1Interval> last_cutAllowedPhi;
   QList<unsigned> last_cutRequiredNHits;
+  QString last_cutRequiredDetectorElement;
   bool last_cutTruthFromIROnly;
   bool last_cutExcludeBarcodeZero;
   bool last_cutTruthExcludeNeutrals;
@@ -156,6 +157,10 @@ TrackCollectionSettingsButton::TrackCollectionSettingsButton(QWidget * parent,in
   connect(m_d->editwindow_ui.spinBox_cut_nhits_muon,SIGNAL(valueChanged(int)),this,SLOT(possibleChange_cutRequiredNHits()));
   connect(m_d->editwindow_ui.spinBox_cut_nprecisionhits_muon,SIGNAL(valueChanged(int)),this,SLOT(possibleChange_cutRequiredNHits()));
 
+  // Required detector element
+  connect(m_d->editwindow_ui.checkBox_requireDetectorElement,SIGNAL(toggled(bool)),this,SLOT(possibleChange_cutRequiredDetectorElement()));
+  connect(m_d->editwindow_ui.lineEdit_detectorElementId,SIGNAL(textChanged(QString)),this,SLOT(possibleChange_cutRequiredDetectorElement()));
+
   // -> cutTruthFromIROnly
   connect(m_d->editwindow_ui.checkBox_cut_truthtracks_creationvertexinIR,SIGNAL(toggled(bool)),this,SLOT(possibleChange_cutTruthFromIROnly()));
   
@@ -542,6 +547,10 @@ QList<unsigned> TrackCollectionSettingsButton::cutRequiredNHits() const
   return l;
 }
 
+QString TrackCollectionSettingsButton::cutRequiredDetectorElement() const {
+  return m_d->editwindow_ui.checkBox_requireDetectorElement->isChecked() ? m_d->editwindow_ui.lineEdit_detectorElementId->text(): QString();
+}
+
 //____________________________________________________________________
 bool TrackCollectionSettingsButton::cutTruthFromIROnly() const
 {
@@ -607,6 +616,15 @@ void TrackCollectionSettingsButton::possibleChange_cutRequiredNHits()
   emit cutRequiredNHitsChanged(m_d->last_cutRequiredNHits);
 }
 //____________________________________________________________________
+void TrackCollectionSettingsButton::possibleChange_cutRequiredDetectorElement()
+{  
+  messageVerbose("TrackCollectionSettingsButton::possibleChange_cutRequiredDetectorElement");
+  if (m_d->last_cutRequiredDetectorElement==cutRequiredDetectorElement()) return;
+  messageVerbose("cutRequiredDetectorElement() changed");
+  m_d->last_cutRequiredDetectorElement=cutRequiredDetectorElement();
+  emit cutRequiredDetectorElementChanged(m_d->last_cutRequiredDetectorElement);
+}
+//____________________________________________________________________
 void TrackCollectionSettingsButton::possibleChange_cutTruthFromIROnly()
 {
   if (m_d->last_cutTruthFromIROnly==cutTruthFromIROnly()) return;
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackHandle_TrkTrack.cxx b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackHandle_TrkTrack.cxx
index 08303ede0475..6783e063d355 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackHandle_TrkTrack.cxx
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackHandle_TrkTrack.cxx
@@ -387,3 +387,28 @@ const Trk::FitQuality* TrackHandle_TrkTrack::getFitQuality() const {
   return m_trk ? m_trk->fitQuality ():nullptr;
 }
 
+bool TrackHandle_TrkTrack::containsDetElement(const QString &id) const
+{
+  VP1Msg::messageVerbose("TrackHandle_TrkTrack::containsDetElement looking for " + id);
+  IDENTIFIER_TYPE tmpInt = id.toLong(nullptr,10);
+  IDENTIFIER_TYPE tmpInt2 = id.toLong(nullptr,16);
+
+  VP1Msg::messageVerbose("TrackHandle_TrkTrack::looping over TSOS ");
+
+  DataVector<const Trk::TrackStateOnSurface>::const_iterator it = trkTrackPointer()->trackStateOnSurfaces()->begin(),
+                                                             itE = trkTrackPointer()->trackStateOnSurfaces()->end();
+  for (; it != itE; ++it)
+  {
+    // Still debugging, so leaving this in for now...
+    // std::cout<<(*it)->surface().associatedDetectorElementIdentifier()<<std::endl;      
+    if ((*it)->surface().associatedDetectorElementIdentifier()==tmpInt) {
+      VP1Msg::messageVerbose("TrackHandle_TrkTrack::containsDetElement FOUND " + id + "!");
+      return true;  
+    }
+    if ((*it)->surface().associatedDetectorElementIdentifier()==tmpInt2) {
+      VP1Msg::messageVerbose("TrackHandle_TrkTrack::containsDetElement FOUND 2 " + id + "!");
+      return true;  
+    }
+  }
+  return false;
+}
\ No newline at end of file
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackSystemController.cxx b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackSystemController.cxx
index 8e3a21d8bd40..0f91252fa8cc 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackSystemController.cxx
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/TrackSystemController.cxx
@@ -134,6 +134,7 @@ public:
   VP1Interval last_cutAllowedEta;
   QList<VP1Interval> last_cutAllowedPhi;
   QList<unsigned> last_cutRequiredNHits;
+  QString last_cutRequiredDetectorElement;
   bool last_cutTruthFromIROnly = false;
   bool last_cutExcludeBarcodeZero = false;
   bool last_cutTruthExcludeNeutrals = false;
@@ -469,6 +470,10 @@ TrackSystemController::TrackSystemController(IVP1System * sys)
   connectToLastUpdateSlot(m_d->ui_cuts.spinBox_cut_nhits_muon);
   connectToLastUpdateSlot(m_d->ui_cuts.spinBox_cut_nprecisionhits_muon);
 
+// Required detector element
+  connect(m_d->ui_cuts.checkBox_requireDetectorElement,SIGNAL(toggled(bool)),this,SLOT(possibleChange_cutRequiredDetectorElement()));
+  connect(m_d->ui_cuts.lineEdit_detectorElementId,SIGNAL(textChanged(QString)),this,SLOT(possibleChange_cutRequiredDetectorElement()));
+
   // -> cutTruthFromIROnly
   addUpdateSlot(SLOT(possibleChange_cutTruthFromIROnly()));
   connectToLastUpdateSlot(m_d->ui_cuts.checkBox_cut_truthtracks_creationvertexinIR);
@@ -1839,6 +1844,12 @@ QList<unsigned> TrackSystemController::cutRequiredNHits() const
   return l;
 }
 
+QString TrackSystemController::cutRequiredDetectorElement() const {
+  QString tmp = m_d->ui_cuts.checkBox_requireDetectorElement->isChecked() ? m_d->ui_cuts.lineEdit_detectorElementId->text(): QString();
+  return tmp;
+}
+
+
 //____________________________________________________________________
 bool TrackSystemController::cutTruthFromIROnly() const
 {
@@ -2249,6 +2260,7 @@ POSSIBLECHANGE_IMP(cutAllowedPt)
 POSSIBLECHANGE_IMP(cutAllowedEta)
 POSSIBLECHANGE_IMP(cutAllowedPhi)
 POSSIBLECHANGE_IMP(cutRequiredNHits)
+POSSIBLECHANGE_IMP(cutRequiredDetectorElement)
 POSSIBLECHANGE_IMP(cutTruthFromIROnly)
 POSSIBLECHANGE_IMP(cutExcludeBarcodeZero)
 POSSIBLECHANGE_IMP(cutTruthExcludeNeutrals)
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/pertrackcollectionsettings_form.ui b/graphics/VP1/VP1Systems/VP1TrackSystems/src/pertrackcollectionsettings_form.ui
index b7ab8c2fb649..365692606d4a 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/pertrackcollectionsettings_form.ui
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/pertrackcollectionsettings_form.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>492</width>
-    <height>640</height>
+    <height>669</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -279,36 +279,17 @@
            <property name="spacing">
             <number>1</number>
            </property>
-           <item row="1" column="0">
-            <widget class="QCheckBox" name="checkBox_cut_nhits_pixel">
-             <property name="toolTip">
-              <string>Hide tracks without this many pixel hits. Only applies to tracks with ID information.</string>
-             </property>
+           <item row="6" column="0">
+            <widget class="QCheckBox" name="checkBox_requireDetectorElement">
              <property name="text">
-              <string>Require Pixel hits:</string>
+              <string>Require Detector Element</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="1">
-            <widget class="QSpinBox" name="spinBox_cut_nhits_pixel"/>
-           </item>
-           <item row="2" column="0">
-            <widget class="QCheckBox" name="checkBox_cut_nhits_sct">
-             <property name="toolTip">
-              <string>Hide tracks without this many SCT hits. Only applies to tracks with ID information.</string>
-             </property>
+           <item row="4" column="0">
+            <widget class="QCheckBox" name="checkBox_cut_nhits_muon">
              <property name="text">
-              <string>Require SCT hits:</string>
-             </property>
-             <property name="checked">
-              <bool>true</bool>
-             </property>
-            </widget>
-           </item>
-           <item row="2" column="1">
-            <widget class="QSpinBox" name="spinBox_cut_nhits_sct">
-             <property name="value">
-              <number>1</number>
+              <string>Require Muon hits:</string>
              </property>
             </widget>
            </item>
@@ -325,13 +306,13 @@
            <item row="4" column="1">
             <widget class="QSpinBox" name="spinBox_cut_nhits_muon"/>
            </item>
-           <item row="3" column="1">
-            <widget class="QSpinBox" name="spinBox_cut_nhits_trt"/>
-           </item>
-           <item row="4" column="0">
-            <widget class="QCheckBox" name="checkBox_cut_nhits_muon">
+           <item row="1" column="0">
+            <widget class="QCheckBox" name="checkBox_cut_nhits_pixel">
+             <property name="toolTip">
+              <string>Hide tracks without this many pixel hits. Only applies to tracks with ID information.</string>
+             </property>
              <property name="text">
-              <string>Require Muon hits:</string>
+              <string>Require Pixel hits:</string>
              </property>
             </widget>
            </item>
@@ -342,9 +323,45 @@
              </property>
             </widget>
            </item>
+           <item row="1" column="1">
+            <widget class="QSpinBox" name="spinBox_cut_nhits_pixel"/>
+           </item>
+           <item row="2" column="1">
+            <widget class="QSpinBox" name="spinBox_cut_nhits_sct">
+             <property name="value">
+              <number>1</number>
+             </property>
+            </widget>
+           </item>
+           <item row="2" column="0">
+            <widget class="QCheckBox" name="checkBox_cut_nhits_sct">
+             <property name="toolTip">
+              <string>Hide tracks without this many SCT hits. Only applies to tracks with ID information.</string>
+             </property>
+             <property name="text">
+              <string>Require SCT hits:</string>
+             </property>
+             <property name="checked">
+              <bool>true</bool>
+             </property>
+            </widget>
+           </item>
+           <item row="3" column="1">
+            <widget class="QSpinBox" name="spinBox_cut_nhits_trt"/>
+           </item>
            <item row="5" column="1">
             <widget class="QSpinBox" name="spinBox_cut_nprecisionhits_muon"/>
            </item>
+           <item row="6" column="1">
+            <widget class="QLineEdit" name="lineEdit_detectorElementId">
+             <property name="toolTip">
+              <string>Only show tracks which contain this detector element. So will not select tracks with no parameter on this detector element.</string>
+             </property>
+             <property name="placeholderText">
+              <string>Identifier</string>
+             </property>
+            </widget>
+           </item>
           </layout>
          </item>
          <item>
@@ -506,17 +523,17 @@ p, li { white-space: pre-wrap; }
   </layout>
  </widget>
  <customwidgets>
-  <customwidget>
-   <class>VP1MaterialButton</class>
-   <extends>QPushButton</extends>
-   <header>VP1Base/VP1MaterialButton.h</header>
-  </customwidget>
   <customwidget>
    <class>VP1EtaPhiCutWidget</class>
    <extends>QWidget</extends>
    <header>VP1Base/VP1EtaPhiCutWidget.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>VP1MaterialButton</class>
+   <extends>QPushButton</extends>
+   <header>VP1Base/VP1MaterialButton.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections>
diff --git a/graphics/VP1/VP1Systems/VP1TrackSystems/src/settings_cuts_form.ui b/graphics/VP1/VP1Systems/VP1TrackSystems/src/settings_cuts_form.ui
index c330815f3e07..860ae8d809be 100644
--- a/graphics/VP1/VP1Systems/VP1TrackSystems/src/settings_cuts_form.ui
+++ b/graphics/VP1/VP1Systems/VP1TrackSystems/src/settings_cuts_form.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>390</width>
-    <height>464</height>
+    <width>407</width>
+    <height>550</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -139,19 +139,13 @@
         <property name="spacing">
          <number>1</number>
         </property>
-        <item row="0" column="0">
-         <widget class="QCheckBox" name="checkBox_cut_nhits_pixel">
-          <property name="toolTip">
-           <string>Hide tracks without this many pixel hits. Only applies to tracks with ID information.</string>
-          </property>
+        <item row="4" column="0">
+         <widget class="QCheckBox" name="checkBox_cut_nprecisionhits_muon">
           <property name="text">
-           <string>Require Pixel hits:</string>
+           <string>Require Precision Muon hits:</string>
           </property>
          </widget>
         </item>
-        <item row="0" column="1">
-         <widget class="QSpinBox" name="spinBox_cut_nhits_pixel"/>
-        </item>
         <item row="1" column="0">
          <widget class="QCheckBox" name="checkBox_cut_nhits_sct">
           <property name="toolTip">
@@ -165,13 +159,6 @@
           </property>
          </widget>
         </item>
-        <item row="1" column="1">
-         <widget class="QSpinBox" name="spinBox_cut_nhits_sct">
-          <property name="value">
-           <number>1</number>
-          </property>
-         </widget>
-        </item>
         <item row="2" column="0">
          <widget class="QCheckBox" name="checkBox_cut_nhits_trt">
           <property name="toolTip">
@@ -182,12 +169,23 @@
           </property>
          </widget>
         </item>
-        <item row="2" column="1">
-         <widget class="QSpinBox" name="spinBox_cut_nhits_trt"/>
+        <item row="5" column="0">
+         <widget class="QCheckBox" name="checkBox_requireDetectorElement">
+          <property name="text">
+           <string>Require Detector Element</string>
+          </property>
+         </widget>
         </item>
         <item row="3" column="1">
          <widget class="QSpinBox" name="spinBox_cut_nhits_muon"/>
         </item>
+        <item row="1" column="1">
+         <widget class="QSpinBox" name="spinBox_cut_nhits_sct">
+          <property name="value">
+           <number>1</number>
+          </property>
+         </widget>
+        </item>
         <item row="3" column="0">
          <widget class="QCheckBox" name="checkBox_cut_nhits_muon">
           <property name="text">
@@ -195,16 +193,35 @@
           </property>
          </widget>
         </item>
-        <item row="4" column="0">
-         <widget class="QCheckBox" name="checkBox_cut_nprecisionhits_muon">
+        <item row="0" column="0">
+         <widget class="QCheckBox" name="checkBox_cut_nhits_pixel">
+          <property name="toolTip">
+           <string>Hide tracks without this many pixel hits. Only applies to tracks with ID information.</string>
+          </property>
           <property name="text">
-           <string>Require Precision Muon hits:</string>
+           <string>Require Pixel hits:</string>
           </property>
          </widget>
         </item>
         <item row="4" column="1">
          <widget class="QSpinBox" name="spinBox_cut_nprecisionhits_muon"/>
         </item>
+        <item row="0" column="1">
+         <widget class="QSpinBox" name="spinBox_cut_nhits_pixel"/>
+        </item>
+        <item row="2" column="1">
+         <widget class="QSpinBox" name="spinBox_cut_nhits_trt"/>
+        </item>
+        <item row="5" column="1">
+         <widget class="QLineEdit" name="lineEdit_detectorElementId">
+          <property name="toolTip">
+           <string>Only show tracks which contain this detector element. So will not select tracks with no parameter on this detector element.</string>
+          </property>
+          <property name="placeholderText">
+           <string>Identifier</string>
+          </property>
+         </widget>
+        </item>
        </layout>
       </item>
       <item>
-- 
GitLab