Skip to content

Commit 1d8ce7c

Browse files
committed
changing code format
1 parent 88c3990 commit 1d8ce7c

File tree

8 files changed

+208
-187
lines changed

8 files changed

+208
-187
lines changed

DataFormats/SiStripCluster/interface/SiStripApproximateClusterCollection_v1.h

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,95 +14,94 @@
1414
* Please consult core software group if in doubt.
1515
**/
1616
namespace v1 {
17-
class SiStripApproximateClusterCollection {
18-
public:
19-
// Helper classes to make creation and iteration easier
20-
class Filler {
17+
class SiStripApproximateClusterCollection {
2118
public:
22-
void push_back(SiStripApproximateCluster_v1 const& cluster) { clusters_.push_back(cluster); }
19+
// Helper classes to make creation and iteration easier
20+
class Filler {
21+
public:
22+
void push_back(SiStripApproximateCluster_v1 const& cluster) { clusters_.push_back(cluster); }
2323

24-
private:
25-
friend SiStripApproximateClusterCollection;
26-
Filler(std::vector<SiStripApproximateCluster_v1>& clusters) : clusters_(clusters) {}
24+
private:
25+
friend SiStripApproximateClusterCollection;
26+
Filler(std::vector<SiStripApproximateCluster_v1>& clusters) : clusters_(clusters) {}
2727

28-
std::vector<SiStripApproximateCluster_v1>& clusters_;
29-
};
28+
std::vector<SiStripApproximateCluster_v1>& clusters_;
29+
};
3030

31-
class const_iterator;
32-
class DetSet {
33-
public:
34-
using const_iterator = std::vector<SiStripApproximateCluster_v1>::const_iterator;
31+
class const_iterator;
32+
class DetSet {
33+
public:
34+
using const_iterator = std::vector<SiStripApproximateCluster_v1>::const_iterator;
3535

36-
unsigned int id() const { return std::accumulate(coll_->detIds_.cbegin(), coll_->detIds_.cbegin()+detIndex_+1, 0); }
36+
unsigned int id() const {
37+
return std::accumulate(coll_->detIds_.cbegin(), coll_->detIds_.cbegin() + detIndex_ + 1, 0);
38+
}
3739

38-
void move(unsigned int clusBegin) const { clusBegin_ = clusBegin; }
39-
const_iterator begin() const { return coll_->clusters_.begin() + clusBegin_; }
40-
const_iterator cbegin() const { return begin(); }
41-
const_iterator end() const { return coll_->clusters_.begin() + clusEnd_; }
42-
const_iterator cend() const { return end(); }
40+
void move(unsigned int clusBegin) const { clusBegin_ = clusBegin; }
41+
const_iterator begin() const { return coll_->clusters_.begin() + clusBegin_; }
42+
const_iterator cbegin() const { return begin(); }
43+
const_iterator end() const { return coll_->clusters_.begin() + clusEnd_; }
44+
const_iterator cend() const { return end(); }
45+
46+
private:
47+
friend SiStripApproximateClusterCollection::const_iterator;
48+
DetSet(SiStripApproximateClusterCollection const* coll, unsigned int detIndex)
49+
: coll_(coll), detIndex_(detIndex), clusEnd_(coll->clusters_.size()) {}
50+
51+
SiStripApproximateClusterCollection const* const coll_;
52+
unsigned int const detIndex_;
53+
mutable unsigned int clusBegin_ = 0;
54+
unsigned int const clusEnd_;
55+
};
56+
57+
class const_iterator {
58+
public:
59+
DetSet operator*() const { return DetSet(coll_, index_); }
60+
61+
const_iterator& operator++() {
62+
++index_;
63+
if (index_ == coll_->detIds_.size()) {
64+
*this = const_iterator();
65+
}
66+
return *this;
67+
}
4368

44-
private:
45-
friend SiStripApproximateClusterCollection::const_iterator;
46-
DetSet(SiStripApproximateClusterCollection const* coll, unsigned int detIndex)
47-
: coll_(coll),
48-
detIndex_(detIndex),
49-
clusEnd_(coll->clusters_.size())
50-
{}
51-
52-
SiStripApproximateClusterCollection const* const coll_;
53-
unsigned int const detIndex_;
54-
mutable unsigned int clusBegin_ = 0;
55-
unsigned int const clusEnd_;
56-
};
69+
const_iterator operator++(int) {
70+
const_iterator clone = *this;
71+
++(*this);
72+
return clone;
73+
}
5774

58-
class const_iterator {
59-
public:
60-
DetSet operator*() const { return DetSet(coll_, index_); }
75+
bool operator==(const_iterator const& other) const { return coll_ == other.coll_ and index_ == other.index_; }
76+
bool operator!=(const_iterator const& other) const { return not operator==(other); }
6177

62-
const_iterator& operator++() {
63-
++index_;
64-
if (index_ == coll_->detIds_.size()) {
65-
*this = const_iterator();
66-
}
67-
return *this;
68-
}
78+
private:
79+
friend SiStripApproximateClusterCollection;
80+
// default-constructed object acts as the sentinel
81+
const_iterator() = default;
82+
const_iterator(SiStripApproximateClusterCollection const* coll) : coll_(coll) {}
6983

70-
const_iterator operator++(int) {
71-
const_iterator clone = *this;
72-
++(*this);
73-
return clone;
74-
}
84+
SiStripApproximateClusterCollection const* coll_ = nullptr;
85+
unsigned int index_ = 0;
86+
};
7587

76-
bool operator==(const_iterator const& other) const { return coll_ == other.coll_ and index_ == other.index_; }
77-
bool operator!=(const_iterator const& other) const { return not operator==(other); }
88+
// Actual public interface
89+
SiStripApproximateClusterCollection() = default;
7890

79-
private:
80-
friend SiStripApproximateClusterCollection;
81-
// default-constructed object acts as the sentinel
82-
const_iterator() = default;
83-
const_iterator(SiStripApproximateClusterCollection const* coll) : coll_(coll) {}
91+
void reserve(std::size_t dets, std::size_t clusters);
92+
Filler beginDet(unsigned int detId);
8493

85-
SiStripApproximateClusterCollection const* coll_ = nullptr;
86-
unsigned int index_ = 0;
87-
};
94+
const_iterator begin() const { return clusters_.empty() ? end() : const_iterator(this); }
95+
const_iterator cbegin() const { return begin(); }
96+
const_iterator end() const { return const_iterator(); }
97+
const_iterator cend() const { return end(); }
8898

89-
// Actual public interface
90-
SiStripApproximateClusterCollection() = default;
91-
92-
void reserve(std::size_t dets, std::size_t clusters);
93-
Filler beginDet(unsigned int detId);
94-
95-
const_iterator begin() const { return clusters_.empty() ? end() : const_iterator(this); }
96-
const_iterator cbegin() const { return begin(); }
97-
const_iterator end() const { return const_iterator(); }
98-
const_iterator cend() const { return end(); }
99-
100-
private:
101-
// The detIds_ and beginIndices_ have one element for each Det. An
102-
// element of beginIndices_ points to the first cluster of the Det
103-
// in clusters_.
104-
std::vector<unsigned int> detIds_; // DetId for the Det
105-
std::vector<SiStripApproximateCluster_v1> clusters_;
106-
};
107-
}
99+
private:
100+
// The detIds_ and beginIndices_ have one element for each Det. An
101+
// element of beginIndices_ points to the first cluster of the Det
102+
// in clusters_.
103+
std::vector<unsigned int> detIds_; // DetId for the Det
104+
std::vector<SiStripApproximateCluster_v1> clusters_;
105+
};
106+
} // namespace v1
108107
#endif

