Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:11

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() != 33) {
0122       throwWithMessage("electronsFloatingPointValues must have 33 elements and it does not");
0123     }
0124     if (electronsIntegralValues_.size() != 8) {
0125       throwWithMessage("electronsIntegralValues must have 8 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() != 17) {
0146       throwWithMessage("photonsFloatingPointValues must have 17 elements and it does not");
0147     }
0148     if (photonsIntegralValues_.size() != 5) {
0149       throwWithMessage("photonsIntegralValues must have 5 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() != 10) {
0158       throwWithMessage("vertexesFloatingPointValues must have 10 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 eleven 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> trkpMode;
0248       std::vector<float> trketaMode;
0249       std::vector<float> trkphiMode;
0250       std::vector<float> trkqoverpModeError;
0251       std::vector<float> trkchi2overndf;
0252       std::vector<int> trkcharge;
0253       std::vector<float> energyMatrix;
0254       std::vector<unsigned int> detIds;
0255       std::vector<float> timingMatrix;
0256       trkd0.reserve(vectorSize);
0257       trkdz.reserve(vectorSize);
0258       trkpt.reserve(vectorSize);
0259       trketa.reserve(vectorSize);
0260       trkphi.reserve(vectorSize);
0261       trkpMode.reserve(vectorSize);
0262       trketaMode.reserve(vectorSize);
0263       trkphiMode.reserve(vectorSize);
0264       trkqoverpModeError.reserve(vectorSize);
0265       trkchi2overndf.reserve(vectorSize);
0266       trkcharge.reserve(vectorSize);
0267       energyMatrix.reserve(vectorSize);
0268       detIds.reserve(vectorSize);
0269       timingMatrix.reserve(vectorSize);
0270       for (unsigned int j = 0; j < vectorSize; ++j) {
0271         trkd0.push_back(static_cast<float>(electronsFloatingPointValues_[19] + offset + j * 10));
0272         trkdz.push_back(static_cast<float>(electronsFloatingPointValues_[20] + offset + j * 10));
0273         trkpt.push_back(static_cast<float>(electronsFloatingPointValues_[21] + offset + j * 10));
0274         trketa.push_back(static_cast<float>(electronsFloatingPointValues_[22] + offset + j * 10));
0275         trkphi.push_back(static_cast<float>(electronsFloatingPointValues_[23] + offset + j * 10));
0276         trkpMode.push_back(static_cast<float>(electronsFloatingPointValues_[28] + offset + j * 10));
0277         trketaMode.push_back(static_cast<float>(electronsFloatingPointValues_[29] + offset + j * 10));
0278         trkphiMode.push_back(static_cast<float>(electronsFloatingPointValues_[30] + offset + j * 10));
0279         trkqoverpModeError.push_back(static_cast<float>(electronsFloatingPointValues_[31] + offset + j * 10));
0280         trkchi2overndf.push_back(static_cast<float>(electronsFloatingPointValues_[24] + offset + j * 10));
0281         trkcharge.push_back(static_cast<int>(electronsIntegralValues_[5] + offset + j * 10));
0282         energyMatrix.push_back(static_cast<float>(electronsFloatingPointValues_[17] + offset + j * 10));
0283         detIds.push_back(static_cast<uint32_t>(electronsIntegralValues_[3] + iOffset + j * 10));
0284         timingMatrix.push_back(static_cast<float>(electronsFloatingPointValues_[18] + offset + j * 10));
0285       }
0286       run3ScoutingElectrons->emplace_back(static_cast<float>(electronsFloatingPointValues_[0] + offset),
0287                                           static_cast<float>(electronsFloatingPointValues_[1] + offset),
0288                                           static_cast<float>(electronsFloatingPointValues_[2] + offset),
0289                                           static_cast<float>(electronsFloatingPointValues_[3] + offset),
0290                                           static_cast<float>(electronsFloatingPointValues_[25] + offset),
0291                                           static_cast<float>(electronsFloatingPointValues_[26] + offset),
0292                                           static_cast<float>(electronsFloatingPointValues_[27] + offset),
0293                                           std::move(trkd0),
0294                                           std::move(trkdz),
0295                                           std::move(trkpt),
0296                                           std::move(trketa),
0297                                           std::move(trkphi),
0298                                           std::move(trkpMode),
0299                                           std::move(trketaMode),
0300                                           std::move(trkphiMode),
0301                                           std::move(trkqoverpModeError),
0302                                           std::move(trkchi2overndf),
0303                                           static_cast<float>(electronsFloatingPointValues_[6] + offset),
0304                                           static_cast<float>(electronsFloatingPointValues_[7] + offset),
0305                                           static_cast<float>(electronsFloatingPointValues_[8] + offset),
0306                                           static_cast<float>(electronsFloatingPointValues_[9] + offset),
0307                                           static_cast<float>(electronsFloatingPointValues_[10] + offset),
0308                                           electronsIntegralValues_[0] + iOffset,
0309                                           std::move(trkcharge),
0310                                           static_cast<float>(electronsFloatingPointValues_[32] + offset),
0311                                           static_cast<float>(electronsFloatingPointValues_[11] + offset),
0312                                           static_cast<float>(electronsFloatingPointValues_[12] + offset),
0313                                           static_cast<float>(electronsFloatingPointValues_[13] + offset),
0314                                           static_cast<float>(electronsFloatingPointValues_[14] + offset),
0315                                           static_cast<float>(electronsFloatingPointValues_[15] + offset),
0316                                           static_cast<float>(electronsFloatingPointValues_[16] + offset),
0317                                           static_cast<uint32_t>(electronsIntegralValues_[2] + iOffset),
0318                                           static_cast<uint32_t>(electronsIntegralValues_[6] + iOffset),
0319                                           static_cast<uint32_t>(electronsIntegralValues_[7] + iOffset),
0320                                           std::move(energyMatrix),
0321                                           std::move(detIds),
0322                                           std::move(timingMatrix),
0323                                           static_cast<bool>((electronsIntegralValues_[4] + iOffset) % 2));
0324     }
0325     iEvent.put(electronsPutToken_, std::move(run3ScoutingElectrons));
0326   }
0327 
0328   void TestWriteRun3Scouting::produceMuons(edm::Event& iEvent) const {
0329     auto run3ScoutingMuons = std::make_unique<std::vector<Run3ScoutingMuon>>();
0330     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0331     run3ScoutingMuons->reserve(vectorSize);
0332     for (unsigned int i = 0; i < vectorSize; ++i) {
0333       double offset = static_cast<double>(iEvent.id().event() + i);
0334       int iOffset = static_cast<int>(iEvent.id().event() + i);
0335 
0336       std::vector<int> vtxIndx;
0337       std::vector<uint16_t> hitPattern;
0338       vtxIndx.reserve(vectorSize);
0339       hitPattern.reserve(vectorSize);
0340       for (unsigned int j = 0; j < vectorSize; ++j) {
0341         vtxIndx.push_back(static_cast<int>(muonsIntegralValues_[17] + iOffset + j * 10));
0342         hitPattern.push_back(static_cast<uint16_t>(muonsIntegralValues_[25] + iOffset + j * 10));
0343       }
0344 
0345       Run3ScoutingHitPatternPOD run3ScoutingHitPatternPOD;
0346       run3ScoutingHitPatternPOD.hitCount = static_cast<uint8_t>(muonsIntegralValues_[18] + iOffset);
0347       run3ScoutingHitPatternPOD.beginTrackHits = static_cast<uint8_t>(muonsIntegralValues_[19] + iOffset);
0348       run3ScoutingHitPatternPOD.endTrackHits = static_cast<uint8_t>(muonsIntegralValues_[20] + iOffset);
0349       run3ScoutingHitPatternPOD.beginInner = static_cast<uint8_t>(muonsIntegralValues_[21] + iOffset);
0350       run3ScoutingHitPatternPOD.endInner = static_cast<uint8_t>(muonsIntegralValues_[22] + iOffset);
0351       run3ScoutingHitPatternPOD.beginOuter = static_cast<uint8_t>(muonsIntegralValues_[23] + iOffset);
0352       run3ScoutingHitPatternPOD.endOuter = static_cast<uint8_t>(muonsIntegralValues_[24] + iOffset);
0353       run3ScoutingHitPatternPOD.hitPattern = std::move(hitPattern);
0354 
0355       run3ScoutingMuons->emplace_back(static_cast<float>(muonsFloatingPointValues_[0] + offset),
0356                                       static_cast<float>(muonsFloatingPointValues_[1] + offset),
0357                                       static_cast<float>(muonsFloatingPointValues_[2] + offset),
0358                                       static_cast<float>(muonsFloatingPointValues_[3] + offset),
0359                                       static_cast<unsigned int>(muonsIntegralValues_[0] + iOffset),
0360                                       muonsIntegralValues_[1] + iOffset,
0361                                       static_cast<float>(muonsFloatingPointValues_[4] + offset),
0362                                       static_cast<float>(muonsFloatingPointValues_[5] + offset),
0363                                       static_cast<float>(muonsFloatingPointValues_[6] + offset),
0364                                       static_cast<float>(muonsFloatingPointValues_[7] + offset),
0365                                       muonsIntegralValues_[2] + iOffset,
0366                                       muonsIntegralValues_[3] + iOffset,
0367                                       muonsIntegralValues_[4] + iOffset,
0368                                       muonsIntegralValues_[5] + iOffset,
0369                                       muonsIntegralValues_[6] + iOffset,
0370                                       muonsIntegralValues_[7] + iOffset,
0371                                       muonsIntegralValues_[8] + iOffset,
0372                                       static_cast<unsigned int>(muonsIntegralValues_[9] + iOffset),
0373                                       static_cast<unsigned int>(muonsIntegralValues_[10] + iOffset),
0374                                       muonsIntegralValues_[11] + iOffset,
0375                                       static_cast<unsigned int>(muonsIntegralValues_[12] + iOffset),
0376                                       muonsIntegralValues_[13] + iOffset,
0377                                       muonsIntegralValues_[14] + iOffset,
0378                                       muonsIntegralValues_[15] + iOffset,
0379                                       muonsIntegralValues_[16] + iOffset,
0380                                       static_cast<float>(muonsFloatingPointValues_[8] + offset),
0381                                       static_cast<float>(muonsFloatingPointValues_[9] + offset),
0382                                       static_cast<float>(muonsFloatingPointValues_[10] + offset),
0383                                       static_cast<float>(muonsFloatingPointValues_[11] + offset),
0384                                       static_cast<float>(muonsFloatingPointValues_[12] + offset),
0385                                       static_cast<float>(muonsFloatingPointValues_[13] + offset),
0386                                       static_cast<float>(muonsFloatingPointValues_[14] + offset),
0387                                       static_cast<float>(muonsFloatingPointValues_[15] + offset),
0388                                       static_cast<float>(muonsFloatingPointValues_[16] + offset),
0389                                       static_cast<float>(muonsFloatingPointValues_[17] + offset),
0390                                       static_cast<float>(muonsFloatingPointValues_[18] + offset),
0391                                       static_cast<float>(muonsFloatingPointValues_[19] + offset),
0392                                       static_cast<float>(muonsFloatingPointValues_[20] + offset),
0393                                       static_cast<float>(muonsFloatingPointValues_[21] + offset),
0394                                       static_cast<float>(muonsFloatingPointValues_[22] + offset),
0395                                       static_cast<float>(muonsFloatingPointValues_[23] + offset),
0396                                       static_cast<float>(muonsFloatingPointValues_[24] + offset),
0397                                       static_cast<float>(muonsFloatingPointValues_[25] + offset),
0398                                       static_cast<float>(muonsFloatingPointValues_[26] + offset),
0399                                       static_cast<float>(muonsFloatingPointValues_[27] + offset),
0400                                       static_cast<float>(muonsFloatingPointValues_[28] + offset),
0401                                       static_cast<float>(muonsFloatingPointValues_[29] + offset),
0402                                       static_cast<float>(muonsFloatingPointValues_[30] + offset),
0403                                       static_cast<float>(muonsFloatingPointValues_[31] + offset),
0404                                       static_cast<float>(muonsFloatingPointValues_[32] + offset),
0405                                       static_cast<float>(muonsFloatingPointValues_[33] + offset),
0406                                       static_cast<float>(muonsFloatingPointValues_[34] + offset),
0407                                       static_cast<float>(muonsFloatingPointValues_[35] + offset),
0408                                       static_cast<float>(muonsFloatingPointValues_[36] + offset),
0409                                       std::move(vtxIndx),
0410                                       std::move(run3ScoutingHitPatternPOD));
0411     }
0412     iEvent.put(muonsPutToken_, std::move(run3ScoutingMuons));
0413   }
0414 
0415   void TestWriteRun3Scouting::produceParticles(edm::Event& iEvent) const {
0416     auto run3ScoutingParticles = std::make_unique<std::vector<Run3ScoutingParticle>>();
0417     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0418     run3ScoutingParticles->reserve(vectorSize);
0419     for (unsigned int i = 0; i < vectorSize; ++i) {
0420       double offset = static_cast<double>(iEvent.id().event() + i);
0421       int iOffset = static_cast<int>(iEvent.id().event() + i);
0422       run3ScoutingParticles->emplace_back(static_cast<float>(particlesFloatingPointValues_[0] + offset),
0423                                           static_cast<float>(particlesFloatingPointValues_[1] + offset),
0424                                           static_cast<float>(particlesFloatingPointValues_[2] + offset),
0425                                           particlesIntegralValues_[0] + iOffset,
0426                                           particlesIntegralValues_[1] + iOffset,
0427                                           static_cast<float>(particlesFloatingPointValues_[3] + offset),
0428                                           static_cast<float>(particlesFloatingPointValues_[4] + offset),
0429                                           static_cast<float>(particlesFloatingPointValues_[5] + offset),
0430                                           static_cast<float>(particlesFloatingPointValues_[6] + offset),
0431                                           static_cast<float>(particlesFloatingPointValues_[7] + offset),
0432                                           static_cast<uint8_t>(particlesIntegralValues_[2] + iOffset),
0433                                           static_cast<uint8_t>(particlesIntegralValues_[3] + iOffset),
0434                                           static_cast<float>(particlesFloatingPointValues_[8] + offset),
0435                                           static_cast<float>(particlesFloatingPointValues_[9] + offset),
0436                                           static_cast<float>(particlesFloatingPointValues_[10] + offset),
0437                                           static_cast<bool>((particlesIntegralValues_[4] + iOffset) % 2));
0438     }
0439     iEvent.put(particlesPutToken_, std::move(run3ScoutingParticles));
0440   }
0441 
0442   void TestWriteRun3Scouting::producePFJets(edm::Event& iEvent) const {
0443     auto run3ScoutingPFJets = std::make_unique<std::vector<Run3ScoutingPFJet>>();
0444     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0445     run3ScoutingPFJets->reserve(vectorSize);
0446 
0447     for (unsigned int i = 0; i < vectorSize; ++i) {
0448       double offset = static_cast<double>(iEvent.id().event() + i);
0449       int iOffset = static_cast<int>(iEvent.id().event() + i);
0450 
0451       std::vector<int> constituents;
0452       constituents.reserve(vectorSize);
0453       for (unsigned int j = 0; j < vectorSize; ++j) {
0454         constituents.push_back(static_cast<int>(pfJetsIntegralValues_[7] + iOffset + j * 10));
0455       }
0456 
0457       run3ScoutingPFJets->emplace_back(static_cast<float>(pfJetsFloatingPointValues_[0] + offset),
0458                                        static_cast<float>(pfJetsFloatingPointValues_[1] + offset),
0459                                        static_cast<float>(pfJetsFloatingPointValues_[2] + offset),
0460                                        static_cast<float>(pfJetsFloatingPointValues_[3] + offset),
0461                                        static_cast<float>(pfJetsFloatingPointValues_[4] + offset),
0462                                        static_cast<float>(pfJetsFloatingPointValues_[5] + offset),
0463                                        static_cast<float>(pfJetsFloatingPointValues_[6] + offset),
0464                                        static_cast<float>(pfJetsFloatingPointValues_[7] + offset),
0465                                        static_cast<float>(pfJetsFloatingPointValues_[8] + offset),
0466                                        static_cast<float>(pfJetsFloatingPointValues_[9] + offset),
0467                                        static_cast<float>(pfJetsFloatingPointValues_[10] + offset),
0468                                        static_cast<float>(pfJetsFloatingPointValues_[11] + offset),
0469                                        pfJetsIntegralValues_[0] + iOffset,
0470                                        pfJetsIntegralValues_[1] + iOffset,
0471                                        pfJetsIntegralValues_[2] + iOffset,
0472                                        pfJetsIntegralValues_[3] + iOffset,
0473                                        pfJetsIntegralValues_[4] + iOffset,
0474                                        pfJetsIntegralValues_[5] + iOffset,
0475                                        pfJetsIntegralValues_[6] + iOffset,
0476                                        static_cast<float>(pfJetsFloatingPointValues_[12] + offset),
0477                                        static_cast<float>(pfJetsFloatingPointValues_[13] + offset),
0478                                        static_cast<float>(pfJetsFloatingPointValues_[14] + offset),
0479                                        std::move(constituents));
0480     }
0481     iEvent.put(pfJetsPutToken_, std::move(run3ScoutingPFJets));
0482   }
0483 
0484   void TestWriteRun3Scouting::producePhotons(edm::Event& iEvent) const {
0485     auto run3ScoutingPhotons = std::make_unique<std::vector<Run3ScoutingPhoton>>();
0486     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0487     run3ScoutingPhotons->reserve(vectorSize);
0488     for (unsigned int i = 0; i < vectorSize; ++i) {
0489       double offset = static_cast<double>(iEvent.id().event() + i);
0490       int iOffset = static_cast<int>(iEvent.id().event() + i);
0491 
0492       std::vector<float> energyMatrix;
0493       std::vector<uint32_t> detIds;
0494       std::vector<float> timingMatrix;
0495       energyMatrix.reserve(vectorSize);
0496       detIds.reserve(vectorSize);
0497       timingMatrix.reserve(vectorSize);
0498       for (unsigned int j = 0; j < vectorSize; ++j) {
0499         energyMatrix.push_back(static_cast<float>(photonsFloatingPointValues_[12] + offset + j * 10));
0500         detIds.push_back(static_cast<uint32_t>(photonsIntegralValues_[1] + iOffset + j * 10));
0501         timingMatrix.push_back(static_cast<float>(photonsFloatingPointValues_[13] + offset + j * 10));
0502       }
0503       run3ScoutingPhotons->emplace_back(static_cast<float>(photonsFloatingPointValues_[0] + offset),
0504                                         static_cast<float>(photonsFloatingPointValues_[1] + offset),
0505                                         static_cast<float>(photonsFloatingPointValues_[2] + offset),
0506                                         static_cast<float>(photonsFloatingPointValues_[3] + offset),
0507                                         static_cast<float>(photonsFloatingPointValues_[14] + offset),
0508                                         static_cast<float>(photonsFloatingPointValues_[15] + offset),
0509                                         static_cast<float>(photonsFloatingPointValues_[16] + offset),
0510                                         static_cast<float>(photonsFloatingPointValues_[4] + offset),
0511                                         static_cast<float>(photonsFloatingPointValues_[5] + offset),
0512                                         static_cast<float>(photonsFloatingPointValues_[6] + offset),
0513                                         static_cast<float>(photonsFloatingPointValues_[7] + offset),
0514                                         static_cast<float>(photonsFloatingPointValues_[8] + offset),
0515                                         static_cast<float>(photonsFloatingPointValues_[9] + offset),
0516                                         static_cast<float>(photonsFloatingPointValues_[10] + offset),
0517                                         static_cast<float>(photonsFloatingPointValues_[11] + offset),
0518                                         static_cast<uint32_t>(photonsIntegralValues_[0] + iOffset),
0519                                         static_cast<uint32_t>(photonsIntegralValues_[3] + iOffset),
0520                                         static_cast<uint32_t>(photonsIntegralValues_[4] + iOffset),
0521                                         std::move(energyMatrix),
0522                                         std::move(detIds),
0523                                         std::move(timingMatrix),
0524                                         static_cast<bool>((photonsIntegralValues_[2] + iOffset) % 2));
0525     }
0526     iEvent.put(photonsPutToken_, std::move(run3ScoutingPhotons));
0527   }
0528 
0529   void TestWriteRun3Scouting::produceTracks(edm::Event& iEvent) const {
0530     auto run3ScoutingTracks = std::make_unique<std::vector<Run3ScoutingTrack>>();
0531     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0532     run3ScoutingTracks->reserve(vectorSize);
0533 
0534     for (unsigned int i = 0; i < vectorSize; ++i) {
0535       double offset = static_cast<double>(iEvent.id().event() + i);
0536       int iOffset = static_cast<int>(iEvent.id().event() + i);
0537 
0538       run3ScoutingTracks->emplace_back(static_cast<float>(tracksFloatingPointValues_[0] + offset),
0539                                        static_cast<float>(tracksFloatingPointValues_[1] + offset),
0540                                        static_cast<float>(tracksFloatingPointValues_[2] + offset),
0541                                        static_cast<float>(tracksFloatingPointValues_[3] + offset),
0542                                        static_cast<float>(tracksFloatingPointValues_[4] + offset),
0543                                        tracksIntegralValues_[0] + iOffset,
0544                                        static_cast<float>(tracksFloatingPointValues_[5] + offset),
0545                                        static_cast<float>(tracksFloatingPointValues_[6] + offset),
0546                                        tracksIntegralValues_[1] + iOffset,
0547                                        tracksIntegralValues_[2] + iOffset,
0548                                        tracksIntegralValues_[3] + iOffset,
0549                                        static_cast<float>(tracksFloatingPointValues_[7] + offset),
0550                                        static_cast<float>(tracksFloatingPointValues_[8] + offset),
0551                                        static_cast<float>(tracksFloatingPointValues_[9] + offset),
0552                                        static_cast<float>(tracksFloatingPointValues_[10] + offset),
0553                                        static_cast<float>(tracksFloatingPointValues_[11] + offset),
0554                                        static_cast<float>(tracksFloatingPointValues_[12] + offset),
0555                                        static_cast<float>(tracksFloatingPointValues_[13] + offset),
0556                                        static_cast<float>(tracksFloatingPointValues_[14] + offset),
0557                                        static_cast<float>(tracksFloatingPointValues_[15] + offset),
0558                                        static_cast<float>(tracksFloatingPointValues_[16] + offset),
0559                                        static_cast<float>(tracksFloatingPointValues_[17] + offset),
0560                                        static_cast<float>(tracksFloatingPointValues_[18] + offset),
0561                                        static_cast<float>(tracksFloatingPointValues_[19] + offset),
0562                                        static_cast<float>(tracksFloatingPointValues_[20] + offset),
0563                                        static_cast<float>(tracksFloatingPointValues_[21] + offset),
0564                                        static_cast<float>(tracksFloatingPointValues_[22] + offset),
0565                                        static_cast<float>(tracksFloatingPointValues_[23] + offset),
0566                                        static_cast<float>(tracksFloatingPointValues_[24] + offset),
0567                                        static_cast<float>(tracksFloatingPointValues_[25] + offset),
0568                                        tracksIntegralValues_[4] + iOffset,
0569                                        static_cast<float>(tracksFloatingPointValues_[26] + offset),
0570                                        static_cast<float>(tracksFloatingPointValues_[27] + offset),
0571                                        static_cast<float>(tracksFloatingPointValues_[28] + offset));
0572     }
0573     iEvent.put(tracksPutToken_, std::move(run3ScoutingTracks));
0574   }
0575 
0576   void TestWriteRun3Scouting::produceVertexes(edm::Event& iEvent) const {
0577     auto run3ScoutingVertexes = std::make_unique<std::vector<Run3ScoutingVertex>>();
0578     unsigned int vectorSize = 2 + iEvent.id().event() % 4;
0579     run3ScoutingVertexes->reserve(vectorSize);
0580 
0581     for (unsigned int i = 0; i < vectorSize; ++i) {
0582       double offset = static_cast<double>(iEvent.id().event() + i);
0583       int iOffset = static_cast<int>(iEvent.id().event() + i);
0584 
0585       run3ScoutingVertexes->emplace_back(static_cast<float>(vertexesFloatingPointValues_[0] + offset),
0586                                          static_cast<float>(vertexesFloatingPointValues_[1] + offset),
0587                                          static_cast<float>(vertexesFloatingPointValues_[2] + offset),
0588                                          static_cast<float>(vertexesFloatingPointValues_[3] + offset),
0589                                          static_cast<float>(vertexesFloatingPointValues_[4] + offset),
0590                                          static_cast<float>(vertexesFloatingPointValues_[5] + offset),
0591                                          vertexesIntegralValues_[0] + iOffset,
0592                                          static_cast<float>(vertexesFloatingPointValues_[6] + offset),
0593                                          vertexesIntegralValues_[1] + iOffset,
0594                                          static_cast<bool>((vertexesIntegralValues_[2] + iOffset) % 2),
0595                                          static_cast<float>(vertexesFloatingPointValues_[7] + offset),
0596                                          static_cast<float>(vertexesFloatingPointValues_[8] + offset),
0597                                          static_cast<float>(vertexesFloatingPointValues_[9] + offset));
0598     }
0599     iEvent.put(vertexesPutToken_, std::move(run3ScoutingVertexes));
0600   }
0601 
0602   void TestWriteRun3Scouting::throwWithMessage(const char* msg) const {
0603     throw cms::Exception("TestFailure") << "TestWriteRun3Scouting constructor, test configuration error, " << msg;
0604   }
0605 
0606 }  // namespace edmtest
0607 
0608 using edmtest::TestWriteRun3Scouting;
0609 DEFINE_FWK_MODULE(TestWriteRun3Scouting);