Skip to content

Commit

Permalink
Merge pull request #193 from JeffersonLab/iss192
Browse files Browse the repository at this point in the history
Add momentum info to the MC Tracker Hit
  • Loading branch information
pbutti authored Apr 22, 2024
2 parents 3b03733 + d67e8d4 commit fbf36b0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
19 changes: 14 additions & 5 deletions event/include/MCTrackerHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ class MCTrackerHit : public TObject {
*
* @param position The hit position.
*/
void setPosition(const double* position, bool rotate = false);

/** @return The hit position. */
std::vector<double> getPosition() const { return {x_, y_, z_}; };
void setPosition(const double* position, bool rotate = false);

/** @return The hit position. */
std::vector<double> getPosition() const { return {x_, y_, z_}; };

void setMomentum(const float* momentum, bool rotate = false);
std::vector<float> getMomentum() const { return {px_, py_, pz_}; };

/** @return the global X coordinate of the hit */
double getGlobalX() const {return x_;}
Expand Down Expand Up @@ -88,7 +91,8 @@ class MCTrackerHit : public TObject {
//** @return the pdg id of particle that made the hit */
int getPDG() const {return pdg_;};

ClassDef(MCTrackerHit, 1);

ClassDef(MCTrackerHit, 1);

private:

Expand All @@ -101,6 +105,11 @@ class MCTrackerHit : public TObject {
/** The x position of the hit. */
double z_{-999};

/** The truth momentum of the hit. Only MC */
float px_{-999};
float py_{-999};
float pz_{-999};

/** The hit time. */
double time_{-999};

Expand Down
19 changes: 19 additions & 0 deletions event/src/MCTrackerHit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ void MCTrackerHit::Clear(Option_t* /* options */) {
TObject::Clear();
}

void MCTrackerHit::setMomentum(const float* momentum, bool rotate) {

//svt angle: it's already with minus sign.
float svtAngle = 30.5e-3;
//Rotate the the input position automatically to match with the SVT tracker system
if (rotate)
{
//x_ = position[1];
py_ = momentum[2];
pz_ = momentum[1] * sin(svtAngle) + momentum[0]*cos(svtAngle);
px_ = momentum[1] * cos(svtAngle) - momentum[0]*sin(svtAngle);
}
else {
px_ = momentum[0];
py_ = momentum[1];
pz_ = momentum[2];
}
}

void MCTrackerHit::setPosition(const double* position, bool rotate) {

//svt angle: it's already with minus sign.
Expand Down
16 changes: 6 additions & 10 deletions processors/src/MCTrackerHitProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@ bool MCTrackerHitProcessor::process(IEvent* ievent) {
mc_tracker_hit->setLayer(decoder["layer"]);
mc_tracker_hit->setModule(decoder["module"]);

// Set the position of the hit
double hitPos[3];
hitPos[0] = lcio_mcTracker_hit->getPosition()[0];
hitPos[1] = lcio_mcTracker_hit->getPosition()[1];
hitPos[2] = lcio_mcTracker_hit->getPosition()[2];
mc_tracker_hit->setPosition(hitPos);

// Set the energy deposit of the hit
mc_tracker_hit->setPosition(lcio_mcTracker_hit->getPosition());
mc_tracker_hit->setMomentum(lcio_mcTracker_hit->getMomentum());

// Set the energy deposit of the hit
mc_tracker_hit->setEdep(lcio_mcTracker_hit->getEDep());

// Set the pdg of particle generating the hit
if(lcio_mcTracker_hit->getMCParticle())
mc_tracker_hit->setPDG(lcio_mcTracker_hit->getMCParticle()->getPDG());
Expand All @@ -90,7 +86,7 @@ bool MCTrackerHitProcessor::process(IEvent* ievent) {

//Push hit onto vector
trackerhits_.push_back(mc_tracker_hit);

}

return true;
Expand Down

0 comments on commit fbf36b0

Please sign in to comment.