Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-06-05 01:26:12

0001 // -*- C++ -*-
0002 //
0003 // Package:    DataFormats/Scouting
0004 // Class:      TestWriteRun3Scouting
0005 //
0006 /**\class edmtest::TestWriteRun3Scouting
0007   Description: Used as part of tests that ensure the Run 3 scouting
0008   data formats can be persistently written and in a subsequent process
0009   read. First, this is done using the current release version for writing
0010   and reading. In addition, the output file of the write process should
0011   be saved permanently each time a Run 3 Scouting persistent data
0012   format changes. In unit tests, we read each of those saved files to verify
0013   that the current releases can read older versions of the data format.
0014 */
0015 // Original Author:  W. David Dagenhart
0016 //         Created:  17 May 2023
0017 
0018 #include "DataFormats/Scouting/interface/Run3ScoutingCaloJet.h"
0019 #include "DataFormats/Scouting/interface/Run3ScoutingElectron.h"
0020 #include "DataFormats/Scouting/interface/Run3ScoutingHitPatternPOD.h"
0021 #include "DataFormats/Scouting/interface/Run3ScoutingMuon.h"
0022 #include "DataFormats/Scouting/interface/Run3ScoutingParticle.h"
0023 #include "DataFormats/Scouting/interface/Run3ScoutingPFJet.h"
0024 #include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h"
0025 #include "DataFormats/Scouting/interface/Run3ScoutingTrack.h"
0026 #include "DataFormats/Scouting/interface/Run3ScoutingVertex.h"
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 #include "FWCore/Framework/interface/global/EDProducer.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0034 #include "FWCore/Utilities/interface/EDPutToken.h"
0035 #include "FWCore/Utilities/interface/Exception.h"
0036 #include "FWCore/Utilities/interface/StreamID.h"
0037 
0038 #include <memory>
0039 #include <utility>
0040 #include <vector>
0041 
0042 namespace edmtest {
0043 
0044   class TestWriteRun3Scouting : public edm::global::EDProducer<> {
0045   public:
0046     TestWriteRun3Scouting(edm::ParameterSet const&);
0047     void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
0048     static void fillDescriptions(edm::ConfigurationDescriptions&);
0049 
0050   private:
0051     void produceCaloJets(edm::Event&) const;
0052     void produceElectrons(edm::Event&) const;
0053     void produceMuons(edm::Event&) const;
0054     void produceParticles(edm::Event&) const;
0055     void producePFJets(edm::Event&) const;
0056     void producePhotons(edm::Event&) const;
0057     void produceTracks(edm::Event&) const;
0058     void produceVertexes(edm::Event&) const;
0059 
0060     void throwWithMessage(const char*) const;
0061 
0062     const std::vector<double> caloJetsValues_;
0063     const edm::EDPutTokenT<std::vector<Run3ScoutingCaloJet>> caloJetsPutToken_;
0064 
0065     const std::vector<double> electronsFloatingPointValues_;
0066     const std::vector<int> electronsIntegralValues_;
0067     const edm::EDPutTokenT<std::vector<Run3ScoutingElectron>> electronsPutToken_;
0068 
0069     const std::vector<double> muonsFloatingPointValues_;
0070     const std::vector<int> muonsIntegralValues_;
0071     const edm::EDPutTokenT<std::vector<Run3ScoutingMuon>> muonsPutToken_;
0072 
0073     const std::vector<double> particlesFloatingPointValues_;
0074     const std::vector<int> particlesIntegralValues_;
0075     const edm::EDPutTokenT<std::vector<Run3ScoutingParticle>> particlesPutToken_;
0076 
0077     const std::vector<double> pfJetsFloatingPointValues_;
0078     const std::vector<int> pfJetsIntegralValues_;
0079     const edm::EDPutTokenT<std::vector<Run3ScoutingPFJet>> pfJetsPutToken_;
0080 
0081     const std::vector<double> photonsFloatingPointValues_;
0082     const std::vector<int> photonsIntegralValues_;
0083     const edm::EDPutTokenT<std::vector<Run3ScoutingPhoton>> photonsPutToken_;
0084 
0085     const std::vector<double> tracksFloatingPointValues_;
0086     const std::vector<int> tracksIntegralValues_;
0087     const edm::EDPutTokenT<std::vector<Run3ScoutingTrack>> tracksPutToken_;
0088 
0089     const std::vector<double> vertexesFloatingPointValues_;
0090     const std::vector<int> vertexesIntegralValues_;
0091     const edm::EDPutTokenT<std::vector<Run3ScoutingVertex>> vertexesPutToken_;
0092   };
0093 
0094   TestWriteRun3Scouting::TestWriteRun3Scouting(edm::ParameterSet const& iPSet)
0095       : caloJetsValues_(iPSet.getParameter<std::vector<double>>("caloJetsValues")),
0096         caloJetsPutToken_(produces()),
0097         electronsFloatingPointValues_(iPSet.getParameter<std::vector<double>>("electronsFloatingPointValues")),
0098         electronsIntegralValues_(iPSet.getParameter<std::vector<int>>("electronsIntegralValues")),
0099         electronsPutToken_(produces()),
0100         muonsFloatingPointValues_(iPSet.getParameter<std::vector<double>>("muonsFloatingPointValues")),
0101         muonsIntegralValues_(iPSet.getParameter<std::vector<int>>("muonsIntegralValues")),
0102         muonsPutToken_(produces()),
0103         particlesFloatingPointValues_(iPSet.getParameter<std::vector<double>>("particlesFloatingPointValues")),
0104         particlesIntegralValues_(iPSet.getParameter<std::vector<int>>("particlesIntegralValues")),
0105         particlesPutToken_(produces()),
0106         pfJetsFloatingPointValues_(iPSet.getParameter<std::vector<double>>("pfJetsFloatingPointValues")),
0107         pfJetsIntegralValues_(iPSet.getParameter<std::vector<int>>("pfJetsIntegralValues")),
0108         pfJetsPutToken_(produces()),
0109         photonsFloatingPointValues_(iPSet.getParameter<std::vector<double>>("photonsFloatingPointValues")),
0110         photonsIntegralValues_(iPSet.getParameter<std::vector<int>>("photonsIntegralValues")),
0111         photonsPutToken_(produces()),
0112         tracksFloatingPointValues_(iPSet.getParameter<std::vector<double>>("tracksFloatingPointValues")),
0113         tracksIntegralValues_(iPSet.getParameter<std::vector<int>>("tracksIntegralValues")),
0114         tracksPutToken_(produces()),
0115         vertexesFloatingPointValues_(iPSet.getParameter<std::vector<double>>("vertexesFloatingPointValues")),
0116         vertexesIntegralValues_(iPSet.getParameter<std::vector<int>>("vertexesIntegralValues")),
0117         vertexesPutToken_(produces()) {
0118     if (caloJetsValues_.size() != 16) {
0119       throwWithMessage("caloJetsValues must have 16 elements and it does not");
0120     }
0121     if (electronsFloatingPointValues_.size() != 25) {
0122       throwWithMessage("electronsFloatingPointValues must have 25 elements and it does not");
0123     }
0124     if (electronsIntegralValues_.size() != 6) {
0125       throwWithMessage("electronsIntegralValues must have 6 elements and it does not");
0126     }
0127     if (muonsFloatingPointValues_.size() != 37) {
0128       throwWithMessage("muonsFloatingPointValues must have 37 elements and it does not");
0129     }
0130     if (muonsIntegralValues_.size() != 26) {
0131       throwWithMessage("muonsIntegralValues must have 26 elements and it does not");
0132     }
0133     if (particlesFloatingPointValues_.size() != 11) {
0134       throwWithMessage("particlesFloatingPointValues must have 11 elements and it does not");
0135     }
0136     if (particlesIntegralValues_.size() != 5) {
0137       throwWithMessage("particlesIntegralValues must have 5 elements and it does not");
0138     }
0139     if (pfJetsFloatingPointValues_.size() != 15) {
0140       throwWithMessage("pfJetsFloatingPointValues must have 15 elements and it does not");
0141     }
0142     if (pfJetsIntegralValues_.size() != 8) {
0143       throwWithMessage("pfJetsIntegralValues must have 8 elements and it does not");
0144     }
0145     if (photonsFloatingPointValues_.size() != 14) {
0146       throwWithMessage("photonsFloatingPointValues must have 14 elements and it does not");
0147     }
0148     if (photonsIntegralValues_.size() != 3) {
0149       throwWithMessage("photonsIntegralValues must have 3 elements and it does not");
0150     }
0151     if (tracksFloatingPointValues_.size() != 29) {
0152       throwWithMessage("tracksFloatingPointValues must have 29 elements and it does not");
0153     }
0154     if (tracksIntegralValues_.size() != 5) {
0155       throwWithMessage("tracksIntegralValues must have 5 elements and it does not");
0156     }
0157     if (vertexesFloatingPointValues_.size() != 7) {
0158       throwWithMessage("vertexesFloatingPointValues must have 7 elements and it does not");
0159     }
0160     if (vertexesIntegralValues_.size() != 3) {
0161       throwWithMessage("vertexesIntegralValues must have 3 elements and it does not");
0162     }
0163   }
0164 
0165   void TestWriteRun3Scouting::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const {
0166     // Fill Run3 scouting objects. Make sure all the containers inside
0167     // of them have something in them (not empty). The values are meaningless.
0168     // We will later check that after writing these objects to persistent storage
0169     // and then reading them in a later process we obtain matching values for
0170     // all this content.
0171 
0172     produceCaloJets(iEvent);
0173     produceElectrons(iEvent);
0174     produceMuons(iEvent);
0175     produceParticles(iEvent);
0176     producePFJets(iEvent);
0177     producePhotons(iEvent);
0178     produceTracks(iEvent);
0179     produceVertexes(iEvent);
0180   }
0181 
0182   void TestWriteRun3Scouting::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0183     edm::ParameterSetDescription desc;
0184     desc.add<std::vector<double>>("caloJetsValues");
0185     desc.add<std::vector<double>>("electronsFloatingPointValues");
0186     desc.add<std::vector<int>>("electronsIntegralValues");
0187     desc.add<std::vector<double>>("muonsFloatingPointValues");
0188     desc.add<std::vector<int>>("muonsIntegralValues");
0189     desc.add<std::vector<double>>("particlesFloatingPointValues");
0190     desc.add<std::vector<int>>("particlesIntegralValues");
0191     desc.add<std::vector<double>>("pfJetsFloatingPointValues");
0192     desc.add<std::vector<int>>("pfJetsIntegralValues");
0193     desc.add<std::vector<double>>("photonsFloatingPointValues");
0194     desc.add<std::vector<int>>("photonsIntegralValues");
0195     desc.add<std::vector<double>>("tracksFloatingPointValues");
0196     desc.add<std::vector<int>>("tracksIntegralValues");
0197     desc.add<std::vector<double>>("vertexesFloatingPointValues");
0198     desc.add<std::vector<int>>("vertexesIntegralValues");
0199     descriptions.addDefault(desc);
0200   }
0201 
0202   void TestWriteRun3Scouting::produceCaloJets(edm::Event& iEvent) const {
0203     auto run3ScoutingCaloJets = std::make_unique<std::vector<Run3ScoutingCaloJet>>();
0204     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0205     run3ScoutingCaloJets->reserve(vectorSize);
0206     for (unsigned int i = 0; i < vectorSize; ++i) {
0207       double offset = static_cast<double>(iEvent.id().event() + i);
0208       run3ScoutingCaloJets->emplace_back(static_cast<float>(caloJetsValues_[0] + offset),
0209                                          static_cast<float>(caloJetsValues_[1] + offset),
0210                                          static_cast<float>(caloJetsValues_[2] + offset),
0211                                          static_cast<float>(caloJetsValues_[3] + offset),
0212                                          static_cast<float>(caloJetsValues_[4] + offset),
0213                                          static_cast<float>(caloJetsValues_[5] + offset),
0214                                          static_cast<float>(caloJetsValues_[6] + offset),
0215                                          static_cast<float>(caloJetsValues_[7] + offset),
0216                                          static_cast<float>(caloJetsValues_[8] + offset),
0217                                          static_cast<float>(caloJetsValues_[9] + offset),
0218                                          static_cast<float>(caloJetsValues_[10] + offset),
0219                                          static_cast<float>(caloJetsValues_[11] + offset),
0220                                          static_cast<float>(caloJetsValues_[12] + offset),
0221                                          static_cast<float>(caloJetsValues_[13] + offset),
0222                                          static_cast<float>(caloJetsValues_[14] + offset),
0223                                          static_cast<float>(caloJetsValues_[15] + offset));
0224     }
0225     iEvent.put(caloJetsPutToken_, std::move(run3ScoutingCaloJets));
0226   }
0227 
0228   void TestWriteRun3Scouting::produceElectrons(edm::Event& iEvent) const {
0229     auto run3ScoutingElectrons = std::make_unique<std::vector<Run3ScoutingElectron>>();
0230     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0231     run3ScoutingElectrons->reserve(vectorSize);
0232     for (unsigned int i = 0; i < vectorSize; ++i) {
0233       double offset = static_cast<double>(iEvent.id().event() + i);
0234       int iOffset = static_cast<int>(iEvent.id().event() + i);
0235 
0236       // Note the first seven of these vectors use an out of sequence index
0237       // (starting at 19 or 5) because they are data members added in a format
0238       // change. In the CMSSW_12_4_0 version, they didn't exist.
0239       // Also the index values 4 and 5 in electronsFloatingPointValues_
0240       // and index 1 in electronsIntegralValues_ are not used because
0241       // those data members were dropped in the same format change.
0242       std::vector<float> trkd0;
0243       std::vector<float> trkdz;
0244       std::vector<float> trkpt;
0245       std::vector<float> trketa;
0246       std::vector<float> trkphi;
0247       std::vector<float> trkchi2overndf;
0248       std::vector<int> trkcharge;
0249       std::vector<float> energyMatrix;
0250       std::vector<unsigned int> detIds;
0251       std::vector<float> timingMatrix;
0252       trkd0.reserve(vectorSize);
0253       trkdz.reserve(vectorSize);
0254       trkpt.reserve(vectorSize);
0255       trketa.reserve(vectorSize);
0256       trkphi.reserve(vectorSize);
0257       trkchi2overndf.reserve(vectorSize);
0258       trkcharge.reserve(vectorSize);
0259       energyMatrix.reserve(vectorSize);
0260       detIds.reserve(vectorSize);
0261       timingMatrix.reserve(vectorSize);
0262       for (unsigned int j = 0; j < vectorSize; ++j) {
0263         trkd0.push_back(static_cast<float>(electronsFloatingPointValues_[19] + offset + j * 10));
0264         trkdz.push_back(static_cast<float>(electronsFloatingPointValues_[20] + offset + j * 10));
0265         trkpt.push_back(static_cast<float>(electronsFloatingPointValues_[21] + offset + j * 10));
0266         trketa.push_back(static_cast<float>(electronsFloatingPointValues_[22] + offset + j * 10));
0267         trkphi.push_back(static_cast<float>(electronsFloatingPointValues_[23] + offset + j * 10));
0268         trkchi2overndf.push_back(static_cast<float>(electronsFloatingPointValues_[24] + offset + j * 10));
0269         trkcharge.push_back(static_cast<int>(electronsIntegralValues_[5] + offset + j * 10));
0270         energyMatrix.push_back(static_cast<float>(electronsFloatingPointValues_[17] + offset + j * 10));
0271         detIds.push_back(static_cast<uint32_t>(electronsIntegralValues_[3] + iOffset + j * 10));
0272         timingMatrix.push_back(static_cast<float>(electronsFloatingPointValues_[18] + offset + j * 10));
0273       }
0274       run3ScoutingElectrons->emplace_back(static_cast<float>(electronsFloatingPointValues_[0] + offset),
0275                                           static_cast<float>(electronsFloatingPointValues_[1] + offset),
0276                                           static_cast<float>(electronsFloatingPointValues_[2] + offset),
0277                                           static_cast<float>(electronsFloatingPointValues_[3] + offset),
0278                                           std::move(trkd0),
0279                                           std::move(trkdz),
0280                                           std::move(trkpt),
0281                                           std::move(trketa),
0282                                           std::move(trkphi),
0283                                           std::move(trkchi2overndf),
0284                                           static_cast<float>(electronsFloatingPointValues_[6] + offset),
0285                                           static_cast<float>(electronsFloatingPointValues_[7] + offset),
0286                                           static_cast<float>(electronsFloatingPointValues_[8] + offset),
0287                                           static_cast<float>(electronsFloatingPointValues_[9] + offset),
0288                                           static_cast<float>(electronsFloatingPointValues_[10] + offset),
0289                                           electronsIntegralValues_[0] + iOffset,
0290                                           std::move(trkcharge),
0291                                           static_cast<float>(electronsFloatingPointValues_[11] + offset),
0292                                           static_cast<float>(electronsFloatingPointValues_[12] + offset),
0293                                           static_cast<float>(electronsFloatingPointValues_[13] + offset),
0294                                           static_cast<float>(electronsFloatingPointValues_[14] + offset),
0295                                           static_cast<float>(electronsFloatingPointValues_[15] + offset),
0296                                           static_cast<float>(electronsFloatingPointValues_[16] + offset),
0297                                           static_cast<uint32_t>(electronsIntegralValues_[2] + iOffset),
0298                                           std::move(energyMatrix),
0299                                           std::move(detIds),
0300                                           std::move(timingMatrix),
0301                                           static_cast<bool>((electronsIntegralValues_[4] + iOffset) % 2));
0302     }
0303     iEvent.put(electronsPutToken_, std::move(run3ScoutingElectrons));
0304   }
0305 
0306   void TestWriteRun3Scouting::produceMuons(edm::Event& iEvent) const {
0307     auto run3ScoutingMuons = std::make_unique<std::vector<Run3ScoutingMuon>>();
0308     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0309     run3ScoutingMuons->reserve(vectorSize);
0310     for (unsigned int i = 0; i < vectorSize; ++i) {
0311       double offset = static_cast<double>(iEvent.id().event() + i);
0312       int iOffset = static_cast<int>(iEvent.id().event() + i);
0313 
0314       std::vector<int> vtxIndx;
0315       std::vector<uint16_t> hitPattern;
0316       vtxIndx.reserve(vectorSize);
0317       hitPattern.reserve(vectorSize);
0318       for (unsigned int j = 0; j < vectorSize; ++j) {
0319         vtxIndx.push_back(static_cast<int>(muonsIntegralValues_[17] + iOffset + j * 10));
0320         hitPattern.push_back(static_cast<uint16_t>(muonsIntegralValues_[25] + iOffset + j * 10));
0321       }
0322 
0323       Run3ScoutingHitPatternPOD run3ScoutingHitPatternPOD;
0324       run3ScoutingHitPatternPOD.hitCount = static_cast<uint8_t>(muonsIntegralValues_[18] + iOffset);
0325       run3ScoutingHitPatternPOD.beginTrackHits = static_cast<uint8_t>(muonsIntegralValues_[19] + iOffset);
0326       run3ScoutingHitPatternPOD.endTrackHits = static_cast<uint8_t>(muonsIntegralValues_[20] + iOffset);
0327       run3ScoutingHitPatternPOD.beginInner = static_cast<uint8_t>(muonsIntegralValues_[21] + iOffset);
0328       run3ScoutingHitPatternPOD.endInner = static_cast<uint8_t>(muonsIntegralValues_[22] + iOffset);
0329       run3ScoutingHitPatternPOD.beginOuter = static_cast<uint8_t>(muonsIntegralValues_[23] + iOffset);
0330       run3ScoutingHitPatternPOD.endOuter = static_cast<uint8_t>(muonsIntegralValues_[24] + iOffset);
0331       run3ScoutingHitPatternPOD.hitPattern = std::move(hitPattern);
0332 
0333       run3ScoutingMuons->emplace_back(static_cast<float>(muonsFloatingPointValues_[0] + offset),
0334                                       static_cast<float>(muonsFloatingPointValues_[1] + offset),
0335                                       static_cast<float>(muonsFloatingPointValues_[2] + offset),
0336                                       static_cast<float>(muonsFloatingPointValues_[3] + offset),
0337                                       static_cast<unsigned int>(muonsIntegralValues_[0] + iOffset),
0338                                       muonsIntegralValues_[1] + iOffset,
0339                                       static_cast<float>(muonsFloatingPointValues_[4] + offset),
0340                                       static_cast<float>(muonsFloatingPointValues_[5] + offset),
0341                                       static_cast<float>(muonsFloatingPointValues_[6] + offset),
0342                                       static_cast<float>(muonsFloatingPointValues_[7] + offset),
0343                                       muonsIntegralValues_[2] + iOffset,
0344                                       muonsIntegralValues_[3] + iOffset,
0345                                       muonsIntegralValues_[4] + iOffset,
0346                                       muonsIntegralValues_[5] + iOffset,
0347                                       muonsIntegralValues_[6] + iOffset,
0348                                       muonsIntegralValues_[7] + iOffset,
0349                                       muonsIntegralValues_[8] + iOffset,
0350                                       static_cast<unsigned int>(muonsIntegralValues_[9] + iOffset),
0351                                       static_cast<unsigned int>(muonsIntegralValues_[10] + iOffset),
0352                                       muonsIntegralValues_[11] + iOffset,
0353                                       static_cast<unsigned int>(muonsIntegralValues_[12] + iOffset),
0354                                       muonsIntegralValues_[13] + iOffset,
0355                                       muonsIntegralValues_[14] + iOffset,
0356                                       muonsIntegralValues_[15] + iOffset,
0357                                       muonsIntegralValues_[16] + iOffset,
0358                                       static_cast<float>(muonsFloatingPointValues_[8] + offset),
0359                                       static_cast<float>(muonsFloatingPointValues_[9] + offset),
0360                                       static_cast<float>(muonsFloatingPointValues_[10] + offset),
0361                                       static_cast<float>(muonsFloatingPointValues_[11] + offset),
0362                                       static_cast<float>(muonsFloatingPointValues_[12] + offset),
0363                                       static_cast<float>(muonsFloatingPointValues_[13] + offset),
0364                                       static_cast<float>(muonsFloatingPointValues_[14] + offset),
0365                                       static_cast<float>(muonsFloatingPointValues_[15] + offset),
0366                                       static_cast<float>(muonsFloatingPointValues_[16] + offset),
0367                                       static_cast<float>(muonsFloatingPointValues_[17] + offset),
0368                                       static_cast<float>(muonsFloatingPointValues_[18] + offset),
0369                                       static_cast<float>(muonsFloatingPointValues_[19] + offset),
0370                                       static_cast<float>(muonsFloatingPointValues_[20] + offset),
0371                                       static_cast<float>(muonsFloatingPointValues_[21] + offset),
0372                                       static_cast<float>(muonsFloatingPointValues_[22] + offset),
0373                                       static_cast<float>(muonsFloatingPointValues_[23] + offset),
0374                                       static_cast<float>(muonsFloatingPointValues_[24] + offset),
0375                                       static_cast<float>(muonsFloatingPointValues_[25] + offset),
0376                                       static_cast<float>(muonsFloatingPointValues_[26] + offset),
0377                                       static_cast<float>(muonsFloatingPointValues_[27] + offset),
0378                                       static_cast<float>(muonsFloatingPointValues_[28] + offset),
0379                                       static_cast<float>(muonsFloatingPointValues_[29] + offset),
0380                                       static_cast<float>(muonsFloatingPointValues_[30] + offset),
0381                                       static_cast<float>(muonsFloatingPointValues_[31] + offset),
0382                                       static_cast<float>(muonsFloatingPointValues_[32] + offset),
0383                                       static_cast<float>(muonsFloatingPointValues_[33] + offset),
0384                                       static_cast<float>(muonsFloatingPointValues_[34] + offset),
0385                                       static_cast<float>(muonsFloatingPointValues_[35] + offset),
0386                                       static_cast<float>(muonsFloatingPointValues_[36] + offset),
0387                                       std::move(vtxIndx),
0388                                       std::move(run3ScoutingHitPatternPOD));
0389     }
0390     iEvent.put(muonsPutToken_, std::move(run3ScoutingMuons));
0391   }
0392 
0393   void TestWriteRun3Scouting::produceParticles(edm::Event& iEvent) const {
0394     auto run3ScoutingParticles = std::make_unique<std::vector<Run3ScoutingParticle>>();
0395     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0396     run3ScoutingParticles->reserve(vectorSize);
0397     for (unsigned int i = 0; i < vectorSize; ++i) {
0398       double offset = static_cast<double>(iEvent.id().event() + i);
0399       int iOffset = static_cast<int>(iEvent.id().event() + i);
0400       run3ScoutingParticles->emplace_back(static_cast<float>(particlesFloatingPointValues_[0] + offset),
0401                                           static_cast<float>(particlesFloatingPointValues_[1] + offset),
0402                                           static_cast<float>(particlesFloatingPointValues_[2] + offset),
0403                                           particlesIntegralValues_[0] + iOffset,
0404                                           particlesIntegralValues_[1] + iOffset,
0405                                           static_cast<float>(particlesFloatingPointValues_[3] + offset),
0406                                           static_cast<float>(particlesFloatingPointValues_[4] + offset),
0407                                           static_cast<float>(particlesFloatingPointValues_[5] + offset),
0408                                           static_cast<float>(particlesFloatingPointValues_[6] + offset),
0409                                           static_cast<float>(particlesFloatingPointValues_[7] + offset),
0410                                           static_cast<uint8_t>(particlesIntegralValues_[2] + iOffset),
0411                                           static_cast<uint8_t>(particlesIntegralValues_[3] + iOffset),
0412                                           static_cast<float>(particlesFloatingPointValues_[8] + offset),
0413                                           static_cast<float>(particlesFloatingPointValues_[9] + offset),
0414                                           static_cast<float>(particlesFloatingPointValues_[10] + offset),
0415                                           static_cast<bool>((particlesIntegralValues_[4] + iOffset) % 2));
0416     }
0417     iEvent.put(particlesPutToken_, std::move(run3ScoutingParticles));
0418   }
0419 
0420   void TestWriteRun3Scouting::producePFJets(edm::Event& iEvent) const {
0421     auto run3ScoutingPFJets = std::make_unique<std::vector<Run3ScoutingPFJet>>();
0422     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0423     run3ScoutingPFJets->reserve(vectorSize);
0424 
0425     for (unsigned int i = 0; i < vectorSize; ++i) {
0426       double offset = static_cast<double>(iEvent.id().event() + i);
0427       int iOffset = static_cast<int>(iEvent.id().event() + i);
0428 
0429       std::vector<int> constituents;
0430       constituents.reserve(vectorSize);
0431       for (unsigned int j = 0; j < vectorSize; ++j) {
0432         constituents.push_back(static_cast<int>(pfJetsIntegralValues_[7] + iOffset + j * 10));
0433       }
0434 
0435       run3ScoutingPFJets->emplace_back(static_cast<float>(pfJetsFloatingPointValues_[0] + offset),
0436                                        static_cast<float>(pfJetsFloatingPointValues_[1] + offset),
0437                                        static_cast<float>(pfJetsFloatingPointValues_[2] + offset),
0438                                        static_cast<float>(pfJetsFloatingPointValues_[3] + offset),
0439                                        static_cast<float>(pfJetsFloatingPointValues_[4] + offset),
0440                                        static_cast<float>(pfJetsFloatingPointValues_[5] + offset),
0441                                        static_cast<float>(pfJetsFloatingPointValues_[6] + offset),
0442                                        static_cast<float>(pfJetsFloatingPointValues_[7] + offset),
0443                                        static_cast<float>(pfJetsFloatingPointValues_[8] + offset),
0444                                        static_cast<float>(pfJetsFloatingPointValues_[9] + offset),
0445                                        static_cast<float>(pfJetsFloatingPointValues_[10] + offset),
0446                                        static_cast<float>(pfJetsFloatingPointValues_[11] + offset),
0447                                        pfJetsIntegralValues_[0] + iOffset,
0448                                        pfJetsIntegralValues_[1] + iOffset,
0449                                        pfJetsIntegralValues_[2] + iOffset,
0450                                        pfJetsIntegralValues_[3] + iOffset,
0451                                        pfJetsIntegralValues_[4] + iOffset,
0452                                        pfJetsIntegralValues_[5] + iOffset,
0453                                        pfJetsIntegralValues_[6] + iOffset,
0454                                        static_cast<float>(pfJetsFloatingPointValues_[12] + offset),
0455                                        static_cast<float>(pfJetsFloatingPointValues_[13] + offset),
0456                                        static_cast<float>(pfJetsFloatingPointValues_[14] + offset),
0457                                        std::move(constituents));
0458     }
0459     iEvent.put(pfJetsPutToken_, std::move(run3ScoutingPFJets));
0460   }
0461 
0462   void TestWriteRun3Scouting::producePhotons(edm::Event& iEvent) const {
0463     auto run3ScoutingPhotons = std::make_unique<std::vector<Run3ScoutingPhoton>>();
0464     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0465     run3ScoutingPhotons->reserve(vectorSize);
0466     for (unsigned int i = 0; i < vectorSize; ++i) {
0467       double offset = static_cast<double>(iEvent.id().event() + i);
0468       int iOffset = static_cast<int>(iEvent.id().event() + i);
0469 
0470       std::vector<float> energyMatrix;
0471       std::vector<uint32_t> detIds;
0472       std::vector<float> timingMatrix;
0473       energyMatrix.reserve(vectorSize);
0474       detIds.reserve(vectorSize);
0475       timingMatrix.reserve(vectorSize);
0476       for (unsigned int j = 0; j < vectorSize; ++j) {
0477         energyMatrix.push_back(static_cast<float>(photonsFloatingPointValues_[12] + offset + j * 10));
0478         detIds.push_back(static_cast<uint32_t>(photonsIntegralValues_[1] + iOffset + j * 10));
0479         timingMatrix.push_back(static_cast<float>(photonsFloatingPointValues_[13] + offset + j * 10));
0480       }
0481       run3ScoutingPhotons->emplace_back(static_cast<float>(photonsFloatingPointValues_[0] + offset),
0482                                         static_cast<float>(photonsFloatingPointValues_[1] + offset),
0483                                         static_cast<float>(photonsFloatingPointValues_[2] + offset),
0484                                         static_cast<float>(photonsFloatingPointValues_[3] + offset),
0485                                         static_cast<float>(photonsFloatingPointValues_[4] + offset),
0486                                         static_cast<float>(photonsFloatingPointValues_[5] + offset),
0487                                         static_cast<float>(photonsFloatingPointValues_[6] + offset),
0488                                         static_cast<float>(photonsFloatingPointValues_[7] + offset),
0489                                         static_cast<float>(photonsFloatingPointValues_[8] + offset),
0490                                         static_cast<float>(photonsFloatingPointValues_[9] + offset),
0491                                         static_cast<float>(photonsFloatingPointValues_[10] + offset),
0492                                         static_cast<float>(photonsFloatingPointValues_[11] + offset),
0493                                         static_cast<uint32_t>(photonsIntegralValues_[0] + iOffset),
0494                                         std::move(energyMatrix),
0495                                         std::move(detIds),
0496                                         std::move(timingMatrix),
0497                                         static_cast<bool>((photonsIntegralValues_[2] + iOffset) % 2));
0498     }
0499     iEvent.put(photonsPutToken_, std::move(run3ScoutingPhotons));
0500   }
0501 
0502   void TestWriteRun3Scouting::produceTracks(edm::Event& iEvent) const {
0503     auto run3ScoutingTracks = std::make_unique<std::vector<Run3ScoutingTrack>>();
0504     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0505     run3ScoutingTracks->reserve(vectorSize);
0506 
0507     for (unsigned int i = 0; i < vectorSize; ++i) {
0508       double offset = static_cast<double>(iEvent.id().event() + i);
0509       int iOffset = static_cast<int>(iEvent.id().event() + i);
0510 
0511       run3ScoutingTracks->emplace_back(static_cast<float>(tracksFloatingPointValues_[0] + offset),
0512                                        static_cast<float>(tracksFloatingPointValues_[1] + offset),
0513                                        static_cast<float>(tracksFloatingPointValues_[2] + offset),
0514                                        static_cast<float>(tracksFloatingPointValues_[3] + offset),
0515                                        static_cast<float>(tracksFloatingPointValues_[4] + offset),
0516                                        tracksIntegralValues_[0] + iOffset,
0517                                        static_cast<float>(tracksFloatingPointValues_[5] + offset),
0518                                        static_cast<float>(tracksFloatingPointValues_[6] + offset),
0519                                        tracksIntegralValues_[1] + iOffset,
0520                                        tracksIntegralValues_[2] + iOffset,
0521                                        tracksIntegralValues_[3] + iOffset,
0522                                        static_cast<float>(tracksFloatingPointValues_[7] + offset),
0523                                        static_cast<float>(tracksFloatingPointValues_[8] + offset),
0524                                        static_cast<float>(tracksFloatingPointValues_[9] + offset),
0525                                        static_cast<float>(tracksFloatingPointValues_[10] + offset),
0526                                        static_cast<float>(tracksFloatingPointValues_[11] + offset),
0527                                        static_cast<float>(tracksFloatingPointValues_[12] + offset),
0528                                        static_cast<float>(tracksFloatingPointValues_[13] + offset),
0529                                        static_cast<float>(tracksFloatingPointValues_[14] + offset),
0530                                        static_cast<float>(tracksFloatingPointValues_[15] + offset),
0531                                        static_cast<float>(tracksFloatingPointValues_[16] + offset),
0532                                        static_cast<float>(tracksFloatingPointValues_[17] + offset),
0533                                        static_cast<float>(tracksFloatingPointValues_[18] + offset),
0534                                        static_cast<float>(tracksFloatingPointValues_[19] + offset),
0535                                        static_cast<float>(tracksFloatingPointValues_[20] + offset),
0536                                        static_cast<float>(tracksFloatingPointValues_[21] + offset),
0537                                        static_cast<float>(tracksFloatingPointValues_[22] + offset),
0538                                        static_cast<float>(tracksFloatingPointValues_[23] + offset),
0539                                        static_cast<float>(tracksFloatingPointValues_[24] + offset),
0540                                        static_cast<float>(tracksFloatingPointValues_[25] + offset),
0541                                        tracksIntegralValues_[4] + iOffset,
0542                                        static_cast<float>(tracksFloatingPointValues_[26] + offset),
0543                                        static_cast<float>(tracksFloatingPointValues_[27] + offset),
0544                                        static_cast<float>(tracksFloatingPointValues_[28] + offset));
0545     }
0546     iEvent.put(tracksPutToken_, std::move(run3ScoutingTracks));
0547   }
0548 
0549   void TestWriteRun3Scouting::produceVertexes(edm::Event& iEvent) const {
0550     auto run3ScoutingVertexes = std::make_unique<std::vector<Run3ScoutingVertex>>();
0551     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0552     run3ScoutingVertexes->reserve(vectorSize);
0553 
0554     for (unsigned int i = 0; i < vectorSize; ++i) {
0555       double offset = static_cast<double>(iEvent.id().event() + i);
0556       int iOffset = static_cast<int>(iEvent.id().event() + i);
0557 
0558       run3ScoutingVertexes->emplace_back(static_cast<float>(vertexesFloatingPointValues_[0] + offset),
0559                                          static_cast<float>(vertexesFloatingPointValues_[1] + offset),
0560                                          static_cast<float>(vertexesFloatingPointValues_[2] + offset),
0561                                          static_cast<float>(vertexesFloatingPointValues_[3] + offset),
0562                                          static_cast<float>(vertexesFloatingPointValues_[4] + offset),
0563                                          static_cast<float>(vertexesFloatingPointValues_[5] + offset),
0564                                          vertexesIntegralValues_[0] + iOffset,
0565                                          static_cast<float>(vertexesFloatingPointValues_[6] + offset),
0566                                          vertexesIntegralValues_[1] + iOffset,
0567                                          static_cast<bool>((vertexesIntegralValues_[2] + iOffset) % 2));
0568     }
0569     iEvent.put(vertexesPutToken_, std::move(run3ScoutingVertexes));
0570   }
0571 
0572   void TestWriteRun3Scouting::throwWithMessage(const char* msg) const {
0573     throw cms::Exception("TestFailure") << "TestWriteRun3Scouting constructor, test configuration error, " << msg;
0574   }
0575 
0576 }  // namespace edmtest
0577 
0578 using edmtest::TestWriteRun3Scouting;
0579 DEFINE_FWK_MODULE(TestWriteRun3Scouting);