CbmRoot
Loading...
Searching...
No Matches
CbmBbaAlignmentMcbmTask.h
Go to the documentation of this file.
1/* Copyright (C) 2023-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: S.Gorbunov[committer], N.Bluhme */
4
11
12#ifndef CbmBbaAlignmentMcbmTask_H
13#define CbmBbaAlignmentMcbmTask_H
14
15
16#include "CbmDefs.h"
17#include "CbmKfTrackFitter.h"
18#include "FairTask.h"
19#include "TString.h"
20
21#include <vector>
22
23class TObject;
24class TH1F;
25class TClonesArray;
26class TFile;
27class TDirectory;
28class TH1F;
29
30
33
34class CbmBbaAlignmentMcbmTask : public FairTask {
35 public:
36 // Constructors/Destructors ---------
37 CbmBbaAlignmentMcbmTask(const char* name = "CbmBbaAlignmentMcbmTask", Int_t iVerbose = 0,
38 TString histoFileName = "./CbmBbaAlignmentHisto.root");
40
41 Int_t GetZtoNStation(Double_t getZ);
42
43 InitStatus Init();
44 void Exec(Option_t* opt);
45 void Finish();
46
49
51 void SetRandomSeed(int seed) { fRandomSeed = seed; }
52
53 void SetMatrixOutFileName(TString sMatrixOutFileName) { fsMatrixOutFileName = sMatrixOutFileName; }
54
55 public:
57 {
60 };
61
62 class Trajectory : public CbmKfTrackFitter<cbm::algo::kf::DoFitTime::N>::Trajectory {
63 public:
66
67 static int GetSensorId(const Node& node) { return node.userReferences[3]; }
68
69 static void SetSensorId(Node& node, int sensorId) { node.userReferences[3] = sensorId; }
70
71 void SetSensorId(size_t inode, int sensorId) { SetSensorId(fNodes[inode], sensorId); }
72 };
73
77
78 Trajectory fUnalignedTrack; // track before alignment
79 Trajectory fAlignedTrack; // track after alignment
80 cbm::algo::kf::TrackParamD fFittedAlignedTrackParam; // fitted track parameters after alignment
81
82 int fNmvdHits{0}; // number of MVD hits
83 int fNstsHits{0}; // number of STS hits
84 int fNmuchHits{0}; // number of MUCH hits
85 int fNtrd1dHits{0}; // number of TRD hits
86 int fNtrd2dHits{0}; // number of TRD hits
87 int fNtofHits{0}; // number of TOF hits
88
89 bool fIsActive{1}; // is the track active
90 void MakeConsistent();
91 };
92
95 };
96
97 struct Sensor { // TGeoNode to be aligned
101 std::string fNodePath{""}; // full path to the node in the root geometry
102
103 bool operator<(const Sensor& other) const
104 {
105 if (fSystemId < other.fSystemId) return true;
106 if (fSystemId > other.fSystemId) return false;
107 if (fTrackingStation < other.fTrackingStation) return true;
108 if (fTrackingStation > other.fTrackingStation) return false;
109 return (fNodePath < other.fNodePath);
110 };
111
112 bool operator==(const Sensor& other) const { return fNodePath == other.fNodePath; };
113 };
114
115 private:
118
119 void WriteHistosCurFile(TObject* obj);
120
121 void ApplyAlignment(const std::vector<double>& par);
122
123 double CostFunction(const std::vector<double>& par);
124
125 void ApplyConstraints(std::vector<double>& par);
126
127 void ConstrainStation(std::vector<double>& par, int iSta, int ixyz);
128
129
131
132 // input data arrays
133
134 TClonesArray* fInputGlobalTracks{nullptr};
135 TClonesArray* fInputStsTracks{nullptr};
136
137 TClonesArray* fInputMcTracks{nullptr}; // Mc info for debugging
138 TClonesArray* fInputGlobalTrackMatches{nullptr}; // Mc info for debugging
139 TClonesArray* fInputStsTrackMatches{nullptr}; // Mc info for debugging
140
141 int fNthreads = 1;
142
144
145 // collection of selected tracks and hits
146 std::vector<TrackContainer> fTracks;
147
148
149 //output file with histograms
150 TString fsMatrixOutFileName{"AlignmentMatrices_finetuning.root"};
151 TString fHistoFileName{"CbmBbaAlignmentHisto.root"};
152 TFile* fHistoFile{nullptr};
153 TDirectory* fHistoDir{nullptr};
154
156
158
161
162 double fCostIdeal{1.e10};
163 double fCostInitial{0.};
164
165 double fSimulatedMisalignmentRange{0.}; // misalignment range for simulated misalignment
166
168
169 double fChi2Total{0.};
170 long fNdfTotal{0};
171 long fFixedNdf{-1};
172
173
174 std::vector<Sensor> fSensors;
175 std::vector<AlignmentBody> fAlignmentBodies;
176
177 //histograms
178
179 std::vector<TH1F*> hResidualsBeforeAlignmentX{};
180 std::vector<TH1F*> hResidualsBeforeAlignmentY{};
181 std::vector<TH1F*> hResidualsAfterAlignmentX{};
182 std::vector<TH1F*> hResidualsAfterAlignmentY{};
183
184 std::vector<TH1F*> hPullsBeforeAlignmentX{};
185 std::vector<TH1F*> hPullsBeforeAlignmentY{};
186 std::vector<TH1F*> hPullsAfterAlignmentX{};
187 std::vector<TH1F*> hPullsAfterAlignmentY{};
188
190};
191
192#endif
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
int Int_t
void SetSensorId(size_t inode, int sensorId)
static void SetSensorId(Node &node, int sensorId)
static int GetSensorId(const Node &node)
void ApplyConstraints(std::vector< double > &par)
void ConstrainStation(std::vector< double > &par, int iSta, int ixyz)
std::vector< TH1F * > hPullsAfterAlignmentX
std::vector< TH1F * > hResidualsBeforeAlignmentY
ClassDef(CbmBbaAlignmentMcbmTask, 1)
std::vector< TH1F * > hPullsBeforeAlignmentY
double CostFunction(const std::vector< double > &par)
CbmKfTrackFitter< cbm::algo::kf::DoFitTime::N > fFitter
void SetSimulatedMisalignmentRange(double range)
void ApplyAlignment(const std::vector< double > &par)
const CbmBbaAlignmentMcbmTask & operator=(const CbmBbaAlignmentMcbmTask &)
std::vector< TH1F * > hPullsBeforeAlignmentX
std::vector< TH1F * > hPullsAfterAlignmentY
Int_t GetZtoNStation(Double_t getZ)
std::vector< TH1F * > hResidualsAfterAlignmentX
CbmBbaAlignmentMcbmTask(const char *name="CbmBbaAlignmentMcbmTask", Int_t iVerbose=0, TString histoFileName="./CbmBbaAlignmentHisto.root")
std::vector< TrackContainer > fTracks
std::vector< TH1F * > hResidualsAfterAlignmentY
std::vector< AlignmentBody > fAlignmentBodies
void SetMatrixOutFileName(TString sMatrixOutFileName)
CbmBbaAlignmentMcbmTask(const CbmBbaAlignmentMcbmTask &)
std::vector< TH1F * > hResidualsBeforeAlignmentX
TrackParam< double > TrackParamD
@ N
Do not fit the time component.
Definition KfDefs.h:133
bool operator<(const Sensor &other) const
bool operator==(const Sensor &other) const
cbm::algo::kf::TrackParamD fFittedAlignedTrackParam