LDMX Software
Public Member Functions | Private Attributes | List of all members
tracking::reco::VertexProcessor Class Reference

Public Member Functions

 VertexProcessor (const std::string &name, framework::Process &process)
 Constructor.
 
 ~VertexProcessor ()=default
 Destructor.
 
void onProcessStart () override
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
void onProcessEnd () override
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor using the given user specified parameters.
 
void produce (framework::Event &event) override
 Run the processor.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

Acts::GeometryContext gctx_
 The contexts - TODO: they should move to some global location, I guess.
 
Acts::MagneticFieldContext bctx_
 
int nevents_ {0}
 
std::shared_ptr< InterpolatedMagneticField3 > sp_interpolated_bField_
 
std::string field_map_ {""}
 Path to the magnetic field map.
 
std::string trk_coll_name_ {"Tracks"}
 
std::shared_ptr< VoidPropagator > propagator_
 
double processing_time_ {0.}
 
TH1F * h_m_
 
TH1F * h_m_truthFilter_
 
TH1F * h_m_truth_
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 47 of file VertexProcessor.h.

Constructor & Destructor Documentation

◆ VertexProcessor()

tracking::reco::VertexProcessor::VertexProcessor ( const std::string &  name,
framework::Process process 
)

Constructor.

Parameters
nameThe name of the instance of this object.
processThe process running this producer.

Definition at line 12 of file VertexProcessor.cxx.

14 : framework::Producer(name, process) {}
Base class for a module which produces a data product.

Member Function Documentation

◆ configure()

void tracking::reco::VertexProcessor::configure ( framework::config::Parameters parameters)
overridevirtual

Configure the processor using the given user specified parameters.

Parameters
parametersSet of parameters used to configure this processor.

Reimplemented from framework::EventProcessor.

Definition at line 43 of file VertexProcessor.cxx.

43 {
44 // TODO:: the bfield map should be taken automatically
45 field_map_ = parameters.getParameter<std::string>("field_map");
46
47 trk_coll_name_ =
48 parameters.getParameter<std::string>("trk_coll_name", "Tracks");
49}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
std::string field_map_
Path to the magnetic field map.

References field_map_, and framework::config::Parameters::getParameter().

◆ onProcessEnd()

void tracking::reco::VertexProcessor::onProcessEnd ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.

Reimplemented from framework::EventProcessor.

Definition at line 191 of file VertexProcessor.cxx.

191 {
192 TFile *outfile = new TFile("VertexingResults.root", "RECREATE");
193 outfile->cd();
194
195 h_m_->Write();
196 h_m_truth_->Write();
197 h_m_truthFilter_->Write();
198 outfile->Close();
199 delete outfile;
200
201 ldmx_log(info) << "AVG Time/Event: " << std::fixed << std::setprecision(3)
202 << processing_time_ / nevents_ << " ms";
203}

◆ onProcessStart()

void tracking::reco::VertexProcessor::onProcessStart ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.

Reimplemented from framework::EventProcessor.

Definition at line 16 of file VertexProcessor.cxx.

16 {
17 gctx_ = Acts::GeometryContext();
18 bctx_ = Acts::MagneticFieldContext();
19
20 h_m_ = new TH1F("m", "m", 100, 0., 1.);
21 h_m_truthFilter_ = new TH1F("m_filter", "m", 100, 0., 1.);
22 h_m_truth_ = new TH1F("m_truth", "m_truth", 100, 0., 1.);
23
24 /*
25 * this is unused, should it be? FIXME
26 auto localToGlobalBin_xyz = [](std::array<size_t, 3> bins,
27 std::array<size_t, 3> sizes) {
28 return (bins[0] * (sizes[1] * sizes[2]) + bins[1] * sizes[2] +
29 bins[2]); // xyz - field space
30 // return (bins[1] * (sizes[2] * sizes[0]) + bins[2] * sizes[0] + bins[0]);
31 // //zxy
32 };
33 */
34
35 // Setup a interpolated bfield map
36 sp_interpolated_bField_ =
37 std::make_shared<InterpolatedMagneticField3>(loadDefaultBField(
38 field_map_, default_transformPos, default_transformBField));
39
40 ldmx_log(info) << "Check if nullptr::" << sp_interpolated_bField_.get();
41}
Acts::GeometryContext gctx_
The contexts - TODO: they should move to some global location, I guess.

References field_map_, and gctx_.

◆ produce()

