File indexing completed on 2024-04-06 12:05:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "DataFormats/SiStripCluster/interface/SiStripApproximateCluster.h"
0019 #include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterCollection.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/global/EDProducer.h"
0023 #include "FWCore/Framework/interface/MakerMacros.h"
0024 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0027 #include "FWCore/Utilities/interface/EDPutToken.h"
0028 #include "FWCore/Utilities/interface/Exception.h"
0029 #include "FWCore/Utilities/interface/StreamID.h"
0030
0031 #include <memory>
0032 #include <utility>
0033 #include <vector>
0034
0035 namespace edmtest {
0036
0037 class TestWriteSiStripApproximateClusterCollection : public edm::global::EDProducer<> {
0038 public:
0039 TestWriteSiStripApproximateClusterCollection(edm::ParameterSet const&);
0040 void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0041 static void fillDescriptions(edm::ConfigurationDescriptions&);
0042
0043 private:
0044 std::vector<unsigned int> integralValues_;
0045 edm::EDPutTokenT<SiStripApproximateClusterCollection> collectionPutToken_;
0046 };
0047
0048 TestWriteSiStripApproximateClusterCollection::TestWriteSiStripApproximateClusterCollection(
0049 edm::ParameterSet const& iPSet)
0050 : integralValues_(iPSet.getParameter<std::vector<unsigned int>>("integralValues")),
0051 collectionPutToken_(produces()) {
0052 if (integralValues_.size() != 7) {
0053 throw cms::Exception("TestFailure") << "TestWriteSiStripApproximateClusterCollection, test configuration error: "
0054 "integralValues should have size 7 and it doesn't";
0055 }
0056 }
0057
0058 void TestWriteSiStripApproximateClusterCollection::produce(edm::StreamID,
0059 edm::Event& iEvent,
0060 edm::EventSetup const&) const {
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 auto siStripApproximateClusterCollection = std::make_unique<SiStripApproximateClusterCollection>();
0074
0075 unsigned int numberDetIds = (iEvent.id().event() - 1) % 10;
0076 unsigned int detId = integralValues_[0] + iEvent.id().event();
0077 for (unsigned int i = 0; i < numberDetIds; ++i) {
0078 detId += iEvent.id().event();
0079 auto filler = siStripApproximateClusterCollection->beginDet(detId);
0080 unsigned int numberOfClustersPerDetId = (iEvent.id().event() - 1) % 10;
0081 for (unsigned int j = 0; j < numberOfClustersPerDetId; ++j) {
0082 unsigned int iOffset = j + iEvent.id().event();
0083 cms_uint16_t barycenter = integralValues_[1] + iOffset;
0084 cms_uint8_t width = integralValues_[2] + iOffset;
0085 cms_uint8_t avgCharge = integralValues_[3] + iOffset;
0086 bool filter = j < (integralValues_[4] + iEvent.id().event()) % 10;
0087 bool isSaturated = j < (integralValues_[5] + iEvent.id().event()) % 10;
0088 bool peakFilter = j < (integralValues_[6] + iEvent.id().event()) % 10;
0089 SiStripApproximateCluster cluster(barycenter, width, avgCharge, filter, isSaturated, peakFilter);
0090 filler.push_back(cluster);
0091 }
0092 }
0093 iEvent.put(collectionPutToken_, std::move(siStripApproximateClusterCollection));
0094 }
0095
0096 void TestWriteSiStripApproximateClusterCollection::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0097 edm::ParameterSetDescription desc;
0098 desc.add<std::vector<unsigned int>>("integralValues");
0099 descriptions.addDefault(desc);
0100 }
0101 }
0102
0103 using edmtest::TestWriteSiStripApproximateClusterCollection;
0104 DEFINE_FWK_MODULE(TestWriteSiStripApproximateClusterCollection);