Skip to content

Commit

Permalink
Merge pull request #38870 from abaty/SaturatedFlag_July272022
Browse files Browse the repository at this point in the history
Addition of saturated flag in SiStrip Approximate Clusters
  • Loading branch information
cmsbuild committed Aug 5, 2022
2 parents 5f2e30a + 26931c1 commit eb2d3a5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
Expand Up @@ -13,21 +13,24 @@ class SiStripApproximateCluster {
public:
SiStripApproximateCluster() {}

explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge) {
explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge, bool isSaturated) {
barycenter_ = barycenter;
width_ = width;
avgCharge_ = avgCharge;
isSaturated_ = isSaturated;
}

explicit SiStripApproximateCluster(const SiStripCluster& cluster);
explicit SiStripApproximateCluster(const SiStripCluster& cluster, unsigned int maxNSat);

float barycenter() const { return barycenter_; }
uint8_t width() const { return width_; }
float avgCharge() const { return avgCharge_; }
bool isSaturated() const { return isSaturated_; }

private:
float barycenter_ = 0;
uint8_t width_ = 0;
float avgCharge_ = 0;
bool isSaturated_ = false;
};
#endif // DATAFORMATS_SiStripApproximateCluster_H
22 changes: 21 additions & 1 deletion DataFormats/SiStripCluster/src/SiStripApproximateCluster.cc
@@ -1,7 +1,27 @@
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"

SiStripApproximateCluster::SiStripApproximateCluster(const SiStripCluster& cluster) {
SiStripApproximateCluster::SiStripApproximateCluster(const SiStripCluster& cluster, unsigned int maxNSat) {
barycenter_ = cluster.barycenter();
width_ = cluster.size();
avgCharge_ = cluster.charge() / cluster.size();
isSaturated_ = false;

//mimicing the algorithm used in StripSubClusterShapeTrajectoryFilter...
//Looks for 3 adjacent saturated strips (ADC>=254)
const auto& ampls = cluster.amplitudes();
unsigned int thisSat = (ampls[0] >= 254), maxSat = thisSat;
for (unsigned int i = 1, n = ampls.size(); i < n; ++i) {
if (ampls[i] >= 254) {
thisSat++;
} else if (thisSat > 0) {
maxSat = std::max<int>(maxSat, thisSat);
thisSat = 0;
}
}
if (thisSat > 0) {
maxSat = std::max<int>(maxSat, thisSat);
}
if (maxSat >= maxNSat) {
isSaturated_ = true;
}
}
4 changes: 2 additions & 2 deletions DataFormats/SiStripCluster/src/classes_def.xml
Expand Up @@ -24,8 +24,8 @@
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripCluster>,SiStripCluster,edmNew::DetSetVector<SiStripCluster>::FindForDetSetVector> > >" />


<class name="SiStripApproximateCluster" ClassVersion="3">
<version ClassVersion="3" checksum="2041370183"/>
<class name="SiStripApproximateCluster" ClassVersion="4">
<version ClassVersion="4" checksum="2854791577"/>
</class>

<class name="edmNew::DetSetVector<SiStripApproximateCluster>"/>
Expand Down
Expand Up @@ -59,6 +59,7 @@ void SiStripApprox2ApproxClusters::produce(edm::Event& event, edm::EventSetup co
float barycenter = cluster.barycenter();
uint8_t width = cluster.width();
float avgCharge = cluster.avgCharge();
bool isSaturated = cluster.isSaturated();

switch (approxVersion) {
case 0: //ORIGINAL
Expand All @@ -85,7 +86,7 @@ void SiStripApprox2ApproxClusters::produce(edm::Event& event, edm::EventSetup co
break;
}

ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge));
ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge, isSaturated));
}
}

Expand Down
Expand Up @@ -25,10 +25,13 @@ class SiStripClusters2ApproxClusters : public edm::stream::EDProducer<> {
private:
edm::InputTag inputClusters;
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusterToken;

unsigned int maxNSat;
};

SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(const edm::ParameterSet& conf) {
inputClusters = conf.getParameter<edm::InputTag>("inputClusters");
maxNSat = conf.getParameter<unsigned int>("maxSaturatedStrips");

clusterToken = consumes<edmNew::DetSetVector<SiStripCluster> >(inputClusters);
produces<edmNew::DetSetVector<SiStripApproximateCluster> >();
Expand All @@ -42,7 +45,7 @@ void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup
edmNew::DetSetVector<SiStripApproximateCluster>::FastFiller ff{*result, detClusters.id()};

for (const auto& cluster : detClusters)
ff.push_back(SiStripApproximateCluster(cluster));
ff.push_back(SiStripApproximateCluster(cluster, maxNSat));
}

event.put(std::move(result));
Expand All @@ -51,7 +54,8 @@ void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup
void SiStripClusters2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("inputClusters", edm::InputTag("siStripClusters"));
desc.add<unsigned int>("maxSaturatedStrips", 3);
descriptions.add("SiStripClusters2ApproxClusters", desc);
}

DEFINE_FWK_MODULE(SiStripClusters2ApproxClusters);
DEFINE_FWK_MODULE(SiStripClusters2ApproxClusters);

0 comments on commit eb2d3a5

Please sign in to comment.