void tracking::reco::VertexProcessor::produce ( framework::Event event)
overridevirtual

Run the processor.

Parameters
eventThe event to process.

Implements framework::Producer.

Definition at line 51 of file VertexProcessor.cxx.

51 {
52 // TODO:: Move this to an external file
53 // And move all this to a single time per processor not for each event!!
54
55 nevents_++;
56 auto start = std::chrono::high_resolution_clock::now();
57 auto &&stepper = Acts::EigenStepper<>{sp_interpolated_bField_};
58
59 // Set up propagator with void navigator
60 propagator_ = std::make_shared<VoidPropagator>(stepper);
61
62 // Track linearizer in the proximity of the vertex location
63 using Linearizer = Acts::HelicalTrackLinearizer;
64 Linearizer::Config linearizerConfig;
65 linearizerConfig.bField = sp_interpolated_bField_;
66 linearizerConfig.propagator = propagator_;
67 Linearizer linearizer(linearizerConfig);
68
69 // Set up Billoir Vertex Fitter
70 using VertexFitter = Acts::FullBilloirVertexFitter;
71
72 VertexFitter::Config vertexFitterCfg;
73
74 VertexFitter billoirFitter(vertexFitterCfg);
75
76 // VertexFitter::State state(sp_interpolated_bField_->makeCache(bctx_));
77
78 // Unconstrained fit
79 // See
80 // https://github.com/acts-project/acts/blob/main/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp#L149
81 // For constraint implementation
82
83 Acts::VertexingOptions vfOptions(gctx_, bctx_);
84
85 // Retrieve the track collection
86 const std::vector<ldmx::Track> tracks =
87 event.getCollection<ldmx::Track>(trk_coll_name_);
88
89 // Retrieve the truth seeds
90 const std::vector<ldmx::Track> seeds =
91 event.getCollection<ldmx::Track>("RecoilTruthSeeds");
92
93 if (tracks.size() < 1) return;
94
95 // Transform the EDM ldmx::tracks to the format needed by ACTS
96 std::vector<Acts::BoundTrackParameters> billoir_tracks;
97
98 // TODO:: The perigee surface should be common between all tracks.
99 // So should only be created once in principle.
100 // There should be no perigeeSurface2
101
102 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface =
103 Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3(
104 tracks.front().getPerigeeX(), tracks.front().getPerigeeY(),
105 tracks.front().getPerigeeZ()));
106
107 for (unsigned int iTrack = 0; iTrack < tracks.size(); iTrack++) {
108 Acts::BoundVector paramVec;
109 paramVec << tracks.at(iTrack).getD0(), tracks.at(iTrack).getZ0(),
110 tracks.at(iTrack).getPhi(), tracks.at(iTrack).getTheta(),
111 tracks.at(iTrack).getQoP(), tracks.at(iTrack).getT();
112
113 Acts::BoundSquareMatrix covMat =
114 tracking::sim::utils::unpackCov(tracks.at(iTrack).getPerigeeCov());
115 auto part{Acts::GenericParticleHypothesis(Acts::ParticleHypothesis(
116 Acts::PdgParticle(tracks.at(iTrack).getPdgID())))};
117 billoir_tracks.push_back(Acts::BoundTrackParameters(
118 perigeeSurface, paramVec, std::move(covMat), part));
119 }
120
121 // Select exactly 2 tracks
122 if (billoir_tracks.size() != 2) {
123 return;
124 }
125
126 if (billoir_tracks.at(0).charge() * billoir_tracks.at(1).charge() > 0) return;
127
128 // Pion mass hypothesis
129 double pion_mass = 139.570 * Acts::UnitConstants::MeV;
130
131 TLorentzVector p1, p2;
132 p1.SetXYZM(billoir_tracks.at(0).momentum()(0),
133 billoir_tracks.at(0).momentum()(1),
134 billoir_tracks.at(0).momentum()(2), pion_mass);
135
136 p2.SetXYZM(billoir_tracks.at(1).momentum()(0),
137 billoir_tracks.at(1).momentum()(1),
138 billoir_tracks.at(1).momentum()(2), pion_mass);
139
140 std::vector<TLorentzVector> pion_seeds;
141
142 if (seeds.size() == 2) {
143 for (int iSeed = 0; iSeed < seeds.size(); iSeed++) {
144 std::shared_ptr<Acts::PerigeeSurface> perigeeSurface2 =
145 Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3(
146 seeds.at(iSeed).getPerigeeX(), seeds.at(iSeed).getPerigeeY(),
147 seeds.at(iSeed).getPerigeeZ()));
148
149 Acts::BoundVector paramVec;
150 paramVec << seeds.at(iSeed).getD0(), seeds.at(iSeed).getZ0(),
151 seeds.at(iSeed).getPhi(), seeds.at(iSeed).getTheta(),
152 seeds.at(iSeed).getQoP(), seeds.at(iSeed).getT();
153
154 Acts::BoundSquareMatrix covMat =
155 tracking::sim::utils::unpackCov(seeds.at(iSeed).getPerigeeCov());
156 int pionPdgId = 211; // pi+
157 if (seeds.at(iSeed).q() < 0) pionPdgId = -211;
158 // BoundTrackParameters needs the particle hypothesis
159 auto part{Acts::GenericParticleHypothesis(
160 Acts::ParticleHypothesis(Acts::PdgParticle(pionPdgId)))};
161 auto boundSeedParams = Acts::BoundTrackParameters(
162 perigeeSurface, paramVec, std::move(covMat), part);
163
164 TLorentzVector pion4v;
165 pion4v.SetXYZM(boundSeedParams.momentum()(0),
166 boundSeedParams.momentum()(1),
167 boundSeedParams.momentum()(2), pion_mass);
168
169 pion_seeds.push_back(pion4v);
170 } // loops on seeds
171
172 h_m_truth_->Fill((pion_seeds.at(0) + pion_seeds.at(1)).M());
173 }
174
175 if ((pion_seeds.size() == 2) &&
176 (pion_seeds.at(0) + pion_seeds.at(1)).M() > 0.490 &&
177 (pion_seeds.at(0) + pion_seeds.at(1)).M() < 0.510) {
178 // Check if the tracks have opposite charge
179 h_m_truthFilter_->Fill((p1 + p2).M());
180 }
181
182 h_m_->Fill((p1 + p2).M());
183
184 auto end = std::chrono::high_resolution_clock::now();
185 // long long microseconds =
186 // std::chrono::duration_cast<std::chrono::microseconds>(end-start).count();
187 auto diff = end - start;
188 processing_time_ += std::chrono::duration<double, std::milli>(diff).count();
189}
Implementation of a track object.
Definition Track.h:52