DataFormats/SiStripCluster/interface/SiStripApproximateCluster_v1.h

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,51 @@ class SiStripApproximateCluster_v1 {
99
public:
1010
SiStripApproximateCluster_v1() {}
1111

12-
explicit SiStripApproximateCluster_v1(cms_uint16_t compBarycenter,
13-
cms_uint8_t width,
14-
cms_uint8_t compavgCharge
15-
)
16-
: compBarycenter_(compBarycenter),
17-
width_(width),
18-
compavgCharge_(compavgCharge)
19-
{}
12+
explicit SiStripApproximateCluster_v1(cms_uint16_t compBarycenter, cms_uint8_t width, cms_uint8_t compavgCharge)
13+
: compBarycenter_(compBarycenter), width_(width), compavgCharge_(compavgCharge) {}
2014

2115
explicit SiStripApproximateCluster_v1(const SiStripCluster& cluster,
22-
unsigned int maxNSat,
23-
float hitPredPos,
24-
float& previous_cluster,
25-
unsigned int& module_length,
26-
unsigned int& previous_module_length,
27-
bool peakFilter);
16+
unsigned int maxNSat,
17+
float hitPredPos,
18+
float& previous_cluster,
19+
unsigned int& module_length,
20+
unsigned int& previous_module_length,
21+
bool peakFilter);
2822

