Skip to content

Commit

Permalink
Clean whitespaces, defines and include directives
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Aug 14, 2018
1 parent 33ff927 commit 8f180ac
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def customizePixelTracksForProfiling(process):
),
verbosity = cms.untracked.uint32(0),
)

process.outPath = cms.EndPath(process.out)

process.schedule = cms.Schedule(process.raw2digi_step, process.reconstruction_step, process.outPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
/** Computes the curvature (1/radius) and, if possible, the center
* of the circle passing through three points.
* The input points are three dimensional for convenience, but the
* calculation is done in the transverse (x,y) plane.
* calculation is done in the transverse (x,y) plane.
* No verification of the reasonableness of the z coordinate is done.
* If the three points lie on a line the curvature is zero and the center
* position is undefined. The 3 points are assumed to make sense:
* if the distance between two of them is very small compared to
* if the distance between two of them is very small compared to
* the ditance to the third the result will be numerically unstable.
*/
*/

class CircleFromThreePoints {
public:
Expand All @@ -26,19 +26,19 @@ class CircleFromThreePoints {
/** Construct from three points (see class description).
* The order of points is not essential, but accuracy should be better if
* the second point lies between the other two on the circle.
* The optional argument "precision" specifies how accurately the
* The optional argument "precision" specifies how accurately the
* straight line check has to be satisfied for setting the curvature
* to zero and the center position to "undefined".
* to zero and the center position to "undefined".
*/
CircleFromThreePoints( const GlobalPoint& inner,
CircleFromThreePoints( const GlobalPoint& inner,
const GlobalPoint& mid,
const GlobalPoint& outer,
double precision = 1.e-7);


/** Returns the curvature (1/radius), in cm^(-1).
* The curvature is precomputed, this is just access method (takes no time).
* If curvature is zero the center is undefined
* If curvature is zero the center is undefined
* (see description of presicion above).
*/
float curvature() const { return theCurvature;}
Expand All @@ -49,14 +49,14 @@ class CircleFromThreePoints {
* If the curvature is very small the position of the center will
* be very inaccurate.
*/
Vector2D center() const { return theCenter; }
Vector2D center() const { return theCenter; }

private:

float theCurvature;
Vector2D theCenter;

void init( const Vector2D& b, const Vector2D& c,
void init( const Vector2D& b, const Vector2D& c,
const Vector2D& offset, double precision);
};

Expand Down
23 changes: 11 additions & 12 deletions RecoPixelVertexing/PixelTriplets/plugins/RecHitsMap.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef RecHitsMap_H
#define RecHitsMap_H
// store T for each cluster...
//FIXME move it to a better place...

#ifndef RecoPixelVertexing_PixelTriplets_plugins_RecHitsMap_h
#define RecoPixelVertexing_PixelTriplets_plugins_RecHitsMap_h


#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include <cstdint>
#include <unordered_map>

#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"


//FIXME move it to a better place...
// store T for each cluster
template<typename T>
class RecHitsMap {
public:

public:
explicit RecHitsMap(T const & d=T()) : dummy(d){}

void clear() {m_map.clear();}
Expand All @@ -26,7 +26,7 @@ class RecHitsMap {
auto const & thit = static_cast<BaseTrackerRecHit const&>(hit);
auto const & clus = thit.firstClusterRef();

if (clus.isPixel())
if (clus.isPixel())
add(clus.pixelCluster(), *thit.detUnit(),v);
else
add(clus.stripCluster(), *thit.detUnit(),v);
Expand All @@ -51,7 +51,7 @@ class RecHitsMap {
}

static uint64_t encode(uint32_t ind, uint16_t mr, uint16_t mc) {
uint64_t u1 = ind;
uint64_t u1 = ind;
uint64_t u2 = mr;
uint64_t u3 = mc;
return (u1<<32) | (u2<<16) | u3;
Expand All @@ -69,9 +69,8 @@ class RecHitsMap {
return (u1<<32) | u2;
}


std::unordered_map<uint64_t, T > m_map;
T dummy;
};

#endif
#endif // RecoPixelVertexing_PixelTriplets_plugins_RecHitsMap_h
129 changes: 53 additions & 76 deletions RecoPixelVertexing/PixelTriplets/src/CellularAutomaton.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
#include "CellularAutomaton.h"

void CellularAutomaton::createAndConnectCells(
const std::vector<const HitDoublets *> &hitDoublets,
const TrackingRegion &region, const float thetaCut, const float phiCut,
const float hardPtCut) {
const std::vector<const HitDoublets *> & hitDoublets,
const TrackingRegion & region,
const float thetaCut,
const float phiCut,
const float hardPtCut)
{
int tsize = 0;
for (auto hd : hitDoublets)
for (auto hd : hitDoublets) {
tsize += hd->size();
}
allCells.reserve(tsize);
unsigned int cellId = 0;
float ptmin = region.ptMin();
Expand All @@ -22,34 +26,26 @@ void CellularAutomaton::createAndConnectCells(
visited = false;
}
for (int rootVertex : theLayerGraph.theRootLayers) {

std::queue<int> LayerPairsToVisit;

for (int LayerPair :
theLayerGraph.theLayers[rootVertex].theOuterLayerPairs) {
for (int LayerPair : theLayerGraph.theLayers[rootVertex].theOuterLayerPairs) {
LayerPairsToVisit.push(LayerPair);
}

unsigned int numberOfLayerPairsToVisitAtThisDepth =
LayerPairsToVisit.size();
unsigned int numberOfLayerPairsToVisitAtThisDepth = LayerPairsToVisit.size();

while (!LayerPairsToVisit.empty()) {
while (not LayerPairsToVisit.empty()) {
auto currentLayerPair = LayerPairsToVisit.front();
auto &currentLayerPairRef = theLayerGraph.theLayerPairs[currentLayerPair];
auto &currentInnerLayerRef =
theLayerGraph.theLayers[currentLayerPairRef.theLayers[0]];
auto &currentOuterLayerRef =
theLayerGraph.theLayers[currentLayerPairRef.theLayers[1]];
auto & currentLayerPairRef = theLayerGraph.theLayerPairs[currentLayerPair];
auto & currentInnerLayerRef = theLayerGraph.theLayers[currentLayerPairRef.theLayers[0]];
auto & currentOuterLayerRef = theLayerGraph.theLayers[currentLayerPairRef.theLayers[1]];
bool allInnerLayerPairsAlreadyVisited{true};

for (auto innerLayerPair : currentInnerLayerRef.theInnerLayerPairs) {
allInnerLayerPairsAlreadyVisited &=
alreadyVisitedLayerPairs[innerLayerPair];
allInnerLayerPairsAlreadyVisited &= alreadyVisitedLayerPairs[innerLayerPair];
}

if (alreadyVisitedLayerPairs[currentLayerPair] == false &&
allInnerLayerPairsAlreadyVisited) {

if (alreadyVisitedLayerPairs[currentLayerPair] == false and allInnerLayerPairsAlreadyVisited) {
const HitDoublets *doubletLayerPairId = hitDoublets[currentLayerPair];
auto numberOfDoublets = doubletLayerPairId->size();
currentLayerPairRef.theFoundCells[0] = cellId;
Expand All @@ -59,15 +55,11 @@ void CellularAutomaton::createAndConnectCells(
doubletLayerPairId->innerHitId(i),
doubletLayerPairId->outerHitId(i));

currentOuterLayerRef
.isOuterHitOfCell[doubletLayerPairId->outerHitId(i)]
.push_back(cellId);
currentOuterLayerRef.isOuterHitOfCell[doubletLayerPairId->outerHitId(i)].push_back(cellId);

cellId++;

auto &neigCells =
currentInnerLayerRef
.isOuterHitOfCell[doubletLayerPairId->innerHitId(i)];
auto & neigCells = currentInnerLayerRef.isOuterHitOfCell[doubletLayerPairId->innerHitId(i)];
allCells.back().checkAlignmentAndTag(
allCells, neigCells, ptmin, region_origin_x, region_origin_y,
region_origin_radius, thetaCut, phiCut, hardPtCut);
Expand All @@ -88,23 +80,21 @@ void CellularAutomaton::createAndConnectCells(
}
}

void CellularAutomaton::evolve(const unsigned int minHitsPerNtuplet) {
void CellularAutomaton::evolve(const unsigned int minHitsPerNtuplet)
{
allStatus.resize(allCells.size());

unsigned int numberOfIterations = minHitsPerNtuplet - 2;
// keeping the last iteration for later
for (unsigned int iteration = 0; iteration < numberOfIterations - 1;
++iteration) {
for (auto &layerPair : theLayerGraph.theLayerPairs) {
for (auto i = layerPair.theFoundCells[0]; i < layerPair.theFoundCells[1];
++i) {
for (unsigned int iteration = 0; iteration < numberOfIterations - 1; ++iteration) {
for (auto & layerPair : theLayerGraph.theLayerPairs) {
for (auto i = layerPair.theFoundCells[0]; i < layerPair.theFoundCells[1]; ++i) {
allCells[i].evolve(i, allStatus);
}
}

for (auto &layerPair : theLayerGraph.theLayerPairs) {
for (auto i = layerPair.theFoundCells[0]; i < layerPair.theFoundCells[1];
++i) {
for (auto & layerPair : theLayerGraph.theLayerPairs) {
for (auto i = layerPair.theFoundCells[0]; i < layerPair.theFoundCells[1]; ++i) {
allStatus[i].updateState();
}
}
Expand All @@ -113,12 +103,10 @@ void CellularAutomaton::evolve(const unsigned int minHitsPerNtuplet) {
// last iteration

for (int rootLayerId : theLayerGraph.theRootLayers) {
for (int rootLayerPair :
theLayerGraph.theLayers[rootLayerId].theOuterLayerPairs) {
auto foundCells =
theLayerGraph.theLayerPairs[rootLayerPair].theFoundCells;
for (int rootLayerPair : theLayerGraph.theLayers[rootLayerId].theOuterLayerPairs) {
auto foundCells = theLayerGraph.theLayerPairs[rootLayerPair].theFoundCells;
for (auto i = foundCells[0]; i < foundCells[1]; ++i) {
auto &cell = allStatus[i];
auto & cell = allStatus[i];
allCells[i].evolve(i, allStatus);
cell.updateState();
if (cell.isRootCell(minHitsPerNtuplet - 2)) {
Expand All @@ -129,27 +117,30 @@ void CellularAutomaton::evolve(const unsigned int minHitsPerNtuplet) {
}
}

void CellularAutomaton::findNtuplets(
std::vector<CACell::CAntuplet> &foundNtuplets,
const unsigned int minHitsPerNtuplet) {
void CellularAutomaton::findNtuplets(std::vector<CACell::CAntuplet> & foundNtuplets, const unsigned int minHitsPerNtuplet)
{
CACell::CAntuple tmpNtuplet;
tmpNtuplet.reserve(minHitsPerNtuplet);

for (auto root_cell : theRootCells) {
for (auto root_cell : theRootCells)
{
tmpNtuplet.clear();
tmpNtuplet.push_back(root_cell);
allCells[root_cell].findNtuplets(allCells, foundNtuplets, tmpNtuplet,
minHitsPerNtuplet);
allCells[root_cell].findNtuplets(allCells, foundNtuplets, tmpNtuplet, minHitsPerNtuplet);
}
}

void CellularAutomaton::findTriplets(
const std::vector<const HitDoublets *> &hitDoublets,
std::vector<CACell::CAntuplet> &foundTriplets, const TrackingRegion &region,
const float thetaCut, const float phiCut, const float hardPtCut) {
std::vector<const HitDoublets *> const& hitDoublets,
std::vector<CACell::CAntuplet> & foundTriplets, TrackingRegion const& region,
const float thetaCut,
const float phiCut,
const float hardPtCut)
{
int tsize = 0;
for (auto hd : hitDoublets)
for (auto hd : hitDoublets) {
tsize += hd->size();
}
allCells.reserve(tsize);

unsigned int cellId = 0;
Expand All @@ -164,34 +155,26 @@ void CellularAutomaton::findTriplets(
visited = false;
}
for (int rootVertex : theLayerGraph.theRootLayers) {

std::queue<int> LayerPairsToVisit;

for (int LayerPair :
theLayerGraph.theLayers[rootVertex].theOuterLayerPairs) {
for (int LayerPair : theLayerGraph.theLayers[rootVertex].theOuterLayerPairs) {
LayerPairsToVisit.push(LayerPair);
}

unsigned int numberOfLayerPairsToVisitAtThisDepth =
LayerPairsToVisit.size();
unsigned int numberOfLayerPairsToVisitAtThisDepth = LayerPairsToVisit.size();

while (!LayerPairsToVisit.empty()) {
while (not LayerPairsToVisit.empty()) {
auto currentLayerPair = LayerPairsToVisit.front();
auto &currentLayerPairRef = theLayerGraph.theLayerPairs[currentLayerPair];
auto &currentInnerLayerRef =
theLayerGraph.theLayers[currentLayerPairRef.theLayers[0]];
auto &currentOuterLayerRef =
theLayerGraph.theLayers[currentLayerPairRef.theLayers[1]];
auto & currentLayerPairRef = theLayerGraph.theLayerPairs[currentLayerPair];
auto & currentInnerLayerRef = theLayerGraph.theLayers[currentLayerPairRef.theLayers[0]];
auto & currentOuterLayerRef = theLayerGraph.theLayers[currentLayerPairRef.theLayers[1]];
bool allInnerLayerPairsAlreadyVisited{true};

for (auto innerLayerPair : currentInnerLayerRef.theInnerLayerPairs) {
allInnerLayerPairsAlreadyVisited &=
alreadyVisitedLayerPairs[innerLayerPair];
allInnerLayerPairsAlreadyVisited &= alreadyVisitedLayerPairs[innerLayerPair];
}

if (alreadyVisitedLayerPairs[currentLayerPair] == false &&
allInnerLayerPairsAlreadyVisited) {

if (alreadyVisitedLayerPairs[currentLayerPair] == false and allInnerLayerPairsAlreadyVisited) {
const HitDoublets *doubletLayerPairId = hitDoublets[currentLayerPair];
auto numberOfDoublets = doubletLayerPairId->size();
currentLayerPairRef.theFoundCells[0] = cellId;
Expand All @@ -201,22 +184,16 @@ void CellularAutomaton::findTriplets(
doubletLayerPairId->innerHitId(i),
doubletLayerPairId->outerHitId(i));

currentOuterLayerRef
.isOuterHitOfCell[doubletLayerPairId->outerHitId(i)]
.push_back(cellId);
currentOuterLayerRef.isOuterHitOfCell[doubletLayerPairId->outerHitId(i)].push_back(cellId);

cellId++;

auto &neigCells =
currentInnerLayerRef
.isOuterHitOfCell[doubletLayerPairId->innerHitId(i)];
auto & neigCells = currentInnerLayerRef.isOuterHitOfCell[doubletLayerPairId->innerHitId(i)];
allCells.back().checkAlignmentAndPushTriplet(
allCells, neigCells, foundTriplets, ptmin, region_origin_x,
region_origin_y, region_origin_radius, thetaCut, phiCut,
hardPtCut);
allCells, neigCells, foundTriplets, ptmin, region_origin_x, region_origin_y,
region_origin_radius, thetaCut, phiCut, hardPtCut);
}
assert(cellId == currentLayerPairRef.theFoundCells[1]);

for (auto outerLayerPair : currentOuterLayerRef.theOuterLayerPairs) {
LayerPairsToVisit.push(outerLayerPair);
}
Expand Down

0 comments on commit 8f180ac

Please sign in to comment.