References gctx_.

Member Data Documentation

◆ bctx_

Acts::MagneticFieldContext tracking::reco::VertexProcessor::bctx_
private

Definition at line 81 of file VertexProcessor.h.

◆ field_map_

std::string tracking::reco::VertexProcessor::field_map_ {""}
private

Path to the magnetic field map.

Definition at line 90 of file VertexProcessor.h.

90{""};

Referenced by configure(), and onProcessStart().

◆ gctx_

Acts::GeometryContext tracking::reco::VertexProcessor::gctx_
private

The contexts - TODO: they should move to some global location, I guess.

Definition at line 80 of file VertexProcessor.h.

Referenced by onProcessStart(), and produce().

◆ h_m_

TH1F* tracking::reco::VertexProcessor::h_m_
private

Definition at line 102 of file VertexProcessor.h.

◆ h_m_truth_

TH1F* tracking::reco::VertexProcessor::h_m_truth_
private

Definition at line 104 of file VertexProcessor.h.

◆ h_m_truthFilter_

TH1F* tracking::reco::VertexProcessor::h_m_truthFilter_
private

Definition at line 103 of file VertexProcessor.h.

◆ nevents_

int tracking::reco::VertexProcessor::nevents_ {0}
private

Definition at line 84 of file VertexProcessor.h.

84{0};

◆ processing_time_

double tracking::reco::VertexProcessor::processing_time_ {0.}
private

Definition at line 100 of file VertexProcessor.h.

100{0.};

◆ propagator_

std::shared_ptr<VoidPropagator> tracking::reco::VertexProcessor::propagator_
private

Definition at line 97 of file VertexProcessor.h.

◆ sp_interpolated_bField_

std::shared_ptr<InterpolatedMagneticField3> tracking::reco::VertexProcessor::sp_interpolated_bField_
private

Definition at line 87 of file VertexProcessor.h.

◆ trk_coll_name_

std::string tracking::reco::VertexProcessor::trk_coll_name_ {"Tracks"}
private

Definition at line 94 of file VertexProcessor.h.

94{"Tracks"};

The documentation for this class was generated from the following files: