Skip to content

Commit

Permalink
Make necessary changes for mutable classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Dec 6, 2021
1 parent b1b0b2b commit 822a7df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions edm4hep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ components:
- float x
- float y
- float z
ExtraCode :
MutableExtraCode:
declaration: "
Vector3f() : x(0),y(0),z(0) {}\n
Vector3f(float xx, float yy, float zz) : x(xx),y(yy),z(zz) {}\n
Expand All @@ -27,7 +27,7 @@ components:
- double x
- double y
- double z
ExtraCode :
MutableExtraCode:
declaration: "
Vector3d() : x(0),y(0),z(0) {}\n
Vector3d(double xx, double yy, double zz) : x(xx),y(yy),z(zz) {}\n
Expand All @@ -42,7 +42,7 @@ components:
Members:
- int a
- int b
ExtraCode :
MutableExtraCode:
declaration: "
Vector2i() : a(0),b(0) {}\n
Vector2i(int aa,int bb) : a(aa),b(bb) {}\n
Expand All @@ -56,7 +56,7 @@ components:
Members:
- float a
- float b
ExtraCode :
MutableExtraCode:
declaration: "
Vector2f() : a(0),b(0) {}\n
Vector2f(float aa,float bb) : a(aa),b(bb) {}\n
Expand All @@ -76,7 +76,7 @@ components:
- float tanLambda // lambda is the dip angle of the track in r-z
- edm4hep::Vector3f referencePoint // Reference point of the track parameters, e.g. the origin at the IP, or the position of the first/last hits or the entry point into the calorimeter.
- std::array<float, 15> covMatrix // lower triangular covariance matrix of the track parameters. the order of parameters is d0, phi, omega, z0, tan(lambda). the array is a row-major flattening of the matrix.
ExtraCode :
MutableExtraCode:
declaration: "
static const int AtOther = 0 ; // any location other than the ones defined below\n
static const int AtIP = 1 ;\n
Expand All @@ -92,7 +92,7 @@ components:
Members:
- int index
- int collectionID
ExtraCode :
MutableExtraCode:
includes: "#include <podio/ObjectID.h>\n"
declaration: "
ObjectID() = default;\n
Expand Down Expand Up @@ -132,7 +132,7 @@ datatypes :
OneToManyRelations:
- edm4hep::MCParticle parents // The parents of this particle.
- edm4hep::MCParticle daughters // The daughters this particle.
ExtraCode :
MutableExtraCode:
includes: "#include <cmath>"
declaration: "
int set_bit(int val, int num, bool bitval){ return (val & ~(1<<num)) | (bitval << num); } \n
Expand All @@ -146,7 +146,7 @@ datatypes :
void setOverlay(bool bitval) { setSimulatorStatus( set_bit( getSimulatorStatus() , BITOverlay , bitval ) ) ; } \n
"

ConstExtraCode:
ExtraCode:
declaration: "
// define the bit positions for the simulation flag\n
static const int BITEndpoint = 31;\n
Expand Down Expand Up @@ -195,14 +195,14 @@ datatypes :
- edm4hep::Vector3f momentum //the 3-momentum of the particle at the hits position in [GeV]
OneToOneRelations:
- edm4hep::MCParticle MCParticle //MCParticle that caused the hit.
ExtraCode :
MutableExtraCode:
includes: "#include <cmath>"
declaration: "
int set_bit(int val, int num, bool bitval){ return (val & ~(1<<num)) | (bitval << num); }\n
void setOverlay(bool val) { setQuality( set_bit( getQuality() , BITOverlay , val ) ) ; }\n
void setProducedBySecondary(bool val) { setQuality( set_bit( getQuality() , BITProducedBySecondary , val ) ) ; }\n
"
ConstExtraCode:
ExtraCode:
declaration: "
static const int BITOverlay = 31;\n
static const int BITProducedBySecondary = 30;\n
Expand Down Expand Up @@ -403,7 +403,7 @@ datatypes :
- edm4hep::Track tracks //tracks that have been used for this particle.
- edm4hep::ReconstructedParticle particles //reconstructed particles that have been combined to this particle.
- edm4hep::ParticleID particleIDs //particle Ids (not sorted by their likelihood)
ExtraCode:
MutableExtraCode:
declaration: "
bool isCompound() { return particles_size() > 0 ;}\n
//vertex where the particle decays This method actually returns the start vertex from the first daughter particle found.\n
Expand Down Expand Up @@ -471,4 +471,4 @@ datatypes :
- float weight // weight of this association
OneToOneRelations:
- edm4hep::Track rec // reference to the track
- edm4hep::MCParticle sim // reference to the Monte-Carlo particle
- edm4hep::MCParticle sim // reference to the Monte-Carlo particle
14 changes: 7 additions & 7 deletions test/utils/test_kinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

