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");
95 B2DEBUG(99,
"[CosmicsAlignmentValidationModule] begin event");
109 if (nFittedTracks != 2) {
111 "[CosmicsAlignmentValidationModule] no two tracks reconstructed, but "
124 if (fitResult1 == fitResult2)
126 "[CosmicsAlignmentValidationModule] Fit Results are from the same track!");
128 if (fitResult1 != NULL) {
144 if (fitResult2 != NULL) {
163 if (fitResult2 != NULL && fitResult1 != NULL) {
189 B2INFO(
"[CosmicsAlignmentValidationModule] Saving tree.");
191 "[CosmicsAlignmentValidationModule] Tree has " <<
tree->GetEntries()
194 tree->Write(
"cosmics");
199 const genfit::Track* gfTrack)
202 RelationIndex < genfit::Track, TrackFitResult > relGfTracksToTrackFitResults;
205 std::vector<const TrackFitResult*> fitResults;
207 for (
const relElement_t& relGfTrackToTrackFitResult : relGfTracksToTrackFitResults.
getElementsFrom(gfTrack)) {
208 B2DEBUG(99,
"----> Related TrackFitResult found!!!");
209 fitResults.push_back(relGfTrackToTrackFitResult.to);
212 int numberTrackFitResults = fitResults.size();
214 if (numberTrackFitResults == 1) {
215 return fitResults[0];
217 if (numberTrackFitResults == 0) {
220 if (numberTrackFitResults > 1) {
222 "[CosmicsAlignmentValidationModule] genfit::Track has "
223 << numberTrackFitResults
224 <<
" 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 endRun() override
Called once when a run ends.
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.
virtual void beginRun() override
Called once before a new run begins.
CosmicsAlignmentValidationModule()
Constructor, for setting module description and parameters.
StoreArray< genfit::Track > m_GenfitTracks
Genfit tracks.
virtual ~CosmicsAlignmentValidationModule()
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.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
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.
Element type for the index.