Skip to content

Commit d7f2719

Browse files
committed
Merge pull request #23 from pinkenburg/master
cleanup of g4hough code, straight forward clean up of my mess, nothing deep touched
2 parents c4a956a + d08ada2 commit d7f2719

17 files changed

Lines changed: 134 additions & 319 deletions

simulation/g4simulation/g4hough/PHG4HoughTransform.C

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121

2222
// PHENIX includes
2323
#include <fun4all/Fun4AllReturnCodes.h>
24-
#include <phool/PHNodeIterator.h>
25-
#include <phool/PHTypedNodeIterator.h>
2624
#include <phool/PHCompositeNode.h>
2725
#include <phool/PHIODataNode.h>
26+
#include <phool/PHNodeIterator.h>
2827
#include <fun4all/getClass.h>
2928

3029
// Geant4 includes
@@ -41,13 +40,11 @@
4140
#include <VertexFinder.h>
4241

4342
// ROOT includes
44-
#include <TVector3.h>
4543
#include <TH1D.h>
4644

4745
// standard includes
4846
#include <cmath>
4947
#include <iostream>
50-
#include <float.h>
5148

5249
using findNode::getClass;
5350
using namespace std;

simulation/g4simulation/g4hough/PHG4SvtxAddConnectedCells.C

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "PHG4SvtxAddConnectedCells.h"
22
#include <fun4all/Fun4AllReturnCodes.h>
3-
#include <phool/PHNodeIterator.h>
4-
#include <phool/PHTypedNodeIterator.h>
53
#include <phool/PHCompositeNode.h>
64
#include <phool/PHIODataNode.h>
75
#include <fun4all/getClass.h>
@@ -39,21 +37,16 @@ bool PHG4SvtxAddConnectedCells::lessthan(const PHG4CylinderCell* lhs,
3937
return false;
4038
}
4139

