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>
35 setDescription(
"Alignment Validation with Cosmics");
37 addParam(
"gfTrackColName", m_gfTrackColName,
38 "Name of genfit::Track collection.", std::string(
""));
39 addParam(
"outputFileName", m_outputFileName,
"Name of the output file.",
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");
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.");
Module to find Track correlation in cosmic events.
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.
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
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
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.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
double getZ0() const
Getter for z0.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
Element type for the index.