forked from sPHENIX-Collaboration/coresoftware
/
TpcSpaceChargeReconstruction.h
136 lines (104 loc) · 3.66 KB
/
TpcSpaceChargeReconstruction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef TPCCALIB_TPCSPACECHARGERECONSTRUCTION_H
#define TPCCALIB_TPCSPACECHARGERECONSTRUCTION_H
/**
* \file TpcSpaceChargeReconstruction.h
* \brief performs space charge distortion reconstruction using tracks
* \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
*/
#include <fun4all/SubsysReco.h>
#include <phparameter/PHParameterInterface.h>
#include <TString.h>
#include <memory>
#include <vector>
// forward declaration
class SvtxTrack;
class SvtxTrackMap;
class TpcSpaceChargeMatrixContainer;
class TrkrCluster;
class TrkrClusterContainer;
/**
* \class TpcSpaceChargeReconstruction
* \brief performs space charge distortion reconstruction using tracks
* \detail To reconstruct the distortions dr0, drphi0 and dz0 in a given volume element, the following chisquare is minimized
chisquare = sum_cluster (drphi - (drphi0 + dr0 tan alpha))**2/error**2 + sum_cluster ( dz - (dz0 + dr0 tan beta))**2/error**2
with
- drphi and dz the residuals (track - cluster) measured for a given cluster
- alpha and beta the track angles at the cluster in the rphi,r plane and the z,r plane, respectively
The chisquare being quadratic in dr0, drphi0 and dz0, it can be minimized analytically.
This results in a linear equation lhs[i].[corrections] = rhs[i], and thus [corrections] = lhs[i]**(-1).rhs[i]
The lhs and rhs matrices are filled in TpcSpaceChargeReconstruction::process_track
The actual inversion is performed in TpcSpaceChargeMatrixInversion::calculate_distortions
*/
class TpcSpaceChargeReconstruction: public SubsysReco, public PHParameterInterface
{
public:
/// constructor
TpcSpaceChargeReconstruction( const std::string& = "TPCSPACECHARGERECONSTRUCTION" );
///@name configuration
//@{
/// set whether to use only tracks with micromegas or not
void set_use_micromegas( bool value )
{ m_use_micromegas = value; }
/// set grid dimensions
/**
\param phibins the number of bins in the azimuth direction
\param zbins the number of bins along z
*/
void set_grid_dimensions( int phibins, int rbins, int zbins );
/// output file
/**
* this is the file where space charge matrix container is stored
*/
void set_outputfile( const std::string& filename )
{ m_outputfile = filename; }
//@}
/// global initialization
int Init(PHCompositeNode*) override;
/// run initialization
int InitRun(PHCompositeNode*) override;
/// event processing
int process_event(PHCompositeNode*) override;
/// end of processing
int End(PHCompositeNode*) override;
/// parameters
void SetDefaultParameters() override;
private:
/// load nodes
int load_nodes( PHCompositeNode* );
/// process tracks
void process_tracks();
/// returns true if track fulfills basic requirement for distortion calculations
bool accept_track( SvtxTrack* ) const;
/// process track
void process_track( SvtxTrack* );
/// get relevant cell for a given cluster
int get_cell_index( TrkrCluster* ) const;
/// output file
std::string m_outputfile = "TpcSpaceChargeMatrices.root";
/// true if only tracks with micromegas must be used
bool m_use_micromegas = true;
///@name selection parameters
//@{
// residual cuts in r, phi plane
float m_max_talpha = 0.6;
float m_max_drphi = 0.5;
// residual cuts in r, z plane
float m_max_tbeta = 1.5;
float m_max_dz = 0.5;
//@}
/// matrix container
std::unique_ptr<TpcSpaceChargeMatrixContainer> m_matrix_container;
///@name counters
//@{
int m_total_tracks = 0;
int m_accepted_tracks = 0;
int m_total_clusters = 0;
int m_accepted_clusters = 0;
//@}
///@name nodes
//@{
SvtxTrackMap* m_track_map = nullptr;
TrkrClusterContainer* m_cluster_map = nullptr;
//@}
};
#endif