diff --git a/Control/AthenaServices/src/MetaDataSvc.cxx b/Control/AthenaServices/src/MetaDataSvc.cxx index b7a084be19577e80a0c410bd3a1ede02123a8167..cc0d822d63f4fd539ca738ecbde92b9b926a6fe0 100644 --- a/Control/AthenaServices/src/MetaDataSvc.cxx +++ b/Control/AthenaServices/src/MetaDataSvc.cxx @@ -5,17 +5,16 @@ /** @file MetaDataSvc.cxx * @brief This file contains the implementation for the MetaDataSvc class. * @author Peter van Gemmeren <gemmeren@anl.gov> - * $Id: MetaDataSvc.cxx,v 1.46 2008-11-19 23:21:10 gemmeren Exp $ **/ #include "MetaDataSvc.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" #include "GaudiKernel/IAddressCreator.h" #include "GaudiKernel/IAlgTool.h" #include "GaudiKernel/IEvtSelector.h" #include "GaudiKernel/IIncidentSvc.h" #include "GaudiKernel/IIoComponentMgr.h" -#include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/IOpaqueAddress.h" #include "GaudiKernel/FileIncident.h" @@ -142,21 +141,15 @@ StatusCode MetaDataSvc::initialize() { ATH_MSG_FATAL("Cannot register myself with the IoComponentMgr."); return(StatusCode::FAILURE); } - ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc", name()); + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name()); if (!joSvc.retrieve().isSuccess()) { ATH_MSG_WARNING("Cannot get JobOptionsSvc."); } else { - const std::vector<const Gaudi::Details::PropertyBase*>* evtselProps = joSvc->getProperties("EventSelector"); - if (evtselProps != nullptr) { - for (std::vector<const Gaudi::Details::PropertyBase*>::const_iterator iter = evtselProps->begin(), - last = evtselProps->end(); iter != last; iter++) { - if ((*iter)->name() == "InputCollections") { - // Get EventSelector to force in-time initialization and FirstInputFile incident - ServiceHandle<IEvtSelector> evtsel("EventSelector", this->name()); - if (!evtsel.retrieve().isSuccess()) { - ATH_MSG_WARNING("Cannot get EventSelector."); - } - } + if (joSvc->has("EventSelector.InputCollections")) { + // Get EventSelector to force in-time initialization and FirstInputFile incident + ServiceHandle<IEvtSelector> evtsel("EventSelector", this->name()); + if (!evtsel.retrieve().isSuccess()) { + ATH_MSG_WARNING("Cannot get EventSelector."); } } } diff --git a/Database/IOVDbSvc/src/IOVDbSvc.cxx b/Database/IOVDbSvc/src/IOVDbSvc.cxx index 7c16b40628208964adbe73c1da4ddfa271b0a58e..923c640e921292a549a9ea180732fc062d0edff8 100644 --- a/Database/IOVDbSvc/src/IOVDbSvc.cxx +++ b/Database/IOVDbSvc/src/IOVDbSvc.cxx @@ -9,22 +9,18 @@ #include "StoreGate/StoreGateSvc.h" #include "StoreGate/StoreClearedIncident.h" -#include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/IIncidentSvc.h" #include "GaudiKernel/Guards.h" #include "GaudiKernel/IOpaqueAddress.h" +#include "GaudiKernel/IProperty.h" #include "AthenaKernel/IOVRange.h" #include "IOVDbDataModel/IOVMetaDataContainer.h" #include "AthenaKernel/IAddressProvider.h" - #include "FileCatalog/IFileCatalog.h" - - #include "EventInfo/TagInfo.h" #include "EventInfoUtils/EventIDFromStore.h" #include "IOVDbParser.h" - #include "IOVDbFolder.h" #include "IOVDbSvc.h" @@ -33,19 +29,6 @@ // helper function for getting jobopt properties namespace { - template<typename Prop_t> - bool - fetchProp( const std::vector<const Gaudi::Details::PropertyBase*>* properties, Prop_t& p ){ - if (properties) { - for ( const auto & pThisProperty: *properties ) { - if ( pThisProperty->name()==p.name() ) { - return (pThisProperty->load(p)); - } - } - } - return false; - } - bool refersToConditionsFolder(const TagInfo::NameTagPair & thisPair){ return thisPair.first.front() == '/'; @@ -771,22 +754,16 @@ StatusCode IOVDbSvc::checkEventSel() { // if so, we can set IOV time already to allow conditons retrieval // in the initialise phase, needed for setting up simulation - // access jobOptionSvc and get properties of EventSelector - ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc",name()); - if (!joSvc.retrieve().isSuccess()) { - ATH_MSG_FATAL( "Could not retrieve [" << joSvc.typeAndName() << "]" ); - return StatusCode::FAILURE; - } - typedef std::vector<const Gaudi::Details::PropertyBase*> Properties_t; - const Properties_t* evtSelProps=joSvc->getProperties("EventSelector"); - // do not return FAILURE if the EventSelector cannot be found, as this - // happens online when we have no EventSelector - if (0==evtSelProps) { - ATH_MSG_DEBUG( "Could not retrieve properties of 'EventSelector' from ["<< joSvc.typeAndName() << "]" ); + SmartIF<IProperty> evtSel = service<IProperty>("EventSelector", /*createIf=*/ false); + if (!evtSel.isValid()) { + // do not return FAILURE if the EventSelector cannot be found, as this + // happens online when we have no EventSelector + ATH_MSG_DEBUG( "Could not retrieve 'EventSelector'" ); return StatusCode::SUCCESS; } + BooleanProperty bprop("OverrideRunNumber",false); - if (fetchProp<BooleanProperty>(evtSelProps,bprop)) { + if (evtSel->getProperty(&bprop)) { if (bprop.value()) { // if flag is set, extract Run,LB and time ATH_MSG_INFO( "Setting run/LB/time from EventSelector override in initialize" ); @@ -797,21 +774,21 @@ StatusCode IOVDbSvc::checkEventSel() { m_par_forceLumiblockNumber.value()!=0) ATH_MSG_WARNING( "forceRunNumber property also set" ); IntegerProperty iprop1("RunNumber",0); - if (fetchProp<IntegerProperty>(evtSelProps,iprop1)) { + if (evtSel->getProperty(&iprop1)) { run=iprop1.value(); } else { ATH_MSG_ERROR( "Unable to get RunNumber from EventSelector"); allGood=false; } IntegerProperty iprop2("FirstLB",0); - if (fetchProp<IntegerProperty>(evtSelProps,iprop2)) { + if (evtSel->getProperty(&iprop2)) { lumib=iprop2.value(); } else { ATH_MSG_ERROR( "Unable to get FirstLB from EventSelector"); allGood=false; } IntegerProperty iprop3("InitialTimeStamp",0); - if (fetchProp<IntegerProperty>(evtSelProps,iprop3)) { + if (evtSel->getProperty(&iprop3)) { time=iprop3.value(); } else { ATH_MSG_ERROR("Unable to get InitialTimeStamp from EventSelector" ); diff --git a/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py b/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py index eeb7337d641d4566d97c326d8c79fa7c0cab3c5c..7f9aedb6c5e2521a5d10ad68eccb8cf05a2a7167 100644 --- a/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py +++ b/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutputItemList_jobOptions.py @@ -52,7 +52,7 @@ if DetFlags.overlay.Truth_on(): if DetFlags.overlay.pixel_on(): outStream.ItemList += ["PixelRDO_Container#*"] - outStream.ItemList += ["InDetBSErrContainer#*"] + outStream.ItemList += ["IDCInDetBSErrContainer#*"] if DetFlags.overlay.SCT_on(): outStream.ItemList += ["SCT_RDO_Container#*"] if DetFlags.overlay.TRT_on(): diff --git a/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutput_jobOptions.py b/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutput_jobOptions.py index 973e9f824a9bb4c703a692ca8d4efb378e000fed..c237b24552db5497f96accd6c481d1137cc7d376 100644 --- a/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutput_jobOptions.py +++ b/Event/EventOverlay/EventOverlayJobTransforms/share/OverlayOutput_jobOptions.py @@ -38,7 +38,7 @@ if DetFlags.overlay.Truth_on(): if DetFlags.overlay.pixel_on(): outStream.ItemList += [ 'InDetSimDataCollection#PixelSDO_Map' ] if overlayFlags.isDataOverlay(): - outStream.ItemList += [ 'InDetBSErrContainer#PixelByteStreamErrs' ] + outStream.ItemList += [ 'IDCInDetBSErrContainer#PixelByteStreamErrs' ] if DetFlags.overlay.SCT_on(): outStream.ItemList += ['InDetSimDataCollection#SCT_SDO_Map'] diff --git a/HLT/Trigger/TrigControl/TrigCommon/python/TrigPyHelper.py b/HLT/Trigger/TrigControl/TrigCommon/python/TrigPyHelper.py index 47751b4fbf6cb2c3a7d65df8d50d2e1d344fff26..24e7b61dcb3f5076155722bff0b57dd792c5c822 100644 --- a/HLT/Trigger/TrigControl/TrigCommon/python/TrigPyHelper.py +++ b/HLT/Trigger/TrigControl/TrigCommon/python/TrigPyHelper.py @@ -44,7 +44,7 @@ class TrigApp(object): for p in jobOptSvc.items(): name = p._0 value = p._1 - client, prop = name.split('.',1) + client, prop = name.rsplit('.',1) if reClient.match(client) and reProp.match(prop): self.log.info("Changing %s.%s from '%s' to '%s'", client, prop, value, newValue) iprop = iProperty(client) diff --git a/HLT/Trigger/TrigControl/TrigServices/src/HltROBDataProviderSvc.cxx b/HLT/Trigger/TrigControl/TrigServices/src/HltROBDataProviderSvc.cxx index d042e5141605cee81513742306f95f4bb5de19c7..5745a8fe3e1092f6f25762232e7e3b61603a44e3 100644 --- a/HLT/Trigger/TrigControl/TrigServices/src/HltROBDataProviderSvc.cxx +++ b/HLT/Trigger/TrigControl/TrigServices/src/HltROBDataProviderSvc.cxx @@ -109,7 +109,8 @@ StatusCode HltROBDataProviderSvc::initialize() if ((jobOptionsSvc.retrieve()).isFailure()) { ATH_MSG_ERROR("Could not find JobOptionsSvc"); } else { - if (m_enabledROBs.fromString(jobOptionsSvc->get("DataFlowConfig.DF_Enabled_ROB_IDs","[]")).isSuccess()) { + if (jobOptionsSvc->has("DataFlowConfig.DF_Enabled_ROB_IDs") && + m_enabledROBs.fromString(jobOptionsSvc->get("DataFlowConfig.DF_Enabled_ROB_IDs")).isSuccess()) { robOKSconfigFound = true; ATH_MSG_INFO(" ---> Read from OKS = " << MSG::dec << m_enabledROBs.value().size() << " enabled ROB IDs."); diff --git a/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelDetailedStaveSupport.cxx b/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelDetailedStaveSupport.cxx index 2f76844d03ddd25b44d82c75d5e2ea9b1053121f..b2c6d31bfd090128f0c875acc400bdc352e684ac 100644 --- a/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelDetailedStaveSupport.cxx +++ b/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelDetailedStaveSupport.cxx @@ -1279,11 +1279,11 @@ GeoSimplePolygonBrep* GeoPixelDetailedStaveSupport::computeStaveEnvelopShape( do double xMid = xVertices[0]-m_width_svc*xDir; double yMid = yVertices[0]-m_width_svc*yDir+1.; convexStaveEnvelopShape->addVertex(xMid, yMid); - convexStaveEnvelopShape->addVertex(xMid-2.*delta*m_thicknessN_svc, yMid); + convexStaveEnvelopShape->addVertex(xMid-delta*m_thicknessN_svc, yMid); xMid = xVertices[0]-m_width_svc*xDir; yMid = yVertices[0]-m_width_svc*.25*yDir+1.; - convexStaveEnvelopShape->addVertex(xMid-2.*delta*m_thicknessN_svc, yMid); + convexStaveEnvelopShape->addVertex(xMid-delta*m_thicknessN_svc, yMid); convexStaveEnvelopShape->addVertex(xMid-delta*m_thicknessN_svc*.5, yMid); convexStaveEnvelopShape->addVertex(xMid-delta*m_thicknessN_svc*.5, yVertices[0]); diff --git a/InnerDetector/InDetRawAlgs/InDetOverlay/python/PixelOverlayConfig.py b/InnerDetector/InDetRawAlgs/InDetOverlay/python/PixelOverlayConfig.py index 67e2a9c2858c4b306dcf3a9991bf434e8d85a7fb..1aa88bed519e313c72ac6ad4a07161ef7363c378 100644 --- a/InnerDetector/InDetRawAlgs/InDetOverlay/python/PixelOverlayConfig.py +++ b/InnerDetector/InDetRawAlgs/InDetOverlay/python/PixelOverlayConfig.py @@ -53,7 +53,7 @@ def PixelOverlayAlgCfg(flags, name="PixelOverlay", **kwargs): if flags.Overlay.DataOverlay: acc.merge(OutputStreamCfg(flags, "RDO", ItemList=[ - "InDetBSErrContainer#PixelByteStreamErrs" + "IDCInDetBSErrContainer#PixelByteStreamErrs" ])) if flags.Output.doWriteRDO_SGNL: diff --git a/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.h b/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.h index 7161f00aa43e7ba006901611d7d98baeba860185..5878c8b06909df9c91a11c89caa93b9b3854f27f 100644 --- a/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.h +++ b/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.h @@ -23,7 +23,6 @@ #include "MagFieldElements/BFieldMeshZR.h" #include "MagFieldElements/BFieldZone.h" -#include <iostream> #include <memory> namespace MagField { diff --git a/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.h b/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.h index b79841a62b3f3f510298d69a0adad48ab901afb4..1d78885d5312afeb2396a2459d0a2ed4a72d4980 100644 --- a/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.h +++ b/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.h @@ -2,73 +2,63 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -// -// BFieldMeshZR.h -// -// A 2-dim z-r mesh inside the solenoid field map -// -// Masahiro Morii, Harvard University -// +/* + * BFieldMeshZR.h + * + * A 2-dim z-r mesh inside the solenoid field map + * + * Masahiro Morii, Harvard University + * + * AthenaMT : RD Schaffer , Christos Anastopoulos + */ #ifndef BFIELDMESHZR_H #define BFIELDMESHZR_H #include "MagFieldElements/BFieldCacheZR.h" #include "MagFieldElements/BFieldVectorZR.h" +#include <array> #include <cmath> #include <vector> -#include <array> class BFieldMeshZR { public: // constructor - BFieldMeshZR(double zmin, double zmax, double rmin, double rmax) - { - m_min = { zmin, rmin }; - m_max = { zmax, rmax }; - } + BFieldMeshZR(double zmin, double zmax, double rmin, double rmax); // allocate space to vectors - void reserve(int nz, int nr) - { - m_mesh[0].reserve(nz); - m_mesh[1].reserve(nr); - m_field.reserve(nz * nr); - } + void reserve(int nz, int nr); // add elements to vectors - void appendMesh(int i, double mesh) { m_mesh[i].push_back(mesh); } - void appendField(const BFieldVectorZR& field) { m_field.push_back(field); } + void appendMesh(int i, double mesh); + void appendField(const BFieldVectorZR& field); // build LUT void buildLUT(); // test if a point is inside this zone - inline bool inside(double z, double r) const - { - return (z >= zmin() && z <= zmax() && r >= rmin() && r <= rmax()); - } + bool inside(double z, double r) const; // find the bin inline void getCache(double z, double r, BFieldCacheZR& cache, double scaleFactor = 1.0) const; // accessors - double min(size_t i) const { return m_min[i]; } - double max(size_t i) const { return m_max[i]; } - double zmin() const { return m_min[0]; } - double zmax() const { return m_max[0]; } - double rmin() const { return m_min[1]; } - double rmax() const { return m_max[1]; } - unsigned nmesh(size_t i) const { return m_mesh[i].size(); } - double mesh(size_t i, size_t j) const { return m_mesh[i][j]; } - unsigned nfield() const { return m_field.size(); } - const BFieldVectorZR& field(size_t i) const { return m_field[i]; } + double min(size_t i) const; + double max(size_t i) const; + double zmin() const; + double zmax() const; + double rmin() const; + double rmax() const; + unsigned nmesh(size_t i) const; + double mesh(size_t i, size_t j) const; + unsigned nfield() const; + const BFieldVectorZR& field(size_t i) const; int memSize() const; private: - std::array<double,2> m_min; - std::array<double,2> m_max; - std::array<std::vector<double>,2> m_mesh; + std::array<double, 2> m_min; + std::array<double, 2> m_max; + std::array<std::vector<double>, 2> m_mesh; std::vector<BFieldVectorZR> m_field; // look-up table and related variables - std::array<std::vector<int>,2> m_LUT; + std::array<std::vector<int>, 2> m_LUT; std::array<double, 2> m_invUnit; // inverse unit size in the LUT int m_zoff; }; diff --git a/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.icc b/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.icc index 781dbf7dc885eef916b3f8c87d55c4da9b8d454e..1b76cf8b1dee79300de6ca089fd736c41efe4b60 100644 --- a/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.icc +++ b/MagneticField/MagFieldElements/MagFieldElements/BFieldMeshZR.icc @@ -36,3 +36,89 @@ BFieldMeshZR::getCache(double z, cache.setField(3, m_field[im0 + m_zoff + 1], scaleFactor); } +inline BFieldMeshZR::BFieldMeshZR(double zmin, + double zmax, + double rmin, + double rmax) +{ + m_min = { zmin, rmin }; + m_max = { zmax, rmax }; +} + +inline void +BFieldMeshZR::reserve(int nz, int nr) +{ + m_mesh[0].reserve(nz); + m_mesh[1].reserve(nr); + m_field.reserve(nz * nr); +} +// add elements to vectors +inline void +BFieldMeshZR::appendMesh(int i, double mesh) +{ + m_mesh[i].push_back(mesh); +} +inline void +BFieldMeshZR::appendField(const BFieldVectorZR& field) +{ + m_field.push_back(field); +} + +// test if a point is inside this zone +inline bool +BFieldMeshZR::inside(double z, double r) const +{ + return (z >= zmin() && z <= zmax() && r >= rmin() && r <= rmax()); +} + +inline double +BFieldMeshZR::min(size_t i) const +{ + return m_min[i]; +} +inline double +BFieldMeshZR::max(size_t i) const +{ + return m_max[i]; +} +inline double +BFieldMeshZR::zmin() const +{ + return m_min[0]; +} +inline double +BFieldMeshZR::zmax() const +{ + return m_max[0]; +} +inline double +BFieldMeshZR::rmin() const +{ + return m_min[1]; +} +inline double +BFieldMeshZR::rmax() const +{ + return m_max[1]; +} +inline unsigned +BFieldMeshZR::nmesh(size_t i) const +{ + return m_mesh[i].size(); +} +inline double +BFieldMeshZR::mesh(size_t i, size_t j) const +{ + return m_mesh[i][j]; +} +inline unsigned +BFieldMeshZR::nfield() const +{ + return m_field.size(); +} +inline const BFieldVectorZR& +BFieldMeshZR::field(size_t i) const +{ + return m_field[i]; +} + diff --git a/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.h b/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.h index 57fbb3ea62338aefee086f46ac501fa3e69da6ee..888e3f8d059a56fdba94c138a94b79fced504544 100644 --- a/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.h +++ b/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.h @@ -29,12 +29,7 @@ public: double rmax, double phimin, double phimax, - double scale) - : BFieldMesh<short>(zmin, zmax, rmin, rmax, phimin, phimax, scale) - , m_id(id) - { - ; - } + double scale); // add elements to vectors void appendCond(const BFieldCond& cond); // compute Biot-Savart magnetic field and add to B[3] @@ -45,10 +40,10 @@ public: // Scaling is done in cachec void scaleField(double factor); // accessors - int id() const { return m_id; } - unsigned ncond() const { return m_cond.size(); } - const BFieldCond& cond(int i) const { return m_cond[i]; } - const std::vector<BFieldCond>* condVector() const { return &m_cond; } + int id() const; + unsigned ncond() const; + const BFieldCond& cond(int i) const; + const std::vector<BFieldCond>* condVector() const; int memSize() const; // adjust the min/max edges to a new value void adjustMin(int i, double x); diff --git a/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.icc b/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.icc index 071400e3729dfef1ee7ac92c3d500d1653f4fa56..ddb5022730ae8913d9cdcbe186f528d46e80aa14 100644 --- a/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.icc +++ b/MagneticField/MagFieldElements/MagFieldElements/BFieldZone.icc @@ -1,6 +1,19 @@ /* Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ + +inline BFieldZone::BFieldZone(int id, + double zmin, + double zmax, + double rmin, + double rmax, + double phimin, + double phimax, + double scale) + : BFieldMesh<short>(zmin, zmax, rmin, rmax, phimin, phimax, scale) + , m_id(id) +{} + inline void BFieldZone::appendCond(const BFieldCond& cond) { @@ -26,6 +39,30 @@ BFieldZone::addBiotSavart(const double* ATH_RESTRICT xyz, } } +inline int +BFieldZone::id() const +{ + return m_id; +} + +inline unsigned +BFieldZone::ncond() const +{ + return m_cond.size(); +} + +inline const BFieldCond& +BFieldZone::cond(int i) const +{ + return m_cond[i]; +} + +inline const std::vector<BFieldCond>* +BFieldZone::condVector() const +{ + return &m_cond; +} + inline int BFieldZone::memSize() const { diff --git a/MagneticField/MagFieldElements/src/AtlasFieldCache.cxx b/MagneticField/MagFieldElements/src/AtlasFieldCache.cxx index a3927c4553d7ae0b388b047d33bfab7aad991839..d9e66122f27f8f1197470b4413577fbe188586f3 100644 --- a/MagneticField/MagFieldElements/src/AtlasFieldCache.cxx +++ b/MagneticField/MagFieldElements/src/AtlasFieldCache.cxx @@ -11,6 +11,9 @@ // #include "MagFieldElements/AtlasFieldCache.h" +#include <cmath> +#include <iostream> + void MagField::AtlasFieldCache::getField(const double* ATH_RESTRICT xyz, double* ATH_RESTRICT bxyz, @@ -89,7 +92,7 @@ MagField::AtlasFieldCache::getFieldZR(const double* ATH_RESTRICT xyz, const double x = xyz[0]; const double y = xyz[1]; const double z = xyz[2]; - const double r = sqrt(x * x + y * y); + const double r = std::sqrt(x * x + y * y); // test if the cache was initialized and the ZR cache is valid for current // position diff --git a/MagneticField/MagFieldElements/src/AtlasFieldMap.cxx b/MagneticField/MagFieldElements/src/AtlasFieldMap.cxx index 1956e5f35d9b4311074d600f804fad890b729498..d1f928528cd028487eaf0df143f9039f55ee1b4b 100644 --- a/MagneticField/MagFieldElements/src/AtlasFieldMap.cxx +++ b/MagneticField/MagFieldElements/src/AtlasFieldMap.cxx @@ -89,46 +89,30 @@ MagField::AtlasFieldMap::initializeMap(TFile* rootfile, // } int id; double zmin; - double zmax; - double rmin; - double rmax; - double phimin; - double phimax; double bscale; int ncond; bool* finite; double* p1x; - double* p1y; - double* p1z; - double* p2x; - double* p2y; - double* p2z; double* curr; int nmeshz; - int nmeshr; - int nmeshphi; double* meshz; - double* meshr; - double* meshphi; int nfield; short* fieldz; - short* fieldr; - short* fieldphi; // define the fixed-sized branches first tree->SetBranchAddress("id", &id); diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx index c5153b14d580f07469596bdc0c45e140275181f0..73720c06f418d97da57ac7e774bf7ef6d111d18c 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.cxx @@ -4,458 +4,475 @@ #include "MooSegmentCombinationFinder.h" +#include "MuonChamberT0s/ChamberT0s.h" +#include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" +#include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonSegment/MuonSegment.h" -#include "MuonSegment/MuonSegmentQuality.h" #include "MuonSegment/MuonSegmentCombinationCollection.h" - -#include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" - -#include "MuonChamberT0s/ChamberT0s.h" +#include "MuonSegment/MuonSegmentQuality.h" #include "MuonSegmentMakerUtils/SortSegmentsByNumberOfHits.h" - -#include "TrkEventPrimitives/FitQuality.h" - -#include "MuonReadoutGeometry/MuonDetectorManager.h" +#include "TrkEventPrimitives/FitQuality.h" //================ Constructor ================================================= -Muon::MooSegmentCombinationFinder::MooSegmentCombinationFinder(const std::string& t, const std::string& n, const IInterface* p) : - AthAlgTool(t,n,p), - m_houghPatternFinder("Muon::MuonHoughPatternFinderTool/MuonHoughPatternFinderTool") - { +Muon::MooSegmentCombinationFinder::MooSegmentCombinationFinder(const std::string& t, const std::string& n, + const IInterface* p) + : AthAlgTool(t, n, p) +{ declareInterface<IMooSegmentCombinationFinder>(this); - declareProperty("HoughPatternFinder", m_houghPatternFinder); - } +} - //================ Initialisation ================================================= +//================ Initialisation ================================================= -StatusCode +StatusCode Muon::MooSegmentCombinationFinder::initialize() -{ - ATH_CHECK( m_edmPrinter.retrieve() ); - ATH_CHECK( m_edmHelperSvc.retrieve() ); - ATH_CHECK( m_idHelperSvc.retrieve() ); - - if( m_doCscSegments ){ - ATH_CHECK( m_csc2dSegmentFinder.retrieve() ); - ATH_CHECK( m_csc4dSegmentFinder.retrieve() ); - } - else{ - m_csc2dSegmentFinder.disable(); - m_csc4dSegmentFinder.disable(); - } - - if( m_doMdtSegments ){ - ATH_CHECK( m_houghPatternFinder.retrieve() ); - ATH_CHECK( m_patternSegmentMaker.retrieve() ); - } - else{ - m_houghPatternFinder.disable(); - m_patternSegmentMaker.disable(); - } - - ATH_CHECK( m_segmentSelector.retrieve() ); - - if( m_doSegmentCombinations ){ - - ATH_CHECK( m_curvedSegmentCombiner.retrieve() ); - - if ( m_doSegmentCombinationCleaning ) - ATH_CHECK( m_segmentCombinationCleaner.retrieve() ); - else - m_segmentCombinationCleaner.disable(); - } - else{ - m_curvedSegmentCombiner.disable(); - m_segmentCombinationCleaner.disable(); - } - - return StatusCode::SUCCESS; +{ + ATH_CHECK(m_edmPrinter.retrieve()); + ATH_CHECK(m_edmHelperSvc.retrieve()); + ATH_CHECK(m_idHelperSvc.retrieve()); + + if (m_doCscSegments) { + ATH_CHECK(m_csc2dSegmentFinder.retrieve()); + ATH_CHECK(m_csc4dSegmentFinder.retrieve()); + } else { + m_csc2dSegmentFinder.disable(); + m_csc4dSegmentFinder.disable(); + } + + if (m_doMdtSegments) { + ATH_CHECK(m_houghPatternFinder.retrieve()); + ATH_CHECK(m_patternSegmentMaker.retrieve()); + } else { + m_houghPatternFinder.disable(); + m_patternSegmentMaker.disable(); + } + + ATH_CHECK(m_segmentSelector.retrieve()); + + if (m_doSegmentCombinations) { + + ATH_CHECK(m_curvedSegmentCombiner.retrieve()); + + if (m_doSegmentCombinationCleaning) + ATH_CHECK(m_segmentCombinationCleaner.retrieve()); + else + m_segmentCombinationCleaner.disable(); + } else { + m_curvedSegmentCombiner.disable(); + m_segmentCombinationCleaner.disable(); + } + + return StatusCode::SUCCESS; } - //================ Finalisation ================================================= +//================ Finalisation ================================================= -StatusCode +StatusCode Muon::MooSegmentCombinationFinder::finalize() { - // print statistics - double nevents = m_nevents!=0 ? static_cast<double>(m_nevents) : 1.; - - ATH_MSG_INFO(" Segment finding Summary: total number of events " << m_nevents << std::endl - << " CSC segment combinations: 2D " << std::setw(12) << m_ncsc2SegmentCombinations << " per event " << m_ncsc2SegmentCombinations/nevents << std::endl - << " CSC segment combinations: 4D " << std::setw(12) << m_ncsc4SegmentCombinations << " per event " << m_ncsc4SegmentCombinations/nevents << std::endl - << " Pattern combinations: " << std::setw(12) << m_npatternCombinations << " per event " << m_npatternCombinations/nevents << std::endl - << " MDT segment combinations: " << std::setw(12) << m_nmdtSegmentCombinations << " per event " << m_nmdtSegmentCombinations/nevents << std::endl - << " Combined segment combinations: " << std::setw(12) << m_ncombinedSegmentCombinations << " per event " << m_ncombinedSegmentCombinations/nevents << std::endl - << " Cleaned segment combinations: " << std::setw(12) << m_ncleanedSegmentCombinations << " per event " << m_ncleanedSegmentCombinations/nevents << std::endl - << " Segments: " << std::setw(12) << m_nsegments << " per event " << m_nsegments/nevents << std::endl - << " straight: " << std::setw(12) << m_nsegmentsStraight << " per event " << m_nsegmentsStraight/nevents << std::endl - << " curved: " << std::setw(12) << m_nsegmentsCurved << " per event " << m_nsegmentsCurved/nevents << std::endl - << " Discarded bad segments: " << std::setw(12) << m_nremovedBadSegments << " per event " << m_nremovedBadSegments/nevents); - - return StatusCode::SUCCESS; + // print statistics + double nevents = m_nevents != 0 ? static_cast<double>(m_nevents) : 1.; + + ATH_MSG_INFO(" Segment finding Summary: total number of events " + << m_nevents << std::endl + << " CSC segment combinations: 2D " << std::setw(12) << m_ncsc2SegmentCombinations << " per event " + << m_ncsc2SegmentCombinations / nevents << std::endl + << " CSC segment combinations: 4D " << std::setw(12) << m_ncsc4SegmentCombinations << " per event " + << m_ncsc4SegmentCombinations / nevents << std::endl + << " Pattern combinations: " << std::setw(12) << m_npatternCombinations << " per event " + << m_npatternCombinations / nevents << std::endl + << " MDT segment combinations: " << std::setw(12) << m_nmdtSegmentCombinations << " per event " + << m_nmdtSegmentCombinations / nevents << std::endl + << " Combined segment combinations: " << std::setw(12) << m_ncombinedSegmentCombinations + << " per event " << m_ncombinedSegmentCombinations / nevents << std::endl + << " Cleaned segment combinations: " << std::setw(12) << m_ncleanedSegmentCombinations + << " per event " << m_ncleanedSegmentCombinations / nevents << std::endl + << " Segments: " << std::setw(12) << m_nsegments << " per event " + << m_nsegments / nevents << std::endl + << " straight: " << std::setw(12) << m_nsegmentsStraight << " per event " + << m_nsegmentsStraight / nevents << std::endl + << " curved: " << std::setw(12) << m_nsegmentsCurved << " per event " + << m_nsegmentsCurved / nevents << std::endl + << " Discarded bad segments: " << std::setw(12) << m_nremovedBadSegments << " per event " + << m_nremovedBadSegments / nevents); + + return StatusCode::SUCCESS; } -void Muon::MooSegmentCombinationFinder::findSegments( const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - Muon::IMooSegmentCombinationFinder::Output& output) +void +Muon::MooSegmentCombinationFinder::findSegments(const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + Muon::IMooSegmentCombinationFinder::Output& output) { // Super tool has various different stages. - // 1. 2d Csc segment making, which produces MuonSegmentCombinations that are passed to the 4D segment maker, and the MuonCurvedSegmentCombiner - // 2. 4d Csc segment making, which produces MuonSegmentCombinations that are passed to the MuonHoughPatternFinder, and the MuonCurvedSegmentCombiner - // 3. MuonHoughPatternFinder, which produces MuonPatternCombinations, and Segment-Pattern Associations (which are passed to the MuonCurvedSegmentCombiner) - // 4. MuonPatternSegmentMaker, which takes in the remaining PRD types, and outputs MuonSegmentCombinations and seg-pattern associations. + // 1. 2d Csc segment making, which produces MuonSegmentCombinations that are passed to the 4D segment maker, and the + // MuonCurvedSegmentCombiner + // 2. 4d Csc segment making, which produces MuonSegmentCombinations that are passed to the MuonHoughPatternFinder, + // and the MuonCurvedSegmentCombiner + // 3. MuonHoughPatternFinder, which produces MuonPatternCombinations, and Segment-Pattern Associations (which are + // passed to the MuonCurvedSegmentCombiner) + // 4. MuonPatternSegmentMaker, which takes in the remaining PRD types, and outputs MuonSegmentCombinations and + // seg-pattern associations. // 5. MuonCurvedSegmentCombiner, which produces a MuonSegmentCombination // 6. MuonSegmentCombinationCleaner // 1. 2s Csc Segment Making - - MuonSegmentCombPatternCombAssociationMap segmentPatternMap; - - std::unique_ptr<MuonSegmentCombinationCollection> csc2dSegmentCombinations(new MuonSegmentCombinationCollection); - std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations(new MuonSegmentCombinationCollection); - if( m_doCscSegments ){ - // reconstruct segments in the CSC eta and phi plane - csc2dSegmentCombinations = m_csc2dSegmentFinder->find( cscCols ); - printSummary( "CSC 2D segment finding", csc2dSegmentCombinations.get() ); - - // combine CSC segments in eta and phi plane if any were found - if (csc2dSegmentCombinations) { - csc4dSegmentCombinations = m_csc4dSegmentFinder->find( *csc2dSegmentCombinations ); - printSummary( "CSC 4D segment finding", csc4dSegmentCombinations.get() ); - } - if( csc4dSegmentCombinations ){ - extractSegmentCollection( csc4dSegmentCombinations.get(), *(output.segmentCollection) ); - } + MuonSegmentCombPatternCombAssociationMap segmentPatternMap; - } + std::unique_ptr<MuonSegmentCombinationCollection> csc2dSegmentCombinations(new MuonSegmentCombinationCollection); + std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations(new MuonSegmentCombinationCollection); + if (m_doCscSegments) { + // reconstruct segments in the CSC eta and phi plane + csc2dSegmentCombinations = m_csc2dSegmentFinder->find(cscCols); + printSummary("CSC 2D segment finding", csc2dSegmentCombinations.get()); - std::unique_ptr<MuonSegmentCombinationCollection> mdtSegmentCombinations(new MuonSegmentCombinationCollection); - if( m_doMdtSegments ){ - // search for global patterns - auto [combis, houghData] = m_houghPatternFinder->find( mdtCols, cscCols, tgcCols, rpcCols, csc4dSegmentCombinations.get() ); - output.patternCombinations = combis.release(); - output.houghDataPerSectorVec = std::move(houghData); - printSummary( "Pattern finding", output.patternCombinations ); + // combine CSC segments in eta and phi plane if any were found + if (csc2dSegmentCombinations) { + csc4dSegmentCombinations = m_csc4dSegmentFinder->find(*csc2dSegmentCombinations); + printSummary("CSC 4D segment finding", csc4dSegmentCombinations.get()); + } - // search for MDT segments - if (output.patternCombinations) { - mdtSegmentCombinations = m_patternSegmentMaker->find( output.patternCombinations, &segmentPatternMap, rpcCols, tgcCols); - if( msgLvl(MSG::DEBUG) ) printSummary( "MDT segment finding", mdtSegmentCombinations.get() ); + if (csc4dSegmentCombinations) { + extractSegmentCollection(csc4dSegmentCombinations.get(), *(output.segmentCollection)); + } } - if( mdtSegmentCombinations ){ - extractSegmentCollection( mdtSegmentCombinations.get(), *(output.segmentCollection) ); + std::unique_ptr<MuonSegmentCombinationCollection> mdtSegmentCombinations(new MuonSegmentCombinationCollection); + if (m_doMdtSegments) { + // search for global patterns + auto [combis, houghData] = + m_houghPatternFinder->find(mdtCols, cscCols, tgcCols, rpcCols, csc4dSegmentCombinations.get()); + output.patternCombinations = combis.release(); + output.houghDataPerSectorVec = std::move(houghData); + printSummary("Pattern finding", output.patternCombinations); + + // search for MDT segments + if (output.patternCombinations) { + mdtSegmentCombinations = + m_patternSegmentMaker->find(output.patternCombinations, &segmentPatternMap, rpcCols, tgcCols); + if (msgLvl(MSG::DEBUG)) printSummary("MDT segment finding", mdtSegmentCombinations.get()); + } + + if (mdtSegmentCombinations) { + extractSegmentCollection(mdtSegmentCombinations.get(), *(output.segmentCollection)); + } + printSummary("MDT segment finding", output.segmentCollection); } - printSummary( "MDT segment finding", output.segmentCollection ); - } - std::unique_ptr<MuonSegmentCombinationCollection> curvedSegmentCombinations; - std::unique_ptr<MuonSegmentCombinationCollection> cleanedSegmentCombinations; - if( m_doSegmentCombinations ){ + std::unique_ptr<MuonSegmentCombinationCollection> curvedSegmentCombinations; + std::unique_ptr<MuonSegmentCombinationCollection> cleanedSegmentCombinations; + if (m_doSegmentCombinations) { - // create dummy collections if CSCs are missing - if( !csc2dSegmentCombinations ) csc2dSegmentCombinations = std::unique_ptr<MuonSegmentCombinationCollection>(new MuonSegmentCombinationCollection); - if( !csc4dSegmentCombinations ) csc4dSegmentCombinations = std::unique_ptr<MuonSegmentCombinationCollection>(new MuonSegmentCombinationCollection); + // create dummy collections if CSCs are missing + if (!csc2dSegmentCombinations) + csc2dSegmentCombinations = + std::unique_ptr<MuonSegmentCombinationCollection>(new MuonSegmentCombinationCollection); + if (!csc4dSegmentCombinations) + csc4dSegmentCombinations = + std::unique_ptr<MuonSegmentCombinationCollection>(new MuonSegmentCombinationCollection); - // combine MDT and CSC segments - if ( mdtSegmentCombinations ) { - curvedSegmentCombinations = m_curvedSegmentCombiner->combineSegments( *mdtSegmentCombinations, - *csc4dSegmentCombinations, - *csc2dSegmentCombinations, - &segmentPatternMap); - if( msgLvl(MSG::DEBUG) ) printSummary( "Segment combining", curvedSegmentCombinations.get() ); + // combine MDT and CSC segments + if (mdtSegmentCombinations) { + curvedSegmentCombinations = m_curvedSegmentCombiner->combineSegments( + *mdtSegmentCombinations, *csc4dSegmentCombinations, *csc2dSegmentCombinations, &segmentPatternMap); + if (msgLvl(MSG::DEBUG)) printSummary("Segment combining", curvedSegmentCombinations.get()); + } } - } - - if( m_doSegmentCombinationCleaning ){ - // clean segment combinations - MuonSegmentCombinationCollection* finalComb=curvedSegmentCombinations.get(); - if(!finalComb) finalComb=mdtSegmentCombinations.get(); - if(!finalComb) finalComb=csc4dSegmentCombinations.get(); - if(finalComb){ - cleanedSegmentCombinations = m_segmentCombinationCleaner->clean(*finalComb, &segmentPatternMap); - printSummary( "Segment combination cleaning", cleanedSegmentCombinations.get() ); + if (m_doSegmentCombinationCleaning) { + // clean segment combinations + MuonSegmentCombinationCollection* finalComb = curvedSegmentCombinations.get(); + if (!finalComb) finalComb = mdtSegmentCombinations.get(); + if (!finalComb) finalComb = csc4dSegmentCombinations.get(); + if (finalComb) { + cleanedSegmentCombinations = m_segmentCombinationCleaner->clean(*finalComb, &segmentPatternMap); + printSummary("Segment combination cleaning", cleanedSegmentCombinations.get()); + } } - } - - // increase counters, assume that the tools is only called once per event - ++m_nevents; - if( csc2dSegmentCombinations ) m_ncsc2SegmentCombinations += csc2dSegmentCombinations->size(); - if( csc4dSegmentCombinations ) m_ncsc4SegmentCombinations += csc4dSegmentCombinations->size(); - if( output.patternCombinations ) m_npatternCombinations += output.patternCombinations->size(); - if( mdtSegmentCombinations ) m_nmdtSegmentCombinations += mdtSegmentCombinations->size(); - if( curvedSegmentCombinations ) m_ncombinedSegmentCombinations += curvedSegmentCombinations->size(); - if( output.segmentCollection->size() ){ - m_nsegments += output.segmentCollection->size(); - Trk::SegmentCollection::const_iterator sit = output.segmentCollection->begin(); - Trk::SegmentCollection::const_iterator sit_end = output.segmentCollection->end(); - for( ;sit!=sit_end;++sit ){ - if( (*sit)->localParameters().contains(Trk::qOverP) ) ++m_nsegmentsCurved; - else ++m_nsegmentsStraight; + // increase counters, assume that the tools is only called once per event + ++m_nevents; + if (csc2dSegmentCombinations) m_ncsc2SegmentCombinations += csc2dSegmentCombinations->size(); + if (csc4dSegmentCombinations) m_ncsc4SegmentCombinations += csc4dSegmentCombinations->size(); + if (output.patternCombinations) m_npatternCombinations += output.patternCombinations->size(); + if (mdtSegmentCombinations) m_nmdtSegmentCombinations += mdtSegmentCombinations->size(); + if (curvedSegmentCombinations) m_ncombinedSegmentCombinations += curvedSegmentCombinations->size(); + if (output.segmentCollection->size()) { + m_nsegments += output.segmentCollection->size(); + Trk::SegmentCollection::const_iterator sit = output.segmentCollection->begin(); + Trk::SegmentCollection::const_iterator sit_end = output.segmentCollection->end(); + for (; sit != sit_end; ++sit) { + if ((*sit)->localParameters().contains(Trk::qOverP)) + ++m_nsegmentsCurved; + else + ++m_nsegmentsStraight; + } } - } - if( m_doSegmentCombinationCleaning ) m_ncleanedSegmentCombinations += cleanedSegmentCombinations->size(); + if (m_doSegmentCombinationCleaning) m_ncleanedSegmentCombinations += cleanedSegmentCombinations->size(); - // clean up intermediate steps - if( csc2dSegmentCombinations ) - postProcess( csc2dSegmentCombinations.get(), segmentPatternMap); + // clean up intermediate steps + if (csc2dSegmentCombinations) postProcess(csc2dSegmentCombinations.get(), segmentPatternMap); - if( csc4dSegmentCombinations) - postProcess( csc4dSegmentCombinations.get(), segmentPatternMap ); + if (csc4dSegmentCombinations) postProcess(csc4dSegmentCombinations.get(), segmentPatternMap); - if( mdtSegmentCombinations) - postProcess( mdtSegmentCombinations.get(), segmentPatternMap ); + if (mdtSegmentCombinations) postProcess(mdtSegmentCombinations.get(), segmentPatternMap); - if( curvedSegmentCombinations) - postProcess( curvedSegmentCombinations.get(), segmentPatternMap ); + if (curvedSegmentCombinations) postProcess(curvedSegmentCombinations.get(), segmentPatternMap); - if(cleanedSegmentCombinations) - postProcess(cleanedSegmentCombinations.get(), segmentPatternMap); + if (cleanedSegmentCombinations) postProcess(cleanedSegmentCombinations.get(), segmentPatternMap); - segmentPatternMap.clear(); - + segmentPatternMap.clear(); } -void -Muon::MooSegmentCombinationFinder::postProcess( MuonSegmentCombinationCollection* col, MuonSegmentCombPatternCombAssociationMap& segmentPatternMap){ - MuonSegmentCombinationCollection::const_iterator cit = col->begin(); - MuonSegmentCombinationCollection::const_iterator cit_end = col->end(); - for(; cit!=cit_end;++cit ){ - segmentPatternMap.erase(*cit); - } - return; +void +Muon::MooSegmentCombinationFinder::postProcess(MuonSegmentCombinationCollection* col, + MuonSegmentCombPatternCombAssociationMap& segmentPatternMap) +{ + MuonSegmentCombinationCollection::const_iterator cit = col->begin(); + MuonSegmentCombinationCollection::const_iterator cit_end = col->end(); + for (; cit != cit_end; ++cit) { + segmentPatternMap.erase(*cit); + } + return; } -void -Muon::MooSegmentCombinationFinder::printStage( std::string stageTag) const { - ATH_MSG_INFO("Reco stage: " << stageTag); +void +Muon::MooSegmentCombinationFinder::printStage(std::string stageTag) const +{ + ATH_MSG_INFO("Reco stage: " << stageTag); } -void -Muon::MooSegmentCombinationFinder::printSummary( std::string stageTag, const MuonSegmentCombinationCollection* col ) const { - if( m_doSummary || msgLvl(MSG::DEBUG) ){ - printStage( stageTag ); - if( !col ){ - ATH_MSG_INFO("No segment combinations found "); - }else{ - ATH_MSG_INFO("Found " << col->size() << " segment combinations " << std::endl - << m_edmPrinter->print( *col )); +void +Muon::MooSegmentCombinationFinder::printSummary(std::string stageTag, const MuonSegmentCombinationCollection* col) const +{ + if (m_doSummary || msgLvl(MSG::DEBUG)) { + printStage(stageTag); + if (!col) { + ATH_MSG_INFO("No segment combinations found "); + } else { + ATH_MSG_INFO("Found " << col->size() << " segment combinations " << std::endl << m_edmPrinter->print(*col)); + } } - } } -void -Muon::MooSegmentCombinationFinder::printSummary( std::string stageTag, const Trk::SegmentCollection* col ) const { - if( m_doSummary || msgLvl(MSG::DEBUG) ){ - printStage( stageTag ); - if( !col ){ - ATH_MSG_INFO("No segments found "); - }else{ - ATH_MSG_INFO("Found " << col->size() << " segments found "); - Trk::SegmentCollection::const_iterator sit = col->begin(); - Trk::SegmentCollection::const_iterator sit_end = col->end(); - for( ;sit!=sit_end;++sit ){ - const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*sit); - if( seg ){ - msg() << m_edmPrinter->print( *seg ) ; - if( sit+1 != sit_end ) msg() << std::endl; +void +Muon::MooSegmentCombinationFinder::printSummary(std::string stageTag, const Trk::SegmentCollection* col) const +{ + if (m_doSummary || msgLvl(MSG::DEBUG)) { + printStage(stageTag); + if (!col) { + ATH_MSG_INFO("No segments found "); + } else { + ATH_MSG_INFO("Found " << col->size() << " segments found "); + Trk::SegmentCollection::const_iterator sit = col->begin(); + Trk::SegmentCollection::const_iterator sit_end = col->end(); + for (; sit != sit_end; ++sit) { + const MuonSegment* seg = dynamic_cast<const MuonSegment*>(*sit); + if (seg) { + msg() << m_edmPrinter->print(*seg); + if (sit + 1 != sit_end) msg() << std::endl; + } + } + msg() << endmsg; } - } - msg() << endmsg; } - } } -void -Muon::MooSegmentCombinationFinder::printSummary( std::string stageTag, const MuonPatternCombinationCollection* col ) const +void +Muon::MooSegmentCombinationFinder::printSummary(std::string stageTag, const MuonPatternCombinationCollection* col) const { - if( m_doSummary || msgLvl(MSG::DEBUG) ){ - printStage( stageTag ); - if( !col ){ - ATH_MSG_INFO("No pattern combinations found "); - }else{ - ATH_MSG_INFO("Found " << col->size() << " pattern combinations found " << std::endl - << m_edmPrinter->print( *col )); + if (m_doSummary || msgLvl(MSG::DEBUG)) { + printStage(stageTag); + if (!col) { + ATH_MSG_INFO("No pattern combinations found "); + } else { + ATH_MSG_INFO("Found " << col->size() << " pattern combinations found " << std::endl + << m_edmPrinter->print(*col)); + } } - } } void -Muon::MooSegmentCombinationFinder::extractSegmentCollection( const MuonSegmentCombinationCollection* combiCol, Trk::SegmentCollection& segmentCol ) const { - - // store single segments per chamber layer - typedef std::vector<std::unique_ptr<Muon::MuonSegment> > SegVec; - //typedef SegVec::iterator SegVecIt; - typedef std::map<Muon::MuonStationIndex::ChIndex, std::unique_ptr<SegVec> > RSMap; - typedef RSMap::iterator RSMapIt; - RSMap segMap; - - unsigned int nremovedBadSegments(0); - unsigned int naccepted(0); - - MuonSegmentCombinationCollection::const_iterator cit = combiCol->begin(); - MuonSegmentCombinationCollection::const_iterator cit_end = combiCol->end(); - for(; cit!=cit_end;++cit ){ - if( !*cit ) { - ATH_MSG_DEBUG(" empty MuonSegmentCombination!!! "); - continue; - } - const Muon::MuonSegmentCombination& combi = **cit; - unsigned int nstations = combi.numberOfStations(); - - // segment quality level - bool ignoreHoles = false; - int quality = 1; - - //chamber status for csc - bool useEta=combi.useStripsInSegment(1); - bool usePhi=combi.useStripsInSegment(0); - - // loop over chambers in combi and extract segments - for(unsigned int i=0; i<nstations; ++i){ - - // loop over segments in station - Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments( i ) ; - - // check if not empty - if( !segments || segments->empty() ) continue; - - // get chamber identifier, chamber index and station index - Identifier chid = m_edmHelperSvc->chamberId( *segments->front() ); - Muon::MuonStationIndex::ChIndex chIndex = m_idHelperSvc->chamberIndex(chid); - - // add segments to region segment map, remove ambigueties (missing at the moment) - RSMapIt rsit = segMap.find( chIndex ); - if( rsit == segMap.end() ){ - std::unique_ptr<SegVec> segs(new SegVec); - // loop over new segments, copy them into collection - Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); - Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); - for( ; sit!=sit_end;++sit){ - - Muon::MuonSegment* seg=(*sit).get(); - // remove bad segments - if( !m_segmentSelector->select( *seg, ignoreHoles, quality, useEta, usePhi ) ){ - if( msgLvl(MSG::VERBOSE) ) { - int q = m_segmentSelector->quality(*seg,ignoreHoles,useEta,usePhi); - ATH_MSG_VERBOSE(" bad segment " << m_edmPrinter->print(*seg) << " quality " << q); - } - ++nremovedBadSegments; +Muon::MooSegmentCombinationFinder::extractSegmentCollection(const MuonSegmentCombinationCollection* combiCol, + Trk::SegmentCollection& segmentCol) const +{ + + // store single segments per chamber layer + typedef std::vector<std::unique_ptr<Muon::MuonSegment> > SegVec; + // typedef SegVec::iterator SegVecIt; + typedef std::map<Muon::MuonStationIndex::ChIndex, std::unique_ptr<SegVec> > RSMap; + typedef RSMap::iterator RSMapIt; + RSMap segMap; + + unsigned int nremovedBadSegments(0); + unsigned int naccepted(0); + + MuonSegmentCombinationCollection::const_iterator cit = combiCol->begin(); + MuonSegmentCombinationCollection::const_iterator cit_end = combiCol->end(); + for (; cit != cit_end; ++cit) { + if (!*cit) { + ATH_MSG_DEBUG(" empty MuonSegmentCombination!!! "); continue; - } - segs->push_back( std::move(*sit) ); } - segMap.insert( std::make_pair( chIndex, std::move(segs) ) ); - }else{ - // loop over new segments, copy them into collection - Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); - Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); - for( ; sit!=sit_end;++sit){ - - Muon::MuonSegment* seg=(*sit).get(); - // remove bad segments - if( !m_segmentSelector->select( *seg, ignoreHoles, quality,useEta,usePhi ) ){ - if( msgLvl(MSG::VERBOSE) ) { - int q = m_segmentSelector->quality(*seg,ignoreHoles,useEta,usePhi); - ATH_MSG_VERBOSE(" bad segment " << m_edmPrinter->print(*seg) << " quality " << q); + const Muon::MuonSegmentCombination& combi = **cit; + unsigned int nstations = combi.numberOfStations(); + + // segment quality level + bool ignoreHoles = false; + int quality = 1; + + // chamber status for csc + bool useEta = combi.useStripsInSegment(1); + bool usePhi = combi.useStripsInSegment(0); + + // loop over chambers in combi and extract segments + for (unsigned int i = 0; i < nstations; ++i) { + + // loop over segments in station + Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments(i); + + // check if not empty + if (!segments || segments->empty()) continue; + + // get chamber identifier, chamber index and station index + Identifier chid = m_edmHelperSvc->chamberId(*segments->front()); + Muon::MuonStationIndex::ChIndex chIndex = m_idHelperSvc->chamberIndex(chid); + + // add segments to region segment map, remove ambigueties (missing at the moment) + RSMapIt rsit = segMap.find(chIndex); + if (rsit == segMap.end()) { + std::unique_ptr<SegVec> segs(new SegVec); + // loop over new segments, copy them into collection + Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); + for (; sit != sit_end; ++sit) { + + Muon::MuonSegment* seg = (*sit).get(); + // remove bad segments + if (!m_segmentSelector->select(*seg, ignoreHoles, quality, useEta, usePhi)) { + if (msgLvl(MSG::VERBOSE)) { + int q = m_segmentSelector->quality(*seg, ignoreHoles, useEta, usePhi); + ATH_MSG_VERBOSE(" bad segment " << m_edmPrinter->print(*seg) << " quality " << q); + } + ++nremovedBadSegments; + continue; + } + segs->push_back(std::move(*sit)); + } + segMap.insert(std::make_pair(chIndex, std::move(segs))); + } else { + // loop over new segments, copy them into collection + Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); + for (; sit != sit_end; ++sit) { + + Muon::MuonSegment* seg = (*sit).get(); + // remove bad segments + if (!m_segmentSelector->select(*seg, ignoreHoles, quality, useEta, usePhi)) { + if (msgLvl(MSG::VERBOSE)) { + int q = m_segmentSelector->quality(*seg, ignoreHoles, useEta, usePhi); + ATH_MSG_VERBOSE(" bad segment " << m_edmPrinter->print(*seg) << " quality " << q); + } + ++nremovedBadSegments; + continue; + } + rsit->second->push_back(std::move(*sit)); + } } - ++nremovedBadSegments; - continue; - } - rsit->second->push_back( std::move(*sit) ); } - } } - } - // optionally output - RSMapIt rsit = segMap.begin(); - RSMapIt rsit_end = segMap.end(); - for( ;rsit!=rsit_end;++rsit){ + // optionally output + RSMapIt rsit = segMap.begin(); + RSMapIt rsit_end = segMap.end(); + for (; rsit != rsit_end; ++rsit) { - if( msgLvl(MSG::DEBUG) ) ATH_MSG_DEBUG("Working on new chamber layer with " << rsit->second->size() << " segments"); + if (msgLvl(MSG::DEBUG)) + ATH_MSG_DEBUG("Working on new chamber layer with " << rsit->second->size() << " segments"); - // sort segments according to the number of hits - std::stable_sort( rsit->second->begin(), rsit->second->end(), SortSegmentsByNumberOfHits() ); + // sort segments according to the number of hits + std::stable_sort(rsit->second->begin(), rsit->second->end(), SortSegmentsByNumberOfHits()); - // insert remaining segments into segment collection, cast away const as Trk::SegmentCollection contains non const pointers - naccepted += rsit->second->size(); - segmentCol.reserve( segmentCol.size()+rsit->second->size()); - SegVec::iterator sit = rsit->second->begin(); - SegVec::iterator sit_end = rsit->second->end(); - for( ;sit!=sit_end;++sit ) { - segmentCol.push_back( (*sit).release()); //releasing here, but the segmentCol immediately takes ownership + // insert remaining segments into segment collection, cast away const as Trk::SegmentCollection contains non + // const pointers + naccepted += rsit->second->size(); + segmentCol.reserve(segmentCol.size() + rsit->second->size()); + SegVec::iterator sit = rsit->second->begin(); + SegVec::iterator sit_end = rsit->second->end(); + for (; sit != sit_end; ++sit) { + segmentCol.push_back((*sit).release()); // releasing here, but the segmentCol immediately takes ownership + } } - } - - ATH_MSG_DEBUG(" Accepted " << naccepted - << " segments and removed " << nremovedBadSegments); - m_nremovedBadSegments += nremovedBadSegments; + ATH_MSG_DEBUG(" Accepted " << naccepted << " segments and removed " << nremovedBadSegments); + m_nremovedBadSegments += nremovedBadSegments; } -std::pair<int,int> Muon::MooSegmentCombinationFinder::hitsInMultilayer( const Muon::MuonSegment& segment ) const { - int nMl1(0); - int nMl2(0); - const std::vector< const Trk::MeasurementBase* >& measurements = segment.containedMeasurements(); - std::vector< const Trk::MeasurementBase* >::const_iterator it = measurements.begin(), itEnd = measurements.end(); - for(;it!=itEnd;++it){ - const Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(*it); - if( mdt ){ - int ml = m_idHelperSvc->mdtIdHelper().multilayer(mdt->identify()); - if( ml == 1 ) ++nMl1; - if( ml == 2 ) ++nMl2; +std::pair<int, int> +Muon::MooSegmentCombinationFinder::hitsInMultilayer(const Muon::MuonSegment& segment) const +{ + int nMl1(0); + int nMl2(0); + const std::vector<const Trk::MeasurementBase*>& measurements = segment.containedMeasurements(); + std::vector<const Trk::MeasurementBase*>::const_iterator it = measurements.begin(), itEnd = measurements.end(); + for (; it != itEnd; ++it) { + const Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(*it); + if (mdt) { + int ml = m_idHelperSvc->mdtIdHelper().multilayer(mdt->identify()); + if (ml == 1) ++nMl1; + if (ml == 2) ++nMl2; + } } - } - return std::make_pair(nMl1,nMl2); + return std::make_pair(nMl1, nMl2); } -bool Muon::MooSegmentCombinationFinder::goodSegment( const Muon::MuonSegment& segment ) const { +bool +Muon::MooSegmentCombinationFinder::goodSegment(const Muon::MuonSegment& segment) const +{ + + std::pair<int, int> hitsInMl = hitsInMultilayer(segment); + + if (hitsInMl.first > 1 && hitsInMl.second > 1) return true; - std::pair<int,int> hitsInMl = hitsInMultilayer(segment); - - if( hitsInMl.first > 1 && hitsInMl.second > 1 ) return true; + const Muon::MuonSegmentQuality* quality = dynamic_cast<const Muon::MuonSegmentQuality*>(segment.fitQuality()); + int missedHits(0); + if (quality) { + missedHits = quality->numberOfHoles(); + } + if (missedHits <= 3) return true; - const Muon::MuonSegmentQuality* quality = dynamic_cast<const Muon::MuonSegmentQuality*>(segment.fitQuality()); - int missedHits(0); - if( quality ) { - missedHits = quality->numberOfHoles(); - } - if( missedHits <= 3 ) return true; - - return false; + return false; } - -bool Muon::MooSegmentCombinationFinder::firstIsBest( const Muon::MuonSegment& seg1, const Muon::MuonSegment& seg2 ) const { - - std::pair<int,int> hitsInMl_1 = hitsInMultilayer(seg1); - std::pair<int,int> hitsInMl_2 = hitsInMultilayer(seg2); - - unsigned int nmdtHits1 = hitsInMl_1.first + hitsInMl_1.second; - unsigned int nmdtHits2 = hitsInMl_2.first + hitsInMl_2.second; - if( nmdtHits1 > nmdtHits2 ) return true; - if( nmdtHits1 < nmdtHits2 ) return false; - - // prefer segments with fit quality (always expected) - const Trk::FitQuality* fq1 = seg1.fitQuality(); - const Trk::FitQuality* fq2 = seg2.fitQuality(); - if( !fq1 && fq2 ) return false; - if( fq1 && !fq2 ) return true; - if( !fq1 && !fq2 ) return false; - - // select candidate with smallest chi2 - double chi2Ndof1 = fq1->chiSquared()/fq1->numberDoF(); - double chi2Ndof2 = fq2->chiSquared()/fq2->numberDoF(); - return chi2Ndof1 < chi2Ndof2; + +bool +Muon::MooSegmentCombinationFinder::firstIsBest(const Muon::MuonSegment& seg1, const Muon::MuonSegment& seg2) const +{ + + std::pair<int, int> hitsInMl_1 = hitsInMultilayer(seg1); + std::pair<int, int> hitsInMl_2 = hitsInMultilayer(seg2); + + unsigned int nmdtHits1 = hitsInMl_1.first + hitsInMl_1.second; + unsigned int nmdtHits2 = hitsInMl_2.first + hitsInMl_2.second; + if (nmdtHits1 > nmdtHits2) return true; + if (nmdtHits1 < nmdtHits2) return false; + + // prefer segments with fit quality (always expected) + const Trk::FitQuality* fq1 = seg1.fitQuality(); + const Trk::FitQuality* fq2 = seg2.fitQuality(); + if (!fq1 && fq2) return false; + if (fq1 && !fq2) return true; + if (!fq1 && !fq2) return false; + + // select candidate with smallest chi2 + double chi2Ndof1 = fq1->chiSquared() / fq1->numberDoF(); + double chi2Ndof2 = fq2->chiSquared() / fq2->numberDoF(); + return chi2Ndof1 < chi2Ndof2; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h index bcc5ea026276b2693bd2ea930a96cdbf38e590a6..1df43bd8ba6878d92d92b6f5480fa1657cc8f0e5 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentCombinationFinder.h @@ -5,129 +5,132 @@ #ifndef MUONMOOSEGMENTFINDER_H #define MUONMOOSEGMENTFINDER_H +#include <map> + #include "AthenaBaseComps/AthAlgTool.h" +#include "CscSegmentMakers/ICscSegmentFinder.h" #include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" - -#include "MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h" -#include "CscSegmentMakers/ICscSegmentFinder.h" -#include "MuonRecToolInterfaces/IMuonHoughPatternFinderTool.h" -#include "MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h" -#include "MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h" -#include "MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h" -#include "MuonSegmentMakerToolInterfaces/IMuonSegmentSelectionTool.h" -#include "MuonRecHelperTools/MuonEDMPrinterTool.h" -#include "MuonRecHelperTools/IMuonEDMHelperSvc.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" - +#include "GaudiKernel/ToolHandle.h" #include "MuonEDM_AssociationObjects/MuonSegmentCombPatternCombAssociationMap.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonPattern/MuonPatternCombinationCollection.h" -#include "TrkSegment/SegmentCollection.h" - -#include "MuonRecHelperTools/IMuonEDMHelperSvc.h" - #include "MuonPrepRawData/CscPrepDataCollection.h" #include "MuonPrepRawData/MdtPrepDataCollection.h" #include "MuonPrepRawData/RpcPrepDataCollection.h" #include "MuonPrepRawData/TgcPrepDataCollection.h" -#include <map> +#include "MuonRecHelperTools/IMuonEDMHelperSvc.h" +#include "MuonRecHelperTools/MuonEDMPrinterTool.h" +#include "MuonRecToolInterfaces/IMuonHoughPatternFinderTool.h" +#include "MuonSegment/MuonSegmentCombinationCollection.h" +#include "MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h" +#include "MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h" +#include "MuonSegmentCombinerToolInterfaces/IMuonSegmentCombinationCleanerTool.h" +#include "MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h" +#include "MuonSegmentMakerToolInterfaces/IMuonSegmentSelectionTool.h" +#include "TrkSegment/SegmentCollection.h" class ICscSegmentFinder; class MdtIdHelper; -namespace Muon -{ - class IMuonHoughPatternFinderTool; - class IMuonPatternSegmentMaker; - class IMuonCurvedSegmentCombiner; - class IMuonSegmentCombinationCleanerTool; - class IMuonSegmentSelectionTool; - class MuonEDMPrinterTool; - - /** @class MooSegmentCombinationFinder - - @author Edward Moyse <edward.moyse@cern.ch> - */ - - class MooSegmentCombinationFinder : virtual public IMooSegmentCombinationFinder, public AthAlgTool - { - public: - MooSegmentCombinationFinder(const std::string&,const std::string&,const IInterface*); - - /** default destructor */ - virtual ~MooSegmentCombinationFinder () = default; - - /** standard Athena-Algorithm method */ - virtual StatusCode initialize(); - /** standard Athena-Algorithm method */ - virtual StatusCode finalize (); - - /** This method cannot currently be const, since it needs to call non-const methods of child tools. - However this should be okay for MT as long as this tool is a private tool of the parent Algorithm.*/ - void findSegments(const std::vector<const MdtPrepDataCollection*>& mdtCols, - const std::vector<const CscPrepDataCollection*>& cscCols, - const std::vector<const TgcPrepDataCollection*>& tgcCols, - const std::vector<const RpcPrepDataCollection*>& rpcCols, - IMooSegmentCombinationFinder::Output& output); - - private: - - /** helper functions to print summary output for the different stages */ - void printStage( std::string stageTag) const; - void printSummary( std::string stageTag, const MuonSegmentCombinationCollection* col ) const; - void printSummary( std::string stageTag, const MuonPatternCombinationCollection* col ) const; - void printSummary( std::string stageTag, const Trk::SegmentCollection* col ) const; - - /** helper functions to write out intermediate results */ - void postProcess( MuonSegmentCombinationCollection* col, MuonSegmentCombPatternCombAssociationMap& segmentPatternMap) ; - - /** extract a segment collection from a segment combination collection */ - void extractSegmentCollection( const MuonSegmentCombinationCollection* combiCol, Trk::SegmentCollection& segments ) const; - - /** select segment on quality */ - bool goodSegment( const MuonSegment& segment ) const; - std::pair<int,int> hitsInMultilayer( const Muon::MuonSegment& segment ) const; - bool firstIsBest( const Muon::MuonSegment& seg1, const Muon::MuonSegment& seg2 ) const; - - Gaudi::Property<bool> m_doSummary {this, "DoSummary", false, "Print summary after each stage"}; - Gaudi::Property<bool> m_doCscSegments {this, "DoCscSegments", true, "Run CSC segment finding"}; - Gaudi::Property<bool> m_doMdtSegments {this, "DoMdtSegments", true, "Run MDT segment finding"}; - Gaudi::Property<bool> m_doSegmentCombinations {this, "DoSegmentCombinations", false, "Run segment combination finding"}; - Gaudi::Property<bool> m_doSegmentCombinationCleaning {this, "DoSegmentCombinationCleaning", false, "Run segment combination cleaning"}; - Gaudi::Property<bool> m_cloneSegments {this, "CloneSegments", false, ""}; - - ToolHandle<MuonEDMPrinterTool> m_edmPrinter {"Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"}; - ServiceHandle<IMuonEDMHelperSvc> m_edmHelperSvc {this, "edmHelper", - "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc", - "Handle to the service providing the IMuonEDMHelperSvc interface" }; - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - ToolHandle<ICscSegmentFinder> m_csc2dSegmentFinder{this, "Csc2dSegmentMaker", "Csc2dSegmentMaker/Csc2dSegmentMaker"}; - ToolHandle<ICscSegmentFinder> m_csc4dSegmentFinder{this, "Csc4dSegmentMaker", "Csc4dSegmentMaker/Csc4dSegmentMaker"}; - ToolHandle<IMuonHoughPatternFinderTool> m_houghPatternFinder; - ToolHandle<IMuonPatternSegmentMaker> m_patternSegmentMaker{this, "MdtSegmentMaker", "Muon::MuonPatternSegmentMaker/MuonPatternSegmentMaker"}; - ToolHandle<IMuonCurvedSegmentCombiner> m_curvedSegmentCombiner{this, "SegmentCombiner", "Muon::MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner"}; - ToolHandle<IMuonSegmentCombinationCleanerTool> m_segmentCombinationCleaner{this, "SegmentCombinationCleaner","Muon::MuonSegmentCombinationCleanerTool/MuonSegmentCombinationCleanerTool"}; - ToolHandle<IMuonSegmentSelectionTool> m_segmentSelector{this, "SegmentSelector", "Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool"}; - - - /** counters */ - mutable std::atomic_uint m_nevents{0}; - mutable std::atomic_uint m_ncsc2SegmentCombinations{0}; - mutable std::atomic_uint m_ncsc4SegmentCombinations{0}; - mutable std::atomic_uint m_npatternCombinations{0}; - mutable std::atomic_uint m_nmdtSegmentCombinations{0}; - mutable std::atomic_uint m_ncombinedSegmentCombinations{0}; - mutable std::atomic_uint m_ncleanedSegmentCombinations{0}; - mutable std::atomic_uint m_nsegments{0}; - mutable std::atomic_uint m_nsegmentsStraight{0}; - mutable std::atomic_uint m_nsegmentsCurved{0}; - mutable std::atomic_uint m_nremovedBadSegments{0}; - - }; - -} // end of namespace - -#endif +namespace Muon { +class IMuonHoughPatternFinderTool; +class IMuonPatternSegmentMaker; +class IMuonCurvedSegmentCombiner; +class IMuonSegmentCombinationCleanerTool; +class IMuonSegmentSelectionTool; +class MuonEDMPrinterTool; + +/** @class MooSegmentCombinationFinder + + @author Edward Moyse <edward.moyse@cern.ch> +*/ + +class MooSegmentCombinationFinder : virtual public IMooSegmentCombinationFinder, public AthAlgTool { + public: + MooSegmentCombinationFinder(const std::string&, const std::string&, const IInterface*); + + /** default destructor */ + virtual ~MooSegmentCombinationFinder() = default; + + /** standard Athena-Algorithm method */ + virtual StatusCode initialize(); + /** standard Athena-Algorithm method */ + virtual StatusCode finalize(); + + /** This method cannot currently be const, since it needs to call non-const methods of child tools. + However this should be okay for MT as long as this tool is a private tool of the parent Algorithm.*/ + void findSegments(const std::vector<const MdtPrepDataCollection*>& mdtCols, + const std::vector<const CscPrepDataCollection*>& cscCols, + const std::vector<const TgcPrepDataCollection*>& tgcCols, + const std::vector<const RpcPrepDataCollection*>& rpcCols, + IMooSegmentCombinationFinder::Output& output); + + private: + /** helper functions to print summary output for the different stages */ + void printStage(std::string stageTag) const; + void printSummary(std::string stageTag, const MuonSegmentCombinationCollection* col) const; + void printSummary(std::string stageTag, const MuonPatternCombinationCollection* col) const; + void printSummary(std::string stageTag, const Trk::SegmentCollection* col) const; + + /** helper functions to write out intermediate results */ + void postProcess(MuonSegmentCombinationCollection* col, + MuonSegmentCombPatternCombAssociationMap& segmentPatternMap); + + /** extract a segment collection from a segment combination collection */ + void extractSegmentCollection(const MuonSegmentCombinationCollection* combiCol, + Trk::SegmentCollection& segments) const; + + /** select segment on quality */ + bool goodSegment(const MuonSegment& segment) const; + std::pair<int, int> hitsInMultilayer(const Muon::MuonSegment& segment) const; + bool firstIsBest(const Muon::MuonSegment& seg1, const Muon::MuonSegment& seg2) const; + + Gaudi::Property<bool> m_doSummary{this, "DoSummary", false, "Print summary after each stage"}; + Gaudi::Property<bool> m_doCscSegments{this, "DoCscSegments", true, "Run CSC segment finding"}; + Gaudi::Property<bool> m_doMdtSegments{this, "DoMdtSegments", true, "Run MDT segment finding"}; + Gaudi::Property<bool> m_doSegmentCombinations{this, "DoSegmentCombinations", false, + "Run segment combination finding"}; + Gaudi::Property<bool> m_doSegmentCombinationCleaning{this, "DoSegmentCombinationCleaning", false, + "Run segment combination cleaning"}; + Gaudi::Property<bool> m_cloneSegments{this, "CloneSegments", false, ""}; + + ToolHandle<MuonEDMPrinterTool> m_edmPrinter{"Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"}; + ServiceHandle<IMuonEDMHelperSvc> m_edmHelperSvc{this, "edmHelper", "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc", + "Handle to the service providing the IMuonEDMHelperSvc interface"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", + "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; + ToolHandle<ICscSegmentFinder> m_csc2dSegmentFinder{this, "Csc2dSegmentMaker", + "Csc2dSegmentMaker/Csc2dSegmentMaker"}; + ToolHandle<ICscSegmentFinder> m_csc4dSegmentFinder{this, "Csc4dSegmentMaker", + "Csc4dSegmentMaker/Csc4dSegmentMaker"}; + ToolHandle<IMuonHoughPatternFinderTool> m_houghPatternFinder{this, "HoughPatternFinder", + "Muon::MuonHoughPatternFinderTool/MuonHoughPatternFinderTool"}; + ToolHandle<IMuonPatternSegmentMaker> m_patternSegmentMaker{this, "MdtSegmentMaker", + "Muon::MuonPatternSegmentMaker/MuonPatternSegmentMaker"}; + ToolHandle<IMuonCurvedSegmentCombiner> m_curvedSegmentCombiner{ + this, "SegmentCombiner", "Muon::MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner"}; + ToolHandle<IMuonSegmentCombinationCleanerTool> m_segmentCombinationCleaner{ + this, "SegmentCombinationCleaner", "Muon::MuonSegmentCombinationCleanerTool/MuonSegmentCombinationCleanerTool"}; + ToolHandle<IMuonSegmentSelectionTool> m_segmentSelector{this, "SegmentSelector", + "Muon::MuonSegmentSelectionTool/MuonSegmentSelectionTool"}; + + + /** counters */ + mutable std::atomic_uint m_nevents{0}; + mutable std::atomic_uint m_ncsc2SegmentCombinations{0}; + mutable std::atomic_uint m_ncsc4SegmentCombinations{0}; + mutable std::atomic_uint m_npatternCombinations{0}; + mutable std::atomic_uint m_nmdtSegmentCombinations{0}; + mutable std::atomic_uint m_ncombinedSegmentCombinations{0}; + mutable std::atomic_uint m_ncleanedSegmentCombinations{0}; + mutable std::atomic_uint m_nsegments{0}; + mutable std::atomic_uint m_nsegmentsStraight{0}; + mutable std::atomic_uint m_nsegmentsCurved{0}; + mutable std::atomic_uint m_nremovedBadSegments{0}; +}; + +} // namespace Muon + +#endif diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx index 534263e40f159dcca78c7cd65d615073b22bbd9a..3113a49fb2ed64dd0f8601d05e8c01f5d09cdb59 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.cxx @@ -3,156 +3,148 @@ */ #include "MooSegmentFinderAlg.h" -#include "MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h" - -#include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h" -#include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h" - -#include "MuonSegment/MuonSegment.h" #include "MuonPrepRawData/MuonPrepDataContainer.h" +#include "MuonSegment/MuonSegment.h" +#include "MuonSegmentCombinerToolInterfaces/IMooSegmentCombinationFinder.h" +#include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h" -MooSegmentFinderAlg::MooSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator): - AthAlgorithm(name,pSvcLocator), - m_keyTgc("TGC_Measurements"), - m_keyTgcPriorBC( "TGC_MeasurementsPriorBC"), - m_keyTgcNextBC("TGC_MeasurementsNextBC"), - m_keyRpc("RPC_Measurements"), - m_keyCsc( "CSC_Clusters"), - m_keyMdt("MDT_DriftCircles"), - m_patternCombiLocation("MuonHoughPatternCombinations"), - m_segmentLocation("MooreSegments"), - m_segmentFinder("Muon::MooSegmentCombinationFinder/MooSegmentCombinationFinder", this), - m_clusterSegMaker("Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder", this), - m_overlapRemovalTool("Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool", this) +MooSegmentFinderAlg::MooSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator) + : AthAlgorithm(name, pSvcLocator), + m_keyTgc("TGC_Measurements"), + m_keyTgcPriorBC("TGC_MeasurementsPriorBC"), + m_keyTgcNextBC("TGC_MeasurementsNextBC"), + m_keyRpc("RPC_Measurements"), + m_keyCsc("CSC_Clusters"), + m_keyMdt("MDT_DriftCircles"), + m_patternCombiLocation("MuonHoughPatternCombinations"), + m_segmentLocation("MooreSegments") { - declareProperty("UseRPC",m_useRpc = true); - declareProperty("UseTGC",m_useTgc = true); - declareProperty("UseTGCPriorBC",m_useTgcPriorBC = false); - declareProperty("UseTGCNextBC",m_useTgcNextBC = false); - declareProperty("UseCSC",m_useCsc = true); - declareProperty("UseMDT",m_useMdt = true); - - declareProperty("doTGCClust",m_doTGCClust = false); - declareProperty("doRPCClust",m_doRPCClust = false); - declareProperty("doClusterTruth",m_doClusterTruth=false); - - declareProperty("CscPrepDataContainer", m_keyCsc); - declareProperty("MdtPrepDataContainer", m_keyMdt); - declareProperty("RpcPrepDataContainer", m_keyRpc); - declareProperty("TgcPrepDataContainer", m_keyTgc); - declareProperty("TgcPrepDataContainerPriorBC", m_keyTgcPriorBC); - declareProperty("TgcPrepDataContainerNextBC", m_keyTgcNextBC); - - declareProperty("MuonPatternCombinationLocation", m_patternCombiLocation); - declareProperty("MuonSegmentOutputLocation", m_segmentLocation ); - - declareProperty("SegmentFinder", m_segmentFinder ); - declareProperty("MuonClusterSegmentFinderTool",m_clusterSegMaker); - declareProperty("SegmentOverlapRemovalTool", m_overlapRemovalTool, "tool to removal overlaps in segment combinations" ); + declareProperty("UseRPC", m_useRpc = true); + declareProperty("UseTGC", m_useTgc = true); + declareProperty("UseTGCPriorBC", m_useTgcPriorBC = false); + declareProperty("UseTGCNextBC", m_useTgcNextBC = false); + declareProperty("UseCSC", m_useCsc = true); + declareProperty("UseMDT", m_useMdt = true); + + declareProperty("doTGCClust", m_doTGCClust = false); + declareProperty("doRPCClust", m_doRPCClust = false); + declareProperty("doClusterTruth", m_doClusterTruth = false); + + declareProperty("CscPrepDataContainer", m_keyCsc); + declareProperty("MdtPrepDataContainer", m_keyMdt); + declareProperty("RpcPrepDataContainer", m_keyRpc); + declareProperty("TgcPrepDataContainer", m_keyTgc); + declareProperty("TgcPrepDataContainerPriorBC", m_keyTgcPriorBC); + declareProperty("TgcPrepDataContainerNextBC", m_keyTgcNextBC); + + declareProperty("MuonPatternCombinationLocation", m_patternCombiLocation); + declareProperty("MuonSegmentOutputLocation", m_segmentLocation); } -MooSegmentFinderAlg::~MooSegmentFinderAlg() -{ -} +MooSegmentFinderAlg::~MooSegmentFinderAlg() {} -StatusCode MooSegmentFinderAlg::initialize() +StatusCode +MooSegmentFinderAlg::initialize() { - - ATH_CHECK( m_segmentFinder.retrieve() ); - ATH_CHECK( m_clusterSegMaker.retrieve() ); - ATH_CHECK( m_overlapRemovalTool.retrieve() ); - - ATH_CHECK( m_keyMdt.initialize(m_useMdt) ); //Nullify key from scheduler if not needed - ATH_CHECK( m_keyCsc.initialize(m_useCsc) ); - ATH_CHECK( m_keyRpc.initialize(m_useRpc) ); - ATH_CHECK( m_keyTgcPriorBC.initialize(m_useTgcPriorBC) ); - ATH_CHECK( m_keyTgcNextBC.initialize(m_useTgcNextBC) ); - ATH_CHECK( m_keyTgc.initialize(m_useTgc) ); - - ATH_CHECK( m_tgcTruth.initialize(m_doClusterTruth) ); - ATH_CHECK( m_rpcTruth.initialize(m_doClusterTruth) ); - - ATH_CHECK( m_patternCombiLocation.initialize() ); - ATH_CHECK( m_segmentLocation.initialize() ); - ATH_CHECK( m_houghDataPerSectorVecKey.initialize() ); - - return StatusCode::SUCCESS; + + ATH_CHECK(m_segmentFinder.retrieve()); + ATH_CHECK(m_clusterSegMaker.retrieve()); + ATH_CHECK(m_overlapRemovalTool.retrieve()); + + ATH_CHECK(m_keyMdt.initialize(m_useMdt)); // Nullify key from scheduler if not needed + ATH_CHECK(m_keyCsc.initialize(m_useCsc)); + ATH_CHECK(m_keyRpc.initialize(m_useRpc)); + ATH_CHECK(m_keyTgcPriorBC.initialize(m_useTgcPriorBC)); + ATH_CHECK(m_keyTgcNextBC.initialize(m_useTgcNextBC)); + ATH_CHECK(m_keyTgc.initialize(m_useTgc)); + + ATH_CHECK(m_tgcTruth.initialize(m_doClusterTruth)); + ATH_CHECK(m_rpcTruth.initialize(m_doClusterTruth)); + + ATH_CHECK(m_patternCombiLocation.initialize()); + ATH_CHECK(m_segmentLocation.initialize()); + ATH_CHECK(m_houghDataPerSectorVecKey.initialize()); + + return StatusCode::SUCCESS; } -StatusCode MooSegmentFinderAlg::execute() +StatusCode +MooSegmentFinderAlg::execute() { - std::vector<const Muon::MdtPrepDataCollection*> mdtCols; - std::vector<const Muon::CscPrepDataCollection*> cscCols; - std::vector<const Muon::TgcPrepDataCollection*> tgcCols; - std::vector<const Muon::RpcPrepDataCollection*> rpcCols; - if( m_useMdt ) retrieveCollections(mdtCols,m_keyMdt); - if( m_useCsc ) retrieveCollections(cscCols,m_keyCsc); - if( m_useTgc ) retrieveCollections(tgcCols,m_keyTgc); - if( m_useTgcPriorBC ) retrieveCollections(tgcCols,m_keyTgcPriorBC); - if( m_useTgcNextBC ) retrieveCollections(tgcCols,m_keyTgcNextBC); - if( m_useRpc ) retrieveCollections(rpcCols,m_keyRpc); - - Muon::IMooSegmentCombinationFinder::Output output; - - SG::WriteHandle<Trk::SegmentCollection> segHandle(m_segmentLocation); - - if (segHandle.record(std::make_unique<Trk::SegmentCollection>()).isSuccess() ){ - ATH_MSG_VERBOSE("stored MuonSegmentCollection at "<<m_segmentLocation.key()); - }else{ - ATH_MSG_ERROR("Failed to store MuonSegmentCollection "); - } - output.segmentCollection=segHandle.ptr(); - - SG::WriteHandle<MuonPatternCombinationCollection> patHandle(m_patternCombiLocation); - - m_segmentFinder->findSegments( mdtCols, cscCols, tgcCols, rpcCols, output ); - - if(output.patternCombinations){ - if( patHandle.record(std::unique_ptr<MuonPatternCombinationCollection>(output.patternCombinations)).isSuccess() ){ - ATH_MSG_VERBOSE("stored MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); - }else{ - ATH_MSG_ERROR("Failed to store MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + std::vector<const Muon::MdtPrepDataCollection*> mdtCols; + std::vector<const Muon::CscPrepDataCollection*> cscCols; + std::vector<const Muon::TgcPrepDataCollection*> tgcCols; + std::vector<const Muon::RpcPrepDataCollection*> rpcCols; + if (m_useMdt) retrieveCollections(mdtCols, m_keyMdt); + if (m_useCsc) retrieveCollections(cscCols, m_keyCsc); + if (m_useTgc) retrieveCollections(tgcCols, m_keyTgc); + if (m_useTgcPriorBC) retrieveCollections(tgcCols, m_keyTgcPriorBC); + if (m_useTgcNextBC) retrieveCollections(tgcCols, m_keyTgcNextBC); + if (m_useRpc) retrieveCollections(rpcCols, m_keyRpc); + + Muon::IMooSegmentCombinationFinder::Output output; + + SG::WriteHandle<Trk::SegmentCollection> segHandle(m_segmentLocation); + + if (segHandle.record(std::make_unique<Trk::SegmentCollection>()).isSuccess()) { + ATH_MSG_VERBOSE("stored MuonSegmentCollection at " << m_segmentLocation.key()); + } else { + ATH_MSG_ERROR("Failed to store MuonSegmentCollection "); + } + output.segmentCollection = segHandle.ptr(); + + SG::WriteHandle<MuonPatternCombinationCollection> patHandle(m_patternCombiLocation); + + m_segmentFinder->findSegments(mdtCols, cscCols, tgcCols, rpcCols, output); + + if (output.patternCombinations) { + if (patHandle.record(std::unique_ptr<MuonPatternCombinationCollection>(output.patternCombinations)).isSuccess()) + { + ATH_MSG_VERBOSE("stored MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + } else { + ATH_MSG_ERROR("Failed to store MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + } + output.patternCombinations = nullptr; + } else { + if (patHandle.record(std::make_unique<MuonPatternCombinationCollection>()).isSuccess()) { + ATH_MSG_VERBOSE("stored MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + } else { + ATH_MSG_ERROR("Failed to store MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + } } - output.patternCombinations = nullptr; - } - else{ - if( patHandle.record(std::make_unique<MuonPatternCombinationCollection>()).isSuccess() ){ - ATH_MSG_VERBOSE("stored MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); - }else{ - ATH_MSG_ERROR("Failed to store MuonPatternCombinationCollection at " << m_patternCombiLocation.key()); + + // write hough data to SG + if (output.houghDataPerSectorVec) { + SG::WriteHandle<Muon::HoughDataPerSectorVec> handle{m_houghDataPerSectorVecKey}; + ATH_CHECK(handle.record(std::move(output.houghDataPerSectorVec))); + } else { + ATH_MSG_VERBOSE("HoughDataPerSectorVec was empty, key: " << m_houghDataPerSectorVecKey.key()); } - } - - // write hough data to SG - if (output.houghDataPerSectorVec) { - SG::WriteHandle<Muon::HoughDataPerSectorVec> handle {m_houghDataPerSectorVecKey}; - ATH_CHECK(handle.record(std::move(output.houghDataPerSectorVec))); - } else { - ATH_MSG_VERBOSE("HoughDataPerSectorVec was empty, key: " << m_houghDataPerSectorVecKey.key()); - } - - //do cluster based segment finding - if (m_doTGCClust || m_doRPCClust){ - const PRD_MultiTruthCollection* tgcTruthColl=0; - const PRD_MultiTruthCollection* rpcTruthColl=0; - if(m_doClusterTruth){ - SG::ReadHandle<PRD_MultiTruthCollection> tgcTruth(m_tgcTruth); - SG::ReadHandle<PRD_MultiTruthCollection> rpcTruth(m_rpcTruth); - tgcTruthColl=tgcTruth.cptr(); - rpcTruthColl=rpcTruth.cptr(); + + // do cluster based segment finding + if (m_doTGCClust || m_doRPCClust) { + const PRD_MultiTruthCollection* tgcTruthColl = 0; + const PRD_MultiTruthCollection* rpcTruthColl = 0; + if (m_doClusterTruth) { + SG::ReadHandle<PRD_MultiTruthCollection> tgcTruth(m_tgcTruth); + SG::ReadHandle<PRD_MultiTruthCollection> rpcTruth(m_rpcTruth); + tgcTruthColl = tgcTruth.cptr(); + rpcTruthColl = rpcTruth.cptr(); + } + SG::ReadHandle<Muon::MdtPrepDataContainer> mdth(m_keyMdt); + m_clusterSegMaker->getClusterSegments(mdth.cptr(), m_doTGCClust ? &tgcCols : 0, m_doRPCClust ? &rpcCols : 0, + tgcTruthColl, rpcTruthColl, segHandle.ptr()); } - SG::ReadHandle<Muon::MdtPrepDataContainer> mdth(m_keyMdt); - m_clusterSegMaker->getClusterSegments(mdth.cptr(), m_doTGCClust ? &tgcCols : 0, m_doRPCClust ? &rpcCols : 0, tgcTruthColl, rpcTruthColl, segHandle.ptr()); - } - m_overlapRemovalTool->removeDuplicates(segHandle.ptr()); + m_overlapRemovalTool->removeDuplicates(segHandle.ptr()); - return StatusCode::SUCCESS; -} // execute + return StatusCode::SUCCESS; +} // execute -StatusCode MooSegmentFinderAlg::finalize() +StatusCode +MooSegmentFinderAlg::finalize() { - return StatusCode::SUCCESS; + return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h index 914bca58346cee6e495818313da4cf132b29d30a..615533b9b0f940428a7b54dc99bbc5dc205b2b0d 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MooSegmentFinderAlg.h @@ -7,96 +7,108 @@ #include "AthenaBaseComps/AthAlgorithm.h" #include "GaudiKernel/ToolHandle.h" - +#include "MuonPattern/MuonPatternCombinationCollection.h" #include "MuonPrepRawData/CscPrepDataCollection.h" #include "MuonPrepRawData/MdtPrepDataCollection.h" +#include "MuonPrepRawData/MuonPrepDataContainer.h" #include "MuonPrepRawData/RpcPrepDataCollection.h" #include "MuonPrepRawData/TgcPrepDataCollection.h" - -#include "TrkTruthData/PRD_MultiTruthCollection.h" - +#include "MuonRecToolInterfaces/HoughDataPerSec.h" #include "MuonSegment/MuonSegmentCombinationCollection.h" +#include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h" #include "TrkSegment/SegmentCollection.h" -#include "MuonPrepRawData/MuonPrepDataContainer.h" -#include "MuonPattern/MuonPatternCombinationCollection.h" -#include "MuonRecToolInterfaces/HoughDataPerSec.h" +#include "TrkTruthData/PRD_MultiTruthCollection.h" class MsgStream; namespace Muon { - class IMuonClusterSegmentFinder; - class IMooSegmentCombinationFinder; - class IMuonSegmentOverlapRemovalTool; -} - -class MooSegmentFinderAlg : public AthAlgorithm -{ - public: - MooSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator); - - virtual ~MooSegmentFinderAlg(); - - virtual StatusCode initialize() override; - virtual StatusCode execute() override; - virtual StatusCode finalize() override; - - private: - template<class T, class Y> - void retrieveCollections( std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key ); - - /** extract segments from a MuonSegmentCombinationCollection */ - Trk::SegmentCollection* extractSegmentCollection( const MuonSegmentCombinationCollection& segmentCombinations ) const; - - /** selection flags for all four technologies */ - bool m_useTgc; - bool m_useTgcPriorBC; - bool m_useTgcNextBC; - bool m_useRpc; - bool m_useCsc; - bool m_useMdt; - - /** selection flags for cluster based segment finding */ - bool m_doTGCClust; - bool m_doRPCClust; - bool m_doClusterTruth; - - /** storegate location of the MuonPrepDataContainer for all four technologies */ - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_keyTgc; - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_keyTgcPriorBC; - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_keyTgcNextBC; - SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_keyRpc; - SG::ReadHandleKey<Muon::CscPrepDataContainer> m_keyCsc; - SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_keyMdt; - - SG::ReadHandleKey<PRD_MultiTruthCollection> m_tgcTruth{this,"TGCTruth","TGC_TruthMap","TGC PRD Multi-truth Collection"}; - SG::ReadHandleKey<PRD_MultiTruthCollection> m_rpcTruth{this,"RPCTruth","RPC_TruthMap","RPC PRD Multi-truth Collection"}; - - SG::WriteHandleKey<MuonPatternCombinationCollection> m_patternCombiLocation; - SG::WriteHandleKey<Trk::SegmentCollection> m_segmentLocation; - SG::WriteHandleKey<Muon::HoughDataPerSectorVec> m_houghDataPerSectorVecKey {this, - "Key_MuonLayerHoughToolHoughDataPerSectorVec", "HoughDataPerSectorVec", "HoughDataPerSectorVec key"}; - - ToolHandle<Muon::IMooSegmentCombinationFinder> m_segmentFinder; //<! pointer to the segment finder - ToolHandle<Muon::IMuonClusterSegmentFinder> m_clusterSegMaker; - ToolHandle<Muon::IMuonSegmentOverlapRemovalTool> m_overlapRemovalTool; - +class IMooSegmentCombinationFinder; +class IMuonSegmentOverlapRemovalTool; +} // namespace Muon + +class MooSegmentFinderAlg : public AthAlgorithm { + public: + MooSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator); + + virtual ~MooSegmentFinderAlg(); + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + private: + template <class T, class Y> + void retrieveCollections(std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key); + + /** extract segments from a MuonSegmentCombinationCollection */ + Trk::SegmentCollection* extractSegmentCollection(const MuonSegmentCombinationCollection& segmentCombinations) const; + + /** selection flags for all four technologies */ + bool m_useTgc; + bool m_useTgcPriorBC; + bool m_useTgcNextBC; + bool m_useRpc; + bool m_useCsc; + bool m_useMdt; + + /** selection flags for cluster based segment finding */ + bool m_doTGCClust; + bool m_doRPCClust; + bool m_doClusterTruth; + + /** storegate location of the MuonPrepDataContainer for all four technologies */ + SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_keyTgc; + SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_keyTgcPriorBC; + SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_keyTgcNextBC; + SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_keyRpc; + SG::ReadHandleKey<Muon::CscPrepDataContainer> m_keyCsc; + SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_keyMdt; + + SG::ReadHandleKey<PRD_MultiTruthCollection> m_tgcTruth{this, "TGCTruth", "TGC_TruthMap", + "TGC PRD Multi-truth Collection"}; + SG::ReadHandleKey<PRD_MultiTruthCollection> m_rpcTruth{this, "RPCTruth", "RPC_TruthMap", + "RPC PRD Multi-truth Collection"}; + + SG::WriteHandleKey<MuonPatternCombinationCollection> m_patternCombiLocation; + SG::WriteHandleKey<Trk::SegmentCollection> m_segmentLocation; + SG::WriteHandleKey<Muon::HoughDataPerSectorVec> m_houghDataPerSectorVecKey{ + this, "Key_MuonLayerHoughToolHoughDataPerSectorVec", "HoughDataPerSectorVec", "HoughDataPerSectorVec key"}; + + ToolHandle<Muon::IMooSegmentCombinationFinder> m_segmentFinder{ + this, + "SegmentFinder", + "Muon::MooSegmentCombinationFinder/MooSegmentCombinationFinder", + }; //<! pointer to the segment finder + ToolHandle<Muon::IMuonClusterSegmentFinder> m_clusterSegMaker{ + this, + "MuonClusterSegmentFinderTool", + "Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder", + }; + ToolHandle<Muon::IMuonSegmentOverlapRemovalTool> m_overlapRemovalTool{ + this, + "SegmentOverlapRemovalTool", + "Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool", + "tool to removal overlaps in segment combinations", + }; }; template <class T, class Y> - void MooSegmentFinderAlg::retrieveCollections( std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key ) { - - SG::ReadHandle<Y> cscPrds (key); - if (cscPrds.isValid()==false) { - ATH_MSG_ERROR("Cannot retrieve Container " << key.key() << " accessing via collections "); - - }else{ - const Y* ptr = cscPrds.cptr(); - cols.reserve(cols.size()+ptr->size()); - for(auto p : *ptr) if(!p->empty()) cols.push_back(p); - ATH_MSG_VERBOSE("Retrieved " << cscPrds.key() << " Container " << cols.size()); - } -} +void +MooSegmentFinderAlg::retrieveCollections(std::vector<const T*>& cols, SG::ReadHandleKey<Y>& key) +{ + SG::ReadHandle<Y> cscPrds(key); + if (cscPrds.isValid() == false) { + ATH_MSG_ERROR("Cannot retrieve Container " << key.key() << " accessing via collections "); + + } else { + const Y* ptr = cscPrds.cptr(); + cols.reserve(cols.size() + ptr->size()); + for (auto p : *ptr) + if (!p->empty()) cols.push_back(p); + ATH_MSG_VERBOSE("Retrieved " << cscPrds.key() << " Container " << cols.size()); + } +} #endif diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx index 88fa757e2b103056a3ccb6776d2e5e57e5297a77..347c29c018069de255bd4fddcdec6bc1255e8e98 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.cxx @@ -1,350 +1,343 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentFinderAlg.h" + #include "CscSegmentMakers/ICscSegmentFinder.h" #include "MuonPattern/MuonPatternChamberIntersect.h" -#include "MuonReadoutGeometry/MuonReadoutElement.h" -#include "MuonPrepRawData/MuonPrepDataContainer.h" -#include "MuonPrepRawData/MuonPrepDataCollection.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" -#include "MuonPattern/MuonPatternCombinationCollection.h" -#include "MuonPrepRawData/MuonPrepDataContainer.h" -#include "MuonPrepRawData/MuonCluster.h" #include "MuonPattern/MuonPatternCombination.h" +#include "MuonPattern/MuonPatternCombinationCollection.h" #include "MuonPatternSegmentMaker/MuonPatternCalibration.h" -#include "TrkParameters/TrackParameters.h" +#include "MuonPrepRawData/MuonCluster.h" +#include "MuonPrepRawData/MuonPrepDataCollection.h" +#include "MuonPrepRawData/MuonPrepDataContainer.h" +#include "MuonRIO_OnTrack/MuonClusterOnTrack.h" +#include "MuonReadoutGeometry/MuonReadoutElement.h" #include "MuonSegment/MuonSegment.h" #include "MuonSegment/MuonSegmentCombination.h" +#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinder.h" - -#include "MuonRIO_OnTrack/MuonClusterOnTrack.h" +#include "TrkParameters/TrackParameters.h" using HepGeom::Transform3D; -MuonSegmentFinderAlg::MuonSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator): - AthAlgorithm(name,pSvcLocator), - m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool"), - m_patternCalibration("Muon::MuonPatternCalibration/MuonPatternCalibration", this), - m_patternSegmentMaker("Muon::MuonPatternSegmentMaker/MuonPatternSegmentMaker", this), - m_segmentMaker("Muon::DCMathSegmentMaker/DCMathSegmentMaker", this), - m_clusterSegMaker("Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder", this), - m_segmentOverlapRemovalTool("Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool", this), - m_clusterCreator("Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator", this), - m_mmClusterCreator("Muon::MMClusterOnTrackCreator/MMClusterOnTrackCreator", this), - m_clusterSegMakerNSW("Muon::MuonClusterSegmentFinderTool/MuonClusterSegmentFinderTool", this), - m_truthSummaryTool("Muon::MuonTruthSummaryTool/MuonTruthSummaryTool", this), - m_csc2dSegmentFinder("Csc2dSegmentMaker/Csc2dSegmentMaker", this), - m_csc4dSegmentFinder("Csc4dSegmentMaker/Csc4dSegmentMaker", this) -{ - //tools - declareProperty("EDMPrinter", m_printer); - declareProperty("MuonPatternCalibration", m_patternCalibration); - declareProperty("MuonPatternSegmentMaker", m_patternSegmentMaker); - declareProperty("SegmentMaker",m_segmentMaker); - declareProperty("ClusterCreator",m_clusterCreator); - declareProperty("MMClusterCreator",m_mmClusterCreator); - declareProperty("MuonClusterSegmentFinderTool",m_clusterSegMakerNSW); - declareProperty("MuonTruthSummaryTool",m_truthSummaryTool); - declareProperty("Csc2dSegmentMaker", m_csc2dSegmentFinder); - declareProperty("Csc4dSegmentMaker", m_csc4dSegmentFinder); - declareProperty("PrintSummary",m_printSummary = false); - declareProperty("MuonClusterSegmentFinder",m_clusterSegMaker); - // - declareProperty("doTGCClust",m_doTGCClust = false); - declareProperty("doRPCClust",m_doRPCClust = false); - declareProperty("doClusterTruth",m_doClusterTruth=false); - -} - -MuonSegmentFinderAlg::~MuonSegmentFinderAlg() +MuonSegmentFinderAlg::MuonSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator) + : AthAlgorithm(name, pSvcLocator) { - + declareProperty("PrintSummary", m_printSummary = false); + // + declareProperty("doTGCClust", m_doTGCClust = false); + declareProperty("doRPCClust", m_doRPCClust = false); + declareProperty("doClusterTruth", m_doClusterTruth = false); } -StatusCode MuonSegmentFinderAlg::initialize() +MuonSegmentFinderAlg::~MuonSegmentFinderAlg() {} + +StatusCode +MuonSegmentFinderAlg::initialize() { - ATH_CHECK( m_idHelperSvc.retrieve() ); - ATH_CHECK( m_printer.retrieve() ); - ATH_CHECK( m_patternCalibration.retrieve() ); - ATH_CHECK( m_patternSegmentMaker.retrieve() ); - ATH_CHECK( m_segmentOverlapRemovalTool.retrieve() ); - ATH_CHECK( m_segmentMaker.retrieve() ); - ATH_CHECK( m_clusterSegMaker.retrieve() ); - - if( !m_truthSummaryTool.empty() ) - ATH_CHECK( m_truthSummaryTool.retrieve() ); - else - m_truthSummaryTool.disable(); - - ATH_CHECK( m_clusterCreator.retrieve() ); - ATH_CHECK( m_clusterSegMakerNSW.retrieve() ); - - if ( !m_csc2dSegmentFinder.empty() ) - ATH_CHECK( m_csc2dSegmentFinder.retrieve() ); - else - m_csc2dSegmentFinder.disable(); - - if ( !m_csc4dSegmentFinder.empty() ) - ATH_CHECK( m_csc4dSegmentFinder.retrieve() ); - else - m_csc4dSegmentFinder.disable(); - - ATH_CHECK( m_segmentCollectionKey.initialize() ); - ATH_CHECK( m_cscPrdsKey.initialize(!m_cscPrdsKey.empty()) ); // check for layouts without CSCs - ATH_CHECK( m_mdtPrdsKey.initialize(m_doTGCClust || m_doRPCClust)); - ATH_CHECK( m_rpcPrdsKey.initialize()); - ATH_CHECK( m_tgcPrdsKey.initialize()); - ATH_CHECK( m_patternCollKey.initialize() ); - ATH_CHECK( m_tgcTruth.initialize(m_doClusterTruth) ); - ATH_CHECK( m_rpcTruth.initialize(m_doClusterTruth) ); - - return StatusCode::SUCCESS; + ATH_CHECK(m_idHelperSvc.retrieve()); + ATH_CHECK(m_printer.retrieve()); + ATH_CHECK(m_patternCalibration.retrieve()); + ATH_CHECK(m_patternSegmentMaker.retrieve()); + ATH_CHECK(m_segmentOverlapRemovalTool.retrieve()); + ATH_CHECK(m_segmentMaker.retrieve()); + ATH_CHECK(m_clusterSegMaker.retrieve()); + + if (!m_truthSummaryTool.empty()) + ATH_CHECK(m_truthSummaryTool.retrieve()); + else + m_truthSummaryTool.disable(); + + ATH_CHECK(m_clusterCreator.retrieve()); + ATH_CHECK(m_mmClusterCreator.retrieve()); + ATH_CHECK(m_clusterSegMakerNSW.retrieve()); + + if (!m_csc2dSegmentFinder.empty()) + ATH_CHECK(m_csc2dSegmentFinder.retrieve()); + else + m_csc2dSegmentFinder.disable(); + + if (!m_csc4dSegmentFinder.empty()) + ATH_CHECK(m_csc4dSegmentFinder.retrieve()); + else + m_csc4dSegmentFinder.disable(); + + ATH_CHECK(m_segmentCollectionKey.initialize()); + ATH_CHECK(m_cscPrdsKey.initialize(!m_cscPrdsKey.empty())); // check for layouts without CSCs + ATH_CHECK(m_mdtPrdsKey.initialize(m_doTGCClust || m_doRPCClust)); + ATH_CHECK(m_rpcPrdsKey.initialize()); + ATH_CHECK(m_tgcPrdsKey.initialize()); + ATH_CHECK(m_patternCollKey.initialize()); + ATH_CHECK(m_tgcTruth.initialize(m_doClusterTruth)); + ATH_CHECK(m_rpcTruth.initialize(m_doClusterTruth)); + + return StatusCode::SUCCESS; } -StatusCode MuonSegmentFinderAlg::execute() +StatusCode +MuonSegmentFinderAlg::execute() { - - // vector to hold segments - SG::WriteHandle<Trk::SegmentCollection> handle(m_segmentCollectionKey); - ATH_CHECK(handle.record(std::make_unique<Trk::SegmentCollection>())); - - SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrds(m_tgcPrdsKey); - const Muon::TgcPrepDataContainer* tgcPrdCont=tgcPrds.cptr(); - SG::ReadHandle<Muon::RpcPrepDataContainer> rpcPrds(m_rpcPrdsKey); - const Muon::RpcPrepDataContainer* rpcPrdCont=rpcPrds.cptr(); - - SG::ReadHandle<MuonPatternCombinationCollection> patternColl(m_patternCollKey); - if(!patternColl.isValid()) { - ATH_MSG_FATAL( "Could not to retrieve the PatternCombinations from StoreGate" ); - return StatusCode::FAILURE; - } - if(patternColl.isPresent()){ //pretty sure this is always the case, but can't hurt to check - ATH_MSG_DEBUG ( "Processing the pattern collections with " << patternColl->size() << " Collections " ); - - for(MuonPatternCombinationCollection::const_iterator patt=patternColl->begin(); patt!=patternColl->end(); ++patt) { - ATH_MSG_DEBUG( "Working on pattern combination " << m_printer->print( **patt ) ); - //check the technology & call the corresponding segment finder - std::vector<const Muon::TgcPrepDataCollection*> tgcCols; - std::vector<const Muon::RpcPrepDataCollection*> rpcCols; - tgcCols.reserve(tgcPrdCont->size()); - for(auto p : *tgcPrdCont){ - if(!p->empty()) tgcCols.push_back(p); - } - rpcCols.reserve(rpcPrdCont->size()); - for(auto p : *rpcPrdCont){ - if(!p->empty()) rpcCols.push_back(p); - } - createSegmentsWithMDTs( *patt, handle.ptr(), rpcCols, tgcCols ); - createSegmentsFromClusters( *patt, handle.ptr() ); - }//end loop on pattern combinations - - } - else{ - ATH_MSG_DEBUG("no pattern collection, moving on ..."); - } - - //do cluster based segment finding - if (m_doTGCClust || m_doRPCClust){ - SG::ReadHandle<Muon::MdtPrepDataContainer> mdtPrds(m_mdtPrdsKey); - const PRD_MultiTruthCollection* tgcTruthColl=0; - const PRD_MultiTruthCollection* rpcTruthColl=0; - if(m_doClusterTruth){ - SG::ReadHandle<PRD_MultiTruthCollection> tgcTruth(m_tgcTruth); - SG::ReadHandle<PRD_MultiTruthCollection> rpcTruth(m_rpcTruth); - tgcTruthColl=tgcTruth.cptr(); - rpcTruthColl=rpcTruth.cptr(); + + // vector to hold segments + SG::WriteHandle<Trk::SegmentCollection> handle(m_segmentCollectionKey); + ATH_CHECK(handle.record(std::make_unique<Trk::SegmentCollection>())); + + SG::ReadHandle<Muon::TgcPrepDataContainer> tgcPrds(m_tgcPrdsKey); + const Muon::TgcPrepDataContainer* tgcPrdCont = tgcPrds.cptr(); + SG::ReadHandle<Muon::RpcPrepDataContainer> rpcPrds(m_rpcPrdsKey); + const Muon::RpcPrepDataContainer* rpcPrdCont = rpcPrds.cptr(); + + SG::ReadHandle<MuonPatternCombinationCollection> patternColl(m_patternCollKey); + if (!patternColl.isValid()) { + ATH_MSG_FATAL("Could not to retrieve the PatternCombinations from StoreGate"); + return StatusCode::FAILURE; + } + if (patternColl.isPresent()) { // pretty sure this is always the case, but can't hurt to check + ATH_MSG_DEBUG("Processing the pattern collections with " << patternColl->size() << " Collections "); + + for (MuonPatternCombinationCollection::const_iterator patt = patternColl->begin(); patt != patternColl->end(); + ++patt) { + ATH_MSG_DEBUG("Working on pattern combination " << m_printer->print(**patt)); + // check the technology & call the corresponding segment finder + std::vector<const Muon::TgcPrepDataCollection*> tgcCols; + std::vector<const Muon::RpcPrepDataCollection*> rpcCols; + tgcCols.reserve(tgcPrdCont->size()); + for (auto p : *tgcPrdCont) { + if (!p->empty()) tgcCols.push_back(p); + } + rpcCols.reserve(rpcPrdCont->size()); + for (auto p : *rpcPrdCont) { + if (!p->empty()) rpcCols.push_back(p); + } + createSegmentsWithMDTs(*patt, handle.ptr(), rpcCols, tgcCols); + createSegmentsFromClusters(*patt, handle.ptr()); + } // end loop on pattern combinations + + } else { + ATH_MSG_DEBUG("no pattern collection, moving on ..."); + } + + // do cluster based segment finding + if (m_doTGCClust || m_doRPCClust) { + SG::ReadHandle<Muon::MdtPrepDataContainer> mdtPrds(m_mdtPrdsKey); + const PRD_MultiTruthCollection* tgcTruthColl = 0; + const PRD_MultiTruthCollection* rpcTruthColl = 0; + if (m_doClusterTruth) { + SG::ReadHandle<PRD_MultiTruthCollection> tgcTruth(m_tgcTruth); + SG::ReadHandle<PRD_MultiTruthCollection> rpcTruth(m_rpcTruth); + tgcTruthColl = tgcTruth.cptr(); + rpcTruthColl = rpcTruth.cptr(); + } + m_clusterSegMaker->getClusterSegments(mdtPrds.cptr(), m_doRPCClust ? rpcPrdCont : 0, + m_doTGCClust ? tgcPrdCont : 0, tgcTruthColl, rpcTruthColl, handle.ptr()); } - m_clusterSegMaker->getClusterSegments(mdtPrds.cptr(),m_doRPCClust ? rpcPrdCont : 0,m_doTGCClust ? tgcPrdCont : 0,tgcTruthColl,rpcTruthColl,handle.ptr()); - } - - ATH_MSG_DEBUG("segments before overlap removal: "<<handle->size()); - m_segmentOverlapRemovalTool->removeDuplicates(handle.ptr()); - - if(!m_truthSummaryTool.empty()){ - for(unsigned int i=0;i<handle.ptr()->size();i++){ - Trk::Segment* tseg=handle.ptr()->at(i); - m_truthSummaryTool->add(*(dynamic_cast<const Muon::MuonSegment*>(tseg)),3); + + ATH_MSG_DEBUG("segments before overlap removal: " << handle->size()); + m_segmentOverlapRemovalTool->removeDuplicates(handle.ptr()); + + if (!m_truthSummaryTool.empty()) { + for (unsigned int i = 0; i < handle.ptr()->size(); i++) { + Trk::Segment* tseg = handle.ptr()->at(i); + m_truthSummaryTool->add(*(dynamic_cast<const Muon::MuonSegment*>(tseg)), 3); + } } - } - - ATH_MSG_DEBUG(" Segments after overlap removal: " << handle->size()); - - if( !m_csc2dSegmentFinder.empty() && !m_csc4dSegmentFinder.empty() ){ - - std::vector<const Muon::CscPrepDataCollection*> cscCols; - - SG::ReadHandle<Muon::CscPrepDataContainer> cscPrds(m_cscPrdsKey); - - if (cscPrds.isValid()) { - - Muon::CscPrepDataContainer::const_iterator it = cscPrds->begin(); - Muon::CscPrepDataContainer::const_iterator it_end = cscPrds->end(); - for( ; it!=it_end; ++it ) { - // skip empty collections - if( (*it)->empty() ) continue; - cscCols.push_back( *it ); - } - ATH_MSG_DEBUG("Retrieved CscPrepDataContainer " << cscCols.size()); - // reconstruct segments in the CSC eta and phi plane - std::unique_ptr<MuonSegmentCombinationCollection> csc2dSegmentCombinations = m_csc2dSegmentFinder->find( cscCols ); - // combine CSC segments in eta and phi plane if any were found - if (csc2dSegmentCombinations) { - std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations = m_csc4dSegmentFinder->find( *csc2dSegmentCombinations ); - if( csc4dSegmentCombinations ){ - - // now copy the segments into the collection, not optimal as unneeded copy - MuonSegmentCombinationCollection::const_iterator cit = csc4dSegmentCombinations->begin(); - MuonSegmentCombinationCollection::const_iterator cit_end = csc4dSegmentCombinations->end(); - for(; cit!=cit_end;++cit ){ - if( !*cit ) { - ATH_MSG_INFO(" empty MuonSegmentCombination!!! "); - continue; - } - const Muon::MuonSegmentCombination& combi = **cit; - unsigned int nstations = combi.numberOfStations(); - - // loop over chambers in combi and extract segments - for(unsigned int i=0; i<nstations; ++i){ - - // loop over segments in station - Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments( i ) ; - - // check if not empty - if( !segments || segments->empty() ) continue; - // loop over new segments, copy them into collection - Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); - Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); - for( ; sit!=sit_end;++sit) handle->push_back( (*sit).release()); //releasing so the handle can take ownership - } - } - } - } + + ATH_MSG_DEBUG(" Segments after overlap removal: " << handle->size()); + + if (!m_csc2dSegmentFinder.empty() && !m_csc4dSegmentFinder.empty()) { + + std::vector<const Muon::CscPrepDataCollection*> cscCols; + + SG::ReadHandle<Muon::CscPrepDataContainer> cscPrds(m_cscPrdsKey); + + if (cscPrds.isValid()) { + + Muon::CscPrepDataContainer::const_iterator it = cscPrds->begin(); + Muon::CscPrepDataContainer::const_iterator it_end = cscPrds->end(); + for (; it != it_end; ++it) { + // skip empty collections + if ((*it)->empty()) continue; + cscCols.push_back(*it); + } + ATH_MSG_DEBUG("Retrieved CscPrepDataContainer " << cscCols.size()); + // reconstruct segments in the CSC eta and phi plane + std::unique_ptr<MuonSegmentCombinationCollection> csc2dSegmentCombinations = + m_csc2dSegmentFinder->find(cscCols); + // combine CSC segments in eta and phi plane if any were found + if (csc2dSegmentCombinations) { + std::unique_ptr<MuonSegmentCombinationCollection> csc4dSegmentCombinations = + m_csc4dSegmentFinder->find(*csc2dSegmentCombinations); + if (csc4dSegmentCombinations) { + + // now copy the segments into the collection, not optimal as unneeded copy + MuonSegmentCombinationCollection::const_iterator cit = csc4dSegmentCombinations->begin(); + MuonSegmentCombinationCollection::const_iterator cit_end = csc4dSegmentCombinations->end(); + for (; cit != cit_end; ++cit) { + if (!*cit) { + ATH_MSG_INFO(" empty MuonSegmentCombination!!! "); + continue; + } + const Muon::MuonSegmentCombination& combi = **cit; + unsigned int nstations = combi.numberOfStations(); + + // loop over chambers in combi and extract segments + for (unsigned int i = 0; i < nstations; ++i) { + + // loop over segments in station + Muon::MuonSegmentCombination::SegmentVec* segments = combi.stationSegments(i); + + // check if not empty + if (!segments || segments->empty()) continue; + // loop over new segments, copy them into collection + Muon::MuonSegmentCombination::SegmentVec::iterator sit = segments->begin(); + Muon::MuonSegmentCombination::SegmentVec::iterator sit_end = segments->end(); + for (; sit != sit_end; ++sit) + handle->push_back((*sit).release()); // releasing so the handle can take ownership + } + } + } + } + } } - } - ATH_MSG_DEBUG("Number of segments found " << handle->size()); - for(unsigned int i=0;i<handle.ptr()->size();i++){ - Trk::Segment* tseg=handle.ptr()->at(i); - ATH_MSG_DEBUG(m_printer->print(*(dynamic_cast<Muon::MuonSegment*>(tseg)))); - } - return StatusCode::SUCCESS; -} // execute + ATH_MSG_DEBUG("Number of segments found " << handle->size()); + for (unsigned int i = 0; i < handle.ptr()->size(); i++) { + Trk::Segment* tseg = handle.ptr()->at(i); + ATH_MSG_DEBUG(m_printer->print(*(dynamic_cast<Muon::MuonSegment*>(tseg)))); + } + return StatusCode::SUCCESS; +} // execute -StatusCode MuonSegmentFinderAlg::finalize() +StatusCode +MuonSegmentFinderAlg::finalize() { - return AthAlgorithm::finalize(); + return AthAlgorithm::finalize(); } -void MuonSegmentFinderAlg::createSegmentsFromClusters(const Muon::MuonPatternCombination* patt, Trk::SegmentCollection* segments ) { - //turn the PRD into MuonCluster - std::map<int,std::vector<const Muon::MuonClusterOnTrack*> > clustersPerSector; - std::vector< Muon::MuonPatternChamberIntersect >::const_iterator it = patt->chamberData().begin(); - for (; it!=patt->chamberData().end(); ++it) { - if((*it).prepRawDataVec().empty()) continue; - const Identifier& id = (*it).prepRawDataVec().front()->identify(); - if( !m_idHelperSvc->isMM(id) && !m_idHelperSvc->issTgc(id) ) continue; - for(std::vector< const Trk::PrepRawData* >::const_iterator pit = (*it).prepRawDataVec().begin(); pit!=(*it).prepRawDataVec().end(); ++pit) { - - const Muon::MuonCluster* cl = dynamic_cast<const Muon::MuonCluster*>(*pit); - if( !cl ) continue; - int sector = m_idHelperSvc->sector(id); - std::vector<const Muon::MuonClusterOnTrack*>& clusters = clustersPerSector[sector]; - - if(m_idHelperSvc->isMM((*pit)->identify())){ - const Muon::MuonClusterOnTrack* clust = m_mmClusterCreator->createRIO_OnTrack( *cl, cl->globalPosition() ); - clusters.push_back(clust); - } else { // must be an sTGC prd - const Muon::MuonClusterOnTrack* clust = m_clusterCreator->createRIO_OnTrack( *cl, cl->globalPosition() ); - clusters.push_back(clust); - } - +void +MuonSegmentFinderAlg::createSegmentsFromClusters(const Muon::MuonPatternCombination* patt, + Trk::SegmentCollection* segments) +{ + // turn the PRD into MuonCluster + std::map<int, std::vector<const Muon::MuonClusterOnTrack*> > clustersPerSector; + std::vector<Muon::MuonPatternChamberIntersect>::const_iterator it = patt->chamberData().begin(); + for (; it != patt->chamberData().end(); ++it) { + if ((*it).prepRawDataVec().empty()) continue; + const Identifier& id = (*it).prepRawDataVec().front()->identify(); + if (!m_idHelperSvc->isMM(id) && !m_idHelperSvc->issTgc(id)) continue; + for (std::vector<const Trk::PrepRawData*>::const_iterator pit = (*it).prepRawDataVec().begin(); + pit != (*it).prepRawDataVec().end(); ++pit) + { + + const Muon::MuonCluster* cl = dynamic_cast<const Muon::MuonCluster*>(*pit); + if (!cl) continue; + int sector = m_idHelperSvc->sector(id); + std::vector<const Muon::MuonClusterOnTrack*>& clusters = clustersPerSector[sector]; + + if (m_idHelperSvc->isMM((*pit)->identify())) { + const Muon::MuonClusterOnTrack* clust = + m_mmClusterCreator->createRIO_OnTrack(*cl, cl->globalPosition()); + clusters.push_back(clust); + } else { // must be an sTGC prd + const Muon::MuonClusterOnTrack* clust = m_clusterCreator->createRIO_OnTrack(*cl, cl->globalPosition()); + clusters.push_back(clust); + } + } } - } - - std::map<int,std::vector<const Muon::MuonClusterOnTrack*> >::iterator sit = clustersPerSector.begin(); - std::map<int,std::vector<const Muon::MuonClusterOnTrack*> >::iterator sit_end = clustersPerSector.end(); - for( ;sit!=sit_end;++sit ){ - std::vector<const Muon::MuonClusterOnTrack*>& clusters = sit->second; - std::vector<Muon::MuonSegment*> segVec; - m_clusterSegMakerNSW->find(clusters,segVec,segments); - - //cleanup the memory - for(std::vector<const Muon::MuonClusterOnTrack*>::iterator cit = clusters.begin(); cit!=clusters.end(); ++cit) { - delete *cit; + + std::map<int, std::vector<const Muon::MuonClusterOnTrack*> >::iterator sit = clustersPerSector.begin(); + std::map<int, std::vector<const Muon::MuonClusterOnTrack*> >::iterator sit_end = clustersPerSector.end(); + for (; sit != sit_end; ++sit) { + std::vector<const Muon::MuonClusterOnTrack*>& clusters = sit->second; + std::vector<Muon::MuonSegment*> segVec; + m_clusterSegMakerNSW->find(clusters, segVec, segments); + + // cleanup the memory + for (std::vector<const Muon::MuonClusterOnTrack*>::iterator cit = clusters.begin(); cit != clusters.end(); + ++cit) { + delete *cit; + } } - } } -void MuonSegmentFinderAlg::createSegmentsWithMDTs(const Muon::MuonPatternCombination* patcomb, Trk::SegmentCollection* segs, - const std::vector<const Muon::RpcPrepDataCollection*> rpcCols, const std::vector<const Muon::TgcPrepDataCollection*> tgcCols) { - - if(m_idHelperSvc->hasMM() && m_idHelperSvc->hasSTgc()) { - - //break the pattern combination into regions and calibrate the PRDs - std::set<int> calibratedRegions; - std::vector< Muon::MuonPatternChamberIntersect >::const_iterator it = patcomb->chamberData().begin(); - for (; it!=patcomb->chamberData().end(); ++it) { - - if((*it).prepRawDataVec().empty()) continue; - Identifier id = (*it).prepRawDataVec().front()->identify(); - if(m_idHelperSvc->isMM(id) || m_idHelperSvc->issTgc(id) ) continue; - - - int regionID = m_patternCalibration->getRegionId(id); - - //check the chamber is not part of a region already calibrated - std::pair<std::set<int>::iterator,bool> val = calibratedRegions.insert(regionID); - if(!val.second) continue; - ATH_MSG_VERBOSE(" Region " << regionID << " adding chamber " << m_idHelperSvc->toStringChamber(id) << " size " << (*it).prepRawDataVec().size() ); - - std::vector<Muon::MuonPatternChamberIntersect> chambers; - chambers.push_back( *it ); - for(std::vector< Muon::MuonPatternChamberIntersect >::const_iterator rit=(it+1); rit!=patcomb->chamberData().end(); ++rit) { - - if((*rit).prepRawDataVec().empty()) continue; - Identifier id2 = (*rit).prepRawDataVec().front()->identify(); - if(m_idHelperSvc->isMM(id2) || m_idHelperSvc->issTgc(id2) ) continue; - - int region = m_patternCalibration->getRegionId(id2); - if(region == regionID) { - ATH_MSG_VERBOSE(" adding additional chamber " << m_idHelperSvc->toStringChamber(id2) << " size " << (*rit).prepRawDataVec().size() ); - chambers.push_back( *rit ); - } - } - - Trk::TrackParameters* trkpars = 0; - if( patcomb->trackParameter() ) trkpars = patcomb->trackParameter()->clone(); - Muon::MuonPatternCombination pattern( trkpars,chambers ); - ATH_MSG_VERBOSE(" created pattern for region: number of chambers " << chambers.size() ); - bool hasPhiMeasurements = m_patternCalibration->checkForPhiMeasurements( pattern ); - //calibrate the hits - Muon::IMuonPatternCalibration::ROTsPerRegion hitsPerRegion; - m_patternCalibration->calibrate( pattern, hitsPerRegion ); - - Muon::IMuonPatternCalibration::ROTsPerRegion::iterator rotit = hitsPerRegion.begin(); - for(; rotit!=hitsPerRegion.end(); ++rotit) { - std::vector<std::vector< const Muon::MdtDriftCircleOnTrack* > >::iterator mdtit = rotit->mdts.begin(); - for( ; mdtit!=rotit->mdts.end(); ++mdtit ){ - if( mdtit->empty() ) continue; - ATH_MSG_VERBOSE("Calling segment finding for sector " << m_idHelperSvc->toString(mdtit->front()->identify()) ); - //fit the segments - m_segmentMaker->find( rotit->regionPos, rotit->regionDir, *mdtit, rotit->clusters, - hasPhiMeasurements, segs, rotit->regionDir.mag() ); - - }//end loop on hits per region - - }//end loop on regions (rotit) - - //memory cleanup - m_patternCalibration->clearRotsPerRegion( hitsPerRegion ); - //store the region ID - calibratedRegions.insert(regionID); - - }//end loop on chambers in the pattern - }else{ - m_patternSegmentMaker->find(*patcomb, rpcCols, tgcCols, segs); - } +void +MuonSegmentFinderAlg::createSegmentsWithMDTs(const Muon::MuonPatternCombination* patcomb, Trk::SegmentCollection* segs, + const std::vector<const Muon::RpcPrepDataCollection*> rpcCols, + const std::vector<const Muon::TgcPrepDataCollection*> tgcCols) +{ + + if (m_idHelperSvc->hasMM() && m_idHelperSvc->hasSTgc()) { + + // break the pattern combination into regions and calibrate the PRDs + std::set<int> calibratedRegions; + std::vector<Muon::MuonPatternChamberIntersect>::const_iterator it = patcomb->chamberData().begin(); + for (; it != patcomb->chamberData().end(); ++it) { + + if ((*it).prepRawDataVec().empty()) continue; + Identifier id = (*it).prepRawDataVec().front()->identify(); + if (m_idHelperSvc->isMM(id) || m_idHelperSvc->issTgc(id)) continue; + + + int regionID = m_patternCalibration->getRegionId(id); + + // check the chamber is not part of a region already calibrated + std::pair<std::set<int>::iterator, bool> val = calibratedRegions.insert(regionID); + if (!val.second) continue; + ATH_MSG_VERBOSE(" Region " << regionID << " adding chamber " << m_idHelperSvc->toStringChamber(id) + << " size " << (*it).prepRawDataVec().size()); + + std::vector<Muon::MuonPatternChamberIntersect> chambers; + chambers.push_back(*it); + for (std::vector<Muon::MuonPatternChamberIntersect>::const_iterator rit = (it + 1); + rit != patcomb->chamberData().end(); ++rit) + { + + if ((*rit).prepRawDataVec().empty()) continue; + Identifier id2 = (*rit).prepRawDataVec().front()->identify(); + if (m_idHelperSvc->isMM(id2) || m_idHelperSvc->issTgc(id2)) continue; + + int region = m_patternCalibration->getRegionId(id2); + if (region == regionID) { + ATH_MSG_VERBOSE(" adding additional chamber " << m_idHelperSvc->toStringChamber(id2) << " size " + << (*rit).prepRawDataVec().size()); + chambers.push_back(*rit); + } + } + + Trk::TrackParameters* trkpars = 0; + if (patcomb->trackParameter()) trkpars = patcomb->trackParameter()->clone(); + Muon::MuonPatternCombination pattern(trkpars, chambers); + ATH_MSG_VERBOSE(" created pattern for region: number of chambers " << chambers.size()); + bool hasPhiMeasurements = m_patternCalibration->checkForPhiMeasurements(pattern); + // calibrate the hits + Muon::IMuonPatternCalibration::ROTsPerRegion hitsPerRegion; + m_patternCalibration->calibrate(pattern, hitsPerRegion); + + Muon::IMuonPatternCalibration::ROTsPerRegion::iterator rotit = hitsPerRegion.begin(); + for (; rotit != hitsPerRegion.end(); ++rotit) { + std::vector<std::vector<const Muon::MdtDriftCircleOnTrack*> >::iterator mdtit = rotit->mdts.begin(); + for (; mdtit != rotit->mdts.end(); ++mdtit) { + if (mdtit->empty()) continue; + ATH_MSG_VERBOSE("Calling segment finding for sector " + << m_idHelperSvc->toString(mdtit->front()->identify())); + // fit the segments + m_segmentMaker->find(rotit->regionPos, rotit->regionDir, *mdtit, rotit->clusters, + hasPhiMeasurements, segs, rotit->regionDir.mag()); + + } // end loop on hits per region + + } // end loop on regions (rotit) + + // memory cleanup + m_patternCalibration->clearRotsPerRegion(hitsPerRegion); + // store the region ID + calibratedRegions.insert(regionID); + + } // end loop on chambers in the pattern + } else { + m_patternSegmentMaker->find(*patcomb, rpcCols, tgcCols, segs); + } } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h index ba9e6ffa3cdb6a4155720aeb8ac640c4c9f08955..45a787505413089762f81205cbfe07d1c4af451f 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MooSegmentCombinationFinder/src/MuonSegmentFinderAlg.h @@ -6,84 +6,173 @@ #define MOOSEGMENTFINDERS_MUOSEGMENTFINDERALGS_H #include "AthenaBaseComps/AthAlgorithm.h" -#include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" - +#include "GaudiKernel/ToolHandle.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" +#include "MuonPattern/MuonPatternChamberIntersect.h" #include "MuonPrepRawData/CscPrepDataCollection.h" #include "MuonPrepRawData/MdtPrepDataCollection.h" #include "MuonPrepRawData/RpcPrepDataCollection.h" #include "MuonPrepRawData/TgcPrepDataCollection.h" -#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonRecHelperTools/MuonEDMPrinterTool.h" -#include "MuonSegment/MuonSegmentCombinationCollection.h" -#include "TrkSegment/SegmentCollection.h" -#include "MuonPattern/MuonPatternChamberIntersect.h" -#include "TrkTruthData/PRD_MultiTruthCollection.h" -#include "MuonSegmentMakerToolInterfaces/IMuonPatternCalibration.h" -#include "MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h" -#include "MuonRecToolInterfaces/IMuonSegmentMaker.h" #include "MuonRecToolInterfaces/IMuonClusterOnTrackCreator.h" +#include "MuonRecToolInterfaces/IMuonSegmentMaker.h" #include "MuonRecToolInterfaces/IMuonTruthSummaryTool.h" +#include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonSegmentMakerToolInterfaces/IMuonClusterSegmentFinderTool.h" +#include "MuonSegmentMakerToolInterfaces/IMuonPatternCalibration.h" +#include "MuonSegmentMakerToolInterfaces/IMuonPatternSegmentMaker.h" #include "MuonSegmentMakerToolInterfaces/IMuonSegmentOverlapRemovalTool.h" -#include "MuonPrepRawData/RpcPrepDataCollection.h" -#include "MuonPrepRawData/TgcPrepDataCollection.h" +#include "TrkSegment/SegmentCollection.h" +#include "TrkTruthData/PRD_MultiTruthCollection.h" namespace Muon { - class IMuonClusterSegmentFinder; +class IMuonClusterSegmentFinder; } class MsgStream; class ICscSegmentFinder; -class MuonSegmentFinderAlg : public AthAlgorithm -{ - public: - MuonSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator); - - virtual ~MuonSegmentFinderAlg(); - - virtual StatusCode initialize() override; - virtual StatusCode execute() override; - virtual StatusCode finalize() override; - - - private: - - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - ToolHandle<Muon::MuonEDMPrinterTool> m_printer; //<! helper printer tool - ToolHandle<Muon::IMuonPatternCalibration> m_patternCalibration; - ToolHandle<Muon::IMuonPatternSegmentMaker> m_patternSegmentMaker; - ToolHandle<Muon::IMuonSegmentMaker> m_segmentMaker; - ToolHandle<Muon::IMuonClusterSegmentFinder> m_clusterSegMaker; - ToolHandle<Muon::IMuonSegmentOverlapRemovalTool> m_segmentOverlapRemovalTool; - ToolHandle<Muon::IMuonClusterOnTrackCreator> m_clusterCreator; //<! pointer to muon cluster rio ontrack creator - ToolHandle<Muon::IMuonClusterOnTrackCreator> m_mmClusterCreator; //<! pointer to mm cluster rio ontrack creator - ToolHandle<Muon::IMuonClusterSegmentFinderTool> m_clusterSegMakerNSW; - ToolHandle<Muon::IMuonTruthSummaryTool> m_truthSummaryTool; - ToolHandle<ICscSegmentFinder> m_csc2dSegmentFinder; - ToolHandle<ICscSegmentFinder> m_csc4dSegmentFinder; - - - SG::WriteHandleKey<Trk::SegmentCollection> m_segmentCollectionKey{this,"SegmentCollectionName","MuonSegments","Muon Segments"}; - SG::ReadHandleKey<Muon::CscPrepDataContainer> m_cscPrdsKey{this,"CSC_clusterkey","CSC_Clusters","CSC PRDs"}; - SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_mdtPrdsKey{this,"MDT_PRDs","MDT_DriftCircles","MDT PRDs"}; - SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_rpcPrdsKey{this,"RPC_PRDs","RPC_Measurements","RPC PRDs"}; - SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrdsKey{this,"TGC_PRDs","TGC_Measurements","TGC PRDs"}; - SG::ReadHandleKey<MuonPatternCombinationCollection> m_patternCollKey{this,"MuonLayerHoughCombisKey","MuonLayerHoughCombis","Hough combinations"}; - SG::ReadHandleKey<PRD_MultiTruthCollection> m_tgcTruth{this,"TGCTruth","TGC_TruthMap","TGC PRD Multi-truth Collection"}; - SG::ReadHandleKey<PRD_MultiTruthCollection> m_rpcTruth{this,"RPCTruth","RPC_TruthMap","RPC PRD Multi-truth Collection"}; - - void createSegmentsWithMDTs(const Muon::MuonPatternCombination* patt,Trk::SegmentCollection* segs, - const std::vector<const Muon::RpcPrepDataCollection*> rpcCols, const std::vector<const Muon::TgcPrepDataCollection*> tgcCols); - void createSegmentsFromClusters(const Muon::MuonPatternCombination* patt,Trk::SegmentCollection* segments); - - bool m_printSummary; - - /** selection flags for cluster based segment finding */ - bool m_doTGCClust; - bool m_doRPCClust; - bool m_doClusterTruth; +class MuonSegmentFinderAlg : public AthAlgorithm { + public: + MuonSegmentFinderAlg(const std::string& name, ISvcLocator* pSvcLocator); + + virtual ~MuonSegmentFinderAlg(); + + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; + + + private: + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{ + this, + "MuonIdHelperSvc", + "Muon::MuonIdHelperSvc/MuonIdHelperSvc", + }; + + ToolHandle<Muon::MuonEDMPrinterTool> m_printer{ + this, + "EDMPrinter", + "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool", + }; //<! helper printer tool + ToolHandle<Muon::IMuonPatternCalibration> m_patternCalibration{ + this, + "MuonPatternCalibration", + "Muon::MuonPatternCalibration/MuonPatternCalibration", + }; + ToolHandle<Muon::IMuonPatternSegmentMaker> m_patternSegmentMaker{ + this, + "MuonPatternSegmentMaker", + "Muon::MuonPatternSegmentMaker/MuonPatternSegmentMaker", + }; + ToolHandle<Muon::IMuonSegmentMaker> m_segmentMaker{ + this, + "SegmentMaker", + "Muon::DCMathSegmentMaker/DCMathSegmentMaker", + }; + ToolHandle<Muon::IMuonClusterSegmentFinder> m_clusterSegMaker{ + this, + "MuonClusterSegmentFinder", + "Muon::MuonClusterSegmentFinder/MuonClusterSegmentFinder", + }; + ToolHandle<Muon::IMuonSegmentOverlapRemovalTool> m_segmentOverlapRemovalTool{ + this, + "MuonSegmentOverlapRemovalTool", + "Muon::MuonSegmentOverlapRemovalTool/MuonSegmentOverlapRemovalTool", + }; + ToolHandle<Muon::IMuonClusterOnTrackCreator> m_clusterCreator{ + this, + "ClusterCreator", + "Muon::MuonClusterOnTrackCreator/MuonClusterOnTrackCreator", + }; //<! pointer to muon cluster rio ontrack creator + ToolHandle<Muon::IMuonClusterOnTrackCreator> m_mmClusterCreator{ + this, + "MMClusterCreator", + "Muon::MMClusterOnTrackCreator/MMClusterOnTrackCreator", + }; //<! pointer to mm cluster rio ontrack creator + ToolHandle<Muon::IMuonClusterSegmentFinderTool> m_clusterSegMakerNSW{ + this, + "MuonClusterSegmentFinderTool", + "Muon::MuonClusterSegmentFinderTool/MuonClusterSegmentFinderTool", + }; + ToolHandle<Muon::IMuonTruthSummaryTool> m_truthSummaryTool{ + this, + "MuonTruthSummaryTool", + "Muon::MuonTruthSummaryTool/MuonTruthSummaryTool", + }; + ToolHandle<ICscSegmentFinder> m_csc2dSegmentFinder{ + this, + "Csc2dSegmentMaker", + "Csc2dSegmentMaker/Csc2dSegmentMaker", + }; + ToolHandle<ICscSegmentFinder> m_csc4dSegmentFinder{ + this, + "Csc4dSegmentMaker", + "Csc4dSegmentMaker/Csc4dSegmentMaker", + }; + + + SG::WriteHandleKey<Trk::SegmentCollection> m_segmentCollectionKey{ + this, + "SegmentCollectionName", + "MuonSegments", + "Muon Segments", + }; + SG::ReadHandleKey<Muon::CscPrepDataContainer> m_cscPrdsKey{ + this, + "CSC_clusterkey", + "CSC_Clusters", + "CSC PRDs", + }; + SG::ReadHandleKey<Muon::MdtPrepDataContainer> m_mdtPrdsKey{ + this, + "MDT_PRDs", + "MDT_DriftCircles", + "MDT PRDs", + }; + SG::ReadHandleKey<Muon::RpcPrepDataContainer> m_rpcPrdsKey{ + this, + "RPC_PRDs", + "RPC_Measurements", + "RPC PRDs", + }; + SG::ReadHandleKey<Muon::TgcPrepDataContainer> m_tgcPrdsKey{ + this, + "TGC_PRDs", + "TGC_Measurements", + "TGC PRDs", + }; + SG::ReadHandleKey<MuonPatternCombinationCollection> m_patternCollKey{ + this, + "MuonLayerHoughCombisKey", + "MuonLayerHoughCombis", + "Hough combinations", + }; + SG::ReadHandleKey<PRD_MultiTruthCollection> m_tgcTruth{ + this, + "TGCTruth", + "TGC_TruthMap", + "TGC PRD Multi-truth Collection", + }; + SG::ReadHandleKey<PRD_MultiTruthCollection> m_rpcTruth{ + this, + "RPCTruth", + "RPC_TruthMap", + "RPC PRD Multi-truth Collection", + }; + + void createSegmentsWithMDTs(const Muon::MuonPatternCombination* patt, Trk::SegmentCollection* segs, + const std::vector<const Muon::RpcPrepDataCollection*> rpcCols, + const std::vector<const Muon::TgcPrepDataCollection*> tgcCols); + void createSegmentsFromClusters(const Muon::MuonPatternCombination* patt, Trk::SegmentCollection* segments); + + bool m_printSummary; + + /** selection flags for cluster based segment finding */ + bool m_doTGCClust; + bool m_doRPCClust; + bool m_doClusterTruth; }; #endif diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h index e8bde81c391811e5c94bad303574da0926c570ef..b4f8083de24cd55532f7dc49055bbdf3bc9be72b 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h @@ -5,75 +5,83 @@ #ifndef MUONMUONCURVEDSEGMENTCOMBINER_H #define MUONMUONCURVEDSEGMENTCOMBINER_H -#include "MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h" -#include "MuonSegmentMakerToolInterfaces/IMuonSegmentPairFittingTool.h" +#include <map> +#include <set> +#include <string> + #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" - -#include "MuonIdHelpers/IMuonIdHelperSvc.h" -#include "MuonEDM_AssociationObjects/MuonSegPatAssMap.h" #include "MuonCurvedSegmentCombiner/MCSCSegmentInfo.h" +#include "MuonEDM_AssociationObjects/MuonSegPatAssMap.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonRecHelperTools/MuonEDMPrinterTool.h" +#include "MuonSegmentCombinerToolInterfaces/IMuonCurvedSegmentCombiner.h" +#include "MuonSegmentMakerToolInterfaces/IMuonSegmentPairFittingTool.h" -#include <string> -#include <map> -#include <set> +namespace Muon { +/** @class MuonCurvedSegmentCombiner + +This is for the Doxygen-Documentation. +Please delete these lines and fill in information about +the Algorithm! +Please precede every member function declaration with a +short Doxygen comment stating the purpose of this function. -namespace Muon -{ - /** @class MuonCurvedSegmentCombiner - - This is for the Doxygen-Documentation. - Please delete these lines and fill in information about - the Algorithm! - Please precede every member function declaration with a - short Doxygen comment stating the purpose of this function. - - @author Edward Moyse <Edward.Moyse@cern.ch> - */ - - class MuonCurvedSegmentCombiner : virtual public IMuonCurvedSegmentCombiner, virtual public IMuonSegmentPairFittingTool, public AthAlgTool - { +@author Edward Moyse <Edward.Moyse@cern.ch> +*/ + +class MuonCurvedSegmentCombiner : virtual public IMuonCurvedSegmentCombiner, + virtual public IMuonSegmentPairFittingTool, + public AthAlgTool { public: - MuonCurvedSegmentCombiner(const std::string&,const std::string&,const IInterface*); + MuonCurvedSegmentCombiner(const std::string&, const std::string&, const IInterface*); + + virtual ~MuonCurvedSegmentCombiner() = default; - virtual ~MuonCurvedSegmentCombiner()=default; - virtual StatusCode initialize(); - + /** INSERT main method here.*/ - std::unique_ptr<MuonSegmentCombinationCollection> combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, - const MuonSegmentCombinationCollection& csc4DCombiColl, - const MuonSegmentCombinationCollection& csc2DCombiColl, - MuonSegmentCombPatternCombAssociationMap* segPattMap); + std::unique_ptr<MuonSegmentCombinationCollection> combineSegments( + const MuonSegmentCombinationCollection& mdtCombiColl, const MuonSegmentCombinationCollection& csc4DCombiColl, + const MuonSegmentCombinationCollection& csc2DCombiColl, MuonSegmentCombPatternCombAssociationMap* segPattMap); - void trackParameters( Muon::MuonSegment& seg ,double &theta,double &curvature,int &imeth ); + void trackParameters(Muon::MuonSegment& seg, double& theta, double& curvature, int& imeth); // void fulltrackParameters( const Muon::MuonSegment& seg ,HepMatrix & T , HepMatrix & CovT ,int &imeth ); - void extrapolateSegment( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); + void extrapolateSegment(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull); - void fit2Segments( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); - void fit2SegmentsC( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); - void fit2SegmentsSL( Muon::MuonSegment& seg , Muon::MuonSegment& sege, Amg::VectorX & Res, Amg::VectorX & Pull ); + void fit2Segments(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull); + void fit2SegmentsC(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull); + void fit2SegmentsSL(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, Amg::VectorX& Pull); private: - - std::unique_ptr<MuonSegmentCombinationCollection> processCombinationCollection(const MuonSegmentCombinationCollection& mdtCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap); - void processCscCombinationCollection( const MuonSegmentCombinationCollection& cscCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap) ; - void process2DCscCombinationCollection( const MuonSegmentCombinationCollection& csc2DcombiCol); + std::unique_ptr<MuonSegmentCombinationCollection> processCombinationCollection( + const MuonSegmentCombinationCollection& mdtCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap); + void processCscCombinationCollection(const MuonSegmentCombinationCollection& cscCombiCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap); + void process2DCscCombinationCollection(const MuonSegmentCombinationCollection& csc2DcombiCol); - void muonCurvedSegmentCombinations(MuonSegmentCombinationCollection* curvedCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap); + void muonCurvedSegmentCombinations(MuonSegmentCombinationCollection* curvedCombiCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap); - Muon::MCSCSegmentInfo segInfo( Muon::MuonSegment* seg ); + Muon::MCSCSegmentInfo segInfo(Muon::MuonSegment* seg); - unsigned int missedHits( Muon::MuonSegment* segment ); + unsigned int missedHits(Muon::MuonSegment* segment); private: - ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; - - ToolHandle< MuonEDMPrinterTool> m_printer; - - bool m_debug; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{ + this, + "MuonIdHelperSvc", + "Muon::MuonIdHelperSvc/MuonIdHelperSvc", + }; + + ToolHandle<MuonEDMPrinterTool> m_printer{ + this, + "Printer", + "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool", + }; + + bool m_debug; bool m_doCosmics; bool m_summary; bool m_useCscSegments; @@ -82,22 +90,22 @@ namespace Muon int m_missedHitsCut; double m_pullAssociationCut; - double m_phiAssociationCut1; - double m_phiAssociationCut2; - bool m_addUnassociatedMiddleEndcapSegments; + double m_phiAssociationCut1; + double m_phiAssociationCut2; + bool m_addUnassociatedMiddleEndcapSegments; - typedef std::map<Muon::MuonSegment*,Muon::MCSCSegmentInfo> SegInfoMap; - typedef SegInfoMap::iterator SegInfoIt; - int m_segmentIndex; - SegInfoMap m_segInfoMap; + typedef std::map<Muon::MuonSegment*, Muon::MCSCSegmentInfo> SegInfoMap; + typedef SegInfoMap::iterator SegInfoIt; + int m_segmentIndex; + SegInfoMap m_segInfoMap; SegInfoMap m_seg2DCscInfoMap; SegInfoMap m_seg4DCscInfoMap; SegInfoMap m_segMdtInfoMap; - std::map<Muon::MuonSegment*, const MuonPatternCombination* > m_segAssoMap; - std::set <Identifier> m_cscIdSet; - }; -} // end of namespace + std::map<Muon::MuonSegment*, const MuonPatternCombination*> m_segAssoMap; + std::set<Identifier> m_cscIdSet; +}; +} // namespace Muon -#endif +#endif diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx index 72fd9fa6ee63eaa8d4932b167fc55b7b8d33be84..2f1052f3b85386332d9bf276932c89591d5d4d62 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentCombiners/MuonSegmentCombinerTools/MuonCurvedSegmentCombiner/src/MuonCurvedSegmentCombiner.cxx @@ -4,472 +4,534 @@ #include "MuonCurvedSegmentCombiner/MuonCurvedSegmentCombiner.h" +#include <iostream> +#include <sstream> +#include <vector> + +#include "MuonPattern/MuonPatternCombination.h" +#include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" +#include "MuonReadoutGeometry/MuonDetectorManager.h" #include "MuonSegment/MuonSegment.h" #include "MuonSegment/MuonSegmentCombination.h" #include "MuonSegment/MuonSegmentCombinationCollection.h" #include "MuonSegment/MuonSegmentQuality.h" -#include "MuonPattern/MuonPatternCombination.h" -#include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" -#include "MuonReadoutGeometry/MuonDetectorManager.h" -#include "TrkRIO_OnTrack/RIO_OnTrack.h" #include "TrkCompetingRIOsOnTrack/CompetingRIOsOnTrack.h" +#include "TrkEventPrimitives/FitQuality.h" #include "TrkParameters/TrackParameters.h" #include "TrkPrepRawData/PrepRawData.h" -#include "TrkEventPrimitives/FitQuality.h" - -#include <iostream> -#include <sstream> -#include <vector> +#include "TrkRIO_OnTrack/RIO_OnTrack.h" //================ Constructor ================================================= -Muon::MuonCurvedSegmentCombiner::MuonCurvedSegmentCombiner(const std::string& t, const std::string& n, const IInterface* p) : - AthAlgTool(t,n,p), - m_printer("Muon::MuonEDMPrinterTool/MuonEDMPrinterTool") +Muon::MuonCurvedSegmentCombiner::MuonCurvedSegmentCombiner(const std::string& t, const std::string& n, + const IInterface* p) + : AthAlgTool(t, n, p) { declareInterface<IMuonCurvedSegmentCombiner>(this); declareInterface<IMuonSegmentPairFittingTool>(this); - declareProperty("DoDebug",m_debug = false); + declareProperty("DoDebug", m_debug = false); - declareProperty("DoSummary",m_summary = false); + declareProperty("DoSummary", m_summary = false); - declareProperty("DoCosmics",m_doCosmics = false); + declareProperty("DoCosmics", m_doCosmics = false); - // ATLAS default use Csc segments - // Cosmics default no do NOT use Csc segments - declareProperty( "UseCscSegments",m_useCscSegments = true ); + // ATLAS default use Csc segments + // Cosmics default no do NOT use Csc segments + declareProperty("UseCscSegments", m_useCscSegments = true); - declareProperty( "AddAll2DCscs",m_addAll2DCscs = true); + declareProperty("AddAll2DCscs", m_addAll2DCscs = true); - declareProperty("MergePatterns",m_mergePatterns = false); + declareProperty("MergePatterns", m_mergePatterns = false); - declareProperty("MissedHitsCut",m_missedHitsCut = 100); + declareProperty("MissedHitsCut", m_missedHitsCut = 100); - declareProperty("PullAssociationCut",m_pullAssociationCut = 5.); + declareProperty("PullAssociationCut", m_pullAssociationCut = 5.); - declareProperty("PhiAssociationCut1",m_phiAssociationCut1 = 0.5); + declareProperty("PhiAssociationCut1", m_phiAssociationCut1 = 0.5); - declareProperty("PhiAssociationCut2",m_phiAssociationCut2 = 0.25); - - declareProperty("AddUnassociatedMiddleEndcapSegments",m_addUnassociatedMiddleEndcapSegments = false) ; + declareProperty("PhiAssociationCut2", m_phiAssociationCut2 = 0.25); + declareProperty("AddUnassociatedMiddleEndcapSegments", m_addUnassociatedMiddleEndcapSegments = false); } //================ Initialisation ================================================= -StatusCode Muon::MuonCurvedSegmentCombiner::initialize() +StatusCode +Muon::MuonCurvedSegmentCombiner::initialize() { ATH_CHECK(m_idHelperSvc.retrieve()); ATH_CHECK(m_printer.retrieve()); - ATH_MSG_DEBUG("initialize() successful in " << name() ); + ATH_MSG_DEBUG("initialize() successful in " << name()); return StatusCode::SUCCESS; } //============================================================================================ std::unique_ptr<MuonSegmentCombinationCollection> -Muon::MuonCurvedSegmentCombiner::combineSegments( const MuonSegmentCombinationCollection& mdtCombiColl, - const MuonSegmentCombinationCollection& csc4DCombiColl, - const MuonSegmentCombinationCollection& csc2DCombiColl, - MuonSegmentCombPatternCombAssociationMap* segPattMap) +Muon::MuonCurvedSegmentCombiner::combineSegments(const MuonSegmentCombinationCollection& mdtCombiColl, + const MuonSegmentCombinationCollection& csc4DCombiColl, + const MuonSegmentCombinationCollection& csc2DCombiColl, + MuonSegmentCombPatternCombAssociationMap* segPattMap) { m_segInfoMap.clear(); m_seg2DCscInfoMap.clear(); m_seg4DCscInfoMap.clear(); m_segMdtInfoMap.clear(); m_cscIdSet.clear(); - m_segAssoMap.clear(); + m_segAssoMap.clear(); m_segmentIndex = 0; - - if( msgLvl(MSG::DEBUG) || m_summary) { - if( mdtCombiColl.empty() ) ATH_MSG_INFO(" summarizing input: Mdt MuonSegment combinations empty" ); - else ATH_MSG_INFO(" summarizing input: Mdt MuonSegment combinations " << std::endl << m_printer->print( mdtCombiColl ) ); - } + if (msgLvl(MSG::DEBUG) || m_summary) { + if (mdtCombiColl.empty()) + ATH_MSG_INFO(" summarizing input: Mdt MuonSegment combinations empty"); + else + ATH_MSG_INFO(" summarizing input: Mdt MuonSegment combinations " << std::endl + << m_printer->print(mdtCombiColl)); + } - // Csc segments - if( m_useCscSegments ){ + // Csc segments + if (m_useCscSegments) { - ATH_MSG_DEBUG(" Retrieved CSC 4D MuonSegmentCombinationCollection " << csc4DCombiColl.size() ); + ATH_MSG_DEBUG(" Retrieved CSC 4D MuonSegmentCombinationCollection " << csc4DCombiColl.size()); - if( msgLvl(MSG::DEBUG) || m_summary) { - if( csc4DCombiColl.empty() ) ATH_MSG_INFO(" summarizing input: Csc MuonSegment combinations empty" ); - else ATH_MSG_INFO(" summarizing input: Csc MuonSegment combinations " << std::endl << m_printer->print( csc4DCombiColl ) ); + if (msgLvl(MSG::DEBUG) || m_summary) { + if (csc4DCombiColl.empty()) + ATH_MSG_INFO(" summarizing input: Csc MuonSegment combinations empty"); + else + ATH_MSG_INFO(" summarizing input: Csc MuonSegment combinations " << std::endl + << m_printer->print(csc4DCombiColl)); } - processCscCombinationCollection(csc4DCombiColl,segPattMap); + processCscCombinationCollection(csc4DCombiColl, segPattMap); // Csc 2D segments - if( msgLvl(MSG::DEBUG) || m_summary) { - if( csc2DCombiColl.empty() ) ATH_MSG_INFO(" summarizing input: Csc 2D MuonSegment combinations empty" ); - else ATH_MSG_INFO(" summarizing input: Csc 2D MuonSegment combinations " << std::endl << m_printer->print( csc2DCombiColl ) ); + if (msgLvl(MSG::DEBUG) || m_summary) { + if (csc2DCombiColl.empty()) + ATH_MSG_INFO(" summarizing input: Csc 2D MuonSegment combinations empty"); + else + ATH_MSG_INFO(" summarizing input: Csc 2D MuonSegment combinations " + << std::endl + << m_printer->print(csc2DCombiColl)); } process2DCscCombinationCollection(csc2DCombiColl); } - return processCombinationCollection(mdtCombiColl,segPattMap); - + return processCombinationCollection(mdtCombiColl, segPattMap); } -std::unique_ptr<MuonSegmentCombinationCollection> Muon::MuonCurvedSegmentCombiner::processCombinationCollection(const MuonSegmentCombinationCollection& mdtCol, - MuonSegmentCombPatternCombAssociationMap* segPattMap){ +std::unique_ptr<MuonSegmentCombinationCollection> +Muon::MuonCurvedSegmentCombiner::processCombinationCollection(const MuonSegmentCombinationCollection& mdtCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap) +{ - std::unique_ptr<MuonSegmentCombinationCollection> curvedCombiCol(new MuonSegmentCombinationCollection); + std::unique_ptr<MuonSegmentCombinationCollection> curvedCombiCol(new MuonSegmentCombinationCollection); int nmdtsegments = 0; - int ncscsegments = m_seg2DCscInfoMap.size() + m_seg4DCscInfoMap.size(); + int ncscsegments = m_seg2DCscInfoMap.size() + m_seg4DCscInfoMap.size(); + + if (m_debug) std::cout << " in processCombinationCollection " << std::endl; - if( m_debug ) std::cout << " in processCombinationCollection " << std::endl; - - MuonSegmentCombinationCollection::const_iterator cit = mdtCol.begin(); + MuonSegmentCombinationCollection::const_iterator cit = mdtCol.begin(); MuonSegmentCombinationCollection::const_iterator cit_end = mdtCol.end(); - for(; cit!=cit_end;++cit ){ + for (; cit != cit_end; ++cit) { const Muon::MuonSegmentCombination* combi = *cit; - if( !combi ) { - ATH_MSG_DEBUG(" empty Mdt MuonSegmentCombination!!! " ); + if (!combi) { + ATH_MSG_DEBUG(" empty Mdt MuonSegmentCombination!!! "); continue; } - // get association to pattern + // get association to pattern - std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, MuonSegmentCombPatternCombAssociationMap::const_iterator> range = segPattMap->equal_range(combi); - if ((range.first)==(range.second)) { + std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, + MuonSegmentCombPatternCombAssociationMap::const_iterator> + range = segPattMap->equal_range(combi); + if ((range.first) == (range.second)) { ATH_MSG_WARNING("MDT Combination missing from the map - something is wrong! Skip combination"); continue; } - + const MuonPatternCombination* pattern = (range.first)->second; - if( m_debug ) std::cout << " handling combi " << combi << " associated pattern " << pattern << std::endl; + if (m_debug) std::cout << " handling combi " << combi << " associated pattern " << pattern << std::endl; -// Muon::MuonSegPatAssMap::object_list combiAssos; + // Muon::MuonSegPatAssMap::object_list combiAssos; // if (assMap) { // assMap->getObjects( combi, combiAssos ); - if( segPattMap->count(combi) != 1 ){ + if (segPattMap->count(combi) != 1) { ATH_MSG_INFO(" This MuonSegPatAssMap for MDTs should only have one entry!! "); } -// Take 2D Csc segments - m_segInfoMap = m_seg2DCscInfoMap; - SegInfoIt seg_it = m_seg4DCscInfoMap.begin(); + // Take 2D Csc segments + m_segInfoMap = m_seg2DCscInfoMap; + SegInfoIt seg_it = m_seg4DCscInfoMap.begin(); SegInfoIt seg_it_end = m_seg4DCscInfoMap.end(); - for(; seg_it != seg_it_end; ++seg_it){ - Muon::MuonSegment* segm = seg_it->first; - if( m_seg4DCscInfoMap[segm].contains(pattern)) { -// Add 4D Csc segment associated to this pattern - Muon::MCSCSegmentInfo info = seg_it->second; - info.patPoint = pattern; - m_segInfoMap[segm] = info; - } + for (; seg_it != seg_it_end; ++seg_it) { + Muon::MuonSegment* segm = seg_it->first; + if (m_seg4DCscInfoMap[segm].contains(pattern)) { + // Add 4D Csc segment associated to this pattern + Muon::MCSCSegmentInfo info = seg_it->second; + info.patPoint = pattern; + m_segInfoMap[segm] = info; + } } bool addedMdtSegments = false; - for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); - if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; - for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; - bool is_mdt=true; - for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ - if (m_idHelperSvc->isMdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; - if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) == true) {is_mdt = false; break;} - } - if (is_mdt == false) continue; - std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); - nmdtsegments++; - if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si].get()] = pattern; - }else{ - if( it->second != pattern ) ATH_MSG_INFO(" MDT Segment pointers should only be found once!! "); - it->second=pattern; - } - Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); - // Add Mdt segment associated to this pattern - m_segmentIndex++; - info.index = m_segmentIndex; - m_segInfoMap[segs[si].get()] = info; - m_segMdtInfoMap[segs[si].get()] = info; - addedMdtSegments = true; - } - } - - if ( addedMdtSegments ) muonCurvedSegmentCombinations(curvedCombiCol.get(),segPattMap); + for (unsigned int i = 0; i < combi->numberOfStations(); ++i) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); + if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; + for (unsigned int si = 0; si < segs.size(); ++si) { + if (m_debug) + std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " + << segs[si]->numberOfContainedROTs() << std::endl; + bool is_mdt = true; + for (unsigned int ri = 0; ri < segs[si]->numberOfContainedROTs(); ri++) { + if (m_idHelperSvc->isMdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; + if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) == true) { + is_mdt = false; + break; + } + } + if (is_mdt == false) continue; + std::map<Muon::MuonSegment*, const MuonPatternCombination*>::iterator it = + m_segAssoMap.find(segs[si].get()); + nmdtsegments++; + if (it == m_segAssoMap.end()) { + m_segAssoMap[segs[si].get()] = pattern; + } else { + if (it->second != pattern) ATH_MSG_INFO(" MDT Segment pointers should only be found once!! "); + it->second = pattern; + } + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); + // Add Mdt segment associated to this pattern + m_segmentIndex++; + info.index = m_segmentIndex; + m_segInfoMap[segs[si].get()] = info; + m_segMdtInfoMap[segs[si].get()] = info; + addedMdtSegments = true; + } + } + + if (addedMdtSegments) muonCurvedSegmentCombinations(curvedCombiCol.get(), segPattMap); } - if (m_debug) std::cout << " First stage muonCurvedSegmentCombinations " << curvedCombiCol->size() << " Mdt segments " << nmdtsegments << " Csc segments " << ncscsegments << std::endl; - + if (m_debug) + std::cout << " First stage muonCurvedSegmentCombinations " << curvedCombiCol->size() << " Mdt segments " + << nmdtsegments << " Csc segments " << ncscsegments << std::endl; + bool mergePatterns = false; if (m_mergePatterns) mergePatterns = true; if (m_doCosmics) mergePatterns = true; - if (m_doCosmics && (curvedCombiCol->size() > 4 || nmdtsegments + ncscsegments > 20)) mergePatterns = false; + if (m_doCosmics && (curvedCombiCol->size() > 4 || nmdtsegments + ncscsegments > 20)) mergePatterns = false; if (mergePatterns) { - if( m_debug ) std::cout << " merging patterns " << std::endl; - -// Clear segment association map - m_segAssoMap.clear(); - cit = mdtCol.begin(); - for(; cit!=cit_end;++cit ){ - const Muon::MuonSegmentCombination* combi = *cit; - if( !combi ) continue; - if (combi->numberOfStations() == 0) continue; - // get association to pattern - std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, MuonSegmentCombPatternCombAssociationMap::const_iterator> range = segPattMap->equal_range(combi); - if ((range.first)==(range.second)) { - continue; - } - const MuonPatternCombination* pattern = (range.first)->second; - if( segPattMap->count(combi) != 1 ){ - ATH_MSG_INFO(" This MuonSegPatAssMap for MDTs should only have one entry!! "); - } + if (m_debug) std::cout << " merging patterns " << std::endl; + + // Clear segment association map + m_segAssoMap.clear(); + cit = mdtCol.begin(); + for (; cit != cit_end; ++cit) { + const Muon::MuonSegmentCombination* combi = *cit; + if (!combi) continue; + if (combi->numberOfStations() == 0) continue; + // get association to pattern + std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, + MuonSegmentCombPatternCombAssociationMap::const_iterator> + range = segPattMap->equal_range(combi); + if ((range.first) == (range.second)) { + continue; + } + const MuonPatternCombination* pattern = (range.first)->second; + if (segPattMap->count(combi) != 1) { + ATH_MSG_INFO(" This MuonSegPatAssMap for MDTs should only have one entry!! "); + } -// Leave out 2D Csc segments -// m_segInfoMap = m_seg2DCscInfoMap; - m_segInfoMap.clear(); - - MuonSegmentCombinationCollection::const_iterator cit1 = cit; - for(; cit1!=cit_end;++cit1 ){ - - const Muon::MuonSegmentCombination* combi1 = *cit1; - if( !combi1 ) continue; - if (combi1->numberOfStations() == 0) continue; - - if (combi1 == combi) continue; - // get association to pattern - std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, MuonSegmentCombPatternCombAssociationMap::const_iterator> range1 = segPattMap->equal_range(combi1); - if ((range1.first)==(range1.second)) { - continue; - } - const MuonPatternCombination* pattern1 = (range1.first)->second; - if( segPattMap->count(combi1) != 1 ){ - ATH_MSG_INFO(" This MuonSegPatAssMap for MDTs should only have one entry!! "); - } - - if( m_debug ) std::cout << " handling combi " << combi << " associated pattern " << pattern1 << std::endl; - - double patternPhi, patternPhi1 ; - double patternTheta, patternTheta1; - double patternMom = 0., patternMom1 = 0.; - Amg::Vector3D patternDir; - Amg::Vector3D patternDir1; - - const Trk::TrackParameters* trkparameters = pattern->trackParameter(); - if (trkparameters) { - const Trk::Perigee* perigee = 0; - perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); - if (perigee) { -// Get theta and phi values - patternPhi = perigee->momentum().phi(); - patternTheta = perigee->momentum().theta(); - patternMom = perigee->momentum().mag(); - patternDir = perigee->momentum(); - } else {continue;} - } else {continue;} - - - trkparameters = pattern1->trackParameter(); - if (trkparameters) { - const Trk::Perigee* perigee = 0; - perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); - if (perigee) { -// Get theta and phi values - patternPhi1 = perigee->momentum().phi(); - patternTheta1 = perigee->momentum().theta(); - patternMom1 = perigee->momentum().mag(); - patternDir1 = perigee->momentum(); - } else {continue;} - } else {continue;} - -// Cuts on angular association of the two patterns - - // if(acos (cos(patternPhi)*cos(patternPhi1) + sin(patternPhi)*sin(patternPhi1)) > 0.3) continue; - // that is the same as: (acos(x)>0.3 <--> x < cos (0.3)= 0.955) - if ((cos(patternPhi)*cos(patternPhi1) + sin(patternPhi)*sin(patternPhi1)) < 0.955) continue; - - - // for (cosmics) patterns that are split and have flipped direction: - if(fabs(patternTheta-patternTheta1) > 1.5) continue; - -// Cosmics can be rotated in theta - - // if(acos (cos(patternTheta)*cos(patternTheta1) + sin(patternTheta)*sin(patternTheta1)) > 0.3 && m_mergePatterns && !m_doCosmics) continue; - // same as: - - if((cos(patternTheta)*cos(patternTheta1) + sin(patternTheta)*sin(patternTheta1)) < 0.955 && m_mergePatterns && !m_doCosmics) continue; - - // only merge patterns in same hemisphere (only for cosmics) - - if (m_doCosmics) { - - // check if any 2 stations in combis are compatible, else combi's completely in other hemisphere: - // could probably be implemented faster (loop over all stations of 1 combi first) - bool compatible = false; - - for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); - if (!segs.empty()) { - const Amg::Vector3D& segpos = segs[0]->globalPosition(); - double dotprod = segpos.x()*patternDir.x() + segpos.y()*patternDir.y() + segpos.z()*patternDir.z(); - - for(unsigned int j=0;j<combi1->numberOfStations();++j){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs1 = *combi1->stationSegments(j); - if (!segs1.empty()) { - const Amg::Vector3D& segpos1 = segs1[0]->globalPosition(); - double dotprod1 = segpos1.x()*patternDir1.x() + segpos1.y()*patternDir1.y() + segpos1.z()*patternDir1.z(); - - // if patterns are in opposite hemisphere (assuming directions are more or less same) - if ((dotprod < 0 && dotprod1 < 0) || (dotprod > 0 && dotprod1 > 0)) { - compatible = true; - } - } - if (compatible == true) break; - } - } - if (compatible == true) break; - } - if (compatible == false) continue; - } - - const MuonPatternCombination* patternSelect = pattern; - if (!m_doCosmics && fabs(patternMom1)> fabs(patternMom)) patternSelect = pattern1; - if ( m_doCosmics && pattern1->chamberData().size() > pattern->chamberData().size() ) patternSelect = pattern1; - - -// Take 2D Csc segments - m_segInfoMap = m_seg2DCscInfoMap; - SegInfoIt seg_it = m_seg4DCscInfoMap.begin(); - SegInfoIt seg_it_end = m_seg4DCscInfoMap.end(); - for(; seg_it != seg_it_end; ++seg_it){ - Muon::MuonSegment* segm = seg_it->first; - if( m_seg4DCscInfoMap[segm].contains(pattern) || m_seg4DCscInfoMap[segm].contains(pattern1)) { -// Add 4D Csc segment associated to this pattern - Muon::MCSCSegmentInfo info = seg_it->second; - info.patPoint = patternSelect; - m_segInfoMap[segm] = info; - } - } - bool addedMdtSegments = false; - for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); - if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; - for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; - bool is_mdt=true; - for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ - if (m_idHelperSvc->isMdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; - if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) == true) {is_mdt = false; break;} - } - if (is_mdt == false)continue; - - std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); - if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si].get()] = patternSelect; - }else{ - it->second=patternSelect; - } - Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); - // Add Mdt segment associated to this pattern - m_segInfoMap[segs[si].get()] = info; - m_segMdtInfoMap[segs[si].get()] = info; - addedMdtSegments = true; - } - } - - for(unsigned int i=0;i<combi1->numberOfStations();++i){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi1->stationSegments(i); - if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; - for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " << segs[si]->numberOfContainedROTs() << std::endl; - bool is_mdt=true; - for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ - if (m_idHelperSvc->isMdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; - if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) == true) {is_mdt = false; break;} - } - if (is_mdt == false)continue; - std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); - if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si].get()] = patternSelect; - }else{ - it->second=patternSelect; - } - Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); - // Add Mdt segment associated to this pattern - m_segInfoMap[segs[si].get()] = info; - m_segMdtInfoMap[segs[si].get()] = info; - addedMdtSegments = true; - } - } - - if ( addedMdtSegments ) muonCurvedSegmentCombinations(curvedCombiCol.get(),segPattMap); - } - } - if (m_debug) std::cout << " Second stage muonCurvedSegmentCombinations " << curvedCombiCol->size() << std::endl; - } // end mergePatterns + // Leave out 2D Csc segments + // m_segInfoMap = m_seg2DCscInfoMap; + m_segInfoMap.clear(); + + MuonSegmentCombinationCollection::const_iterator cit1 = cit; + for (; cit1 != cit_end; ++cit1) { + + const Muon::MuonSegmentCombination* combi1 = *cit1; + if (!combi1) continue; + if (combi1->numberOfStations() == 0) continue; + + if (combi1 == combi) continue; + // get association to pattern + std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, + MuonSegmentCombPatternCombAssociationMap::const_iterator> + range1 = segPattMap->equal_range(combi1); + if ((range1.first) == (range1.second)) { + continue; + } + const MuonPatternCombination* pattern1 = (range1.first)->second; + if (segPattMap->count(combi1) != 1) { + ATH_MSG_INFO(" This MuonSegPatAssMap for MDTs should only have one entry!! "); + } + + if (m_debug) + std::cout << " handling combi " << combi << " associated pattern " << pattern1 << std::endl; + + double patternPhi, patternPhi1; + double patternTheta, patternTheta1; + double patternMom = 0., patternMom1 = 0.; + Amg::Vector3D patternDir; + Amg::Vector3D patternDir1; + + const Trk::TrackParameters* trkparameters = pattern->trackParameter(); + if (trkparameters) { + const Trk::Perigee* perigee = 0; + perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); + if (perigee) { + // Get theta and phi values + patternPhi = perigee->momentum().phi(); + patternTheta = perigee->momentum().theta(); + patternMom = perigee->momentum().mag(); + patternDir = perigee->momentum(); + } else { + continue; + } + } else { + continue; + } + + + trkparameters = pattern1->trackParameter(); + if (trkparameters) { + const Trk::Perigee* perigee = 0; + perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); + if (perigee) { + // Get theta and phi values + patternPhi1 = perigee->momentum().phi(); + patternTheta1 = perigee->momentum().theta(); + patternMom1 = perigee->momentum().mag(); + patternDir1 = perigee->momentum(); + } else { + continue; + } + } else { + continue; + } + + // Cuts on angular association of the two patterns + + // if(acos (cos(patternPhi)*cos(patternPhi1) + sin(patternPhi)*sin(patternPhi1)) > 0.3) continue; + // that is the same as: (acos(x)>0.3 <--> x < cos (0.3)= 0.955) + if ((cos(patternPhi) * cos(patternPhi1) + sin(patternPhi) * sin(patternPhi1)) < 0.955) continue; + + + // for (cosmics) patterns that are split and have flipped direction: + if (fabs(patternTheta - patternTheta1) > 1.5) continue; + + // Cosmics can be rotated in theta + + // if(acos (cos(patternTheta)*cos(patternTheta1) + sin(patternTheta)*sin(patternTheta1)) > 0.3 && + // m_mergePatterns && !m_doCosmics) continue; same as: + + if ((cos(patternTheta) * cos(patternTheta1) + sin(patternTheta) * sin(patternTheta1)) < 0.955 + && m_mergePatterns && !m_doCosmics) + continue; + + // only merge patterns in same hemisphere (only for cosmics) + + if (m_doCosmics) { + + // check if any 2 stations in combis are compatible, else combi's completely in other hemisphere: + // could probably be implemented faster (loop over all stations of 1 combi first) + bool compatible = false; + + for (unsigned int i = 0; i < combi->numberOfStations(); ++i) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); + if (!segs.empty()) { + const Amg::Vector3D& segpos = segs[0]->globalPosition(); + double dotprod = + segpos.x() * patternDir.x() + segpos.y() * patternDir.y() + segpos.z() * patternDir.z(); + + for (unsigned int j = 0; j < combi1->numberOfStations(); ++j) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs1 = + *combi1->stationSegments(j); + if (!segs1.empty()) { + const Amg::Vector3D& segpos1 = segs1[0]->globalPosition(); + double dotprod1 = segpos1.x() * patternDir1.x() + segpos1.y() * patternDir1.y() + + segpos1.z() * patternDir1.z(); + + // if patterns are in opposite hemisphere (assuming directions are more or less + // same) + if ((dotprod < 0 && dotprod1 < 0) || (dotprod > 0 && dotprod1 > 0)) { + compatible = true; + } + } + if (compatible == true) break; + } + } + if (compatible == true) break; + } + if (compatible == false) continue; + } + + const MuonPatternCombination* patternSelect = pattern; + if (!m_doCosmics && fabs(patternMom1) > fabs(patternMom)) patternSelect = pattern1; + if (m_doCosmics && pattern1->chamberData().size() > pattern->chamberData().size()) + patternSelect = pattern1; + + + // Take 2D Csc segments + m_segInfoMap = m_seg2DCscInfoMap; + SegInfoIt seg_it = m_seg4DCscInfoMap.begin(); + SegInfoIt seg_it_end = m_seg4DCscInfoMap.end(); + for (; seg_it != seg_it_end; ++seg_it) { + Muon::MuonSegment* segm = seg_it->first; + if (m_seg4DCscInfoMap[segm].contains(pattern) || m_seg4DCscInfoMap[segm].contains(pattern1)) { + // Add 4D Csc segment associated to this pattern + Muon::MCSCSegmentInfo info = seg_it->second; + info.patPoint = patternSelect; + m_segInfoMap[segm] = info; + } + } + bool addedMdtSegments = false; + for (unsigned int i = 0; i < combi->numberOfStations(); ++i) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); + if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; + for (unsigned int si = 0; si < segs.size(); ++si) { + if (m_debug) + std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " + << segs[si]->numberOfContainedROTs() << std::endl; + bool is_mdt = true; + for (unsigned int ri = 0; ri < segs[si]->numberOfContainedROTs(); ri++) { + if (m_idHelperSvc->isMdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; + if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) == true) { + is_mdt = false; + break; + } + } + if (is_mdt == false) continue; + + std::map<Muon::MuonSegment*, const MuonPatternCombination*>::iterator it = + m_segAssoMap.find(segs[si].get()); + if (it == m_segAssoMap.end()) { + m_segAssoMap[segs[si].get()] = patternSelect; + } else { + it->second = patternSelect; + } + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); + // Add Mdt segment associated to this pattern + m_segInfoMap[segs[si].get()] = info; + m_segMdtInfoMap[segs[si].get()] = info; + addedMdtSegments = true; + } + } + + for (unsigned int i = 0; i < combi1->numberOfStations(); ++i) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi1->stationSegments(i); + if (m_debug) std::cout << " station " << i << " has MDT segments: " << segs.size() << std::endl; + for (unsigned int si = 0; si < segs.size(); ++si) { + if (m_debug) + std::cout << " Store Mdt segment " << si << " pointer " << segs[si].get() << " Rios " + << segs[si]->numberOfContainedROTs() << std::endl; + bool is_mdt = true; + for (unsigned int ri = 0; ri < segs[si]->numberOfContainedROTs(); ri++) { + if (m_idHelperSvc->isMdt(segs[si]->rioOnTrack(ri)->identify()) == true) break; + if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) == true) { + is_mdt = false; + break; + } + } + if (is_mdt == false) continue; + std::map<Muon::MuonSegment*, const MuonPatternCombination*>::iterator it = + m_segAssoMap.find(segs[si].get()); + if (it == m_segAssoMap.end()) { + m_segAssoMap[segs[si].get()] = patternSelect; + } else { + it->second = patternSelect; + } + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); + // Add Mdt segment associated to this pattern + m_segInfoMap[segs[si].get()] = info; + m_segMdtInfoMap[segs[si].get()] = info; + addedMdtSegments = true; + } + } - if( msgLvl(MSG::DEBUG) || m_summary) { - if( curvedCombiCol->empty() ) ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations empty"); - else ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations " << std::endl << m_printer->print( *curvedCombiCol ) ); + if (addedMdtSegments) muonCurvedSegmentCombinations(curvedCombiCol.get(), segPattMap); + } + } + if (m_debug) std::cout << " Second stage muonCurvedSegmentCombinations " << curvedCombiCol->size() << std::endl; + } // end mergePatterns + + if (msgLvl(MSG::DEBUG) || m_summary) { + if (curvedCombiCol->empty()) + ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations empty"); + else + ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations " << std::endl + << m_printer->print(*curvedCombiCol)); } return curvedCombiCol; } void -Muon::MuonCurvedSegmentCombiner::processCscCombinationCollection( const MuonSegmentCombinationCollection& combiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap) { - MuonSegmentCombinationCollection::const_iterator cit = combiCol.begin(); +Muon::MuonCurvedSegmentCombiner::processCscCombinationCollection(const MuonSegmentCombinationCollection& combiCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap) +{ + MuonSegmentCombinationCollection::const_iterator cit = combiCol.begin(); MuonSegmentCombinationCollection::const_iterator cit_end = combiCol.end(); - for(; cit!=cit_end;++cit ){ + for (; cit != cit_end; ++cit) { const Muon::MuonSegmentCombination* combi = *cit; - if( !combi ) { + if (!combi) { ATH_MSG_DEBUG(" empty Csc 4D MuonSegmentCombination!!! "); continue; } - if(combi->numberOfStations() > 0 ){ - // get association to pattern - // Muon::MuonSegPatAssMap::object_list combiAssos; + if (combi->numberOfStations() > 0) { + // get association to pattern + // Muon::MuonSegPatAssMap::object_list combiAssos; // if (m_assCscMap) { // m_assCscMap->getObjects( combi, combiAssos ); // } - std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, MuonSegmentCombPatternCombAssociationMap::const_iterator> range = segPattMap->equal_range(combi); - if ((range.first)==(range.second)) { + std::pair<MuonSegmentCombPatternCombAssociationMap::const_iterator, + MuonSegmentCombPatternCombAssociationMap::const_iterator> + range = segPattMap->equal_range(combi); + if ((range.first) == (range.second)) { ATH_MSG_DEBUG("CSC Combination missing from the map - can happen"); return; } - + const MuonPatternCombination* pattern = (*(range.first)).second; - for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); - if(m_debug) std::cout << " station " << i << " has Csc segments: " << segs.size() << std::endl; - for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Csc segment " << si << std::endl; + for (unsigned int i = 0; i < combi->numberOfStations(); ++i) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); + if (m_debug) std::cout << " station " << i << " has Csc segments: " << segs.size() << std::endl; + for (unsigned int si = 0; si < segs.size(); ++si) { + if (m_debug) std::cout << " Store Csc segment " << si << std::endl; bool is_csc = false; - for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ - if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify())) { + for (unsigned int ri = 0; ri < segs[si]->numberOfContainedROTs(); ri++) { + if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify())) { is_csc = true; m_cscIdSet.insert(segs[si]->rioOnTrack(ri)->identify()); if (m_debug) std::cout << " csc hits on 4d segment " << m_cscIdSet.size() << std::endl; } } - if (is_csc == false) continue; - std::map<Muon::MuonSegment*, const MuonPatternCombination* >::iterator it = m_segAssoMap.find(segs[si].get()); - if( it == m_segAssoMap.end() ){ - m_segAssoMap[segs[si].get()] = pattern; - }else{ - it->second=pattern; - } -// 4D Csc segments can be on more than 1 pattern + if (is_csc == false) continue; + std::map<Muon::MuonSegment*, const MuonPatternCombination*>::iterator it = + m_segAssoMap.find(segs[si].get()); + if (it == m_segAssoMap.end()) { + m_segAssoMap[segs[si].get()] = pattern; + } else { + it->second = pattern; + } + // 4D Csc segments can be on more than 1 pattern Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); m_segmentIndex++; - info.index = m_segmentIndex; - MuonSegmentCombPatternCombAssociationMap::const_iterator ia_it = range.first; + info.index = m_segmentIndex; + MuonSegmentCombPatternCombAssociationMap::const_iterator ia_it = range.first; MuonSegmentCombPatternCombAssociationMap::const_iterator ia_it_end = range.second; - for(; ia_it != ia_it_end; ++ia_it){ - info.patPointers.push_back((*ia_it).second); + for (; ia_it != ia_it_end; ++ia_it) { + info.patPointers.push_back((*ia_it).second); } m_seg4DCscInfoMap[segs[si].get()] = info; - if(m_debug) std::cout << " Store Csc segment " << " associated pattern size " << info.patPointers.size() << std::endl; + if (m_debug) + std::cout << " Store Csc segment " + << " associated pattern size " << info.patPointers.size() << std::endl; } } } @@ -477,2023 +539,2178 @@ Muon::MuonCurvedSegmentCombiner::processCscCombinationCollection( const MuonSegm } void -Muon::MuonCurvedSegmentCombiner::process2DCscCombinationCollection( const MuonSegmentCombinationCollection& combiCol) { - MuonSegmentCombinationCollection::const_iterator cit = combiCol.begin(); +Muon::MuonCurvedSegmentCombiner::process2DCscCombinationCollection(const MuonSegmentCombinationCollection& combiCol) +{ + MuonSegmentCombinationCollection::const_iterator cit = combiCol.begin(); MuonSegmentCombinationCollection::const_iterator cit_end = combiCol.end(); - for(; cit!=cit_end;++cit ){ + for (; cit != cit_end; ++cit) { const Muon::MuonSegmentCombination* combi = *cit; - if( !combi ) { + if (!combi) { ATH_MSG_DEBUG(" empty Csc 2D MuonSegmentCombination!!! "); continue; } - for(unsigned int i=0;i<combi->numberOfStations();++i){ - const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); - if(m_debug) std::cout << " station " << i << " has Csc segments: " << segs.size() << std::endl; - for(unsigned int si=0;si<segs.size();++si){ - if(m_debug) std::cout << " Store Csc segment? " << si << std::endl; - bool is_csc = false; - int ncsc = 0; - int ncscmatched = 0; - for (unsigned int ri=0;ri<segs[si]->numberOfContainedROTs(); ri++){ - if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) && ! m_idHelperSvc->cscIdHelper().measuresPhi(segs[si]->rioOnTrack(ri)->identify()) ) { - is_csc = true; - ncsc++; - if (m_cscIdSet.find(segs[si]->rioOnTrack(ri)->identify())!=m_cscIdSet.end()) ncscmatched++; - } - } - if (is_csc == false) continue; - if(m_debug) std::cout << " Csc eta hits " << ncsc << " Matched with 4D " << ncscmatched << std::endl; - if (ncsc == ncscmatched && !m_addAll2DCscs) continue; - - // 2D Csc segments are NOT associated to Pattern - - m_segAssoMap[segs[si].get()] = 0; - Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); - m_segmentIndex++; - info.index = m_segmentIndex; - m_seg2DCscInfoMap[segs[si].get()] = info; - //if(m_debug) std::cout << " Store Csc eta segment " << " associated pattern size " << combiAssos.size() << std::endl; - } - } + for (unsigned int i = 0; i < combi->numberOfStations(); ++i) { + const std::vector<std::unique_ptr<Muon::MuonSegment> >& segs = *combi->stationSegments(i); + if (m_debug) std::cout << " station " << i << " has Csc segments: " << segs.size() << std::endl; + for (unsigned int si = 0; si < segs.size(); ++si) { + if (m_debug) std::cout << " Store Csc segment? " << si << std::endl; + bool is_csc = false; + int ncsc = 0; + int ncscmatched = 0; + for (unsigned int ri = 0; ri < segs[si]->numberOfContainedROTs(); ri++) { + if (m_idHelperSvc->isCsc(segs[si]->rioOnTrack(ri)->identify()) + && !m_idHelperSvc->cscIdHelper().measuresPhi(segs[si]->rioOnTrack(ri)->identify())) + { + is_csc = true; + ncsc++; + if (m_cscIdSet.find(segs[si]->rioOnTrack(ri)->identify()) != m_cscIdSet.end()) ncscmatched++; + } + } + if (is_csc == false) continue; + if (m_debug) std::cout << " Csc eta hits " << ncsc << " Matched with 4D " << ncscmatched << std::endl; + if (ncsc == ncscmatched && !m_addAll2DCscs) continue; + + // 2D Csc segments are NOT associated to Pattern + + m_segAssoMap[segs[si].get()] = 0; + Muon::MCSCSegmentInfo info = segInfo(segs[si].get()); + m_segmentIndex++; + info.index = m_segmentIndex; + m_seg2DCscInfoMap[segs[si].get()] = info; + // if(m_debug) std::cout << " Store Csc eta segment " << " associated pattern size " << + // combiAssos.size() << std::endl; + } + } } } -void Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentCombinationCollection* curvedCombiCol, MuonSegmentCombPatternCombAssociationMap* segPattMap) { +void +Muon::MuonCurvedSegmentCombiner::muonCurvedSegmentCombinations(MuonSegmentCombinationCollection* curvedCombiCol, + MuonSegmentCombPatternCombAssociationMap* segPattMap) +{ - // Strategy for makening trackcandidates: combinations of segments - // Fill vectors with segment information MCSCSegmentInfo: - // e.g. station, missed hits, and crude momentum estimate - // Make ordering of segments according to multiplicity (per chamber), missed hits and momentum orderSegments - // For high multiplicities: take only first 10 segments per chamber + // Strategy for makening trackcandidates: combinations of segments + // Fill vectors with segment information MCSCSegmentInfo: + // e.g. station, missed hits, and crude momentum estimate + // Make ordering of segments according to multiplicity (per chamber), missed hits and momentum orderSegments + // For high multiplicities: take only first 10 segments per chamber - // Search for combinations is done pair wise - // Short and Long chambers in same type (e.g. BOS and BOL )-> use Straightline fit to two segments - // Different chambers (B vs E/F or I vs M vs O vs E) -> use Curved Fit to two segments + // Search for combinations is done pair wise + // Short and Long chambers in same type (e.g. BOS and BOL )-> use Straightline fit to two segments + // Different chambers (B vs E/F or I vs M vs O vs E) -> use Curved Fit to two segments - // Association cuts: a) Same pattern (pointer) - // b) Cosmics: dotprod phi1 phi2 > 0 - // c) Add 2D segment CSC (not associated to pattern); extrapolate pattern < 500 mm - // d) Add no phi hits - phi hits within m_phiAssociationCut1 (0.25) - // both have phi hits and same phi angle on pattern - // If all residuals in Pull space are within m_pullAssociatioCut (5) + // Association cuts: a) Same pattern (pointer) + // b) Cosmics: dotprod phi1 phi2 > 0 + // c) Add 2D segment CSC (not associated to pattern); extrapolate pattern < 500 mm + // d) Add no phi hits - phi hits within m_phiAssociationCut1 (0.25) + // both have phi hits and same phi angle on pattern + // If all residuals in Pull space are within m_pullAssociatioCut (5) - // The pair is added to the list of combination - // if one of the segments is already associated the other segment is added this combination + // The pair is added to the list of combination + // if one of the segments is already associated the other segment is added this combination - // Multiplicities of segments per unique Chamber code and per Pattern - // Count segments: MDT -> one per pattern - // CSC -> 0 or more patterns - std::map<int , int> segmentsChamber; + // Multiplicities of segments per unique Chamber code and per Pattern + // Count segments: MDT -> one per pattern + // CSC -> 0 or more patterns + std::map<int, int> segmentsChamber; - SegInfoIt seg_it = m_segInfoMap.begin(); + SegInfoIt seg_it = m_segInfoMap.begin(); SegInfoIt seg_it_end = m_segInfoMap.end(); - int nSegments = 0; - for(; seg_it != seg_it_end; ++seg_it){ - Muon::MuonSegment* segm = seg_it->first; - int npSize = 0; - if (m_segAssoMap.count(segm)>0) { + int nSegments = 0; + for (; seg_it != seg_it_end; ++seg_it) { + Muon::MuonSegment* segm = seg_it->first; + int npSize = 0; + if (m_segAssoMap.count(segm) > 0) { npSize = npSize + m_segAssoMap.count(segm); } else { npSize = 1; } - nSegments += npSize; + nSegments += npSize; } - // Vectors for storing segment information - std::vector<Muon::MuonSegment*> segment(nSegments); - std::vector<std::string> station(nSegments); // station string - std::vector<int> iPhiPatHits(nSegments); // phi hits on pattern - std::vector<double> patPhi(nSegments); // phi value of pattern - std::vector<double> patTheta(nSegments); // theta value of pattern - std::vector<int> multi(nSegments); // multiplicity in chamber - std::vector<int> missedHits(nSegments); // missed hits in MDT - std::vector<int> missedLay(nSegments); // missed layers hit in trigger Chambers - std::vector<int> nHots(nSegments); // hit on track for MDT or CSC segments - std::vector<double> momentum(nSegments); // momentum estimate - std::vector<int> drop(nSegments); // drop segment = 1 ; keep it 0 - std::vector<const Muon::MuonPatternCombination*> patPoint(nSegments); // phi measurement on segment - -// -// Order the segments according to stationcode, missed (trigger) hits, and chi2 -// - std::map<double , Muon::MuonSegment*> checkSegments; - std::map<int , Muon::MuonSegment*> checkSegmentsIndex; -// -// assign an integer to each pattern needed to count segments per pattern per chamber -// - std::map <const Muon::MuonPatternCombination*, int > patIndex; - - seg_it = m_segInfoMap.begin(); - seg_it_end = m_segInfoMap.end(); - int patIn = -1; + // Vectors for storing segment information + std::vector<Muon::MuonSegment*> segment(nSegments); + std::vector<std::string> station(nSegments); // station string + std::vector<int> iPhiPatHits(nSegments); // phi hits on pattern + std::vector<double> patPhi(nSegments); // phi value of pattern + std::vector<double> patTheta(nSegments); // theta value of pattern + std::vector<int> multi(nSegments); // multiplicity in chamber + std::vector<int> missedHits(nSegments); // missed hits in MDT + std::vector<int> missedLay(nSegments); // missed layers hit in trigger Chambers + std::vector<int> nHots(nSegments); // hit on track for MDT or CSC segments + std::vector<double> momentum(nSegments); // momentum estimate + std::vector<int> drop(nSegments); // drop segment = 1 ; keep it 0 + std::vector<const Muon::MuonPatternCombination*> patPoint(nSegments); // phi measurement on segment + + // + // Order the segments according to stationcode, missed (trigger) hits, and chi2 + // + std::map<double, Muon::MuonSegment*> checkSegments; + std::map<int, Muon::MuonSegment*> checkSegmentsIndex; + // + // assign an integer to each pattern needed to count segments per pattern per chamber + // + std::map<const Muon::MuonPatternCombination*, int> patIndex; + + seg_it = m_segInfoMap.begin(); + seg_it_end = m_segInfoMap.end(); + int patIn = -1; int patInlast = -1; - for(; seg_it != seg_it_end; ++seg_it){ - Muon::MuonSegment* segm = seg_it->first; - const Muon::MCSCSegmentInfo& info = m_segInfoMap[segm]; - if (info.patPoint!=0) { - if (patIndex.count(info.patPoint)!=1) { - patInlast++; - patIndex[info.patPoint] = patInlast; - patIn = patInlast; - } else { - patIn = patIndex[info.patPoint]; - } - } else { - patIn = 0; - } -// -// Built key to distinguish segments -// - int code = info.stationCode; - int missedh = info.nMissedHits; - if ( missedh < 0 ) missedh = 0; - if ( missedh > 10 ) missedh = 10; - double layMissed = info.layMissed; - int ntrigFrac = (int) layMissed*10; - double theta = segm->globalDirection().theta(); - double lchi2 = info.chi2/info.nHots; - int patternHits = info.patHits; - std::string st = info.station; - if (st[0] == 'C') patternHits = 0; - int ntot = info.nHots; - if ( ntot < 5 ) ntot = 5; - - int miscorrect = 0; - if(info.phiPatHits == 0) miscorrect = 2; - if(info.nLayTrig > 0) miscorrect = 2; - if(info.nLayTrig > 2) miscorrect = 3; - - int missedHitsCut = m_missedHitsCut; - if( info.station[1] == 'I' ) ++missedHitsCut; - - if( 5*(missedh-miscorrect) > ntot*missedHitsCut) { - if (m_debug) std::cout << " Drop this segment with missed hits " << missedh << " correction " << miscorrect << " phi pat hits " << info.phiPatHits << " trigger layers " << info.nLayTrig << std::endl; + for (; seg_it != seg_it_end; ++seg_it) { + Muon::MuonSegment* segm = seg_it->first; + const Muon::MCSCSegmentInfo& info = m_segInfoMap[segm]; + if (info.patPoint != 0) { + if (patIndex.count(info.patPoint) != 1) { + patInlast++; + patIndex[info.patPoint] = patInlast; + patIn = patInlast; + } else { + patIn = patIndex[info.patPoint]; + } + } else { + patIn = 0; + } + // + // Built key to distinguish segments + // + int code = info.stationCode; + int missedh = info.nMissedHits; + if (missedh < 0) missedh = 0; + if (missedh > 10) missedh = 10; + double layMissed = info.layMissed; + int ntrigFrac = (int)layMissed * 10; + double theta = segm->globalDirection().theta(); + double lchi2 = info.chi2 / info.nHots; + int patternHits = info.patHits; + std::string st = info.station; + if (st[0] == 'C') patternHits = 0; + int ntot = info.nHots; + if (ntot < 5) ntot = 5; + + int miscorrect = 0; + if (info.phiPatHits == 0) miscorrect = 2; + if (info.nLayTrig > 0) miscorrect = 2; + if (info.nLayTrig > 2) miscorrect = 3; + + int missedHitsCut = m_missedHitsCut; + if (info.station[1] == 'I') ++missedHitsCut; + + if (5 * (missedh - miscorrect) > ntot * missedHitsCut) { + if (m_debug) + std::cout << " Drop this segment with missed hits " << missedh << " correction " << miscorrect + << " phi pat hits " << info.phiPatHits << " trigger layers " << info.nLayTrig << std::endl; continue; - } - int indexSegment = info.index; - double key = 10000*(code+1)+missedh*100+ntrigFrac*10 +10*lchi2 - (indexSegment/10000.) - patternHits - 100*info.nHots ; - if(checkSegmentsIndex.count(indexSegment)==1) { - if (m_debug) std::cout << " PROBLEM with Segments Index is already in the checkSegmentsIndex collection " << indexSegment << std::endl; - } - checkSegmentsIndex[indexSegment] = segm; - if (checkSegments.count(key)==1) { - const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[checkSegments[key]]; - double theta2 = checkSegments[key]->globalDirection().theta(); - std::string st = info.station; - if (m_debug) std::cout << " PROBLEM this key is already in the checkSegments collection " << key << " station " << st << " pointer1 " << info.patPoint << " pointer2 " << info2.patPoint << " theta " << theta << " theta2 " << theta2 << std::endl; - } - checkSegments[key] = segm; - if (info.patPoint!=0) { - segmentsChamber[1000*code+patIn] += 1; - } else { - segmentsChamber[1000*code] += 1; - } + } + int indexSegment = info.index; + double key = 10000 * (code + 1) + missedh * 100 + ntrigFrac * 10 + 10 * lchi2 - (indexSegment / 10000.) + - patternHits - 100 * info.nHots; + if (checkSegmentsIndex.count(indexSegment) == 1) { + if (m_debug) + std::cout << " PROBLEM with Segments Index is already in the checkSegmentsIndex collection " + << indexSegment << std::endl; + } + checkSegmentsIndex[indexSegment] = segm; + if (checkSegments.count(key) == 1) { + const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[checkSegments[key]]; + double theta2 = checkSegments[key]->globalDirection().theta(); + std::string st = info.station; + if (m_debug) + std::cout << " PROBLEM this key is already in the checkSegments collection " << key << " station " << st + << " pointer1 " << info.patPoint << " pointer2 " << info2.patPoint << " theta " << theta + << " theta2 " << theta2 << std::endl; + } + checkSegments[key] = segm; + if (info.patPoint != 0) { + segmentsChamber[1000 * code + patIn] += 1; + } else { + segmentsChamber[1000 * code] += 1; + } } - std::map<double , Muon::MuonSegment*>::iterator ic_it = checkSegments.begin(); - std::map<double , Muon::MuonSegment*>::iterator ic_it_end= checkSegments.end(); + std::map<double, Muon::MuonSegment*>::iterator ic_it = checkSegments.begin(); + std::map<double, Muon::MuonSegment*>::iterator ic_it_end = checkSegments.end(); if (m_debug) { - std::cout << " Check Input Segments " << checkSegments.size() << std::endl ; - for(; ic_it != ic_it_end; ++ic_it){ - Muon::MuonSegment* seg = ic_it->second; - const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; - std::string st = info.station; - int code = info.stationCode; - double theta = seg->globalDirection().theta(); - if (m_debug) std::cout << " Check Station " << st << " code " << code << " theta " << theta << " key " << ic_it->first << std::endl; - } + std::cout << " Check Input Segments " << checkSegments.size() << std::endl; + for (; ic_it != ic_it_end; ++ic_it) { + Muon::MuonSegment* seg = ic_it->second; + const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; + std::string st = info.station; + int code = info.stationCode; + double theta = seg->globalDirection().theta(); + if (m_debug) + std::cout << " Check Station " << st << " code " << code << " theta " << theta << " key " + << ic_it->first << std::endl; + } } - - // Order segments according to key including multiplicity per pattern and chamber - - std::map<int , Muon::MuonSegment*> orderSegments; - int i = 0; - ic_it = checkSegments.begin(); - for(; ic_it != ic_it_end; ++ic_it){ - Muon::MuonSegment* segm = ic_it->second; - const Muon::MCSCSegmentInfo& info = m_segInfoMap[segm]; - -// Built key from ordered segments per station and missed hits - - int code = info.stationCode; + + // Order segments according to key including multiplicity per pattern and chamber + + std::map<int, Muon::MuonSegment*> orderSegments; + int i = 0; + ic_it = checkSegments.begin(); + for (; ic_it != ic_it_end; ++ic_it) { + Muon::MuonSegment* segm = ic_it->second; + const Muon::MCSCSegmentInfo& info = m_segInfoMap[segm]; + + // Built key from ordered segments per station and missed hits + + int code = info.stationCode; int missedh = info.nMissedHits; - int nHots = info.nHots; - if ( missedh < 0 ) missedh = 0; - if ( missedh > 10 ) missedh = 10; + int nHots = info.nHots; + if (missedh < 0) missedh = 0; + if (missedh > 10) missedh = 10; double invc = info.invcurvature; - double p = fabs(1./invc)/10.; - int ip = (int) sqrt( p/1000.); - if (ip > 10 ) ip = 10; - ip = 10 - ip; - int nLayTrig = info.nLayTrig; - std::string st = info.station; - double layMissed = info.layMissed; - int ntrigFrac = (int) layMissed*10; - if (m_debug) std::cout << " station " << info.station << " missed hits " << missedh << " nLayTrig " << nLayTrig << " layers missed " << layMissed << " ntrigFrac " << ntrigFrac << std::endl; -// int ntot = nHots; -// if ( ntot < 5 ) ntot = 5; -// if( 5*missedh > ntot*m_missedHitsCut) { -// if (m_debug) std::cout << " Drop this segment with missed hits " << missedh << std::endl; -// continue; -// } + double p = fabs(1. / invc) / 10.; + int ip = (int)sqrt(p / 1000.); + if (ip > 10) ip = 10; + ip = 10 - ip; + int nLayTrig = info.nLayTrig; + std::string st = info.station; + double layMissed = info.layMissed; + int ntrigFrac = (int)layMissed * 10; + if (m_debug) + std::cout << " station " << info.station << " missed hits " << missedh << " nLayTrig " << nLayTrig + << " layers missed " << layMissed << " ntrigFrac " << ntrigFrac << std::endl; + // int ntot = nHots; + // if ( ntot < 5 ) ntot = 5; + // if( 5*missedh > ntot*m_missedHitsCut) { + // if (m_debug) std::cout << " Drop this segment with missed hits " << missedh << std::endl; + // continue; + // } int patIn = 0; - if (info.patPoint!=0) { - if (patIndex.count(info.patPoint)!=1) if (m_debug) std::cout << " Pattern pointer not in PatIndex " << std::endl; - patIn = patIndex[info.patPoint]; - } - int key = segmentsChamber[1000*code+patIn]*100000+missedh*10000+ntrigFrac*1000+1000*ip+i; - if (info.nCsc == 1) key = key + 10000*(int) log(1.+info.chi2/nHots); + if (info.patPoint != 0) { + if (patIndex.count(info.patPoint) != 1) + if (m_debug) std::cout << " Pattern pointer not in PatIndex " << std::endl; + patIn = patIndex[info.patPoint]; + } + int key = segmentsChamber[1000 * code + patIn] * 100000 + missedh * 10000 + ntrigFrac * 1000 + 1000 * ip + i; + if (info.nCsc == 1) key = key + 10000 * (int)log(1. + info.chi2 / nHots); if (info.nCsc == 1 && nHots < 7) key = key + 100000; - if (m_debug) std::cout << " segments station " << segmentsChamber[1000*code+patIn] << " missed hits " << missedh << " ntrigFrac " << ntrigFrac << " ip " << ip << " i " << i << " key " << key << std::endl; - if (m_debug && info.nCsc == 1 ) std::cout << " Csc Segment " << info.nHots << " log 1 + chi2 dof " << log(1.+info.chi2/nHots) << std::endl; - - if (orderSegments.count(key)==1) { - if (m_debug) std::cout << " PROBLEM this key is already in the orderSegments collection " << key << std::endl; + if (m_debug) + std::cout << " segments station " << segmentsChamber[1000 * code + patIn] << " missed hits " << missedh + << " ntrigFrac " << ntrigFrac << " ip " << ip << " i " << i << " key " << key << std::endl; + if (m_debug && info.nCsc == 1) + std::cout << " Csc Segment " << info.nHots << " log 1 + chi2 dof " << log(1. + info.chi2 / nHots) + << std::endl; + + if (orderSegments.count(key) == 1) { + if (m_debug) + std::cout << " PROBLEM this key is already in the orderSegments collection " << key << std::endl; } orderSegments[key] = segm; i++; } - // Reset nSegments + // Reset nSegments - std::map<int , Muon::MuonSegment*>::iterator io_it = orderSegments.begin(); - std::map<int , Muon::MuonSegment*>::iterator io_it_end= orderSegments.end(); + std::map<int, Muon::MuonSegment*>::iterator io_it = orderSegments.begin(); + std::map<int, Muon::MuonSegment*>::iterator io_it_end = orderSegments.end(); - // Store segments and stations - if (m_debug) std::cout << " Summary Input Segments " << nSegments << std::endl ; - i = 0; - int j0 =0; - int code0 =0; - for(; io_it != io_it_end; ++io_it){ - Muon::MuonSegment* seg = io_it->second; + // Store segments and stations + if (m_debug) std::cout << " Summary Input Segments " << nSegments << std::endl; + i = 0; + int j0 = 0; + int code0 = 0; + for (; io_it != io_it_end; ++io_it) { + Muon::MuonSegment* seg = io_it->second; const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; - std::string st = info.station; - segment[i] = seg; - station[i] = st; - iPhiPatHits[i] = info.phiPatHits; - patPhi[i] = info.patPhi; - patTheta[i] = info.patTheta; - patPoint[i] = info.patPoint; - int code = info.stationCode; - int patIn = 0; - if (info.patPoint!=0) { - patIn = patIndex[info.patPoint]; - } - multi[i] = segmentsChamber[1000*code+patIn]; + std::string st = info.station; + segment[i] = seg; + station[i] = st; + iPhiPatHits[i] = info.phiPatHits; + patPhi[i] = info.patPhi; + patTheta[i] = info.patTheta; + patPoint[i] = info.patPoint; + int code = info.stationCode; + int patIn = 0; + if (info.patPoint != 0) { + patIn = patIndex[info.patPoint]; + } + multi[i] = segmentsChamber[1000 * code + patIn]; int miscorrect = 0; - if(info.phiPatHits == 0) miscorrect = 2; - if(info.nLayTrig > 0) miscorrect = 2; - if(info.nLayTrig > 2) miscorrect = 3; + if (info.phiPatHits == 0) miscorrect = 2; + if (info.nLayTrig > 0) miscorrect = 2; + if (info.nLayTrig > 2) miscorrect = 3; missedHits[i] = info.nMissedHits - miscorrect; - if(missedHits[i] < 0) missedHits[i]; - missedLay[i] = (int) info.layMissed; - nHots[i] = info.nHots; - double invc = info.invcurvature; - double p = fabs(1./invc)/10.; - momentum[i] = p; - - if (m_debug){ -// double phisp = atan2( seg->globalPosition().y(), seg->globalPosition().x()); -// std::cout << " station " << st << " Segment position x " << seg->globalPosition().x() << " y " << seg->globalPosition().y() << " z " << seg->globalPosition().z()<< " phi " << seg->globalDirection().phi() << " phi space " << phisp <<" phi pat " << patPhi[i] << " theta " << seg->globalDirection().theta() << " theta pat " << patTheta[i] <<std::endl; -// std::cout << info << " pointer " << patPoint[i] << " MDT missed " << info.nMissedHits << " Trigger Missed " << info.layMissed <<" missed Hits " << missedHits[i] << std::endl; - std::cout << " Key station " << st << " theta " << seg->globalDirection().theta() << " key " << io_it->first << " patPhi " << patPhi[i] << " patTheta " << patTheta[i] << std::endl; - } + if (missedHits[i] < 0) missedHits[i]; + missedLay[i] = (int)info.layMissed; + nHots[i] = info.nHots; + double invc = info.invcurvature; + double p = fabs(1. / invc) / 10.; + momentum[i] = p; + + if (m_debug) { + // double phisp = atan2( seg->globalPosition().y(), seg->globalPosition().x()); + // std::cout << " station " << st << " Segment position x " << seg->globalPosition().x() << " y " + // << seg->globalPosition().y() << " z " << seg->globalPosition().z()<< " phi " << + // seg->globalDirection().phi() << " phi space " << phisp <<" phi pat " << patPhi[i] << " theta " + // << seg->globalDirection().theta() << " theta pat " << patTheta[i] <<std::endl; std::cout << + // info << " pointer " << patPoint[i] << " MDT missed " << info.nMissedHits << " Trigger Missed " + // << info.layMissed <<" missed Hits " << missedHits[i] << std::endl; + std::cout << " Key station " << st << " theta " << seg->globalDirection().theta() << " key " << io_it->first + << " patPhi " << patPhi[i] << " patTheta " << patTheta[i] << std::endl; + } drop[i] = 0; if (multi[i] > 9) { j0++; if (j0 == 1) code0 = code; - if (code == code0 ) { - if (j0 > 9 ) drop[i] = 1; + if (code == code0) { + if (j0 > 9) drop[i] = 1; } else { - j0 = 1; + j0 = 1; code0 = code; } } - if (m_debug && drop[i] ==1 ) std::cout << "Drop this segment with multiplicity " << multi[i] << " drop " << drop[i] << " station " << st << " theta " << seg->globalDirection().theta() << std::endl; + if (m_debug && drop[i] == 1) + std::cout << "Drop this segment with multiplicity " << multi[i] << " drop " << drop[i] << " station " << st + << " theta " << seg->globalDirection().theta() << std::endl; i++; - } + } nSegments = i; - if(m_debug) std::cout << " nsegments " << nSegments << " index " << i << std::endl ; - - std::list <std::vector<int> > combiSegmentList(0); - - for (int i = 0; i <nSegments;++i) { - if ( drop[i] == 1 ) continue; - std::string st1 = station[i]; - double theta1 = segment[i]->globalDirection().theta(); - bool segmentAdded = false; - for (int j = i+1; j <nSegments;++j) { - if ( drop[j] == 1 ) continue; - std::string st2 = station[j]; - double theta2 = segment[j]->globalDirection().theta(); - if ( st1[0] == st2[0] && st1[1] == st2[1] && st1[2] == st2[2] ) continue; -// if (m_debug) std::cout << " segment nr i begin " << i << std::endl; -// if (m_debug) std::cout << " segment nr j begin " << j << std::endl; - - if (patPoint[i]!=0&&patPoint[j]!=0) { + if (m_debug) std::cout << " nsegments " << nSegments << " index " << i << std::endl; + + std::list<std::vector<int> > combiSegmentList(0); + + for (int i = 0; i < nSegments; ++i) { + if (drop[i] == 1) continue; + std::string st1 = station[i]; + double theta1 = segment[i]->globalDirection().theta(); + bool segmentAdded = false; + for (int j = i + 1; j < nSegments; ++j) { + if (drop[j] == 1) continue; + std::string st2 = station[j]; + double theta2 = segment[j]->globalDirection().theta(); + if (st1[0] == st2[0] && st1[1] == st2[1] && st1[2] == st2[2]) continue; + // if (m_debug) std::cout << " segment nr i begin " << i << std::endl; + // if (m_debug) std::cout << " segment nr j begin " << j << std::endl; + + if (patPoint[i] != 0 && patPoint[j] != 0) { // Combine segments from same pattern - // Cosmics: Combine all segments (cuts on angle applied later) -// Also Cosmics on Pattern ... -// if (patPoint[i]!=patPoint[j]&&!m_doCosmics) { - if (patPoint[i]!=patPoint[j]) { + // Cosmics: Combine all segments (cuts on angle applied later) + // Also Cosmics on Pattern ... + // if (patPoint[i]!=patPoint[j]&&!m_doCosmics) { + if (patPoint[i] != patPoint[j]) { bool selectPair = true; - // Do not combine segments if NOT on same pattern and NO phi measurements - if (iPhiPatHits[i]+iPhiPatHits[j] == 0) selectPair = false; -// Csc 4D segments check all patternpointers - if ( st1[0] == 'C' ) { - selectPair = false; - if( m_segInfoMap[segment[i]].contains(patPoint[j])) { -// Overwrite = store correct pointer! - patPoint[i] = patPoint[j]; - selectPair = true; - } - } else if ( st2[0] == 'C' ) { - selectPair = false; - if( m_segInfoMap[segment[j]].contains(patPoint[i])) { -// Overwrite = store correct pointer! - patPoint[j] = patPoint[i]; - selectPair = true; - } + // Do not combine segments if NOT on same pattern and NO phi measurements + if (iPhiPatHits[i] + iPhiPatHits[j] == 0) selectPair = false; + // Csc 4D segments check all patternpointers + if (st1[0] == 'C') { + selectPair = false; + if (m_segInfoMap[segment[i]].contains(patPoint[j])) { + // Overwrite = store correct pointer! + patPoint[i] = patPoint[j]; + selectPair = true; + } + } else if (st2[0] == 'C') { + selectPair = false; + if (m_segInfoMap[segment[j]].contains(patPoint[i])) { + // Overwrite = store correct pointer! + patPoint[j] = patPoint[i]; + selectPair = true; + } } else { - if (patPoint[i]!=patPoint[j]) selectPair = false; - } - if(!selectPair) { - if (m_debug) std::cout << " Pair not selected i " << i << " j " << j << " station 1 " << st1 << " theta " << theta1 << " station 2 " << st2 << " theta " << theta2<< " point i " << patPoint[i] << "point j " << patPoint[j] << " phipat i " << iPhiPatHits[i] << " phipat j " << iPhiPatHits[j] << std::endl; - continue; + if (patPoint[i] != patPoint[j]) selectPair = false; + } + if (!selectPair) { + if (m_debug) + std::cout << " Pair not selected i " << i << " j " << j << " station 1 " << st1 + << " theta " << theta1 << " station 2 " << st2 << " theta " << theta2 + << " point i " << patPoint[i] << "point j " << patPoint[j] << " phipat i " + << iPhiPatHits[i] << " phipat j " << iPhiPatHits[j] << std::endl; + continue; } } - if (m_debug) std::cout << " OK pattern pointer i " << patPoint[i] << " j " << patPoint[j] << " i " << i << " j " << j << " station 1 " << st1 << " theta " << theta1 << " station 2 " << st2 << " theta " << theta2<< std::endl; + if (m_debug) + std::cout << " OK pattern pointer i " << patPoint[i] << " j " << patPoint[j] << " i " << i << " j " + << j << " station 1 " << st1 << " theta " << theta1 << " station 2 " << st2 << " theta " + << theta2 << std::endl; } else { - // If 2D CSC segments not on a pattern -// if(m_assCscMap && st1[0] =='C'&&patPoint[i]!=0) continue; -// if(m_assCscMap && st2[0] =='C'&&patPoint[j]!=0) continue; - if( st1[0] =='C'&&patPoint[i]!=0) continue; - if( st2[0] =='C'&&patPoint[j]!=0) continue; - if (m_debug) std::cout << " pattern pointer i " << patPoint[i] << " j " << patPoint[j] << std::endl; + // If 2D CSC segments not on a pattern + // if(m_assCscMap && st1[0] =='C'&&patPoint[i]!=0) continue; + // if(m_assCscMap && st2[0] =='C'&&patPoint[j]!=0) continue; + if (st1[0] == 'C' && patPoint[i] != 0) continue; + if (st2[0] == 'C' && patPoint[j] != 0) continue; + if (m_debug) std::cout << " pattern pointer i " << patPoint[i] << " j " << patPoint[j] << std::endl; // Extrapolate pattern Forward in CSC region - if (st1[0] == 'C' && st2[0] == 'C') continue; + if (st1[0] == 'C' && st2[0] == 'C') continue; - double hitz = 0.; - double hitr = 0.; - double r0 = 0.; - double z0 = 0.; - double theta = 0.; + double hitz = 0.; + double hitr = 0.; + double r0 = 0.; + double z0 = 0.; + double theta = 0.; double invcurvature = 0.; - int k = -1; - if (st1[0] == 'C' ) { - hitz = segment[i]->globalPosition().z(); - hitr = segment[i]->globalPosition().perp(); - theta = segment[j]->globalDirection().theta(); - z0 = segment[j]->globalPosition().z(); - r0 = segment[j]->globalPosition().perp(); - k = j; - } - if( st2[0] == 'C') { - hitz = segment[j]->globalPosition().z(); - hitr = segment[j]->globalPosition().perp(); - theta = segment[i]->globalDirection().theta(); - z0 = segment[i]->globalPosition().z(); - r0 = segment[i]->globalPosition().perp(); - k = i; - } - if (m_debug) std:: cout << " station " << st1 << " station j " << st2 << std::endl; - if (m_debug) std::cout << " CSC segment r " << hitr << " segment z " << hitz << " segment theta " << theta <<std::endl; + int k = -1; + if (st1[0] == 'C') { + hitz = segment[i]->globalPosition().z(); + hitr = segment[i]->globalPosition().perp(); + theta = segment[j]->globalDirection().theta(); + z0 = segment[j]->globalPosition().z(); + r0 = segment[j]->globalPosition().perp(); + k = j; + } + if (st2[0] == 'C') { + hitz = segment[j]->globalPosition().z(); + hitr = segment[j]->globalPosition().perp(); + theta = segment[i]->globalDirection().theta(); + z0 = segment[i]->globalPosition().z(); + r0 = segment[i]->globalPosition().perp(); + k = i; + } + if (m_debug) std::cout << " station " << st1 << " station j " << st2 << std::endl; + if (m_debug) + std::cout << " CSC segment r " << hitr << " segment z " << hitz << " segment theta " << theta + << std::endl; if (k > -1) { if (patPoint[k] != 0) { - const Trk::TrackParameters* trkparameters = patPoint[k]->trackParameter(); + const Trk::TrackParameters* trkparameters = patPoint[k]->trackParameter(); if (trkparameters) { const Trk::Perigee* perigee = 0; - perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); + perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); if (perigee) { - const Amg::VectorX parameters = perigee->parameters(); - double phi = parameters[Trk::phi]; - theta = parameters[Trk::theta]; - r0 = - perigee->position().y()*std::cos(phi) + perigee->position().x()*std::sin(phi) ; + const Amg::VectorX parameters = perigee->parameters(); + double phi = parameters[Trk::phi]; + theta = parameters[Trk::theta]; + r0 = -perigee->position().y() * std::cos(phi) + perigee->position().x() * std::sin(phi); double charge = 1.; - if ( r0 < 0) charge = -1.; - if (m_debug) std::cout << " Pattern Momentum " << perigee->momentum().mag() << std::endl; - invcurvature = charge/(perigee->momentum().mag()); - z0 = perigee->position().z(); + if (r0 < 0) charge = -1.; + if (m_debug) + std::cout << " Pattern Momentum " << perigee->momentum().mag() << std::endl; + invcurvature = charge / (perigee->momentum().mag()); + z0 = perigee->position().z(); } } - } - } + } + } if (fabs(cos(theta)) < 0.2) continue; - double z_cylinder = 5000.; - int sign = 1; + double z_cylinder = 5000.; + int sign = 1; if (hitz < 0) sign = -1; - double rext = r0 + (hitz-z0)*std::tan(theta) - (hitz-sign*z_cylinder)*(hitz-sign*z_cylinder)*invcurvature/std::cos(theta); + double rext = + r0 + (hitz - z0) * std::tan(theta) + - (hitz - sign * z_cylinder) * (hitz - sign * z_cylinder) * invcurvature / std::cos(theta); double sdistance = (rext - hitr); - if (m_debug) std::cout << " CSC extrapolation r0 " << r0 << " z0 " << z0 << " theta " << theta << " inv curvature " << invcurvature << " distance " << sdistance << std::endl; + if (m_debug) + std::cout << " CSC extrapolation r0 " << r0 << " z0 " << z0 << " theta " << theta + << " inv curvature " << invcurvature << " distance " << sdistance << std::endl; if (fabs(sdistance) > 500.) continue; } -// Skip segment combi with too many missed hits - - int ntot = nHots[i]+nHots[j]; - if (ntot < 10 ) ntot = 10; - if( st1[0]!=st2[0] || st1[1]!=st2[1] ) { - bool dropmissed = false; - if( 10 *(missedHits[i]+missedHits[j]) > ntot*m_missedHitsCut ) dropmissed = true; - if ( st1[0]!=st2[0] || st1[2]!=st2[2] ) { - int missedL = missedLay[i]; - if(missedLay[j] < missedL) missedL = missedLay[j]; - if( 10 *(missedHits[i]+missedHits[j]+missedL) > ntot*(m_missedHitsCut+1) ) dropmissed = true; - } else { - if( 10 *(missedHits[i]+missedHits[j]+missedLay[i]+missedLay[j]) > ntot*(m_missedHitsCut+1) ) dropmissed = true; - } - if (dropmissed) { - if (m_debug) std::cout << " DROP MISSED i " << i << st1 << " missed i " << missedHits[i] << " missedLay i " << missedLay[i] << " j " << j << st2 << " missed j " << missedHits[j] << " missedLay j " << missedLay[j] << " nHots i " << nHots[i] << " nHots j " << nHots[j] << std::endl; - continue; - } + // Skip segment combi with too many missed hits + + int ntot = nHots[i] + nHots[j]; + if (ntot < 10) ntot = 10; + if (st1[0] != st2[0] || st1[1] != st2[1]) { + bool dropmissed = false; + if (10 * (missedHits[i] + missedHits[j]) > ntot * m_missedHitsCut) dropmissed = true; + if (st1[0] != st2[0] || st1[2] != st2[2]) { + int missedL = missedLay[i]; + if (missedLay[j] < missedL) missedL = missedLay[j]; + if (10 * (missedHits[i] + missedHits[j] + missedL) > ntot * (m_missedHitsCut + 1)) + dropmissed = true; + } else { + if (10 * (missedHits[i] + missedHits[j] + missedLay[i] + missedLay[j]) + > ntot * (m_missedHitsCut + 1)) + dropmissed = true; + } + if (dropmissed) { + if (m_debug) + std::cout << " DROP MISSED i " << i << st1 << " missed i " << missedHits[i] << " missedLay i " + << missedLay[i] << " j " << j << st2 << " missed j " << missedHits[j] + << " missedLay j " << missedLay[j] << " nHots i " << nHots[i] << " nHots j " + << nHots[j] << std::endl; + continue; + } } - // + // Amg::VectorX Res(4); - Res.setZero(); - Amg::VectorX Pull(4); - Pull.setZero(); - double phisp = atan2( segment[i]->globalPosition().y(), segment[i]->globalPosition().x()); - double phispe = atan2( segment[j]->globalPosition().y(), segment[j]->globalPosition().x()); - // double psi = ( cos(phisp)*cos(phispe) + sin(phisp)*sin(phispe) ); - // double dphis = sin (segment[i]->globalDirection().phi())*sin (segment[j]->globalDirection().phi()) + cos (segment[i]->globalDirection().phi())*cos (segment[j]->globalDirection().phi()); - - // select closest in phi according to: angular phi or space phi - double dphis = ( cos(patPhi[i])*cos(patPhi[j]) + sin(patPhi[i])*sin(patPhi[j]) ); + Res.setZero(); + Amg::VectorX Pull(4); + Pull.setZero(); + double phisp = atan2(segment[i]->globalPosition().y(), segment[i]->globalPosition().x()); + double phispe = atan2(segment[j]->globalPosition().y(), segment[j]->globalPosition().x()); + // double psi = ( cos(phisp)*cos(phispe) + sin(phisp)*sin(phispe) ); + // double dphis = sin (segment[i]->globalDirection().phi())*sin (segment[j]->globalDirection().phi()) + + // cos (segment[i]->globalDirection().phi())*cos (segment[j]->globalDirection().phi()); + + // select closest in phi according to: angular phi or space phi + double dphis = (cos(patPhi[i]) * cos(patPhi[j]) + sin(patPhi[i]) * sin(patPhi[j])); if (m_debug) { - // fpe protection: - if (dphis>1) dphis=1.; - else if (dphis<-1) dphis=-1; - double cdphis = acos(dphis); - std::cout << " acos dphis " << cdphis << " iphi1 " << iPhiPatHits[i] << " iphi2 " << iPhiPatHits[j] << std::endl; - std::cout << " Phi space 1 " << phisp << " Phi space 2 " << phispe << " Phi 1 " << segment[i]->globalDirection().phi() << " Phi 2 " << segment[j]->globalDirection().phi() << " pattern phi 1 " << patPhi[i] << " pattern phi2 " << patPhi[j] << std::endl; - } + // fpe protection: + if (dphis > 1) + dphis = 1.; + else if (dphis < -1) + dphis = -1; + double cdphis = acos(dphis); + std::cout << " acos dphis " << cdphis << " iphi1 " << iPhiPatHits[i] << " iphi2 " << iPhiPatHits[j] + << std::endl; + std::cout << " Phi space 1 " << phisp << " Phi space 2 " << phispe << " Phi 1 " + << segment[i]->globalDirection().phi() << " Phi 2 " << segment[j]->globalDirection().phi() + << " pattern phi 1 " << patPhi[i] << " pattern phi2 " << patPhi[j] << std::endl; + } bool selectPair = false; - if (patPoint[i]==patPoint[j] && patPoint[i]!=0) { - // Accept all pairs from same pattern - selectPair = true ; + if (patPoint[i] == patPoint[j] && patPoint[i] != 0) { + // Accept all pairs from same pattern + selectPair = true; } -// if (m_doCosmics && patPoint[i]!=patPoint[j]){ -// selectPair = true ; -// double phii = segment[i]->globalDirection().phi(); -// double phij = segment[j]->globalDirection().phi(); -// double thetai = segment[i]->globalDirection().theta(); -// double thetaj = segment[j]->globalDirection().theta(); -// double dotprod = sin(thetai)*sin(thetaj)*cos(phii)*cos(phij) + sin(thetai)*sin(thetaj)*sin(phii)*sin(phij) + cos(thetai)*cos(thetaj); -// double psicosmics = acos(dotprod); -// if (psicosmics > 0.1) selectPair = false; -// } - if (patPoint[i]!=patPoint[j]){ + // if (m_doCosmics && patPoint[i]!=patPoint[j]){ + // selectPair = true ; + // double phii = segment[i]->globalDirection().phi(); + // double phij = segment[j]->globalDirection().phi(); + // double thetai = segment[i]->globalDirection().theta(); + // double thetaj = segment[j]->globalDirection().theta(); + // double dotprod = sin(thetai)*sin(thetaj)*cos(phii)*cos(phij) + + // sin(thetai)*sin(thetaj)*sin(phii)*sin(phij) + cos(thetai)*cos(thetaj); double psicosmics + // = acos(dotprod); if (psicosmics > 0.1) selectPair = false; + // } + if (patPoint[i] != patPoint[j]) { selectPair = false; - if (patPoint[i]== 0 || patPoint[j] ==0) { - // Accept all pairs with no link to pattern == 2D CSC segments - selectPair = true ; + if (patPoint[i] == 0 || patPoint[j] == 0) { + // Accept all pairs with no link to pattern == 2D CSC segments + selectPair = true; } // Recuperate split patterns - // Phi measured for both segments -// double pest = fabs(momentum[i]); -// if (fabs(momentum[j]) < pest ) pest = fabs(momentum[j]); -// if( pest < 5000) pest = 5000.; -// // phi cut not used for association -// double phicut = m_phiAssociationCut2 * 5000. / pest; -// if (patPhi[i] == patPhi[j] ) selectPair = true; -// // Phi measured for one of the segment -// if (fabs (cdphis) < m_phiAssociationCut2 && (iPhiPatHits[i] == 0 || iPhiPatHits[j] == 0) ) selectPair = true; -// if (selectPair && m_debug) std::cout<< " Split pattern dphi " << cdphis << " momentum estimate " << pest << " phi cut " << phicut << std::endl; + // Phi measured for both segments + // double pest = fabs(momentum[i]); + // if (fabs(momentum[j]) < pest ) pest = fabs(momentum[j]); + // if( pest < 5000) pest = 5000.; + // // phi cut not used for association + // double phicut = m_phiAssociationCut2 * 5000. / pest; + // if (patPhi[i] == patPhi[j] ) selectPair = true; + // // Phi measured for one of the segment + // if (fabs (cdphis) < m_phiAssociationCut2 && (iPhiPatHits[i] == 0 || iPhiPatHits[j] + // == 0) ) selectPair = true; if (selectPair && m_debug) std::cout<< " Split pattern + // dphi " << cdphis << " momentum estimate " << pest << " phi cut " << phicut << + // std::endl; } - if (!selectPair&&m_debug) std::cout << " Pair not selected i " << i << " j " << j << std::endl; - if (selectPair) { - if ( st1[2] != st2[2] && st1[0] == st2[0] && st1[1] == st2[1] ) { - if (m_debug) std::cout << " Start SL fit 0 " << std::endl; - - fit2SegmentsSL(*segment[i],*segment[j], Res, Pull); - // if (m_doCosmics) fit2SegmentsC(segment[i],segment[j], Res, Pull); - } else if ( (st1[0] == 'E' || st1[0] == 'F') && ( st2[0] == 'E' || st2[0] == 'F') && - ((st1[1] == 'O' && st2[1] == 'M')||(st2[1] == 'O' && st1[1] == 'M')) ) { - if (m_debug) std::cout << " Start SL fit 1 " << std::endl; - fit2SegmentsSL(*segment[i],*segment[j], Res, Pull); - // if (m_doCosmics) fit2SegmentsC(segment[i],segment[j], Res, Pull); - } else { - if (m_debug) std::cout << " Start full fit " << std::endl; - if (!m_doCosmics) fit2Segments(*segment[i],*segment[j], Res, Pull); - if (m_doCosmics ){ - if( dphis > 0.) { - fit2SegmentsC(*segment[i],*segment[j], Res, Pull); - if (fabs(Pull[0]) > m_pullAssociationCut || fabs(Pull[1]) > m_pullAssociationCut || - fabs(Pull[2]) > m_pullAssociationCut || fabs(Pull[3]) > m_pullAssociationCut) { - fit2SegmentsSL(*segment[i],*segment[j], Res, Pull); - } - }else{ - if( m_debug ) std::cout << " not doing any fit " << std::endl; - continue; - } - } - } - if (m_debug) std::cout << " End fits Pull " << Pull[0] << " station 1 " << st1<< " station 2 " << st2 << " theta " << theta1 << " station 2 " << st2 << " theta " << theta2 << std::endl; - - // Good match - if (fabs(Pull[0]) < m_pullAssociationCut && fabs(Pull[1]) < m_pullAssociationCut && fabs(Pull[2]) < m_pullAssociationCut && fabs(Pull[3]) < m_pullAssociationCut) { - if (m_debug) std::cout << " Segment nr i,j associated " << i << " " << " station " << st1 << " j " << j << " station " << st2 << " theta " << theta1 << " station 2 " << st2 << " theta " << theta2 << std::endl; - segmentAdded = true; - std::list < std::vector<int> >::iterator it=combiSegmentList.begin(); - std::list < std::vector<int> >::iterator it_begin=combiSegmentList.begin(); - std::list < std::vector<int> >::iterator it_end=combiSegmentList.end(); - std::list < std::vector<int> > addCombiSegmentList(0); - - bool add = true; - if (combiSegmentList.size() == 0) add = false; - - int itermax = combiSegmentList.size(); - if( itermax > 5 && m_debug ) std::cout << " combinations " << itermax << std::endl; - if (itermax > 100) break; - int iter = 0; - for (; it!=it_end ; ++it) { - ++iter; - if (iter>itermax) { - if (m_debug) std::cout << "Problem should not occur iter " << iter << " itermax " << itermax <<std::endl; - break; + if (!selectPair && m_debug) std::cout << " Pair not selected i " << i << " j " << j << std::endl; + if (selectPair) { + if (st1[2] != st2[2] && st1[0] == st2[0] && st1[1] == st2[1]) { + if (m_debug) std::cout << " Start SL fit 0 " << std::endl; + + fit2SegmentsSL(*segment[i], *segment[j], Res, Pull); + // if (m_doCosmics) fit2SegmentsC(segment[i],segment[j], Res, Pull); + } else if ((st1[0] == 'E' || st1[0] == 'F') && (st2[0] == 'E' || st2[0] == 'F') + && ((st1[1] == 'O' && st2[1] == 'M') || (st2[1] == 'O' && st1[1] == 'M'))) + { + if (m_debug) std::cout << " Start SL fit 1 " << std::endl; + fit2SegmentsSL(*segment[i], *segment[j], Res, Pull); + // if (m_doCosmics) fit2SegmentsC(segment[i],segment[j], Res, Pull); + } else { + if (m_debug) std::cout << " Start full fit " << std::endl; + if (!m_doCosmics) fit2Segments(*segment[i], *segment[j], Res, Pull); + if (m_doCosmics) { + if (dphis > 0.) { + fit2SegmentsC(*segment[i], *segment[j], Res, Pull); + if (fabs(Pull[0]) > m_pullAssociationCut || fabs(Pull[1]) > m_pullAssociationCut + || fabs(Pull[2]) > m_pullAssociationCut || fabs(Pull[3]) > m_pullAssociationCut) + { + fit2SegmentsSL(*segment[i], *segment[j], Res, Pull); } - if (m_debug) std::cout << " Combination length "<< std::distance(it_end,it_begin) << " index " << std::distance(it,it_begin) - << " length " << std::distance(combiSegmentList.end(),it) << " len2 " << std::distance(combiSegmentList.end(),combiSegmentList.begin())<< std::endl; - std::vector<int>& combi = *it; - bool iFound = false; - bool jFound = false; - // reject combinations if on different patterns - bool reject = false; - for (unsigned int k = 0 ; k < combi.size() ; ++k ) { - if (m_debug) std::cout << " k " << k << " combi k " << combi[k] << std::endl; - if (i == combi[k]) iFound = true; - if (j == combi[k]) jFound = true; - std::string stk = station[combi[k]]; - if (patPoint[j]!=0 && patPoint[combi[k]]!=0) { - if (patPoint[j]!= patPoint[combi[k]]) { - if(st2[0]!='C' && stk[0]!='C') reject = true; - } - } - if (patPoint[i]!=0 && patPoint[combi[k]]!=0) { - if (patPoint[i]!= patPoint[combi[k]]) { - if(st1[0]!='C' && stk[0]!='C') reject = true; - } + } else { + if (m_debug) std::cout << " not doing any fit " << std::endl; + continue; + } + } + } + if (m_debug) + std::cout << " End fits Pull " << Pull[0] << " station 1 " << st1 << " station 2 " << st2 + << " theta " << theta1 << " station 2 " << st2 << " theta " << theta2 << std::endl; + + // Good match + if (fabs(Pull[0]) < m_pullAssociationCut && fabs(Pull[1]) < m_pullAssociationCut + && fabs(Pull[2]) < m_pullAssociationCut && fabs(Pull[3]) < m_pullAssociationCut) + { + if (m_debug) + std::cout << " Segment nr i,j associated " << i << " " + << " station " << st1 << " j " << j << " station " << st2 << " theta " << theta1 + << " station 2 " << st2 << " theta " << theta2 << std::endl; + segmentAdded = true; + std::list<std::vector<int> >::iterator it = combiSegmentList.begin(); + std::list<std::vector<int> >::iterator it_begin = combiSegmentList.begin(); + std::list<std::vector<int> >::iterator it_end = combiSegmentList.end(); + std::list<std::vector<int> > addCombiSegmentList(0); + + bool add = true; + if (combiSegmentList.size() == 0) add = false; + + int itermax = combiSegmentList.size(); + if (itermax > 5 && m_debug) std::cout << " combinations " << itermax << std::endl; + if (itermax > 100) break; + int iter = 0; + for (; it != it_end; ++it) { + ++iter; + if (iter > itermax) { + if (m_debug) + std::cout << "Problem should not occur iter " << iter << " itermax " << itermax + << std::endl; + break; + } + if (m_debug) + std::cout << " Combination length " << std::distance(it_end, it_begin) << " index " + << std::distance(it, it_begin) << " length " + << std::distance(combiSegmentList.end(), it) << " len2 " + << std::distance(combiSegmentList.end(), combiSegmentList.begin()) << std::endl; + std::vector<int>& combi = *it; + bool iFound = false; + bool jFound = false; + // reject combinations if on different patterns + bool reject = false; + for (unsigned int k = 0; k < combi.size(); ++k) { + if (m_debug) std::cout << " k " << k << " combi k " << combi[k] << std::endl; + if (i == combi[k]) iFound = true; + if (j == combi[k]) jFound = true; + std::string stk = station[combi[k]]; + if (patPoint[j] != 0 && patPoint[combi[k]] != 0) { + if (patPoint[j] != patPoint[combi[k]]) { + if (st2[0] != 'C' && stk[0] != 'C') reject = true; } } - if (m_debug && iFound) std::cout << " iFound i " << i << " station " << station[i] << std::endl; - if (m_debug && jFound) std::cout << " jFound j " << j << " station " << station[j] << std::endl; - - // Don't add segments to combination if they have different phi pattern values - // Be carefull not to add same segments (if associated differently) - if ((iFound && !jFound) ||(!iFound && jFound) ) { - // if (phimaxi > 0.001) iFound = false; - // if (phimaxj > 0.001) jFound = false; - if (reject && m_debug) std::cout << " Try to add segment with different pattern pointer phi i " << patPhi[i] << " phi j " << patPhi[j] << " theta i " << patTheta[i] << " theta j " << patTheta[j] << std::endl; - if (reject) iFound = false; - if (reject) jFound = false; - } - - add =true; - if (!iFound && !jFound ) add =false; - - if (iFound && !jFound ) { - combi.push_back(j); - if (m_debug) std::cout << " Add to existing set j " << j << std::endl; - } - if (jFound && !iFound ) { - combi.push_back(i); - if (m_debug) std::cout << " Add to existing set i " << i << std::endl; - - } - if (m_debug) std::cout << " Loop combis " << i << std::endl; - - // write Information out - if (m_debug) { - std::cout << " Check this combination " ; - std::vector<int>& combi0 = *it; - for (unsigned int k = 0 ; k < combi0.size() ; ++k ) { - std::cout <<" segment nr " << combi0[k] << " Station " << station[combi0[k]] << std::endl ; + if (patPoint[i] != 0 && patPoint[combi[k]] != 0) { + if (patPoint[i] != patPoint[combi[k]]) { + if (st1[0] != 'C' && stk[0] != 'C') reject = true; } } - } // end loop Segmentcombis - if (!add ) { - std::vector<int> combi2(2); - combi2[0]= i; - combi2[1]= j; - combiSegmentList.push_back(combi2); - if (m_debug) std::cout << " End Make combination i " << i << " j " << j << std::endl; } - if (m_debug) std::cout << " add segments to list " << addCombiSegmentList.size() << std::endl; + if (m_debug && iFound) + std::cout << " iFound i " << i << " station " << station[i] << std::endl; + if (m_debug && jFound) + std::cout << " jFound j " << j << " station " << station[j] << std::endl; + + // Don't add segments to combination if they have different phi pattern values + // Be carefull not to add same segments (if associated differently) + if ((iFound && !jFound) || (!iFound && jFound)) { + // if (phimaxi > 0.001) iFound = false; + // if (phimaxj > 0.001) jFound = false; + if (reject && m_debug) + std::cout << " Try to add segment with different pattern pointer phi i " << patPhi[i] + << " phi j " << patPhi[j] << " theta i " << patTheta[i] << " theta j " + << patTheta[j] << std::endl; + if (reject) iFound = false; + if (reject) jFound = false; + } + + add = true; + if (!iFound && !jFound) add = false; - combiSegmentList.insert( combiSegmentList.end(),addCombiSegmentList.begin(),addCombiSegmentList.end() ); + if (iFound && !jFound) { + combi.push_back(j); + if (m_debug) std::cout << " Add to existing set j " << j << std::endl; + } + if (jFound && !iFound) { + combi.push_back(i); + if (m_debug) std::cout << " Add to existing set i " << i << std::endl; + } + if (m_debug) std::cout << " Loop combis " << i << std::endl; + // write Information out if (m_debug) { - int ncombi = 0; - std::list < std::vector<int> >::iterator it0=combiSegmentList.begin(); - std::list < std::vector<int> >::iterator it0_end=combiSegmentList.end(); - for (; it0!=it0_end ; ++it0) { - ncombi++; - std::cout << " Check after ADD combinations " << ncombi ; - std::vector<int>& combi0 = *it0; - for (unsigned int k = 0 ; k < combi0.size() ; ++k ) { - std::cout <<" segment nr " << combi0[k] << " Station " << station[combi0[k]] << std::endl ; - } + std::cout << " Check this combination "; + std::vector<int>& combi0 = *it; + for (unsigned int k = 0; k < combi0.size(); ++k) { + std::cout << " segment nr " << combi0[k] << " Station " << station[combi0[k]] + << std::endl; + } + } + } // end loop Segmentcombis + if (!add) { + std::vector<int> combi2(2); + combi2[0] = i; + combi2[1] = j; + combiSegmentList.push_back(combi2); + if (m_debug) std::cout << " End Make combination i " << i << " j " << j << std::endl; + } + if (m_debug) std::cout << " add segments to list " << addCombiSegmentList.size() << std::endl; + + combiSegmentList.insert(combiSegmentList.end(), addCombiSegmentList.begin(), + addCombiSegmentList.end()); + + if (m_debug) { + int ncombi = 0; + std::list<std::vector<int> >::iterator it0 = combiSegmentList.begin(); + std::list<std::vector<int> >::iterator it0_end = combiSegmentList.end(); + for (; it0 != it0_end; ++it0) { + ncombi++; + std::cout << " Check after ADD combinations " << ncombi; + std::vector<int>& combi0 = *it0; + for (unsigned int k = 0; k < combi0.size(); ++k) { + std::cout << " segment nr " << combi0[k] << " Station " << station[combi0[k]] + << std::endl; } } - } // end goodmatch m_pullAssociationCut standard deviations - }// end select pair - -// if (m_debug) std::cout << " segment nr j end " << j << std::endl; - } // end segment j -// if (m_debug) std::cout << " segment nr i end " << i << std::endl; - if (m_addUnassociatedMiddleEndcapSegments) { - if (st1[0] == 'E' && st1[1] == 'M' ) { + } + } // end goodmatch m_pullAssociationCut standard deviations + } // end select pair + + // if (m_debug) std::cout << " segment nr j end " << j << std::endl; + } // end segment j + // if (m_debug) std::cout << " segment nr i end " << i << std::endl; + if (m_addUnassociatedMiddleEndcapSegments) { + if (st1[0] == 'E' && st1[1] == 'M') { if (!segmentAdded) { - std::vector<int> combi(1); - combi[0] = i; - combiSegmentList.insert(combiSegmentList.end(), combi ); - if(m_debug) std::cout << " addUnassociatedMiddleEndcapSegment succesfull " << i << " station " << st1 << std::endl; + std::vector<int> combi(1); + combi[0] = i; + combiSegmentList.insert(combiSegmentList.end(), combi); + if (m_debug) + std::cout << " addUnassociatedMiddleEndcapSegment succesfull " << i << " station " << st1 + << std::endl; } - } } - } // end segment i + } + } // end segment i // removal of residual subsets - std::list < std::vector<int> >::iterator it_begin=combiSegmentList.begin(); - std::list < std::vector<int> >::iterator it=combiSegmentList.begin(); - std::list < std::vector<int> >::iterator it2=combiSegmentList.begin(); - std::list < std::vector<int> >::iterator it_end=combiSegmentList.end(); - while ( it!=it_end ) { - std::vector<int>& combi1 = *it; - // if (m_debug) std::cout << " pos first "<< std::distance(it,it_begin) << std::endl; - bool erased = false; - it2 = it; - ++it2; - while (it2!=it_end ) { - // if (m_debug) std::cout << " pos second " << std::distance(it2,it_begin) << std::endl; - unsigned int overlap = 0; - std::vector<int>& combi2 = *it2; - for (unsigned int i = 0 ; i < combi1.size() ; ++i ) { - for (unsigned int j = 0 ; j < combi2.size() ; ++j ) { - if (combi1[i]==combi2[j]) { - overlap++; - break; - } + std::list<std::vector<int> >::iterator it_begin = combiSegmentList.begin(); + std::list<std::vector<int> >::iterator it = combiSegmentList.begin(); + std::list<std::vector<int> >::iterator it2 = combiSegmentList.begin(); + std::list<std::vector<int> >::iterator it_end = combiSegmentList.end(); + while (it != it_end) { + std::vector<int>& combi1 = *it; + // if (m_debug) std::cout << " pos first "<< std::distance(it,it_begin) << std::endl; + bool erased = false; + it2 = it; + ++it2; + while (it2 != it_end) { + // if (m_debug) std::cout << " pos second " << std::distance(it2,it_begin) << std::endl; + unsigned int overlap = 0; + std::vector<int>& combi2 = *it2; + for (unsigned int i = 0; i < combi1.size(); ++i) { + for (unsigned int j = 0; j < combi2.size(); ++j) { + if (combi1[i] == combi2[j]) { + overlap++; + break; } } - // if (m_debug) std::cout << " Removing Overlaps " << overlap << " size 2: " << combi2.size() << " size 1: " << combi1.size() << std::endl; - if (overlap == combi2.size()) { - it2 = combiSegmentList.erase(it2); - if (m_debug) std::cout << " erased second " << std::endl; - if (m_debug) std::cout << " pos second " << std::distance(it2,it_begin) << std::endl; - continue; - } else if (overlap == combi1.size()) { - it = combiSegmentList.erase(it); - erased = true; - if (m_debug) std::cout << " erased first " << std::endl; - break; - } - ++it2; - } // it2 - if (!erased) ++it; - } // it - - // Write out MuonSegmentCombination for track candidates - - //Muon::MuonSegPatAssMap* assCurvedMap = new Muon::MuonSegPatAssMap(); - - if (m_debug) std::cout << " Summary Segment Combinations found " << combiSegmentList.size() << std::endl; - if (combiSegmentList.size()>0) { - it = combiSegmentList.begin(); - it_end=combiSegmentList.end(); - int i = 0; - for (; it!=it_end ; ++it) { - i++; - // create MuonSegmentCombination for one track candidate - Muon::MuonSegmentCombination* combination = new Muon::MuonSegmentCombination(); - typedef std::map <std::string , std::unique_ptr<std::vector<std::unique_ptr<Muon::MuonSegment> > > > ChamberSort; - typedef ChamberSort::iterator ChamberSortIt; - ChamberSort chamberSort; - - std::vector<int>& combi = *it; - if (m_debug) std::cout << "Segment combination " << i; - - const Muon::MuonPatternCombination* patc = 0; - for (unsigned int k = 0 ; k < combi.size() ; ++k ) { - if (patPoint[combi[k]]) patc = patPoint[combi[k]]; - if (m_debug){ - Muon::MuonSegment* seg = segment[combi[k]]; - //const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; - double phisp = atan2( seg->globalPosition().y(), seg->globalPosition().x()); - std::cout << " Segment position x " << seg->globalPosition().x() << " y " << seg->globalPosition().y() << " z " << seg->globalPosition().z()<< " phi " << seg->globalDirection().phi() << " phi space " << phisp << " theta " << seg->globalDirection().theta() <<std::endl; - //std::cout << info << std::endl; - } - std::string st = station[combi[k]]; - ChamberSortIt pos = chamberSort.find(st); - if (pos == chamberSort.end()) { - chamberSort[st] = std::make_unique<std::vector<std::unique_ptr<Muon::MuonSegment> > >(); - chamberSort[st]->push_back(std::unique_ptr<Muon::MuonSegment>(segment[combi[k]]->clone())); - // if (m_debug) std::cout << " First segment in Station " << st << std::endl; - } else { - pos->second->push_back(std::unique_ptr<Muon::MuonSegment>(segment[combi[k]]->clone())); - // if (m_debug) std::cout << " Next segment in Station " << st << " size " << segPerStation->size() << std::endl; - } + } + // if (m_debug) std::cout << " Removing Overlaps " << overlap << " size 2: " << combi2.size() << " + // size 1: " << combi1.size() << std::endl; + if (overlap == combi2.size()) { + it2 = combiSegmentList.erase(it2); + if (m_debug) std::cout << " erased second " << std::endl; + if (m_debug) std::cout << " pos second " << std::distance(it2, it_begin) << std::endl; + continue; + } else if (overlap == combi1.size()) { + it = combiSegmentList.erase(it); + erased = true; + if (m_debug) std::cout << " erased first " << std::endl; + break; + } + ++it2; + } // it2 + if (!erased) ++it; + } // it + + // Write out MuonSegmentCombination for track candidates + + // Muon::MuonSegPatAssMap* assCurvedMap = new Muon::MuonSegPatAssMap(); + + if (m_debug) std::cout << " Summary Segment Combinations found " << combiSegmentList.size() << std::endl; + if (combiSegmentList.size() > 0) { + it = combiSegmentList.begin(); + it_end = combiSegmentList.end(); + int i = 0; + for (; it != it_end; ++it) { + i++; + // create MuonSegmentCombination for one track candidate + Muon::MuonSegmentCombination* combination = new Muon::MuonSegmentCombination(); + typedef std::map<std::string, std::unique_ptr<std::vector<std::unique_ptr<Muon::MuonSegment> > > > + ChamberSort; + typedef ChamberSort::iterator ChamberSortIt; + ChamberSort chamberSort; + + std::vector<int>& combi = *it; + if (m_debug) std::cout << "Segment combination " << i; + + const Muon::MuonPatternCombination* patc = 0; + for (unsigned int k = 0; k < combi.size(); ++k) { + if (patPoint[combi[k]]) patc = patPoint[combi[k]]; + if (m_debug) { + Muon::MuonSegment* seg = segment[combi[k]]; + // const Muon::MCSCSegmentInfo& info = m_segInfoMap[seg]; + double phisp = atan2(seg->globalPosition().y(), seg->globalPosition().x()); + std::cout << " Segment position x " << seg->globalPosition().x() << " y " + << seg->globalPosition().y() << " z " << seg->globalPosition().z() << " phi " + << seg->globalDirection().phi() << " phi space " << phisp << " theta " + << seg->globalDirection().theta() << std::endl; + // std::cout << info << std::endl; } - ChamberSortIt cit = chamberSort.begin(); - ChamberSortIt cit_end = chamberSort.end(); - for (;cit !=cit_end; ++cit) { - combination->addSegments( std::move(cit->second) ); + std::string st = station[combi[k]]; + ChamberSortIt pos = chamberSort.find(st); + if (pos == chamberSort.end()) { + chamberSort[st] = std::make_unique<std::vector<std::unique_ptr<Muon::MuonSegment> > >(); + chamberSort[st]->push_back(std::unique_ptr<Muon::MuonSegment>(segment[combi[k]]->clone())); + // if (m_debug) std::cout << " First segment in Station " << st << std::endl; + } else { + pos->second->push_back(std::unique_ptr<Muon::MuonSegment>(segment[combi[k]]->clone())); + // if (m_debug) std::cout << " Next segment in Station " << st << " size " << + // segPerStation->size() << std::endl; } - - // if (patc) assCurvedMap->addAssociation( patternCol, patc, combiCol, combination ); - segPattMap->insert(std::make_pair(combination, patc)); - - curvedCombiCol->push_back( combination ); } - } + ChamberSortIt cit = chamberSort.begin(); + ChamberSortIt cit_end = chamberSort.end(); + for (; cit != cit_end; ++cit) { + combination->addSegments(std::move(cit->second)); + } + + // if (patc) assCurvedMap->addAssociation( patternCol, patc, combiCol, combination ); + segPattMap->insert(std::make_pair(combination, patc)); - if( msgLvl(MSG::DEBUG) || m_summary) { - if( curvedCombiCol->empty() ) ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations empty"); - else ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations " << std::endl << m_printer->print( *curvedCombiCol ) ); + curvedCombiCol->push_back(combination); } } -unsigned int -Muon::MuonCurvedSegmentCombiner::missedHits( Muon::MuonSegment* seg) { + if (msgLvl(MSG::DEBUG) || m_summary) { + if (curvedCombiCol->empty()) + ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations empty"); + else + ATH_MSG_INFO(" summarizing output: MuonCurvedSegment combinations " << std::endl + << m_printer->print(*curvedCombiCol)); + } +} - // try to dynamic_cast to MdtSegmentQuality in order to obtain quality +unsigned int +Muon::MuonCurvedSegmentCombiner::missedHits(Muon::MuonSegment* seg) +{ + + // try to dynamic_cast to MdtSegmentQuality in order to obtain quality const Muon::MuonSegmentQuality* q = dynamic_cast<const Muon::MuonSegmentQuality*>(seg->fitQuality()); - if( !q ) { + if (!q) { ATH_MSG_DEBUG("dynamic_cast MuonSegmentQuality failed"); return 0; } ATH_MSG_DEBUG("Got MuonSegmentQuality " - << " hots " << q->numberDoF()+2 << " number of holes + out of time hits " << q->channelsWithoutHit().size() ); + << " hots " << q->numberDoF() + 2 << " number of holes + out of time hits " + << q->channelsWithoutHit().size()); // unsigned int hots = q->hots(); - //unsigned int crossedtubes = q->crossedTubesMl1()+q->crossedTubesMl2() ; - //unsigned int deltas = q->deltas(); + // unsigned int crossedtubes = q->crossedTubesMl1()+q->crossedTubesMl2() ; + // unsigned int deltas = q->deltas(); - unsigned int missed = q->channelsWithoutHit().size(); + unsigned int missed = q->channelsWithoutHit().size(); // if(missed < 0) missed = 0; - return missed; + return missed; } -Muon::MCSCSegmentInfo -Muon::MuonCurvedSegmentCombiner::segInfo( Muon::MuonSegment* seg ){ - - Muon::MCSCSegmentInfo info; - - // MDT information - info.index = -1; - - info.nMult1 = 0; - info.nMult2 = 0; - info.nLayTrig = 0; - info.nMissedHits = 0; - info.layMissed = 0.; - // Phi measurement - info.phiPatHits = 0; - info.patHits = 0; - - // Hits on segment (CSC or MDT) - int nHots = 0; - // station code and string - int code = 0; - std::string name; - bool ismdt = false; - - info.chi2 = 0.; - if( seg->fitQuality()) { - info.chi2 = (seg->fitQuality())->chiSquared(); - } - - const MdtDriftCircleOnTrack* mdtShortest = 0; - double shortestTube = 1e9; - Identifier id; - std::vector<const Trk::MeasurementBase*> mbs = seg->containedMeasurements(); - std::vector<const Trk::MeasurementBase*>::const_iterator mit = mbs.begin(); - std::vector<const Trk::MeasurementBase*>::const_iterator mit_end = mbs.end(); - for (;mit!=mit_end;++mit) { - Identifier idr ; - const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*> (*mit); - if (!rot){ - const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*> (*mit); - if (crot) rot = &crot->rioOnTrack(0); - } - if (rot) idr = rot->identify(); - if (!rot) continue; - if(m_idHelperSvc->isCsc(idr)){ - id = idr; - } - if(m_idHelperSvc->isMdt(idr)){ - - const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(*mit); - if( mdt ){ - int lay = m_idHelperSvc->mdtIdHelper().tubeLayer(mdt->identify()); - int tube = m_idHelperSvc->mdtIdHelper().tube(mdt->identify()); - double tubelen = mdt->prepRawData()->detectorElement()->getActiveTubeLength(lay,tube); - if( tubelen < shortestTube ){ - mdtShortest = mdt; - shortestTube = tubelen; - } - } - ismdt = true; - id = idr; - break; - } - } - - - if (ismdt) { - - bool closeToChamberEdge = false; - double posAlongTube = 0; - if( mdtShortest ){ - posAlongTube = (mdtShortest->associatedSurface().transform().inverse()*seg->globalPosition()).z(); - if( 0.5*shortestTube - fabs(posAlongTube) < 100. ) closeToChamberEdge = true; - }else{ - ATH_MSG_WARNING(" shorest tube not set "); - } - - ATH_MSG_DEBUG(" new seg in " << m_idHelperSvc->mdtIdHelper().print_to_string(id)); - // MDT or CSC segment - info.nCsc = 0; - info.nMissedHits = closeToChamberEdge ? 0 : missedHits(seg); - - int stName = m_idHelperSvc->mdtIdHelper().stationName( id ); - name = m_idHelperSvc->mdtIdHelper().stationNameString( stName ); - int stEta = m_idHelperSvc->mdtIdHelper().stationEta( id ); - int stPhi = m_idHelperSvc->mdtIdHelper().stationPhi( id ); - code = stName*1000+100*stPhi+stEta; - - int nMult1 = 0; - int nMult2 = 0; - std::map < int, int > triggerLayers; - mit = mbs.begin(); - for (;mit!=mit_end;++mit) { - Identifier idr ; - const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*> (*mit); - if (!rot){ - const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*> (*mit); - if (crot) rot = &crot->rioOnTrack(0); - } - if (rot) idr = rot->identify(); - if (!rot) continue; - - if(m_idHelperSvc->isMdt(idr)){ - if( m_idHelperSvc->mdtIdHelper().multilayer(idr) == 1 ) nMult1++; - if( m_idHelperSvc->mdtIdHelper().multilayer(idr) == 2 ) nMult2++; - nHots++; - } - int layerCode = 0; - if(m_idHelperSvc->isRpc(idr)){ - layerCode = 1000000*(m_idHelperSvc->rpcIdHelper().stationName(idr))+10000*(m_idHelperSvc->rpcIdHelper().stationPhi(idr))+ 100* ((m_idHelperSvc->rpcIdHelper().stationEta(idr))+10); - layerCode = layerCode + 2*((m_idHelperSvc->rpcIdHelper().doubletR(idr))-1)+16*((m_idHelperSvc->rpcIdHelper().gasGap(idr))-1); - if (m_idHelperSvc->rpcIdHelper().measuresPhi(idr)) layerCode += 100; - triggerLayers[layerCode] = 1; - ATH_MSG_DEBUG(" RPC hit phi" << m_idHelperSvc->rpcIdHelper().measuresPhi(idr) << " R " << m_idHelperSvc->rpcIdHelper().doubletR(idr) << " gas " << m_idHelperSvc->rpcIdHelper().gasGap(idr)); - } - if (m_idHelperSvc->isTgc( idr )) { - layerCode = 1000000*(m_idHelperSvc->tgcIdHelper().stationName(idr))+10000*(m_idHelperSvc->tgcIdHelper().stationPhi(idr))+ 100* ((m_idHelperSvc->tgcIdHelper().stationEta(idr))+10); - layerCode = layerCode + m_idHelperSvc->tgcIdHelper().gasGap(idr); - if (m_idHelperSvc->tgcIdHelper().isStrip(idr)) layerCode += 100; - triggerLayers[layerCode] = 1; - } - } - info.nLayTrig = triggerLayers.size(); -// - std::string st = name; - int nLayTrig = triggerLayers.size(); - int nLayMax = 0; - if (st[0] == 'B') { - if (st[1] == 'M') nLayMax = 4; - if (st[1] == 'O') nLayMax = 2; - } else if (st[0] == 'E' || st[0] == 'F') { - if (st[1] == 'I') nLayMax = 2; - if (st[1] == 'M') nLayMax = 7; - } -// -// Model quality: maximal 3 missed hits = no TGCs in Middle (7) -// 1 missed hit = no TGCs Inner (2) -// 2 missed hits = no RPC Middle (4) -// 1 missed hit = no RPC Outer (2) - - double trigFrac = 0.; - if (nLayTrig > nLayMax && nLayMax > 0 ) { - nLayTrig = nLayMax; +Muon::MCSCSegmentInfo +Muon::MuonCurvedSegmentCombiner::segInfo(Muon::MuonSegment* seg) +{ + + Muon::MCSCSegmentInfo info; + + // MDT information + info.index = -1; + + info.nMult1 = 0; + info.nMult2 = 0; + info.nLayTrig = 0; + info.nMissedHits = 0; + info.layMissed = 0.; + // Phi measurement + info.phiPatHits = 0; + info.patHits = 0; + + // Hits on segment (CSC or MDT) + int nHots = 0; + // station code and string + int code = 0; + std::string name; + bool ismdt = false; + + info.chi2 = 0.; + if (seg->fitQuality()) { + info.chi2 = (seg->fitQuality())->chiSquared(); } - if ( nLayMax > 0 ) { - trigFrac = (nLayMax - nLayTrig)/2.; + + const MdtDriftCircleOnTrack* mdtShortest = 0; + double shortestTube = 1e9; + Identifier id; + std::vector<const Trk::MeasurementBase*> mbs = seg->containedMeasurements(); + std::vector<const Trk::MeasurementBase*>::const_iterator mit = mbs.begin(); + std::vector<const Trk::MeasurementBase*>::const_iterator mit_end = mbs.end(); + for (; mit != mit_end; ++mit) { + Identifier idr; + const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(*mit); + if (!rot) { + const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(*mit); + if (crot) rot = &crot->rioOnTrack(0); + } + if (rot) idr = rot->identify(); + if (!rot) continue; + if (m_idHelperSvc->isCsc(idr)) { + id = idr; + } + if (m_idHelperSvc->isMdt(idr)) { + + const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(*mit); + if (mdt) { + int lay = m_idHelperSvc->mdtIdHelper().tubeLayer(mdt->identify()); + int tube = m_idHelperSvc->mdtIdHelper().tube(mdt->identify()); + double tubelen = mdt->prepRawData()->detectorElement()->getActiveTubeLength(lay, tube); + if (tubelen < shortestTube) { + mdtShortest = mdt; + shortestTube = tubelen; + } + } + ismdt = true; + id = idr; + break; + } } - if (m_debug) std::cout << " nLayTrig " << nLayTrig << " nLayMax " << nLayMax << " trigFrac " << trigFrac << std::endl; - if (trigFrac > 3.) trigFrac = 3.; -// -// Station witn NO RPCs or partial coverage -// - if (st[0] == 'B' && st[1] =='E' && st[2] =='E') trigFrac = 0.; - if (st[0] == 'B' && st[1] =='O' && st[2] =='G') trigFrac = 0.; - if (st[0] == 'B' && st[1] =='O' && st[2] =='L') trigFrac = trigFrac/2.; - if (st[0] == 'B' && st[1] =='M' && st[2] =='L') trigFrac = trigFrac/2.; - if (st[0] == 'B' && st[1] =='M' && st[2] =='F') trigFrac = trigFrac/2.; -// -// Endcap stations no TGC coverage for station eta = +-1 -// reduced TGC coverage in Barrel-Endcap around station eta 4,5 -// - if (st[0] == 'E') { - if(abs(stEta) == 1 ) trigFrac = 0.; - if(abs(stEta) == 5 && st[1] =='M' && st[2] =='S' ) trigFrac = trigFrac/4.; - if(abs(stEta) == 5 && st[1] =='I' && st[2] =='L' ) trigFrac = trigFrac/4.; - if(abs(stEta) == 4 && st[1] =='I' && st[2] =='L' ) trigFrac = trigFrac/4.; - } - info.layMissed = trigFrac; - - info.nMult1 = nMult1; - info.nMult2 = nMult2; - - } else if (m_idHelperSvc->isCsc(id)) { - ATH_MSG_DEBUG(" new seg in " << m_idHelperSvc->cscIdHelper().print_to_string(id)); - info.nCsc = 1; - int stName = m_idHelperSvc->cscIdHelper().stationName( id ); - name = m_idHelperSvc->cscIdHelper().stationNameString( stName ); - int steta = m_idHelperSvc->cscIdHelper().stationEta( id ); - code = stName*1000+steta; - mit = mbs.begin(); - for (;mit!=mit_end;++mit) { - Identifier idr ; - const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*> (*mit); - if (!rot){ - const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*> (*mit); - if (crot) rot = &crot->rioOnTrack(0); - } - if (rot) idr = rot->identify(); - if (!rot) continue; - if(m_idHelperSvc->isCsc(idr)) { - nHots++; - } + + + if (ismdt) { + + bool closeToChamberEdge = false; + double posAlongTube = 0; + if (mdtShortest) { + posAlongTube = (mdtShortest->associatedSurface().transform().inverse() * seg->globalPosition()).z(); + if (0.5 * shortestTube - fabs(posAlongTube) < 100.) closeToChamberEdge = true; + } else { + ATH_MSG_WARNING(" shorest tube not set "); + } + + ATH_MSG_DEBUG(" new seg in " << m_idHelperSvc->mdtIdHelper().print_to_string(id)); + // MDT or CSC segment + info.nCsc = 0; + info.nMissedHits = closeToChamberEdge ? 0 : missedHits(seg); + + int stName = m_idHelperSvc->mdtIdHelper().stationName(id); + name = m_idHelperSvc->mdtIdHelper().stationNameString(stName); + int stEta = m_idHelperSvc->mdtIdHelper().stationEta(id); + int stPhi = m_idHelperSvc->mdtIdHelper().stationPhi(id); + code = stName * 1000 + 100 * stPhi + stEta; + + int nMult1 = 0; + int nMult2 = 0; + std::map<int, int> triggerLayers; + mit = mbs.begin(); + for (; mit != mit_end; ++mit) { + Identifier idr; + const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(*mit); + if (!rot) { + const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(*mit); + if (crot) rot = &crot->rioOnTrack(0); + } + if (rot) idr = rot->identify(); + if (!rot) continue; + + if (m_idHelperSvc->isMdt(idr)) { + if (m_idHelperSvc->mdtIdHelper().multilayer(idr) == 1) nMult1++; + if (m_idHelperSvc->mdtIdHelper().multilayer(idr) == 2) nMult2++; + nHots++; + } + int layerCode = 0; + if (m_idHelperSvc->isRpc(idr)) { + layerCode = 1000000 * (m_idHelperSvc->rpcIdHelper().stationName(idr)) + + 10000 * (m_idHelperSvc->rpcIdHelper().stationPhi(idr)) + + 100 * ((m_idHelperSvc->rpcIdHelper().stationEta(idr)) + 10); + layerCode = layerCode + 2 * ((m_idHelperSvc->rpcIdHelper().doubletR(idr)) - 1) + + 16 * ((m_idHelperSvc->rpcIdHelper().gasGap(idr)) - 1); + if (m_idHelperSvc->rpcIdHelper().measuresPhi(idr)) layerCode += 100; + triggerLayers[layerCode] = 1; + ATH_MSG_DEBUG(" RPC hit phi" << m_idHelperSvc->rpcIdHelper().measuresPhi(idr) << " R " + << m_idHelperSvc->rpcIdHelper().doubletR(idr) << " gas " + << m_idHelperSvc->rpcIdHelper().gasGap(idr)); + } + if (m_idHelperSvc->isTgc(idr)) { + layerCode = 1000000 * (m_idHelperSvc->tgcIdHelper().stationName(idr)) + + 10000 * (m_idHelperSvc->tgcIdHelper().stationPhi(idr)) + + 100 * ((m_idHelperSvc->tgcIdHelper().stationEta(idr)) + 10); + layerCode = layerCode + m_idHelperSvc->tgcIdHelper().gasGap(idr); + if (m_idHelperSvc->tgcIdHelper().isStrip(idr)) layerCode += 100; + triggerLayers[layerCode] = 1; + } + } + info.nLayTrig = triggerLayers.size(); + // + std::string st = name; + int nLayTrig = triggerLayers.size(); + int nLayMax = 0; + if (st[0] == 'B') { + if (st[1] == 'M') nLayMax = 4; + if (st[1] == 'O') nLayMax = 2; + } else if (st[0] == 'E' || st[0] == 'F') { + if (st[1] == 'I') nLayMax = 2; + if (st[1] == 'M') nLayMax = 7; + } + // + // Model quality: maximal 3 missed hits = no TGCs in Middle (7) + // 1 missed hit = no TGCs Inner (2) + // 2 missed hits = no RPC Middle (4) + // 1 missed hit = no RPC Outer (2) + + double trigFrac = 0.; + if (nLayTrig > nLayMax && nLayMax > 0) { + nLayTrig = nLayMax; + } + if (nLayMax > 0) { + trigFrac = (nLayMax - nLayTrig) / 2.; + } + if (m_debug) + std::cout << " nLayTrig " << nLayTrig << " nLayMax " << nLayMax << " trigFrac " << trigFrac << std::endl; + if (trigFrac > 3.) trigFrac = 3.; + // + // Station witn NO RPCs or partial coverage + // + if (st[0] == 'B' && st[1] == 'E' && st[2] == 'E') trigFrac = 0.; + if (st[0] == 'B' && st[1] == 'O' && st[2] == 'G') trigFrac = 0.; + if (st[0] == 'B' && st[1] == 'O' && st[2] == 'L') trigFrac = trigFrac / 2.; + if (st[0] == 'B' && st[1] == 'M' && st[2] == 'L') trigFrac = trigFrac / 2.; + if (st[0] == 'B' && st[1] == 'M' && st[2] == 'F') trigFrac = trigFrac / 2.; + // + // Endcap stations no TGC coverage for station eta = +-1 + // reduced TGC coverage in Barrel-Endcap around station eta 4,5 + // + if (st[0] == 'E') { + if (abs(stEta) == 1) trigFrac = 0.; + if (abs(stEta) == 5 && st[1] == 'M' && st[2] == 'S') trigFrac = trigFrac / 4.; + if (abs(stEta) == 5 && st[1] == 'I' && st[2] == 'L') trigFrac = trigFrac / 4.; + if (abs(stEta) == 4 && st[1] == 'I' && st[2] == 'L') trigFrac = trigFrac / 4.; + } + info.layMissed = trigFrac; + + info.nMult1 = nMult1; + info.nMult2 = nMult2; + + } else if (m_idHelperSvc->isCsc(id)) { + ATH_MSG_DEBUG(" new seg in " << m_idHelperSvc->cscIdHelper().print_to_string(id)); + info.nCsc = 1; + int stName = m_idHelperSvc->cscIdHelper().stationName(id); + name = m_idHelperSvc->cscIdHelper().stationNameString(stName); + int steta = m_idHelperSvc->cscIdHelper().stationEta(id); + code = stName * 1000 + steta; + mit = mbs.begin(); + for (; mit != mit_end; ++mit) { + Identifier idr; + const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(*mit); + if (!rot) { + const Trk::CompetingRIOsOnTrack* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(*mit); + if (crot) rot = &crot->rioOnTrack(0); + } + if (rot) idr = rot->identify(); + if (!rot) continue; + if (m_idHelperSvc->isCsc(idr)) { + nHots++; + } + } } - } -// Start values for pattern information + // Start values for pattern information - int nphi = 0; - int nall = 0; - double patternPhi = -1000.; - double patternTheta = -1000.; - double patternMomentum = -1.; - info.patPoint = 0; + int nphi = 0; + int nall = 0; + double patternPhi = -1000.; + double patternTheta = -1000.; + double patternMomentum = -1.; + info.patPoint = 0; -// Navigate to FIRST pattern stored in m_segAssoMap + // Navigate to FIRST pattern stored in m_segAssoMap const Muon::MuonPatternCombination* patP = m_segAssoMap[seg]; - if (patP != 0 ) { -// Set pattern pointer - info.patPoint = patP; - const Trk::TrackParameters* trkparameters = patP->trackParameter(); - if (trkparameters) { - const Trk::Perigee* perigee = 0; - perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); - if (perigee) { -// Get momentum and phi value - patternMomentum = perigee->momentum().mag(); - patternPhi = perigee->momentum().phi(); - patternTheta = perigee->momentum().theta(); - } - } -// Count phi hits - std::vector< Muon::MuonPatternChamberIntersect >::const_iterator it = patP->chamberData().begin(); - for (; it!=patP->chamberData().end(); ++it ) { - std::vector< const Trk::PrepRawData* >::const_iterator pit = (*it).prepRawDataVec().begin(); - for (; pit!=(*it).prepRawDataVec().end(); ++pit) { - const Trk::PrepRawData* hit = *pit ; - nall++; - Identifier id = hit->identify() ; - if ( m_idHelperSvc->isRpc(id) ) { - if( m_idHelperSvc->rpcIdHelper().measuresPhi(id) ) nphi++; - } else if( m_idHelperSvc->isTgc(id) ) { - if( m_idHelperSvc->tgcIdHelper().isStrip(id) ) nphi++; - } else if( m_idHelperSvc->isCsc(id) ) { - if( m_idHelperSvc->cscIdHelper().measuresPhi(id) ) nphi++; - } - } - } - + if (patP != 0) { + // Set pattern pointer + info.patPoint = patP; + const Trk::TrackParameters* trkparameters = patP->trackParameter(); + if (trkparameters) { + const Trk::Perigee* perigee = 0; + perigee = dynamic_cast<const Trk::Perigee*>(trkparameters); + if (perigee) { + // Get momentum and phi value + patternMomentum = perigee->momentum().mag(); + patternPhi = perigee->momentum().phi(); + patternTheta = perigee->momentum().theta(); + } + } + // Count phi hits + std::vector<Muon::MuonPatternChamberIntersect>::const_iterator it = patP->chamberData().begin(); + for (; it != patP->chamberData().end(); ++it) { + std::vector<const Trk::PrepRawData*>::const_iterator pit = (*it).prepRawDataVec().begin(); + for (; pit != (*it).prepRawDataVec().end(); ++pit) { + const Trk::PrepRawData* hit = *pit; + nall++; + Identifier id = hit->identify(); + if (m_idHelperSvc->isRpc(id)) { + if (m_idHelperSvc->rpcIdHelper().measuresPhi(id)) nphi++; + } else if (m_idHelperSvc->isTgc(id)) { + if (m_idHelperSvc->tgcIdHelper().isStrip(id)) nphi++; + } else if (m_idHelperSvc->isCsc(id)) { + if (m_idHelperSvc->cscIdHelper().measuresPhi(id)) nphi++; + } + } + } } -// if (m_debug) std::cout << " Seg Info Phi hits on pattern " << nphi << std::endl; - info.phiPatHits = 0; - info.patHits = nall; - if(nphi>0) info.phiPatHits = nphi; - info.patPhi = patternPhi; - info.patTheta = patternTheta; - info.patMomentum = patternMomentum; - - info.nHots = nHots; - info.stationCode = code; - info.station = name; - - if (m_debug) std::cout << " Station name " << name << " Station code " << code << std::endl; - - double theta; - double invcurvature; - int imeth; - trackParameters(*seg,theta,invcurvature,imeth); - info.invcurvature = invcurvature; - - return info; + // if (m_debug) std::cout << " Seg Info Phi hits on pattern " << nphi << std::endl; + info.phiPatHits = 0; + info.patHits = nall; + if (nphi > 0) info.phiPatHits = nphi; + info.patPhi = patternPhi; + info.patTheta = patternTheta; + info.patMomentum = patternMomentum; + + info.nHots = nHots; + info.stationCode = code; + info.station = name; + + if (m_debug) std::cout << " Station name " << name << " Station code " << code << std::endl; + + double theta; + double invcurvature; + int imeth; + trackParameters(*seg, theta, invcurvature, imeth); + info.invcurvature = invcurvature; + + return info; } -void -Muon::MuonCurvedSegmentCombiner::trackParameters( Muon::MuonSegment& seg ,double &theta,double &invcurvature,int &imeth ){ +void +Muon::MuonCurvedSegmentCombiner::trackParameters(Muon::MuonSegment& seg, double& theta, double& invcurvature, + int& imeth) +{ // Determine track parameters in Rz plane (theta and inverse curvature) from the input segment - Amg::MatrixX Model(2,2);// H projection matrix PDG + Amg::MatrixX Model(2, 2); // H projection matrix PDG Model.setZero(); - Amg::MatrixX CovT(2,2); // Covariance or Track parameters here 2 + Amg::MatrixX CovT(2, 2); // Covariance or Track parameters here 2 CovT.setZero(); - Amg::MatrixX CovTI(2,2); // Covariance Inverse of Track parameters + Amg::MatrixX CovTI(2, 2); // Covariance Inverse of Track parameters CovTI.setZero(); - Amg::MatrixX V(2,1);// V = H^T Cov^-1 r Cov-1 = Covariance of measurements + Amg::MatrixX V(2, 1); // V = H^T Cov^-1 r Cov-1 = Covariance of measurements V.setZero(); - Amg::MatrixX T(2,1);// Track parameters + Amg::MatrixX T(2, 1); // Track parameters T.setZero(); - Amg::MatrixX ym(2,1); // Vector of measurememns + Amg::MatrixX ym(2, 1); // Vector of measurememns ym.setZero(); - Amg::MatrixX Res(2,1); // Vector of residuals + Amg::MatrixX Res(2, 1); // Vector of residuals Res.setZero(); double radius_cylinder = 4000.; - double z_cylinder = 6000.; - double z_end = 15000.; + double z_cylinder = 6000.; + double z_end = 15000.; double thetas = seg.globalDirection().theta(); - double rs = seg.globalPosition().perp(); - double zs = seg.globalPosition().z(); - double ers2 = 0.1*0.1; //error squared position - double ets2 = 0.0001*0.0001; // error squared angle - double sign = 1; - if ( zs < 0 ) sign = -1.; - - const Muon::MCSCSegmentInfo& info = m_segInfoMap[&seg]; - std::string st = info.station; - bool barrel = false; + double rs = seg.globalPosition().perp(); + double zs = seg.globalPosition().z(); + double ers2 = 0.1 * 0.1; // error squared position + double ets2 = 0.0001 * 0.0001; // error squared angle + double sign = 1; + if (zs < 0) sign = -1.; + + const Muon::MCSCSegmentInfo& info = m_segInfoMap[&seg]; + std::string st = info.station; + bool barrel = false; if (st[0] == 'B') barrel = true; if (barrel) { imeth = 0; - // Barrel Track Model Matrix - Model(0,0) = rs; - Model(0,1) = (rs-radius_cylinder)*(rs-radius_cylinder); - Model(1,0) = 1; - Model(1,1) = 2*(rs-radius_cylinder); - // Measurements ym - // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 - ym(0,0) = zs; - ym(1,0)= cos(thetas)/sin(thetas); + // Barrel Track Model Matrix + Model(0, 0) = rs; + Model(0, 1) = (rs - radius_cylinder) * (rs - radius_cylinder); + Model(1, 0) = 1; + Model(1, 1) = 2 * (rs - radius_cylinder); + // Measurements ym + // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 + ym(0, 0) = zs; + ym(1, 0) = cos(thetas) / sin(thetas); } else { imeth = 1; - // Forward Track Model Matrix - Model(0,0) = zs; - Model(0,1) = sign*(zs-sign*z_cylinder)*(zs-sign*z_cylinder); - Model(1,0) = 1; - Model(1,1) = 2*sign*(zs-sign*z_cylinder); + // Forward Track Model Matrix + Model(0, 0) = zs; + Model(0, 1) = sign * (zs - sign * z_cylinder) * (zs - sign * z_cylinder); + Model(1, 0) = 1; + Model(1, 1) = 2 * sign * (zs - sign * z_cylinder); if (fabs(zs) > z_end) { - Model(0,1) = -z_end*z_end + z_cylinder*z_cylinder + 2*zs*sign*(z_end-z_cylinder); - Model(1,1) = 2*(sign*z_end-sign*z_cylinder); - } - // Measurements ym - // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 - ym(0,0) = rs; - ym(1,0)= tan(thetas); - if (m_debug) std::cout << " Forward zs " << zs << std::endl; + Model(0, 1) = -z_end * z_end + z_cylinder * z_cylinder + 2 * zs * sign * (z_end - z_cylinder); + Model(1, 1) = 2 * (sign * z_end - sign * z_cylinder); + } + // Measurements ym + // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 + ym(0, 0) = rs; + ym(1, 0) = tan(thetas); + if (m_debug) std::cout << " Forward zs " << zs << std::endl; } - for(int i = 0; i <2 ; ++i ) { - V(i,0)= Model(0,i)*ym(0,0)/ers2 + Model(1,i)*ym(1,0)/ets2; - } + for (int i = 0; i < 2; ++i) { + V(i, 0) = Model(0, i) * ym(0, 0) / ers2 + Model(1, i) * ym(1, 0) / ets2; + } - for(int i = 0; i <2 ; ++i ) { - for(int j = 0; j <2 ; ++j ) { - CovTI(i,j) += Model(0,i)*Model(0,j)/ers2; - CovTI(i,j) += Model(1,i)*Model(1,j)/ets2; + for (int i = 0; i < 2; ++i) { + for (int j = 0; j < 2; ++j) { + CovTI(i, j) += Model(0, i) * Model(0, j) / ers2; + CovTI(i, j) += Model(1, i) * Model(1, j) / ets2; } } // Solution for Track parameters - CovT = CovTI.inverse(); - T = CovT*V; + CovT = CovTI.inverse(); + T = CovT * V; // calculate residuals and chi2 - for(int i = 0; i <2 ; ++i ) { - Res(i,0)= Model(i,0)*T(0,0) + Model(i,1)*T(1,0) - ym(i,0); - } + for (int i = 0; i < 2; ++i) { + Res(i, 0) = Model(i, 0) * T(0, 0) + Model(i, 1) * T(1, 0) - ym(i, 0); + } // double chi2 = Res(0,0)*Res(0,0)/ers2 + Res(1,0)*Res(1,0)/ets2; - // std::cout << " residuals matrix method z " << Res(0,0) << " cot(theta) " << Res(1,0) << " chi2 " << chi2 << std::endl; - // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; + // std::cout << " residuals matrix method z " << Res(0,0) << " cot(theta) " << Res(1,0) << " chi2 " << chi2 << + // std::endl; std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; - Amg::MatrixX ModelP(2,2);// Matrix for predicition H + Amg::MatrixX ModelP(2, 2); // Matrix for predicition H Model.setZero(); - Amg::MatrixX ModelPT(2,2);// Transposed + Amg::MatrixX ModelPT(2, 2); // Transposed ModelPT.setZero(); - for(int i = 0; i <2 ; ++i ) { - for(int j = 0; j <2 ; ++j ) { - ModelP(i,j)=Model(i,j); - ModelPT(i,j)=Model(j,i); + for (int i = 0; i < 2; ++i) { + for (int j = 0; j < 2; ++j) { + ModelP(i, j) = Model(i, j); + ModelPT(i, j) = Model(j, i); } } - Amg::MatrixX CovP(2,2);// Covariance of predicition + Amg::MatrixX CovP(2, 2); // Covariance of predicition CovP.setZero(); - CovP = ModelP*CovT*ModelPT; - - if ( m_debug ) std::cout << " covariance at measurement 00 " << CovP(0,0) << " 01 " << CovP(0,1) << " 10 " << CovP(1,0) << " 11 " << CovP(1,1) << std::endl; - if ( m_debug ) std::cout << " covariance at track 00 " << CovT(0,0) << " 01 " << CovT(0,1) << " 10 " << CovT(1,0) << " 11 " << CovT(1,1) << std::endl; + CovP = ModelP * CovT * ModelPT; + if (m_debug) + std::cout << " covariance at measurement 00 " << CovP(0, 0) << " 01 " << CovP(0, 1) << " 10 " << CovP(1, 0) + << " 11 " << CovP(1, 1) << std::endl; + if (m_debug) + std::cout << " covariance at track 00 " << CovT(0, 0) << " 01 " << CovT(0, 1) << " 10 " << CovT(1, 0) << " 11 " + << CovT(1, 1) << std::endl; if (imeth == 0) { - theta = atan2(1.,T(0,0)); - invcurvature = T(1,0)*sin(theta); + theta = atan2(1., T(0, 0)); + invcurvature = T(1, 0) * sin(theta); } else if (imeth == 1) { - theta = atan2(T(0,0),1.); - if (T(0,0) < 0) theta = atan2 ( -T(0,0),-1.); - invcurvature = T(1,0)*cos(theta); - } + theta = atan2(T(0, 0), 1.); + if (T(0, 0) < 0) theta = atan2(-T(0, 0), -1.); + invcurvature = T(1, 0) * cos(theta); + } // double dis = signedDistance(0.,theta,invcurvature,0.,rs,zs); // StandardAlgs standardAlgs; // double diss = standardAlgs.signedDistanceCurvedToHit(0.,theta,invcurvature,0.,rs,zs); - if(m_debug) std:: cout<< " Track parameters theta " << theta << " invcurvature " << invcurvature << " Momentum " << 0.1/invcurvature << std::endl; - - + if (m_debug) + std::cout << " Track parameters theta " << theta << " invcurvature " << invcurvature << " Momentum " + << 0.1 / invcurvature << std::endl; } -void -Muon::MuonCurvedSegmentCombiner::fit2SegmentsSL( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +void +Muon::MuonCurvedSegmentCombiner::fit2SegmentsSL(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, + Amg::VectorX& Pull) +{ // Fit 2 segments to a straightline (no Interaction Point constraint) - // Tracking matrices - Amg::MatrixX Model(4,2);// H projection matrix PDG + // Tracking matrices + Amg::MatrixX Model(4, 2); // H projection matrix PDG Model.setZero(); - Amg::MatrixX CovT(2,2); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; + Amg::MatrixX CovT(2, 2); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; CovT.setZero(); - Amg::MatrixX V(2,1);// V = H^T Cov^-1 r Cov-1 = Covariance of measurements + Amg::MatrixX V(2, 1); // V = H^T Cov^-1 r Cov-1 = Covariance of measurements V.setZero(); - Amg::MatrixX T(2,1);// Track parameters + Amg::MatrixX T(2, 1); // Track parameters T.setZero(); - Amg::MatrixX ym(4,1); // Vector of measurememns + Amg::MatrixX ym(4, 1); // Vector of measurememns ym.setZero(); - // Extrapolation Matrices - Amg::MatrixX Resi(4,1); // Residuals + // Extrapolation Matrices + Amg::MatrixX Resi(4, 1); // Residuals Resi.setZero(); // Geometry conventions - //int imeth; + // int imeth; - // First Segment - const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; - double thetas = seg.globalDirection().theta(); - double rs = seg.globalPosition().perp(); - double zs = seg.globalPosition().z(); + // First Segment + const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; + double thetas = seg.globalDirection().theta(); + double rs = seg.globalPosition().perp(); + double zs = seg.globalPosition().z(); // angular resolution double era1 = 0.0002; - if( info1.nMult1 == 0 || info1.nMult2 == 0 ) era1 = 0.002; + if (info1.nMult1 == 0 || info1.nMult2 == 0) era1 = 0.002; if (info1.nCsc > 0) era1 = 0.002; // Second Segment - const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; - double thetase = sege.globalDirection().theta(); - if (m_debug) std::cout << " thetase " << thetase <<std::endl; + const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; + double thetase = sege.globalDirection().theta(); + if (m_debug) std::cout << " thetase " << thetase << std::endl; double rse = sege.globalPosition().perp(); double zse = sege.globalPosition().z(); - if (m_doCosmics) { // translate line to IP for cosmics - double dist = sqrt((rse-rs)*(rse-rs)+(zse-zs)*(zse-zs)); - int is = 1; - if(sege.globalPosition().y() > seg.globalPosition().y()) is = -1; - double phiSegments = atan2(is*sege.globalPosition().y()-is*seg.globalPosition().y(),is*sege.globalPosition().x()-is*seg.globalPosition().x()); - double dphi = phiSegments - seg.globalDirection().phi(); - double dphie = phiSegments - sege.globalDirection().phi(); - if(m_debug) std::cout << " phiSegments " << phiSegments << " segment phi " << sege.globalDirection().phi() << " dist " << dist << " dphi " << dphi << " dphie " << dphie << std::endl; - - rse = sege.globalPosition().x() * std::cos(sege.globalDirection().phi()) + sege.globalPosition().y() * std::sin(sege.globalDirection().phi()); - rs = seg.globalPosition().x() * std::cos(seg.globalDirection().phi()) + seg.globalPosition().y() * std::sin(seg.globalDirection().phi()); - if(fabs(dphi)>0.5||fabs(dphie)>0.5) { -// Phi direction unreliable - rse = sege.globalPosition().x() * std::cos(phiSegments) + sege.globalPosition().y() * std::sin(phiSegments); - rs = seg.globalPosition().x() * std::cos(phiSegments) + seg.globalPosition().y() * std::sin(phiSegments); - if(m_debug) std::cout << " Phi direction Unreliable " << std::endl; - } + if (m_doCosmics) { // translate line to IP for cosmics + double dist = sqrt((rse - rs) * (rse - rs) + (zse - zs) * (zse - zs)); + int is = 1; + if (sege.globalPosition().y() > seg.globalPosition().y()) is = -1; + double phiSegments = atan2(is * sege.globalPosition().y() - is * seg.globalPosition().y(), + is * sege.globalPosition().x() - is * seg.globalPosition().x()); + double dphi = phiSegments - seg.globalDirection().phi(); + double dphie = phiSegments - sege.globalDirection().phi(); + if (m_debug) + std::cout << " phiSegments " << phiSegments << " segment phi " << sege.globalDirection().phi() << " dist " + << dist << " dphi " << dphi << " dphie " << dphie << std::endl; + + rse = sege.globalPosition().x() * std::cos(sege.globalDirection().phi()) + + sege.globalPosition().y() * std::sin(sege.globalDirection().phi()); + rs = seg.globalPosition().x() * std::cos(seg.globalDirection().phi()) + + seg.globalPosition().y() * std::sin(seg.globalDirection().phi()); + if (fabs(dphi) > 0.5 || fabs(dphie) > 0.5) { + // Phi direction unreliable + rse = sege.globalPosition().x() * std::cos(phiSegments) + sege.globalPosition().y() * std::sin(phiSegments); + rs = seg.globalPosition().x() * std::cos(phiSegments) + seg.globalPosition().y() * std::sin(phiSegments); + if (m_debug) std::cout << " Phi direction Unreliable " << std::endl; + } } double era2 = 0.0002; - if( info2.nMult1 == 0 || info2.nMult2 == 0 ) era2 = 0.002; + if (info2.nMult1 == 0 || info2.nMult2 == 0) era2 = 0.002; if (info2.nCsc > 0) era2 = 0.002; - // Get momenta + // Get momenta double ic1 = info1.invcurvature; double ic2 = info2.invcurvature; - if (m_doCosmics) ic1 = 1./15000.; - if (m_doCosmics) ic2 = 1./15000.; - double scf = 20*fabs(ic1)*50000.; - if (fabs(ic2) > fabs(ic1) ) scf = 20*fabs(ic2)*50000.; - if (scf < 1. ) scf = 1.; - if (scf > 100. ) scf = 100.; - if (m_debug) std::cout << " error scaling in SL fit " << scf << std::endl; - - std::string st1 = info1.station; - std::string st2 = info2.station; - bool barrel = false; - if (st1[0] == 'B' || st2[0] == 'B' ) barrel = true; - -// additional error scaling - double scfn = 0.; + if (m_doCosmics) ic1 = 1. / 15000.; + if (m_doCosmics) ic2 = 1. / 15000.; + double scf = 20 * fabs(ic1) * 50000.; + if (fabs(ic2) > fabs(ic1)) scf = 20 * fabs(ic2) * 50000.; + if (scf < 1.) scf = 1.; + if (scf > 100.) scf = 100.; + if (m_debug) std::cout << " error scaling in SL fit " << scf << std::endl; + + std::string st1 = info1.station; + std::string st2 = info2.station; + bool barrel = false; + if (st1[0] == 'B' || st2[0] == 'B') barrel = true; + + // additional error scaling + double scfn = 0.; double phiHitScale = 1.; - if ( info1.phiPatHits == 0 || info2.phiPatHits == 0 ) phiHitScale = 2.; - // Barrel - Endcap - if ( (st1[0] == 'E' && st2[0] == 'B' ) || (st2[0] == 'E' && st1[0] == 'B' ) ) scfn = phiHitScale*25.; + if (info1.phiPatHits == 0 || info2.phiPatHits == 0) phiHitScale = 2.; + // Barrel - Endcap + if ((st1[0] == 'E' && st2[0] == 'B') || (st2[0] == 'E' && st1[0] == 'B')) scfn = phiHitScale * 25.; // Small - Large - if ( st1[2] != st2[2] ) scfn = phiHitScale*25.; - // Extended - if ( st1[1] == 'E' || st2[1] == 'E' ) scfn = phiHitScale*25.; + if (st1[2] != st2[2]) scfn = phiHitScale * 25.; + // Extended + if (st1[1] == 'E' || st2[1] == 'E') scfn = phiHitScale * 25.; // Error definitions // double scf = 1; // pt = 100 GeV scf = 1; pt 5 GeV scf = 20*20 - double ers2 = 0.1*0.1+scf*scf+scfn*scfn; //error squared position - double ets21 = era1*era1 + 0.002*0.002*(scf*scf+scfn*scfn); // error squared angle - double ets22 = era2*era2 + 0.002*0.002*(scf*scf+scfn+scfn); // error squared angle + double ers2 = 0.1 * 0.1 + scf * scf + scfn * scfn; // error squared position + double ets21 = era1 * era1 + 0.002 * 0.002 * (scf * scf + scfn * scfn); // error squared angle + double ets22 = era2 * era2 + 0.002 * 0.002 * (scf * scf + scfn + scfn); // error squared angle // double sign = 1; // if ( zs < 0 ) sign = -1.; if (m_debug) std::cout << " Fit2SegmentsSL Nofield " << std::endl; if (barrel) { - //imeth = 0; - // Barrel Track Model Matrix - Model(0,0) = 1.; - Model(0,1) = rs; - Model(1,1) = 1.; - Model(2,0) = 1.; - Model(2,1) = rse; - Model(3,1) = 1.; - // Measurements ym - // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 - ym(0,0) = zs; - ym(1,0)= cos(thetas)/sin(thetas); - ym(2,0) = zse; - ym(3,0)= cos(thetase)/sin(thetase); + // imeth = 0; + // Barrel Track Model Matrix + Model(0, 0) = 1.; + Model(0, 1) = rs; + Model(1, 1) = 1.; + Model(2, 0) = 1.; + Model(2, 1) = rse; + Model(3, 1) = 1.; + // Measurements ym + // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 + ym(0, 0) = zs; + ym(1, 0) = cos(thetas) / sin(thetas); + ym(2, 0) = zse; + ym(3, 0) = cos(thetase) / sin(thetase); } else { - //imeth = 1; + // imeth = 1; if (m_debug) std::cout << " forward fit " << cos(thetas) << std::endl; - // Forward Track Model Matrix - Model(0,0) = 1.; - Model(0,1) = zs; - Model(1,1) = 1.; - Model(2,0) = 1.; - Model(2,1) = zse; - Model(3,1) = 1.; - // Measurements ym - // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 - ym(0,0) = rs; - ym(1,0)= tan(thetas); - ym(2,0) = rse; - ym(3,0)= tan(thetase); - // std::cout << " Forward zs " << zs << std::endl; + // Forward Track Model Matrix + Model(0, 0) = 1.; + Model(0, 1) = zs; + Model(1, 1) = 1.; + Model(2, 0) = 1.; + Model(2, 1) = zse; + Model(3, 1) = 1.; + // Measurements ym + // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 + ym(0, 0) = rs; + ym(1, 0) = tan(thetas); + ym(2, 0) = rse; + ym(3, 0) = tan(thetase); + // std::cout << " Forward zs " << zs << std::endl; + } + if (m_debug) + std::cout << " distance segments " << sqrt((zs - zse) * (zs - zse) + (rs - rse) * (rs - rse)) << std::endl; + for (int i = 0; i < 2; ++i) { + V(i, 0) = Model(0, i) * ym(0, 0) / ers2 + Model(1, i) * ym(1, 0) / ets21 + Model(2, i) * ym(2, 0) / ers2 + + Model(3, i) * ym(3, 0) / ets22; } - if (m_debug) std::cout << " distance segments " << sqrt((zs-zse)*(zs-zse)+(rs-rse)*(rs-rse))<< std::endl; - for(int i = 0; i <2 ; ++i ) { - V(i,0)= Model(0,i)*ym(0,0)/ers2 + Model(1,i)*ym(1,0)/ets21 - + Model(2,i)*ym(2,0)/ers2 + Model(3,i)*ym(3,0)/ets22; - } - Amg::MatrixX CovTI(2,2); // Covariance Inverse of Track parameters + Amg::MatrixX CovTI(2, 2); // Covariance Inverse of Track parameters CovTI.setZero(); - for(int i = 0; i <2 ; ++i ) { - for(int j = 0; j <2 ; ++j ) { - CovTI(i,j) += Model(0,i)*Model(0,j)/ers2; - CovTI(i,j) += Model(1,i)*Model(1,j)/ets21; - CovTI(i,j) += Model(2,i)*Model(2,j)/ers2; - CovTI(i,j) += Model(3,i)*Model(3,j)/ets22; + for (int i = 0; i < 2; ++i) { + for (int j = 0; j < 2; ++j) { + CovTI(i, j) += Model(0, i) * Model(0, j) / ers2; + CovTI(i, j) += Model(1, i) * Model(1, j) / ets21; + CovTI(i, j) += Model(2, i) * Model(2, j) / ers2; + CovTI(i, j) += Model(3, i) * Model(3, j) / ets22; } } // Solution for Track parameters - CovT = CovTI.inverse(); + CovT = CovTI.inverse(); // std::cout << " ierr " << ierr << std::endl; - T = CovT*V; - // std::cout << " covariance at track 00 " << CovT(0,0) << " 01 " << CovT(0,1) << " 11 " << CovT(1,1) << std::endl; - // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; + T = CovT * V; + // std::cout << " covariance at track 00 " << CovT(0,0) << " 01 " << CovT(0,1) << " 11 " << CovT(1,1) << + // std::endl; std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; - //double theta=0.; + // double theta=0.; // if (imeth == 0) { // theta = atan2(1.,T(1,0)); // } else if (imeth == 1) { // theta = atan(T(1,0)); - // } + // } // calculate residuals and chi2 - for(int i = 0; i <4 ; ++i ) { - Resi(i,0)= Model(i,0)*T(0,0) + Model(i,1)*T(1,0) - ym(i,0); - } - double chi2 = Resi(0,0)*Resi(0,0)/ers2 + Resi(1,0)*Resi(1,0)/ets21 - + Resi(2,0)*Resi(2,0)/ers2 + Resi(3,0)*Resi(3,0)/ets22; - - if (m_debug) std::cout << " resi 00 " << Resi(0,0) << " chi2 " << chi2 << std::endl; + for (int i = 0; i < 4; ++i) { + Resi(i, 0) = Model(i, 0) * T(0, 0) + Model(i, 1) * T(1, 0) - ym(i, 0); + } + double chi2 = Resi(0, 0) * Resi(0, 0) / ers2 + Resi(1, 0) * Resi(1, 0) / ets21 + Resi(2, 0) * Resi(2, 0) / ers2 + + Resi(3, 0) * Resi(3, 0) / ets22; + if (m_debug) std::cout << " resi 00 " << Resi(0, 0) << " chi2 " << chi2 << std::endl; - Res = Amg::VectorX(4); + Res = Amg::VectorX(4); Res.setZero(); - for(int i = 0; i <4 ; ++i ) { - Res[i]= Resi(i,0); - } + for (int i = 0; i < 4; ++i) { + Res[i] = Resi(i, 0); + } - Pull = Amg::VectorX(4); + Pull = Amg::VectorX(4); Pull.setZero(); - // do scaling - bool toobig = false; - for(int i = 0; i <4 ; ++i ) { - if ( i==0 ) Pull[i] = Res[i]/sqrt(ers2); - if ( i==1 ) Pull[i] = Res[i]/sqrt(ets21); - if ( i==2 ) Pull[i] = Res[i]/sqrt(ers2); - if ( i==3 ) Pull[i] = Res[i]/sqrt(ets22); - if ( fabs( Pull[i] ) > 5 ) toobig = true; + // do scaling + bool toobig = false; + for (int i = 0; i < 4; ++i) { + if (i == 0) Pull[i] = Res[i] / sqrt(ers2); + if (i == 1) Pull[i] = Res[i] / sqrt(ets21); + if (i == 2) Pull[i] = Res[i] / sqrt(ers2); + if (i == 3) Pull[i] = Res[i] / sqrt(ets22); + if (fabs(Pull[i]) > 5) toobig = true; } if (toobig && m_debug) { - std::cout << " SL Pull too BIG " << " rad pos1 " << rs << " rad pos2 " << rse << " ang1 " << thetas << " ang2 " << thetase << std::endl; + std::cout << " SL Pull too BIG " + << " rad pos1 " << rs << " rad pos2 " << rse << " ang1 " << thetas << " ang2 " << thetase + << std::endl; std::string st1 = info1.station; std::string st2 = info2.station; - const Amg::Vector3D& d1 = seg.globalDirection(); - const Amg::Vector3D& d2 = sege.globalDirection(); - std::cout << st1 << " " << st2 << " diff phi " << d1.x()*d2.y() - d1.y()*d2.x() << std::endl ; + const Amg::Vector3D& d1 = seg.globalDirection(); + const Amg::Vector3D& d2 = sege.globalDirection(); + std::cout << st1 << " " << st2 << " diff phi " << d1.x() * d2.y() - d1.y() * d2.x() << std::endl; } - if (m_debug) std::cout << " Fit2SegmentsSL: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] << " pull 1 " << Pull[1] << std::endl; - if (m_debug) std::cout << " Fit2SegmentsSL: Residual 2 " << Res[2] << " pull 2 " << Pull[2] << " Residual 3 " << Res[3] << " pull 3 " << Pull[3] << std::endl; - + if (m_debug) + std::cout << " Fit2SegmentsSL: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] + << " pull 1 " << Pull[1] << std::endl; + if (m_debug) + std::cout << " Fit2SegmentsSL: Residual 2 " << Res[2] << " pull 2 " << Pull[2] << " Residual 3 " << Res[3] + << " pull 3 " << Pull[3] << std::endl; } - -void -Muon::MuonCurvedSegmentCombiner::fit2Segments( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +void +Muon::MuonCurvedSegmentCombiner::fit2Segments(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, + Amg::VectorX& Pull) +{ - // Fit 2 segments to one track and determine residuals and pulls - // Tracking matrices - Amg::MatrixX Model(5,3);// H projection matrix PDG + // Fit 2 segments to one track and determine residuals and pulls + + // Tracking matrices + Amg::MatrixX Model(5, 3); // H projection matrix PDG Model.setZero(); - Amg::MatrixX CovT(3,3); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; + Amg::MatrixX CovT(3, 3); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; CovT.setZero(); - Amg::MatrixX V(3,1);// V = H^T Cov^-1 r Cov-1 = Covariance of measurements + Amg::MatrixX V(3, 1); // V = H^T Cov^-1 r Cov-1 = Covariance of measurements V.setZero(); - Amg::MatrixX T(3,1);// Track parameters + Amg::MatrixX T(3, 1); // Track parameters T.setZero(); - Amg::MatrixX ym(5,1); // Vector of measurememns + Amg::MatrixX ym(5, 1); // Vector of measurememns ym.setZero(); - // Extrapolation Matrices - Amg::MatrixX Resi(5,1); // Residuals + // Extrapolation Matrices + Amg::MatrixX Resi(5, 1); // Residuals Resi.setZero(); - // Geometry conventions + // Geometry conventions double radius_cylinder = 4000.; - double z_cylinder = 6000.; - double z_end = 15000.; - double cos_barrel = std::cos(std::atan2(11430.,14000.)); - int imeth; - - // First Segment - const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; - double thetas = seg.globalDirection().theta(); - double rs = seg.globalPosition().perp(); - double zs = seg.globalPosition().z(); - // double phi = seg.globalDirection().phi(); + double z_cylinder = 6000.; + double z_end = 15000.; + double cos_barrel = std::cos(std::atan2(11430., 14000.)); + int imeth; + + // First Segment + const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; + double thetas = seg.globalDirection().theta(); + double rs = seg.globalPosition().perp(); + double zs = seg.globalPosition().z(); + // double phi = seg.globalDirection().phi(); // double phisp = atan2( seg.globalPosition().y(), seg.globalPosition().x()); - double thetasp = atan2(rs,zs); + double thetasp = atan2(rs, zs); // angular resolution double era1 = 0.0002; - if( info1.nMult1 == 0 || info1.nMult2 == 0 ) era1 = 0.002; + if (info1.nMult1 == 0 || info1.nMult2 == 0) era1 = 0.002; if (info1.nCsc > 0) era1 = 0.002; // Second Segment - const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; - double thetase = sege.globalDirection().theta(); - double rse = sege.globalPosition().perp(); - double zse = sege.globalPosition().z(); - // double phie = sege.globalDirection().phi(); + const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; + double thetase = sege.globalDirection().theta(); + double rse = sege.globalPosition().perp(); + double zse = sege.globalPosition().z(); + // double phie = sege.globalDirection().phi(); // double phispe = atan2( sege.globalPosition().y(), sege.globalPosition().x()); - double thetaspe = atan2(rse,zse); + double thetaspe = atan2(rse, zse); double era2 = 0.0002; - if( info2.nMult1 == 0 || info2.nMult2 == 0 ) era2 = 0.002; + if (info2.nMult1 == 0 || info2.nMult2 == 0) era2 = 0.002; if (info2.nCsc > 0) era2 = 0.002; - // Get momenta + // Get momenta double ic1 = info1.invcurvature; double ic2 = info2.invcurvature; - double scf = 20*fabs(ic1)*50000.; - if (fabs(ic2) > fabs(ic1) ) scf = 20*fabs(ic2)*50000.; - if (scf < 1. ) scf = 1.; - if (scf > 100. ) scf = 100.; - if (m_debug) std::cout << " error scaling in Curved fit " << scf << std::endl; - if (std::abs(std::cos(thetasp))>cos_barrel || std::abs(std::cos(thetaspe))>cos_barrel ) scf = 2*scf; - - std::string st1 = info1.station; - std::string st2 = info2.station; - bool barrel = false; - if (st1[0] == 'B' || st2[0] == 'B' ) barrel = true; - -// additional error scaling - double scfn = 0.; + double scf = 20 * fabs(ic1) * 50000.; + if (fabs(ic2) > fabs(ic1)) scf = 20 * fabs(ic2) * 50000.; + if (scf < 1.) scf = 1.; + if (scf > 100.) scf = 100.; + if (m_debug) std::cout << " error scaling in Curved fit " << scf << std::endl; + if (std::abs(std::cos(thetasp)) > cos_barrel || std::abs(std::cos(thetaspe)) > cos_barrel) scf = 2 * scf; + + std::string st1 = info1.station; + std::string st2 = info2.station; + bool barrel = false; + if (st1[0] == 'B' || st2[0] == 'B') barrel = true; + + // additional error scaling + double scfn = 0.; double phiHitScale = 1.; - if ( info1.phiPatHits == 0 || info2.phiPatHits == 0 ) phiHitScale = 2.; - // Barrel - Endcap - if ( (st1[0] == 'E' && st2[0] == 'B' ) || (st2[0] == 'E' && st1[0] == 'B' ) ) scfn = phiHitScale*25.; + if (info1.phiPatHits == 0 || info2.phiPatHits == 0) phiHitScale = 2.; + // Barrel - Endcap + if ((st1[0] == 'E' && st2[0] == 'B') || (st2[0] == 'E' && st1[0] == 'B')) scfn = phiHitScale * 25.; // Small - Large - if ( st1[2] != st2[2] ) scfn = phiHitScale*25.; - // Extended - if ( st1[1] == 'E' || st2[1] == 'E' ) scfn = phiHitScale*25.; + if (st1[2] != st2[2]) scfn = phiHitScale * 25.; + // Extended + if (st1[1] == 'E' || st2[1] == 'E') scfn = phiHitScale * 25.; // Error definitions // double scf = 1; // pt = 100 GeV scf = 1; pt 5 GeV scf = 20*20 - double ers2 = 0.1*0.1+scf*scf+scfn*scfn; //error squared position - double ebs2 = 50*50*fabs(sin(thetas)*sin(thetase))+ers2; //error squared beam position - double ets21 = era1*era1 + 0.002*0.002*(scf*scf+scfn*scfn); // error squared angle - double ets22 = era2*era2 + 0.002*0.002*(scf*scf+scfn+scfn); // error squared angle + double ers2 = 0.1 * 0.1 + scf * scf + scfn * scfn; // error squared position + double ebs2 = 50 * 50 * fabs(sin(thetas) * sin(thetase)) + ers2; // error squared beam position + double ets21 = era1 * era1 + 0.002 * 0.002 * (scf * scf + scfn * scfn); // error squared angle + double ets22 = era2 * era2 + 0.002 * 0.002 * (scf * scf + scfn + scfn); // error squared angle double sign = 1; - if ( zs < 0 ) sign = -1.; + if (zs < 0) sign = -1.; if (barrel) { imeth = 0; - // Barrel Track Model Matrix - Model(0,0) = 1.; - Model(1,0) = 1.; - Model(1,1) = rs; - Model(1,2) = (rs-radius_cylinder)*(rs-radius_cylinder); - Model(2,1) = 1.; - Model(2,2) = 2*(rs-radius_cylinder); - Model(3,0) = 1.; - Model(3,1) = rse; - Model(3,2) = (rse-radius_cylinder)*(rse-radius_cylinder); - Model(4,1) = 1.; - Model(4,2) = 2*(rse-radius_cylinder); - // Measurements ym - // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 - ym(0,0) = 0.; - ym(1,0) = zs; - ym(2,0)= cos(thetas)/sin(thetas); - ym(3,0) = zse; - ym(4,0)= cos(thetase)/sin(thetase); + // Barrel Track Model Matrix + Model(0, 0) = 1.; + Model(1, 0) = 1.; + Model(1, 1) = rs; + Model(1, 2) = (rs - radius_cylinder) * (rs - radius_cylinder); + Model(2, 1) = 1.; + Model(2, 2) = 2 * (rs - radius_cylinder); + Model(3, 0) = 1.; + Model(3, 1) = rse; + Model(3, 2) = (rse - radius_cylinder) * (rse - radius_cylinder); + Model(4, 1) = 1.; + Model(4, 2) = 2 * (rse - radius_cylinder); + // Measurements ym + // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 + ym(0, 0) = 0.; + ym(1, 0) = zs; + ym(2, 0) = cos(thetas) / sin(thetas); + ym(3, 0) = zse; + ym(4, 0) = cos(thetase) / sin(thetase); } else { imeth = 1; if (m_debug) std::cout << " forward fit " << cos(thetas) << std::endl; - // Forward Track Model Matrix - Model(0,0) = 1.; - Model(1,0) = 1.; - Model(1,1) = zs; - Model(1,2) = sign*(zs-sign*z_cylinder)*(zs-sign*z_cylinder); - Model(2,1) = 1; - Model(2,2) = sign*2*(zs-sign*z_cylinder); - Model(3,0) = 1.; - Model(3,1) = zse; - Model(3,2) = sign*(zse-sign*z_cylinder)*(zse-sign*z_cylinder); - Model(4,1) = 1; - Model(4,2) = sign*2*(zse-sign*z_cylinder); - - if (fabs(zs) > z_end+2000) { - Model(1,2) = sign*(-z_end*z_end + z_cylinder*z_cylinder + 2*zs*sign*(z_end-z_cylinder) - + (zs-sign*z_end)*(zs-sign*z_end)/5.); - Model(2,2) = sign*(2*(sign*z_end-sign*z_cylinder) - + (zs-sign*z_end)/5.); + // Forward Track Model Matrix + Model(0, 0) = 1.; + Model(1, 0) = 1.; + Model(1, 1) = zs; + Model(1, 2) = sign * (zs - sign * z_cylinder) * (zs - sign * z_cylinder); + Model(2, 1) = 1; + Model(2, 2) = sign * 2 * (zs - sign * z_cylinder); + Model(3, 0) = 1.; + Model(3, 1) = zse; + Model(3, 2) = sign * (zse - sign * z_cylinder) * (zse - sign * z_cylinder); + Model(4, 1) = 1; + Model(4, 2) = sign * 2 * (zse - sign * z_cylinder); + + if (fabs(zs) > z_end + 2000) { + Model(1, 2) = sign + * (-z_end * z_end + z_cylinder * z_cylinder + 2 * zs * sign * (z_end - z_cylinder) + + (zs - sign * z_end) * (zs - sign * z_end) / 5.); + Model(2, 2) = sign * (2 * (sign * z_end - sign * z_cylinder) + (zs - sign * z_end) / 5.); + } + if (fabs(zse) > z_end + 2000) { + Model(3, 2) = sign + * (-z_end * z_end + z_cylinder * z_cylinder + 2 * zse * sign * (z_end - z_cylinder) + + (zse - sign * z_end) * (zse - sign * z_end) / 5.); + Model(4, 2) = sign * (2 * (sign * z_end - sign * z_cylinder) + (zse - sign * z_end) / 5.); } - if (fabs(zse) > z_end+2000) { - Model(3,2) = sign*(-z_end*z_end + z_cylinder*z_cylinder + 2*zse*sign*(z_end-z_cylinder) - + (zse-sign*z_end)*(zse-sign*z_end)/5.); - Model(4,2) = sign*(2*(sign*z_end-sign*z_cylinder) - + (zse-sign*z_end)/5.); - } - // Measurements ym - // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 - ym(0,0) = 0.; - ym(1,0) = rs; - ym(2,0)= tan(thetas); - ym(3,0) = rse; - ym(4,0)= tan(thetase); - - // std::cout << " Forward zs " << zs << std::endl; + // Measurements ym + // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 + ym(0, 0) = 0.; + ym(1, 0) = rs; + ym(2, 0) = tan(thetas); + ym(3, 0) = rse; + ym(4, 0) = tan(thetase); + + // std::cout << " Forward zs " << zs << std::endl; } - if (m_debug) std::cout << " distance segments " << sqrt((zs-zse)*(zs-zse)+(rs-rse)*(rs-rse))<< std::endl; + if (m_debug) + std::cout << " distance segments " << sqrt((zs - zse) * (zs - zse) + (rs - rse) * (rs - rse)) << std::endl; - for(int i = 0; i <3 ; ++i ) { - V(i,0)= Model(0,i)*ym(0,0)/ebs2 + Model(1,i)*ym(1,0)/ers2 + Model(2,i)*ym(2,0)/ets21 - + Model(3,i)*ym(3,0)/ers2 + Model(4,i)*ym(4,0)/ets22; - } + for (int i = 0; i < 3; ++i) { + V(i, 0) = Model(0, i) * ym(0, 0) / ebs2 + Model(1, i) * ym(1, 0) / ers2 + Model(2, i) * ym(2, 0) / ets21 + + Model(3, i) * ym(3, 0) / ers2 + Model(4, i) * ym(4, 0) / ets22; + } - Amg::MatrixX CovTI(3,3); // Covariance Inverse of Track parameters + Amg::MatrixX CovTI(3, 3); // Covariance Inverse of Track parameters CovTI.setZero(); - for(int i = 0; i <3 ; ++i ) { - for(int j = 0; j <3 ; ++j ) { - CovTI(i,j) += Model(0,i)*Model(0,j)/ebs2; - CovTI(i,j) += Model(1,i)*Model(1,j)/ers2; - CovTI(i,j) += Model(2,i)*Model(2,j)/ets21; - CovTI(i,j) += Model(3,i)*Model(3,j)/ers2; - CovTI(i,j) += Model(4,i)*Model(4,j)/ets22; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + CovTI(i, j) += Model(0, i) * Model(0, j) / ebs2; + CovTI(i, j) += Model(1, i) * Model(1, j) / ers2; + CovTI(i, j) += Model(2, i) * Model(2, j) / ets21; + CovTI(i, j) += Model(3, i) * Model(3, j) / ers2; + CovTI(i, j) += Model(4, i) * Model(4, j) / ets22; } } // Solution for Track parameters - CovT = CovTI.inverse(); - T = CovT*V; - // std::cout << " covariance at track 00 " << CovT(0,0) << " 11 " << CovT(1,1) << " 12 " << CovT(1,2) << " 22 " << CovT(2,2) << std::endl; + CovT = CovTI.inverse(); + T = CovT * V; + // std::cout << " covariance at track 00 " << CovT(0,0) << " 11 " << CovT(1,1) << " 12 " << CovT(1,2) << " 22 " << + // CovT(2,2) << std::endl; - double theta=0.; double invcurvature=0.; + double theta = 0.; + double invcurvature = 0.; if (imeth == 0) { - theta = atan2(1.,T(1,0)); - invcurvature = T(2,0)*sin(theta); + theta = atan2(1., T(1, 0)); + invcurvature = T(2, 0) * sin(theta); } else if (imeth == 1) { - theta = atan2(1.,1./T(1,0)); - invcurvature = -T(2,0)*fabs(cos(theta)); - } + theta = atan2(1., 1. / T(1, 0)); + invcurvature = -T(2, 0) * fabs(cos(theta)); + } - if (m_debug) std::cout << " Momentum in MeV " << (1./invcurvature)/10. << " theta fit " << theta << std::endl; + if (m_debug) std::cout << " Momentum in MeV " << (1. / invcurvature) / 10. << " theta fit " << theta << std::endl; // calculate residuals and chi2 - for(int i = 0; i <5 ; ++i ) { - Resi(i,0)= Model(i,0)*T(0,0) + Model(i,1)*T(1,0) + Model(i,2)*T(2,0) - ym(i,0); - } - double chi2 = Resi(0,0)*Resi(0,0)/ebs2 + Resi(1,0)*Resi(1,0)/ers2 + Resi(2,0)*Resi(2,0)/ets21 - + Resi(3,0)*Resi(3,0)/ers2 + Resi(4,0)*Resi(4,0)/ets22; - if (m_debug) std::cout << " resi 00 " << Resi(0,0) << " chi2 " << chi2 << std::endl; - // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; + for (int i = 0; i < 5; ++i) { + Resi(i, 0) = Model(i, 0) * T(0, 0) + Model(i, 1) * T(1, 0) + Model(i, 2) * T(2, 0) - ym(i, 0); + } + double chi2 = Resi(0, 0) * Resi(0, 0) / ebs2 + Resi(1, 0) * Resi(1, 0) / ers2 + Resi(2, 0) * Resi(2, 0) / ets21 + + Resi(3, 0) * Resi(3, 0) / ers2 + Resi(4, 0) * Resi(4, 0) / ets22; + if (m_debug) std::cout << " resi 00 " << Resi(0, 0) << " chi2 " << chi2 << std::endl; + // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; // Reshuffle residuals Res(0) -> segment position in Model (1,x) // Res(1) -> segment angle in Model (2,x) - Res = Amg::VectorX(4); + Res = Amg::VectorX(4); Res.setZero(); - for(int i = 1; i <5 ; ++i ) { - Res[i-1]= Resi(i,0); - } + for (int i = 1; i < 5; ++i) { + Res[i - 1] = Resi(i, 0); + } - Pull = Amg::VectorX(4); + Pull = Amg::VectorX(4); Pull.setZero(); - bool toobig = false; - for(int i = 0; i <4 ; ++i ) { - if ( i==0 ) Pull[i] = Res[i]/sqrt(ers2); - if ( i==1 ) Pull[i] = Res[i]/sqrt(ets21); - if ( i==2 ) Pull[i] = Res[i]/sqrt(ers2); - if ( i==3 ) Pull[i] = Res[i]/sqrt(ets22); - if ( fabs( Pull[i] ) > 5 ) toobig = true; + bool toobig = false; + for (int i = 0; i < 4; ++i) { + if (i == 0) Pull[i] = Res[i] / sqrt(ers2); + if (i == 1) Pull[i] = Res[i] / sqrt(ets21); + if (i == 2) Pull[i] = Res[i] / sqrt(ers2); + if (i == 3) Pull[i] = Res[i] / sqrt(ets22); + if (fabs(Pull[i]) > 5) toobig = true; } if (toobig && m_debug) { - std::cout << " Pull too BIGFIT " << " rad pos1 " << rs << " rad pos2 " << rse << " ang1 " << thetas << " ang2 " << thetase << std::endl; - double phisp = atan2( seg.globalPosition().y(), seg.globalPosition().x()); - double phispe = atan2( sege.globalPosition().y(), sege.globalPosition().x()); - std::cout << " z pos1 " << zs << " z pos2 " << zse << " phi pos 1 " << phisp << " phi pos 2 " << phispe << std::endl; - - const Amg::Vector3D& d1 = seg.globalDirection(); - const Amg::Vector3D& d2 = sege.globalDirection(); - std::cout << st1 << " " << st2 << " diff phi " << d1.x()*d2.y() - d1.y()*d2.x() << std::endl ; + std::cout << " Pull too BIGFIT " + << " rad pos1 " << rs << " rad pos2 " << rse << " ang1 " << thetas << " ang2 " << thetase + << std::endl; + double phisp = atan2(seg.globalPosition().y(), seg.globalPosition().x()); + double phispe = atan2(sege.globalPosition().y(), sege.globalPosition().x()); + std::cout << " z pos1 " << zs << " z pos2 " << zse << " phi pos 1 " << phisp << " phi pos 2 " << phispe + << std::endl; + + const Amg::Vector3D& d1 = seg.globalDirection(); + const Amg::Vector3D& d2 = sege.globalDirection(); + std::cout << st1 << " " << st2 << " diff phi " << d1.x() * d2.y() - d1.y() * d2.x() << std::endl; } - if (m_debug) std::cout << " Fit2Segments: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] << " pull 1 " << Pull[1] << std::endl; - if (m_debug) std::cout << " Fit2Segments: Residual 2 " << Res[2] << " pull 2 " << Pull[2] << " Residual 3 " << Res[3] << " pull 3 " << Pull[3] << std::endl; - if (m_debug) std::cout << " radius 1 " << ym(1,0) << " cottan theta 1 " << ym(2,0) << " radius 2 " << ym(3,0) - << " cottan theta 2 " << ym(4,0) << std::endl; - if (m_debug) std::cout << " radius fit 1 " << -(Res[0]+ym(1,0)) << " cottan theta fit 1 " << -(Res[1]+ym(2,0)) << " radius 2 fit " << -(Res[2]+ym(3,0)) - << " cottan theta 2 fit " << -(Res[3]+ym(4,0)) << std::endl; + if (m_debug) + std::cout << " Fit2Segments: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] + << " pull 1 " << Pull[1] << std::endl; + if (m_debug) + std::cout << " Fit2Segments: Residual 2 " << Res[2] << " pull 2 " << Pull[2] << " Residual 3 " << Res[3] + << " pull 3 " << Pull[3] << std::endl; + if (m_debug) + std::cout << " radius 1 " << ym(1, 0) << " cottan theta 1 " << ym(2, 0) << " radius 2 " << ym(3, 0) + << " cottan theta 2 " << ym(4, 0) << std::endl; + if (m_debug) + std::cout << " radius fit 1 " << -(Res[0] + ym(1, 0)) << " cottan theta fit 1 " << -(Res[1] + ym(2, 0)) + << " radius 2 fit " << -(Res[2] + ym(3, 0)) << " cottan theta 2 fit " << -(Res[3] + ym(4, 0)) + << std::endl; } -void Muon::MuonCurvedSegmentCombiner::fit2SegmentsC( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +void +Muon::MuonCurvedSegmentCombiner::fit2SegmentsC(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, + Amg::VectorX& Pull) +{ - // Fit two segments for cosmics with loose IP constraint and free curvature + // Fit two segments for cosmics with loose IP constraint and free curvature - // Tracking matrices - Amg::MatrixX Model(5,3);// H projection matrix PDG + // Tracking matrices + Amg::MatrixX Model(5, 3); // H projection matrix PDG Model.setZero(); - Amg::MatrixX CovT(3,3); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; + Amg::MatrixX CovT(3, 3); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; CovT.setZero(); - Amg::MatrixX V(3,1);// V = H^T Cov^-1 r Cov-1 = Covariance of measurements + Amg::MatrixX V(3, 1); // V = H^T Cov^-1 r Cov-1 = Covariance of measurements V.setZero(); - Amg::MatrixX T(3,1);// Track parameters + Amg::MatrixX T(3, 1); // Track parameters T.setZero(); - Amg::MatrixX ym(5,1); // Vector of measurememns + Amg::MatrixX ym(5, 1); // Vector of measurememns ym.setZero(); - // Extrapolation Matrices - Amg::MatrixX Resi(5,1); // Residuals + // Extrapolation Matrices + Amg::MatrixX Resi(5, 1); // Residuals Resi.setZero(); - // Geometry conventions + // Geometry conventions double radius_cylinder = 4000.; - double z_cylinder = 6000.; - double z_end = 15000.; - double cos_barrel = std::cos(std::atan2(11430.,14000.)); - int imeth; - - // First Segment - const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; - double thetas = seg.globalDirection().theta(); - double rs = seg.globalPosition().perp(); - double zs = seg.globalPosition().z(); - double thetasp = atan2(rs,zs); + double z_cylinder = 6000.; + double z_end = 15000.; + double cos_barrel = std::cos(std::atan2(11430., 14000.)); + int imeth; + + // First Segment + const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; + double thetas = seg.globalDirection().theta(); + double rs = seg.globalPosition().perp(); + double zs = seg.globalPosition().z(); + double thetasp = atan2(rs, zs); // angular resolution double era1 = 0.0002; - if( info1.nMult1 == 0 || info1.nMult2 == 0 ) era1 = 0.002; + if (info1.nMult1 == 0 || info1.nMult2 == 0) era1 = 0.002; if (info1.nCsc > 0) era1 = 0.002; // Second Segment - const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; - double thetase = sege.globalDirection().theta(); - double rse = sege.globalPosition().perp(); - double zse = sege.globalPosition().z(); - double thetaspe = atan2(rse,zse); - double era2 = 0.0002; - if( info2.nMult1 == 0 || info2.nMult2 == 0 ) era2 = 0.002; + const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; + double thetase = sege.globalDirection().theta(); + double rse = sege.globalPosition().perp(); + double zse = sege.globalPosition().z(); + double thetaspe = atan2(rse, zse); + double era2 = 0.0002; + if (info2.nMult1 == 0 || info2.nMult2 == 0) era2 = 0.002; if (info2.nCsc > 0) era2 = 0.002; double rsec = rse; - double rsc = rs; - - if (m_doCosmics) { // translate line to IP for cosmics - double dist = sqrt((rse-rs)*(rse-rs)+(zse-zs)*(zse-zs)); - int is = 1; - if(sege.globalPosition().y() > seg.globalPosition().y()) is = -1; - double phiSegments = atan2(is*sege.globalPosition().y()-is*seg.globalPosition().y(),is*sege.globalPosition().x()-is*seg.globalPosition().x()); - double dphi = phiSegments - seg.globalDirection().phi(); - double dphie = phiSegments - sege.globalDirection().phi(); - if(m_debug) std::cout << " phiSegments " << phiSegments << " segment phi " << sege.globalDirection().phi() << " dist " << dist << " dphi " << dphi << " dphie " << dphie << std::endl; - - rsec = sege.globalPosition().x() * std::cos(sege.globalDirection().phi()) + sege.globalPosition().y() * std::sin(sege.globalDirection().phi()); - rsc = seg.globalPosition().x() * std::cos(seg.globalDirection().phi()) + seg.globalPosition().y() * std::sin(seg.globalDirection().phi()); - if(fabs(dphi)>0.5||fabs(dphie)>0.5) { -// Phi direction unreliable - rsec = sege.globalPosition().x() * std::cos(phiSegments) + sege.globalPosition().y() * std::sin(phiSegments); - rsc = seg.globalPosition().x() * std::cos(phiSegments) + seg.globalPosition().y() * std::sin(phiSegments); - if(m_debug) std::cout << " Phi direction Unreliable " << std::endl; - } - + double rsc = rs; + + if (m_doCosmics) { // translate line to IP for cosmics + double dist = sqrt((rse - rs) * (rse - rs) + (zse - zs) * (zse - zs)); + int is = 1; + if (sege.globalPosition().y() > seg.globalPosition().y()) is = -1; + double phiSegments = atan2(is * sege.globalPosition().y() - is * seg.globalPosition().y(), + is * sege.globalPosition().x() - is * seg.globalPosition().x()); + double dphi = phiSegments - seg.globalDirection().phi(); + double dphie = phiSegments - sege.globalDirection().phi(); + if (m_debug) + std::cout << " phiSegments " << phiSegments << " segment phi " << sege.globalDirection().phi() << " dist " + << dist << " dphi " << dphi << " dphie " << dphie << std::endl; + + rsec = sege.globalPosition().x() * std::cos(sege.globalDirection().phi()) + + sege.globalPosition().y() * std::sin(sege.globalDirection().phi()); + rsc = seg.globalPosition().x() * std::cos(seg.globalDirection().phi()) + + seg.globalPosition().y() * std::sin(seg.globalDirection().phi()); + if (fabs(dphi) > 0.5 || fabs(dphie) > 0.5) { + // Phi direction unreliable + rsec = + sege.globalPosition().x() * std::cos(phiSegments) + sege.globalPosition().y() * std::sin(phiSegments); + rsc = seg.globalPosition().x() * std::cos(phiSegments) + seg.globalPosition().y() * std::sin(phiSegments); + if (m_debug) std::cout << " Phi direction Unreliable " << std::endl; + } } - double invcurvature=1./15000.; - for (int iter = 0 ; iter <2 ;++iter ){ + double invcurvature = 1. / 15000.; + for (int iter = 0; iter < 2; ++iter) { double scf = 1; - if (iter == 0) scf = 20*fabs(invcurvature)*50000; - if (scf < 1. ) scf = 1.; - if (scf > 100. ) scf = 100.; - if (m_debug) std::cout << " error scaling in Cosmics Curved fit " << scf << std::endl; - if (std::abs(std::cos(thetasp))>cos_barrel || std::abs(std::cos(thetaspe))>cos_barrel ) scf = 2*scf; - - std::string st1 = info1.station; - std::string st2 = info2.station; - bool barrel = false; - if (st1[0] == 'B' || st2[0] == 'B' ) barrel = true; - -// additional error scaling - double scfn = 0.; + if (iter == 0) scf = 20 * fabs(invcurvature) * 50000; + if (scf < 1.) scf = 1.; + if (scf > 100.) scf = 100.; + if (m_debug) std::cout << " error scaling in Cosmics Curved fit " << scf << std::endl; + if (std::abs(std::cos(thetasp)) > cos_barrel || std::abs(std::cos(thetaspe)) > cos_barrel) scf = 2 * scf; + + std::string st1 = info1.station; + std::string st2 = info2.station; + bool barrel = false; + if (st1[0] == 'B' || st2[0] == 'B') barrel = true; + + // additional error scaling + double scfn = 0.; double phiHitScale = 1.; - if ( info1.phiPatHits == 0 || info2.phiPatHits == 0 ) phiHitScale = 2.; - // Barrel - Endcap - if ( (st1[0] == 'E' && st2[0] == 'B' ) || (st2[0] == 'E' && st1[0] == 'B' ) ) scfn = phiHitScale*25.; - // Small - Large - if ( st1[2] != st2[2] ) scfn = phiHitScale*25.; - // Extended - if ( st1[1] == 'E' || st2[1] == 'E' ) scfn = phiHitScale*25.; - - // Error definitions - // double scf = 1; // pt = 100 GeV scf = 1; pt 5 GeV scf = 20*20 - double ers2 = 0.1*0.1+scf*scf+scfn*scfn; //error squared position - double ebs2 = 10000.*10000.; //error squared beam position - double ets21 = era1*era1 + 0.002*0.002*(scf*scf+scfn*scfn); // error squared angle - double ets22 = era2*era2 + 0.002*0.002*(scf*scf+scfn+scfn); // error squared angle + if (info1.phiPatHits == 0 || info2.phiPatHits == 0) phiHitScale = 2.; + // Barrel - Endcap + if ((st1[0] == 'E' && st2[0] == 'B') || (st2[0] == 'E' && st1[0] == 'B')) scfn = phiHitScale * 25.; + // Small - Large + if (st1[2] != st2[2]) scfn = phiHitScale * 25.; + // Extended + if (st1[1] == 'E' || st2[1] == 'E') scfn = phiHitScale * 25.; + + // Error definitions + // double scf = 1; // pt = 100 GeV scf = 1; pt 5 GeV scf = 20*20 + double ers2 = 0.1 * 0.1 + scf * scf + scfn * scfn; // error squared position + double ebs2 = 10000. * 10000.; // error squared beam position + double ets21 = era1 * era1 + 0.002 * 0.002 * (scf * scf + scfn * scfn); // error squared angle + double ets22 = era2 * era2 + 0.002 * 0.002 * (scf * scf + scfn + scfn); // error squared angle double sign = 1; - if ( zs < 0 ) sign = -1.; + if (zs < 0) sign = -1.; if (barrel) { imeth = 0; - // Barrel Track Model Matrix - Model(0,0) = 1.; - Model(1,0) = 1.; - Model(1,1) = rsc; - Model(1,2) = (rs-radius_cylinder)*(rs-radius_cylinder); - Model(2,1) = 1.; - Model(2,2) = 2*(rs-radius_cylinder); - Model(3,0) = 1.; - Model(3,1) = rsec; - Model(3,2) = (rse-radius_cylinder)*(rse-radius_cylinder); - Model(4,1) = 1.; - Model(4,2) = 2*(rse-radius_cylinder); - // Measurements ym - // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 - ym(0,0) = 0.; - ym(1,0) = zs; - ym(2,0)= cos(thetas)/sin(thetas); - ym(3,0) = zse; - ym(4,0)= cos(thetase)/sin(thetase); + // Barrel Track Model Matrix + Model(0, 0) = 1.; + Model(1, 0) = 1.; + Model(1, 1) = rsc; + Model(1, 2) = (rs - radius_cylinder) * (rs - radius_cylinder); + Model(2, 1) = 1.; + Model(2, 2) = 2 * (rs - radius_cylinder); + Model(3, 0) = 1.; + Model(3, 1) = rsec; + Model(3, 2) = (rse - radius_cylinder) * (rse - radius_cylinder); + Model(4, 1) = 1.; + Model(4, 2) = 2 * (rse - radius_cylinder); + // Measurements ym + // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 + ym(0, 0) = 0.; + ym(1, 0) = zs; + ym(2, 0) = cos(thetas) / sin(thetas); + ym(3, 0) = zse; + ym(4, 0) = cos(thetase) / sin(thetase); } else { imeth = 1; if (m_debug) std::cout << " forward fit " << cos(thetas) << std::endl; - // Forward Track Model Matrix - Model(0,0) = 1.; - Model(1,0) = 1.; - Model(1,1) = zs; - Model(1,2) = sign*(zs-sign*z_cylinder)*(zs-sign*z_cylinder); - Model(2,1) = 1; - Model(2,2) = sign*2*(zs-sign*z_cylinder); - Model(3,0) = 1.; - Model(3,1) = zse; - Model(3,2) = sign*(zse-sign*z_cylinder)*(zse-sign*z_cylinder); - Model(4,1) = 1; - Model(4,2) = sign*2*(zse-sign*z_cylinder); - - if (fabs(zs) > z_end+2000) { - Model(1,2) = sign*(-z_end*z_end + z_cylinder*z_cylinder + 2*zs*sign*(z_end-z_cylinder) - + (zs-sign*z_end)*(zs-sign*z_end)/5.); - Model(2,2) = sign*(2*(sign*z_end-sign*z_cylinder) - + (zs-sign*z_end)/5.); + // Forward Track Model Matrix + Model(0, 0) = 1.; + Model(1, 0) = 1.; + Model(1, 1) = zs; + Model(1, 2) = sign * (zs - sign * z_cylinder) * (zs - sign * z_cylinder); + Model(2, 1) = 1; + Model(2, 2) = sign * 2 * (zs - sign * z_cylinder); + Model(3, 0) = 1.; + Model(3, 1) = zse; + Model(3, 2) = sign * (zse - sign * z_cylinder) * (zse - sign * z_cylinder); + Model(4, 1) = 1; + Model(4, 2) = sign * 2 * (zse - sign * z_cylinder); + + if (fabs(zs) > z_end + 2000) { + Model(1, 2) = sign + * (-z_end * z_end + z_cylinder * z_cylinder + 2 * zs * sign * (z_end - z_cylinder) + + (zs - sign * z_end) * (zs - sign * z_end) / 5.); + Model(2, 2) = sign * (2 * (sign * z_end - sign * z_cylinder) + (zs - sign * z_end) / 5.); + } + if (fabs(zse) > z_end + 2000) { + Model(3, 2) = sign + * (-z_end * z_end + z_cylinder * z_cylinder + 2 * zse * sign * (z_end - z_cylinder) + + (zse - sign * z_end) * (zse - sign * z_end) / 5.); + Model(4, 2) = sign * (2 * (sign * z_end - sign * z_cylinder) + (zse - sign * z_end) / 5.); } - if (fabs(zse) > z_end+2000) { - Model(3,2) = sign*(-z_end*z_end + z_cylinder*z_cylinder + 2*zse*sign*(z_end-z_cylinder) - + (zse-sign*z_end)*(zse-sign*z_end)/5.); - Model(4,2) = sign*(2*(sign*z_end-sign*z_cylinder) - + (zse-sign*z_end)/5.); - } - // Measurements ym - // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 - ym(0,0) = 0.; - ym(1,0) = rsc; - ym(2,0)= tan(thetas); - ym(3,0) = rsec; - ym(4,0)= tan(thetase); - // std::cout << " Forward zs " << zs << std::endl; + // Measurements ym + // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 + ym(0, 0) = 0.; + ym(1, 0) = rsc; + ym(2, 0) = tan(thetas); + ym(3, 0) = rsec; + ym(4, 0) = tan(thetase); + // std::cout << " Forward zs " << zs << std::endl; } - if (m_debug) std::cout << " distance segments " << sqrt((zs-zse)*(zs-zse)+(rs-rse)*(rs-rse))<< std::endl; - - for(int i = 0; i <3 ; ++i ) { - V(i,0)= Model(0,i)*ym(0,0)/ebs2 + Model(1,i)*ym(1,0)/ers2 + Model(2,i)*ym(2,0)/ets21 - + Model(3,i)*ym(3,0)/ers2 + Model(4,i)*ym(4,0)/ets22; - } - - Amg::MatrixX CovTI(3,3); // Covariance Inverse of Track parameters - CovTI.setZero(); - for(int i = 0; i <3 ; ++i ) { - for(int j = 0; j <3 ; ++j ) { - CovTI(i,j) += Model(0,i)*Model(0,j)/ebs2; - CovTI(i,j) += Model(1,i)*Model(1,j)/ers2; - CovTI(i,j) += Model(2,i)*Model(2,j)/ets21; - CovTI(i,j) += Model(3,i)*Model(3,j)/ers2; - CovTI(i,j) += Model(4,i)*Model(4,j)/ets22; + if (m_debug) + std::cout << " distance segments " << sqrt((zs - zse) * (zs - zse) + (rs - rse) * (rs - rse)) << std::endl; + + for (int i = 0; i < 3; ++i) { + V(i, 0) = Model(0, i) * ym(0, 0) / ebs2 + Model(1, i) * ym(1, 0) / ers2 + Model(2, i) * ym(2, 0) / ets21 + + Model(3, i) * ym(3, 0) / ers2 + Model(4, i) * ym(4, 0) / ets22; + } + + Amg::MatrixX CovTI(3, 3); // Covariance Inverse of Track parameters + CovTI.setZero(); + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + CovTI(i, j) += Model(0, i) * Model(0, j) / ebs2; + CovTI(i, j) += Model(1, i) * Model(1, j) / ers2; + CovTI(i, j) += Model(2, i) * Model(2, j) / ets21; + CovTI(i, j) += Model(3, i) * Model(3, j) / ers2; + CovTI(i, j) += Model(4, i) * Model(4, j) / ets22; } } - // Solution for Track parameters - CovT = CovTI.inverse(); - T = CovT*V; - // std::cout << " covariance at track 00 " << CovT(0,0) << " 11 " << CovT(1,1) << " 12 " << CovT(1,2) << " 22 " << CovT(2,2) << std::endl; + // Solution for Track parameters + CovT = CovTI.inverse(); + T = CovT * V; + // std::cout << " covariance at track 00 " << CovT(0,0) << " 11 " << CovT(1,1) << " 12 " << CovT(1,2) << " 22 + // " << CovT(2,2) << std::endl; - double theta=0.; + double theta = 0.; if (imeth == 0) { - theta = atan2(1.,T(1,0)); - invcurvature = T(2,0)*sin(theta); + theta = atan2(1., T(1, 0)); + invcurvature = T(2, 0) * sin(theta); } else if (imeth == 1) { - theta = atan(T(1,0)); - invcurvature = T(2,0)*cos(theta); - } + theta = atan(T(1, 0)); + invcurvature = T(2, 0) * cos(theta); + } - if (m_debug) std::cout << " Momentum in MeV " << (1./invcurvature)/10. << std::endl; + if (m_debug) std::cout << " Momentum in MeV " << (1. / invcurvature) / 10. << std::endl; - // calculate residuals and chi2 - for(int i = 0; i <5 ; ++i ) { - Resi(i,0)= Model(i,0)*T(0,0) + Model(i,1)*T(1,0) + Model(i,2)*T(2,0) - ym(i,0); - } - double chi2 = Resi(0,0)*Resi(0,0)/ebs2 + Resi(1,0)*Resi(1,0)/ers2 + Resi(2,0)*Resi(2,0)/ets21 - + Resi(3,0)*Resi(3,0)/ers2 + Resi(4,0)*Resi(4,0)/ets22; - if (m_debug) std::cout << " resi 00 " << Resi(0,0) << " chi2 " << chi2 << std::endl; - // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; + // calculate residuals and chi2 + for (int i = 0; i < 5; ++i) { + Resi(i, 0) = Model(i, 0) * T(0, 0) + Model(i, 1) * T(1, 0) + Model(i, 2) * T(2, 0) - ym(i, 0); + } + double chi2 = Resi(0, 0) * Resi(0, 0) / ebs2 + Resi(1, 0) * Resi(1, 0) / ers2 + Resi(2, 0) * Resi(2, 0) / ets21 + + Resi(3, 0) * Resi(3, 0) / ers2 + Resi(4, 0) * Resi(4, 0) / ets22; + if (m_debug) std::cout << " resi 00 " << Resi(0, 0) << " chi2 " << chi2 << std::endl; + // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; - // Reshuffle residuals Res(0) -> segment position in Model (1,x) - // Res(1) -> segment angle in Model (2,x) + // Reshuffle residuals Res(0) -> segment position in Model (1,x) + // Res(1) -> segment angle in Model (2,x) Res = Amg::VectorX(4); - Res.setZero(); - for(int i = 1; i <5 ; ++i ) { - Res[i-1]= Resi(i,0); - } - - Pull = Amg::VectorX(4); - Pull.setZero(); - - bool toobig = false; - for(int i = 0; i <4 ; ++i ) { - if ( i==0 ) Pull[i] = Res[i]/sqrt(ers2); - if ( i==1 ) Pull[i] = Res[i]/sqrt(ets21); - if ( i==2 ) Pull[i] = Res[i]/sqrt(ers2); - if ( i==3 ) Pull[i] = Res[i]/sqrt(ets22); - if ( fabs( Pull[i] ) > 5 ) toobig = true; + Res.setZero(); + for (int i = 1; i < 5; ++i) { + Res[i - 1] = Resi(i, 0); + } + + Pull = Amg::VectorX(4); + Pull.setZero(); + + bool toobig = false; + for (int i = 0; i < 4; ++i) { + if (i == 0) Pull[i] = Res[i] / sqrt(ers2); + if (i == 1) Pull[i] = Res[i] / sqrt(ets21); + if (i == 2) Pull[i] = Res[i] / sqrt(ers2); + if (i == 3) Pull[i] = Res[i] / sqrt(ets22); + if (fabs(Pull[i]) > 5) toobig = true; } if (toobig && m_debug) { - std::cout << " Pull too BIGFIT " << " rad pos1 " << rs << " rad pos2 " << rse << " ang1 " << thetas << " ang2 " << thetase << std::endl; + std::cout << " Pull too BIGFIT " + << " rad pos1 " << rs << " rad pos2 " << rse << " ang1 " << thetas << " ang2 " << thetase + << std::endl; } - if (m_debug) std::cout << " Fit2Segments: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] << " pull 1 " << Pull[1] << std::endl; - if (m_debug) std::cout << " Fit2Segments: Residual 2 " << Res[2] << " pull 2 " << Pull[2] << " Residual 3 " << Res[3] << " pull 3 " << Pull[3] << std::endl; - } + if (m_debug) + std::cout << " Fit2Segments: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] + << " pull 1 " << Pull[1] << std::endl; + if (m_debug) + std::cout << " Fit2Segments: Residual 2 " << Res[2] << " pull 2 " << Pull[2] << " Residual 3 " << Res[3] + << " pull 3 " << Pull[3] << std::endl; } +} -void Muon::MuonCurvedSegmentCombiner::extrapolateSegment( Muon::MuonSegment& seg , Muon::MuonSegment& sege , Amg::VectorX & Res, Amg::VectorX & Pull) { +void +Muon::MuonCurvedSegmentCombiner::extrapolateSegment(Muon::MuonSegment& seg, Muon::MuonSegment& sege, Amg::VectorX& Res, + Amg::VectorX& Pull) +{ // extrapolate segment seg* to segment sege* and determine residuals and pulls - // Tracking matrices - Amg::MatrixX Model(3,3);// H projection matrix PDG + // Tracking matrices + Amg::MatrixX Model(3, 3); // H projection matrix PDG Model.setZero(); - Amg::MatrixX CovT(3,3); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; + Amg::MatrixX CovT(3, 3); // Covariance or Track parameters here 3: z beam; r/z segment; tan/cot theta segment; CovT.setZero(); - Amg::MatrixX V(3,1);// V = H^T Cov^-1 r Cov-1 = Covariance of measurements + Amg::MatrixX V(3, 1); // V = H^T Cov^-1 r Cov-1 = Covariance of measurements V.setZero(); - Amg::MatrixX T(3,1);// Track parameters + Amg::MatrixX T(3, 1); // Track parameters T.setZero(); - Amg::MatrixX ym(3,1); // Vector of measurememns + Amg::MatrixX ym(3, 1); // Vector of measurememns ym.setZero(); - // Extrapolation Matrices - Amg::MatrixX ModelE(3,3);// H projection matrix for second segment + // Extrapolation Matrices + Amg::MatrixX ModelE(3, 3); // H projection matrix for second segment ModelE.setZero(); - Amg::MatrixX ymE(3,1); // Vector of measurememts second segment + Amg::MatrixX ymE(3, 1); // Vector of measurememts second segment ymE.setZero(); - Amg::MatrixX Resi(3,1); // Residuals + Amg::MatrixX Resi(3, 1); // Residuals Resi.setZero(); - // Geometry conventions + // Geometry conventions double radius_cylinder = 4000.; - double z_cylinder = 5000.; - double z_end = 15000.; - // double cos_barrel = std::cos(std::atan2(11430.,14000.)); - //int imeth; + double z_cylinder = 5000.; + double z_end = 15000.; + // double cos_barrel = std::cos(std::atan2(11430.,14000.)); + // int imeth; // Segment to start double thetas = seg.globalDirection().theta(); - double rs = seg.globalPosition().perp(); - double zs = seg.globalPosition().z(); + double rs = seg.globalPosition().perp(); + double zs = seg.globalPosition().z(); // Second Segment to extrapolate to double thetase = sege.globalDirection().theta(); - double rse = sege.globalPosition().perp(); - double zse = sege.globalPosition().z(); + double rse = sege.globalPosition().perp(); + double zse = sege.globalPosition().z(); // Error definitions - double ebs2 = 50*50; //error squared beam position - double ers2 = 0.1*0.1; //error squared position + double ebs2 = 50 * 50; // error squared beam position + double ers2 = 0.1 * 0.1; // error squared position // high pt - // double ets2 = 0.0001*0.0001; // error squared angle - double ets2 = 0.05*0.05; // error squared angle + // double ets2 = 0.0001*0.0001; // error squared angle + double ets2 = 0.05 * 0.05; // error squared angle double sign = 1; - if ( zs < 0 ) sign = -1.; + if (zs < 0) sign = -1.; const Muon::MCSCSegmentInfo& info1 = m_segInfoMap[&seg]; const Muon::MCSCSegmentInfo& info2 = m_segInfoMap[&sege]; - std::string st1 = info1.station; - std::string st2 = info2.station; - bool barrel = false; - if (st1[0] == 'B' || st2[0] == 'B' ) barrel = true; + std::string st1 = info1.station; + std::string st2 = info2.station; + bool barrel = false; + if (st1[0] == 'B' || st2[0] == 'B') barrel = true; if (barrel) { - //imeth = 0; - // Barrel Track Model Matrix - Model(0,0) = 1.; - Model(1,0) = 1.; - Model(1,1) = rs; - Model(1,2) = (rs-radius_cylinder)*(rs-radius_cylinder); - Model(2,1) = 1.; - Model(2,2) = 2*(rs-radius_cylinder); - ModelE(0,0) = 1.; - ModelE(1,0) = 1.; - ModelE(1,1) = rse; - ModelE(1,2) = (rse-radius_cylinder)*(rse-radius_cylinder); - ModelE(2,1) = 1.; - ModelE(2,2) = 2*(rse-radius_cylinder); - // Measurements ym - // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 - ym(0,0) = 0.; - ym(1,0) = zs; - ym(2,0)= cos(thetas)/sin(thetas); - ymE(0,0) = 0.; - ymE(1,0) = zse; - ymE(2,0)= cos(thetase)/sin(thetase); + // imeth = 0; + // Barrel Track Model Matrix + Model(0, 0) = 1.; + Model(1, 0) = 1.; + Model(1, 1) = rs; + Model(1, 2) = (rs - radius_cylinder) * (rs - radius_cylinder); + Model(2, 1) = 1.; + Model(2, 2) = 2 * (rs - radius_cylinder); + ModelE(0, 0) = 1.; + ModelE(1, 0) = 1.; + ModelE(1, 1) = rse; + ModelE(1, 2) = (rse - radius_cylinder) * (rse - radius_cylinder); + ModelE(2, 1) = 1.; + ModelE(2, 2) = 2 * (rse - radius_cylinder); + // Measurements ym + // correspondig squared errors: zs -> ers2 cot(thetas) ->ets2 + ym(0, 0) = 0.; + ym(1, 0) = zs; + ym(2, 0) = cos(thetas) / sin(thetas); + ymE(0, 0) = 0.; + ymE(1, 0) = zse; + ymE(2, 0) = cos(thetase) / sin(thetase); } else { - //imeth = 1; - // Forward Track Model Matrix - Model(0,0) = 1.; - Model(1,0) = 1.; - Model(1,1) = zs; - Model(1,2) = sign*(zs-sign*z_cylinder)*(zs-sign*z_cylinder); - Model(2,1) = 1; - Model(2,2) = sign*2*(zs-sign*z_cylinder); - ModelE(0,0) = 1.; - ModelE(1,0) = 1.; - ModelE(1,1) = zse; - ModelE(1,2) = sign*(zse-sign*z_cylinder)*(zse-sign*z_cylinder); - ModelE(2,1) = 1; - Model(2,2) = sign*2*(zse-sign*z_cylinder); + // imeth = 1; + // Forward Track Model Matrix + Model(0, 0) = 1.; + Model(1, 0) = 1.; + Model(1, 1) = zs; + Model(1, 2) = sign * (zs - sign * z_cylinder) * (zs - sign * z_cylinder); + Model(2, 1) = 1; + Model(2, 2) = sign * 2 * (zs - sign * z_cylinder); + ModelE(0, 0) = 1.; + ModelE(1, 0) = 1.; + ModelE(1, 1) = zse; + ModelE(1, 2) = sign * (zse - sign * z_cylinder) * (zse - sign * z_cylinder); + ModelE(2, 1) = 1; + Model(2, 2) = sign * 2 * (zse - sign * z_cylinder); if (fabs(zs) > z_end) { - Model(1,2) = sign*(-z_end*z_end + z_cylinder*z_cylinder + 2*zs*sign*(z_end-z_cylinder)); - Model(2,2) = sign*2*(sign*z_end-sign*z_cylinder); - ModelE(1,2) = sign*(-z_end*z_end + z_cylinder*z_cylinder + 2*zse*sign*(z_end-z_cylinder)); - ModelE(2,2) = sign*2*(sign*z_end-sign*z_cylinder); - } - // Measurements ym - // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 - ym(0,0) = 0.; - ym(1,0) = rs; - ym(2,0)= tan(thetas); - ymE(0,0) = 0.; - ymE(1,0) = rse; - ymE(2,0)= tan(thetase); - // std::cout << " Forward zs " << zs << std::endl; + Model(1, 2) = sign * (-z_end * z_end + z_cylinder * z_cylinder + 2 * zs * sign * (z_end - z_cylinder)); + Model(2, 2) = sign * 2 * (sign * z_end - sign * z_cylinder); + ModelE(1, 2) = sign * (-z_end * z_end + z_cylinder * z_cylinder + 2 * zse * sign * (z_end - z_cylinder)); + ModelE(2, 2) = sign * 2 * (sign * z_end - sign * z_cylinder); + } + // Measurements ym + // correspondig squared errors: rs -> ers2 tan(thetas) ->ets2 + ym(0, 0) = 0.; + ym(1, 0) = rs; + ym(2, 0) = tan(thetas); + ymE(0, 0) = 0.; + ymE(1, 0) = rse; + ymE(2, 0) = tan(thetase); + // std::cout << " Forward zs " << zs << std::endl; } - for (int iter = 0; iter<1; ++iter) { + for (int iter = 0; iter < 1; ++iter) { - for(int i = 0; i <3 ; ++i ) { - V(i,0)= Model(0,i)*ym(0,0)/ebs2 + Model(1,i)*ym(1,0)/ers2 + Model(2,i)*ym(2,0)/ets2; - } + for (int i = 0; i < 3; ++i) { + V(i, 0) = Model(0, i) * ym(0, 0) / ebs2 + Model(1, i) * ym(1, 0) / ers2 + Model(2, i) * ym(2, 0) / ets2; + } - Amg::MatrixX CovTI(3,3); // Covariance Inverse of Track parameters - CovTI.setZero(); - for(int i = 0; i <3 ; ++i ) { - for(int j = 0; j <3 ; ++j ) { - CovTI(i,j) += Model(0,i)*Model(0,j)/ebs2; - CovTI(i,j) += Model(1,i)*Model(1,j)/ers2; - CovTI(i,j) += Model(2,i)*Model(2,j)/ets2; + Amg::MatrixX CovTI(3, 3); // Covariance Inverse of Track parameters + CovTI.setZero(); + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + CovTI(i, j) += Model(0, i) * Model(0, j) / ebs2; + CovTI(i, j) += Model(1, i) * Model(1, j) / ers2; + CovTI(i, j) += Model(2, i) * Model(2, j) / ets2; } } - // Solution for Track parameters - CovT = CovTI.inverse(); - T = CovT*V; - // std::cout << " covariance at track 00 " << CovT(0,0) << " 11 " << CovT(1,1) << " 12 " << CovT(1,2) << " 22 " << CovT(2,2) << std::endl; + // Solution for Track parameters + CovT = CovTI.inverse(); + T = CovT * V; + // std::cout << " covariance at track 00 " << CovT(0,0) << " 11 " << CovT(1,1) << " 12 " << CovT(1,2) << " 22 + // " << CovT(2,2) << std::endl; - // double theta=0.; + // double theta=0.; // if (imeth == 0) { // theta = atan2(1.,T(1,0)); // //invcurvature = T(2,0)*sin(theta); // } else if (imeth == 1) { // theta = atan(T(1,0)); // //invcurvature = T(2,0)*cos(theta); - // } + // } if (iter == 0) { - // ets2 = invcurvature*invcurvature*10000.*50*50; - // if (ets2 < 1e-8) ets2 = 1e-8; - // if (ets2 > 1.e-2) ets2 = 1e-2; - } + // ets2 = invcurvature*invcurvature*10000.*50*50; + // if (ets2 < 1e-8) ets2 = 1e-8; + // if (ets2 > 1.e-2) ets2 = 1e-2; + } if (iter == 1) { - // std::cout << " reiterated with ets2 angular spread" << ets2 << " invcurv " << invcurvature << " cos(theta) " << cos(theta) << std::endl; - } + // std::cout << " reiterated with ets2 angular spread" << ets2 << " invcurv " << invcurvature << " + // cos(theta) " << cos(theta) << std::endl; + } } // calculate residuals and chi2 - for(int i = 0; i <3 ; ++i ) { - Resi(i,0)= Model(i,0)*T(0,0) + Model(i,1)*T(1,0) + Model(i,2)*T(2,0) - ym(i,0); - } + for (int i = 0; i < 3; ++i) { + Resi(i, 0) = Model(i, 0) * T(0, 0) + Model(i, 1) * T(1, 0) + Model(i, 2) * T(2, 0) - ym(i, 0); + } // double chi2 = Resi(0,0)*Resi(0,0)/ebs2 + Resi(1,0)*Resi(1,0)/ers2 + Resi(2,0)*Resi(2,0)/ets2; - // std::cout << " residuals matrix method z " << Res(0,0) << " cot(theta) " << Res(1,0) << " chi2 " << chi2 << std::endl; - // std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; + // std::cout << " residuals matrix method z " << Res(0,0) << " cot(theta) " << Res(1,0) << " chi2 " << chi2 << + // std::endl; std:: cout<< " Track parameters Matrix T00 " << T(0,0) << " T10 " << T(1,0) << std::endl; // Reshuffle residuals Res(0) -> segment position in Model (1,x) // Res(1) -> segment angle in Model (2,x) // Amg::VectorX Res(2,0); - Res = Amg::VectorX(2); + Res = Amg::VectorX(2); Res.setZero(); - for(int i = 1; i <3 ; ++i ) { - Res[i-1]= ModelE(i,0)*T(0,0) + ModelE(i,1)*T(1,0) + ModelE(i,2)*T(2,0) - ymE(i,0); - } + for (int i = 1; i < 3; ++i) { + Res[i - 1] = ModelE(i, 0) * T(0, 0) + ModelE(i, 1) * T(1, 0) + ModelE(i, 2) * T(2, 0) - ymE(i, 0); + } - Amg::MatrixX ModelET(3,3);// Transposed + Amg::MatrixX ModelET(3, 3); // Transposed ModelET.setZero(); - for(int i = 0; i <3 ; ++i ) { - for(int j = 0; j <3 ; ++j ) { - ModelET(i,j)=ModelE(j,i); + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 3; ++j) { + ModelET(i, j) = ModelE(j, i); } } - Amg::MatrixX CovE(3,3);// Covariance of predicition + Amg::MatrixX CovE(3, 3); // Covariance of predicition CovE.setZero(); - CovE = ModelE*CovT*ModelET; + CovE = ModelE * CovT * ModelET; - Pull = Amg::VectorX(2); + Pull = Amg::VectorX(2); Pull.setZero(); - for(int i = 0; i <2 ; ++i ) { - if ( i==0 ) Pull[i] = Res[i]/sqrt(CovE(1,1)+ers2); - if ( i==1 ) Pull[i] = Res[i]/sqrt(CovE(2,2)+ets2); + for (int i = 0; i < 2; ++i) { + if (i == 0) Pull[i] = Res[i] / sqrt(CovE(1, 1) + ers2); + if (i == 1) Pull[i] = Res[i] / sqrt(CovE(2, 2) + ets2); } - if (m_debug) std::cout << " Extrapolation: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] << " pull 1 " << Pull[1] << std::endl; - - + if (m_debug) + std::cout << " Extrapolation: Residual 0 " << Res[0] << " pull 0 " << Pull[0] << " Residual 1 " << Res[1] + << " pull 1 " << Pull[1] << std::endl; } - diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcGlobalUtilities.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcGlobalUtilities.cxx index d3c3c714bfed84dc3cbe6d5e6205578a761b4ba8..2ceaa143af8b5421f61d5632605372d89c28d339 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcGlobalUtilities.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/RpcRawDataMonitoring/src/RpcGlobalUtilities.cxx @@ -140,8 +140,9 @@ std::vector<int> RpcStripShift(const MuonGM::MuonDetectorManager* muonMgr, cons } for(int idbz=1; idbz!= 4; idbz++){ - Identifier rpcId = rpcIdHelper.channelID(krpcstationName, ieta, irpcstationPhi, krpcdoubletR, idbz, 1, 1, 1, 1); // last 4 arguments are: int doubletPhi, int gasGap, int measuresPhi, int strip - if (!rpcId.is_valid()) continue; + bool isValid = false; + Identifier rpcId = rpcIdHelper.channelID(krpcstationName, ieta, irpcstationPhi, krpcdoubletR, idbz, 1, 1, 1, 1, false, &isValid); // last 5 arguments are: int doubletPhi, int gasGap, int measuresPhi, int strip, isValid + if (!isValid) continue; const MuonGM::RpcReadoutElement* rpc = muonMgr->getRpcReadoutElement(rpcId); if(rpc){ diff --git a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx index dc2849cceba26b9104c65df9a3a2366020dd5bab..50b7483a74e44f5e1b83fea39482ca57253bdc3d 100644 --- a/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/Root/ElectronSelectorHelpers.cxx @@ -102,10 +102,32 @@ bool ElectronSelectorHelpers::passBLayerRequirement(const xAOD::TrackParticle *t } -// ================================================================== bool ElectronSelectorHelpers::passAmbiguity(xAOD::AmbiguityTool::AmbiguityType type, const uint8_t criterion){ // helper to check if ambiguity type is one of several that are stored in a bitmask - return criterion & 0x1<<type; + // + // Christos Rel 22 new ambi. + // + // The issue is that the "criterion" encodes what should + // pass only. + // If it was not stored in the GroupData and need to keep compatibility + // this would have been trivial but .... + // + // We want reject types + // ambiguousVertexEoverPBetterThanTrackEoverP=6, + // photon=7, + // + // What pass is 0b11111 (31) e.g we do not specify explicitly the bit + // to cut on. Which of course now breaks. + // The magic 31 comes from config files which will be updated + // at some stage for new tunes. + // And the code below pass for types 0,1,2,3,4 (the 5 bits sets) + // 2^0 + 2^1 + 2^2 +2^3 +2^4 = 1+2+4+8+16 = 31 + // + // For now solve ad-hoc and keep compatibility with existing config + // tooling in GroupArea/PHYS/Derivation etc by adding 32 + // + // + return (32+criterion) & 0x1<<type; } diff --git a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h index 8befc2322366250dd9a9057d2741578796bf41ea..493aafe50c2f72ad702691425d0044a34d29e38f 100644 --- a/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h +++ b/PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEGammaAmbiguityTool.h @@ -36,10 +36,9 @@ namespace xAOD { ambiguousTrackLowPt=2, ambiguousTrackHighEoverP=3, ambiguousTrackNoPixel =4, - ambiguousVertexEoverPBetterThanTrackEoverP=5, - photon=6, - // this falls at the end to avoid problems in other tools (el ID) using bitwise operations - ambiguousNoInnermost=7, + ambiguousNoInnermost=5, + ambiguousVertexEoverPBetterThanTrackEoverP=6, + photon=7, unknown=8, }; } diff --git a/Reconstruction/MET/METUtilities/Root/METRebuilder.cxx b/Reconstruction/MET/METUtilities/Root/METRebuilder.cxx index 330fa6c402898f6f4642322721db19c88852ed61..ce42fe26085b41f4fe5a582efbe45e68d725e59c 100644 --- a/Reconstruction/MET/METUtilities/Root/METRebuilder.cxx +++ b/Reconstruction/MET/METUtilities/Root/METRebuilder.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // METRebuilder.cxx @@ -42,7 +42,7 @@ #include "AsgDataHandles/WriteHandle.h" #ifndef ROOTCORE -#include "GaudiKernel/IJobOptionsSvc.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" #endif namespace met { @@ -216,14 +216,14 @@ namespace met { ATH_CHECK( trkSelTool->initialize() ); m_trkseltool = ToolHandle<InDet::IInDetTrackSelectionTool>(trkSelTool); #else - ServiceHandle<IJobOptionsSvc> josvc("JobOptionsSvc",name()); + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> josvc("JobOptionsSvc",name()); std::string toolName = "IDTrkSel_METUtil"; ATH_MSG_INFO("METRebuilder: Autoconfiguring " << toolName); m_trkseltool.setTypeAndName("InDet::InDetTrackSelectionTool/"+toolName); std::string fullToolName = "ToolSvc."+toolName; - ATH_CHECK( josvc->addPropertyToCatalogue(fullToolName,FloatProperty("maxZ0SinTheta",1.5)) ); - ATH_CHECK( josvc->addPropertyToCatalogue(fullToolName,FloatProperty("maxD0overSigmaD0",1.5)) ); - ATH_CHECK( josvc->addPropertyToCatalogue(fullToolName,StringProperty("CutLevel","TightPrimary")) ); + josvc->set(fullToolName + ".maxZ0SinTheta", Gaudi::Utils::toString<float>(1.5)); + josvc->set(fullToolName + ".maxD0overSigmaD0",Gaudi::Utils::toString<float>(1.5)); + josvc->set(fullToolName + ".CutLevel","TightPrimary"); #endif } ATH_CHECK( m_trkseltool.retrieve() ); diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py index 55ce81b9aabb8d145366cc306a13ef928b8e9262..9e3316a7fac354c584f94c193680f452cb767e0c 100644 --- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py +++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py @@ -309,9 +309,6 @@ def getTauSubstructure(): from tauRecTools.tauRecToolsConf import TauSubstructureVariables TauSubstructureVariables = TauSubstructureVariables( name = _name, - # parameters for CaloIsoCorrected variable - maxPileUpCorrection = 4000., #MeV - pileUpAlpha = 1.0, VertexCorrection = True, IncShowerSubtr = tauFlags.useShowerSubClusters() ) diff --git a/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx b/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx index c78183810d0b34f07005840b4875236b530151fa..2f3f5e5a07d0e2262f72fb977150753ffc8561a8 100644 --- a/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx +++ b/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx @@ -32,7 +32,7 @@ m_incShowerSubtr(true){ bool CaloClusterVariables::update(const xAOD::TauJet& pTau) { - const xAOD::Jet* pSeed = *pTau.jetLink(); + const xAOD::Jet* pSeed = pTau.jet(); if(!pSeed) return false; // Loop through jets, get links to clusters @@ -43,7 +43,7 @@ bool CaloClusterVariables::update(const xAOD::TauJet& pTau) { for (auto pCluster : clusterList){ // correct cluster if (pTau.vertexLink() && m_doVertexCorrection) - constituents.emplace_back (*pCluster, (*pTau.vertexLink())->position()); + constituents.emplace_back (*pCluster, pTau.vertex()->position()); else constituents.emplace_back (*pCluster); } @@ -95,7 +95,7 @@ bool CaloClusterVariables::update(const xAOD::TauJet& pTau) { if (this->m_numConstit < 2) this->m_totMass = DEFAULT; else { double mass2 = sum_e * sum_e - (sum_px * sum_px + sum_py * sum_py + sum_pz * sum_pz); - this->m_totMass = mass2 > 0 ? sqrt(mass2) : -sqrt(-mass2); + this->m_totMass = mass2 > 0 ? std::sqrt(mass2) : -std::sqrt(-mass2); } // Calculate the average radius of the constituents wrt the tau centroid @@ -149,7 +149,7 @@ bool CaloClusterVariables::update(const xAOD::TauJet& pTau) { if (this->m_effNumConstit_int < 2) this->m_effMass = DEFAULT; else { double mass2 = sum_e * sum_e - (sum_px * sum_px + sum_py * sum_py + sum_pz * sum_pz); - this->m_effMass = mass2 > 0 ? sqrt(mass2) : -sqrt(-mass2); + this->m_effMass = mass2 > 0 ? std::sqrt(mass2) : -std::sqrt(-mass2); } // Calculate the average radius of the constituents wrt the tau centroid @@ -175,7 +175,7 @@ TLorentzVector CaloClusterVariables::calculateTauCentroid(int nConst, const std: current_px = c.p4().Px(); current_py = c.p4().Py(); current_pz = c.p4().Pz(); - modulus = sqrt(current_px * current_px + current_py * current_py + current_pz * current_pz); + modulus = std::sqrt(current_px * current_px + current_py * current_py + current_pz * current_pz); px += current_px / modulus; py += current_py / modulus; pz += current_pz / modulus; diff --git a/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx b/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx index 486a8c32090486001e7295b6819fa74e7a3a2915..e109b2cac42cb4852fc95532360fa66701ab7fdf 100644 --- a/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx @@ -31,10 +31,6 @@ StatusCode MvaTESVariableDecorator::initialize() { return StatusCode::SUCCESS; } -StatusCode MvaTESVariableDecorator::finalize() { - return StatusCode::SUCCESS; -} - //_____________________________________________________________________________ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { @@ -85,8 +81,7 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { TLorentzVector clusters_had_P4; clusters_had_P4.SetPtEtaPhiM(0,0,0,0); - TLorentzVector LC_P4; - LC_P4.SetPtEtaPhiM(xTau.ptDetectorAxis(), xTau.etaDetectorAxis(), xTau.phiDetectorAxis(), xTau.m()); + const TLorentzVector& LC_P4 = xTau.p4(xAOD::TauJetParameters::DetectorAxis); // Loop through jets, get links to clusters std::vector<const xAOD::CaloCluster*> clusterList; @@ -111,8 +106,8 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { if(cl->retrieveMoment(xAOD::CaloCluster::MomentType::EM_PROBABILITY,em_probability)) { mean_em_probability += clE*em_probability; - if(em_probability>0.5) clusters_EM_P4 += (TLorentzVector) cl->p4(xAOD::CaloCluster::State::CALIBRATED); - else clusters_had_P4 += (TLorentzVector) cl->p4(xAOD::CaloCluster::State::CALIBRATED); + if(em_probability>0.5) clusters_EM_P4 += cl->p4(xAOD::CaloCluster::State::CALIBRATED); + else clusters_had_P4 += cl->p4(xAOD::CaloCluster::State::CALIBRATED); } else ATH_MSG_WARNING("Failed to retrieve moment: EM_PROBABILITY"); @@ -167,8 +162,8 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { Pi0_totalP4.SetPtEtaPhiM(0,0,0,0); for(size_t i=0; i<xTau.nPi0PFOs(); i++){ - Pi0_totalP4 += (TLorentzVector)xTau.pi0PFO(i)->p4(); - }; + Pi0_totalP4 += xTau.pi0PFO(i)->p4(); + } double Pi0_totalE = Pi0_totalP4.E(); @@ -177,8 +172,8 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { charged_totalP4.SetPtEtaPhiM(0,0,0,0); for(size_t i=0; i<xTau.nChargedPFOs(); i++){ - charged_totalP4 += (TLorentzVector)xTau.chargedPFO(i)->p4(); - }; + charged_totalP4 += xTau.chargedPFO(i)->p4(); + } double charged_totalE = charged_totalP4.E(); @@ -189,13 +184,5 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) const { } xTau.setDetail(xAOD::TauJetParameters::PFOEngRelDiff, (float) relDiff); - // calculate interpolated pT - double pt_pantau = xTau.ptPanTauCellBased(); - double pt_LC = xTau.ptDetectorAxis(); - double interpolWeight = 0.5 * ( 1. + TMath::TanH( ( pt_LC/GeV - 250. ) / 20. ) ); - double LC_pantau_interpolPt = interpolWeight*pt_LC + (1.-interpolWeight)*pt_pantau; - - xTau.setDetail(xAOD::TauJetParameters::LC_pantau_interpolPt, (float) LC_pantau_interpolPt); - return StatusCode::SUCCESS; } diff --git a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx index 4f0ce6b99e77c9aeb7b6421bfe3fa129fc69564c..6f281362bd8876533487736d4a1a319180bb272d 100644 --- a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx +++ b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx @@ -63,9 +63,9 @@ StatusCode TauCalibrateLC::initialize() { //retrieve number of eta bins from file m_nEtaBins = m_etaBinHist->GetNbinsX(); //member var if (m_nEtaBins==6) - ATH_MSG_INFO("using 2011 tau energy calibration"); + ATH_MSG_INFO("using tau energy calibration with 6 eta bins"); else if (m_nEtaBins==5) - ATH_MSG_INFO("using 2012 tau energy calibration"); + ATH_MSG_INFO("using tau energy calibration with 5 eta bins"); else { ATH_MSG_FATAL("Wrong or broken tau energy calibration file"); return StatusCode::FAILURE; @@ -142,13 +142,11 @@ StatusCode TauCalibrateLC::execute(xAOD::TauJet& pTau) const if (m_doEnergyCorr) { // get detector axis values - double eta = pTau.etaDetectorAxis(); - double absEta = std::abs(eta); + double absEta = std::abs( pTau.etaDetectorAxis() ); int etaBin = m_etaBinHist->GetXaxis()->FindBin(absEta) - 1; if (etaBin>=m_nEtaBins) etaBin = m_nEtaBins-1; // correction from last bin should be applied on all taus outside stored eta range - int nVertex = 0; // Obtain pileup @@ -220,7 +218,7 @@ StatusCode TauCalibrateLC::execute(xAOD::TauJet& pTau) const double energyFinal = energyPileupCorr / calibConst; - if (not m_doPtResponse) energyFinal /= cosh(pTau.eta()) ; + if (not m_doPtResponse) energyFinal /= std::cosh(pTau.eta()) ; pTau.setP4( energyFinal * GeV, pTau.eta(), pTau.phi(), pTau.m()); ATH_MSG_DEBUG("Energy at LC scale = " << energyLC << " pile-up offset " << offset << " calib. const. = " << calibConst << " final energy = " << energyFinal); @@ -252,7 +250,7 @@ StatusCode TauCalibrateLC::execute(xAOD::TauJet& pTau) const } ATH_MSG_DEBUG("eta " << eta << "; corrected eta = " << etaCorr << " ; phi " << phi << "; corrected phi " << phiCorr ); - pTau.setP4( pTau.e() / cosh( etaCorr ), etaCorr, phiCorr, pTau.m()); + pTau.setP4( pTau.e() / std::cosh( etaCorr ), etaCorr, phiCorr, pTau.m()); pTau.setP4(xAOD::TauJetParameters::TauEtaCalib, pTau.pt(), pTau.eta(), pTau.phi(), pTau.m()); } @@ -262,11 +260,3 @@ StatusCode TauCalibrateLC::execute(xAOD::TauJet& pTau) const return StatusCode::SUCCESS; } - -//----------------------------------------------------------------------------- -// Finalize -//----------------------------------------------------------------------------- - -StatusCode TauCalibrateLC::finalize() { - return StatusCode::SUCCESS; -} diff --git a/Reconstruction/tauRecTools/Root/TauCommonCalcVars.cxx b/Reconstruction/tauRecTools/Root/TauCommonCalcVars.cxx index a69c9f87a354ff8a843f08afeab2c883754d7737..d41d276f0df466bda0c31f0ca6012461f0431a7d 100644 --- a/Reconstruction/tauRecTools/Root/TauCommonCalcVars.cxx +++ b/Reconstruction/tauRecTools/Root/TauCommonCalcVars.cxx @@ -9,22 +9,19 @@ // date: 2008-05-18 // // This class calculates tau variables after core seed reconstruction -// -// 17/03/2010: (AK) change to P4Helpers -// 16/05/2011: (FF) fix if primaryVertexContainer==NULL (coverity 21734) -// Dez 2011: (FF) switch to full LC calibrated tau 4-vector for some variables //----------------------------------------------------------------------------- #include "tauRecTools/TauCommonCalcVars.h" #include "tauRecTools/KineUtils.h" #include <vector> + //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- TauCommonCalcVars::TauCommonCalcVars(const std::string &name) : -TauRecToolBase(name) { - //if TauTrackClassifier is not run, wide&passTrkSelector==classifiedIsolation==modifiedIsolationTrack - declareProperty("isolationTrackType", m_isolationTrackType=xAOD::TauJetParameters::modifiedIsolationTrack); + TauRecToolBase(name) { + //if TauTrackClassifier is not run, wide&passTrkSelector==classifiedIsolation==modifiedIsolationTrack + declareProperty("isolationTrackType", m_isolationTrackType=xAOD::TauJetParameters::modifiedIsolationTrack); } //----------------------------------------------------------------------------- @@ -34,180 +31,134 @@ TauRecToolBase(name) { TauCommonCalcVars::~TauCommonCalcVars() { } - -//----------------------------------------------------------------------------- -// Initializer -//----------------------------------------------------------------------------- - -StatusCode TauCommonCalcVars::initialize() { - return StatusCode::SUCCESS; -} - - -//----------------------------------------------------------------------------- -// Finalizer -//----------------------------------------------------------------------------- - -StatusCode TauCommonCalcVars::finalize() { - return StatusCode::SUCCESS; -} - - //----------------------------------------------------------------------------- // Execution //----------------------------------------------------------------------------- StatusCode TauCommonCalcVars::execute(xAOD::TauJet& pTau) const { - ///////////////////////////////////////////////// - // Calculate variables that are always valid - //////////////////////////////////////////////// + ///////////////////////////////////////////////// + // Calculate variables that are always valid + //////////////////////////////////////////////// - //init some vars - pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFrac, static_cast<float>( 0 ) ); + //init some vars + pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFrac, (float) 0. ); - // Leading track pT and et/pt(lead track) - if (pTau.nTracks() > 0) { - pTau.setDetail( xAOD::TauJetParameters::leadTrkPt, static_cast<float>( pTau.track(0)->pt() ) ); + // Leading track pT and et/pt(lead track) + if (pTau.nTracks() > 0) { + pTau.setDetail( xAOD::TauJetParameters::leadTrkPt, static_cast<float>( pTau.track(0)->pt() ) ); - float emscale_ptEM = 0; - float emscale_ptHad = 0; + float emscale_ptEM = 0.; + float emscale_ptHad = 0.; - if ( !pTau.detail( xAOD::TauJetParameters::etEMAtEMScale, emscale_ptEM ) ) - { - ATH_MSG_DEBUG("retrieval of tau detail failed. stopping calculation of further variables"); - return StatusCode::SUCCESS; - } - - if ( !pTau.detail( xAOD::TauJetParameters::etHadAtEMScale, emscale_ptHad ) ) - { - ATH_MSG_DEBUG("retrieval of tau detail failed. stopping calculation of further variables"); - return StatusCode::SUCCESS; - } + if ( !pTau.detail( xAOD::TauJetParameters::etEMAtEMScale, emscale_ptEM ) ) + { + ATH_MSG_DEBUG("retrieval of tau detail failed. stopping calculation of further variables"); + return StatusCode::SUCCESS; + } + + if ( !pTau.detail( xAOD::TauJetParameters::etHadAtEMScale, emscale_ptHad ) ) + { + ATH_MSG_DEBUG("retrieval of tau detail failed. stopping calculation of further variables"); + return StatusCode::SUCCESS; + } - pTau.setDetail( xAOD::TauJetParameters::etOverPtLeadTrk, static_cast<float>( (emscale_ptEM + emscale_ptHad) / pTau.track(0)->pt() ) ); - } + pTau.setDetail( xAOD::TauJetParameters::etOverPtLeadTrk, static_cast<float>( (emscale_ptEM + emscale_ptHad) / pTau.track(0)->pt() ) ); + } - // invariant mass of track system - std::vector<const xAOD::TauTrack*> tauTracks = pTau.tracks(xAOD::TauJetParameters::TauTrackFlag::classifiedCharged); - for( const xAOD::TauTrack* trk : pTau.tracks((xAOD::TauJetParameters::TauTrackFlag) m_isolationTrackType) ) tauTracks.push_back(trk); - if (tauTracks.size()> 0) { - - TLorentzVector sumOfTrackVector; - TLorentzVector tempTrackVector; - - for (const xAOD::TauTrack* tauTrk : tauTracks) - { - tempTrackVector=tauTrk->p4(); - sumOfTrackVector += tempTrackVector; - } - pTau.setDetail( xAOD::TauJetParameters::massTrkSys, static_cast<float>( sumOfTrackVector.M() ) ); - float tempfloat = 0; - if ( pTau.detail( xAOD::TauJetParameters::massTrkSys, tempfloat ) ) - ATH_MSG_VERBOSE("set massTrkSys " << tempfloat); - } + // invariant mass of track system + std::vector<const xAOD::TauTrack*> tauTracks = pTau.tracks(xAOD::TauJetParameters::TauTrackFlag::classifiedCharged); + for( const xAOD::TauTrack* trk : pTau.tracks((xAOD::TauJetParameters::TauTrackFlag) m_isolationTrackType) ) tauTracks.push_back(trk); + if (tauTracks.size()> 0) { - if (tauTracks.size()> 0 && pTau.nTracks()>1) { + TLorentzVector sumOfTrackVector; - double leadTrkPhi = pTau.track(0)->phi();//fix this depending on how we choose to define this - double leadTrkEta = pTau.track(0)->eta();//dito. new TauJet_v3 track sorting doesn't guarantee this will be the same track + for (const xAOD::TauTrack* tauTrk : tauTracks) + { + sumOfTrackVector += tauTrk->p4(); + } + pTau.setDetail( xAOD::TauJetParameters::massTrkSys, static_cast<float>( sumOfTrackVector.M() ) ); + } - double ptSum = 0; - double sumWeightedDR = 0; - double sumWeightedDR2 = 0; + if (tauTracks.size()> 0 && pTau.nTracks()>1) { + // BUG? + // this is equivalent to: if (pTau.nTracks()>1) + // shouldn't it be: if (tauTracks.size()> 1 && pTau.nTracks()>0) ? + // currently, 1-prong taus are skipped + double ptSum = 0.; + double sumWeightedDR = 0.; + double sumWeightedDR2 = 0.; - for (const xAOD::TauTrack* tauTrk : tauTracks){ + for (const xAOD::TauTrack* tauTrk : tauTracks) { - double deltaR = Tau1P3PKineUtils::deltaR(leadTrkEta, leadTrkPhi, tauTrk->eta(), tauTrk->phi() ); + double deltaR = pTau.track(0)->p4().DeltaR(tauTrk->p4()); - ptSum += tauTrk->pt(); - sumWeightedDR += deltaR * (tauTrk->pt()); - sumWeightedDR2 += deltaR * deltaR * (tauTrk->pt()); + ptSum += tauTrk->pt(); + sumWeightedDR += deltaR * tauTrk->pt(); + sumWeightedDR2 += deltaR * deltaR * tauTrk->pt(); + } - } + double trkWidth2 = (ptSum!=0.) ? (sumWeightedDR2/ptSum - std::pow(sumWeightedDR/ptSum, 2.)) : 0.; - double trkWidth2 = sumWeightedDR2 / ptSum - sumWeightedDR * sumWeightedDR / ptSum / ptSum; + if (trkWidth2 > 0.) pTau.setDetail( xAOD::TauJetParameters::trkWidth2, static_cast<float>( trkWidth2 ) ); + else pTau.setDetail( xAOD::TauJetParameters::trkWidth2, (float) 0. ); + } - if (trkWidth2 > 0.) pTau.setDetail( xAOD::TauJetParameters::trkWidth2, static_cast<float>( trkWidth2 ) ); - else pTau.setDetail( xAOD::TauJetParameters::trkWidth2, static_cast<float>( 0. ) ); - } + if (tauTracks.size()> 0) { + + double ptSum = 0; + double innerPtSum = 0; + double sumWeightedDR = 0; + double innerSumWeightedDR = 0; + double sumWeightedDR2 = 0; - if (tauTracks.size()> 0) { - - double ptSum = 0; - double innerPtSum = 0; - double sumWeightedDR = 0; - double innerSumWeightedDR = 0; - double sumWeightedDR2 = 0; - - - for (const xAOD::TauTrack* tauTrk : tauTracks){ - - double deltaR = Tau1P3PKineUtils::deltaR( ( inTrigger() ? pTau.eta() : pTau.etaIntermediateAxis()), pTau.phi(), tauTrk->eta(), tauTrk->phi() ); - - ptSum += tauTrk->pt(); - sumWeightedDR += deltaR * (tauTrk->pt()); - sumWeightedDR2 += deltaR * deltaR * (tauTrk->pt()); - - //add calculation of innerTrkAvgDist - if(tauTrk->flag(xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)){ - innerPtSum += tauTrk->pt(); - innerSumWeightedDR += deltaR * (tauTrk->pt()); - } - } - - if (ptSum > 0.0001) { - // seedCalo_trkAvgDist - pTau.setDetail( xAOD::TauJetParameters::trkAvgDist, static_cast<float>( sumWeightedDR / ptSum ) ); - - float tempfloat; - if ( pTau.detail( xAOD::TauJetParameters::trkAvgDist, tempfloat ) ) - ATH_MSG_VERBOSE("set seedCalo_trkAvgDist " << tempfloat ); - - // seedCalo_trkRmsDist - double trkRmsDist2 = sumWeightedDR2 / ptSum - sumWeightedDR * sumWeightedDR / ptSum / ptSum; - if (trkRmsDist2 > 0) { - pTau.setDetail( xAOD::TauJetParameters::trkRmsDist, static_cast<float>( sqrt(trkRmsDist2) ) ); - } else { - pTau.setDetail( xAOD::TauJetParameters::trkRmsDist, static_cast<float>( 0. ) ); - } - if ( pTau.detail( xAOD::TauJetParameters::trkRmsDist, tempfloat ) ) - ATH_MSG_VERBOSE("set seedCalo_trkRmsDist " << tempfloat ); - } - - if (ptSum > 0.0) { - - // SumPtTrkFrac - pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFrac, static_cast<float>( 1. - innerPtSum/ptSum ) ); - // FIXME!!! put pileup correction here once availabe - // FIXME!!! for now set corrected version same as uncorrected - pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFracCorrected, static_cast<float>( 1. - innerPtSum/ptSum ) ); + for (const xAOD::TauTrack* tauTrk : tauTracks){ + // BUG! should consistently use phiIntermediateAxis - will be fixed in a separate MR + double deltaR = Tau1P3PKineUtils::deltaR( ( inTrigger() ? pTau.eta() : pTau.etaIntermediateAxis()), pTau.phi(), tauTrk->eta(), tauTrk->phi() ); + // will become: + // double deltaR = inTrigger() ? pTau.p4().DeltaR(tauTrk->p4()) : pTau.p4(xAOD::TauJetParameters::IntermediateAxis).DeltaR(tauTrk->p4()); - } else { - - pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFrac, static_cast<float>( 0.0 ) ); - pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFracCorrected, static_cast<float>( 0.0 ) ); - - } - - if (ptSum > 0.00 && innerPtSum > 0.0) { - - ATH_MSG_DEBUG("innerSumWeightedDR = " << innerSumWeightedDR << " innerPtSum = " << innerPtSum << " ptSum = " << ptSum ); - - // InnerTrkAvgDist - pTau.setDetail( xAOD::TauJetParameters::innerTrkAvgDist, static_cast<float>( innerSumWeightedDR / innerPtSum ) ); - // FIXME!!! put pileup correction here once availabe - // FIXME!!! for now set corrected version same as uncorrected - pTau.setDetail( xAOD::TauJetParameters::innerTrkAvgDistCorrected, static_cast<float>( innerSumWeightedDR / innerPtSum ) ); - - } else { - pTau.setDetail( xAOD::TauJetParameters::innerTrkAvgDist, static_cast<float>( 0.0 )); - pTau.setDetail( xAOD::TauJetParameters::innerTrkAvgDistCorrected, static_cast<float>( 0.0 )); - } + ptSum += tauTrk->pt(); + sumWeightedDR += deltaR * tauTrk->pt(); + sumWeightedDR2 += deltaR * deltaR * tauTrk->pt(); + + //add calculation of innerTrkAvgDist + if(tauTrk->flag(xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)){ + innerPtSum += tauTrk->pt(); + innerSumWeightedDR += deltaR * tauTrk->pt(); + } + } + if (ptSum > 0.) { + // seedCalo_trkAvgDist + pTau.setDetail( xAOD::TauJetParameters::trkAvgDist, static_cast<float>( sumWeightedDR / ptSum ) ); + + // seedCalo_trkRmsDist + double trkRmsDist2 = sumWeightedDR2 / ptSum - pow(sumWeightedDR/ptSum, 2.); + if (trkRmsDist2 > 0.) { + pTau.setDetail( xAOD::TauJetParameters::trkRmsDist, static_cast<float>( std::sqrt(trkRmsDist2) ) ); + } + else { + pTau.setDetail( xAOD::TauJetParameters::trkRmsDist, (float) 0. ); + } + + // SumPtTrkFrac + pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFrac, static_cast<float>( 1. - innerPtSum/ptSum ) ); + } + else { + pTau.setDetail( xAOD::TauJetParameters::trkAvgDist, (float) 0. ); + pTau.setDetail( xAOD::TauJetParameters::SumPtTrkFrac, (float) 0. ); } - return StatusCode::SUCCESS; -} + if (innerPtSum > 0.) { + // InnerTrkAvgDist + pTau.setDetail( xAOD::TauJetParameters::innerTrkAvgDist, static_cast<float>( innerSumWeightedDR / innerPtSum ) ); + } + else { + pTau.setDetail( xAOD::TauJetParameters::innerTrkAvgDist, (float) 0. ); + } + } + return StatusCode::SUCCESS; +} diff --git a/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx b/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx index 028b99cd08634f595941ff19778ff76c9a7fafeb..e21dacbdddb7daf33ee1a8b17e0997ffa69271c0 100644 --- a/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx @@ -99,11 +99,6 @@ StatusCode TauEleOLRDecorator::execute(xAOD::TauJet& tau) const return StatusCode::SUCCESS; } -StatusCode TauEleOLRDecorator::finalize() -{ - return StatusCode::SUCCESS; -} - float TauEleOLRDecorator::getCutVal(float fEta, float fPt) const { if(fPt>1900) fPt=1900; diff --git a/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx b/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx index 4fb22ecafd8be8b58ce2ba0f2fd7df2a939079b1..b5bd887590eb22bf2f9352da4d017b1fdb608d27 100644 --- a/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx +++ b/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx @@ -114,13 +114,13 @@ StatusCode TauIDVarCalculator::execute(xAOD::TauJet& tau) const CaloSampling::HEC0, CaloSampling::TileBar0, CaloSampling::TileGap1, CaloSampling::TileExt0}; // Get Clusters via Jet Seed - const xAOD::Jet *jetSeed = (*tau.jetLink()); + const xAOD::Jet *jetSeed = tau.jet(); if (!jetSeed) { ATH_MSG_ERROR("Tau jet link is invalid."); return StatusCode::FAILURE; } - auto p4IntAxis = tau.p4(xAOD::TauJetParameters::IntermediateAxis); + const TLorentzVector& p4IntAxis = tau.p4(xAOD::TauJetParameters::IntermediateAxis); float eEMAtEMScaleFixed = 0; float eHadAtEMScaleFixed = 0; float eHad1AtEMScaleFixed = 0; @@ -145,8 +145,7 @@ StatusCode TauIDVarCalculator::execute(xAOD::TauJet& tau) const eEMAtEMScaleFixed / ( eEMAtEMScaleFixed + eHadAtEMScaleFixed ) : LOW_NUMBER; if(tau.nTracks() > 0){ - const xAOD::TrackParticle* track = 0; - track = tau.track(0)->track(); + const xAOD::TrackParticle* track = tau.track(0)->track(); acc_absEtaLead(tau) = std::abs( track->eta() ); acc_leadTrackEta(tau) = std::abs( track->eta() ); acc_absDeltaEta(tau) = std::abs( track->eta() - tau.eta() ); @@ -229,8 +228,3 @@ StatusCode TauIDVarCalculator::execute(xAOD::TauJet& tau) const return StatusCode::SUCCESS; } - -StatusCode TauIDVarCalculator::finalize() -{ - return StatusCode::SUCCESS; -} diff --git a/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx b/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx index d1bf07dc4a10eb3234e7713e4052fbaef2d3a9ce..99eabc40800227b2721c20b6cc6f5801bc3e3cd0 100644 --- a/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx +++ b/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx @@ -64,8 +64,3 @@ StatusCode TauJetBDTEvaluator::execute(xAOD::TauJet& xTau) const { return StatusCode::SUCCESS; } - -//________________________________________ -StatusCode TauJetBDTEvaluator::finalize(){ - return StatusCode::SUCCESS; -} diff --git a/Reconstruction/tauRecTools/Root/TauJetRNNEvaluator.cxx b/Reconstruction/tauRecTools/Root/TauJetRNNEvaluator.cxx index a46f5e6c6e75f397c5599c1061c7b45d39222324..bfa52f0a8e0308628854b135ec6d26b4356828d7 100644 --- a/Reconstruction/tauRecTools/Root/TauJetRNNEvaluator.cxx +++ b/Reconstruction/tauRecTools/Root/TauJetRNNEvaluator.cxx @@ -177,7 +177,7 @@ StatusCode TauJetRNNEvaluator::get_tracks( StatusCode TauJetRNNEvaluator::get_clusters( const xAOD::TauJet &tau, std::vector<const xAOD::CaloCluster *> &out) const { - const xAOD::Jet *jet_seed = *tau.jetLink(); + const xAOD::Jet *jet_seed = tau.jet(); if (!jet_seed) { ATH_MSG_ERROR("Tau jet link is invalid."); return StatusCode::FAILURE; diff --git a/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx b/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx index 2f77020605c5c44fa06abfbce0a2be6dac36a460..1adadc66ea3637a3f1e7d51944c462132c4e110f 100644 --- a/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx +++ b/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ //----------------------------------------------------------------------------- @@ -7,27 +7,21 @@ // package: Reconstruction/tauRec // authors: Benedict Winter, Will Davey // date: 2012-10-09 -// //----------------------------------------------------------------------------- -#include <vector> - #include "tauRecTools/TauPi0ScoreCalculator.h" #include "tauRecTools/HelperFunctions.h" #include "xAODPFlow/PFO.h" -using std::vector; -using std::string; - //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- -TauPi0ScoreCalculator::TauPi0ScoreCalculator( const string& name ) : +TauPi0ScoreCalculator::TauPi0ScoreCalculator(const std::string& name) : TauRecToolBase(name), m_mvaBDT(nullptr) { - declareProperty("BDTWeightFile", m_weightfile); + declareProperty("BDTWeightFile", m_weightfile); } //------------------------------------------------------------------------- @@ -38,7 +32,6 @@ TauPi0ScoreCalculator::~TauPi0ScoreCalculator() { } - StatusCode TauPi0ScoreCalculator::initialize() { std::string weightFile = find_file(m_weightfile); @@ -49,12 +42,6 @@ StatusCode TauPi0ScoreCalculator::initialize() return StatusCode::SUCCESS; } -StatusCode TauPi0ScoreCalculator::finalize() -{ - return StatusCode::SUCCESS; -} - - StatusCode TauPi0ScoreCalculator::executePi0nPFO(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer) const { //--------------------------------------------------------------------- @@ -79,7 +66,6 @@ StatusCode TauPi0ScoreCalculator::executePi0nPFO(xAOD::TauJet& pTau, xAOD::PFOCo return StatusCode::SUCCESS; } - float TauPi0ScoreCalculator::calculateScore(const xAOD::PFO* neutralPFO) const { std::map<TString, float> availableVariables; // map of the variable name to its value diff --git a/Reconstruction/tauRecTools/Root/TauPi0Selector.cxx b/Reconstruction/tauRecTools/Root/TauPi0Selector.cxx index 1fe30b074506cebb1fe7128e97c6b0b5c82ac188..6c80984f9de6337c9e235fa280909587a2196c83 100644 --- a/Reconstruction/tauRecTools/Root/TauPi0Selector.cxx +++ b/Reconstruction/tauRecTools/Root/TauPi0Selector.cxx @@ -7,18 +7,15 @@ // package: Reconstruction/tauRec // authors: Benedict Winter, Will Davey // date: 2012-10-09 -// //----------------------------------------------------------------------------- #include "tauRecTools/TauPi0Selector.h" -using std::string; - //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- -TauPi0Selector::TauPi0Selector( const string& name ) : +TauPi0Selector::TauPi0Selector(const std::string& name) : TauRecToolBase(name) { declareProperty("ClusterEtCut", m_clusterEtCut); @@ -34,29 +31,19 @@ TauPi0Selector::~TauPi0Selector() { } -StatusCode TauPi0Selector::initialize() -{ - return StatusCode::SUCCESS; -} - -StatusCode TauPi0Selector::finalize() -{ - return StatusCode::SUCCESS; -} - StatusCode TauPi0Selector::executePi0nPFO(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer) const { // decay mode enum auto kDecayModeProto = xAOD::TauJetParameters::PanTau_DecayModeProto; // Clear vector of cell-based pi0 PFO Links. Required when rerunning on xAOD level. pTau.clearProtoPi0PFOLinks(); - // Set proto decay mode to "not set". Will be overwritten for taus with 1-5 tracks - pTau.setPanTauDetail(kDecayModeProto, xAOD::TauJetParameters::DecayMode::Mode_NotSet); //--------------------------------------------------------------------- // only run on 1-5 prong taus //--------------------------------------------------------------------- if (pTau.nTracks() == 0 || pTau.nTracks() >5 ) { + // Set proto decay mode to "not set". Will be overwritten for taus with 1-5 tracks + pTau.setPanTauDetail(kDecayModeProto, xAOD::TauJetParameters::DecayMode::Mode_NotSet); return StatusCode::SUCCESS; } @@ -153,8 +140,8 @@ TLorentzVector TauPi0Selector::getP4(const xAOD::TauJet& pTau) const const xAOD::PFO* pi0PFO = (*pi0PFOLink); // assign neutral pion mass double mass = 134.9766; - double p = std::sqrt(pow(pi0PFO->e(),2) - pow(mass,2)); - double pt = p/cosh(pi0PFO->eta()); + double p = std::sqrt(std::pow(pi0PFO->e(),2) - std::pow(mass,2)); + double pt = p/std::cosh(pi0PFO->eta()); TLorentzVector pi0_corrP4; pi0_corrP4.SetPtEtaPhiM(pt,pi0PFO->eta(),pi0PFO->phi(),mass); p4+=pi0_corrP4; diff --git a/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx b/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx index 1d5fdd5d5edbd88f79fc76c6f8ff3ea657d9d2d9..05437d8655be4ff3cc9e0e3669772a55ef34ffb3 100644 --- a/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx +++ b/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx @@ -18,26 +18,21 @@ #include "tauRecTools/CaloClusterVariables.h" #include "tauRecTools/TauSubstructureVariables.h" - -#include "tauRecTools/KineUtils.h" #include "tauRecTools/HelperFunctions.h" #define GeV 1000 -const double TauSubstructureVariables::DEFAULT = -1111.; +const float TauSubstructureVariables::DEFAULT = -1111.; //********************************** // Constructor //********************************** TauSubstructureVariables::TauSubstructureVariables( const std::string& name ) - : TauRecToolBase(name) { - declareProperty("maxPileUpCorrection", m_maxPileUpCorrection = 4 * GeV); - declareProperty("pileUpAlpha", m_pileUpAlpha = 1.0); - declareProperty("VertexCorrection", m_doVertexCorrection = false); - declareProperty("IncShowerSubtr", m_incShowerSubtr = true); + : TauRecToolBase(name) { + declareProperty("VertexCorrection", m_doVertexCorrection = false); + declareProperty("IncShowerSubtr", m_incShowerSubtr = true); } - //********************************** // Destructor //********************************** @@ -45,301 +40,190 @@ TauSubstructureVariables::TauSubstructureVariables( const std::string& name ) TauSubstructureVariables::~TauSubstructureVariables() { } - -//*********************************** -// Initialize method -//*********************************** - -StatusCode TauSubstructureVariables::initialize() { - return StatusCode::SUCCESS; -} - -//*********************************** -// Finalize method -//*********************************** - -StatusCode TauSubstructureVariables::finalize() { - return StatusCode::SUCCESS; -} - - //************************************ // Execute method //************************************ StatusCode TauSubstructureVariables::execute(xAOD::TauJet& pTau) const { - const xAOD::Jet* taujetseed = (*pTau.jetLink()); - if (!taujetseed) { - ATH_MSG_ERROR("Tau jet link is invalid."); - return StatusCode::FAILURE; - } - - //***************************************************** - // calculate some tau substructure variables - //***************************************************** - - CaloClusterVariables CaloClusterVariablesTool; - CaloClusterVariablesTool.setVertexCorrection(m_doVertexCorrection); - CaloClusterVariablesTool.setIncSub(m_incShowerSubtr); - - bool isFilled = CaloClusterVariablesTool.update(pTau); - - if (!isFilled) { - ATH_MSG_DEBUG("problem in calculating calo cluster variables -> will be set to -1111"); - - pTau.setDetail(xAOD::TauJetParameters::numTopoClusters , static_cast<int>(DEFAULT) ); - pTau.setDetail(xAOD::TauJetParameters::numEffTopoClusters , static_cast<float>(DEFAULT) ); - pTau.setDetail(xAOD::TauJetParameters::topoInvMass, static_cast<float>(DEFAULT) ); - pTau.setDetail(xAOD::TauJetParameters::effTopoInvMass, static_cast<float>(DEFAULT) ); - pTau.setDetail(xAOD::TauJetParameters::topoMeanDeltaR, static_cast<float>(DEFAULT) ); - pTau.setDetail(xAOD::TauJetParameters::effTopoMeanDeltaR, static_cast<float>(DEFAULT) ); - - } else { - // Getting the variables - //----------------------- - double TopoInvMass = CaloClusterVariablesTool.totalMass(); - double EffTopoInvMass = CaloClusterVariablesTool.effectiveMass(); - unsigned int NumTopoClusters = CaloClusterVariablesTool.numConstituents(); - double NumEffTopoClusters = CaloClusterVariablesTool.effectiveNumConstituents(); - double TopoMeanDeltaR = CaloClusterVariablesTool.averageRadius(); - double EffTopoMeanDeltaR = CaloClusterVariablesTool.averageEffectiveRadius(); - - ATH_MSG_VERBOSE(" Substructure variables: "); - ATH_MSG_VERBOSE("-------------------------"); - ATH_MSG_VERBOSE(" TopoInvMass: " << TopoInvMass); - ATH_MSG_VERBOSE(" EffTopoInvMass: " << EffTopoInvMass); - ATH_MSG_VERBOSE(" NumTopoClusters: " << NumTopoClusters); - ATH_MSG_VERBOSE("NumEffTopoClusters: " << NumEffTopoClusters); - ATH_MSG_VERBOSE(" TopoMeanDeltaR: " << TopoMeanDeltaR); - ATH_MSG_VERBOSE(" EffTopoMeanDeltaR: " << EffTopoMeanDeltaR); - - //Record the variables - //--------------------- - - pTau.setDetail(xAOD::TauJetParameters::numTopoClusters , static_cast<int> (NumTopoClusters) ); - pTau.setDetail(xAOD::TauJetParameters::numEffTopoClusters , static_cast<float>(NumEffTopoClusters) ); - pTau.setDetail(xAOD::TauJetParameters::topoInvMass , static_cast<float>(TopoInvMass) ); - pTau.setDetail(xAOD::TauJetParameters::effTopoInvMass , static_cast<float>(EffTopoInvMass) ); - pTau.setDetail(xAOD::TauJetParameters::topoMeanDeltaR , static_cast<float>(TopoMeanDeltaR) ); - pTau.setDetail(xAOD::TauJetParameters::effTopoMeanDeltaR , static_cast<float>(EffTopoMeanDeltaR) ); - - } - - //***************************************************** - // calculate some new cluster based ID variables - //***************************************************** - // New cluster-based variables - float totalEnergy(0.); - float calo_iso(0.); - float dr(0.); - - unsigned int num_clusters(0); - - TLorentzVector leadClusVec; - TLorentzVector subLeadClusVec; - TLorentzVector approxSubstructure4Vec; - double clusELead = -1111.0; - double clusESubLead = -1111.0; - - // Loop through jets, get links to clusters - std::vector<const xAOD::CaloCluster*> vClusters; - ATH_CHECK(tauRecTools::GetJetClusterList(taujetseed, vClusters, m_incShowerSubtr)); - - for (auto incluster : vClusters){ - ++num_clusters; - - // calc total energy - totalEnergy += incluster->e(); + const xAOD::Jet* taujetseed = pTau.jet(); + if (!taujetseed) { + ATH_MSG_ERROR("Tau jet link is invalid."); + return StatusCode::FAILURE; + } + + //***************************************************** + // calculate some tau substructure variables + //***************************************************** + + CaloClusterVariables CaloClusterVariablesTool; + CaloClusterVariablesTool.setVertexCorrection(m_doVertexCorrection); + CaloClusterVariablesTool.setIncSub(m_incShowerSubtr); + + bool isFilled = CaloClusterVariablesTool.update(pTau); + + if (!isFilled) { + ATH_MSG_DEBUG("problem in calculating calo cluster variables -> will be set to -1111"); + + pTau.setDetail(xAOD::TauJetParameters::numTopoClusters, static_cast<int>(DEFAULT)); + pTau.setDetail(xAOD::TauJetParameters::numEffTopoClusters, DEFAULT); + pTau.setDetail(xAOD::TauJetParameters::topoInvMass, DEFAULT); + pTau.setDetail(xAOD::TauJetParameters::effTopoInvMass, DEFAULT); + pTau.setDetail(xAOD::TauJetParameters::topoMeanDeltaR, DEFAULT); + pTau.setDetail(xAOD::TauJetParameters::effTopoMeanDeltaR, DEFAULT); + } + else { + pTau.setDetail(xAOD::TauJetParameters::numTopoClusters, static_cast<int>(CaloClusterVariablesTool.numConstituents())); + pTau.setDetail(xAOD::TauJetParameters::numEffTopoClusters, static_cast<float>(CaloClusterVariablesTool.effectiveNumConstituents())); + pTau.setDetail(xAOD::TauJetParameters::topoInvMass, static_cast<float>(CaloClusterVariablesTool.totalMass())); + pTau.setDetail(xAOD::TauJetParameters::effTopoInvMass, static_cast<float>(CaloClusterVariablesTool.effectiveMass())); + pTau.setDetail(xAOD::TauJetParameters::topoMeanDeltaR, static_cast<float>(CaloClusterVariablesTool.averageRadius())); + pTau.setDetail(xAOD::TauJetParameters::effTopoMeanDeltaR, static_cast<float>(CaloClusterVariablesTool.averageEffectiveRadius())); + } + + //***************************************************** + // calculate some new cluster based ID variables + //***************************************************** + // New cluster-based variables + float totalEnergy(0.); + float calo_iso(0.); + float dr(0.); + + TLorentzVector leadClusVec; + TLorentzVector subLeadClusVec; + TLorentzVector approxSubstructure4Vec; + double clusELead = DEFAULT; + double clusESubLead = DEFAULT; + + // Loop through jets, get links to clusters + std::vector<const xAOD::CaloCluster*> vClusters; + ATH_CHECK(tauRecTools::GetJetClusterList(taujetseed, vClusters, m_incShowerSubtr)); + + for (auto incluster : vClusters){ + + // calc total energy + totalEnergy += incluster->e(); - //apply Vertex correction on a temporary - TLorentzVector tempclusvec; - if (m_doVertexCorrection && pTau.vertexLink()) - tempclusvec = CaloVertexedClusterType(*incluster, (*pTau.vertexLink())->position()).p4(); - else - tempclusvec = CaloVertexedClusterType(*incluster).p4(); - - dr = Tau1P3PKineUtils::deltaR(pTau.eta(),pTau.phi(), tempclusvec.Eta(), tempclusvec.Phi()); - if (0.2 <= dr && dr < 0.4) - { - calo_iso += tempclusvec.Et(); - } - else if (dr < 0.2) - { - double clusEnergyBE = ( incluster->energyBE(0) + incluster->energyBE(1) + incluster->energyBE(2) ); + //apply Vertex correction on a temporary + TLorentzVector tempclusvec; + if (m_doVertexCorrection && pTau.vertexLink()) + tempclusvec = CaloVertexedClusterType(*incluster, pTau.vertex()->position()).p4(); + else + tempclusvec = CaloVertexedClusterType(*incluster).p4(); + + dr = pTau.p4().DeltaR(tempclusvec); + if (0.2 <= dr && dr < 0.4) + { + calo_iso += tempclusvec.Et(); + } + else if (dr < 0.2) + { + double clusEnergyBE = ( incluster->energyBE(0) + incluster->energyBE(1) + incluster->energyBE(2) ); - if (clusEnergyBE > clusELead) - { - //change current leading cluster to subleading - clusESubLead = clusELead; - subLeadClusVec = leadClusVec; - - //set energy and 4-vector of leading cluster - clusELead = clusEnergyBE; - leadClusVec.SetPtEtaPhiM(clusELead/cosh(tempclusvec.Eta()), tempclusvec.Eta(), tempclusvec.Phi(), 0); - } - else if (clusEnergyBE > clusESubLead) - { - //set energy and 4-vector of subleading cluster only - clusESubLead = clusEnergyBE; - subLeadClusVec.SetPtEtaPhiM(clusESubLead/cosh(tempclusvec.Eta()), tempclusvec.Eta(), tempclusvec.Phi(), 0); - } - - } - - } - - if (clusELead > 0.) { - approxSubstructure4Vec += leadClusVec; - } - if (clusESubLead > 0.) { - approxSubstructure4Vec += subLeadClusVec; + if (clusEnergyBE > clusELead) + { + //change current leading cluster to subleading + clusESubLead = clusELead; + subLeadClusVec = leadClusVec; + + //set energy and 4-vector of leading cluster + clusELead = clusEnergyBE; + leadClusVec.SetPtEtaPhiM(clusELead/std::cosh(tempclusvec.Eta()), tempclusvec.Eta(), tempclusvec.Phi(), 0.); + } + else if (clusEnergyBE > clusESubLead) + { + //set energy and 4-vector of subleading cluster only + clusESubLead = clusEnergyBE; + subLeadClusVec.SetPtEtaPhiM(clusESubLead/std::cosh(tempclusvec.Eta()), tempclusvec.Eta(), tempclusvec.Phi(), 0.); } - // now sort cluster by energy - std::sort(vClusters.begin(), vClusters.end(), DefCaloClusterCompare()); - - // determine energy sum of leading 2 and leading 3 clusters - float sum2LeadClusterE(0.); - float sum3LeadClusterE(0.); - std::vector<const xAOD::CaloCluster*>::const_iterator icluster(vClusters.begin()); - std::vector<const xAOD::CaloCluster*>::const_iterator icluster_end(vClusters.end()); - - for (; icluster != icluster_end && icluster != vClusters.begin() + 3; ++icluster) { - if (icluster < vClusters.begin() + 2) { - sum2LeadClusterE += (*icluster)->e(); - } - sum3LeadClusterE += (*icluster)->e(); - } - - //record variables - if (totalEnergy != 0) { - ATH_MSG_VERBOSE(" lead2ClusterEOverAllClusterE: " << sum2LeadClusterE / totalEnergy); - ATH_MSG_VERBOSE(" lead3ClusterEOverAllClusterE: " << sum3LeadClusterE / totalEnergy); - - pTau.setDetail(xAOD::TauJetParameters::lead2ClusterEOverAllClusterE, static_cast<float>(sum2LeadClusterE / totalEnergy) ); - pTau.setDetail(xAOD::TauJetParameters::lead3ClusterEOverAllClusterE, static_cast<float>(sum3LeadClusterE / totalEnergy) ); - } - - ATH_MSG_VERBOSE(" caloIso: " << calo_iso); - pTau.setDetail(xAOD::TauJetParameters::caloIso, static_cast<float>(calo_iso) ); - - // calculate calorimeter energies in different layers - float PSSEnergy(0.); - float EMEnergy(0.); - float HADEnergy(0.); - icluster = vClusters.begin(); - for (; icluster != icluster_end; ++icluster) { - float clEnergy = (*icluster)->e(); - - //Calculate the fractions of energy in different calorimeter layers - const xAOD::CaloCluster *cl = *icluster; - float PreSampler = cl->eSample(CaloSampling::PreSamplerB) + cl->eSample(CaloSampling::PreSamplerE); - float EMLayer1 = cl->eSample(CaloSampling::EMB1) + cl->eSample(CaloSampling::EME1); - float EMLayer2 = cl->eSample(CaloSampling::EMB2) + cl->eSample(CaloSampling::EME2); - - float Energy = cl->rawE(); - float PSSF = Energy != 0 ? (PreSampler + EMLayer1) / Energy : 0; - float EM2F = Energy != 0 ? EMLayer2 / Energy : 0; - float EMF = PSSF + EM2F; - - PSSEnergy += PSSF * clEnergy; - EMEnergy += EMF * clEnergy; - HADEnergy += (Energy != 0) ? (1 - EMF) * clEnergy : 0; - } - - // calculate trk momentum - float trkSysMomentum(0.); - for (unsigned int i(0); i < pTau.nTracks(); ++i) { - trkSysMomentum += pTau.track(i)->pt() * cosh(pTau.track(i)->eta()); - - //adding the core tracks to the approximate substructure 4 vector - approxSubstructure4Vec += pTau.track(i)->p4(); - } - - // set new approximate energy flow variables for tau ID - pTau.setDetail(xAOD::TauJetParameters::ptRatioEflowApprox, static_cast<float>(approxSubstructure4Vec.Pt()/ pTau.ptDetectorAxis()) ); - pTau.setDetail(xAOD::TauJetParameters::mEflowApprox, static_cast<float>(approxSubstructure4Vec.M()) ); - - - float fPSSFraction = (totalEnergy != 0) ? PSSEnergy / totalEnergy : DEFAULT; - float fChPIEMEOverCaloEME = (EMEnergy != 0) ? (trkSysMomentum - HADEnergy) / EMEnergy : DEFAULT; - float fEMPOverTrkSysP = DEFAULT; - if (pTau.nTracks() > 0) fEMPOverTrkSysP = (trkSysMomentum != 0) ? EMEnergy / trkSysMomentum : DEFAULT; - - pTau.setDetail(xAOD::TauJetParameters::PSSFraction, static_cast<float>(fPSSFraction)); - pTau.setDetail(xAOD::TauJetParameters::ChPiEMEOverCaloEME, static_cast<float>(fChPIEMEOverCaloEME)); - pTau.setDetail(xAOD::TauJetParameters::EMPOverTrkSysP, static_cast<float>(fEMPOverTrkSysP)); - - // jvf and sumPtTrk are now a vector and the old run1-type jvf value is stored in the 0-th element - // sumPtTrk is calculated wrt Vertices - - float jvf(0.0); - float sumPtTrk(0.0); - - // for tau trigger: JVF and sumPtTrack are not available - if (!inTrigger()) - { - std::vector<float> sumPtTrkvec; - std::vector<float> jvfvec; - - // ToDo still need to check if the 500MeV threshold is correct - taujetseed->getAttribute(xAOD::JetAttribute::SumPtTrkPt500, sumPtTrkvec); - taujetseed->getAttribute(xAOD::JetAttribute::JVF, jvfvec); - - if (!jvfvec.empty() && !sumPtTrkvec.empty()) { - // ToDo need to check if first vertex is the vertex we want to use here! - jvf = jvfvec[0]; - sumPtTrk = sumPtTrkvec[0]; - } - else { - ATH_MSG_WARNING("jvf value vector and/or sumPtTrk vector returned from seed jet is empty!"); - } - } - - float pt_pileup = (1.0 - jvf) * sumPtTrk; - - const float max_pileup_correction = m_maxPileUpCorrection; - const float alpha = m_pileUpAlpha; - float pileup_correction = alpha * pt_pileup; - - ATH_MSG_VERBOSE(" --------------------------------------"); - ATH_MSG_VERBOSE(" Pile-up correction parameter"); - ATH_MSG_VERBOSE(" -> sumPtTrk: " << sumPtTrk); - ATH_MSG_VERBOSE(" -> jvf: " << jvf); - ATH_MSG_VERBOSE(" -> pt_pileup: " << pt_pileup); - ATH_MSG_VERBOSE(" -> alpha: " << alpha); - ATH_MSG_VERBOSE(" -> max pileup corr: " << max_pileup_correction); - - if (pileup_correction > max_pileup_correction) { - pileup_correction = max_pileup_correction; - } - const float calo_iso_corrected = calo_iso - pileup_correction; - - ATH_MSG_VERBOSE(" -> pileup corr: " << pileup_correction); - ATH_MSG_VERBOSE(" --------------------------------------"); - - //record variable - ATH_MSG_VERBOSE(" caloIsoCorrected: " << calo_iso_corrected); - pTau.setDetail(xAOD::TauJetParameters::caloIsoCorrected, static_cast<float>(calo_iso_corrected) ); - - // calculate dRMax - unsigned int numTrack(pTau.nTracks()); - if (numTrack > 0) { - float dRmin = -1 * -1111; - float dRmax = -1111; - float dR; - - for (unsigned int i(0); i < numTrack; ++i) { - if (pTau.track(i) == 0) continue; - dR = Tau1P3PKineUtils::deltaR( pTau.track(i)->eta(), pTau.track(i)->phi(), pTau.eta(), pTau.phi() ); - if (dRmin > dR) dRmin = dR; - if (dRmax < dR) dRmax = dR; - } - //record variable - ATH_MSG_VERBOSE(" dRmax: " << dRmax); - pTau.setDetail(xAOD::TauJetParameters::dRmax, static_cast<float>(dRmax) ); - } - - return StatusCode::SUCCESS; + } + + } + + if (clusELead > 0.) { + approxSubstructure4Vec += leadClusVec; + } + if (clusESubLead > 0.) { + approxSubstructure4Vec += subLeadClusVec; + } + + // now sort cluster by energy + std::sort(vClusters.begin(), vClusters.end(), DefCaloClusterCompare()); + + // determine energy sum of leading 2 and leading 3 clusters + float sum2LeadClusterE = 0.; + if(vClusters.size()>0) { + sum2LeadClusterE = vClusters.at(0)->e(); + if(vClusters.size()>1) sum2LeadClusterE += vClusters.at(1)->e(); + } + float sum3LeadClusterE = sum2LeadClusterE; + if(vClusters.size()>2) sum3LeadClusterE += vClusters.at(2)->e(); + + if (totalEnergy != 0.) { + pTau.setDetail(xAOD::TauJetParameters::lead2ClusterEOverAllClusterE, (sum2LeadClusterE / totalEnergy) ); + pTau.setDetail(xAOD::TauJetParameters::lead3ClusterEOverAllClusterE, (sum3LeadClusterE / totalEnergy) ); + } + + pTau.setDetail(xAOD::TauJetParameters::caloIso, calo_iso); + + // calculate calorimeter energies in different layers + float PSSEnergy(0.); + float EMEnergy(0.); + float HADEnergy(0.); + + for (auto cl : vClusters) { + float clEnergy = cl->e(); + + //Calculate the fractions of energy in different calorimeter layers + float PreSampler = cl->eSample(CaloSampling::PreSamplerB) + cl->eSample(CaloSampling::PreSamplerE); + float EMLayer1 = cl->eSample(CaloSampling::EMB1) + cl->eSample(CaloSampling::EME1); + float EMLayer2 = cl->eSample(CaloSampling::EMB2) + cl->eSample(CaloSampling::EME2); + + float Energy = cl->rawE(); + float PSSF = Energy != 0 ? (PreSampler + EMLayer1) / Energy : 0; + float EM2F = Energy != 0 ? EMLayer2 / Energy : 0; + float EMF = PSSF + EM2F; + + PSSEnergy += PSSF * clEnergy; + EMEnergy += EMF * clEnergy; + HADEnergy += (Energy != 0) ? (1 - EMF) * clEnergy : 0; + } + + // calculate trk momentum + float trkSysMomentum(0.); + for (size_t i=0; i < pTau.nTracks(); ++i) { + trkSysMomentum += pTau.track(i)->pt() * std::cosh(pTau.track(i)->eta()); + + //adding the core tracks to the approximate substructure 4 vector + approxSubstructure4Vec += pTau.track(i)->p4(); + } + + // set new approximate energy flow variables for tau ID + pTau.setDetail(xAOD::TauJetParameters::ptRatioEflowApprox, static_cast<float>(approxSubstructure4Vec.Pt()/ pTau.ptDetectorAxis()) ); + pTau.setDetail(xAOD::TauJetParameters::mEflowApprox, static_cast<float>(approxSubstructure4Vec.M()) ); + + float fPSSFraction = (totalEnergy != 0.) ? PSSEnergy / totalEnergy : DEFAULT; + float fChPIEMEOverCaloEME = (EMEnergy != 0.) ? (trkSysMomentum - HADEnergy) / EMEnergy : DEFAULT; + float fEMPOverTrkSysP = DEFAULT; + if (pTau.nTracks() > 0) fEMPOverTrkSysP = (trkSysMomentum != 0.) ? EMEnergy / trkSysMomentum : DEFAULT; + + pTau.setDetail(xAOD::TauJetParameters::PSSFraction, fPSSFraction); + pTau.setDetail(xAOD::TauJetParameters::ChPiEMEOverCaloEME, fChPIEMEOverCaloEME); + pTau.setDetail(xAOD::TauJetParameters::EMPOverTrkSysP, fEMPOverTrkSysP); + + // calculate dRMax + size_t numTrack = pTau.nTracks(); + if (numTrack > 0) { + float dRmax = 0.; + float dR = 0.; + + for (size_t i=0; i < numTrack; ++i) { + dR = pTau.track(i)->p4().DeltaR(pTau.p4()); + if (dR > dRmax) dRmax = dR; + } + pTau.setDetail(xAOD::TauJetParameters::dRmax, dRmax); + } + + return StatusCode::SUCCESS; } diff --git a/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx b/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx index 5150e1ca4ffc76d2e6461baf29144d7792f7c3be..7268663e5c9158c18b1288c4fabde082dc4cb0d3 100644 --- a/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx +++ b/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx @@ -45,13 +45,6 @@ StatusCode TauTrackClassifier::initialize() return StatusCode::SUCCESS; } - -StatusCode TauTrackClassifier::finalize() -{ - return StatusCode::SUCCESS; -} - - //______________________________________________________________________________ StatusCode TauTrackClassifier::executeTrackClassifier(xAOD::TauJet& xTau, xAOD::TauTrackContainer& tauTrackCon) const { @@ -130,66 +123,67 @@ StatusCode TrackMVABDT::finalize() //______________________________________________________________________________ StatusCode TrackMVABDT::initialize() { - m_mAvailableVars={{"TracksAuxDyn.tauPt", new float(0)} - , {"TracksAuxDyn.jetSeedPt", new float(0)} - , {"TracksAuxDyn.tauEta", new float(0)} - , {"TracksAuxDyn.trackEta", new float(0)} - , {"TracksAuxDyn.z0sinThetaTJVA", new float(0)} - , {"TracksAuxDyn.rConv", new float(0)} - , {"TracksAuxDyn.rConvII", new float(0)} - , {"TauTracksAuxDyn.rConv/TauTracksAuxDyn.rConvII", new float(0)} - , {"TracksAuxDyn.DRJetSeedAxis", new float(0)} - , {"TracksAuxDyn.dRJetSeedAxis", new float(0)} - , {"TracksAux.d0", new float(0)} - , {"TracksAux.qOverP", new float(0)} - , {"TracksAux.theta", new float(0)} - , {"TracksAux.eProbabilityHT", new float(0)} - , {"TracksAux.numberOfInnermostPixelLayerHits", new float(0)} - , {"TracksAux.numberOfPixelHits", new float(0)} - , {"TracksAux.numberOfPixelDeadSensors", new float(0)} - , {"TracksAux.numberOfPixelSharedHits", new float(0)} - , {"TracksAux.numberOfSCTHits", new float(0)} - , {"TracksAux.numberOfSCTDeadSensors", new float(0)} - , {"TracksAux.numberOfSCTSharedHits", new float(0)} - , {"TracksAux.numberOfTRTHighThresholdHits", new float(0)} - , {"TracksAux.numberOfTRTHits", new float(0)} - , {"TracksAux.numberOfPixelHits+TracksAux.numberOfPixelDeadSensors", new float(0)} - , {"TracksAux.numberOfPixelHits+TracksAux.numberOfPixelDeadSensors+TracksAux.numberOfSCTHits+TracksAux.numberOfSCTDeadSensors", new float(0)} - - , {"TauTracksAuxDyn.tauPt", new float(0)} - , {"TauTracksAuxDyn.jetSeedPt", new float(0)} - , {"TauTracksAuxDyn.tauEta", new float(0)} - , {"TauTracksAuxDyn.trackEta", new float(0)} - , {"TauTracksAuxDyn.z0sinThetaTJVA", new float(0)} - , {"TauTracksAuxDyn.rConv", new float(0)} - , {"TauTracksAuxDyn.rConvII", new float(0)} - , {"TauTracksAuxDyn.dRJetSeedAxis", new float(0)} - , {"TauTracksAuxDyn.d0", new float(0)} - , {"TauTracksAuxDyn.qOverP", new float(0)} - , {"TauTracksAuxDyn.theta", new float(0)} - , {"TauTracksAuxDyn.eProbabilityHT", new float(0)} - , {"TauTracksAuxDyn.numberOfInnermostPixelLayerHits", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHits", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelDeadSensors", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelSharedHits", new float(0)} - , {"TauTracksAuxDyn.numberOfSCTHits", new float(0)} - , {"TauTracksAuxDyn.numberOfSCTDeadSensors", new float(0)} - , {"TauTracksAuxDyn.numberOfSCTSharedHits", new float(0)} - , {"TauTracksAuxDyn.numberOfTRTHighThresholdHits", new float(0)} - , {"TauTracksAuxDyn.numberOfTRTHits", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors+TauTracksAuxDyn.numberOfSCTHits+TauTracksAuxDyn.numberOfSCTDeadSensors", new float(0)} - - - , {"1/(TauTracksAuxDyn.trackPt)", new float(0)} - , {"fabs(TauTracksAuxDyn.qOverP)", new float(0)} - , {"TauTracksAuxDyn.numberOfContribPixelLayers", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors+TauTracksAuxDyn.numberOfPixelHoles", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors+TauTracksAuxDyn.numberOfPixelHoles+TauTracksAuxDyn.numberOfSCTHits+TauTracksAuxDyn.numberOfSCTDeadSensors+TauTracksAuxDyn.numberOfSCTHoles", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHoles", new float(0)} - , {"TauTracksAuxDyn.numberOfPixelHoles+TauTracksAuxDyn.numberOfSCTHoles", new float(0)} - , {"TauTracksAuxDyn.numberOfSCTHoles", new float(0)} - , {"TauTracksAux.pt", new float(0)} + m_mAvailableVars={ + {"TracksAuxDyn.tauPt", new float(0)} + , {"TracksAuxDyn.jetSeedPt", new float(0)} + , {"TracksAuxDyn.tauEta", new float(0)} + , {"TracksAuxDyn.trackEta", new float(0)} + , {"TracksAuxDyn.z0sinThetaTJVA", new float(0)} + , {"TracksAuxDyn.rConv", new float(0)} + , {"TracksAuxDyn.rConvII", new float(0)} + , {"TauTracksAuxDyn.rConv/TauTracksAuxDyn.rConvII", new float(0)} + , {"TracksAuxDyn.DRJetSeedAxis", new float(0)} + , {"TracksAuxDyn.dRJetSeedAxis", new float(0)} + , {"TracksAux.d0", new float(0)} + , {"TracksAux.qOverP", new float(0)} + , {"TracksAux.theta", new float(0)} + , {"TracksAux.eProbabilityHT", new float(0)} + , {"TracksAux.numberOfInnermostPixelLayerHits", new float(0)} + , {"TracksAux.numberOfPixelHits", new float(0)} + , {"TracksAux.numberOfPixelDeadSensors", new float(0)} + , {"TracksAux.numberOfPixelSharedHits", new float(0)} + , {"TracksAux.numberOfSCTHits", new float(0)} + , {"TracksAux.numberOfSCTDeadSensors", new float(0)} + , {"TracksAux.numberOfSCTSharedHits", new float(0)} + , {"TracksAux.numberOfTRTHighThresholdHits", new float(0)} + , {"TracksAux.numberOfTRTHits", new float(0)} + , {"TracksAux.numberOfPixelHits+TracksAux.numberOfPixelDeadSensors", new float(0)} + , {"TracksAux.numberOfPixelHits+TracksAux.numberOfPixelDeadSensors+TracksAux.numberOfSCTHits+TracksAux.numberOfSCTDeadSensors", new float(0)} + + , {"TauTracksAuxDyn.tauPt", new float(0)} + , {"TauTracksAuxDyn.jetSeedPt", new float(0)} + , {"TauTracksAuxDyn.tauEta", new float(0)} + , {"TauTracksAuxDyn.trackEta", new float(0)} + , {"TauTracksAuxDyn.z0sinThetaTJVA", new float(0)} + , {"TauTracksAuxDyn.rConv", new float(0)} + , {"TauTracksAuxDyn.rConvII", new float(0)} + , {"TauTracksAuxDyn.dRJetSeedAxis", new float(0)} + , {"TauTracksAuxDyn.d0", new float(0)} + , {"TauTracksAuxDyn.qOverP", new float(0)} + , {"TauTracksAuxDyn.theta", new float(0)} + , {"TauTracksAuxDyn.eProbabilityHT", new float(0)} + , {"TauTracksAuxDyn.numberOfInnermostPixelLayerHits", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHits", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelDeadSensors", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelSharedHits", new float(0)} + , {"TauTracksAuxDyn.numberOfSCTHits", new float(0)} + , {"TauTracksAuxDyn.numberOfSCTDeadSensors", new float(0)} + , {"TauTracksAuxDyn.numberOfSCTSharedHits", new float(0)} + , {"TauTracksAuxDyn.numberOfTRTHighThresholdHits", new float(0)} + , {"TauTracksAuxDyn.numberOfTRTHits", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors+TauTracksAuxDyn.numberOfSCTHits+TauTracksAuxDyn.numberOfSCTDeadSensors", new float(0)} + + + , {"1/(TauTracksAuxDyn.trackPt)", new float(0)} + , {"fabs(TauTracksAuxDyn.qOverP)", new float(0)} + , {"TauTracksAuxDyn.numberOfContribPixelLayers", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors+TauTracksAuxDyn.numberOfPixelHoles", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHits+TauTracksAuxDyn.numberOfPixelDeadSensors+TauTracksAuxDyn.numberOfPixelHoles+TauTracksAuxDyn.numberOfSCTHits+TauTracksAuxDyn.numberOfSCTDeadSensors+TauTracksAuxDyn.numberOfSCTHoles", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHoles", new float(0)} + , {"TauTracksAuxDyn.numberOfPixelHoles+TauTracksAuxDyn.numberOfSCTHoles", new float(0)} + , {"TauTracksAuxDyn.numberOfSCTHoles", new float(0)} + , {"TauTracksAux.pt", new float(0)} }; ATH_CHECK(addWeightsFile()); @@ -331,6 +325,5 @@ StatusCode TrackMVABDT::setVars(const xAOD::TauTrack& xTrack, const xAOD::TauJet setVar("TauTracksAuxDyn.numberOfSCTHoles") = fNumberOfSCTHoles; setVar("TauTracksAux.pt") = xTrackParticle->pt(); - return StatusCode::SUCCESS; - + return StatusCode::SUCCESS; } diff --git a/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx b/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx index cab8bec41f24d8a3f4f69420f1897349fd3a562c..94e7daaf6ef7ac89d8063483c35f53bb89172d30 100644 --- a/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx @@ -10,8 +10,7 @@ #include "TFile.h" #include "TH2.h" - - +//______________________________________________________________________________ TauWPDecorator::TauWPDecorator(const std::string& name) : TauRecToolBase(name) { declareProperty("UseEleBDT", m_electronMode = false); @@ -34,13 +33,11 @@ TauWPDecorator::TauWPDecorator(const std::string& name) : declareProperty("DecorWPCutEffs3P", m_decorWPEffs3p); } - - +//______________________________________________________________________________ TauWPDecorator::~TauWPDecorator() { } - - +//______________________________________________________________________________ StatusCode TauWPDecorator::retrieveHistos(int nProng) { // Find and open file std::string fileName; @@ -91,8 +88,7 @@ StatusCode TauWPDecorator::retrieveHistos(int nProng) { return StatusCode::SUCCESS; } - - +//______________________________________________________________________________ StatusCode TauWPDecorator::storeLimits(int nProng) { std::shared_ptr<std::vector<m_pair_t>> histArray = nullptr; if (nProng == 0) { @@ -131,14 +127,14 @@ StatusCode TauWPDecorator::storeLimits(int nProng) { return StatusCode::SUCCESS; } +//______________________________________________________________________________ double TauWPDecorator::transformScore(double score, double cutLow, double effLow, double cutHigh, double effHigh) const { double efficiency = effLow + (score - cutLow)/(cutHigh - cutLow) * (effHigh - effLow); double scoreTrans = 1.0 - efficiency; return scoreTrans; } - - +//______________________________________________________________________________ StatusCode TauWPDecorator::initialize() { ATH_CHECK( m_aveIntPerXKey.initialize() ); @@ -172,8 +168,7 @@ StatusCode TauWPDecorator::initialize() { return StatusCode::SUCCESS; } - - +//______________________________________________________________________________ StatusCode TauWPDecorator::execute(xAOD::TauJet& pTau) const { // obtain the dependent variables of the efficiency // -- x variable is tau pt @@ -305,9 +300,3 @@ StatusCode TauWPDecorator::execute(xAOD::TauJet& pTau) const { return StatusCode::SUCCESS; } - - - -StatusCode TauWPDecorator::finalize() { - return StatusCode::SUCCESS; -} diff --git a/Reconstruction/tauRecTools/src/JetSeedBuilder.cxx b/Reconstruction/tauRecTools/src/JetSeedBuilder.cxx index cf349446aa11f0dae3b0b2cac4b9da378a55feb4..17950599553cb8cc64ff9831b5bfac38aba15e62 100644 --- a/Reconstruction/tauRecTools/src/JetSeedBuilder.cxx +++ b/Reconstruction/tauRecTools/src/JetSeedBuilder.cxx @@ -12,38 +12,23 @@ #include "xAODTau/TauJetAuxContainer.h" #include "xAODTau/TauJet.h" - - +//______________________________________________________________________________ JetSeedBuilder::JetSeedBuilder(const std::string& name) : TauRecToolBase(name) { } - - +//______________________________________________________________________________ JetSeedBuilder::~JetSeedBuilder() { } - - -StatusCode JetSeedBuilder::initialize() { - return StatusCode::SUCCESS; -} - - - -StatusCode JetSeedBuilder::finalize() { - return StatusCode::SUCCESS; -} - - - +//______________________________________________________________________________ StatusCode JetSeedBuilder::execute(xAOD::TauJet& pTau) const { ATH_MSG_DEBUG("Starting execute"); const xAOD::Jet* jetSeed = nullptr; if (pTau.jetLink().isValid()) { - jetSeed = * pTau.jetLink(); + jetSeed = pTau.jet(); } else { ATH_MSG_ERROR("seed is not a jet -> tau will not be reconstructed"); @@ -76,4 +61,3 @@ StatusCode JetSeedBuilder::execute(xAOD::TauJet& pTau) const { } #endif - diff --git a/Reconstruction/tauRecTools/src/JetSeedBuilder.h b/Reconstruction/tauRecTools/src/JetSeedBuilder.h index ea014e431d1246640c93ee81c3ef6539714ea955..f52c5f533eff6999ce76f890810212d7c00701db 100644 --- a/Reconstruction/tauRecTools/src/JetSeedBuilder.h +++ b/Reconstruction/tauRecTools/src/JetSeedBuilder.h @@ -26,14 +26,8 @@ class JetSeedBuilder : public TauRecToolBase { /** @brief Destructor */ virtual ~JetSeedBuilder(); - /** @brief Initialization of this tool */ - virtual StatusCode initialize() override; - /** @brief Executation of this tool */ virtual StatusCode execute(xAOD::TauJet& pTau) const override; - - /** @brief Finalization of this tool */ - virtual StatusCode finalize() override; }; #endif /* JETSEEDBUILDER_H */ diff --git a/Reconstruction/tauRecTools/src/TauAxisSetter.cxx b/Reconstruction/tauRecTools/src/TauAxisSetter.cxx index 7713d7b53bfb6e6035229435832646acd427a4a1..281811a695e9593fd0dde1870d755904d3ca3dcf 100644 --- a/Reconstruction/tauRecTools/src/TauAxisSetter.cxx +++ b/Reconstruction/tauRecTools/src/TauAxisSetter.cxx @@ -12,28 +12,19 @@ #include "xAODTau/TauJet.h" #include "CaloUtils/CaloVertexedCluster.h" - - +//______________________________________________________________________________ TauAxisSetter::TauAxisSetter(const std::string& name) : TauRecToolBase(name) { } - - +//______________________________________________________________________________ TauAxisSetter::~TauAxisSetter() { } - - -StatusCode TauAxisSetter::initialize() { - return StatusCode::SUCCESS; -} - - - +//______________________________________________________________________________ StatusCode TauAxisSetter::execute(xAOD::TauJet& pTau) const { - const xAOD::Jet* pJetSeed = (*pTau.jetLink()); + const xAOD::Jet* pJetSeed = pTau.jet(); if (!pJetSeed) { ATH_MSG_ERROR("Tau jet link is invalid."); return StatusCode::FAILURE; @@ -91,7 +82,7 @@ StatusCode TauAxisSetter::execute(xAOD::TauJet& pTau) const { ATH_CHECK(tauRecTools::GetJetClusterList(pJetSeed, clusterList, m_incShowerSubtr, baryCenter, m_clusterCone)); for (auto cluster : clusterList){ if (pTau.vertexLink()) { - tauInterAxis += xAOD::CaloVertexedCluster(*cluster, (*pTau.vertexLink())->position()).p4(); + tauInterAxis += xAOD::CaloVertexedCluster(*cluster, pTau.vertex()->position()).p4(); } else { tauInterAxis += xAOD::CaloVertexedCluster(*cluster).p4(); @@ -106,10 +97,4 @@ StatusCode TauAxisSetter::execute(xAOD::TauJet& pTau) const { return StatusCode::SUCCESS; } - - -StatusCode TauAxisSetter::finalize() { - return StatusCode::SUCCESS; -} - #endif diff --git a/Reconstruction/tauRecTools/src/TauAxisSetter.h b/Reconstruction/tauRecTools/src/TauAxisSetter.h index 2f239a426f25900dbc5f2397a3bac3b39a0a774d..09095467f33a74abe6e8c59c9f0d20d0482f9aea 100644 --- a/Reconstruction/tauRecTools/src/TauAxisSetter.h +++ b/Reconstruction/tauRecTools/src/TauAxisSetter.h @@ -33,14 +33,8 @@ class TauAxisSetter : public TauRecToolBase { /** @brief Destructor */ ~TauAxisSetter(); - /** @brief Initialization of this tool */ - virtual StatusCode initialize() override; - /** @brief Execution of this tool */ virtual StatusCode execute(xAOD::TauJet& pTau) const override; - - /** @brief Finalization of this tool */ - virtual StatusCode finalize() override; private: diff --git a/Reconstruction/tauRecTools/src/TauCellVariables.cxx b/Reconstruction/tauRecTools/src/TauCellVariables.cxx index f43b65e91fd8a67107e5e363de34eae07e4c28cd..ddceb6ffbfb6e4589382325c22fb66094f1f970b 100644 --- a/Reconstruction/tauRecTools/src/TauCellVariables.cxx +++ b/Reconstruction/tauRecTools/src/TauCellVariables.cxx @@ -15,34 +15,19 @@ #include <cmath> #include <vector> - - +//______________________________________________________________________________ TauCellVariables::TauCellVariables(const std::string& name) : TauRecToolBase(name) { } - - +//______________________________________________________________________________ TauCellVariables::~TauCellVariables() { } - - -StatusCode TauCellVariables::finalize() { - return StatusCode::SUCCESS; -} - - - -StatusCode TauCellVariables::initialize() { - return StatusCode::SUCCESS; -} - - - +//______________________________________________________________________________ StatusCode TauCellVariables::execute(xAOD::TauJet& pTau) const { - const xAOD::Jet* pJetSeed = (*pTau.jetLink()); + const xAOD::Jet* pJetSeed = pTau.jet(); if (!pJetSeed) { ATH_MSG_ERROR("tau does not have jet seed for cell variable calculation"); return StatusCode::FAILURE; @@ -94,7 +79,7 @@ StatusCode TauCellVariables::execute(xAOD::TauJet& pTau) const { // correct cell four momentum based on tau vertex if (m_doVertexCorrection && pTau.vertexLink()) { - CaloVertexedCell vxCell (*cell, (*pTau.vertexLink())->position()); + CaloVertexedCell vxCell (*cell, pTau.vertex()->position()); cellPhi = vxCell.phi(); cellEta = vxCell.eta(); cellET = vxCell.et(); @@ -202,4 +187,3 @@ StatusCode TauCellVariables::execute(xAOD::TauJet& pTau) const { } #endif - diff --git a/Reconstruction/tauRecTools/src/TauCellVariables.h b/Reconstruction/tauRecTools/src/TauCellVariables.h index 13119d343b6a79ee91afac4f6783d5b62baab14b..0d2c2336a454a3f6a76dcfd8a38f344ec8d77193 100644 --- a/Reconstruction/tauRecTools/src/TauCellVariables.h +++ b/Reconstruction/tauRecTools/src/TauCellVariables.h @@ -25,12 +25,6 @@ class TauCellVariables : public TauRecToolBase { /** @brief Destructor */ ~TauCellVariables(); - /** @brief Initialization of this tool */ - virtual StatusCode initialize() override; - - /** @brief Finalization of this tool */ - virtual StatusCode finalize() override; - /** @brief Perform the calculation of cell variables for each tau candidate */ virtual StatusCode execute(xAOD::TauJet& pTau) const override; @@ -49,8 +43,7 @@ class TauCellVariables : public TauRecToolBase { Gaudi::Property<bool> m_incShowerSubtr {this, "IncShowerSubtr", true, "use shower subtracted clusters in calo calculations"}; }; - - +//______________________________________________________________________________ inline bool TauCellVariables::isEMLayer(const CaloSampling::CaloSample& calo) const { if ((calo == CaloSampling::PreSamplerB) || (calo == CaloSampling::PreSamplerE) || @@ -65,8 +58,7 @@ inline bool TauCellVariables::isEMLayer(const CaloSampling::CaloSample& calo) co } } - - +//______________________________________________________________________________ inline bool TauCellVariables::isStripLayer(const CaloSampling::CaloSample& calo) const { if ((calo == CaloSampling::EMB1) || (calo == CaloSampling::EME1)) { @@ -78,4 +70,3 @@ inline bool TauCellVariables::isStripLayer(const CaloSampling::CaloSample& calo) } #endif /* TAUREC_TAUCELLVARIABLES_H */ - diff --git a/Reconstruction/tauRecTools/src/TauElectronVetoVariables.cxx b/Reconstruction/tauRecTools/src/TauElectronVetoVariables.cxx index 6f2eccd2cd574e6f8818c20cabb0106fe802b158..a47162cb0ab48d388adf8de3023aad79eb59a0d7 100644 --- a/Reconstruction/tauRecTools/src/TauElectronVetoVariables.cxx +++ b/Reconstruction/tauRecTools/src/TauElectronVetoVariables.cxx @@ -3,24 +3,6 @@ */ #ifndef XAOD_ANALYSIS -//----------------------------------------------------------------------------- -// file: tau1p3pEleVeto.cxx -// package: Reconstruction/tauRec -// authors: Zofia Czyczula -// date: 2006-09-27 -// -// -// This tool veto electrons. -// -// MODIFIED: -// 02-04-2007 - (AK) protection against missing egamma Collection -// 25-03-2008 - (AK for ZC) upgade of the code -// 28-03-1008 - (AK) fix for protection against missing egamma Collection -// ERROR->WARNING -// 15/04/2008 - (AK) fixing compilation warning bug #35463 -// 03-10-2008 - (ZC) upgarade of the code -// 16/03/2010 - (AK) use the cell id instead of the pointer -//----------------------------------------------------------------------------- #include <algorithm> #include <cmath> @@ -52,14 +34,6 @@ TauRecToolBase(name) { //------------------------------------------------------------------------- TauElectronVetoVariables::~TauElectronVetoVariables() { } -//------------------------------------------------------------------------- -// Finalizer -//------------------------------------------------------------------------- -StatusCode TauElectronVetoVariables::finalize() -{ - return StatusCode::SUCCESS; -} - //------------------------------------------------------------------------- // Initializer //------------------------------------------------------------------------- @@ -194,7 +168,7 @@ StatusCode TauElectronVetoVariables::execute(xAOD::TauJet& pTau) const } } - const xAOD::Jet* pJetSeed = (*pTau.jetLink()); + const xAOD::Jet* pJetSeed = pTau.jet(); if (!pJetSeed) { ATH_MSG_ERROR("tau does not have jet seed for electron veto cell variable calculation"); return StatusCode::FAILURE; @@ -220,7 +194,7 @@ StatusCode TauElectronVetoVariables::execute(xAOD::TauJet& pTau) const else cellSeen.set(pCell->caloDDE()->calo_hash()); if (m_doVertexCorrection && pTau.vertexLink()) { - CaloVertexedCell vxCell (*pCell, (*pTau.vertexLink())->position()); + CaloVertexedCell vxCell (*pCell, pTau.vertex()->position()); cellPhi = vxCell.phi(); cellEta = vxCell.eta(); cellET = vxCell.et(); diff --git a/Reconstruction/tauRecTools/src/TauElectronVetoVariables.h b/Reconstruction/tauRecTools/src/TauElectronVetoVariables.h index d239719254f93975e1b5353826ac117ed7ff4899..975c731e44038d589252291598133738cfe5b376 100644 --- a/Reconstruction/tauRecTools/src/TauElectronVetoVariables.h +++ b/Reconstruction/tauRecTools/src/TauElectronVetoVariables.h @@ -31,7 +31,6 @@ public: virtual ~TauElectronVetoVariables(); virtual StatusCode execute(xAOD::TauJet& pTau) const override; virtual StatusCode initialize() override; - virtual StatusCode finalize() override; private: Gaudi::Property<bool> m_doVertexCorrection {this, "VertexCorrection", false, "switch of vertex correction"}; diff --git a/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.cxx b/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.cxx index 3cf2711b00d2f34fb39cc47a34495bda68391628..eed20fb0e6a3d2aa44d5b79837eb43b6f4c49223 100644 --- a/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.cxx +++ b/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.cxx @@ -8,7 +8,6 @@ // package: Reconstruction/tauEvent // authors: Benedict Winter, Will Davey, Stephanie Yuen // date: 2012-10-09 -// //----------------------------------------------------------------------------- #include "CaloUtils/CaloClusterStoreHelper.h" @@ -18,14 +17,11 @@ #include "TauPi0ClusterCreator.h" #include "tauRecTools/HelperFunctions.h" -using std::vector; -using std::string; - //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- -TauPi0ClusterCreator::TauPi0ClusterCreator( const string& name) : +TauPi0ClusterCreator::TauPi0ClusterCreator(const std::string& name) : TauRecToolBase(name) { } @@ -37,24 +33,14 @@ TauPi0ClusterCreator::~TauPi0ClusterCreator() { } - -StatusCode TauPi0ClusterCreator::initialize() -{ - return StatusCode::SUCCESS; -} - -StatusCode TauPi0ClusterCreator::finalize() -{ - return StatusCode::SUCCESS; -} - +//______________________________________________________________________________ StatusCode TauPi0ClusterCreator::executePi0ClusterCreator(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer, xAOD::PFOContainer& hadronicClusterPFOContainer, xAOD::CaloClusterContainer& pi0CaloClusterContainer, const xAOD::CaloClusterContainer& pPi0ClusterContainer) const { // Any tau needs to have PFO vectors. Set empty vectors before nTrack cut - vector<ElementLink<xAOD::PFOContainer> > empty; + std::vector<ElementLink<xAOD::PFOContainer> > empty; pTau.setProtoChargedPFOLinks(empty); pTau.setProtoNeutralPFOLinks(empty); pTau.setProtoPi0PFOLinks(empty); @@ -100,9 +86,9 @@ StatusCode TauPi0ClusterCreator::executePi0ClusterCreator(xAOD::TauJet& pTau, xA // calorimeter is required. float EM1CoreFrac = getEM1CoreFrac(pPi0Cluster); int NHitsInEM1 = getNPhotons(shotVector, shotsInCluster); - vector<int> NPosECellsInLayer = getNPosECells(pPi0Cluster); - vector<float> firstEtaWRTClusterPositionInLayer = get1stEtaMomWRTCluster(pPi0Cluster); - vector<float> secondEtaWRTClusterPositionInLayer = get2ndEtaMomWRTCluster(pPi0Cluster); + std::vector<int> NPosECellsInLayer = getNPosECells(pPi0Cluster); + std::vector<float> firstEtaWRTClusterPositionInLayer = get1stEtaMomWRTCluster(pPi0Cluster); + std::vector<float> secondEtaWRTClusterPositionInLayer = get2ndEtaMomWRTCluster(pPi0Cluster); // Retrieve cluster moments that are used for fake supression and that are not stored in AOD // for every cluster. Do this after applying the vertex correction, since the moments @@ -209,6 +195,7 @@ StatusCode TauPi0ClusterCreator::executePi0ClusterCreator(xAOD::TauJet& pTau, xA return StatusCode::SUCCESS; } +//______________________________________________________________________________ // Functions used to calculate BDT variables other than those provided by the CaloClusterMomentsMaker float TauPi0ClusterCreator::getEM1CoreFrac(const xAOD::CaloCluster* pi0Candidate) const { @@ -234,6 +221,7 @@ float TauPi0ClusterCreator::getEM1CoreFrac(const xAOD::CaloCluster* pi0Candidate return coreEnergy/sumEPosCellsEM1; } +//______________________________________________________________________________ // Do cluster to shot matching. // A cluster is matched to a shot if the seed cell of the shot is in the cluster std::map<unsigned, xAOD::CaloCluster*> TauPi0ClusterCreator::getClusterToShotMap(const std::vector<const xAOD::PFO*>& shotVector, @@ -292,6 +280,7 @@ std::map<unsigned, xAOD::CaloCluster*> TauPi0ClusterCreator::getClusterToShotMap return clusterToShotMap; } +//______________________________________________________________________________ std::vector<unsigned> TauPi0ClusterCreator::getShotsMatchedToCluster(const std::vector<const xAOD::PFO*>& shotVector, const std::map<unsigned, xAOD::CaloCluster*>& clusterToShotMap, const xAOD::CaloCluster* pPi0Cluster) const @@ -306,6 +295,7 @@ std::vector<unsigned> TauPi0ClusterCreator::getShotsMatchedToCluster(const std:: return shotsMatchedToCluster; } +//______________________________________________________________________________ int TauPi0ClusterCreator::getNPhotons(const std::vector<const xAOD::PFO*>& shotVector, const std::vector<unsigned>& shotsInCluster ) const { @@ -319,9 +309,10 @@ int TauPi0ClusterCreator::getNPhotons(const std::vector<const xAOD::PFO*>& shotV return nPhotons; } -vector<int> TauPi0ClusterCreator::getNPosECells(const xAOD::CaloCluster* pi0Candidate) const +//______________________________________________________________________________ +std::vector<int> TauPi0ClusterCreator::getNPosECells(const xAOD::CaloCluster* pi0Candidate) const { - vector<int> nPosECellsInLayer(3,0); // 3 layers initialised with 0 +ve cells + std::vector<int> nPosECellsInLayer(3,0); // 3 layers initialised with 0 +ve cells const CaloClusterCellLink* theCellLink = pi0Candidate->getCellLinks(); CaloClusterCellLink::const_iterator cellInClusterItr = theCellLink->begin(); @@ -338,11 +329,11 @@ vector<int> TauPi0ClusterCreator::getNPosECells(const xAOD::CaloCluster* pi0Cand return nPosECellsInLayer; } - -vector<float> TauPi0ClusterCreator::get1stEtaMomWRTCluster(const xAOD::CaloCluster* pi0Candidate) const +//______________________________________________________________________________ +std::vector<float> TauPi0ClusterCreator::get1stEtaMomWRTCluster(const xAOD::CaloCluster* pi0Candidate) const { - vector<float> firstEtaWRTClusterPositionInLayer (4, 0.); //init with 0. for 0-3 layers - vector<float> sumEInLayer (4, 0.); //init with 0. for 0-3 layers + std::vector<float> firstEtaWRTClusterPositionInLayer (4, 0.); //init with 0. for 0-3 layers + std::vector<float> sumEInLayer (4, 0.); //init with 0. for 0-3 layers const CaloClusterCellLink* theCellLink = pi0Candidate->getCellLinks(); CaloClusterCellLink::const_iterator cellInClusterItr = theCellLink->begin(); @@ -370,10 +361,11 @@ vector<float> TauPi0ClusterCreator::get1stEtaMomWRTCluster(const xAOD::CaloClust return firstEtaWRTClusterPositionInLayer; } -vector<float> TauPi0ClusterCreator::get2ndEtaMomWRTCluster( const xAOD::CaloCluster* pi0Candidate) const +//______________________________________________________________________________ +std::vector<float> TauPi0ClusterCreator::get2ndEtaMomWRTCluster( const xAOD::CaloCluster* pi0Candidate) const { - vector<float> secondEtaWRTClusterPositionInLayer (4, 0.); //init with 0. for 0-3 layers - vector<float> sumEInLayer (4, 0.); //init with 0. for 0-3 layers + std::vector<float> secondEtaWRTClusterPositionInLayer (4, 0.); //init with 0. for 0-3 layers + std::vector<float> sumEInLayer (4, 0.); //init with 0. for 0-3 layers const CaloClusterCellLink* theCellLinks = pi0Candidate->getCellLinks(); @@ -398,9 +390,10 @@ vector<float> TauPi0ClusterCreator::get2ndEtaMomWRTCluster( const xAOD::CaloClus return secondEtaWRTClusterPositionInLayer; } +//______________________________________________________________________________ bool TauPi0ClusterCreator::setHadronicClusterPFOs(xAOD::TauJet& pTau, xAOD::PFOContainer& pHadronPFOContainer) const { - const xAOD::Jet* tauJetSeed = (*pTau.jetLink()); + const xAOD::Jet* tauJetSeed = pTau.jet(); if (!tauJetSeed) { ATH_MSG_ERROR("Could not retrieve tau jet seed"); return false; diff --git a/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.h b/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.h index ef90efafbb2a1fd4a6445c106f2234eccdfa08a3..6185d81cb347e34cf20499c4311132618e1b9cd1 100644 --- a/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.h +++ b/Reconstruction/tauRecTools/src/TauPi0ClusterCreator.h @@ -26,8 +26,6 @@ public: ASG_TOOL_CLASS2(TauPi0ClusterCreator, TauRecToolBase, ITauToolBase); virtual ~TauPi0ClusterCreator(); - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; virtual StatusCode executePi0ClusterCreator(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer, xAOD::PFOContainer& hadronicClusterPFOContainer, xAOD::CaloClusterContainer& pi0CaloClusContainer, diff --git a/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.cxx b/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.cxx index e20747d4892432a2ad095d6add4ef07c3f32bf93..ff5fa8094347dcae034adf5f07fd43c74d0ba5d9 100644 --- a/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.cxx +++ b/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.cxx @@ -7,7 +7,6 @@ // package: Reconstruction/tauRec // authors: Stephanie Yuen, Benedict Winter, Will Davey // date: 2014-08-04 -// //----------------------------------------------------------------------------- #include <vector> @@ -19,14 +18,11 @@ #include "FourMomUtils/xAODP4Helpers.h" #include "xAODCaloEvent/CaloVertexedTopoCluster.h" -using std::vector; -using std::string; - //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- -TauPi0ClusterScaler::TauPi0ClusterScaler( const string& name ) : +TauPi0ClusterScaler::TauPi0ClusterScaler(const std::string& name) : TauRecToolBase(name) { } @@ -39,18 +35,7 @@ TauPi0ClusterScaler::~TauPi0ClusterScaler() { } - -StatusCode TauPi0ClusterScaler::initialize() -{ - return StatusCode::SUCCESS; -} - -StatusCode TauPi0ClusterScaler::finalize() -{ - return StatusCode::SUCCESS; -} - - +//______________________________________________________________________________ StatusCode TauPi0ClusterScaler::executePi0ClusterScaler(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer, xAOD::PFOContainer& chargedPFOContainer) const { // Clear vector of cell-based charged PFO Links. @@ -82,6 +67,7 @@ StatusCode TauPi0ClusterScaler::executePi0ClusterScaler(xAOD::TauJet& pTau, xAOD return StatusCode::SUCCESS; } +//______________________________________________________________________________ void TauPi0ClusterScaler::resetNeutralPFOs(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer) const { // Set neutral PFO kinematics to vertex corrected cluster @@ -92,7 +78,7 @@ void TauPi0ClusterScaler::resetNeutralPFOs(xAOD::TauJet& pTau, xAOD::PFOContaine // apply cluster vertex correction if(pTau.vertexLink()){ - auto clcorr = xAOD::CaloVertexedTopoCluster(*cl, (*pTau.vertexLink())->position()); + auto clcorr = xAOD::CaloVertexedTopoCluster(*cl, pTau.vertex()->position()); pfo->setP4(clcorr.pt(), clcorr.eta(), clcorr.phi(), 0.0); } else{ @@ -107,8 +93,7 @@ void TauPi0ClusterScaler::resetNeutralPFOs(xAOD::TauJet& pTau, xAOD::PFOContaine } } - - +//______________________________________________________________________________ void TauPi0ClusterScaler::createChargedPFOs(xAOD::TauJet& pTau, xAOD::PFOContainer& cPFOContainer) const { ATH_MSG_DEBUG("Creating charged PFOs"); @@ -137,6 +122,7 @@ void TauPi0ClusterScaler::createChargedPFOs(xAOD::TauJet& pTau, xAOD::PFOContain } } +//______________________________________________________________________________ void TauPi0ClusterScaler::associateHadronicToChargedPFOs(xAOD::TauJet& pTau, xAOD::PFOContainer& chargedPFOContainer) const { ATH_MSG_DEBUG("Associating hadronic PFOs to charged PFOs"); @@ -215,6 +201,7 @@ void TauPi0ClusterScaler::associateHadronicToChargedPFOs(xAOD::TauJet& pTau, xAO } } +//______________________________________________________________________________ void TauPi0ClusterScaler::associateChargedToNeutralPFOs(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer) const { ATH_MSG_DEBUG("Associating charged PFOs to neutral PFOs"); @@ -293,7 +280,7 @@ void TauPi0ClusterScaler::associateChargedToNeutralPFOs(xAOD::TauJet& pTau, xAOD } } - +//______________________________________________________________________________ void TauPi0ClusterScaler::subtractChargedEnergyFromNeutralPFOs(xAOD::PFOContainer& neutralPFOContainer) const { ATH_MSG_DEBUG("Subtracting charged energy from neutral PFOs"); @@ -328,11 +315,10 @@ void TauPi0ClusterScaler::subtractChargedEnergyFromNeutralPFOs(xAOD::PFOContaine neutralEnergy -= chargedEMEnergy; ATH_MSG_DEBUG("Subtracting charged energy: " << chargedEMEnergy ); } - float neutralPt = neutralEnergy / cosh(neutralPFO->eta()); + float neutralPt = neutralEnergy / std::cosh(neutralPFO->eta()); if(neutralPt <= 100.) neutralPt = 100.0; ATH_MSG_DEBUG("Neutral PFO pt, orig: " << neutralPFO->pt() << " new: " << neutralPt); neutralPFO->setP4(neutralPt , neutralPFO->eta(), neutralPFO->phi(), neutralPFO->m()); } } - diff --git a/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.h b/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.h index 9bfe5c51c5b7f6aec079a542688c67d3b4c1b52b..bb05d81d099398cdb304e1982152bafd45383e1c 100644 --- a/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.h +++ b/Reconstruction/tauRecTools/src/TauPi0ClusterScaler.h @@ -28,8 +28,6 @@ public: ASG_TOOL_CLASS2(TauPi0ClusterScaler, TauRecToolBase, ITauToolBase) virtual ~TauPi0ClusterScaler(); - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; virtual StatusCode executePi0ClusterScaler(xAOD::TauJet& pTau, xAOD::PFOContainer& pNeutralPFOContainer, xAOD::PFOContainer& pChargedPFOContainer) const override; private: diff --git a/Reconstruction/tauRecTools/src/TauPi0CreateROI.cxx b/Reconstruction/tauRecTools/src/TauPi0CreateROI.cxx index f96b1d173c2b7eee80c3199f2f74f70e45ab9e45..b372dffc1ae1ae3efbcbd7b148ff6ba9640d1169 100644 --- a/Reconstruction/tauRecTools/src/TauPi0CreateROI.cxx +++ b/Reconstruction/tauRecTools/src/TauPi0CreateROI.cxx @@ -15,14 +15,11 @@ #include <boost/scoped_ptr.hpp> -using std::vector; -using std::string; - //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- -TauPi0CreateROI::TauPi0CreateROI( const string& name ) : +TauPi0CreateROI::TauPi0CreateROI(const std::string& name) : TauRecToolBase(name) { } @@ -44,6 +41,7 @@ StatusCode TauPi0CreateROI::initialize() { return StatusCode::SUCCESS; } +//______________________________________________________________________________ StatusCode TauPi0CreateROI::executePi0CreateROI(xAOD::TauJet& pTau, CaloCellContainer& pPi0CellContainer, std::vector<CaloCell*>& addedCellsMap) { //--------------------------------------------------------------------- @@ -67,7 +65,7 @@ StatusCode TauPi0CreateROI::executePi0CreateROI(xAOD::TauJet& pTau, CaloCellCont pCellContainer = caloCellInHandle.cptr(); // get only EM cells within dR<0.4 - vector<CaloCell_ID::SUBCALO> emSubCaloBlocks; + std::vector<CaloCell_ID::SUBCALO> emSubCaloBlocks; emSubCaloBlocks.push_back(CaloCell_ID::LAREM); boost::scoped_ptr<CaloCellList> pCells(new CaloCellList(pCellContainer,emSubCaloBlocks)); pCells->select(pTau.eta(), pTau.phi(), 0.4); // TODO: change hardcoded 0.4 to tau cone variable, (or func. from TauJet)? @@ -98,8 +96,4 @@ StatusCode TauPi0CreateROI::executePi0CreateROI(xAOD::TauJet& pTau, CaloCellCont return StatusCode::SUCCESS; } -StatusCode TauPi0CreateROI::finalize() { - return StatusCode::SUCCESS; -} - #endif diff --git a/Reconstruction/tauRecTools/src/TauPi0CreateROI.h b/Reconstruction/tauRecTools/src/TauPi0CreateROI.h index cc30fd6204aa74f61289351148f4e38e1ca52ee9..b5b7a1fe055f115607037062b0b28ea7d9e66309 100644 --- a/Reconstruction/tauRecTools/src/TauPi0CreateROI.h +++ b/Reconstruction/tauRecTools/src/TauPi0CreateROI.h @@ -32,7 +32,6 @@ public: virtual StatusCode initialize() override; virtual StatusCode executePi0CreateROI(xAOD::TauJet& pTau, CaloCellContainer& Pi0CellContainer, std::vector<CaloCell*>& map) override; - virtual StatusCode finalize() override; private: SG::ReadHandleKey<CaloCellContainer> m_caloCellInputContainer{this,"Key_caloCellInputContainer", "AllCalo", "input vertex container key"}; diff --git a/Reconstruction/tauRecTools/src/TauShotFinder.cxx b/Reconstruction/tauRecTools/src/TauShotFinder.cxx index 86bcd2660353fce4fb1ec567c7ec39d982f2414e..1ebb673a60f559186064b3904bd4600e691c6f5b 100644 --- a/Reconstruction/tauRecTools/src/TauShotFinder.cxx +++ b/Reconstruction/tauRecTools/src/TauShotFinder.cxx @@ -8,7 +8,6 @@ // package: Reconstruction/tauRec // authors: Will Davey, Benedict Winter, Stephanie Yuen // date: 2013-05-22 -// //----------------------------------------------------------------------------- #include <boost/scoped_ptr.hpp> @@ -23,14 +22,11 @@ #include "xAODPFlow/PFOAuxContainer.h" #include "xAODPFlow/PFO.h" -using std::vector; -using std::string; - //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- -TauShotFinder::TauShotFinder( const string& name ) : +TauShotFinder::TauShotFinder(const std::string& name) : TauRecToolBase(name) { } @@ -41,6 +37,7 @@ TauShotFinder::TauShotFinder( const string& name ) : TauShotFinder::~TauShotFinder() { } +//______________________________________________________________________________ StatusCode TauShotFinder::initialize() { // retrieve tools @@ -55,17 +52,13 @@ StatusCode TauShotFinder::initialize() { return StatusCode::SUCCESS; } -StatusCode TauShotFinder::finalize() -{ - return StatusCode::SUCCESS; -} - +//______________________________________________________________________________ StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& tauShotClusterContainer, xAOD::PFOContainer& tauShotPFOContainer) const { ATH_MSG_DEBUG("execute"); // Any tau needs to have shot PFO vectors. Set empty vectors before nTrack cut - vector<ElementLink<xAOD::PFOContainer> > empty; + std::vector<ElementLink<xAOD::PFOContainer> > empty; pTau.setShotPFOLinks(empty); //--------------------------------------------------------------------- @@ -86,7 +79,7 @@ StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloCluste const CaloCellContainer *pCellContainer = caloCellInHandle.cptr();; // get only EM cells within dR<0.4 - vector<CaloCell_ID::SUBCALO> emSubCaloBlocks; + std::vector<CaloCell_ID::SUBCALO> emSubCaloBlocks; emSubCaloBlocks.push_back(CaloCell_ID::LAREM); boost::scoped_ptr<CaloCellList> pCells(new CaloCellList(pCellContainer,emSubCaloBlocks)); pCells->select(pTau.eta(), pTau.phi(), 0.4); @@ -254,7 +247,7 @@ StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloCluste shot->setAttribute<int>(xAOD::PFODetails::PFOAttributes::tauShots_nPhotons, nPhotons); // remove shot(s) from list - vector<const CaloCell*>::iterator cellItrNonConst; + std::vector<const CaloCell*>::iterator cellItrNonConst; cellItrNonConst = std::find(seedCells.begin(),seedCells.end(),cell); seedCells.erase(cellItrNonConst); if( mergePhi ){ @@ -267,6 +260,7 @@ StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloCluste return StatusCode::SUCCESS; } +//______________________________________________________________________________ std::vector<const CaloCell*> TauShotFinder::getNeighbours(const CaloCellContainer* pCellContainer, const CaloCell* cell, int maxDepth) const @@ -277,6 +271,7 @@ std::vector<const CaloCell*> TauShotFinder::getNeighbours(const CaloCellContaine return cells; } +//______________________________________________________________________________ void TauShotFinder::addNeighbours(const CaloCellContainer* pCellContainer, const CaloCell* cell, std::vector<const CaloCell*>& cells, @@ -306,6 +301,7 @@ void TauShotFinder::addNeighbours(const CaloCellContainer* pCellContainer, } } +//______________________________________________________________________________ bool TauShotFinder::isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell2Hash, bool next) const{ std::vector<IdentifierHash> neigHashes; if( next ) m_calo_id->get_neighbours(cell1Hash,LArNeighbours::nextInPhi,neigHashes); @@ -317,6 +313,7 @@ bool TauShotFinder::isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell return false; } +//______________________________________________________________________________ float TauShotFinder::getEtaBin(float seedEta) const { float absSeedEta=std::abs(seedEta); if(absSeedEta < 0.80) return 0; // Central Barrel @@ -326,6 +323,7 @@ float TauShotFinder::getEtaBin(float seedEta) const { else return 4; // endcap, coarse granularity } +//______________________________________________________________________________ float TauShotFinder::getNPhotons(int etaBin, float seedEnergy) const { // no photon counting in crack region, e.g. [1.39, 1.51] if(etaBin==2) return 0; @@ -340,6 +338,7 @@ float TauShotFinder::getNPhotons(int etaBin, float seedEnergy) const { return 1; } +//______________________________________________________________________________ // some really slick c++ way of doing sort (since we need to use the member m_caloWeightTool) TauShotFinder::ptSort::ptSort( const TauShotFinder& info ) : m_info(info) { } bool TauShotFinder::ptSort::operator()( const CaloCell* c1, const CaloCell* c2 ){ diff --git a/Reconstruction/tauRecTools/src/TauShotFinder.h b/Reconstruction/tauRecTools/src/TauShotFinder.h index b0a70569b20ecbfefd917d990a0389bfa7b8733f..6273fc619692164dbf2885e079f0f6b2b258ac24 100644 --- a/Reconstruction/tauRecTools/src/TauShotFinder.h +++ b/Reconstruction/tauRecTools/src/TauShotFinder.h @@ -22,7 +22,6 @@ public: virtual StatusCode initialize() override; virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& tauShotCaloClusContainer, xAOD::PFOContainer& tauShotPFOContainer) const override; - virtual StatusCode finalize() override; private: diff --git a/Reconstruction/tauRecTools/src/TauTrackFinder.cxx b/Reconstruction/tauRecTools/src/TauTrackFinder.cxx index 2ab38a0bae2b2909fe74894ff1b0d5c7974a071a..996718a98892b9aa059143981d187fb63b6f2820 100644 --- a/Reconstruction/tauRecTools/src/TauTrackFinder.cxx +++ b/Reconstruction/tauRecTools/src/TauTrackFinder.cxx @@ -11,12 +11,11 @@ #include "xAODTau/TauTrackContainer.h" #include "TauTrackFinder.h" -#include "tauRecTools/KineUtils.h" #include "tauRecTools/TrackSort.h" -TauTrackFinder::TauTrackFinder(const std::string& name ) : - TauRecToolBase(name) { +TauTrackFinder::TauTrackFinder(const std::string& name) : + TauRecToolBase(name) { m_EMSamplings = {CaloSampling::EME1, CaloSampling::EMB1}; m_HadSamplings = {CaloSampling::TileBar1, CaloSampling::HEC1, CaloSampling::TileExt1}; } @@ -41,11 +40,6 @@ StatusCode TauTrackFinder::initialize() { return StatusCode::SUCCESS; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -StatusCode TauTrackFinder::finalize() { - return StatusCode::SUCCESS; -} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * StatusCode TauTrackFinder::executeTrackFinder(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackCon, const xAOD::TrackParticleContainer* trackContainer) const { @@ -74,7 +68,7 @@ StatusCode TauTrackFinder::executeTrackFinder(xAOD::TauJet& pTau, xAOD::TauTrack } // get the primary vertex - const xAOD::Vertex* pVertex = pTau.vertexLink()!=0 ? (*pTau.vertexLink()) : NULL; + const xAOD::Vertex* pVertex = pTau.vertexLink() ? pTau.vertex() : nullptr; // retrieve tracks wrt a vertex // as a vertex is used: tau origin / PV / beamspot / 0,0,0 (in this order, depending on availability) @@ -224,7 +218,7 @@ TauTrackFinder::TauTrackType TauTrackFinder::tauTrackType( const xAOD::TauJet& p const xAOD::TrackParticle& trackParticle, const xAOD::Vertex* primaryVertex) const { - double dR = Tau1P3PKineUtils::deltaR(pTau.eta(),pTau.phi(),trackParticle.eta(),trackParticle.phi()); + double dR = pTau.p4().DeltaR(trackParticle.p4()); if (dR > m_maxJetDr_wide) return NotTauTrack; diff --git a/Reconstruction/tauRecTools/src/TauTrackFinder.h b/Reconstruction/tauRecTools/src/TauTrackFinder.h index 23e0d0f223425707b9c845623fc7cac6a2d8757f..42888b9073833d5985a4689dedb7aa273e40fade 100644 --- a/Reconstruction/tauRecTools/src/TauTrackFinder.h +++ b/Reconstruction/tauRecTools/src/TauTrackFinder.h @@ -59,7 +59,6 @@ public: //------------------------------------------------------------- virtual StatusCode initialize() override; virtual StatusCode executeTrackFinder(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackCon, const xAOD::TrackParticleContainer* trackContainer = nullptr) const override; - virtual StatusCode finalize() override; private: //------------------------------------------------------------- diff --git a/Reconstruction/tauRecTools/src/TauVertexFinder.cxx b/Reconstruction/tauRecTools/src/TauVertexFinder.cxx index e50ff0a9793e261afd29a5cdf94dc0b986d1c08b..a40c2bb93fec6e9a3c20178bc7b99293d7421280 100644 --- a/Reconstruction/tauRecTools/src/TauVertexFinder.cxx +++ b/Reconstruction/tauRecTools/src/TauVertexFinder.cxx @@ -35,17 +35,12 @@ StatusCode TauVertexFinder::initialize() { return StatusCode::SUCCESS; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -StatusCode TauVertexFinder::finalize() { - return StatusCode::SUCCESS; -} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * StatusCode TauVertexFinder::executeVertexFinder(xAOD::TauJet& pTau, const xAOD::VertexContainer* vertexContainer, const xAOD::TrackParticleContainer* trackContainer) const { - const xAOD::VertexContainer * vxContainer = 0; + const xAOD::VertexContainer * vxContainer = nullptr; if (!m_vertexInputContainer.empty()) { SG::ReadHandle<xAOD::VertexContainer> vertexInHandle( m_vertexInputContainer ); @@ -119,14 +114,14 @@ TauVertexFinder::getPV_TJVA(const xAOD::TauJet& pTau, const xAOD::TrackParticleContainer * trackContainer, float& maxJVF) const { - const xAOD::Jet* pJetSeed = (*pTau.jetLink()); + const xAOD::Jet* pJetSeed = pTau.jet(); std::vector<const xAOD::TrackParticle*> tracksForTJVA; const double dDeltaRMax(0.2); std::vector<const xAOD::Vertex*> matchedVertexOnline; // the implementation follows closely the example given in modifyJet(...) in https://svnweb.cern.ch/trac/atlasoff/browser/Reconstruction/Jet/JetMomentTools/trunk/Root/JetVertexFractionTool.cxx#15 - const xAOD::TrackParticleContainer* trackParticleCont = 0; + const xAOD::TrackParticleContainer* trackParticleCont = nullptr; std::vector<const xAOD::TrackParticle*> assocTracks; if (inTrigger()) { @@ -170,7 +165,7 @@ TauVertexFinder::getPV_TJVA(const xAOD::TauJet& pTau, } // Get the TVA object - const jet::TrackVertexAssociation* tva = NULL; + const jet::TrackVertexAssociation* tva = nullptr; // ATR-15665 for trigger: reimplementation of TrackVertexAssociationTool::buildTrackVertexAssociation_custom if(inTrigger()){ @@ -277,6 +272,7 @@ float TauVertexFinder::getJetVertexFraction(const xAOD::Vertex* vertex, const st } return sumTrackAll!=0 ? sumTrackPV/sumTrackAll : 0; } + // for online ATR-15665: reimplementation needed for online because the tva doesn't work. The size of the track collection from TE is not the same as the max track index float TauVertexFinder::getJetVertexFraction(const xAOD::Vertex* vertex, const std::vector<const xAOD::TrackParticle*>& tracks, diff --git a/Reconstruction/tauRecTools/src/TauVertexFinder.h b/Reconstruction/tauRecTools/src/TauVertexFinder.h index 2ba24f28d96ee0834bdc4da828cc82235076f0d7..0896967c6d07cf0ca5b5ec9e80e2660c4f7b09b3 100644 --- a/Reconstruction/tauRecTools/src/TauVertexFinder.h +++ b/Reconstruction/tauRecTools/src/TauVertexFinder.h @@ -12,8 +12,6 @@ #include "JetEDM/TrackVertexAssociation.h" #include "InDetTrackSelectionTool/IInDetTrackSelectionTool.h" - - ///////////////////////////////////////////////////////////////////////////// /** @@ -44,8 +42,6 @@ public: const xAOD::VertexContainer* vertexContainer = nullptr, const xAOD::TrackParticleContainer* trackContainer = nullptr) const override; - StatusCode finalize() override; - private: ElementLink<xAOD::VertexContainer> getPV_TJVA(const xAOD::TauJet& tauJet, diff --git a/Reconstruction/tauRecTools/src/TauVertexVariables.cxx b/Reconstruction/tauRecTools/src/TauVertexVariables.cxx index a5df906bd86ea44ce083a4c61ca8293fc8c62a29..19586dc894c945b4c23de7e65233b543b36d778d 100644 --- a/Reconstruction/tauRecTools/src/TauVertexVariables.cxx +++ b/Reconstruction/tauRecTools/src/TauVertexVariables.cxx @@ -46,13 +46,6 @@ StatusCode TauVertexVariables::initialize() { return StatusCode::SUCCESS; } -//----------------------------------------------------------------------------- -// Finalizer -//----------------------------------------------------------------------------- -StatusCode TauVertexVariables::finalize() { - return StatusCode::SUCCESS; -} - //----------------------------------------------------------------------------- // Execution //----------------------------------------------------------------------------- @@ -82,7 +75,7 @@ StatusCode TauVertexVariables::executeVertexVariables(xAOD::TauJet& pTau, xAOD:: } } else if (pTau.vertexLink()) { // offline: obtain tau vertex by link - vxcand = *(pTau.vertexLink()) ; + vxcand = pTau.vertex() ; //check if vertex has a valid type (skip if vertex has type NoVtx) if (vxcand->vertexType() != xAOD::VxType::NoVtx) { myIPandSigma = std::unique_ptr<const Trk::ImpactParametersAndSigma>(m_trackToVertexIPEstimator->estimate(pTau.track(0)->track(), vxcand)); @@ -152,7 +145,7 @@ StatusCode TauVertexVariables::executeVertexVariables(xAOD::TauJet& pTau, xAOD:: } // get the starting point for the fit using Trk::Tracks - Amg::Vector3D seedPoint = m_SeedFinder->findSeed(origTracks); + const Amg::Vector3D& seedPoint = m_SeedFinder->findSeed(origTracks); ATH_MSG_VERBOSE("seedPoint x/y/perp=" << seedPoint.x() << " " << seedPoint.y() << " "<< seedPoint.z() << " " << TMath::Sqrt(seedPoint.x()*seedPoint.x()+seedPoint.y()+seedPoint.y())); // fitting the vertex itself @@ -163,7 +156,7 @@ StatusCode TauVertexVariables::executeVertexVariables(xAOD::TauJet& pTau, xAOD:: } // get the transverse flight path significance - float trFlightPS = trFlightPathSig(pTau, *xAODvertex); + double trFlightPS = trFlightPathSig(pTau, *xAODvertex); pTau.setDetail(xAOD::TauJetParameters::trFlightPathSig, (float)(trFlightPS)); ATH_MSG_VERBOSE("transverse flight path significance="<<trFlightPS); @@ -187,7 +180,7 @@ StatusCode TauVertexVariables::executeVertexVariables(xAOD::TauJet& pTau, xAOD:: double TauVertexVariables::trFlightPathSig(const xAOD::TauJet& pTau, const xAOD::Vertex& secVertex) const { const xAOD::Vertex* pVertex = nullptr; - if (pTau.vertexLink()) pVertex = *pTau.vertexLink(); + if (pTau.vertexLink()) pVertex = pTau.vertex(); if (!pVertex) { ATH_MSG_WARNING("No primary vertex information for calculation of transverse flight path significance"); return -11111.; diff --git a/Reconstruction/tauRecTools/src/TauVertexVariables.h b/Reconstruction/tauRecTools/src/TauVertexVariables.h index a426c446073ce832b209f69508759ed3ce47babb..a54aadb3ad39dbc09b47520b8099d5bb1a7e97c7 100644 --- a/Reconstruction/tauRecTools/src/TauVertexVariables.h +++ b/Reconstruction/tauRecTools/src/TauVertexVariables.h @@ -15,7 +15,6 @@ #include "TrkVertexFitterInterfaces/IVertexFitter.h" #include "TrkVertexFitterInterfaces/IVertexSeedFinder.h" - /** * * @brief Class for calculating vertex variables. @@ -34,7 +33,7 @@ public: virtual StatusCode initialize() override; virtual StatusCode executeVertexVariables(xAOD::TauJet& pTau, xAOD::VertexContainer& pVertexContainer) const override; - virtual StatusCode finalize() override; + //------------------------------------------------------------- //! determines the transverse flight path significance from //! the primary vertex and the secondary vertex of tau candidate diff --git a/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h b/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h index 93d7d8edb817ad2eeffaab719c54cd65149ffb69..d59716827b4b296ce4cf69b92bf21013949aa0cd 100644 --- a/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h +++ b/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h @@ -24,7 +24,6 @@ class MvaTESVariableDecorator virtual StatusCode initialize() override; virtual StatusCode execute(xAOD::TauJet& xTau) const override; - virtual StatusCode finalize() override; private: diff --git a/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h b/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h index b7f4766733dc1be54f8cca73db72d2d64d468ea1..3c28f8472a3678ac97a990c4fbf3b2793de31d93 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h @@ -33,7 +33,6 @@ class TauCalibrateLC : public TauRecToolBase { ~TauCalibrateLC(); virtual StatusCode initialize() override; - virtual StatusCode finalize() override; virtual StatusCode execute(xAOD::TauJet& pTau) const override; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauCommonCalcVars.h b/Reconstruction/tauRecTools/tauRecTools/TauCommonCalcVars.h index 78080de6cb94ab3a6dd6bed3597814a6df2e3c37..ab075be1b33adfe6fafb784925dd19ba5da86a34 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauCommonCalcVars.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauCommonCalcVars.h @@ -26,9 +26,7 @@ public: ASG_TOOL_CLASS2(TauCommonCalcVars, TauRecToolBase, ITauToolBase) ~TauCommonCalcVars(); - virtual StatusCode initialize() override; virtual StatusCode execute(xAOD::TauJet& pTau) const override; - virtual StatusCode finalize() override; private: int m_isolationTrackType; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauEleOLRDecorator.h b/Reconstruction/tauRecTools/tauRecTools/TauEleOLRDecorator.h index ed65691fe12b40e87d4148e2508e4bd59cdf2532..465ec125de7c4de667231675870fb0c9e85b8571 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauEleOLRDecorator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauEleOLRDecorator.h @@ -31,7 +31,6 @@ class TauEleOLRDecorator: virtual public TauRecToolBase virtual StatusCode initialize() override; virtual StatusCode execute(xAOD::TauJet&) const override; - virtual StatusCode finalize() override; private: float getCutVal(float fEta, float fPt) const; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauIDVarCalculator.h b/Reconstruction/tauRecTools/tauRecTools/TauIDVarCalculator.h index 854b58f9f428b1963aeec93f6be46eee68041842..a4618e291a15d60c5f5e37ef865d5348a02efdc2 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauIDVarCalculator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauIDVarCalculator.h @@ -27,7 +27,6 @@ class TauIDVarCalculator: public TauRecToolBase virtual StatusCode initialize() override; virtual StatusCode execute(xAOD::TauJet&) const override; - virtual StatusCode finalize() override; static const float LOW_NUMBER; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h b/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h index 60498a34e217b2fc3b0ae57bfebf086579239bc1..f7854ea3c9ba8b7d5fc9ff0809bd1bebdd9b0b02 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h @@ -29,7 +29,6 @@ class TauJetBDTEvaluator virtual StatusCode initialize() override; virtual StatusCode execute(xAOD::TauJet& xTau) const override; - virtual StatusCode finalize() override; private: std::unique_ptr<tauRecTools::BDTHelper> m_mvaBDT; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h b/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h index fe9732e26f1eae2452517108855b0d00691e26e3..ba8b377e9a6fba52417b92dfe37cc0160df8533f 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h @@ -27,7 +27,6 @@ public: virtual ~TauPi0ScoreCalculator(); virtual StatusCode initialize() override; - virtual StatusCode finalize() override; virtual StatusCode executePi0nPFO(xAOD::TauJet& pTau, xAOD::PFOContainer& pNeutralPFOContainer) const override; private: diff --git a/Reconstruction/tauRecTools/tauRecTools/TauPi0Selector.h b/Reconstruction/tauRecTools/tauRecTools/TauPi0Selector.h index 954b67647253af6843c8c7fcec4235ea17903ac0..16506a71f5ff79b3a3ddd5793e51e152b648b367 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauPi0Selector.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauPi0Selector.h @@ -21,8 +21,6 @@ public: TauPi0Selector(const std::string& name); ASG_TOOL_CLASS2(TauPi0Selector, TauRecToolBase, ITauToolBase) virtual ~TauPi0Selector(); - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; virtual StatusCode executePi0nPFO(xAOD::TauJet& pTau, xAOD::PFOContainer& pNeutralPFOContainer) const override; private: diff --git a/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h b/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h index 5e2a31aaacc0b9e1ffdae84a219080471ba1f1d8..3530a60331afc8e7515e683ad080a1f6adf94138 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h @@ -20,22 +20,15 @@ class TauSubstructureVariables : public TauRecToolBase public: ASG_TOOL_CLASS2(TauSubstructureVariables, TauRecToolBase, ITauToolBase) - static const double DEFAULT; + static const float DEFAULT; TauSubstructureVariables(const std::string& name="TauSubstructureVariables"); ~TauSubstructureVariables(); virtual StatusCode execute(xAOD::TauJet& pTau) const override; - virtual StatusCode initialize() override; - virtual StatusCode finalize() override; private: - // Maximal pile up correction in GeV for a tau candidate. - // Used for the caloIso corrected variable. - double m_maxPileUpCorrection; - double m_pileUpAlpha; //!< slope of the pileup correction - // enable cell origin correction // eta and phi of the cells are corrected wrt to the origin of the tau vertex bool m_doVertexCorrection; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h b/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h index 3c296e293165fcb5ce376b7e1803386166956476..219c1a34a6b1e410d1528919c816b60526791c40 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h @@ -43,12 +43,11 @@ public: virtual StatusCode initialize() override; virtual StatusCode executeTrackClassifier(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer ) const override; - virtual StatusCode finalize() override; private: ToolHandleArray<TrackMVABDT> m_vClassifier; std::vector<std::string> m_vClassifierNames;//optional - + }; // class TauTrackClassifier //______________________________________________________________________________ @@ -91,10 +90,8 @@ private: std::unique_ptr<MVAUtils::BDT> m_rReader; //! - // std::map<int, std::string> m_mParsedVarsBDT; //! std::map<TString, float*> m_mAvailableVars; //! inline float& setVar(const TString& var) { return *(m_mAvailableVars[var]); } //!< not-stateless, many such examples need to be fixed for r22 - std::vector<float*> m_vars; //!< points to floats in m_mAvailableVars that are used in BDT }; // class TrackMVABDT diff --git a/Reconstruction/tauRecTools/tauRecTools/TauWPDecorator.h b/Reconstruction/tauRecTools/tauRecTools/TauWPDecorator.h index 290230663bc9c6d2fcb5314086b38eb0804ccdb9..edd7691ba2b9c6f90d7f977c10a426b45d0a4886 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauWPDecorator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauWPDecorator.h @@ -48,9 +48,6 @@ class TauWPDecorator : public TauRecToolBase { /** @brief Executation of this tool */ virtual StatusCode execute(xAOD::TauJet& pTau) const override; - /** @brief Finalization of this tool */ - virtual StatusCode finalize() override; - private: /** diff --git a/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py b/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py index 3f662248fbfcb6d29beb0e64bc81ec2a32c232a8..0cfe69a84e7bc3b4ea9ca36018ef0a19bd87c9c6 100644 --- a/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py +++ b/TileCalorimeter/TileMonitoring/python/TileRawChannelTimeMonitorAlgorithm.py @@ -102,6 +102,7 @@ def TileRawChannelTimeMonitoringConfig(flags, **kwargs): tileRawChanTimeMonAlg, 'TileDigitizerTimeLB', topPath = 'Tile/RawChannelTime') for postfix, tool in digiTimeVsLBArray.Tools.items(): ros, module, digitizer = [int(x) for x in postfix.split('_')[1:]] + digitizer += 1 moduleName = Tile.getDrawerString(ros + 1, module) title = 'Run ' + run + ' ' + moduleName + ' Digitizer ' + str(digitizer) diff --git a/Tools/PROCTools/python/RunTier0TestsTools.py b/Tools/PROCTools/python/RunTier0TestsTools.py index d058ec0221496ef170f8f7a6f48ef13b7adaa2bb..b7cfe7f93dda67a085ec2f72a63f0a3b950adb2a 100644 --- a/Tools/PROCTools/python/RunTier0TestsTools.py +++ b/Tools/PROCTools/python/RunTier0TestsTools.py @@ -25,7 +25,7 @@ ciRefFileMap = { 's3505-21.0' : 'v1', 's3505-21.3' : 'v1', 's3505-21.9' : 'v1', - 's3505-22.0' : 'v6', + 's3505-22.0' : 'v7', # OverlayTier0Test_required-test 'overlay-d1498-21.0' : 'v2', 'overlay-d1498-22.0' : 'v36', diff --git a/Tools/Scripts/share/git-package-pseudomerge.py b/Tools/Scripts/share/git-package-pseudomerge.py index 2d064bbca66e62efe25334d925c1519c53be5b47..1f51c451fbc53ae33f6c19107e26cb74d822a6e8 100755 --- a/Tools/Scripts/share/git-package-pseudomerge.py +++ b/Tools/Scripts/share/git-package-pseudomerge.py @@ -115,10 +115,10 @@ if args.stage == 1: call(["git", "fetch", "upstream"]) # Check we're not going to trample on work - localChanges = check_output(["git", "status", "--porcelain"]) + localChanges = check_output(["git", "status", "--porcelain"],text=True) if localChanges != "": print("Local changes: " + localChanges) - prompt = raw_input(bcolors.WARNING + 'This will discard all local changes in the repository which are not already committed, please confirm this is OK! (y/n): ' + bcolors.ENDC) + prompt = input(bcolors.WARNING + 'This will discard all local changes in the repository which are not already committed, please confirm this is OK! (y/n): ' + bcolors.ENDC) if (prompt != "Y" and prompt != "y"): print(bcolors.HEADER + 'Exiting' + bcolors.ENDC) exit() @@ -152,7 +152,7 @@ if args.stage == 1: print(bcolors.HEADER + 'Performing reset ' + bcolors.ENDC) - result = check_output(["git", "status", "--porcelain"]) + result = check_output(["git", "status", "--porcelain"],text=True) toReset = [] responsibleRule = "" @@ -169,6 +169,7 @@ if args.stage == 1: doKeep = False doProgress = False + for path in args.packages: # For each package in the list of merge-packages pathSplit = path.rstrip('/').split('/') # Explode path if level == len(pathSplit) and path == responsibleRule: @@ -219,7 +220,7 @@ if args.stage == 1: elif args.stage == 2: - conflicted = check_output(["git", "diff", "--name-only", "--diff-filter=U"]) + conflicted = check_output(["git", "diff", "--name-only", "--diff-filter=U"],text=True) if conflicted != "": print(bcolors.FAIL + "Conflicting paths remain, please resolve and use 'git add' on:\n" + conflicted + bcolors.ENDC) print(bcolors.HEADER + 'Use "git status" to check the state of the merge' + bcolors.ENDC) diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h index 1bf3a71984b8bca62caf57a4fe09c4e619fb915e..2a8dc08725fd0a9297161dd59a0b25b40f86fe7d 100755 --- a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h +++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h @@ -93,8 +93,6 @@ namespace Trk class Track { public: - - friend class TrackSummaryTool; friend class TrackSlimmingTool; Track (); //!<needed by POOL. DO NOT USE YOURSELF! @@ -233,7 +231,7 @@ namespace Trk /** * Set the track summary pointer. The Trk::Track takes ownership */ - void setTrackSummary(Trk::TrackSummary* input); + void setTrackSummary(std::unique_ptr<Trk::TrackSummary> input); /** * reset all caches @@ -323,7 +321,7 @@ namespace Trk /** * Datamember to cache the TrackSummary */ - Trk::TrackSummary* m_trackSummary; + std::unique_ptr<Trk::TrackSummary> m_trackSummary; /** * This is aclass which stores the identity of where the track diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc index f68aded1c6e755c82702942a5d99645b2c469d71..251dca1c813187b2251289377544673e58259091 100644 --- a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc +++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc @@ -32,13 +32,13 @@ Track::info() inline const Trk::TrackSummary* Track::trackSummary() const { - return m_trackSummary; + return m_trackSummary.get(); } inline Trk::TrackSummary* Track::trackSummary() { - return m_trackSummary; + return m_trackSummary.get(); } } diff --git a/Tracking/TrkEvent/TrkTrack/src/Track.cxx b/Tracking/TrkEvent/TrkTrack/src/Track.cxx index c05c963bf384df946221cdfa8087264e2d60e014..438fee95ae373bc392b4a7f6254734756eae4e6f 100755 --- a/Tracking/TrkEvent/TrkTrack/src/Track.cxx +++ b/Tracking/TrkEvent/TrkTrack/src/Track.cxx @@ -28,7 +28,6 @@ Trk::Track::Track() , m_cachedOutlierVector{} , m_perigeeParameters{} , m_fitQuality(nullptr) - , m_trackSummary(nullptr) { #ifndef NDEBUG s_numberOfInstantiations++; // new Track, so increment total count @@ -45,7 +44,6 @@ Trk::Track::Track( , m_cachedOutlierVector{} , m_perigeeParameters{} , m_fitQuality(fitQuality) - , m_trackSummary(nullptr) , m_trackInfo(info) { // find the Perigee params they will become valid given the outcome @@ -62,7 +60,6 @@ Trk::Track::Track(const Trk::Track& rhs) , m_cachedOutlierVector{} , m_perigeeParameters{} , m_fitQuality(nullptr) - , m_trackSummary(nullptr) { //Do the actual payload copy copyHelper(rhs); @@ -79,8 +76,7 @@ Trk::Track::operator=(const Trk::Track& rhs) // First clear this object delete m_fitQuality; m_fitQuality = nullptr; - delete m_trackSummary; - m_trackSummary = nullptr; + m_trackSummary.reset(nullptr); // Invalidate the caches m_cachedParameterVector.reset(); m_cachedMeasurementVector.reset(); @@ -110,7 +106,7 @@ Trk::Track::copyHelper(const Trk::Track& rhs) } // create & copy other variables if (rhs.trackSummary() != nullptr) { - m_trackSummary = new Trk::TrackSummary(*(rhs.m_trackSummary)); + m_trackSummary = std::make_unique<Trk::TrackSummary>(*(rhs.m_trackSummary)); } // Create the TrackStateVector and the perigeeParameters if (rhs.m_trackStateVector != nullptr) { @@ -154,7 +150,6 @@ Trk::Track::Track(Trk::Track&& rhs) noexcept // but undefined state make the ptr null. rhs.m_trackStateVector = nullptr; rhs.m_fitQuality = nullptr; - rhs.m_trackSummary = nullptr; #ifndef NDEBUG s_numberOfInstantiations++; // new Track, so increment total count @@ -168,7 +163,6 @@ Trk::Track::operator=(Trk::Track&& rhs) noexcept // First clear this object // same as dtor of the object delete m_fitQuality; - delete m_trackSummary; delete m_trackStateVector; // move from rhs to this m_trackStateVector = std::move(rhs.m_trackStateVector); @@ -182,7 +176,6 @@ Trk::Track::operator=(Trk::Track&& rhs) noexcept // but undefined state make the ptr null. rhs.m_trackStateVector = nullptr; rhs.m_fitQuality = nullptr; - rhs.m_trackSummary = nullptr; } return *this; } @@ -190,7 +183,6 @@ Trk::Track::operator=(Trk::Track&& rhs) noexcept Trk::Track::~Track() { delete m_fitQuality; - delete m_trackSummary; // the following is DataVectors // and so delete the contained objects automatically. delete m_trackStateVector; @@ -339,10 +331,9 @@ void Trk::Track::setInfo(const TrackInfo& input) m_trackInfo = input; } -void Trk::Track::setTrackSummary(Trk::TrackSummary* input) +void Trk::Track::setTrackSummary(std::unique_ptr<Trk::TrackSummary> input) { - delete m_trackSummary; // delete existing - m_trackSummary = input; // add new + m_trackSummary = std::move(input); } void Trk::Track::reset() diff --git a/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h b/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h index 13ae226c33b7e95185648a7258621bc50c45529f..ca02495f95a222ff09d6fde28964e16663ccc5ce 100755 --- a/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h +++ b/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h @@ -101,7 +101,7 @@ public: if (!track.trackSummary()) { computeAndReplaceTrackSummary(track, prd_to_track_map, false /*DO NOT suppress hole search*/); } else { - updateSharedHitCount(track, prd_to_track_map, *track.m_trackSummary); + updateSharedHitCount(track, prd_to_track_map, *track.trackSummary()); } } @@ -148,7 +148,7 @@ public: if (!track.trackSummary()) { computeAndReplaceTrackSummary(track, nullptr, false /*DO NOT suppress hole search*/); } else { - updateSharedHitCount(track, nullptr, *track.m_trackSummary); + updateSharedHitCount(track, nullptr, *track.trackSummary()); } } @@ -191,11 +191,9 @@ private: bool doHolesInDet, bool doHolesMuon) const { - Trk::TrackSummary* ts = createSummary(track, prd_to_track_map, doHolesInDet, doHolesMuon).release(); Trk::Track& nonConstTrack = const_cast<Trk::Track&>(track); - delete nonConstTrack.m_trackSummary; - nonConstTrack.m_trackSummary = ts; - return onlyUpdateTrack ? nullptr : new Trk::TrackSummary(*ts); + nonConstTrack.setTrackSummary(createSummary(track, prd_to_track_map, doHolesInDet, doHolesMuon)); + return onlyUpdateTrack ? nullptr : new Trk::TrackSummary(*nonConstTrack.trackSummary()); } /** use this method to update a track. this means a tracksummary is created for this track but not returned. the summary can then be obtained from the track. diff --git a/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx b/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx index bcb0783196329b40c6dd85996be83eb786cefa34..f1c6b44cb460c0ed64df874c644a788a277462ee 100755 --- a/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx +++ b/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx @@ -136,12 +136,14 @@ const Trk::TrackSummary* Trk::TrackSummaryTool::createSummary( const Track& trac void Trk::TrackSummaryTool::computeAndReplaceTrackSummary(Trk::Track &track, const Trk::PRDtoTrackMap *prd_to_track_map, bool suppress_hole_search) const { - delete track.m_trackSummary; - track.m_trackSummary = nullptr; - track.m_trackSummary = createSummary(track, - prd_to_track_map, - m_doHolesInDet & !suppress_hole_search, - m_doHolesMuon & !suppress_hole_search).release(); + track.setTrackSummary( + createSummary( + track, + prd_to_track_map, + m_doHolesInDet & !suppress_hole_search, + m_doHolesMuon & !suppress_hole_search + ) + ); } std::unique_ptr<Trk::TrackSummary> Trk::TrackSummaryTool::summary( const Track& track) const @@ -338,7 +340,7 @@ Trk::TrackSummaryTool::updateTrackNoHoleSearch(Track& track, { // first check if track has summary already. computeAndReplaceTrackSummary(track, prd_to_track_map, true /*suppress hole search*/); - m_idTool->updateExpectedHitInfo(track, *track.m_trackSummary); /*Needed for expected B-Layer*/ + m_idTool->updateExpectedHitInfo(track, *track.trackSummary()); /*Needed for expected B-Layer*/ } void Trk::TrackSummaryTool::updateSharedHitCount(const Track& track, const Trk::PRDtoTrackMap *prd_to_track_map,TrackSummary &summary) const diff --git a/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py b/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py index cbd06a7d750cc17206cf4048c6559f1f0d8cbb2f..5a6ef4e3ae8860f0a55e378ee960714019572c03 100755 --- a/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py +++ b/Trigger/TrigAlgorithms/TrigMuonEF/python/TrigMuonEFConfig.py @@ -440,7 +440,7 @@ def TMEF_MuonStauSegmentRegionRecoveryTool(name='TMEF_MuonStauSegmentRegionRecov if athenaCommonFlags.isOnline: kwargs.setdefault('MdtCondKey', "") return CfgMgr.Muon__MuonSegmentRegionRecoveryTool(name,**kwargs) - + def TMEF_CombinedStauTrackBuilderFit( name='TMEF_CombinedStauTrackBuilderFit', **kwargs ): kwargs.setdefault('MdtRotCreator' , CfgGetter.getPublicTool('MdtDriftCircleOnTrackCreatorStau') ) return TMEF_CombinedMuonTrackBuilder(name,**kwargs ) @@ -497,13 +497,15 @@ class TrigMuonEFStandaloneTrackToolConfig (TrigMuonEFConf.TrigMuonEFStandaloneTr if MuonGeometryFlags.hasCSC(): self.CscClusterProvider = CfgGetter.getPublicTool("CscThresholdClusterBuilderTool") + muonLayerHoughTool = CfgGetter.getPublicTool("MuonLayerHoughTool") + muonLayerHoughTool.DoTruth=False + self.SegmentsFinderTool = CfgGetter.getPublicToolClone( "TMEF_SegmentsFinderTool","MooSegmentFinder", - HoughPatternFinder = CfgGetter.getPublicTool("MuonLayerHoughTool"), + HoughPatternFinder = muonLayerHoughTool, Csc2dSegmentMaker=("Csc2dSegmentMaker/Csc2dSegmentMaker" if MuonGeometryFlags.hasCSC() else ""), Csc4dSegmentMaker=("Csc4dSegmentMaker/Csc4dSegmentMaker" if MuonGeometryFlags.hasCSC() else "")) CfgGetter.getPublicTool("MuonHoughPatternFinderTool").RecordAll=False - CfgGetter.getPublicTool("MuonLayerHoughTool").DoTruth=False CfgGetter.getPublicTool("MooTrackFitter").SLFit=False self.MdtRawDataProvider = "TMEF_MdtRawDataProviderTool" diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py index 7f8a260eb7572bea85ae45f0acf07a47bafff314..027f7c4515e4d1465e8e5de05e46cf9256bdc7ea 100644 --- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py +++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration ################################################################################ ## @@ -357,9 +357,6 @@ def getTauSubstructure(): from tauRecTools.tauRecToolsConf import TauSubstructureVariables TauSubstructureVariables = TauSubstructureVariables( name = _name, - # parameters for CaloIsoCorrected variable - maxPileUpCorrection = 4000., #MeV - pileUpAlpha = 1.0, VertexCorrection = doVertexCorrection ) diff --git a/Trigger/TrigValidation/TrigP1Test/share/test_trigP1_magFieldToggle.ref b/Trigger/TrigValidation/TrigP1Test/share/test_trigP1_magFieldToggle.ref index e5cefeb4bb83b5250fb1d819d931be8f4012708b..06214864d5b71363616d268d0d6d3cb0b7afb44e 100644 --- a/Trigger/TrigValidation/TrigP1Test/share/test_trigP1_magFieldToggle.ref +++ b/Trigger/TrigValidation/TrigP1Test/share/test_trigP1_magFieldToggle.ref @@ -45,45 +45,45 @@ AtlasFieldCacheCondAlg 1 0 INFO updateCurrentFromParame AtlasFieldCacheCondAlg 1 0 INFO execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor 1/1, EventRange {[360027,l:0,b:4294967295] - [360028,l:0,b:4294967295]} AtlasFieldCacheCondAlg 1 0 INFO execute: no map read (currents == 0 MagFieldCondReader 1 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 1 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 1 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 2 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 2 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 2 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 3 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 3 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 3 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 4 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 4 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 4 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 5 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 5 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 5 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 6 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 6 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 6 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 7 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 7 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 7 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 8 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 8 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 8 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 9 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 9 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 9 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 10 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 10 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 10 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 11 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 11 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 11 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 12 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 12 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 12 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 13 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 13 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 13 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 14 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 14 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 14 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 15 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 15 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 15 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 16 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 16 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 16 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 17 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 17 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 17 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 18 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 18 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 18 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 19 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 19 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 19 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 MagFieldCondReader 20 0 INFO Field status: solenoid=0, toroids=0 -MagFieldCondReader 20 0 INFO Field xyz: 100, 100, 100, 0, 0, 1.997 +MagFieldCondReader 20 0 INFO Field xyz: 100, 100, 100, 0, 0, 0 AtlasFieldCacheCondAlg 1 0 INFO updateCurrentFromParameters: Update from job options: Range of input/output is {[360028,l:0,b:4294967295] - [360029,l:0,b:4294967295]} AtlasFieldCacheCondAlg 1 0 INFO execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor 1/1, EventRange {[360028,l:0,b:4294967295] - [360029,l:0,b:4294967295]} AtlasFieldCacheCondAlg 1 0 INFO execute: solenoid zone id 7000 diff --git a/Trigger/TrigValidation/TrigP1Test/test/test_trigP1_magFieldToggle_build.py b/Trigger/TrigValidation/TrigP1Test/test/test_trigP1_magFieldToggle_build.py index eb6b6d82befb4c4c3ef17c8d194b2f1b84c53cae..edf8d7f786d9f69375160baaa980504380e6d7fd 100755 --- a/Trigger/TrigValidation/TrigP1Test/test/test_trigP1_magFieldToggle_build.py +++ b/Trigger/TrigValidation/TrigP1Test/test/test_trigP1_magFieldToggle_build.py @@ -27,7 +27,7 @@ os.system('get_files -symlink -remove -jo setMagFieldCurrents.py') # Create a symlink to the first input file input_file = get_input('data').paths[0] -run_no = eformat.istream(input_file)[0].run_no() +run_no = eformat.istream(str(input_file))[0].run_no() # `str` needed only for Python2 try: os.remove('raw.data') except Exception: diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py index 5dbc8f7c73b594c460284a968246d7a304aa08e6..8629344668e98cb3d10fce03a2dd083fbc0894f5 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py @@ -301,7 +301,6 @@ def setupMenu(): TriggerFlags.StreamingSlice.signatures = TriggerFlags.StreamingSlice.signatures() + [ ChainProp(name='HLT_noalg_mb_L1RD2_EMPTY', l1SeedThresholds=['FSNOSEED'], stream=['MinBias'], groups=MinBiasGroup), ChainProp(name='HLT_noalg_zb_L1ZB', l1SeedThresholds=['FSNOSEED'], stream=['ZeroBias'], groups=ZeroBiasGroup), - ChainProp(name='HLT_noalg_L1MBTS_1_EMPTY', l1SeedThresholds=['FSNOSEED'], stream=['MinBias'], groups=MinBiasGroup), #ATR-21740 ] TriggerFlags.MonitorSlice.signatures = TriggerFlags.MonitorSlice.signatures() + [ diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/PhysicsP1_pp_run3_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/PhysicsP1_pp_run3_v1.py index 7e274bd5c516c5e972e11e327e1a14131d6f4dc2..a6d8eb245a80eda092b786fef0559ca8b27dca63 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/PhysicsP1_pp_run3_v1.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/PhysicsP1_pp_run3_v1.py @@ -131,6 +131,9 @@ def addP1Signatures(): ChainProp(name='HLT_noalg_cosmiccalo_L1J12_FIRSTEMPTY', stream=['CosmicCalo','express'],groups=['RATE:Cosmic_Calo','BW:Jet']), ChainProp(name='HLT_noalg_cosmiccalo_L1J30_FIRSTEMPTY', stream=['CosmicCalo','express'],groups=['RATE:Cosmic_Calo','BW:Jet']), # ChainProp(name='HLT_noalg_cosmiccalo_L1RD1_BGRP10', l1SeedThresholds=['FSNOSEED'], stream=['CosmicCalo','express'],groups=['RATE:Calibration','BW:Detector']), + + # MBTS + ChainProp(name='HLT_noalg_L1MBTS_1_EMPTY', l1SeedThresholds=['FSNOSEED'], stream=['MinBias'], groups=MinBiasGroup), #ATR-21740 ] TriggerFlags.MonitorSlice.signatures = TriggerFlags.MonitorSlice.signatures() + [ ChainProp(name='HLT_costmonitor_CostMonDS_L1All', l1SeedThresholds=['FSNOSEED'], stream=['CostMonitoring'], groups=['RATE:Monitoring','BW:Other']),