Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ namespace v1 {
// Helper classes to make creation and iteration easier
class Filler {
public:
void push_back(SiStripApproximateCluster_v1 const& cluster) { clusters_.push_back(cluster); }
void push_back(v1::SiStripApproximateCluster const& cluster) { clusters_.push_back(cluster); }

private:
friend SiStripApproximateClusterCollection;
Filler(std::vector<SiStripApproximateCluster_v1>& clusters) : clusters_(clusters) {}
Filler(std::vector<v1::SiStripApproximateCluster>& clusters) : clusters_(clusters) {}

std::vector<SiStripApproximateCluster_v1>& clusters_;
std::vector<v1::SiStripApproximateCluster>& clusters_;
};

class const_iterator;
class DetSet {
public:
using const_iterator = std::vector<SiStripApproximateCluster_v1>::const_iterator;
using const_iterator = std::vector<v1::SiStripApproximateCluster>::const_iterator;

unsigned int id() const {
return std::accumulate(coll_->detIds_.cbegin(), coll_->detIds_.cbegin() + detIndex_ + 1, 0);
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace v1 {
// element of beginIndices_ points to the first cluster of the Det
// in clusters_.
std::vector<unsigned int> detIds_; // DetId for the Det
std::vector<SiStripApproximateCluster_v1> clusters_;
std::vector<v1::SiStripApproximateCluster> clusters_;
};
} // namespace v1
#endif
111 changes: 57 additions & 54 deletions DataFormats/SiStripCluster/interface/SiStripApproximateCluster_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,66 @@
#include "assert.h"

class SiStripCluster;
class SiStripApproximateCluster_v1 {
public:
SiStripApproximateCluster_v1() {}

explicit SiStripApproximateCluster_v1(cms_uint16_t compBarycenter, cms_uint8_t width, cms_uint8_t compavgCharge)
: compBarycenter_(compBarycenter), width_(width), compavgCharge_(compavgCharge) {}
namespace v1 {
class SiStripApproximateCluster {
public:
SiStripApproximateCluster() {}

explicit SiStripApproximateCluster_v1(const SiStripCluster& cluster,
unsigned int maxNSat,
float hitPredPos,
float& previous_cluster,
unsigned int& module_length,
unsigned int& previous_module_length,
bool peakFilter);
explicit SiStripApproximateCluster(cms_uint16_t compBarycenter, cms_uint8_t width, cms_uint8_t compavgCharge)
: compBarycenter_(compBarycenter), width_(width), compavgCharge_(compavgCharge) {}

const cms_uint16_t compBarycenter() const { return compBarycenter_; }
explicit SiStripApproximateCluster(const SiStripCluster& cluster,
unsigned int maxNSat,
float hitPredPos,
float& previous_cluster,
unsigned int& module_length,
unsigned int& previous_module_length,
bool peakFilter);

float barycenter(float previous_barycenter = 0,
unsigned int module_length = 0,
unsigned int previous_module_length = 0) const {
float _barycenter;
cms_uint16_t compBarycenter = (compBarycenter_ & 0x7FFF);
if (previous_barycenter == -999)
_barycenter = compBarycenter * maxBarycenter_ / maxRange_;
else {
_barycenter = ((compBarycenter * maxBarycenter_ / maxRange_) - (module_length - previous_module_length)) +
previous_barycenter;
const cms_uint16_t compBarycenter() const { return compBarycenter_; }

float barycenter(float previous_barycenter = 0,
unsigned int module_length = 0,
unsigned int previous_module_length = 0) const {
float barycenter;
cms_uint16_t compBarycenter = (compBarycenter_ & 0x7FFF);
if (previous_barycenter == -999)
barycenter = compBarycenter * maxBarycenter_ / maxRange_;
else {
barycenter = ((compBarycenter * maxBarycenter_ / maxRange_) - (module_length - previous_module_length)) +
previous_barycenter;
}
assert(barycenter <= maxBarycenter_ && "Returning barycenter > maxBarycenter");
return barycenter;
}
cms_uint8_t width() const { return width_; }
float avgCharge() const {
cms_uint8_t compavgCharge = (compavgCharge_ & 0x3F);
float avgCharge_ = compavgCharge * maxavgCharge_ / maxavgChargeRange_;
assert(avgCharge_ <= maxavgCharge_ && "Returning avgCharge > maxavgCharge");
return avgCharge_;
}
assert(_barycenter <= maxBarycenter_ && "Returning barycenter > maxBarycenter");
return _barycenter;
}
cms_uint8_t width() const { return width_; }
float avgCharge() const {
cms_uint8_t compavgCharge = (compavgCharge_ & 0x3F);
float avgCharge_ = compavgCharge * maxavgCharge_ / maxavgChargeRange_;
assert(avgCharge_ <= maxavgCharge_ && "Returning avgCharge > maxavgCharge");
return avgCharge_;
}
bool filter() const { return (compavgCharge_ & (1 << kfilterMask)); }
bool isSaturated() const { return (compavgCharge_ & (1 << kSaturatedMask)); }
bool peakFilter() const { return (compBarycenter_ & (1 << kpeakFilterMask)); }
bool filter() const { return (compavgCharge_ & (1 << kfilterMask)); }
bool isSaturated() const { return (compavgCharge_ & (1 << kSaturatedMask)); }
bool peakFilter() const { return (compBarycenter_ & (1 << kpeakFilterMask)); }

private:
cms_uint16_t compBarycenter_ = 0;
cms_uint8_t width_ = 0;
cms_uint8_t compavgCharge_ = 0;
static constexpr double maxRange_ = 32767;
static constexpr double maxBarycenter_ = 1536.;
static constexpr double maxavgChargeRange_ = 63;
static constexpr double maxavgCharge_ = 255.;
static constexpr double trimMaxADC_ = 30.;
static constexpr double trimMaxFracTotal_ = .15;
static constexpr double trimMaxFracNeigh_ = .25;
static constexpr double maxTrimmedSizeDiffNeg_ = .7;
static constexpr double maxTrimmedSizeDiffPos_ = 1.;
static constexpr int kfilterMask = 6;
static constexpr int kpeakFilterMask = 7;
static constexpr int kSaturatedMask = 15;
};
#endif // DataFormats_SiStripCluster_SiStripApproximateCluster_v1_h
private:
cms_uint16_t compBarycenter_ = 0;
cms_uint8_t width_ = 0;
cms_uint8_t compavgCharge_ = 0;
static constexpr double maxRange_ = 32767;
static constexpr double maxBarycenter_ = 1536.;
static constexpr double maxavgChargeRange_ = 63;
static constexpr double maxavgCharge_ = 255.;
static constexpr double trimMaxADC_ = 30.;
static constexpr double trimMaxFracTotal_ = .15;
static constexpr double trimMaxFracNeigh_ = .25;
static constexpr double maxTrimmedSizeDiffNeg_ = .7;
static constexpr double maxTrimmedSizeDiffPos_ = 1.;
static constexpr int kfilterMask = 6;
static constexpr int kpeakFilterMask = 7;
static constexpr int kSaturatedMask = 15;
};
} // namespace v1
#endif // DataFormats_SiStripCluster_SiStripApproximateCluster_h
4 changes: 1 addition & 3 deletions DataFormats/SiStripCluster/interface/SiStripCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include <numeric>
#include <iostream>

class SiStripApproximateCluster;

class SiStripCluster {
public:
typedef std::vector<SiStripDigi>::const_iterator SiStripDigiIter;
Expand Down Expand Up @@ -46,7 +44,7 @@ class SiStripCluster {
}

SiStripCluster(const SiStripApproximateCluster cluster, const uint16_t maxStrips);
SiStripCluster(const SiStripApproximateCluster_v1 cluster,
SiStripCluster(const v1::SiStripApproximateCluster cluster,
const uint16_t maxStrips,
float pc = -999,
unsigned int module_length = 0,
Expand Down
15 changes: 7 additions & 8 deletions DataFormats/SiStripCluster/src/SiStripApproximateCluster_v1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
#include <algorithm>
#include <cassert>
#include <cmath>

SiStripApproximateCluster_v1::SiStripApproximateCluster_v1(const SiStripCluster& cluster,
unsigned int maxNSat,
float hitPredPos,
float& previous_cluster,
unsigned int& module_length,
unsigned int& previous_module_length,
bool peakFilter) {
v1::SiStripApproximateCluster::SiStripApproximateCluster(const SiStripCluster& cluster,
unsigned int maxNSat,
float hitPredPos,
float& previous_cluster,
unsigned int& module_length,
unsigned int& previous_module_length,
bool peakFilter) {
bool filter_, isSaturated_, peakFilter_;
if (previous_cluster == -999.)
compBarycenter_ = std::round(cluster.barycenter() * maxRange_ / maxBarycenter_);
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/SiStripCluster/src/SiStripCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SiStripCluster::SiStripCluster(const SiStripApproximateCluster cluster, const ui
firstStrip_ |= approximateMask;
}

SiStripCluster::SiStripCluster(const SiStripApproximateCluster_v1 cluster,
SiStripCluster::SiStripCluster(const v1::SiStripApproximateCluster cluster,
const uint16_t maxStrips,
float p_bc,
unsigned int module_length,
Expand Down
28 changes: 15 additions & 13 deletions DataFormats/SiStripCluster/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,36 @@



<class name="SiStripApproximateCluster_v1" ClassVersion="7">
<version ClassVersion="7" checksum="1154754493"/>
<class name="v1::SiStripApproximateCluster" ClassVersion="8">
<version ClassVersion="8" checksum="4999754"/>
<version ClassVersion="7" checksum="1154754493"/>
<version ClassVersion="6" checksum="132211472"/>
<version ClassVersion="5" checksum="3495825183"/>
<version ClassVersion="4" checksum="2854791577"/>
<version ClassVersion="3" checksum="2041370183"/>
</class>
<class name="v1::SiStripApproximateClusterCollection" ClassVersion="4">
<version ClassVersion="4" checksum="2896589077"/>
<class name="v1::SiStripApproximateClusterCollection" ClassVersion="5">
<version ClassVersion="5" checksum="3036799892"/>
<version ClassVersion="4" checksum="2896589077"/>
<version ClassVersion="3" checksum="3101417750"/>
</class>
<class name="edm::Wrapper<v1::SiStripApproximateClusterCollection>"/>

<class name="edmNew::DetSetVector<SiStripApproximateCluster_v1>"/>
<class name="edm::Wrapper<edmNew::DetSetVector<SiStripApproximateCluster_v1>>"/>
<class name="edmNew::DetSetVector<v1::SiStripApproximateCluster>"/>
<class name="edm::Wrapper<edmNew::DetSetVector<v1::SiStripApproximateCluster>>"/>

<class name="std::vector<SiStripApproximateCluster_v1>"/>
<class name="std::vector<v1::SiStripApproximateCluster>"/>

<class name="edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster_v1>, SiStripApproximateCluster_v1, edmNew::DetSetVector<SiStripApproximateCluster_v1>::FindForDetSetVector>"/>
<class name="edm::Ref<edmNew::DetSetVector<v1::SiStripApproximateCluster>, v1::SiStripApproximateCluster, edmNew::DetSetVector<v1::SiStripApproximateCluster>::FindForDetSetVector>"/>


<class name="edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateCluster_v1> >"/>
<class name="edm::Wrapper<edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateCluster_v1> > >"/>
<class name="edm::ContainerMask<edmNew::DetSetVector<v1::SiStripApproximateCluster> >"/>
<class name="edm::Wrapper<edm::ContainerMask<edmNew::DetSetVector<v1::SiStripApproximateCluster> > >"/>


<class name="std::vector<edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster_v1>,SiStripApproximateCluster_v1,edmNew::DetSetVector<SiStripApproximateCluster_v1>::FindForDetSetVector> >" />
<class name="edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster_v1>,SiStripApproximateCluster_v1,edmNew::DetSetVector<SiStripApproximateCluster_v1>::FindForDetSetVector> >" />
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster_v1>,SiStripApproximateCluster_v1,edmNew::DetSetVector<SiStripApproximateCluster_v1>::FindForDetSetVector> > >" />
<class name="std::vector<edm::Ref<edmNew::DetSetVector<v1::SiStripApproximateCluster>,v1::SiStripApproximateCluster,edmNew::DetSetVector<v1::SiStripApproximateCluster>::FindForDetSetVector> >" />
<class name="edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<v1::SiStripApproximateCluster>,v1::SiStripApproximateCluster,edmNew::DetSetVector<v1::SiStripApproximateCluster>::FindForDetSetVector> >" />
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<v1::SiStripApproximateCluster>,v1::SiStripApproximateCluster,edmNew::DetSetVector<v1::SiStripApproximateCluster>::FindForDetSetVector> > >" />
<class name="SiStripClustersSOA" ClassVersion="3">
<version ClassVersion="3" checksum="2739562998"/>
</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ class SiStripApprox2Clusters : public edm::global::EDProducer<> {
};

SiStripApprox2Clusters::SiStripApprox2Clusters(const edm::ParameterSet& conf) {
clusterToken_ = consumes(conf.getParameter<edm::InputTag>("inputApproxClusters"));
clusterToken_v1_ = consumes(conf.getParameter<edm::InputTag>("inputApproxClusters"));
tkGeomToken_ = esConsumes();
v1 = conf.getParameter<bool>("v1");
if (v1) {
clusterToken_v1_ = consumes(conf.getParameter<edm::InputTag>("inputApproxClusters"));
} else {
clusterToken_ = consumes(conf.getParameter<edm::InputTag>("inputApproxClusters"));
}
produces<edmNew::DetSetVector<SiStripCluster>>();
}

Expand All @@ -47,7 +50,7 @@ void SiStripApprox2Clusters::produce(edm::StreamID id, edm::Event& event, const
const auto& tkGeom = &iSetup.getData(tkGeomToken_);
const auto& tkDets = tkGeom->dets();

if (!v1) {
if (clusterToken_v1_.isUninitialized()) {
const auto& clusterCollection = event.get(clusterToken_);
for (const auto& detClusters : clusterCollection) {
edmNew::DetSetVector<SiStripCluster>::FastFiller ff{*result, detClusters.id()};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ void SiStripClusters2ApproxClusters_v1::produce(edm::Event& event, edm::EventSet
bool isTrivial = (std::abs(hitPredPos) < 2.f && hitStrips <= 2);

if (!usable || isTrivial) {
ff.push_back(SiStripApproximateCluster_v1(cluster,
maxNSat,
hitPredPos,
previous_cluster,
module_length,
first_cluster ? previous_module_length : module_length,
true));
ff.push_back(v1::SiStripApproximateCluster(cluster,
maxNSat,
hitPredPos,
previous_cluster,
module_length,
first_cluster ? previous_module_length : module_length,
true));
} else {
bool peakFilter = false;
SlidingPeakFinder pf(std::max<int>(2, std::ceil(std::abs(hitPredPos) + subclusterWindow_)));
Expand All @@ -174,13 +174,13 @@ void SiStripClusters2ApproxClusters_v1::produce(edm::Event& event, edm::EventSet
subclusterCutSN_);
peakFilter = pf.apply(cluster.amplitudes(), test);

ff.push_back(SiStripApproximateCluster_v1(cluster,
maxNSat,
hitPredPos,
previous_cluster,
module_length,
first_cluster ? previous_module_length : module_length,
peakFilter));
ff.push_back(v1::SiStripApproximateCluster(cluster,
maxNSat,
hitPredPos,
previous_cluster,
module_length,
first_cluster ? previous_module_length : module_length,
peakFilter));
}
first_cluster = false;
}
Expand Down