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

Vertex Reconstruction with Timing 810 #15710

Merged
merged 5 commits into from
Sep 21, 2016
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: 2 additions & 1 deletion DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "DataFormats/GeometryCommonDetAlgo/interface/ErrorMatrixTag.h"

/**
* typedef to a GlobalErrorBase object defined as a 3*3 covariance matrix
* typedef to a GlobalErrorBase object defined as a 4*4 covariance matrix
* acts like a 3*3 matrix to preserve backwards compatibility
*/

typedef GlobalErrorBase<double,ErrorMatrixTag> GlobalError;
Expand Down
85 changes: 75 additions & 10 deletions DataFormats/GeometryCommonDetAlgo/interface/GlobalErrorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,51 @@ class GlobalErrorBase
theCartesianError(2,0)=c31;
theCartesianError(2,1)=c32;
theCartesianError(2,2)=c33;
theCartesianError(3,0) = 0.;
theCartesianError(3,1) = 0.;
theCartesianError(3,2) = 0.;
theCartesianError(3,3) = 0.;
}

/**
/**
* Constructor.
* The symmetric matrix stored as a lower triangular matrix (4D)
*/
GlobalErrorBase(T c11, T c21, T c22, T c31, T c32, T c33, T c41, T c42, T c43, T c44) {
theCartesianError(0,0)=c11;
theCartesianError(1,0)=c21;
theCartesianError(1,1)=c22;
theCartesianError(2,0)=c31;
theCartesianError(2,1)=c32;
theCartesianError(2,2)=c33;
theCartesianError(3,0)=c41;
theCartesianError(3,1)=c42;
theCartesianError(3,2)=c43;
theCartesianError(3,3)=c44;
}

/**
* Constructor from SymMatrix. The original matrix has to be a 3*3 matrix.
*/
GlobalErrorBase(const AlgebraicSymMatrix33 & err) :
theCartesianError(err) { }
GlobalErrorBase(const AlgebraicSymMatrix33 & err) {
theCartesianError(0,0) = err(0,0);
theCartesianError(1,0) = err(1,0);
theCartesianError(1,1) = err(1,1);
theCartesianError(2,0) = err(2,0);
theCartesianError(2,1) = err(2,1);
theCartesianError(2,2) = err(2,2);
theCartesianError(3,0) = 0.;
theCartesianError(3,1) = 0.;
theCartesianError(3,2) = 0.;
theCartesianError(3,3) = 0.;
}

/**
* Constructor from SymMatrix. The original matrix has to be a 4*4 matrix.
*/
GlobalErrorBase(const AlgebraicSymMatrix44 & err) :
theCartesianError(err) { }


~GlobalErrorBase() {}

Expand All @@ -85,19 +123,46 @@ class GlobalErrorBase
T czz() const {
return theCartesianError(2,2);
}

T ctx() const {
return theCartesianError(3,0);
}

