Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of saturated flag in SiStrip Approximate Clusters #38870

Merged
merged 2 commits into from Aug 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"/>
Copy link
Contributor

@makortel makortel Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have kept the checksum for class version 3 in addition of 4.

Copy link
Contributor

@jpata jpata Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matti. Is there a way to detect this at compile time (or in the tests)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing straightforward comes to my mind, but maybe we could figure out something. A specific check would certainly help to catch such cases. Could you open an issue about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! #39008

</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);