forked from sPHENIX-Collaboration/coresoftware
/
RawClusterBuilderTopo.h
191 lines (127 loc) · 5.42 KB
/
RawClusterBuilderTopo.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#ifndef CALORECO_RAWCLUSTERTOPO_H
#define CALORECO_RAWCLUSTERTOPO_H
//===========================================================
/// \file RawClusterBuilderTopo.h
/// \brief 3-D topoClustering across calorimeter layers
/// \author Dennis V. Perepelitsa
//===========================================================
#include <fun4all/SubsysReco.h>
#include <string>
#include <vector>
#include <map>
#include <utility> // for pair
class PHCompositeNode;
class RawClusterContainer;
class RawTowerGeomContainer;
class RawClusterBuilderTopo : public SubsysReco
{
public:
RawClusterBuilderTopo(const std::string &name = "RawClusterBuilderTopo");
~RawClusterBuilderTopo() override {}
int InitRun(PHCompositeNode *topNode) override;
int process_event(PHCompositeNode *topNode) override;
int End(PHCompositeNode *topNode) override;
void set_nodename( const std::string &nodename ) {
ClusterNodeName = nodename;
}
void set_noise( float noise_0 = 0.0025, float noise_1 = 0.006, float noise_2 = 0.03) {
_noise_LAYER[ 0 ] = noise_0;
_noise_LAYER[ 1 ] = noise_1;
_noise_LAYER[ 2 ] = noise_2;
}
void set_significance( float seed, float grow, float peri ) {
_sigma_seed = seed;
_sigma_grow = grow;
_sigma_peri = peri;
}
void allow_corner_neighbor( bool allow ) {
_allow_corner_neighbor = allow;
}
void set_enable_HCal( bool enable_HCal ) {
_enable_HCal = enable_HCal;
}
void set_enable_EMCal( bool enable_EMCal ) {
_enable_EMCal = enable_EMCal;
}
void set_do_split( bool do_split ) {
_do_split = do_split;
}
void set_minE_local_max( float minE_0 = 1, float minE_1 = 1, float minE_2 = 1) {
_local_max_minE_LAYER[0] = minE_0;
_local_max_minE_LAYER[1] = minE_1;
_local_max_minE_LAYER[2] = minE_2;
}
void set_R_shower( float R_shower ) {
_R_shower = R_shower;
}
private:
void CreateNodes(PHCompositeNode *topNode);
std::vector< std::vector< std::vector<float> > > _TOWERMAP_E_LAYER_ETA_PHI;
std::vector< std::vector< std::vector<int> > > _TOWERMAP_KEY_LAYER_ETA_PHI;
std::vector< std::vector< std::vector<int> > > _TOWERMAP_STATUS_LAYER_ETA_PHI;
std::vector< std::vector<float> > _EMTOWERMAP_E_ETA_PHI;
std::vector< std::vector<int> > _EMTOWERMAP_KEY_ETA_PHI;
std::vector< std::vector<int> > _EMTOWERMAP_STATUS_ETA_PHI;
// geometric constants to express IHCal<->EMCal overlap in eta
static int RawClusterBuilderTopo_constants_EMCal_eta_start_given_IHCal[];
static int RawClusterBuilderTopo_constants_EMCal_eta_end_given_IHCal[];
static int RawClusterBuilderTopo_constants_IHCal_eta_given_EMCal[];
// geometric parameters defined at runtime
int _EMCAL_NETA;
int _EMCAL_NPHI;
int _HCAL_NETA;
int _HCAL_NPHI;
// utility functions to express IHCal<->EMCal overlap in phi
int get_first_matching_EMCal_phi_from_IHCal( int index_hcal_phi ) {
return ( (68 + 4 * ( index_hcal_phi - 32) + _EMCAL_NPHI ) % _EMCAL_NPHI );
}
int get_matching_HCal_phi_from_EMCal( int index_emcal_phi ) {
return ( (32 + ( index_emcal_phi - 68 + _EMCAL_NPHI ) / 4 ) % _HCAL_NPHI );
}
std::vector<int> get_adjacent_towers_by_ID( int ID );
float calculate_dR( float, float, float, float );
void export_single_cluster(std::vector<int>);
void export_clusters(std::vector<int>, std::map< int, std::pair<int,int> >, unsigned int, std::vector<float>, std::vector<float>, std::vector<float> );
int get_ID( int ilayer, int ieta, int iphi ) {
if ( ilayer < 2 ) return ilayer * _HCAL_NETA * _HCAL_NPHI + ieta * _HCAL_NPHI + iphi;
else return _EMCAL_NPHI * _EMCAL_NETA + ieta * _EMCAL_NPHI + iphi;
}
int get_ilayer_from_ID( int ID ) {
if ( ID < _EMCAL_NPHI * _EMCAL_NETA ) return ( (int) ( ID / ( _HCAL_NETA * _HCAL_NPHI ) ) );
else return 2;
}
int get_ieta_from_ID( int ID ) {
if ( ID < _EMCAL_NPHI * _EMCAL_NETA ) return ( (int) ( ( ID % ( _HCAL_NETA * _HCAL_NPHI ) ) / ( _HCAL_NPHI ) ) );
else return ( (int) ( ( ID - _EMCAL_NPHI * _EMCAL_NETA ) / _EMCAL_NPHI ) );
}
int get_iphi_from_ID( int ID ) {
if ( ID < _EMCAL_NPHI * _EMCAL_NETA ) return ( (int) ( ID % _HCAL_NPHI ) );
else return ( (int) ( ( ID - _EMCAL_NPHI * _EMCAL_NETA ) % _EMCAL_NPHI ) );
}
int get_status_from_ID( int ID ) {
if ( ID < _EMCAL_NPHI * _EMCAL_NETA ) return _TOWERMAP_STATUS_LAYER_ETA_PHI[ get_ilayer_from_ID( ID ) ][ get_ieta_from_ID( ID ) ][ get_iphi_from_ID( ID ) ];
else return _EMTOWERMAP_STATUS_ETA_PHI[ get_ieta_from_ID( ID ) ][ get_iphi_from_ID( ID ) ];
}
float get_E_from_ID( int ID ) {
if ( ID < _EMCAL_NPHI * _EMCAL_NETA ) return _TOWERMAP_E_LAYER_ETA_PHI[ get_ilayer_from_ID( ID ) ][ get_ieta_from_ID( ID ) ][ get_iphi_from_ID( ID ) ];
else return _EMTOWERMAP_E_ETA_PHI[ get_ieta_from_ID( ID ) ][ get_iphi_from_ID( ID ) ];
}
void set_status_by_ID( int ID , int status ) {
if ( ID < _EMCAL_NPHI * _EMCAL_NETA ) _TOWERMAP_STATUS_LAYER_ETA_PHI[ get_ilayer_from_ID( ID ) ][ get_ieta_from_ID( ID ) ][ get_iphi_from_ID( ID ) ] = status;
else _EMTOWERMAP_STATUS_ETA_PHI[ get_ieta_from_ID( ID ) ][ get_iphi_from_ID( ID ) ] = status;
}
RawClusterContainer *_clusters;
RawTowerGeomContainer* _geom_containers[3];
float _noise_LAYER[3];
float _sigma_seed;
float _sigma_grow;
float _sigma_peri;
bool _allow_corner_neighbor;
bool _enable_HCal;
bool _enable_EMCal;
bool _do_split;
float _local_max_minE_LAYER[3];
float _R_shower;
std::string ClusterNodeName;
};
#endif