44#include " FWCore/Framework/interface/Frameworkfwd.h"
55#include " FWCore/Framework/interface/stream/EDProducer.h"
66#include " FWCore/ParameterSet/interface/ParameterSet.h"
7- #include " FWCore/Utilities/interface/InputTag.h"
87#include " FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
98#include " FWCore/ParameterSet/interface/ParameterSetDescription.h"
9+ #include " FWCore/Utilities/interface/InputTag.h"
1010#include " DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
1111#include " DataFormats/SiStripCluster/interface/SiStripCluster.h"
1212#include " DataFormats/Common/interface/DetSetVectorNew.h"
@@ -24,58 +24,65 @@ class SiStripApprox2ApproxClusters : public edm::stream::EDProducer<> {
2424
2525private:
2626 edm::InputTag inputApproxClusters;
27- std::string approxVersion;
27+ uint8_t approxVersion;
28+ std::string approxVersionS;
2829 edm::EDGetTokenT<edmNew::DetSetVector<SiStripApproximateCluster>> clusterToken;
2930};
3031
3132SiStripApprox2ApproxClusters::SiStripApprox2ApproxClusters (const edm::ParameterSet& conf) {
3233 inputApproxClusters = conf.getParameter <edm::InputTag>(" inputApproxClusters" );
33- approxVersion = conf.getParameter <std::string>(" approxVersion" );
34-
34+ approxVersionS = conf.getParameter <std::string>(" approxVersion" );
35+
36+ approxVersion=-1 ;
37+
38+ if (approxVersionS==" ORIGINAL" ) approxVersion=0 ;
39+ else if (approxVersionS==" FULL_WIDTH" ) approxVersion=1 ;
40+ else if (approxVersionS==" BARY_RES_0.1" ) approxVersion=2 ;
41+ else if (approxVersionS==" BARY_CHARGE_RES_0.1" ) approxVersion=3 ;
42+
3543 clusterToken = consumes<edmNew::DetSetVector<SiStripApproximateCluster>>(inputApproxClusters);
3644 produces<edmNew::DetSetVector<SiStripApproximateCluster>>();
3745}
3846
3947void SiStripApprox2ApproxClusters::produce (edm::Event& event, edm::EventSetup const &) {
4048 auto result = std::make_unique<edmNew::DetSetVector<SiStripApproximateCluster>>();
41- const auto & clusters = event.get (clusterToken);
49+ const auto & clusterCollection = event.get (clusterToken);
4250
43- for (const auto & detClusters : * clusterCollection) {
51+ for (const auto & detClusters : clusterCollection) {
4452 edmNew::DetSetVector<SiStripApproximateCluster>::FastFiller ff{*result, detClusters.id ()};
4553
4654 for (const auto & cluster : detClusters) {
4755 float barycenter = cluster.barycenter ();
4856 uint8_t width = cluster.width ();
4957 float avgCharge = cluster.avgCharge ();
50-
51- if (approxVersion == " ORIGINAL" ) {
52- barycenter = std::round (barycenter);
53- if (width > 0x3F )
54- width = 0x3F ;
55- avgCharge = std::round (avgCharge);
56-
57- } else if (approxVersion == " FULL_WIDTH" ) {
58- barycenter = std::round (barycenter);
59- avgCharge = std::round (avgCharge);
60-
61- } else if (approxVersion == " BARY_RES_0.1" ) {
62- barycenter = std::round (barycenter * 10 ) / 10 ;
63- if (width > 0x3F )
64- width = 0x3F ;
65- avgCharge = std::round (avgCharge);
66-
67- } else if (approxVersion == " BARY_CHARGE_RES_0.1" ) {
68- barycenter = std::round (barycenter * 10 ) / 10 ;
69- if (width > 0x3F )
70- width = 0x3F ;
71- avgCharge = std::round (avgCharge * 10 ) / 10 ;
58+
59+ switch (approxVersion){
60+ case 0 : // ORIGINAL
61+ barycenter = std::round (barycenter);
62+ if (width > 0x3F ) width = 0x3F ;
63+ avgCharge = std::round (avgCharge);
64+ break ;
65+ case 1 : // FULL_WIDTH
66+ barycenter = std::round (barycenter);
67+ avgCharge = std::round (avgCharge);
68+ break ;
69+ case 2 : // BARY_RES_0.1
70+ barycenter = std::round (barycenter * 10 ) / 10 ;
71+ if (width > 0x3F ) width = 0x3F ;
72+ avgCharge = std::round (avgCharge);
73+ break ;
74+ case 3 : // BARY_CHARGE_RES_0.1
75+ barycenter = std::round (barycenter * 10 ) / 10 ;
76+ if (width > 0x3F ) width = 0x3F ;
77+ avgCharge = std::round (avgCharge * 10 ) / 10 ;
78+ break ;
7279 }
73-
80+
7481 ff.push_back (SiStripApproximateCluster (barycenter, width, avgCharge));
7582 }
7683 }
7784
78- e .put (std::move (result));
85+ event .put (std::move (result));
7986}
8087
8188void SiStripApprox2ApproxClusters::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
0 commit comments