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>
17#include <boost/foreach.hpp>
38 "Name of genfit::Track collection.", std::string(
""));
40 std::string(
"cosmics.root"));
50 "[CosmicsAlignmentValidation Module]: Starting initialization of CosmicsAlignmentValidation Module. Give me Cosmics!");
54 tree =
new TTree(
"cosmics",
"cosmics");
97 B2DEBUG(99,
"[CosmicsAlignmentValidationModule] begin event");
111 if (nFittedTracks != 2) {
113 "[CosmicsAlignmentValidationModule] no two tracks reconstructed, but "
126 if (fitResult1 == fitResult2)
128 "[CosmicsAlignmentValidationModule] Fit Results are from the same track!");
130 if (fitResult1 != NULL) {
146 if (fitResult2 != NULL) {
165 if (fitResult2 != NULL && fitResult1 != NULL) {
191 B2INFO(
"[CosmicsAlignmentValidationModule] Saving tree.");
193 "[CosmicsAlignmentValidationModule] Tree has " <<
tree->GetEntries()
196 tree->Write(
"cosmics");
201 const genfit::Track* gfTrack)
204 RelationIndex < genfit::Track, TrackFitResult > relGfTracksToTrackFitResults;
207 std::vector<const TrackFitResult*> fitResults;
209 BOOST_FOREACH(
const relElement_t& relGfTrackToTrackFitResult, relGfTracksToTrackFitResults.
getElementsFrom(gfTrack)) {
210 B2DEBUG(99,
"----> Related TrackFitResult found!!!");
211 fitResults.push_back(relGfTrackToTrackFitResult.to);
214 int numberTrackFitResults = fitResults.size();
216 if (numberTrackFitResults == 1) {
217 return fitResults[0];
219 if (numberTrackFitResults == 0) {
222 if (numberTrackFitResults > 1) {
224 "[CosmicsAlignmentValidationModule] genfit::Track has "
225 << numberTrackFitResults
226 <<
" 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
ouput 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.