58{
61 if (logLevel==MSG::VERBOSE)
m_debug = 1;
62 if (logLevel< MSG::VERBOSE)
m_debug = 2;
63
64
70 }
71 else {
73 return 1;
74 }
76 log << MSG::ERROR <<
"Could not open file " <<
file <<
endmsg;
77 return 1;
78 }
79
80
81
82
83 unsigned int line=0, record=0;
85
86 log << MSG::VERBOSE <<
"Parsing input file:" <<
endmsg;
87
88 std::vector<Cell> allCells;
89
90 while ( fin >> token ) {
92 if ( token[0] == '#' || token[0] == '!' || ( token[0] == '/' && token[1] == '/' ) ) {
94 continue;
95 }
96
97 unsigned int toklen = strlen(token) - 1 ;
98 token[toklen] = 0;
99 log << MSG::VERBOSE << token <<
" ";
100
101 Cell newCell;
102 newCell.name = token;
103 for (
unsigned int i=0;
i<4; ++
i) newCell.neighbours[i].clear();
104
106 while ( fin >> token) {
107 toklen = strlen(token) - 1;
108 bool lastelem = ( token[toklen] == ';' );
109 token[toklen] = 0;
111 if (strcmp(token,"none") != 0)
112 newCell.neighbours[
column].emplace_back(token);
113 if (lastelem) {
115 if (4 == column) break;
116 }
117 }
118
120
122 allCells.emplace_back(std::move(newCell));
123 record++;
124
125 }
126
128
129 log << MSG::DEBUG <<
"Processed " <<
line <<
" lines, " << record <<
" records." <<
endmsg;
130
131 unsigned int curSize = allCells.size();
132 for (
unsigned int i=0;
i<curSize; ++
i) {
133
134 std::string::size_type
pos = allCells[
i].name.find(
'-', 0 );
135 if ( std::string::npos != pos ) {
136
137 Cell newCell;
138 std::string tmpName;
139 tmpName = allCells[
i].name;
140 tmpName.replace(pos,1,"+");
141 newCell.name = tmpName;
142
143 for (unsigned int j=0; j<4; ++j) {
144 unsigned int j1 = (j<2) ? 1-j : j;
145 unsigned int nb_size=allCells[
i].neighbours[j].size();
146 for (
unsigned int k=0;
k<nb_size; ++
k) {
147 tmpName = allCells[
i].neighbours[j][
k];
148 pos = tmpName.find(
'-', 0 );
149 if ( std::string::npos != pos ) {
150 tmpName.replace(pos,1,"+");
151 } else {
152 pos = tmpName.find(
'+', 0 );
153 if ( std::string::npos != pos ) {
154 tmpName.replace(pos,1,"-");
155 }
156 }
157 newCell.neighbours[
j1].push_back(tmpName);
158 }
159 }
160 allCells.push_back(std::move(newCell));
161 }
162 }
163
164 unsigned int nids = 0;
165 unsigned int max_phi = 0,
phi=0;
166 std::set<std::pair<IdentifierHash,int> >
ids;
170 ConstRangeIterator rit(range);
171 auto first = rit.begin();
172 auto last = rit.end();
174 const ExpandedIdentifier& exp_id = (*first);
176 if (
phi > max_phi) max_phi =
phi;
183 if(!(
ids.insert(std::make_pair(hashid,
phi))).second){
184 log << MSG::ERROR <<
"init_hashes "
185 << " Error: duplicated id for cell id. nids= " << nids
188 }
189 nids++;
190 }
191 }
192 ++max_phi;
197 return (1);
198 }
199
200 curSize = allCells.size();
201
202 std::string nb_name[4] = {"Prev_eta_", "Next_eta_", "Prev_smp_", "Next_smp_"};
203
204 for (
unsigned int i=0;
i<curSize; ++
i) {
205 get_id(allCells[i].name,allCells[i].
id,tileID);
206 allCells[
i].hash_id = tileID->
channels().
hash (allCells[i].
id);
207 for (
unsigned int ii=0; ii<
m_length; ++ii) {
209 allCells[
i].index = ii;
210 break;
211 }
212 }
213
214 for (unsigned int j=0; j<4; ++j) {
215 unsigned int nb_size=allCells[
i].neighbours[j].size();
216 allCells[
i].neighbours_ind[j].resize(nb_size);
217 for (
unsigned int k=0;
k<nb_size; ++
k) {
218 for (unsigned int ii=0; ii<curSize; ++ii) {
219 if ( allCells[ii].name == allCells[i].neighbours[j][k]) {
220 allCells[
i].neighbours_ind[j][
k] = ii;
222 log << MSG::VERBOSE << allCells[
i].name <<
" "
223 << tileID->
to_string(allCells[i].
id,-2) <<
" "
224 << allCells[
i].hash_id <<
" "
225 << allCells[
i].index <<
" "
226 << nb_name[j] <<
k <<
" "
227 << allCells[
i].neighbours[j][
k] <<
" "
228 << allCells[
i].neighbours_ind[j][
k] <<
" "
230 }
231 break;
232 }
233 }
234 }
235 }
236 }
237
244
245 std::vector<short int> neighbours[4];
246 for (
unsigned int i=0;
i<curSize; ++
i) {
247 unsigned int ind = allCells[
i].index;
248
249 for (unsigned int j=0; j<4; ++j) {
250 unsigned int nb_size=allCells[
i].neighbours[j].size();
251 neighbours[j].resize(nb_size);
252 for (
unsigned int k=0;
k<nb_size; ++
k) {
253 neighbours[j][
k] = allCells[allCells[
i].neighbours_ind[j][
k]].index;
254 }
255 }
256
261
262
263
264
265 int sd = tileID->
side(allCells[i].
id);
266 int tw = tileID->
tower(allCells[i].
id);
267 int sm = tileID->
sample(allCells[i].
id);
268 int se = tileID->
section(allCells[i].
id);
269
270 for (unsigned int j=2; j<4; ++j) {
271
272
273 unsigned int nb_size=allCells[
i].neighbours[j].size();
274 for (
unsigned int k=0;
k<nb_size; ++
k) {
275 unsigned int new_i = allCells[
i].neighbours_ind[j][
k];
276 for (unsigned int new_j=0; new_j<2; ++new_j) {
277 unsigned int new_nb_size=allCells[new_i].neighbours[new_j].size();
278 for (unsigned int new_k=0; new_k<new_nb_size; ++new_k) {
279 unsigned int new_nb_i = allCells[new_i].neighbours_ind[new_j][new_k];
280 short new_nb_index = allCells[new_nb_i].index;
281 int n=neighbours[j].size()-1;
283 if (neighbours[j][n] == new_nb_index)
284 break;
285 }
286 if (n<0) {
287 int new_sd = tileID->
side(allCells[new_nb_i].
id);
288 int new_tw = tileID->
tower(allCells[new_nb_i].
id);
289 int new_sm = tileID->
sample(allCells[new_nb_i].
id);
290 int new_se = tileID->
section(allCells[new_nb_i].
id);
291 if ( ( new_sd != sd && new_tw == tw ) ||
292 ( new_sd == sd && (
293 ( new_se == se && abs(new_tw - tw) < 3 ) ||
294 ( new_se != se && (
295 ( new_sm == sm+1 && abs(new_tw - tw) < 3 ) ||
296 ( new_sm != sm+1 && abs(new_tw - tw) < 4 ) ))))) {
297 neighbours[j].push_back(new_nb_index);
298 }
299 }
300 }
301 }
302 }
303 }
304
307 }
308
310
312 std::vector<IdentifierHash> nb_list;
313
315 for (
unsigned int i=0;
i<hash_max; ++
i) {
316
318 tileID->
get_id (i,
id, &context);
319 if ( tileID->module(id) != 0 ) continue;
320
321 IdentifierHash hash_id=
i;
322 nb_list.clear(); nb_list.push_back(hash_id);
323 print_list(nb_list, tileID, &context, log,
"\nCell ",
" : ");
324
326 print_list(nb_list, tileID, &context, log,
"Prev phi ",
" ; ");
327
329 print_list(nb_list, tileID, &context, log,
"Next phi ",
" ; ");
330
332 print_list(nb_list, tileID, &context, log,
"Prev eta ",
" ; ");
333
335 print_list(nb_list, tileID, &context, log,
"Next eta ",
" ; ");
336
338 print_list(nb_list, tileID, &context, log,
"Prev smp ",
" ; ");
339
341 print_list(nb_list, tileID, &context, log,
"Next smp ",
" ; ");
342
344 print_list(nb_list, tileID, &context, log,
"Face 2D ",
" ; ");
345
347 print_list(nb_list, tileID, &context, log,
"Corn 2D ",
" ; ");
348
350 print_list(nb_list, tileID, &context, log,
"All 2D ",
" ; ");
351
353 print_list(nb_list, tileID, &context, log,
"All 3D ",
" ; ");
354
356 print_list(nb_list, tileID, &context, log,
"All 3DC ",
" ; ");
357
359 print_list(nb_list, tileID, &context, log,
"Super 3D ",
" ; ");
360
361 }
362 }
363
364 return (0);
365}
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
IdentifierHash hash(Identifier id) const
Look up the hash code corresponding to an Identifier.
const HashGroup & channels() const
Return the HashGroup for channels (cells).
size_type cardinality() const
Computes a possible cardinality from all ranges.
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
int initialize_next_eta(unsigned int ind, const std::vector< short int > &all_cells)
std::vector< std::vector< short int > > m_next_samp_wide
std::vector< std::vector< short int > > m_prev_samp
int fill_phi_vec(std::set< std::pair< IdentifierHash, int > > &ids, unsigned int hash_max, unsigned int max_phi, MsgStream &log)
static void print_list(std::vector< IdentifierHash > &nb_list, const Tile_Base_ID *tileID, const IdContext *context, MsgStream &log, const char *pref, const char *suff)
std::vector< std::vector< short int > > m_prev_samp_wide
std::vector< std::vector< short int > > m_next_samp
int initialize_prev_eta(unsigned int ind, const std::vector< short int > &all_cells)
int initialize_next_samp(unsigned int ind, const std::vector< short int > &all_cells)
int initialize_next_samp_wide(unsigned int ind, const std::vector< short int > &all_cells)
static void get_id(std::string &strName, Identifier &id, const Tile_Base_ID *tileID)
int initialize_prev_samp_wide(unsigned int ind, const std::vector< short int > &all_cells)
int initialize_prev_samp(unsigned int ind, const std::vector< short int > &all_cells)
std::vector< std::vector< short int > > m_next_eta
std::vector< std::vector< short int > > m_prev_eta
int get_neighbours(const IdentifierHash &id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = prevInPhi,...
size_type cell_hash_max() const
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const
create compact id from hash id (return == 0 for OK)
IdContext cell_context() const
id for cells
size_type m_SECTION_INDEX
MultiRange m_full_cell_range
IMessageSvc * getMessageSvc(bool quiet=false)
logLevel
If HLT PSK is set on command line read it from DB instead of COOL (ATR-25974)