29-
const cms_uint16_t compBarycenter() const {
30-
return compBarycenter_;
31-
}
23+
const cms_uint16_t compBarycenter() const { return compBarycenter_; }
3224

33-
float barycenter(float previous_barycenter=0,
34-
unsigned int module_length=0, unsigned int previous_module_length=0) const {
25+
float barycenter(float previous_barycenter = 0,
26+
unsigned int module_length = 0,
27+
unsigned int previous_module_length = 0) const {
3528
float _barycenter;
36-
cms_uint16_t compBarycenter = (compBarycenter_&0x7FFF);
37-
if ( previous_barycenter == -999 )
38-
_barycenter = compBarycenter * maxBarycenter_/maxRange_;
29+
cms_uint16_t compBarycenter = (compBarycenter_ & 0x7FFF);
30+
if (previous_barycenter == -999)
31+
_barycenter = compBarycenter * maxBarycenter_ / maxRange_;
3932
else {
40-
_barycenter = ((compBarycenter * maxBarycenter_/maxRange_) - (module_length-previous_module_length)) + previous_barycenter;
33+
_barycenter = ((compBarycenter * maxBarycenter_ / maxRange_) - (module_length - previous_module_length)) +
34+
previous_barycenter;
4135
}
4236
assert(_barycenter <= maxBarycenter_ && "Returning barycenter > maxBarycenter");
43-
return _barycenter; }
44-
cms_uint8_t width() const {return width_; }
37+
return _barycenter;
38+
}
39+
cms_uint8_t width() const { return width_; }
4540
float avgCharge() const {
46-
cms_uint8_t compavgCharge = (compavgCharge_ & 0x3F);
47-
float avgCharge_ = compavgCharge * maxavgCharge_/maxavgChargeRange_ ;
41+
cms_uint8_t compavgCharge = (compavgCharge_ & 0x3F);
42+
float avgCharge_ = compavgCharge * maxavgCharge_ / maxavgChargeRange_;
4843
assert(avgCharge_ <= maxavgCharge_ && "Returning avgCharge > maxavgCharge");
49-
return avgCharge_; }
50-
bool filter() const { return (compavgCharge_& (1<<kfilterMask)); }
51-
bool isSaturated() const { return (compavgCharge_& (1<<kSaturatedMask)); }
52-
bool peakFilter() const { return (compBarycenter_ & (1<<kpeakFilterMask)); }
44+
return avgCharge_;
45+
}
46+
bool filter() const { return (compavgCharge_ & (1 << kfilterMask)); }
47+
bool isSaturated() const { return (compavgCharge_ & (1 << kSaturatedMask)); }
48+
bool peakFilter() const { return (compBarycenter_ & (1 << kpeakFilterMask)); }
5349

5450
private:
5551
cms_uint16_t compBarycenter_ = 0;
5652
cms_uint8_t width_ = 0;
5753
cms_uint8_t compavgCharge_ = 0;
58-
static constexpr double maxRange_ = 32767; //32767;
54+
static constexpr double maxRange_ = 32767;
5955
static constexpr double maxBarycenter_ = 1536.;
60-
static constexpr double maxavgChargeRange_ = 63; //63;
56+
static constexpr double maxavgChargeRange_ = 63;
6157
static constexpr double maxavgCharge_ = 255.;
6258
static constexpr double trimMaxADC_ = 30.;
6359
static constexpr double trimMaxFracTotal_ = .15;

DataFormats/SiStripCluster/interface/SiStripCluster.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ class SiStripCluster {
4646
}
4747

4848
SiStripCluster(const SiStripApproximateCluster cluster, const uint16_t maxStrips);
49-
SiStripCluster(const SiStripApproximateCluster_v1 cluster, const uint16_t maxStrips, float pc=-999, unsigned int module_length=0, unsigned int previous_module_length=0);
49+
SiStripCluster(const SiStripApproximateCluster_v1 cluster,
50+
const uint16_t maxStrips,
51+
float pc = -999,
52+
unsigned int module_length = 0,
53+
unsigned int previous_module_length = 0);
5054

