9#include <alignment/modules/CosmicsAlignmentValidation/CosmicsAlignmentValidation.h>
11#include <framework/datastore/RelationIndex.h>
12#include <mdst/dataobjects/MCParticle.h>
14#include <root/TFile.h>
15#include <root/TTree.h>
36 "Name of genfit::Track collection.", std::string(
""));
38 std::string(
"cosmics.root"));
48 "[CosmicsAlignmentValidation Module]: Starting initialization of CosmicsAlignmentValidation Module. Give me Cosmics!");
52 tree =
new TTree(
"cosmics",
"cosmics");
91 B2DEBUG(99,
"[CosmicsAlignmentValidationModule] begin event");
105 if (nFittedTracks != 2) {
107 "[CosmicsAlignmentValidationModule] no two tracks reconstructed, but "
120 if (fitResult1 == fitResult2)
122 "[CosmicsAlignmentValidationModule] Fit Results are from the same track!");
124 if (fitResult1 != NULL) {
140 if (fitResult2 != NULL) {
159 if (fitResult2 != NULL && fitResult1 != NULL) {
181 B2INFO(
"[CosmicsAlignmentValidationModule] Saving tree.");
183 "[CosmicsAlignmentValidationModule] Tree has " <<
tree->GetEntries()
186 tree->Write(
"cosmics");
191 const genfit::Track* gfTrack)
194 RelationIndex < genfit::Track, TrackFitResult > relGfTracksToTrackFitResults;
197 std::vector<const TrackFitResult*> fitResults;
199 for (
const relElement_t& relGfTrackToTrackFitResult : relGfTracksToTrackFitResults.
getElementsFrom(gfTrack)) {
200 B2DEBUG(99,
"----> Related TrackFitResult found!!!");
201 fitResults.push_back(relGfTrackToTrackFitResult.to);
204 int numberTrackFitResults = fitResults.size();
206 if (numberTrackFitResults == 1) {
207 return fitResults[0];
209 if (numberTrackFitResults == 0) {
212 if (numberTrackFitResults > 1) {
214 "[CosmicsAlignmentValidationModule] genfit::Track has "
215 << numberTrackFitResults
216 <<
" related TrackFitResults. No TrackFitResult is returned.");
virtual void initialize() override
Use this to initialize resources or memory your module needs.
float t_p2MC
momentum in MC
virtual void event() override
Called once for each event.
virtual void terminate() override
Clean up anything you created in initialize().
const TrackFitResult * findRelatedTrackFitResult(const genfit::Track *gfTrack)
Find trackfit results in for the corresponding track.
CosmicsAlignmentValidationModule()
Constructor, for setting module description and parameters.
StoreArray< genfit::Track > m_GenfitTracks
Genfit tracks.
~CosmicsAlignmentValidationModule() override
Use to clean up anything you created in the constructor.
float t_p1MC
momentum in MC
std::string m_gfTrackColName
m_gfTrackColName
StoreArray< MCParticle > m_MCParticles
MC particles.
std::string m_outputFileName
output filename string
void setDescription(const std::string &description)
Sets the description of the module.
range_from getElementsFrom(const FROM *from) const
Return a range of all elements pointing from the given object.
RelationIndexContainer< FROM, TO >::Element Element
Struct representing a single element in the index.
Values of the result of a track fit with a given particle hypothesis.
double getPhi() const
Getter for phi0 with CDF naming convention.
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
double getOmega() const
Getter for omega.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.