Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of the MTD to the tracker Navigation #33272

Merged
merged 6 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RecoMTD/DetLayers/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<use name="FWCore/Utilities"/>
<use name="TrackingTools/DetLayers"/>
<use name="Utilities/BinningTools"/>
<use name="Geometry/MTDGeometryBuilder"/>
<use name="Geometry/Records"/>
<use name="RecoMTD/Records"/>
<export>
<lib name="1"/>
</export>
10 changes: 8 additions & 2 deletions RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include "DataFormats/DetId/interface/DetId.h"
#include "TrackingTools/DetLayers/interface/DetLayerGeometry.h"
#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"

#include <vector>
#include <map>

Expand Down Expand Up @@ -50,6 +53,11 @@ class MTDDetLayerGeometry : public DetLayerGeometry {
/// return the DetLayer which correspond to a certain DetId
const DetLayer* idToLayer(const DetId& detId) const override;

// Added to allow building the MTDDetLayer from external plugins
void buildLayers(const MTDGeometry* geo, const MTDTopology* mtopo);

void sortLayers();

private:
/// Add ETL layers
/// etllayers.first=forward (+Z), etllayers.second=backward (-Z)
Expand All @@ -61,8 +69,6 @@ class MTDDetLayerGeometry : public DetLayerGeometry {

DetId makeDetLayerId(const DetLayer* detLayer) const;

void sortLayers();

std::vector<const DetLayer*> etlLayers_fw;
std::vector<const DetLayer*> etlLayers_bk;
std::vector<const DetLayer*> etlLayers_all;
Expand Down
21 changes: 7 additions & 14 deletions RecoMTD/DetLayers/plugins/MTDDetLayerGeometryESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "Geometry/Records/interface/MTDTopologyRcd.h"
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"

#include "ETLDetLayerGeometryBuilder.h"
#include "BTLDetLayerGeometryBuilder.h"
#include "RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h"
#include "RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h"
#include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand Down Expand Up @@ -52,19 +52,12 @@ MTDDetLayerGeometryESProducer::MTDDetLayerGeometryESProducer(const edm::Paramete

std::unique_ptr<MTDDetLayerGeometry> MTDDetLayerGeometryESProducer::produce(const MTDRecoGeometryRecord& record) {
auto mtdDetLayerGeometry = std::make_unique<MTDDetLayerGeometry>();
auto mtd = record.getHandle(geomToken_);
auto mtdtopo = record.getHandle(mtdtopoToken_);

if (auto mtd = record.getHandle(geomToken_)) {
// Build BTL layers
mtdDetLayerGeometry->addBTLLayers(BTLDetLayerGeometryBuilder::buildLayers(*mtd));
// Build ETL layers, depends on the scenario
if (auto mtdtopo = record.getHandle(mtdtopoToken_)) {
mtdDetLayerGeometry->addETLLayers(ETLDetLayerGeometryBuilder::buildLayers(*mtd, mtdtopo->getMTDTopologyMode()));
} else {
LogWarning("MTDDetLayers") << "No MTD topology is available.";
}
} else {
LogWarning("MTDDetLayers") << "No MTD geometry is available.";
}
//The BTL and ETL builders are now called internally by the MTDDetLayerGeometry.
//This allows external plugings to use and build the object.
mtdDetLayerGeometry->buildLayers(&(*mtd), &(*mtdtopo));

// Sort layers properly
mtdDetLayerGeometry->sortLayers();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//#define EDM_ML_DEBUG

#include "BTLDetLayerGeometryBuilder.h"
#include "RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h"

#include <DataFormats/ForwardDetId/interface/BTLDetId.h>
#include <Geometry/CommonDetUnit/interface/GeomDet.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//#define EDM_ML_DEBUG

#include "ETLDetLayerGeometryBuilder.h"
#include "RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h"

#include <RecoMTD/DetLayers/interface/MTDRingForwardDoubleLayer.h>
#include <RecoMTD/DetLayers/interface/MTDDetRing.h>
Expand Down Expand Up @@ -66,9 +66,6 @@ pair<vector<DetLayer*>, vector<DetLayer*> > ETLDetLayerGeometryBuilder::buildLay
}
}
}
//
// the first entry is Z+ ( MTD side 1), the second is Z- (MTD side 0)
//
pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[1], result[0]);
return res_pair;
}
Expand Down
19 changes: 19 additions & 0 deletions RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

