CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EcalRecHitProducerGPU.cc
Go to the documentation of this file.
32 
34 
35 class EcalRecHitProducerGPU : public edm::stream::EDProducer<edm::ExternalWork> {
36 public:
37  explicit EcalRecHitProducerGPU(edm::ParameterSet const& ps);
38  ~EcalRecHitProducerGPU() override;
40 
41 private:
43  void produce(edm::Event&, edm::EventSetup const&) override;
44 
45 private:
46  // data
47  uint32_t neb_, nee_; // extremely important, in particular neb_
48 
49  // gpu input
53 
54  // event data
56 
58 
59  // gpu output
62 
63  // configuration parameters
65 
66  // conditions tokens
75 
76  // conditions handles
79 
80  // Associate reco flagbit (outer vector) to many db status flags (inner vector)
81  std::vector<int>
82  expanded_v_DB_reco_flags_; // Transform a map in a vector // FIXME AM: int or uint32 to be checked
83  std::vector<uint32_t> expanded_Sizes_v_DB_reco_flags_; // Saving the size for each piece
84  std::vector<uint32_t> expanded_flagbit_v_DB_reco_flags_; // And the "key" for each key
85 
86  uint32_t flagmask_; // do not propagate channels with these flags on
87 };
88 
91 
92  desc.add<edm::InputTag>("uncalibrecHitsInLabelEB",
93  edm::InputTag("ecalUncalibRecHitProducerGPU", "EcalUncalibRecHitsEB"));
94  desc.add<edm::InputTag>("uncalibrecHitsInLabelEE",
95  edm::InputTag("ecalUncalibRecHitProducerGPU", "EcalUncalibRecHitsEE"));
96 
97  desc.add<std::string>("recHitsLabelEB", "EcalRecHitsGPUEB");
98  desc.add<std::string>("recHitsLabelEE", "EcalRecHitsGPUEE");
99 
100  desc.add<bool>("killDeadChannels", true);
101 
102  desc.add<double>("EBLaserMIN", 0.01);
103  desc.add<double>("EELaserMIN", 0.01);
104  desc.add<double>("EBLaserMAX", 30.0);
105  desc.add<double>("EELaserMAX", 30.0);
106 
107  desc.addOptionalNode(edm::ParameterDescription<uint32_t>("maxNumberHitsEB", true, true), 61200u)
108  ->setComment("This parameter is obsolete and will be ignored.");
109  desc.addOptionalNode(edm::ParameterDescription<uint32_t>("maxNumberHitsEE", true, true), 14648u)
110  ->setComment("This parameter is obsolete and will be ignored.");
111 }
112 
114  //---- input
115  uncalibRecHitsInEBToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEB"));
116  uncalibRecHitsInEEToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEE"));
117 
118  //---- output
119  recHitsTokenEB_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"));
120  recHitsTokenEE_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"));
121 
122  bool killDeadChannels = ps.getParameter<bool>("killDeadChannels");
124 
125  configParameters_.EBLaserMIN = ps.getParameter<double>("EBLaserMIN");
126  configParameters_.EELaserMIN = ps.getParameter<double>("EELaserMIN");
127  configParameters_.EBLaserMAX = ps.getParameter<double>("EBLaserMAX");
128  configParameters_.EELaserMAX = ps.getParameter<double>("EELaserMAX");
129 
130  flagmask_ = 0;
133  flagmask_ |= 0x1 << EcalRecHit::kDead;
134  flagmask_ |= 0x1 << EcalRecHit::kKilled;
137 
139 
140  // for recovery and killing
141 
142  configParameters_.recoverEBIsolatedChannels = ps.getParameter<bool>("recoverEBIsolatedChannels");
143  configParameters_.recoverEEIsolatedChannels = ps.getParameter<bool>("recoverEEIsolatedChannels");
144  configParameters_.recoverEBVFE = ps.getParameter<bool>("recoverEBVFE");
145  configParameters_.recoverEEVFE = ps.getParameter<bool>("recoverEEVFE");
146  configParameters_.recoverEBFE = ps.getParameter<bool>("recoverEBFE");
147  configParameters_.recoverEEFE = ps.getParameter<bool>("recoverEEFE");
148 
149  // conditions tokens
150  tokenADCToGeVConstant_ = esConsumes<EcalRechitADCToGeVConstantGPU, EcalADCToGeVConstantRcd>();
151  tokenIntercalibConstants_ = esConsumes<EcalIntercalibConstantsGPU, EcalIntercalibConstantsRcd>();
152  tokenChannelStatus_ = esConsumes<EcalRechitChannelStatusGPU, EcalChannelStatusRcd>();
153  tokenLaserAPDPNRatios_ = esConsumes<EcalLaserAPDPNRatiosGPU, EcalLaserAPDPNRatiosRcd>();
154  tokenLaserAPDPNRatiosRef_ = esConsumes<EcalLaserAPDPNRatiosRefGPU, EcalLaserAPDPNRatiosRefRcd>();
155  tokenLaserAlphas_ = esConsumes<EcalLaserAlphasGPU, EcalLaserAlphasRcd>();
156  tokenLinearCorrections_ = esConsumes<EcalLinearCorrectionsGPU, EcalLinearCorrectionsRcd>();
157  tokenRecHitParameters_ = esConsumes<EcalRecHitParametersGPU, JobConfigurationGPURecord>();
158 }
159 
161 
163  edm::EventSetup const& setup,
165  // cuda products
166  auto const& ebUncalibRecHitsProduct = event.get(uncalibRecHitsInEBToken_);
167  auto const& eeUncalibRecHitsProduct = event.get(uncalibRecHitsInEEToken_);
168  // raii
169  cms::cuda::ScopedContextAcquire ctx{ebUncalibRecHitsProduct, std::move(holder), cudaState_};
170  // get actual object
171  auto const& ebUncalibRecHits = ctx.get(ebUncalibRecHitsProduct);
172  auto const& eeUncalibRecHits = ctx.get(eeUncalibRecHitsProduct);
173 
174  ecal::rechit::EventInputDataGPU inputDataGPU{ebUncalibRecHits, eeUncalibRecHits};
175 
176  neb_ = ebUncalibRecHits.size;
177  nee_ = eeUncalibRecHits.size;
178 
179  // stop here if there are no uncalibRecHits
180  if (neb_ + nee_ == 0)
181  return;
182 
183  int nchannelsEB = ebUncalibRecHits.size; // --> offsetForInput, first EB and then EE
184 
185  // conditions
186  // - laser correction
187  // - IC
188  // - adt2gev
189 
190  //
193 
194  auto const& ADCToGeVConstantProduct = setup.getData(tokenADCToGeVConstant_).getProduct(ctx.stream());
195  auto const& IntercalibConstantsProduct = IntercalibConstantsHandle_->getProduct(ctx.stream());
196  auto const& ChannelStatusProduct = setup.getData(tokenChannelStatus_).getProduct(ctx.stream());
197 
198  auto const& LaserAPDPNRatiosProduct = setup.getData(tokenLaserAPDPNRatios_).getProduct(ctx.stream());
199  auto const& LaserAPDPNRatiosRefProduct = setup.getData(tokenLaserAPDPNRatiosRef_).getProduct(ctx.stream());
200  auto const& LaserAlphasProduct = setup.getData(tokenLaserAlphas_).getProduct(ctx.stream());
201  auto const& LinearCorrectionsProduct = setup.getData(tokenLinearCorrections_).getProduct(ctx.stream());
202  auto const& recHitParametersProduct = recHitParametersHandle_->getProduct(ctx.stream());
203 
204  // set config ptrs : this is done to avoid changing things downstream
205  configParameters_.ChannelStatusToBeExcluded = recHitParametersProduct.channelStatusToBeExcluded.get();
207  configParameters_.expanded_v_DB_reco_flags = recHitParametersProduct.expanded_v_DB_reco_flags.get();
208  configParameters_.expanded_Sizes_v_DB_reco_flags = recHitParametersProduct.expanded_Sizes_v_DB_reco_flags.get();
209  configParameters_.expanded_flagbit_v_DB_reco_flags = recHitParametersProduct.expanded_flagbit_v_DB_reco_flags.get();
211 
212  // bundle up conditions
213  ecal::rechit::ConditionsProducts conditions{ADCToGeVConstantProduct,
214  IntercalibConstantsProduct,
215  ChannelStatusProduct,
216  LaserAPDPNRatiosProduct,
217  LaserAPDPNRatiosRefProduct,
218  LaserAlphasProduct,
219  LinearCorrectionsProduct,
221 
222  // dev mem
224 
225  //
226  // schedule algorithms
227  //
228 
229  edm::TimeValue_t event_time = event.time().value();
230 
232  inputDataGPU, eventOutputDataGPU_, conditions, configParameters_, nchannelsEB, event_time, ctx.stream());
233 
234  cudaCheck(cudaGetLastError());
235 }
236 
239 
242 
243  // put into the event
246 }
247 
std::vector< uint32_t > expanded_Sizes_v_DB_reco_flags_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Product const & getProduct(cudaStream_t) const
edm::EDGetTokenT< InputProduct > uncalibRecHitsInEBToken_
edm::ESHandle< EcalRecHitParametersGPU > recHitParametersHandle_
RecHit<::calo::common::DevStoragePolicy > recHitsEB
ecal::rechit::EventOutputDataGPU eventOutputDataGPU_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
RecHit<::calo::common::DevStoragePolicy > recHitsEE
void produce(edm::Event &, edm::EventSetup const &) override
edm::ESGetToken< EcalRecHitParametersGPU, JobConfigurationGPURecord > tokenRecHitParameters_
edm::ESHandle< EcalIntercalibConstantsGPU > IntercalibConstantsHandle_
edm::ESGetToken< EcalIntercalibConstantsGPU, EcalIntercalibConstantsRcd > tokenIntercalibConstants_
EcalRecHitProducerGPU(edm::ParameterSet const &ps)
edm::EDPutTokenT< OutputProduct > recHitsTokenEB_
edm::EDPutTokenT< OutputProduct > recHitsTokenEE_
edm::ESGetToken< EcalLaserAlphasGPU, EcalLaserAlphasRcd > tokenLaserAlphas_
void allocate(ConfigurationParameters const &configParameters, uint32_t sizeEB, uint32_t sizeEE, cudaStream_t cudaStream)
edm::EDGetTokenT< InputProduct > uncalibRecHitsInEEToken_
edm::ESGetToken< EcalLinearCorrectionsGPU, EcalLinearCorrectionsRcd > tokenLinearCorrections_
std::vector< uint32_t > expanded_flagbit_v_DB_reco_flags_
static void fillDescriptions(edm::ConfigurationDescriptions &)
std::tuple< intvec, intvec, uint32vec, uint32vec > getValues() const
unsigned long long TimeValue_t
Definition: Timestamp.h:28
edm::ESGetToken< EcalRechitADCToGeVConstantGPU, EcalADCToGeVConstantRcd > tokenADCToGeVConstant_
void create_ecal_rehit(EventInputDataGPU const &eventInputGPU, EventOutputDataGPU &eventOutputGPU, ConditionsProducts const &conditions, ConfigurationParameters const &configParameters, uint32_t const nChannelsBarrel, edm::TimeValue_t const event_time, cudaStream_t cudaStream)
Product const & getProduct(cudaStream_t) const
edm::ESGetToken< EcalLaserAPDPNRatiosRefGPU, EcalLaserAPDPNRatiosRefRcd > tokenLaserAPDPNRatiosRef_
ecal::rechit::ConfigurationParameters configParameters_
std::vector< int > expanded_v_DB_reco_flags_
edm::ESGetToken< EcalLaserAPDPNRatiosGPU, EcalLaserAPDPNRatiosRcd > tokenLaserAPDPNRatios_
edm::ESGetToken< EcalRechitChannelStatusGPU, EcalChannelStatusRcd > tokenChannelStatus_
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
cms::cuda::ContextState cudaState_
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1