42-
PHG4SvtxAddConnectedCells::PHG4SvtxAddConnectedCells(const char* name) :
40+
PHG4SvtxAddConnectedCells::PHG4SvtxAddConnectedCells(const string &name) :
4341
SubsysReco(name),
42+
connected_phi_offset(128), // offset in phi bins for connected cells
4443
_cells(NULL),
4544
_geom_container(NULL),
4645
_timer(PHTimeServer::get()->insert_new(name)) {
4746

48-
for(int i=0;i<20;i++)
49-
ncells_connected[i] = 0;
47+
memset(ncells_connected,0,sizeof(ncells_connected));
5048

5149
// Default values. Override using the setters if desired
52-
connected_phi_offset = 128; // offset in phi bins for connected cells
53-
ncells_connected[0] = 0;
54-
ncells_connected[1] = 0;
55-
ncells_connected[2] = 0;
56-
ncells_connected[3] = 0;
5750
ncells_connected[4] = 2;
5851
ncells_connected[5] = 2;
5952
ncells_connected[6] = 5;
@@ -67,29 +60,15 @@ PHG4SvtxAddConnectedCells::PHG4SvtxAddConnectedCells(const char* name) :
6760

6861
int PHG4SvtxAddConnectedCells::InitRun(PHCompositeNode* topNode) {
6962

70-
PHNodeIterator iter(topNode);
71-
72-
// Looking for the DST node
73-
PHCompositeNode *dstNode
74-
= static_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode","DST"));
75-
if (!dstNode) {
76-
cout << PHWHERE << "DST Node missing, doing nothing." << endl;
77-
return Fun4AllReturnCodes::ABORTRUN;
78-
}
79-
8063
// get the SVX geometry object
81-
_geom_container = 0;
82-
PHTypedNodeIterator<PHG4CylinderCellGeomContainer> geomiter(topNode);
83-
PHIODataNode<PHG4CylinderCellGeomContainer>* PHG4CylinderCellGeomContainerNode = geomiter.find("CYLINDERCELLGEOM_SVTX");
84-
if(!PHG4CylinderCellGeomContainerNode) {
85-
cout << PHWHERE
86-
<< " ERROR: Can't find PHG4CylinderCellGeomContainerNode."
87-
<< endl;
88-
return Fun4AllReturnCodes::ABORTRUN;
89-
} else {
90-
_geom_container = (PHG4CylinderCellGeomContainer*) PHG4CylinderCellGeomContainerNode->getData();
91-
}
92-
64+
_geom_container = findNode::getClass<PHG4CylinderCellGeomContainer>(topNode,"CYLINDERCELLGEOM_SVTX");
65+
if (!_geom_container)
66+
{
67+
cout << PHWHERE
68+
<< " ERROR: Can't find PHG4CylinderCellGeomContainerNode."
69+
<< endl;
70+
return Fun4AllReturnCodes::ABORTRUN;
71+
}
9372

9473
return Fun4AllReturnCodes::EVENT_OK;
9574
}
@@ -102,14 +81,10 @@ int PHG4SvtxAddConnectedCells::process_event(PHCompositeNode *topNode) {
10281
// Get Nodes
10382
//----------
10483

105-
_cells = 0;
106-
PHTypedNodeIterator<PHG4CylinderCellContainer> celliter(topNode);
107-
PHIODataNode<PHG4CylinderCellContainer>* cell_container_node = celliter.find("G4CELL_SVTX");
108-
if (!cell_container_node) {
84+
_cells = findNode::getClass<PHG4CylinderCellContainer>(topNode,"G4CELL_SVTX");
85+
if (!_cells) {
10986
cout << PHWHERE << " ERROR: Can't find G4CELL_SVTX." << endl;
11087
return Fun4AllReturnCodes::ABORTRUN;
111-
} else {
112-
_cells = (PHG4CylinderCellContainer*) cell_container_node->getData();
11388
}
11489

11590
// Since the G4 layers don't necessarily correspond to the silicon

simulation/g4simulation/g4hough/PHG4SvtxAddConnectedCells.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class PHG4SvtxAddConnectedCells : public SubsysReco {
1414

1515
public:
1616

17-
PHG4SvtxAddConnectedCells(const char * name = "PHG4SvtxAddConnectedCells");
18-
~PHG4SvtxAddConnectedCells(){}
17+
PHG4SvtxAddConnectedCells(const std::string &name = "PHG4SvtxAddConnectedCells");
18+
virtual ~PHG4SvtxAddConnectedCells(){}
1919

2020
//! module initialization
2121
int Init(PHCompositeNode *topNode){return 0;}
@@ -30,12 +30,12 @@ class PHG4SvtxAddConnectedCells : public SubsysReco {
3030
int End(PHCompositeNode *topNode){return 0;}
3131

3232

33-
void set_phi_offset(int offset) {
33+
void set_phi_offset(const int offset) {
3434
connected_phi_offset = offset;
3535
std::cout << " PHG4SvtxAddConnectedCells: phi bins offset for connected cells set to " << connected_phi_offset << std::endl;
3636
}
3737

38-
void set_ncells_connected(int layer, int connected) {
38+
void set_ncells_connected(const int layer, const int connected) {
3939
if(layer < 19)
4040
{
4141
ncells_connected[layer] = connected;

simulation/g4simulation/g4hough/PHG4SvtxBeamSpotReco.C

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#include "PHG4SvtxBeamSpotReco.h"
2-
2+
#include "SvtxBeamSpot.h"
33
#include "SvtxVertexMap.h"
44
#include "SvtxVertex.h"
55

66
#include <fun4all/Fun4AllReturnCodes.h>
7-
#include <phool/PHNodeIterator.h>
8-
#include <phool/PHTypedNodeIterator.h>
97
#include <phool/PHCompositeNode.h>
108
#include <phool/PHIODataNode.h>
9+
#include <phool/PHNodeIterator.h>
1110
#include <fun4all/getClass.h>
1211
#include <fun4all/recoConsts.h>
1312

@@ -17,13 +16,12 @@
1716

1817
using namespace std;
1918

20-
PHG4SvtxBeamSpotReco::PHG4SvtxBeamSpotReco(const char* name) :
19+
PHG4SvtxBeamSpotReco::PHG4SvtxBeamSpotReco(const string &name) :
2120
SubsysReco(name),
2221
_pca(2),
2322
_vertexes(NULL),
2423
_beamspot(NULL),
2524
_timer(PHTimeServer::get()->insert_new(name)) {
26-
verbosity = 0;
2725
}
2826

2927
int PHG4SvtxBeamSpotReco::InitRun(PHCompositeNode* topNode) {
@@ -35,7 +33,7 @@ int PHG4SvtxBeamSpotReco::InitRun(PHCompositeNode* topNode) {
3533
PHNodeIterator iter(topNode);
3634

3735
PHCompositeNode *parNode
38-
= static_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode","PAR"));
36+
= dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode","PAR"));
3937
if (!parNode) {
4038
cout << PHWHERE << "PAR Node missing, doing nothing." << endl;
4139
return Fun4AllReturnCodes::ABORTRUN;

simulation/g4simulation/g4hough/PHG4SvtxBeamSpotReco.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#ifndef __PHG4SVTXBEAMSPOTRECO__
22
#define __PHG4SVTXBEAMSPOTRECO__
33

4-
#include "SvtxVertexMap.h"
5-
#include "SvtxBeamSpot.h"
64

75
#include <fun4all/SubsysReco.h>
86
#include <phool/PHTimeServer.h>
97

108
#include <TPrincipal.h>
119

10+
class SvtxBeamSpot;
11+
class SvtxVertexMap;
12+
1213
class PHG4SvtxBeamSpotReco : public SubsysReco {
1314

1415
public:
1516

16-
PHG4SvtxBeamSpotReco(const char * name = "PHG4SvtxBeamSpotReco");
17+
PHG4SvtxBeamSpotReco(const std::string &name = "PHG4SvtxBeamSpotReco");
1718
virtual ~PHG4SvtxBeamSpotReco(){}
1819

1920
//! module initialization

simulation/g4simulation/g4hough/PHG4SvtxClusterizer.C

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
#include <g4main/PHG4Hit.h>
99
#include <g4main/PHG4HitContainer.h>
1010
#include <fun4all/Fun4AllReturnCodes.h>
11-
#include <phool/PHNodeIterator.h>
12-
#include <phool/PHTypedNodeIterator.h>
1311
#include <phool/PHCompositeNode.h>
1412
#include <phool/PHIODataNode.h>
13+
#include <phool/PHNodeIterator.h>
1514
#include <fun4all/getClass.h>
1615
#include <g4detectors/PHG4CylinderCellContainer.h>
1716
#include <g4detectors/PHG4CylinderCellGeomContainer.h>
@@ -123,14 +122,11 @@ bool PHG4SvtxClusterizer::ladder_are_adjacent(const PHG4CylinderCell* lhs,
123122
return false;
124123
}
125124

126-
PHG4SvtxClusterizer::PHG4SvtxClusterizer(const char* name) :
125+
PHG4SvtxClusterizer::PHG4SvtxClusterizer(const string &name) :
127126
SubsysReco(name),
128127
_hits(NULL),
129128
_clusterlist(NULL),
130129
_fraction_of_mip(0.5),
131-
_thresholds_by_layer(),
132-
_make_z_clustering(),
133-
_make_e_weights(),
134130
_timer(PHTimeServer::get()->insert_new(name)) {
135131
}
136132

@@ -151,7 +147,7 @@ int PHG4SvtxClusterizer::InitRun(PHCompositeNode* topNode) {
151147

152148
// Looking for the DST node
153149
PHCompositeNode *dstNode
154-
= static_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode","DST"));
150+
= dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode","DST"));
155151
if (!dstNode) {
156152
cout << PHWHERE << "DST Node missing, doing nothing." << endl;
157153
return Fun4AllReturnCodes::ABORTRUN;
@@ -215,16 +211,12 @@ int PHG4SvtxClusterizer::process_event(PHCompositeNode *topNode) {
215211

216212
_timer.get()->restart();
217213

218-
_clusterlist = 0;
219-
PHTypedNodeIterator<SvtxClusterMap> clusteriter(topNode);
220-
PHIODataNode<SvtxClusterMap> *SvtxClusterMapNode = clusteriter.find("SvtxClusterMap");
221-
if (!SvtxClusterMapNode) {
222-
cout << PHWHERE << " ERROR: Can't find SvtxClusterMap." << endl;
223-
return Fun4AllReturnCodes::ABORTRUN;
224-
} else {
225-
_clusterlist = (SvtxClusterMap*)SvtxClusterMapNode->getData();
226-
}
227-
214+
_clusterlist = findNode::getClass<SvtxClusterMap>(topNode,"SvtxClusterMap");
215+
if (!_clusterlist)
216+
{
217+
cout << PHWHERE << " ERROR: Can't find SvtxClusterMap." << endl;
218+
return Fun4AllReturnCodes::ABORTRUN;
219+
}
228220
_clusterlist->Reset();
229221

230222
ClusterCylinderCells(topNode);
@@ -239,12 +231,7 @@ int PHG4SvtxClusterizer::process_event(PHCompositeNode *topNode) {
239231
void PHG4SvtxClusterizer::CalculateCylinderThresholds(PHCompositeNode *topNode) {
240232

241233
// get the SVX geometry object
242-
PHG4CylinderCellGeomContainer* geom_container = 0;
243-
PHTypedNodeIterator<PHG4CylinderCellGeomContainer> geomiter(topNode);
244-
PHIODataNode<PHG4CylinderCellGeomContainer>* PHG4CylinderCellGeomContainerNode = geomiter.find("CYLINDERCELLGEOM_SVTX");
245-
if(PHG4CylinderCellGeomContainerNode) {
246-
geom_container = (PHG4CylinderCellGeomContainer*) PHG4CylinderCellGeomContainerNode->getData();
247-
}
234+
PHG4CylinderCellGeomContainer* geom_container = findNode::getClass<PHG4CylinderCellGeomContainer>(topNode,"CYLINDERCELLGEOM_SVTX");
248235
if (!geom_container) return;
249236

250237
// determine cluster thresholds and layer index mapping
@@ -276,21 +263,10 @@ void PHG4SvtxClusterizer::CalculateCylinderThresholds(PHCompositeNode *topNode)
276263

277264
void PHG4SvtxClusterizer::CalculateLadderThresholds(PHCompositeNode *topNode) {
278265

279-
PHG4CylinderCellContainer *cells = NULL;
280-
PHG4CylinderGeomContainer *geom_container = NULL;
281-
282-
PHTypedNodeIterator<PHG4CylinderCellContainer> celliter(topNode);
283-
PHIODataNode<PHG4CylinderCellContainer>* cell_container_node = celliter.find("G4CELL_SILICON_TRACKER");
284-
if (cell_container_node) {
285-
cells = (PHG4CylinderCellContainer*) cell_container_node->getData();
286-
}
266+
PHG4CylinderCellContainer *cells = findNode::getClass<PHG4CylinderCellContainer>(topNode,"G4CELL_SILICON_TRACKER");
287267
if (!cells) return;
288-
289-
PHTypedNodeIterator<PHG4CylinderGeomContainer> geomiter(topNode);
290-
PHIODataNode<PHG4CylinderGeomContainer>* PHG4CylinderGeomContainerNode = geomiter.find("CYLINDERGEOM_SILICON_TRACKER");
291-
if (PHG4CylinderGeomContainerNode) {
292-
geom_container = (PHG4CylinderGeomContainer*) PHG4CylinderGeomContainerNode->getData();
293-
}
268+
269+
PHG4CylinderGeomContainer *geom_container = findNode::getClass<PHG4CylinderGeomContainer>(topNode,"CYLINDERGEOM_SILICON_TRACKER");
294270
if (!geom_container) return;
295271

296272
PHG4CylinderGeomContainer::ConstRange layerrange = geom_container->get_begin_end();
@@ -326,28 +302,13 @@ void PHG4SvtxClusterizer::ClusterCylinderCells(PHCompositeNode *topNode) {
326302
//----------
327303

328304
// get the SVX geometry object
329-
PHG4CylinderCellGeomContainer* geom_container = 0;
330-
PHTypedNodeIterator<PHG4CylinderCellGeomContainer> geomiter(topNode);
331-
PHIODataNode<PHG4CylinderCellGeomContainer>* PHG4CylinderCellGeomContainerNode = geomiter.find("CYLINDERCELLGEOM_SVTX");
332-
if(PHG4CylinderCellGeomContainerNode) {
333-
geom_container = (PHG4CylinderCellGeomContainer*) PHG4CylinderCellGeomContainerNode->getData();
334-
}
305+
PHG4CylinderCellGeomContainer* geom_container = findNode::getClass<PHG4CylinderCellGeomContainer>(topNode,"CYLINDERCELLGEOM_SVTX");
335306
if (!geom_container) return;
336307

337-
PHG4HitContainer* g4hits = 0;
338-
PHTypedNodeIterator<PHG4HitContainer> g4hititer(topNode);
339-
PHIODataNode<PHG4HitContainer> *PHG4HitContainerNode = g4hititer.find("G4HIT_SVTX");
340-
if (PHG4HitContainerNode) {
341-
g4hits = (PHG4HitContainer*)PHG4HitContainerNode->getData();
342-
}
308+
PHG4HitContainer* g4hits = findNode::getClass<PHG4HitContainer>(topNode,"G4HIT_SVTX");
343309
if (!g4hits) return;
344310

345-
PHG4CylinderCellContainer* cells = 0;
346-
PHTypedNodeIterator<PHG4CylinderCellContainer> celliter(topNode);
347-
PHIODataNode<PHG4CylinderCellContainer>* cell_container_node = celliter.find("G4CELL_SVTX");
348-
if (cell_container_node) {
349-
cells = (PHG4CylinderCellContainer*) cell_container_node->getData();
350-
}
311+
PHG4CylinderCellContainer* cells = findNode::getClass<PHG4CylinderCellContainer>(topNode,"G4CELL_SVTX");
351312
if (!cells) return;
352313

353314
//-----------
@@ -612,28 +573,13 @@ void PHG4SvtxClusterizer::ClusterLadderCells(PHCompositeNode *topNode) {
612573
//----------
613574

614575
// get the SVX geometry object
615-
PHG4CylinderGeomContainer* geom_container = 0;
616-
PHTypedNodeIterator<PHG4CylinderGeomContainer> geomiter(topNode);
617-
PHIODataNode<PHG4CylinderGeomContainer>* PHG4CylinderGeomContainerNode = geomiter.find("CYLINDERGEOM_SILICON_TRACKER");
618-
if(PHG4CylinderGeomContainerNode) {
619-
geom_container = (PHG4CylinderGeomContainer*) PHG4CylinderGeomContainerNode->getData();
620-
}
576+
PHG4CylinderGeomContainer* geom_container = findNode::getClass<PHG4CylinderGeomContainer>(topNode,"CYLINDERGEOM_SILICON_TRACKER");
621577
if (!geom_container) return;
622578

623-
PHG4HitContainer* g4hits = 0;
624-
PHTypedNodeIterator<PHG4HitContainer> g4hititer(topNode);
625-
PHIODataNode<PHG4HitContainer> *PHG4HitContainerNode = g4hititer.find("G4HIT_SILICON_TRACKER");
626-
if (PHG4HitContainerNode) {
627-
g4hits = (PHG4HitContainer*)PHG4HitContainerNode->getData();
628-
}
579+
PHG4HitContainer* g4hits = findNode::getClass<PHG4HitContainer>(topNode,"G4HIT_SILICON_TRACKER");
629580
if (!g4hits) return;
630581

631-
PHG4CylinderCellContainer* cells = 0;
632-
PHTypedNodeIterator<PHG4CylinderCellContainer> celliter(topNode);
633-
PHIODataNode<PHG4CylinderCellContainer>* cell_container_node = celliter.find("G4CELL_SILICON_TRACKER");
634-
if (cell_container_node) {
635-
cells = (PHG4CylinderCellContainer*) cell_container_node->getData();
636-
}
582+
PHG4CylinderCellContainer* cells = findNode::getClass<PHG4CylinderCellContainer>(topNode,"G4CELL_SILICON_TRACKER");
637583
if (!cells) return;
638584

639585
//-----------
@@ -921,13 +867,11 @@ void PHG4SvtxClusterizer::PrintClusters(PHCompositeNode *topNode) {
921867

922868
if (verbosity >= 1) {
923869

924-
PHTypedNodeIterator<SvtxClusterMap> clusteriter(topNode);
925-
PHIODataNode<SvtxClusterMap> *SvtxClusterMapNode = clusteriter.find("SvtxClusterMap");
926-
if (!SvtxClusterMapNode) return;
870+
SvtxClusterMap *clusterlist = findNode::getClass<SvtxClusterMap>(topNode,"SvtxClusterMap");
871+
if (!clusterlist) return;
927872

928873
cout << "================= PHG4SvtxClusterizer::process_event() ====================" << endl;
929874

930-
SvtxClusterMap *clusterlist = (SvtxClusterMap*)SvtxClusterMapNode->getData();
931875

932876
cout << " Found and recorded the following " << clusterlist->size() << " clusters: " << endl;
933877

0 commit comments

Comments
 (0)