CMS 3D CMS Logo

SiStripApprox2ApproxClusters.cc
Go to the documentation of this file.
1 
2 
14 
15 #include <vector>
16 #include <memory>
17 
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:
27  uint8_t approxVersion;
30 };
31 
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 
52  auto result = std::make_unique<edmNew::DetSetVector<SiStripApproximateCluster>>();
53  const auto& clusterCollection = event.get(clusterToken);
54 
55  for (const auto& detClusters : clusterCollection) {
57 
58  for (const auto& cluster : detClusters) {
59  float barycenter = cluster.barycenter();
60  uint8_t width = cluster.width();
61  float avgCharge = cluster.avgCharge();
62  bool isSaturated = cluster.isSaturated();
63 
64  switch (approxVersion) {
65  case 0: //ORIGINAL
66  barycenter = std::round(barycenter);
67  if (width > 0x3F)
68  width = 0x3F;
69  avgCharge = std::round(avgCharge);
70  break;
71  case 1: //FULL_WIDTH
72  barycenter = std::round(barycenter);
73  avgCharge = std::round(avgCharge);
74  break;
75  case 2: //BARY_RES_0.1
76  barycenter = std::round(barycenter * 10) / 10;
77  if (width > 0x3F)
78  width = 0x3F;
79  avgCharge = std::round(avgCharge);
80  break;
81  case 3: //BARY_CHARGE_RES_0.1
82  barycenter = std::round(barycenter * 10) / 10;
83  if (width > 0x3F)
84  width = 0x3F;
85  avgCharge = std::round(avgCharge * 10) / 10;
86  break;
87  }
88 
89  ff.push_back(SiStripApproximateCluster(barycenter, width, avgCharge, isSaturated));
90  }
91  }
92 
93  event.put(std::move(result));
94 }
95 
98  desc.add<edm::InputTag>("inputApproxClusters", edm::InputTag("siStripClusters"));
99  desc.add<std::string>("approxVersion", std::string("ORIGINAL"));
100 
101  descriptions.add("SiStripApprox2ApproxClusters", desc);
102 }
103 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edmNew::DetSetVector< SiStripApproximateCluster > > clusterToken
SiStripApprox2ApproxClusters(const edm::ParameterSet &conf)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1