Skip to content

Commit

Permalink
Small changes (defaults, comp warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tvami committed Sep 18, 2024
1 parent b63ea6f commit dda76d2
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 85 deletions.
10 changes: 5 additions & 5 deletions Recon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ if(BUILD_EVENT_ONLY)
class "TriggerResult" )
register_event_object( module_path "Recon/Event" namespace "ldmx"
class "HgcrocDigiCollection" )
register_event_object( module_path "Recon/Event"
register_event_object( module_path "Recon/Event"
namespace "ldmx" class "HgcrocTrigDigi"
type "collection" )
register_event_object( module_path "Recon/Event"
register_event_object( module_path "Recon/Event"
namespace "ldmx" class "CaloTrigPrim"
type "collection" )
register_event_object(module_path "Recon/Event" namespace "ldmx"
register_event_object(module_path "Recon/Event" namespace "ldmx"
class "PFCandidate" type "collection" )
register_event_object( module_path "Recon/Event" namespace "ldmx"
register_event_object( module_path "Recon/Event" namespace "ldmx"
class "BeamElectronTruth" type "collection" )
register_event_object( module_path "Recon/Event" namespace "ldmx"
class "TrackDeDxMassEstimate" type "collection" )
setup_library(module Recon name Event
setup_library(module Recon name Event
dependencies ROOT::Core
register_target)

Expand Down
73 changes: 35 additions & 38 deletions Recon/include/Recon/Event/TrackDeDxMassEstimate.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @file TrackDeDxMassEstimate.h
* @brief Class that represents the estimated mass of a particle
* @brief Class that represents the estimated mass of a particle
* using tracker dE/dx information
* @author Danyi Zhang, UCSB
* @author Danyi Zhang, Tamas Almos Vami (UCSB)
*/

#ifndef RECON_TRACKDEDXMASSESTIMATOR_H_
#define RECON_TRACKDEDXMASSESTIMATOR_H_
#ifndef RECON_TRACKDEDXMASSESTIMATE_H_
#define RECON_TRACKDEDXMASSESTIMATE_H_

#include <iostream>

Expand All @@ -20,15 +20,15 @@
namespace ldmx {
/**
* @class TrackDeDxMassEstimate
* @brief Represents the estimated mass of a particle
* @brief Represents the estimated mass of a particle
* using tracker dE/dx information
* @note This class represents the estimated mass information
* from a tracker including mass, track index, and the track type
*/

class TrackDeDxMassEstimate {
public:
/**
/**
* Class constructor.
*/
TrackDeDxMassEstimate();
Expand All @@ -48,63 +48,60 @@ class TrackDeDxMassEstimate {
*/
void Print() const;


/**
* Set the estimated mass of the particle/track.
* @param mass The estimated mass of the particle/track.
*/
* Set the estimated mass of the particle/track.
* @param mass The estimated mass of the particle/track.
*/
void setMass(double mass) { mass_ = mass; }

/**
* Set the index of the track.
* @param trackIndex The index of the track.
* 1: tagger track, 2: recoil track
*/
* Set the index of the track.
* @param trackIndex The index of the track.
*/
void setTrackIndex(int trackIndex) { trackIndex_ = trackIndex; }

/**
* Set the type of the track.
* @param trackType The type of the track.
*/
* Set the type of the track.
* @param trackType The type of the track.
* 1: tagger track, 2: recoil track
* Possibly consider truth with 0
* and ECAL with 3
*/
void setTrackType(int trackType) { trackType_ = trackType; }

/**
* Get the estimated mass of the particle/track.
* @return The estimated mass of the particle/track.
*/
* Get the estimated mass of the particle/track.
* @return The estimated mass of the particle/track.
*/
double getMass() const { return mass_; }

/**
* Get the index of the track.
* @return The index of the track.
*/
* Get the index of the track.
* @return The index of the track.
*/
int getTrackIndex() const { return trackIndex_; }

/**
* Get the type of the track.
* @return The type of the track.
*/
int getTrackType() const { return trackType_; }



/**
* Get the type of the track.
* @return The type of the track.
*/
int getTrackType() const { return trackType_; }

private:
/* The estimated mass of the particle/track */
double mass_{0.};

/* The index of the track */
int trackIndex_{0};
int trackIndex_{-1};

/* The type of the track */
int trackType_{0};
int trackType_{-1};

/**
* The ROOT class definition.
*/
* The ROOT class definition.
*/
ClassDef(TrackDeDxMassEstimate, 1);

};
} // namespace ldmx
} // namespace ldmx

#endif // RECON_TRACKDEDXMASSESTIMATOR_H_
#endif // RECON_TRACKDEDXMASSESTIMATE_H_
20 changes: 10 additions & 10 deletions Recon/include/Recon/TrackDeDxMassEstimator.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* @file TrackDeDxMassEstimator.h
* @brief Class that estimates the mass of a particle using tracker dE/dx information
* @author Danyi Zhang, UCSB
* @brief Class that estimates the mass of a particle using tracker dE/dx
* information
* @author Danyi Zhang, Tamas Almos Vami (UCSB)
*/

#ifndef RECON_TRACKDEDXMASSESTIMATOR_H_
Expand All @@ -10,10 +11,9 @@
// LDMX Framework
#include "Framework/Configure/Parameters.h"
#include "Framework/EventProcessor.h"

#include "Tracking/Event/Track.h"
#include "Tracking/Event/Measurement.h"
#include "Recon/Event/TrackDeDxMassEstimate.h"
#include "Tracking/Event/Measurement.h"
#include "Tracking/Event/Track.h"

namespace recon {

Expand All @@ -23,19 +23,19 @@ namespace recon {
*/
class TrackDeDxMassEstimator : public framework::Producer {
public:
TrackDeDxMassEstimator(const std::string &name, framework::Process &process)
TrackDeDxMassEstimator(const std::string& name, framework::Process& process)
: framework::Producer(name, process) {}

virtual void configure(framework::config::Parameters& ps);

virtual void produce(framework::Event& event);
virtual void produce(framework::Event& event) override;

private:
// specific verbosity of this producer
int verbose_{0};

float fit_res_C_{0.};
float fit_res_K_{0.};
float fit_res_K_{-9999.};

// name of input track collection
std::string trackCollection_;
Expand All @@ -46,4 +46,4 @@ class TrackDeDxMassEstimator : public framework::Producer {

} // namespace recon

#endif // RECON_TRACKMASSESTIMATORDEDX_H_
#endif // RECON_TRACKDEDXMASSESTIMATOR_H_
29 changes: 14 additions & 15 deletions Recon/src/Recon/Event/TrackDeDxMassEstimate.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
ClassImp(ldmx::TrackDeDxMassEstimate);

namespace ldmx {
TrackDeDxMassEstimate::TrackDeDxMassEstimate() {}
TrackDeDxMassEstimate::TrackDeDxMassEstimate() {}

TrackDeDxMassEstimate::~TrackDeDxMassEstimate() { Clear(); }
TrackDeDxMassEstimate::~TrackDeDxMassEstimate() { Clear(); }

void TrackDeDxMassEstimate::Clear() {
mass_ = 0.;
trackIndex_ = 0;
trackType_ = 0;
}
void TrackDeDxMassEstimate::Clear() {
mass_ = 0.;
trackIndex_ = -1;
trackType_ = -1;
}

void TrackDeDxMassEstimate::Print() const {
std::cout << "TrackDeDxMassEstimate { "
<< "Mass: " << mass_ << ", "
<< "Track Index: " << trackIndex_ << ", "
<< "Track Type: " << trackType_
<< " }" << std::endl;
}
void TrackDeDxMassEstimate::Print() const {
std::cout << "TrackDeDxMassEstimate { "
<< "Mass: " << mass_ << ", "
<< "Track Index: " << trackIndex_ << ", "
<< "Track Type: " << trackType_ << " }" << std::endl;
}

} // namespace ldmx
} // namespace ldmx
35 changes: 19 additions & 16 deletions Recon/src/Recon/TrackDeDxMassEstimator.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <iostream>
#include "Recon/TrackDeDxMassEstimator.h"

#include <iostream>

#include "Recon/Event/TrackDeDxMassEstimate.h"

namespace recon {
Expand All @@ -9,8 +11,9 @@ void TrackDeDxMassEstimator::configure(framework::config::Parameters &ps) {
fit_res_K_ = ps.getParameter<double>("fit_res_K");
trackCollection_ =
ps.getParameter<std::string>("track_collection", "RecoilTracks");

ldmx_log(info) << "Track Collection " << trackCollection_ << std::endl;

ldmx_log(info) << "Track Collection used for TrackDeDxMassEstimator "
<< trackCollection_;
}

void TrackDeDxMassEstimator::produce(framework::Event &event) {
Expand All @@ -19,38 +22,39 @@ void TrackDeDxMassEstimator::produce(framework::Event &event) {
<< " not in event" << std::endl;
return;
}
const std::vector<ldmx::Track> tracks{event.getCollection<ldmx::Track>(trackCollection_)};
const std::vector<ldmx::Track> tracks{
event.getCollection<ldmx::Track>(trackCollection_)};

// Retrieve the measurements
if (!event.exists(measCollection_)) return;
auto measurements{event.getCollection<ldmx::Measurement>(measCollection_)};

std::vector<ldmx::TrackDeDxMassEstimate> massEstimates;

// Loop over the collection of tracks
// for (auto &track : tracks) {
for (uint i = 0; i < tracks.size(); i++) {
auto track = tracks.at(i);
// If track momentum doen't exist, skip
if (track.getMomentum().empty()) {
ldmx_log(debug) << "Track " << i << " is empty" << std::endl;
auto trackMomentum = track.getMomentum();
if (trackMomentum.size() == 0) {
ldmx_log(debug) << "Track " << i << " is empty";
continue;
}

auto px = trackMomentum[0];
auto py = trackMomentum[1];
auto pz = trackMomentum[2];
// Get the track momentum magnitude
float p = sqrt(pow(track.getMomentum()[0], 2)
+ pow(track.getMomentum()[1], 2)
+ pow(track.getMomentum()[2], 2));
std::cout << "Track " << i << " has momentum " << p << std::endl;
float p = sqrt(px * px + py * py + pz * pz);
ldmx_log(debug) << "Track " << i << " has momentum " << p;

/// Get the hits associated with the track
ldmx::TrackDeDxMassEstimate mes;
float sum_dedx = 0;
float sum_dedx = 0.;
for (auto imeas : track.getMeasurementsIdxs()) {
auto meas = measurements.at(imeas);
if (meas.getEdep() >= 0)
sum_dedx += meas.getEdep();

if (meas.getEdep() > 0) sum_dedx += meas.getEdep();
}
mes.setMass(100.);
mes.setTrackIndex(i);
Expand All @@ -60,7 +64,6 @@ void TrackDeDxMassEstimator::produce(framework::Event &event) {

// Add the mass estimates to the event
event.add("TrackDeDxMassEstimate", massEstimates);


// // Loop over the collection of hits and print the hit details
// for (const ldmx::EcalHit &hit : hits) {
Expand Down
2 changes: 1 addition & 1 deletion Tracking/include/Tracking/Event/Measurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Measurement {
/// TrackIDs the vector of TrackIDs that form the measurement
std::vector<unsigned int> trackIds_{};

ClassDef(Measurement, 1);
ClassDef(Measurement, 2);
}; // Measurement

typedef std::vector<Measurement> Measurements;
Expand Down

0 comments on commit dda76d2

Please sign in to comment.