5155
// extend the cluster
5256
template <typename Iter>

DataFormats/SiStripCluster/src/SiStripApproximateClusterCollection_v1.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ void SiStripApproximateClusterCollection::reserve(std::size_t dets, std::size_t
66
}
77

88
SiStripApproximateClusterCollection::Filler SiStripApproximateClusterCollection::beginDet(unsigned int detId) {
9-
detIds_.push_back((detIds_.size() == 0) ? detId : detId - (std::accumulate(detIds_.cbegin(), detIds_.cend(),0)));
9+
detIds_.push_back((detIds_.empty()) ? detId : detId - (std::accumulate(detIds_.cbegin(), detIds_.cend(), 0)));
1010
return Filler(clusters_);
1111
}

DataFormats/SiStripCluster/src/SiStripApproximateCluster_v1.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster_v1.h"
22
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
33
#include <algorithm>
4+
#include <cassert>
45
#include <cmath>
5-
#include <assert.h>
66

77
SiStripApproximateCluster_v1::SiStripApproximateCluster_v1(const SiStripCluster& cluster,
8-
unsigned int maxNSat,
9-
float hitPredPos,
10-
float& previous_cluster,
11-
unsigned int& module_length,
12-
unsigned int& previous_module_length,
13-
bool peakFilter) {
8+
unsigned int maxNSat,
9+
float hitPredPos,
10+
float& previous_cluster,
11+
unsigned int& module_length,
12+
unsigned int& previous_module_length,
13+
bool peakFilter) {
1414
bool filter_, isSaturated_, peakFilter_;
1515
if (previous_cluster == -999.)
16-
compBarycenter_ = std::round(cluster.barycenter() * maxRange_/maxBarycenter_);
16+
compBarycenter_ = std::round(cluster.barycenter() * maxRange_ / maxBarycenter_);
1717
else
18-
compBarycenter_ = std::round(((cluster.barycenter()-previous_cluster)+(module_length-previous_module_length))* maxRange_/maxBarycenter_);
18+
compBarycenter_ =
19+
std::round(((cluster.barycenter() - previous_cluster) + (module_length - previous_module_length)) * maxRange_ /
20+
maxBarycenter_);
1921
previous_cluster = barycenter(previous_cluster, module_length, previous_module_length);
2022
assert(cluster.barycenter() <= maxBarycenter_ && "Got a barycenter > maxBarycenter");
2123
assert(compBarycenter_ <= maxRange_ && "Filling compBarycenter > maxRange");
22-
width_ = std::min(255,(int)cluster.size());//cluster.size();
24+
width_ = std::min(255, (int)cluster.size()); //cluster.size();
2325
float avgCharge_ = cluster.charge() * 1. / width_;
2426
assert(avgCharge_ <= maxavgCharge_ && "Got a avgCharge > maxavgCharge");
25-
compavgCharge_ = std::round(avgCharge_ * maxavgChargeRange_/maxavgCharge_);
27+
compavgCharge_ = std::round(avgCharge_ * maxavgChargeRange_ / maxavgCharge_);
2628
assert(compavgCharge_ <= maxavgChargeRange_ && "Filling compavgCharge > maxavgChargeRange");
2729
filter_ = false;
2830
isSaturated_ = false;

DataFormats/SiStripCluster/src/SiStripCluster.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ SiStripCluster::SiStripCluster(const SiStripApproximateCluster cluster, const ui
4040
firstStrip_ |= approximateMask;
4141
}
4242

43-
SiStripCluster::SiStripCluster(const SiStripApproximateCluster_v1 cluster, const uint16_t maxStrips, float p_bc,unsigned int module_length, unsigned int previous_module_length) : error_x(-99999.9) {
43+
SiStripCluster::SiStripCluster(const SiStripApproximateCluster_v1 cluster,
44+
const uint16_t maxStrips,
45+
float p_bc,
46+
unsigned int module_length,
47+
unsigned int previous_module_length)
48+
: error_x(-99999.9) {
4449
barycenter_ = cluster.barycenter(p_bc, module_length, previous_module_length);
4550
charge_ = cluster.width() * cluster.avgCharge();
4651
amplitudes_.resize(cluster.width(), cluster.avgCharge());

0 commit comments

Comments
 (0)