Skip to content

Commit

Permalink
Move the function properly under the class
Browse files Browse the repository at this point in the history
  • Loading branch information
tvami committed Nov 15, 2024
1 parent 1a2be3c commit 6a1b0a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
16 changes: 3 additions & 13 deletions Ecal/include/Ecal/EcalVetoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,7 @@
#include "TVector3.h"

// For recoil tracking
// #include "Tracking/Event/Track.h"
#pragma once

#include "Framework/Configure/Parameters.h"
#include "Framework/Event.h"
#include "Framework/EventProcessor.h"
#include "SimCore/Event/SimTrackerHit.h"
#include "Tracking/Event/Measurement.h"
#include "Tracking/Event/Track.h"
#include "Tracking/Event/TruthTrack.h"

// C++
#include <map>
Expand Down Expand Up @@ -121,9 +112,9 @@ class EcalVetoProcessor : public framework::Producer {
* @param[in] ts_title The track state title, most likely "ecal"
* @returns Vector of parameters for a propagated recoil track
*/
std::vector<float> trackProp(const ldmx::Tracks& tracks,
ldmx::TrackStateType ts_type,
const std::string& ts_title);
std::vector<float> trackProp(const ldmx::Tracks& tracks,
ldmx::TrackStateType ts_type,
const std::string& ts_title);

private:
std::map<ldmx::EcalID, float> cellMap_;
Expand Down Expand Up @@ -183,7 +174,6 @@ class EcalVetoProcessor : public framework::Producer {
std::string rec_coll_name_;
bool recoil_from_tracking_;
std::string track_collection_;


/** Name of the collection which will containt the results. */
std::string collectionName_{"EcalVeto"};
Expand Down
29 changes: 13 additions & 16 deletions Ecal/src/Ecal/EcalVetoProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
/*~~~~~~~~~~~*/
#include "Tools/AnalysisUtils.h"

// For recoil tracking
#include "Tracking/Event/Track.h"

// C++
#include <stdlib.h>

Expand Down Expand Up @@ -246,13 +243,14 @@ void EcalVetoProcessor::produce(framework::Event &event) {
}
}
}
// Get recoilPos using recoil tracking
// Get recoilPos using recoil tracking
if (recoil_from_tracking_) {
auto recoil_tracks{event.getCollection<ldmx::Track>(track_collection_)};
std::vector<float> recoilTrackStates = trackProp(recoil_tracks, ldmx::TrackStateType::AtECAL, "ecal");
std::vector<float> recoilTrackStates =
trackProp(recoil_tracks, ldmx::TrackStateType::AtECAL, "ecal");
// recoilPos defined earlier but redefining now to come from the track state
recoilPos[0] = recoilTrackStates[0]; // track_state_loc0
recoilPos[1] = recoilTrackStates[1]; // track_state_loc1
recoilPos[0] = recoilTrackStates[0]; // track_state_loc0
recoilPos[1] = recoilTrackStates[1]; // track_state_loc1
}

if (verbose_) {
Expand Down Expand Up @@ -1274,18 +1272,18 @@ float EcalVetoProcessor::distPtToLine(TVector3 h1, TVector3 p1, TVector3 p2) {
return ((h1 - p1).Cross(h1 - p2)).Mag() / (p1 - p2).Mag();
}

std::vector<float> trackProp(const ldmx::Tracks& tracks,
ldmx::TrackStateType ts_type,
const std::string& ts_title) {
std::vector<float> EcalVetoProcessor::trackProp(const ldmx::Tracks &tracks,
ldmx::TrackStateType ts_type,
const std::string &ts_title) {
// Vector to hold the new track state variables
std::vector<float> newTrackStates;
std::vector<float> newTrackStates;

for (auto& track : tracks) {
for (auto &track : tracks) {
// Get track state for ts_type
auto trk_ts = track.getTrackState(ts_type);
// Continue if there's no value
if (!trk_ts.has_value()) continue;
ldmx::Track::TrackState& TargetState = trk_ts.value();
if (!trk_ts.has_value()) continue;
ldmx::Track::TrackState &TargetState = trk_ts.value();

// Check that the track state is filled
if (TargetState.params.size() < 5) continue;
Expand All @@ -1299,14 +1297,13 @@ std::vector<float> trackProp(const ldmx::Tracks& tracks,

// Break after getting the first valid track state
// TODO: interface this with CLUE to make sure the propageted track
// has an associated cluster in the ECAL
// has an associated cluster in the ECAL
break;
}

return newTrackStates;
}


} // namespace ecal

DECLARE_PRODUCER_NS(ecal, EcalVetoProcessor);

0 comments on commit 6a1b0a6

Please sign in to comment.