/**
T cty() const {
return theCartesianError(3,1);
}

T ctz() const {
return theCartesianError(3,2);
}

T ctt() const {
return theCartesianError(3,3);
}

/**
* Access method to the matrix,
* /return The SymMatrix
*/
const AlgebraicSymMatrix33 & matrix() const {
return theCartesianError;
}
const AlgebraicSymMatrix33 & matrix_new() const {
const AlgebraicSymMatrix33 matrix() const {
AlgebraicSymMatrix33 out;
out(0,0) = theCartesianError(0,0);
out(1,0) = theCartesianError(1,0);
out(1,1) = theCartesianError(1,1);
out(2,0) = theCartesianError(2,0);
out(2,1) = theCartesianError(2,1);
out(2,2) = theCartesianError(2,2);
return out;
}

/**
* Access method to the matrix,
* /return The SymMatrix 4x4
*/
const AlgebraicSymMatrix44& matrix4D() const {
return theCartesianError;
}


T rerr(const GlobalPoint& aPoint) const {
T r2 = aPoint.perp2();
T x2 = aPoint.x()*aPoint.x();
Expand Down Expand Up @@ -129,7 +194,7 @@ class GlobalErrorBase

private:

AlgebraicSymMatrix33 theCartesianError;
AlgebraicSymMatrix44 theCartesianError;

};

Expand Down
3 changes: 2 additions & 1 deletion DataFormats/ParticleFlowReco/src/classes_def_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@
<class name="edm::Wrapper<std::vector<reco::PFDisplacedVertexCandidate> >"/>
<class name="edm::Ref< std::vector<reco::PFDisplacedVertexCandidate>, reco::PFDisplacedVertexCandidate, edm::refhelper::FindUsingAdvance<std::vector<reco::PFDisplacedVertexCandidate>,reco::PFDisplacedVertexCandidate> >"/>

<class name="reco::PFDisplacedVertex" ClassVersion="12">
<class name="reco::PFDisplacedVertex" ClassVersion="13">
<version ClassVersion="13" checksum="3552936040"/>
<version ClassVersion="12" checksum="2818127737"/>
<version ClassVersion="11" checksum="4172417049"/>
<version ClassVersion="10" checksum="4202892065"/>
Expand Down
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/src/classes_def_other.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<lcgdict>
<selection>

<class name="std::pair<std::string,std::vector<float> >" />
<class name="std::pair<std::string,std::vector<float> >" />
<class name="edm::Wrapper<std::pair<std::string,std::vector<float> > >" />
<class name="std::vector<pat::JetCorrFactors::CorrectionFactor>" />
<class name="edm::Wrapper<std::vector<pat::JetCorrFactors::CorrectionFactor> >" />
Expand Down
3 changes: 3 additions & 0 deletions DataFormats/PatCandidates/src/classes_other.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
namespace DataFormats_PatCandidates {
struct dictionaryother {

std::vector<std::vector<float> > vecvecf;
edm::Wrapper<std::vector<std::vector<float> > > wvecvecf;

std::pair<std::string, std::vector<float> > jcfcf;
edm::Wrapper<std::pair<std::string, std::vector<float> > > w_jcfcf;
std::vector<pat::JetCorrFactors::CorrectionFactor> v_jcfcf;
Expand Down
36 changes: 29 additions & 7 deletions DataFormats/VertexReco/interface/Vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,27 @@ namespace reco {
typedef math::Error<dimension>::type Error;
Copy link
Contributor

Choose a reason for hiding this comment

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

better defind dimension4D = 4 enum and use it instead of "dimension+1" everywhere

Copy link
Contributor

Choose a reason for hiding this comment

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

this comment was not addressed

/// covariance error matrix (3x3)
typedef math::Error<dimension>::type CovarianceMatrix;
/// covariance error matrix (4x4)
typedef math::Error<dimension+1>::type Error4D;
/// covariance error matrix (4x4)
typedef math::Error<dimension+1>::type CovarianceMatrix4D;
/// matix size
enum { size = dimension * ( dimension + 1 ) / 2 };
enum { size = dimension * ( dimension + 1 ) / 2, size4D = ( dimension + 1 ) * ( dimension + 2 ) / 2 };
/// index type
typedef unsigned int index;
/// default constructor - The vertex will not be valid. Position, error,
/// chi2, ndof will have random entries, and the vectors of tracks will be empty
/// Use the isValid method to check that your vertex is valid.
Vertex(): chi2_( 0.0 ), ndof_( 0 ), position_(0.,0.,0. ) { validity_ = false; for(int i = 0; i < size; ++ i ) covariance_[i]=0.;
Vertex(): chi2_( 0.0 ), ndof_( 0 ), position_(0.,0.,0.), time_(0.) { validity_ = false; for(int i = 0; i < size4D; ++ i ) covariance_[i]=0.;
}
/// Constructor for a fake vertex.
Vertex( const Point &, const Error &);
/// Constructor for a fake vertex. 4D
Vertex( const Point &, const Error4D &, double);
/// constructor for a valid vertex, with all data
Vertex( const Point &, const Error &, double chi2, double ndof, size_t size );
/// constructor for a valid vertex, with all data 4D
Vertex( const Point &, const Error4D &, double time, double chi2, double ndof, size_t size );
/// Tells whether the vertex is valid.
bool isValid() const {return validity_;}
/// Tells whether a Vertex is fake, i.e. not a vertex made out of a proper
Expand Down Expand Up @@ -84,6 +92,8 @@ namespace reco {
trackRef_iterator tracks_end() const;
/// number of tracks
size_t tracksSize() const;
/// python friendly track getting
const TrackBaseRef& trackRefAt(size_t idx) const { return tracks_[idx]; }
/// chi-squares
double chi2() const { return chi2_; }
/** Number of degrees of freedom
Expand All @@ -101,14 +111,18 @@ namespace reco {
double x() const { return position_.X(); }
/// y coordinate
double y() const { return position_.Y(); }
/// y coordinate
/// z coordinate
double z() const { return position_.Z(); }
/// t coordinate
double t() const { return time_; }
/// error on x
double xError() const { return sqrt( covariance(0, 0) ); }
/// error on y
double yError() const { return sqrt( covariance(1, 1) ); }
/// error on z
double zError() const { return sqrt( covariance(2, 2) ); }
/// error on t
double tError() const { return sqrt( covariance(3, 3) ); }
/// (i, j)-th element of error matrix, i, j = 0, ... 2
// Note that:
// double error( int i, int j ) const
Expand All @@ -118,10 +132,18 @@ namespace reco {
}
/// return SMatrix
CovarianceMatrix covariance() const { Error m; fill( m ); return m; }
/// return SMatrix 4D
CovarianceMatrix4D covariance4D() const { Error4D m; fill( m ); return m; }

/// return SMatrix
Error error() const { Error m; fill( m ); return m; }
/// return SMatrix
Error4D error4D() const { Error4D m; fill( m ); return m; }

/// fill SMatrix
void fill( CovarianceMatrix & v ) const;
/// 4D version
void fill( CovarianceMatrix4D & v ) const;

/// Checks whether refitted tracks are stored.
bool hasRefittedTracks() const {return !refittedTracks_.empty();}
Expand Down Expand Up @@ -162,16 +184,16 @@ namespace reco {
float ndof_;
/// position
Point position_;
/// covariance matrix (3x3) as vector
float covariance_[ size ];
/// covariance matrix (4x4) as vector
float covariance_[ size4D];
/// reference to tracks
std::vector<TrackBaseRef > tracks_;
std::vector<TrackBaseRef> tracks_;
/// The vector of refitted tracks
std::vector<Track> refittedTracks_;
std::vector<uint8_t> weights_;
/// tells wether the vertex is really valid.
bool validity_;

double time_;

/// position index
index idx( index i, index j ) const {
Expand Down
47 changes: 42 additions & 5 deletions DataFormats/VertexReco/src/Vertex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,64 @@ using namespace reco;
using namespace std;

Vertex::Vertex( const Point & p , const Error & err, double chi2, double ndof, size_t size ) :
chi2_( chi2 ), ndof_( ndof ), position_( p ) {
chi2_( chi2 ), ndof_( ndof ), position_( p ), time_(0.) {
tracks_.reserve( size );
index idx = 0;
for( index i = 0; i < dimension; ++ i )
for( index i = 0; i < dimension + 1; ++ i ) {
for( index j = 0; j <= i; ++ j ) {
if( i == dimension || j == dimension ) {
covariance_[ idx ++ ] = 0.0;
} else {
covariance_[ idx ++ ] = err( i, j );
}
}
}
validity_ = true;
}

Vertex::Vertex( const Point & p , const Error4D & err, double time, double chi2, double ndof, size_t size ) :
chi2_( chi2 ), ndof_( ndof ), position_( p ), time_(time) {
tracks_.reserve( size4D );
index idx = 0;
for( index i = 0; i < dimension + 1; ++ i )
for( index j = 0; j <= i; ++ j )
covariance_[ idx ++ ] = err( i, j );
validity_ = true;
}

Vertex::Vertex( const Point & p , const Error & err) :
chi2_( 0.0 ), ndof_( 0 ), position_( p ) {
chi2_( 0.0 ), ndof_( 0 ), position_( p ), time_(0.) {
index idx = 0;
for( index i = 0; i < dimension + 1; ++ i ) {
for( index j = 0; j <= i; ++ j ) {
if( i == dimension || j == dimension ) {
covariance_[ idx ++ ] = 0.0;
} else {
covariance_[ idx ++ ] = err( i, j );
}
}
}
validity_ = true;
}

Vertex::Vertex( const Point & p , const Error4D & err, double time) :
chi2_( 0.0 ), ndof_( 0 ), position_( p ), time_(time) {
index idx = 0;
for( index i = 0; i < dimension; ++ i )
for( index i = 0; i < dimension + 1; ++ i )
for( index j = 0; j <= i; ++ j )
covariance_[ idx ++ ] = err( i, j );
validity_ = true;
}

void Vertex::fill( Error & err ) const {
Error4D temp;
fill(temp);
err = temp.Sub<Error>(0,0);
}

void Vertex::fill( Error4D & err ) const {
index idx = 0;
for( index i = 0; i < dimension; ++ i )
for( index i = 0; i < dimension + 1; ++ i )
for( index j = 0; j <= i; ++ j )
err( i, j ) = covariance_[ idx ++ ];
}
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/VertexReco/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<lcgdict>
<class name="reco::Vertex" ClassVersion="10">
<class name="reco::Vertex" ClassVersion="11">
<version ClassVersion="11" checksum="4120119845"/>
<version ClassVersion="10" checksum="414871454"/>
</class>
<class name="std::vector<reco::Vertex>" />
Expand Down
3 changes: 3 additions & 0 deletions IOMC/RandomEngine/python/IOMC_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,6 @@
eras.phase2_muon.toModify(RandomNumberGeneratorService, simMuonME0Digis = cms.PSet(
initialSeed = cms.untracked.uint32(1234567),
engineName = cms.untracked.string('HepJamesRandom')) )

eras.phase2_timing.toModify(RandomNumberGeneratorService,
trackTimeValueMapProducer = cms.PSet(initialSeed = cms.untracked.uint32(1234567), engineName = cms.untracked.string('HepJamesRandom') ) )
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ TemplatedSecondaryVertexProducer<CandIPTagInfo,reco::VertexCompositePtrCandidate
edm::LogError("UnexpectedInputs") << "Building from Tracks, should not happen!";
VertexCompositePtrCandidate vtxCompPtrCand;

vtxCompPtrCand.setCovariance(sv.vertexState().error().matrix_new());
vtxCompPtrCand.setCovariance(sv.vertexState().error().matrix());
vtxCompPtrCand.setChi2AndNdof(sv.totalChiSquared(), sv.degreesOfFreedom());
vtxCompPtrCand.setVertex(Candidate::Point(sv.position().x(),sv.position().y(),sv.position().z()));

Expand All @@ -988,7 +988,7 @@ TemplatedSecondaryVertexProducer<CandIPTagInfo,reco::VertexCompositePtrCandidate
{
VertexCompositePtrCandidate vtxCompPtrCand;

vtxCompPtrCand.setCovariance(sv.vertexState().error().matrix_new());
vtxCompPtrCand.setCovariance(sv.vertexState().error().matrix());
vtxCompPtrCand.setChi2AndNdof(sv.totalChiSquared(), sv.degreesOfFreedom());
vtxCompPtrCand.setVertex(Candidate::Point(sv.position().x(),sv.position().y(),sv.position().z()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ double JetSignalVertexCompatibilityAlgo::trackVertexCompat(
tsos.cartesianError().position();

return ROOT::Math::Mag2(dir) /
std::sqrt(ROOT::Math::Similarity(cov.matrix_new(), dir));
std::sqrt(ROOT::Math::Similarity(cov.matrix(), dir));
}

const TransientTrack&
Expand Down
3 changes: 2 additions & 1 deletion RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<library name="RecoParticleFlowPFProducerSimPlugins" file="SimPFProducer.cc,TauHadronDecayFilter.cc,PFSimParticleProducer.cc,EcalBarrelClusterFastTimer.cc,ResolutionModel.cc,PerfectResolutionModel.cc,ConfigurableFlatResolutionModel.cc,SealModuleSim.cc">
<library name="RecoParticleFlowPFProducerSimPlugins" file="SimPFProducer.cc,TauHadronDecayFilter.cc,PFSimParticleProducer.cc,EcalBarrelClusterFastTimer.cc,,SealModuleSim.cc">
<use name="DataFormats/EcalDetId"/>
<use name="Geometry/HGCalGeometry"/>
<use name="TrackingTools/MaterialEffects"/>
Expand All @@ -24,6 +24,7 @@
<use name="RecoTracker/TrackProducer"/>
<use name="SimDataFormats/CaloHit"/>
<use name="SimGeneral/HepPDTRecord"/>
<use name="SimTracker/TrackAssociation"/>
<use name="TrackingTools/GeomPropagators"/>
<use name="TrackingTools/PatternTools"/>
<use name="TrackingTools/Records"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include <memory>

#include "ResolutionModel.h"
#include "SimTracker/TrackAssociation/interface/ResolutionModel.h"
#include "CLHEP/Units/SystemOfUnits.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "CLHEP/Random/RandGauss.h"
Expand Down
Loading