Skip to content

Commit 92b8b51

Browse files
authored
Merge pull request cms-sw#33546 from icali/ApproximatedClusters_11_3_0_pre6_V0
SiStripApproximateCluster reduced data format for HI
2 parents b21c3e1 + 214e8b4 commit 92b8b51

11 files changed

+642
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTER_H
2+
#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTER_H
3+
4+
#include <numeric>
5+
#include <cmath>
6+
#include <iostream>
7+
#include <iomanip>
8+
9+
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
10+
11+
class SiStripApproximateCluster {
12+
public:
13+
SiStripApproximateCluster() {}
14+
15+
explicit SiStripApproximateCluster(float barycenter, uint8_t width, float avgCharge) {
16+
barycenter_ = barycenter;
17+
width_ = width;
18+
avgCharge_ = avgCharge;
19+
}
20+
21+
explicit SiStripApproximateCluster(const SiStripCluster& cluster) {
22+
barycenter_ = cluster.barycenter();
23+
width_ = cluster.size();
24+
avgCharge_ = cluster.charge() / cluster.size();
25+
}
26+
27+
float barycenter() const { return barycenter_; }
28+
uint8_t width() const { return width_; }
29+
float avgCharge() const { return avgCharge_; }
30+
31+
private:
32+
float barycenter_ = 0;
33+
uint8_t width_ = 0;
34+
float avgCharge_ = 0;
35+
};
36+
#endif // DATAFORMATS_SiStripApproximateCluster_H

DataFormats/SiStripCluster/src/classes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "DataFormats/Common/interface/DetSetVectorNew.h"
66
#include "DataFormats/Common/interface/Ref.h"
77
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
8+
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
89
#include "DataFormats/Common/interface/ContainerMask.h"
910

1011
#endif // SISTRIPCLUSTER_CLASSES_H

DataFormats/SiStripCluster/src/classes_def.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,24 @@
2323
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripCluster>,SiStripCluster,edmNew::DetSetVector<SiStripCluster>::FindForDetSetVector> > >" />
2424

2525