#include "edm4hep/kinematics.h"

#include "edm4hep/MCParticle.h"
#include "edm4hep/ReconstructedParticle.h"
#include "edm4hep/MutableMCParticle.h"
#include "edm4hep/MutableReconstructedParticle.h"

#include "Math/Vector4D.h"

#include <tuple>

using ParticleTypes = std::tuple<edm4hep::MCParticle, edm4hep::ReconstructedParticle>;
using ParticleTypes = std::tuple<edm4hep::MutableMCParticle, edm4hep::MutableReconstructedParticle>;

TEMPLATE_LIST_TEST_CASE( "pT: transverse momentum", "[pT][kinematics]", ParticleTypes)
{
Expand Down Expand Up @@ -62,7 +62,7 @@ TEMPLATE_LIST_TEST_CASE( "p: momentum", "[p][kinematics]", ParticleTypes )
TEST_CASE( "p4: four momentum - MCParticle", "[p4][kinematics][MCParticle]" )
{
using namespace edm4hep;
MCParticle particle;
MutableMCParticle particle;
particle.setMomentum({1.0f, 2.0f, 3.0f});
particle.setMass(42);
REQUIRE(utils::p4(particle) == LorentzVectorM{1, 2, 3, 42});
Expand All @@ -74,7 +74,7 @@ TEST_CASE( "p4: four momentum - MCParticle", "[p4][kinematics][MCParticle]" )
TEST_CASE( "p4: four momentum - ReconstructedParticle", "[p4][kinematics][ReconstructedParticle]" )
{
using namespace edm4hep;
ReconstructedParticle particle;
MutableReconstructedParticle particle;
particle.setMomentum({1.0f, 2.0f, 3.0f});
particle.setMass(125);

Expand All @@ -94,7 +94,7 @@ TEST_CASE( "p4: four momentum - ReconstructedParticle", "[p4][kinematics][Recons

TEST_CASE( "p4 with user set values", "[p4][kinematics][user set values]" ) {
using namespace edm4hep;
ReconstructedParticle particle;
MutableReconstructedParticle particle;
particle.setMomentum({1.0f, 2.0f, 3.0f});
particle.setMass(125.0f);
particle.setEnergy(42.0f);
Expand All @@ -110,7 +110,7 @@ TEST_CASE( "p4 with user set values", "[p4][kinematics][user set values]" ) {
REQUIRE(particle.getEnergy() == 42.f);

// Make sure everything still works with the MC particle
MCParticle mcPart;
MutableMCParticle mcPart;
mcPart.setMomentum({-1.0f, -2.0f, -3.0f});
mcPart.setMass(125.0f);

Expand Down
4 changes: 2 additions & 2 deletions test/write_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void write(std::string outfilename) {
sch1.setEnergy( j * 0.1 );
sch1.setPosition( { j*100.f , j*200.f, j*50.f } ) ;

auto cont1 = edm4hep::CaloHitContribution(11, j * 0.1f ,j*1e-9f, { j*100.01f , j*200.01f, j*50.01f } );
auto cont1 = edm4hep::MutableCaloHitContribution(11, j * 0.1f ,j*1e-9f, { j*100.01f , j*200.01f, j*50.01f } );
sccons.push_back( cont1 ) ;
cont1.setParticle( mcp7 ) ;
sch1.addToContributions( cont1 ) ;
Expand All @@ -168,7 +168,7 @@ void write(std::string outfilename) {
sch2.setPosition( { -j*100.f , -j*200.f, -j*50.f } ) ;
sch2.setEnergy( j * .2 );

auto cont2 = edm4hep::CaloHitContribution(-11, j*0.2f , j*1e-9f, { -j*100.01f , -j*200.01f, -j*50.01f } );
auto cont2 = edm4hep::MutableCaloHitContribution(-11, j*0.2f , j*1e-9f, { -j*100.01f , -j*200.01f, -j*50.01f } );
sccons.push_back( cont2 ) ;
cont2.setParticle( mcp8 ) ;
sch2.addToContributions( cont2 ) ;
Expand Down

0 comments on commit 822a7df

Please sign in to comment.