#include <RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h>
#include <RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h>
#include <RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h>

#include <FWCore/Utilities/interface/Exception.h>
#include <TrackingTools/DetLayers/interface/DetLayer.h>
Expand All @@ -14,15 +16,32 @@
#include <Utilities/General/interface/precomputed_value_sort.h>
#include <DataFormats/GeometrySurface/interface/GeometricSorting.h>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <algorithm>

using namespace std;
using namespace geomsort;
using namespace edm;

MTDDetLayerGeometry::MTDDetLayerGeometry() {}

MTDDetLayerGeometry::~MTDDetLayerGeometry() {}

void MTDDetLayerGeometry::buildLayers(const MTDGeometry* geo, const MTDTopology* mtopo) {
if (geo) {
// Build BTL layers
this->addBTLLayers(BTLDetLayerGeometryBuilder::buildLayers(*geo));
// Build ETL layers, depends on the scenario
if (mtopo) {
this->addETLLayers(ETLDetLayerGeometryBuilder::buildLayers(*geo, mtopo->getMTDTopologyMode()));
} else {
LogWarning("MTDDetLayers") << "No MTD topology is available.";
}
} else {
LogWarning("MTDDetLayers") << "No MTD geometry is available.";
}
}

void MTDDetLayerGeometry::addETLLayers(const pair<vector<DetLayer*>, vector<DetLayer*> >& etllayers) {
for (auto const it : etllayers.first) {
etlLayers_fw.push_back(it);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
#include "RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
#include "Geometry/Records/interface/MTDTopologyRcd.h"
#include "Geometry/Records/interface/MTDDigiGeometryRecord.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include <memory>
#include <string>

class TrackerMTDRecoGeometryESProducer : public edm::ESProducer {
public:
TrackerMTDRecoGeometryESProducer(const edm::ParameterSet &p);

std::unique_ptr<GeometricSearchTracker> produce(const TrackerRecoGeometryRecord &);

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopToken_;
edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> mtdgeomToken_;
edm::ESGetToken<MTDTopology, MTDTopologyRcd> mtdTopToken_;
bool usePhase2Stacks_;
};

using namespace edm;

TrackerMTDRecoGeometryESProducer::TrackerMTDRecoGeometryESProducer(const edm::ParameterSet &p)
: usePhase2Stacks_(p.getParameter<bool>("usePhase2Stacks")) {
auto c = setWhatProduced(this);

tTopToken_ = c.consumes();
geomToken_ = c.consumes(edm::ESInputTag("", p.getUntrackedParameter<std::string>("trackerGeometryLabel")));
mtdgeomToken_ = c.consumes();
mtdTopToken_ = c.consumes();
}

std::unique_ptr<GeometricSearchTracker> TrackerMTDRecoGeometryESProducer::produce(
const TrackerRecoGeometryRecord &iRecord) {
TrackerGeometry const &tG = iRecord.get(geomToken_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parbol the clang-tidy warninbg reported refers to this line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry these were false positives. The original code (in ESProducers) is fine (and slightly better than going through getHandle()).

MTDGeometry const &mG = iRecord.get(mtdgeomToken_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this


GeometricSearchTrackerBuilder builder;
return std::unique_ptr<GeometricSearchTracker>(
builder.build(tG.trackerDet(), &tG, &iRecord.get(tTopToken_), &mG, &iRecord.get(mtdTopToken_), usePhase2Stacks_));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this one. As this is fresh new code, it would be good IMHO to fix it immediately

}

void TrackerMTDRecoGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;

desc.add<bool>("usePhase2Stacks", false);
desc.addUntracked<std::string>("trackerGeometryLabel", "");
descriptions.addDefault(desc);
}

DEFINE_FWK_EVENTSETUP_MODULE(TrackerMTDRecoGeometryESProducer);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import FWCore.ParameterSet.Config as cms

TrackerRecoGeometryESProducer = cms.ESProducer("TrackerMTDRecoGeometryESProducer",
usePhase2Stacks = cms.bool(False)
)

from Configuration.ProcessModifiers.vectorHits_cff import vectorHits
vectorHits.toModify(TrackerRecoGeometryESProducer, usePhase2Stacks = True)
3 changes: 2 additions & 1 deletion RecoTracker/MkFit/plugins/MkFitOutputConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ std::vector<const DetLayer*> MkFitOutputConverter::createDetLayers(const mkfit::
const int subdet, const int layer, const int isStereo, const DetId& detId, const DetLayer* lay) {
const int index = lnc.convertLayerNumber(subdet, layer, false, isStereo, isPlusSide(detId));
if (index < 0 or static_cast<unsigned>(index) >= dets.size()) {
throw cms::Exception("LogicError") << "Invalid mkFit layer index " << index << " for DetId " << detId
throw cms::Exception("LogicError") << "Invalid mkFit layer index " << index << " for det rawId " << detId.rawId()
<< " "
<< " subdet " << subdet << " layer " << layer << " isStereo " << isStereo;
}
dets[index] = lay;
Expand Down
13 changes: 10 additions & 3 deletions RecoTracker/Record/interface/TrackerRecoGeometryRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/Records/interface/MTDGeometryRecord.h"
#include "Geometry/Records/interface/MTDDigiGeometryRecord.h"
#include "Geometry/Records/interface/MTDTopologyRcd.h"

#include "FWCore/Utilities/interface/mplVector.h"

class TrackerRecoGeometryRecord : public edm::eventsetup::DependentRecordImplementation<
TrackerRecoGeometryRecord,
edm::mpl::Vector<TrackerTopologyRcd, TrackerDigiGeometryRecord> > {};
class TrackerRecoGeometryRecord
: public edm::eventsetup::DependentRecordImplementation<TrackerRecoGeometryRecord,
edm::mpl::Vector<TrackerTopologyRcd,
TrackerDigiGeometryRecord,
MTDGeometryRecord,
MTDTopologyRcd,
MTDDigiGeometryRecord> > {};

#endif
1 change: 1 addition & 0 deletions RecoTracker/TkDetLayers/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<use name="DataFormats/SiStripDetId"/>
<use name="DataFormats/SiPixelDetId"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="RecoMTD/DetLayers"/>
<use name="FWCore/MessageLogger"/>
16 changes: 16 additions & 0 deletions RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
#include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
#include "TrackingTools/DetLayers/interface/DetLayerGeometry.h"
#include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h"

class TrackerTopology;

Expand All @@ -26,6 +27,12 @@ class GeometricSearchTracker : public DetLayerGeometry {

~GeometricSearchTracker() override __attribute__((cold));

void addDetLayerGeometry();

void addMTDLayers(const std::vector<BarrelDetLayer const*>& btl,
const std::vector<ForwardDetLayer const*>& negEtl,
const std::vector<ForwardDetLayer const*>& posEtl);

std::vector<DetLayer const*> const& allLayers() const { return theAllLayers; }

std::vector<BarrelDetLayer const*> const& barrelLayers() const { return theBarrelLayers; }
Expand All @@ -52,6 +59,9 @@ class GeometricSearchTracker : public DetLayerGeometry {
/// obsolete method. Use idToLayer() instead.
const DetLayer* detLayer(const DetId& id) const { return idToLayer(id); };

//Need to make this pointer public so the tracker builder can build the MTD
MTDDetLayerGeometry* mtdDetLayerGeometry;

private:
std::vector<DetLayer const*> theAllLayers;
std::vector<BarrelDetLayer const*> theBarrelLayers;
Expand All @@ -70,6 +80,12 @@ class GeometricSearchTracker : public DetLayerGeometry {
std::vector<ForwardDetLayer const*> thePosTidLayers;
std::vector<ForwardDetLayer const*> thePosTecLayers;

//MTD stuff
std::vector<BarrelDetLayer const*> theBTLLayers;
std::vector<ForwardDetLayer const*> theETLLayers;
std::vector<ForwardDetLayer const*> theNegETLLayers;
std::vector<ForwardDetLayer const*> thePosETLLayers;

const TrackerTopology* theTrkTopo;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

class TrackerTopology;
class MTDTopology;

/** GeometricSearchTrackerBuilder implementation
*
Expand All @@ -20,6 +21,14 @@ class GeometricSearchTrackerBuilder {
const TrackerGeometry* theGeomDetGeometry,
const TrackerTopology* tTopo,
const bool usePhase2Stacks = false) __attribute__((cold));

//This constructor builds also the MTD geometry
GeometricSearchTracker* build(const GeometricDet* theGeometricTracker,
const TrackerGeometry* theGeomDetGeometry,
const TrackerTopology* tTopo,
const MTDGeometry* mtd,
const MTDTopology* mTopo,
const bool usePhase2Stacks = false) __attribute__((cold));
};

#endif
Loading