26+
<class name="SiStripApproximateCluster" ClassVersion="3">
27+
<version ClassVersion="3" checksum="2041370183"/>
28+
</class>
29+
30+
<class name="edmNew::DetSetVector<SiStripApproximateCluster>"/>
31+
<class name="edm::Wrapper<edmNew::DetSetVector<SiStripApproximateCluster>>"/>
32+
33+
<class name="std::vector<SiStripApproximateCluster>"/>
34+
35+
<class name="edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster>, SiStripApproximateCluster, edmNew::DetSetVector<SiStripApproximateCluster>::FindForDetSetVector>"/>
36+
37+
38+
<class name="edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateCluster> >"/>
39+
<class name="edm::Wrapper<edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateCluster> > >"/>
40+
41+
42+
<class name="std::vector<edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster>,SiStripApproximateCluster,edmNew::DetSetVector<SiStripApproximateCluster>::FindForDetSetVector> >" />
43+
<class name="edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster>,SiStripApproximateCluster,edmNew::DetSetVector<SiStripApproximateCluster>::FindForDetSetVector> >" />
44+
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateCluster>,SiStripApproximateCluster,edmNew::DetSetVector<SiStripApproximateCluster>::FindForDetSetVector> > >" />
45+
2646
</lcgdict>
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<use name="DataFormats/Common"/>
22
<use name="FWCore/Framework"/>
33
<use name="FWCore/ParameterSet"/>
4+
<use name="FWCore/Utilities"/>
45
<use name="DataFormats/SiStripDigi"/>
56
<use name="DataFormats/SiStripCluster"/>
7+
<use name="DataFormats/Common"/>
68
<use name="CondFormats/DataRecord"/>
79
<use name="CondFormats/SiStripObjects"/>
810
<use name="CalibFormats/SiStripObjects"/>
911
<use name="CalibTracker/Records"/>
1012
<use name="RecoLocalTracker/Records"/>
13+
<use name="CommonTools/UtilAlgos"/>
14+
<use name="CommonTools/Utils"/>
15+
<use name="root"/>
1116
<export>
1217
<lib name="1"/>
13-
</export>
18+
</export>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
2+
3+
#include "FWCore/Framework/interface/MakerMacros.h"
4+
#include "FWCore/Framework/interface/Frameworkfwd.h"
5+
#include "FWCore/Framework/interface/stream/EDProducer.h"
6+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
7+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
8+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
9+
#include "FWCore/Utilities/interface/InputTag.h"
10+
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
11+
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
12+
#include "DataFormats/Common/interface/DetSetVectorNew.h"
13+
#include "DataFormats/Common/interface/DetSetVector.h"
14+
15+
#include <vector>
16+
#include <memory>
17+
18+
class SiStripApprox2ApproxClusters : public edm::stream::EDProducer<> {
19+
public:
20+
explicit SiStripApprox2ApproxClusters(const edm::ParameterSet& conf);
21+
void produce(edm::Event&, const edm::EventSetup&) override;
22+
23+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
24+
25+
private:
26+
edm::InputTag inputApproxClusters;
27+
uint8_t approxVersion;
28+
std::string approxVersionS;
29+
edm::EDGetTokenT<edmNew::DetSetVector<SiStripApproximateCluster>> clusterToken;
30+
};
31+
32+
SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters(const edm::ParameterSet& conf) {
33+
inputApproxClusters = conf.getParameter<edm::InputTag>("inputApproxClusters");
34+
approxVersionS = conf.getParameter<std::string>("approxVersion");
35+
36+
approxVersion = -1;
37+
38+
if (approxVersionS == "ORIGINAL")
39+
approxVersion = 0;
40+
else if (approxVersionS == "FULL_WIDTH")
41+
approxVersion = 1;
42+
else if (approxVersionS == "BARY_RES_0.1")
43+
approxVersion = 2;
44+
else if (approxVersionS == "BARY_CHARGE_RES_0.1")
45+
approxVersion = 3;
46+
47+
clusterToken = consumes<edmNew::DetSetVector<SiStripApproximateCluster>>(inputApproxClusters);
48+
produces<edmNew::DetSetVector<SiStripApproximateCluster>>();
49+
}
50+
51+
void SiStripApprox2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&) {
52+
auto result = std::make_unique<edmNew::DetSetVector<SiStripApproximateCluster>>();
53+
const auto& clusterCollection = event.get(clusterToken);
54+
55+
for (const auto& detClusters : clusterCollection) {
56+
edmNew::DetSetVector<SiStripApproximateCluster>::FastFiller ff{*result, detClusters.id()};
57+
58+
for (const auto& cluster : detClusters) {
59+
float barycenter = cluster.barycenter();
60+
uint8_t width = cluster.width();
61+
float avgCharge = cluster.avgCharge();
62+
63+
switch (approxVersion) {
64+
case 0: //ORIGINAL
65+
barycenter = std::round(barycenter);
66+
if (width > 0x3F)
67+
width = 0x3F;
68+
avgCharge = std::round(avgCharge);
69+
break;
70+
case 1: //FULL_WIDTH
71+
barycenter = std::round(barycenter);
72+
avgCharge = std::round(avgCharge);
73+
break;
74+
case 2: //BARY_RES_0.1
75+
barycenter = std::round(barycenter * 10) / 10;
76+
if (width > 0x3F)
77+
width = 0x3F;
78+
avgCharge = std::round(avgCharge);
79+
break;
80+
case 3: //BARY_CHARGE_RES_0.1
81+
barycenter = std::round(barycenter * 10) / 10;
82+
if (width > 0x3F)
83+
width = 0x3F;
84+
avgCharge = std::round(avgCharge * 10) / 10;
85+
break;
86+
}
87+
88+
ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge));
89+
}
90+
}
91+
92+
event.put(std::move(result));
93+
}
94+
95+
void SiStripApprox2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
96+
edm::ParameterSetDescription desc;
97+
desc.add<edm::InputTag>("inputApproxClusters", edm::InputTag("siStripClusters"));
98+
desc.add<std::string>("approxVersion", std::string("ORIGINAL"));
99+
100+
descriptions.add("SiStripApprox2ApproxClusters", desc);
101+
}
102+
103+
DEFINE_FWK_MODULE(SiStripApprox2ApproxClusters);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
3+
#include "FWCore/Framework/interface/MakerMacros.h"
4+
#include "FWCore/Framework/interface/Frameworkfwd.h"
5+
#include "FWCore/Framework/interface/stream/EDProducer.h"
6+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
7+
#include "FWCore/Utilities/interface/InputTag.h"
8+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
9+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
10+
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
11+
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
12+
#include "DataFormats/Common/interface/DetSetVectorNew.h"
13+
#include "DataFormats/Common/interface/DetSetVector.h"
14+
15+
#include <vector>
16+
#include <memory>
17+
18+
class SiStripClusters2ApproxClusters : public edm::stream::EDProducer<> {
19+
public:
20+
explicit SiStripClusters2ApproxClusters(const edm::ParameterSet& conf);
21+
void produce(edm::Event&, const edm::EventSetup&) override;
22+
23+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
24+
25+
private:
26+
edm::InputTag inputClusters;
27+
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusterToken;
28+
};
29+
30+
SiStripClusters2ApproxClusters::SiStripClusters2ApproxClusters(const edm::ParameterSet& conf) {
31+
inputClusters = conf.getParameter<edm::InputTag>("inputClusters");
32+
33+
clusterToken = consumes<edmNew::DetSetVector<SiStripCluster> >(inputClusters);
34+
produces<edmNew::DetSetVector<SiStripApproximateCluster> >();
35+
}
36+
37+
void SiStripClusters2ApproxClusters::produce(edm::Event& event, edm::EventSetup const&) {
38+
auto result = std::make_unique<edmNew::DetSetVector<SiStripApproximateCluster> >();
39+
const auto& clusterCollection = event.get(clusterToken);
40+
41+
for (const auto& detClusters : clusterCollection) {
42+
edmNew::DetSetVector<SiStripApproximateCluster>::FastFiller ff{*result, detClusters.id()};
43+
44+
for (const auto& cluster : detClusters)
45+
ff.push_back(SiStripApproximateCluster(cluster));
46+
}
47+
48+
event.put(std::move(result));
49+
}
50+
51+
void SiStripClusters2ApproxClusters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
52+
edm::ParameterSetDescription desc;
53+
desc.add<edm::InputTag>("inputClusters", edm::InputTag("siStripClusters"));
54+
descriptions.add("SiStripClusters2ApproxClusters", desc);
55+
}
56+
57+
DEFINE_FWK_MODULE(SiStripClusters2ApproxClusters);

