CMS 3D CMS Logo

EcalDigisFromPortableProducer.cc
Go to the documentation of this file.
1 #include <utility>
2 
14 
16 public:
18  ~EcalDigisFromPortableProducer() override = default;
20 
21 private:
22  void produce(edm::Event&, edm::EventSetup const&) override;
23 
24  template <typename ProductType, typename... ARGS>
26  return (produceDummyIntegrityCollections_) ? produces<ProductType>(std::forward<ARGS>(args)...)
28  }
29 
30 private:
31  // input digi collections on host in SoA format
35 
36  // output digi collections in legacy format
39 
40  // whether to produce dummy integrity collections
42 
43  // dummy producer collections
46 
47  // dummy ECAL raw data collection
49 
50  // dummy integrity for xtal data
54 
55  // dummy integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection)
59 
60  // dummy integrity errors
64 
66 
67  // dummy TCC collections
70 
71  // dummy mem integrity collections
76 };
77 
80 
81  desc.add<edm::InputTag>("digisInLabelEB", edm::InputTag{"ecalRawToDigiPortable", "ebDigis"});
82  desc.add<edm::InputTag>("digisInLabelEE", edm::InputTag{"ecalRawToDigiPortable", "eeDigis"});
83  desc.add<std::string>("digisOutLabelEB", "ebDigis");
84  desc.add<std::string>("digisOutLabelEE", "eeDigis");
85  desc.add<bool>("produceDummyIntegrityCollections", false);
86 
87  confDesc.add("ecalDigisFromPortableProducer", desc);
88 }
89 
91  : // input digi collections on host in SoA format
92  digisInEBToken_{consumes(ps.getParameter<edm::InputTag>("digisInLabelEB"))},
93  digisInEEToken_{consumes(ps.getParameter<edm::InputTag>("digisInLabelEE"))},
94 
95  // output digi collections in legacy format
96  digisOutEBToken_{produces<EBDigiCollection>(ps.getParameter<std::string>("digisOutLabelEB"))},
97  digisOutEEToken_{produces<EEDigiCollection>(ps.getParameter<std::string>("digisOutLabelEE"))},
98 
99  // whether to produce dummy integrity collections
100  produceDummyIntegrityCollections_{ps.getParameter<bool>("produceDummyIntegrityCollections")},
101 
102  // dummy collections
103  ebSrFlagToken_{dummyProduces<EBSrFlagCollection>()},
104  eeSrFlagToken_{dummyProduces<EESrFlagCollection>()},
105 
106  // dummy ECAL raw data collection
107  ecalRawDataToken_{dummyProduces<EcalRawDataCollection>()},
108 
109  // dummy integrity for xtal data
110  ebIntegrityGainErrorsToken_{dummyProduces<EBDetIdCollection>("EcalIntegrityGainErrors")},
111  ebIntegrityGainSwitchErrorsToken_{dummyProduces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors")},
112  ebIntegrityChIdErrorsToken_{dummyProduces<EBDetIdCollection>("EcalIntegrityChIdErrors")},
113 
114  // dummy integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection)
115  eeIntegrityGainErrorsToken_{dummyProduces<EEDetIdCollection>("EcalIntegrityGainErrors")},
116  eeIntegrityGainSwitchErrorsToken_{dummyProduces<EEDetIdCollection>("EcalIntegrityGainSwitchErrors")},
117  eeIntegrityChIdErrorsToken_{dummyProduces<EEDetIdCollection>("EcalIntegrityChIdErrors")},
118 
119  // dummy integrity errors
120  integrityTTIdErrorsToken_{dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors")},
121  integrityZSXtalIdErrorsToken_{dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityZSXtalIdErrors")},
122  integrityBlockSizeErrorsToken_{dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors")},
123 
124  //
125  pnDiodeDigisToken_{dummyProduces<EcalPnDiodeDigiCollection>()},
126 
127  // dummy TCC collections
128  ecalTriggerPrimitivesToken_{dummyProduces<EcalTrigPrimDigiCollection>("EcalTriggerPrimitives")},
129  ecalPseudoStripInputsToken_{dummyProduces<EcalPSInputDigiCollection>("EcalPseudoStripInputs")},
130 
131  // dummy mem integrity collections
132  ecalIntegrityMemTtIdErrorsToken_{dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors")},
133  ecalIntegrityMemBlockSizeErrorsToken_{
134  dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSizeErrors")},
135  ecalIntegrityMemChIdErrorsToken_{dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors")},
136  ecalIntegrityMemGainErrorsToken_{dummyProduces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors")} {}
137 
139  // output collections
140  auto digisEB = std::make_unique<EBDigiCollection>();
141  auto digisEE = std::make_unique<EEDigiCollection>();
142 
143  auto const& digisEBSoAHostColl = event.get(digisInEBToken_);
144  auto const& digisEESoAHostColl = event.get(digisInEEToken_);
145  auto& digisEBSoAView = digisEBSoAHostColl.view();
146  auto& digisEESoAView = digisEESoAHostColl.view();
147 
148  auto const digisEBSize = digisEBSoAView.size();
149  auto const digisEESize = digisEESoAView.size();
150  auto const digisEBDataSize = digisEBSize * ecalPh1::sampleSize;
151  auto const digisEEDataSize = digisEESize * ecalPh1::sampleSize;
152 
153  // Intermediate containers because the DigiCollection containers are accessible only as const
158 
159  digisIdsEB.resize(digisEBSize);
160  digisIdsEE.resize(digisEESize);
161  digisDataEB.resize(digisEBDataSize);
162  digisDataEE.resize(digisEEDataSize);
163 
164  // copy data
165  std::memcpy(digisIdsEB.data(), digisEBSoAView.id(), digisEBSize * sizeof(uint32_t));
166  std::memcpy(digisIdsEE.data(), digisEESoAView.id(), digisEESize * sizeof(uint32_t));
167  std::memcpy(digisDataEB.data(), digisEBSoAView.data()->data(), digisEBDataSize * sizeof(uint16_t));
168  std::memcpy(digisDataEE.data(), digisEESoAView.data()->data(), digisEEDataSize * sizeof(uint16_t));
169 
170  digisEB->swap(digisIdsEB, digisDataEB);
171  digisEE->swap(digisIdsEE, digisDataEE);
172 
173  digisEB->sort();
174  digisEE->sort();
175 
176  event.put(digisOutEBToken_, std::move(digisEB));
177  event.put(digisOutEEToken_, std::move(digisEE));
178 
180  // dummy collections
181  event.emplace(ebSrFlagToken_);
182  event.emplace(eeSrFlagToken_);
183  // dummy ECAL raw data collection
184  event.emplace(ecalRawDataToken_);
185  // dummy integrity for xtal data
186  event.emplace(ebIntegrityGainErrorsToken_);
187  event.emplace(ebIntegrityGainSwitchErrorsToken_);
188  event.emplace(ebIntegrityChIdErrorsToken_);
189  // dummy integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection)
190  event.emplace(eeIntegrityGainErrorsToken_);
191  event.emplace(eeIntegrityGainSwitchErrorsToken_);
192  event.emplace(eeIntegrityChIdErrorsToken_);
193  // dummy integrity errors
194  event.emplace(integrityTTIdErrorsToken_);
195  event.emplace(integrityZSXtalIdErrorsToken_);
196  event.emplace(integrityBlockSizeErrorsToken_);
197  //
198  event.emplace(pnDiodeDigisToken_);
199  // dummy TCC collections
200  event.emplace(ecalTriggerPrimitivesToken_);
201  event.emplace(ecalPseudoStripInputsToken_);
202  // dummy mem integrity collections
203  event.emplace(ecalIntegrityMemTtIdErrorsToken_);
205  event.emplace(ecalIntegrityMemChIdErrorsToken_);
206  event.emplace(ecalIntegrityMemGainErrorsToken_);
207  }
208 }
209 
edm::EDGetTokenT< InputProduct > digisInEBToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDPutTokenT< EcalElectronicsIdCollection > integrityBlockSizeErrorsToken_
EcalDigisFromPortableProducer(edm::ParameterSet const &ps)
PortableHostCollection< EcalDigiSoA > EcalDigiHostCollection
edm::EDPutTokenT< EcalTrigPrimDigiCollection > ecalTriggerPrimitivesToken_
edm::EDPutTokenT< EcalPSInputDigiCollection > ecalPseudoStripInputsToken_
edm::EDPutTokenT< EEDetIdCollection > eeIntegrityChIdErrorsToken_
edm::EDPutTokenT< EEDetIdCollection > eeIntegrityGainErrorsToken_
edm::EDPutTokenT< EBDetIdCollection > ebIntegrityChIdErrorsToken_
edm::EDPutTokenT< EBDetIdCollection > ebIntegrityGainErrorsToken_
edm::EDPutTokenT< EcalElectronicsIdCollection > ecalIntegrityMemTtIdErrorsToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
edm::EDGetTokenT< InputProduct > digisInEEToken_
edm::EDPutTokenT< EcalElectronicsIdCollection > ecalIntegrityMemGainErrorsToken_
std::vector< data_type > DataContainer
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~EcalDigisFromPortableProducer() override=default
edm::EDPutTokenT< EcalElectronicsIdCollection > ecalIntegrityMemBlockSizeErrorsToken_
edm::EDPutTokenT< EcalElectronicsIdCollection > integrityZSXtalIdErrorsToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDPutTokenT< EBDigiCollection > digisOutEBToken_
static constexpr unsigned int sampleSize
Definition: EcalConstants.h:53
edm::EDPutTokenT< EBDetIdCollection > ebIntegrityGainSwitchErrorsToken_
void produce(edm::Event &, edm::EventSetup const &) override
std::vector< id_type > IdContainer
edm::EDPutTokenT< EcalElectronicsIdCollection > ecalIntegrityMemChIdErrorsToken_
edm::EDPutTokenT< EESrFlagCollection > eeSrFlagToken_
edm::EDPutTokenT< EcalPnDiodeDigiCollection > pnDiodeDigisToken_
edm::EDPutTokenT< EEDetIdCollection > eeIntegrityGainSwitchErrorsToken_
edm::EDPutTokenT< ProductType > dummyProduces(ARGS &&... args)
edm::EDPutTokenT< EBSrFlagCollection > ebSrFlagToken_
edm::EDPutTokenT< EcalRawDataCollection > ecalRawDataToken_
def move(src, dest)
Definition: eostools.py:511
edm::EDPutTokenT< EcalElectronicsIdCollection > integrityTTIdErrorsToken_
Definition: event.py:1
edm::EDPutTokenT< EEDigiCollection > digisOutEEToken_