Skip to content

Commit cb7d17d

Browse files
committed
CMergeManager and CBoolAlgBase constructors now sets defaults for algos --dc
1 parent f6b979e commit cb7d17d

7 files changed

Lines changed: 61 additions & 21 deletions

File tree

ClusterMerging/CMTAlgPriority/CPAlgoNHits_tool.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ namespace cmtool {
5454
{
5555
auto nhit = cluster.size();
5656

57+
std::cout << "\t\t size is " << cluster.size() << std::endl;
58+
5759
return ( nhit < _min_hits ? -1 : (float)nhit );
5860
}
5961

ClusterMerging/CMToolBase/CBoolAlgoBase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ namespace cmtool {
2727
class CBoolAlgoBase : public CMAlgoBase {
2828

2929
public:
30+
31+
CBoolAlgoBase(){_merge_till_converge = false; _pair_wise = true;}
3032

3133
/// Default destructor
32-
virtual ~CBoolAlgoBase(){};
34+
virtual ~CBoolAlgoBase() = default;
3335

3436
/**
3537
Core function: given the CPAN input, return whether a cluster should be

ClusterMerging/CMToolBase/CMAlgoBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace cmtool {
3636

3737
public:
3838

39-
virtual ~CMAlgoBase() noexcept = default;
39+
virtual ~CMAlgoBase() = default;
4040

4141
void configure(const fhicl::ParameterSet& pset){};
4242

ClusterMerging/CMToolBase/CMManagerBase.cxx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace cmtool {
99
{
1010
_fout = 0;
1111
_debug_mode = kNone;
12-
_priority_algo = nullptr;
12+
//_priority_algo = nullptr;
1313
_min_nhits = 1;
1414
_merge_till_converge = false;
1515
Reset();
@@ -154,28 +154,37 @@ namespace cmtool {
154154
_priority.clear();
155155
_planes.clear();
156156

157+
std::cout << "Computing priority algo with algo " << _priority_algo->Name()
158+
<< " for " << clusters.size() << " clusters"
159+
<< std::endl;
160+
157161
if(!clusters.size()) return;
158162

159163
// Priority is computed cluster-by-cluster. In case of two clusters having the same priority
160164
// value the one with lower cluster index gets the priority. Also, clusters with priority < 0
161165
// are not logged (assumed not to be used)
162166

163-
for(size_t i=0; i<clusters.size(); ++i) {
164-
165-
size_t c_index = clusters.size() - i - 1;
166-
float priority = clusters.at(c_index).size();
167-
168-
if(_priority_algo) {
169-
priority = _priority_algo->Priority(clusters.at(c_index));
170-
}
167+
for(size_t i=0; i<clusters.size(); ++i) {
168+
169+
size_t c_index = clusters.size() - i - 1;
170+
float priority = clusters.at(c_index).size();
171+
if (priority < 10) priority = -1;
172+
/*
173+
if(_priority_algo) {
174+
std::cout << "\t calculating priority. now it is " << priority << std::endl;
175+
priority = _priority_algo->Priority(clusters.at(c_index));
176+
}
177+
*/
171178

179+
std::cout << "\t\t priority for cluster " << i << " is " << priority << std::endl;
180+
172181
if(priority>0) {
173182
_priority.insert(std::make_pair(priority,c_index));
174-
183+
175184
if( _planes.find(clusters.at(c_index)._plane) == _planes.end() )
176-
185+
177186
_planes.insert(clusters.at(c_index)._plane);
178-
187+
179188
}
180189

181190
}

ClusterMerging/CMToolBase/CMergeManager.cxx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ namespace cmtool {
146146

147147
merge_switch.at(i) = false;
148148

149+
std::cout << "Computing priority over " << _tmp_merged_clusters.size() << " input clusters" << std::endl;
149150
ComputePriority(_tmp_merged_clusters);
151+
std::cout << "there are " << _priority.size() << " pairs" << std::endl;
150152

151153
// Run merging algorithm
152154
RunMerge(algo_idx,_tmp_merged_clusters, merge_switch, bk);
@@ -227,11 +229,19 @@ namespace cmtool {
227229

228230
}
229231

232+
std::cout << " \033[093m priority pairs : \033[00m " << _priority.size() << std::endl;
233+
230234
//
231235
// Merging
232236
//
237+
int niter = 0;
238+
int nloop1 = 0;
239+
int nloop2 = 0;
240+
int ndiffpl = 0;
241+
int nflag = 0;
242+
int nmerge = 0;
233243

234-
int niter = 0;
244+
std::cout << "pair-wise mode? " << _merge_algo_v[algo_idx]->PairWiseMode() << std::endl;
235245

236246
// which mode? pair-wise:
237247
if (_merge_algo_v[algo_idx]->PairWiseMode() == true) {
@@ -240,24 +250,34 @@ namespace cmtool {
240250
for(auto citer1 = _priority.rbegin();
241251
citer1 != _priority.rend();
242252
++citer1) {
243-
253+
254+
nloop1 += 1;
255+
244256
auto citer2 = citer1;
245257

246258
UChar_t plane1 = in_clusters.at((*citer1).second)._plane;
247259

248260
while(1) {
249261
citer2++;
250262
if(citer2 == _priority.rend()) break;
263+
264+
nloop2 += 1;
251265

252266
// Skip if not on the same plane
253267
UChar_t plane2 = in_clusters.at((*citer2).second)._plane;
254268
if(plane1 != plane2) continue;
269+
270+
ndiffpl += 1;
255271

256272
// Skip if this combination is not meant to be compared
257273
if(!(merge_flag.at((*citer2).second)) && !(merge_flag.at((*citer1).second)) ) continue;
274+
275+
nflag += 1;
258276

259277
// Skip if this combination is not allowed to merge
260278
if(!(book_keeper.MergeAllowed((*citer1).second,(*citer2).second))) continue;
279+
280+
nmerge += 1;
261281

262282
if(_debug_mode <= kPerMerging){
263283

@@ -292,9 +312,14 @@ namespace cmtool {
292312

293313
} // end looping over clusters
294314

295-
if (_debug_mode <= kPerIteration)
296-
std::cout << " \033[093m pair-wise comparisons : \033[00m " << niter << std::endl;
297-
315+
if (_debug_mode <= kPerIteration){
316+
std::cout << " \033[093m pair-wise comparisons : \033[00m " << niter << std::endl;
317+
std::cout << " \033[093m loop1 iterations : \033[00m " << nloop1 << std::endl;
318+
std::cout << " \033[093m loop2 iterations : \033[00m " << nloop2 << std::endl;
319+
std::cout << " \033[093m ndiffplane : \033[00m " << ndiffpl << std::endl;
320+
std::cout << " \033[093m nflag : \033[00m " << nflag << std::endl;
321+
std::cout << " \033[093m nmerge : \033[00m " << nmerge << std::endl;
322+
}
298323
}// if pair-wise mode
299324

300325

@@ -334,7 +359,7 @@ namespace cmtool {
334359

335360
}
336361

337-
void CMergeManager::ReportAlgoChain() {
362+
void CMergeManager::ReportAlgoChain() {
338363

339364
std::cout << "\t\t" << std::endl;
340365
std::cout << "\t\t *****************" << std::endl;

ClusterMerging/CMToolBase/CPriorityAlgoBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace cmtool {
2626
class CPriorityAlgoBase : public CMAlgoBase {
2727

2828
public:
29+
30+
CPriorityAlgoBase(){}
2931

3032
/// Default destructor
3133
virtual ~CPriorityAlgoBase(){};

ClusterMerging/ClusterMerger_module.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ ClusterMerger::ClusterMerger(fhicl::ParameterSet const & pset)
125125
std::cout << "DD \t done adding algo" << std::endl;
126126
}// for all algorithms to be added
127127

128-
_merge_helper->GetManager().ReportAlgoChain();
128+
_omerge_helper->GetManager().ReportAlgoChain();
129129

130130
produces<std::vector<recob::Cluster> >();
131131
produces<art::Assns <recob::Cluster, recob::Hit> >();

0 commit comments

Comments
 (0)