diff --git a/Reconstruction/ParticleID/src/TPCDndxAlg.cpp b/Reconstruction/ParticleID/src/TPCDndxAlg.cpp index 0af4dbc23467ae88ce287faae3cf1fb7b2e130cd..e002b94988f81b05fea7e37f2cdd6eb162d269f2 100644 --- a/Reconstruction/ParticleID/src/TPCDndxAlg.cpp +++ b/Reconstruction/ParticleID/src/TPCDndxAlg.cpp @@ -1,6 +1,7 @@ #include "TPCDndxAlg.h" #include "DataHelper/HelixClass.h" #include "DataHelper/Navigation.h" +#include "DetIdentifier/CEPCConf.h" #include "edm4hep/Hypothesis.h" #include "edm4hep/MCParticle.h" @@ -16,8 +17,8 @@ DECLARE_COMPONENT(TPCDndxAlg) TPCDndxAlg::TPCDndxAlg(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { // Input - declareProperty("ClupatraTracks", _trackCol, "handler of the input track collection"); - declareProperty("ClupatraTracksParticleAssociation", _trkParAssCol, "handler of the input track particle association collection"); + declareProperty("CompleteTracks", _trackCol, "handler of the input track collection"); + declareProperty("CompleteTracksParticleAssociation", _trkParAssCol, "handler of the input track particle association collection"); // Output declareProperty("DndxTracks", _dndxCol, "handler of the collection of dN/dx tracks"); @@ -33,6 +34,18 @@ StatusCode TPCDndxAlg::initialize() { m_pid_svc = nullptr; } + m_geosvc = service<IGeomSvc>("GeomSvc"); + if (!m_geosvc) { + error() << "Could not find GeomSvc!" << endmsg; + return StatusCode::FAILURE; + } + + m_decoder = m_geosvc->getDecoder("TPCCollection"); + if (!m_decoder) { + error() << "Could not find TPC decoder!" << endmsg; + return StatusCode::FAILURE; + } + return GaudiAlgorithm::initialize(); } @@ -99,8 +112,7 @@ StatusCode TPCDndxAlg::execute() { } } if (trk_par.tanLambda > 0.1) { - ihit_first = 0; - ihit_last = nhits - 1; + getFirstAndLastHitsByZ(hitcol, ihit_first, ihit_last); } else { getFirstAndLastHitsByRadius(hitcol, ihit_first, ihit_last); @@ -162,15 +174,18 @@ StatusCode TPCDndxAlg::finalize() { void TPCDndxAlg::getFirstAndLastHitsByRadius(const podio::RelationRange<edm4hep::TrackerHit>& hitcol, int& first, int& last) { bool first_hit = true; - double rmin, rmax; + double rmin(-999.), rmax(-999.); for (size_t ihit = 0; ihit < hitcol.size(); ihit++) { auto hit = hitcol[ihit]; + auto cellid = hit.getCellID(); + auto sysid = m_decoder->get(cellid, "system"); + if (sysid != CEPCConf::DetID::TPC) { + continue; + } + double x = hit.getPosition()[0]; double y = hit.getPosition()[1]; double r = sqrt(x*x + y*y); - // if (!isCDCHit(&hit)) { - // continue; - // } if (first_hit) { rmin = r; rmax = r; @@ -190,3 +205,35 @@ void TPCDndxAlg::getFirstAndLastHitsByRadius(const podio::RelationRange<edm4hep: } } } + +void TPCDndxAlg::getFirstAndLastHitsByZ(const podio::RelationRange<edm4hep::TrackerHit>& hitcol, int& first, int& last) { + bool first_hit = true; + double zmin(-999.), zmax(-999.); + for (size_t ihit = 0; ihit < hitcol.size(); ihit++) { + auto hit = hitcol[ihit]; + auto cellid = hit.getCellID(); + auto sysid = m_decoder->get(cellid, "system"); + if (sysid != CEPCConf::DetID::TPC) { + continue; + } + + double z = hit.getPosition()[2]; + if (first_hit) { + zmin = z; + zmax = z; + first = ihit; + last = ihit; + first_hit = false; + } + else { + if (z < zmin) { + zmin = z; + first = ihit; + } + if (z > zmax) { + zmax = z; + last = ihit; + } + } + } +} diff --git a/Reconstruction/ParticleID/src/TPCDndxAlg.h b/Reconstruction/ParticleID/src/TPCDndxAlg.h index c8cd699ebea3e27a9168f4515377e192ed90b6d7..12eec2b3ab683dfd7a90e3f28f1a300d9a6a284e 100644 --- a/Reconstruction/ParticleID/src/TPCDndxAlg.h +++ b/Reconstruction/ParticleID/src/TPCDndxAlg.h @@ -13,6 +13,7 @@ #include "GaudiAlg/GaudiAlgorithm.h" +#include "DetInterface/IGeomSvc.h" #include "SimplePIDSvc/ISimplePIDSvc.h" /** @@ -31,14 +32,17 @@ public: protected: Gaudi::Property<std::string> m_method{this, "Method", "Simple"}; + SmartIF<IGeomSvc> m_geosvc; + dd4hep::DDSegmentation::BitFieldCoder* m_decoder; - DataHandle<edm4hep::TrackCollection> _trackCol{"ClupatraTracks", Gaudi::DataHandle::Reader, this}; - DataHandle<edm4hep::MCRecoTrackParticleAssociationCollection> _trkParAssCol{"ClupatraTracksParticleAssociation", Gaudi::DataHandle::Reader, this}; + DataHandle<edm4hep::TrackCollection> _trackCol{"CompleteTracks", Gaudi::DataHandle::Reader, this}; + DataHandle<edm4hep::MCRecoTrackParticleAssociationCollection> _trkParAssCol{"CompleteTracksParticleAssociation", Gaudi::DataHandle::Reader, this}; DataHandle<edm4hep::RecDqdxCollection> _dndxCol{"DndxTracks", Gaudi::DataHandle::Writer, this}; private: SmartIF<ISimplePIDSvc> m_pid_svc; void getFirstAndLastHitsByRadius(const podio::RelationRange<edm4hep::TrackerHit>& hitcol, int& first, int& last); + void getFirstAndLastHitsByZ(const podio::RelationRange<edm4hep::TrackerHit>& hitcol, int& first, int& last); }; #endif