RecoLocalTracker/SiStripClusterizer/test/SealModules.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
#include "RecoLocalTracker/SiStripClusterizer/test/StripByStripTestDriver.h"
1010
#include "RecoLocalTracker/SiStripClusterizer/test/ClusterizerUnitTesterESProducer.h"
1111
#include "RecoLocalTracker/SiStripClusterizer/test/ClusterRefinerTagMCmerged.h"
12+
#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h"
1213

1314
DEFINE_FWK_MODULE(CompareClusters);
1415
DEFINE_FWK_MODULE(ClusterizerUnitTester);
1516
DEFINE_FWK_MODULE(StripByStripTestDriver);
1617
DEFINE_FWK_EVENTSETUP_MODULE(ClusterizerUnitTesterESProducer);
1718
DEFINE_FWK_MODULE(ClusterRefinerTagMCmerged);
19+
DEFINE_FWK_MODULE(SiStripApproximatedClustersDump);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h"
2+
3+
SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::ParameterSet& conf) {
4+
inputTagClusters = conf.getParameter<edm::InputTag>("approximatedClustersTag");
5+
clusterToken = consumes<edmNew::DetSetVector<SiStripApproximateCluster>>(inputTagClusters);
6+
7+
usesResource("TFileService");
8+
9+
outNtuple = fs->make<TTree>("ApproxClusters", "ApproxClusters");
10+
outNtuple->Branch("event", &eventN, "event/i");
11+
outNtuple->Branch("detId", &detId, "detId/i");
12+
outNtuple->Branch("barycenter", &barycenter, "barycenter/F");
13+
outNtuple->Branch("width", &width, "width/b");
14+
outNtuple->Branch("charge", &avCharge, "charge/b");
15+
}
16+
17+
SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {}
18+
19+
void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) {
20+
edm::Handle<edmNew::DetSetVector<SiStripApproximateCluster>> clusterCollection = event.getHandle(clusterToken);
21+
22+
for (const auto& detClusters : *clusterCollection) {
23+
detId = detClusters.detId();
24+
eventN = event.id().event();
25+
26+
for (const auto& cluster : detClusters) {
27+
barycenter = cluster.barycenter();
28+
width = cluster.width();
29+
avCharge = cluster.avgCharge();
30+
outNtuple->Fill();
31+
}
32+
}
33+
}
34+
35+
void SiStripApproximatedClustersDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
36+
edm::ParameterSetDescription desc;
37+
desc.add<edm::InputTag>("approximatedClustersTag", edm::InputTag("SiStripClusters2ApproxClusters"));
38+
descriptions.add("SiStripApproximatedClustersDump", desc);
39+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef RecoLocalTracker_SiStripApproximatedClustersDump_h
2+
#define RecoLocalTracker_SiStripApproximatedClustersDump_h
3+
4+
// user include files
5+
#include "FWCore/Framework/interface/Frameworkfwd.h"
6+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
7+
#include "FWCore/Framework/interface/MakerMacros.h"
8+
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
9+
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
10+
#include "FWCore/Framework/interface/Event.h"
11+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
12+
#include "DataFormats/Common/interface/DetSet.h"
13+
#include "DataFormats/Common/interface/DetSetVector.h"
14+
#include "DataFormats/Common/interface/DetSetVectorNew.h"
15+
#include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
16+
17+
#include "FWCore/ServiceRegistry/interface/Service.h"
18+
#include "CommonTools/UtilAlgos/interface/TFileService.h"
19+
#include "CommonTools/Utils/interface/TFileDirectory.h"
20+
21+
#include <memory>
22+
#include <iostream>
23+
24+
//ROOT inclusion
25+
#include "TROOT.h"
26+
#include "TFile.h"
27+
#include "TNtuple.h"
28+
#include "TTree.h"
29+
#include "TMath.h"
30+
#include "TList.h"
31+
#include "TString.h"
32+
33+
//
34+
// class decleration
35+
//
36+
37+
class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer<edm::one::SharedResources> {
38+
public:
39+
explicit SiStripApproximatedClustersDump(const edm::ParameterSet&);
40+
~SiStripApproximatedClustersDump() override;
41+
42+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
43+
44+
private:
45+
void analyze(const edm::Event&, const edm::EventSetup&) override;
46+
47+
edm::InputTag inputTagClusters;
48+
edm::EDGetTokenT<edmNew::DetSetVector<SiStripApproximateCluster> > clusterToken;
49+
50+
TTree* outNtuple;
51+
edm::Service<TFileService> fs;
52+
53+
uint32_t detId;
54+
uint16_t barycenter;
55+
uint16_t width;
56+
uint8_t avCharge;
57+
edm::EventNumber_t eventN;
58+
};
59+
#endif

0 commit comments

Comments
 (0)