Skip to content

Commit

Permalink
address Iannas comments part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
JanFSchulte committed Aug 27, 2020
1 parent 2d86c8b commit 03698e6
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 99 deletions.
11 changes: 0 additions & 11 deletions DataFormats/TrackerRecHit2D/src/VectorHit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ VectorHit::VectorHit(const GeomDet& idet,
thePosition = LocalPoint(vh2Dzx.localPosition().x(), vh2Dzy.localPosition().x(), 0.);

theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), 1.);
//theDirection = LocalVector(vh2Dzx.localDirection().x(), vh2Dzy.localDirection().x(), vh2Dzy.localDirection().z());
//theDirection = theDirection.unit();

//building the cov matrix 4x4 starting from the 2x2
AlgebraicSymMatrix22 covMatZX = vh2Dzx.covMatrix();
Expand Down Expand Up @@ -82,7 +80,6 @@ bool VectorHit::sharesClusters(VectorHit const& h1, VectorHit const& h2, SharedI
}

void VectorHit::getKfComponents4D(KfComponentsHolder& holder) const {
//if (!hasPositionAndError()) throwExceptionUninitialized("getKfComponents");
AlgebraicVector4& pars = holder.params<4>();
pars[0] = theDirection.x();
pars[1] = theDirection.y();
Expand Down Expand Up @@ -229,8 +226,6 @@ std::pair<double, double> VectorHit::curvatureORphi(std::string curvORphi) const
double ytg = -(gPositionLower.x() - xcentre);

//to compute phi at the origin
//double xtg = ycentre;
//double ytg = -(xcentre);
phi = atan2(ytg, xtg);

AlgebraicROOTObject<4, 4>::Matrix jacobian;
Expand Down Expand Up @@ -268,10 +263,6 @@ std::pair<double, double> VectorHit::curvatureORphi(std::string curvORphi) const
M[0] = (gPositionLower.y() - ycentre) / pow(rho, 2); // dphi/dxcentre
M[1] = -(gPositionLower.x() - xcentre) / pow(rho, 2); // dphi/dycentre
//to compute phi at the origin
//float x0 = 0.0;
//float y0 = 0.0;
//M[0] = (y0 - ycentre)/pow(rho,2); // dphi/dxcentre
//M[1] =-(x0 - xcentre)/pow(rho,2); // dphi/dycentre

AlgebraicROOTObject<2, 4>::Matrix K;
K[0][0] =
Expand Down Expand Up @@ -342,8 +333,6 @@ std::pair<double, double> VectorHit::curvatureORphi(std::string curvORphi) const
temp = temp * gErrors;
errorCurvature = temp[0] * curvatureJacobian[0] + temp[1] * curvatureJacobian[1] + temp[2] * curvatureJacobian[2] +
temp[3] * curvatureJacobian[3];
//if(curvORphi == "curvature") std::cout << "curvature: " << curvature << std::endl;
//if(curvORphi == "curvature") std::cout << "curvature error: " << errorCurvature << std::endl;

} else {
std::cout << " straight line!" << std::endl;
Expand Down
1 change: 0 additions & 1 deletion DataFormats/TrackerRecHit2D/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@
<version ClassVersion="2" checksum="333065919"/>
</class>

<class name="edm::Ref<edmNew::DetSetVector<Phase2TrackerCluster1D>,Phase2TrackerCluster1D,edmNew::DetSetVector<Phase2TrackerCluster1D>::FindForDetSetVector>"/>
<class name="edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<Phase2TrackerCluster1D>,Phase2TrackerCluster1D,edmNew::DetSetVector<Phase2TrackerCluster1D>::FindForDetSetVector> >"/>
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<Phase2TrackerCluster1D>,Phase2TrackerCluster1D,edmNew::DetSetVector<Phase2TrackerCluster1D>::FindForDetSetVector> > >"/>
<class name="edmNew::DetSetVector<VectorHit> "/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from RecoLocalTracker.SiPhase2Clusterizer.phase2TrackerClusterizer_cfi import *
from RecoLocalTracker.Phase2TrackerRecHits.Phase2StripCPEGeometricESProducer_cfi import *
from RecoLocalTracker.SiPhase2VectorHitBuilder.SiPhase2RecHitMatcher_cfi import *

_pixeltrackerlocalrecoTask_phase2 = pixeltrackerlocalrecoTask.copy()
_pixeltrackerlocalrecoTask_phase2.add(siPhase2Clusters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include "DataFormats/Phase2TrackerCluster/interface/Phase2TrackerCluster1D.h"
#include "DataFormats/TrackerRecHit2D/interface/VectorHit.h"

#include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
#include <FWCore/ParameterSet/interface/ParameterSetDescription.h>

class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> {
public:
explicit VectorHitBuilderEDProducer(const edm::ParameterSet&);
Expand All @@ -24,15 +27,16 @@ class VectorHitBuilderEDProducer : public edm::stream::EDProducer<> {
edmNew::DetSetVector<Phase2TrackerCluster1D>& clustersRej,
VectorHitCollectionNew& outputAcc,
VectorHitCollectionNew& outputRej);
VectorHitBuilderAlgorithmBase* algo() const { return stubsBuilder; };
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
VectorHitBuilderAlgorithmBase* algo() const { return stubsBuilder_; };

private:
VectorHitBuilderAlgorithmBase* stubsBuilder;
std::string offlinestubsTag;
unsigned int maxOfflinestubs;
std::string algoTag;
edm::EDGetTokenT<edmNew::DetSetVector<Phase2TrackerCluster1D> > clusterProducer;
bool readytobuild;
VectorHitBuilderAlgorithmBase* stubsBuilder_;
std::string offlinestubsTag_;
unsigned int maxOfflinestubs_;
std::string algoTag_;
edm::EDGetTokenT<edmNew::DetSetVector<Phase2TrackerCluster1D> > clusterProducer_;
bool readytobuild_;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h"
#include "RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.h"

DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer);
DEFINE_FWK_MODULE(VectorHitBuilderEDProducer);
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
#include "RecoLocalTracker/SiPhase2VectorHitBuilder/plugins/SiPhase2RecHitMatcherESProducer.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 "RecoLocalTracker/Records/interface/TkPhase2OTCPERecord.h"

#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoLocalTracker/SiPhase2VectorHitBuilder/interface/VectorHitBuilderEDProducer.h"
#include <memory>

class SiPhase2RecHitMatcherESProducer : public edm::ESProducer {
public:
SiPhase2RecHitMatcherESProducer(const edm::ParameterSet&);
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
std::shared_ptr<VectorHitBuilderEDProducer> produce(const TkPhase2OTCPERecord&);

private:
std::string name_;
std::shared_ptr<VectorHitBuilderEDProducer> matcher_;
edm::ParameterSet pset_;
};

SiPhase2RecHitMatcherESProducer::SiPhase2RecHitMatcherESProducer(const edm::ParameterSet& p) {
name = p.getParameter<std::string>("ComponentName");
name_ = p.getParameter<std::string>("ComponentName");
pset_ = p;
setWhatProduced(this, name);
setWhatProduced(this, name_);
}

std::shared_ptr<VectorHitBuilderEDProducer> SiPhase2RecHitMatcherESProducer::produce(
const TkPhase2OTCPERecord& iRecord) {
if (name == "SiPhase2VectorHitMatcher") {
if (name_ == "SiPhase2VectorHitMatcher") {
matcher_ = std::make_shared<VectorHitBuilderEDProducer>(pset_);

edm::ESHandle<TrackerGeometry> tGeomHandle;
Expand All @@ -28,3 +44,36 @@ std::shared_ptr<VectorHitBuilderEDProducer> SiPhase2RecHitMatcherESProducer::pro
}
return matcher_;
}

void
SiPhase2RecHitMatcherESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("offlinestubs", "vectorHits");
desc.add<int>("maxVectorHits", 999999999);
desc.add<std::string>("Algorithm", "VectorHitBuilderAlgorithm");
desc.add<std::string>("ComponentName", "SiPhase2VectorHitMatcher");
desc.add<edm::ESInputTag>("CPE", edm::ESInputTag("phase2StripCPEESProducer","Phase2StripCPE"));
desc.add<std::vector<double>>("BarrelCut", {
0.0,
0.05,
0.06,
0.08,
0.09,
0.12,
0.2,
});
desc.add<std::string>("Phase2CPE_name", "Phase2StripCPE");
desc.add<std::string>("Clusters", "siPhase2Clusters");
desc.add<int>("maxVectorHitsInAStack", 999);
desc.add<std::vector<double>>("EndcapCut", {
0.0,
0.1,
0.1,
0.1,
0.1,
0.1,
});
descriptions.add("SiPhase2RecHitMatcherESProducer", desc);
}

DEFINE_FWK_EVENTSETUP_MODULE(SiPhase2RecHitMatcherESProducer);

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

VectorHitBuilderEDProducer::VectorHitBuilderEDProducer(edm::ParameterSet const& conf)
: offlinestubsTag(conf.getParameter<std::string>("offlinestubs")),
maxOfflinestubs(conf.getParameter<int>("maxVectorHits")),
algoTag(conf.getParameter<std::string>("Algorithm")),
//clusterProducer(conf.getParameter<edm::InputTag>("Clusters")),
readytobuild(false) {
clusterProducer = consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(
: offlinestubsTag_(conf.getParameter<std::string>("offlinestubs")),
maxOfflinestubs_(conf.getParameter<int>("maxVectorHits")),
algoTag_(conf.getParameter<std::string>("Algorithm")),
//_clusterProducer(conf.getParameter<edm::InputTag>("Clusters")),
readytobuild_(false) {
clusterProducer_ = consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(
edm::InputTag(conf.getParameter<std::string>("Clusters")));

produces<edmNew::DetSetVector<Phase2TrackerCluster1D> >("ClustersAccepted");
produces<edmNew::DetSetVector<Phase2TrackerCluster1D> >("ClustersRejected");
produces<VectorHitCollectionNew>(offlinestubsTag + "Accepted");
produces<VectorHitCollectionNew>(offlinestubsTag + "Rejected");
produces<VectorHitCollectionNew>(offlinestubsTag_ + "Accepted");
produces<VectorHitCollectionNew>(offlinestubsTag_ + "Rejected");
setupAlgorithm(conf);
}

VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder; }
VectorHitBuilderEDProducer::~VectorHitBuilderEDProducer() { delete stubsBuilder_; }

void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetup& es) {
LogDebug("VectorHitBuilderEDProducer") << "VectorHitBuilderEDProducer::produce() begin";

// get input clusters data
edm::Handle<edmNew::DetSetVector<Phase2TrackerCluster1D> > clustersHandle;
event.getByToken(clusterProducer, clustersHandle);
event.getByToken(clusterProducer_, clustersHandle);

// create the final output collection
std::unique_ptr<edmNew::DetSetVector<Phase2TrackerCluster1D> > outputClustersAccepted(
Expand All @@ -36,13 +36,13 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu
std::unique_ptr<VectorHitCollectionNew> outputVHAccepted(new VectorHitCollectionNew());
std::unique_ptr<VectorHitCollectionNew> outputVHRejected(new VectorHitCollectionNew());

if (readytobuild)
stubsBuilder->initialize(es);
if (readytobuild_)
stubsBuilder_->initialize(es);
else
edm::LogError("VectorHitBuilderEDProducer") << "Impossible initialization of builder!!";

// check on the input clusters
stubsBuilder->printClusters(*clustersHandle);
stubsBuilder_->printClusters(*clustersHandle);

// running the stub building algorithm
//ERICA::output should be moved in the different algo classes?
Expand All @@ -58,7 +58,7 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu
}
}
/*
if(numberOfVectorHits > maxOfflinestubs) {
if(numberOfVectorHits > _maxOfflinestubs) {
edm::LogError("VectorHitBuilderEDProducer") << "Limit on the number of stubs exceeded. An empty output collection will be produced instead.\n";
VectorHitCollectionNew empty;
empty.swap(outputAcc);
Expand All @@ -67,20 +67,20 @@ void VectorHitBuilderEDProducer::produce(edm::Event& event, const edm::EventSetu
// write output to file
event.put(std::move(outputClustersAccepted), "ClustersAccepted");
event.put(std::move(outputClustersRejected), "ClustersRejected");
event.put(std::move(outputVHAccepted), offlinestubsTag + "Accepted");
event.put(std::move(outputVHRejected), offlinestubsTag + "Rejected");
event.put(std::move(outputVHAccepted), offlinestubsTag_ + "Accepted");
event.put(std::move(outputVHRejected), offlinestubsTag_ + "Rejected");

// LogDebug("VectorHitBuilderEDProducer") << " Executing " << algoTag << " resulted in " << numberOfVectorHits << ".";
// LogDebug("VectorHitBuilderEDProducer") << " Executing " << _algoTag << " resulted in " << numberOfVectorHits << ".";
LogDebug("VectorHitBuilderEDProducer") << "found\n" << numberOfVectorHits << " .\n";
}

void VectorHitBuilderEDProducer::setupAlgorithm(edm::ParameterSet const& conf) {
if (algoTag == "VectorHitBuilderAlgorithm") {
stubsBuilder = new VectorHitBuilderAlgorithm(conf);
readytobuild = true;
if (algoTag_ == "VectorHitBuilderAlgorithm") {
stubsBuilder_ = new VectorHitBuilderAlgorithm(conf);
readytobuild_ = true;
} else {
edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag << " is invalid.\n";
readytobuild = false;
edm::LogError("VectorHitBuilderEDProducer") << " Choice " << algoTag_ << " is invalid.\n";
readytobuild_ = false;
}
}

Expand All @@ -89,12 +89,40 @@ void VectorHitBuilderEDProducer::run(edm::Handle<edmNew::DetSetVector<Phase2Trac
edmNew::DetSetVector<Phase2TrackerCluster1D>& clustersRej,
VectorHitCollectionNew& outputAcc,
VectorHitCollectionNew& outputRej) {
if (!readytobuild) {
if (!readytobuild_) {
edm::LogError("VectorHitBuilderEDProducer") << " No stub builder algorithm was found - cannot run!";
return;
}

stubsBuilder->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej);
stubsBuilder_->run(clusters, outputAcc, outputRej, clustersAcc, clustersRej);
}
void
VectorHitBuilderEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("offlinestubs", "vectorHits");
desc.add<int>("maxVectorHits", 999999999);
desc.add<std::string>("Algorithm", "VectorHitBuilderAlgorithm");
desc.add<edm::ESInputTag>("CPE", edm::ESInputTag("phase2StripCPEESProducer","Phase2StripCPE"));
desc.add<std::vector<double>>("BarrelCut", {
0.0,
0.05,
0.06,
0.08,
0.09,
0.12,
0.2,
});
desc.add<std::string>("Clusters", "siPhase2Clusters");
desc.add<int>("maxVectorHitsInAStack", 999);
desc.add<std::vector<double>>("EndcapCut", {
0.0,
0.1,
0.1,
0.1,
0.1,
0.1,
});
descriptions.add("siPhase2VectorHits", desc);
}

#include "FWCore/Utilities/interface/typelookup.h"
Expand Down

0 comments on commit 03698e6

Please sign in to comment.