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 
109  //---- input
110  uncalibRecHitsInEBToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEB"));
111  uncalibRecHitsInEEToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEE"));
112 
113  //---- output
114  recHitsTokenEB_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"));
115  recHitsTokenEE_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"));
116 
117  bool killDeadChannels = ps.getParameter<bool>("killDeadChannels");
119 
120  configParameters_.EBLaserMIN = ps.getParameter<double>("EBLaserMIN");
121  configParameters_.EELaserMIN = ps.getParameter<double>("EELaserMIN");
122  configParameters_.EBLaserMAX = ps.getParameter<double>("EBLaserMAX");
123  configParameters_.EELaserMAX = ps.getParameter<double>("EELaserMAX");
124 
125  flagmask_ = 0;
128  flagmask_ |= 0x1 << EcalRecHit::kDead;
129  flagmask_ |= 0x1 << EcalRecHit::kKilled;
132 
134 
135  // for recovery and killing
136 
137  configParameters_.recoverEBIsolatedChannels = ps.getParameter<bool>("recoverEBIsolatedChannels");
138  configParameters_.recoverEEIsolatedChannels = ps.getParameter<bool>("recoverEEIsolatedChannels");
139  configParameters_.recoverEBVFE = ps.getParameter<bool>("recoverEBVFE");
140  configParameters_.recoverEEVFE = ps.getParameter<bool>("recoverEEVFE");
141  configParameters_.recoverEBFE = ps.getParameter<bool>("recoverEBFE");
142  configParameters_.recoverEEFE = ps.getParameter<bool>("recoverEEFE");
143 
144  // conditions tokens
145  tokenADCToGeVConstant_ = esConsumes<EcalRechitADCToGeVConstantGPU, EcalADCToGeVConstantRcd>();
146  tokenIntercalibConstants_ = esConsumes<EcalIntercalibConstantsGPU, EcalIntercalibConstantsRcd>();
147  tokenChannelStatus_ = esConsumes<EcalRechitChannelStatusGPU, EcalChannelStatusRcd>();
148  tokenLaserAPDPNRatios_ = esConsumes<EcalLaserAPDPNRatiosGPU, EcalLaserAPDPNRatiosRcd>();
149  tokenLaserAPDPNRatiosRef_ = esConsumes<EcalLaserAPDPNRatiosRefGPU, EcalLaserAPDPNRatiosRefRcd>();
150  tokenLaserAlphas_ = esConsumes<EcalLaserAlphasGPU, EcalLaserAlphasRcd>();
151  tokenLinearCorrections_ = esConsumes<EcalLinearCorrectionsGPU, EcalLinearCorrectionsRcd>();
152  tokenRecHitParameters_ = esConsumes<EcalRecHitParametersGPU, JobConfigurationGPURecord>();
153 }
154 
156 
158  edm::EventSetup const& setup,
160  // cuda products
161  auto const& ebUncalibRecHitsProduct = event.get(uncalibRecHitsInEBToken_);
162  auto const& eeUncalibRecHitsProduct = event.get(uncalibRecHitsInEEToken_);
163  // raii
164  cms::cuda::ScopedContextAcquire ctx{ebUncalibRecHitsProduct, std::move(holder), cudaState_};
165  // get actual object
166  auto const& ebUncalibRecHits = ctx.get(ebUncalibRecHitsProduct);
167  auto const& eeUncalibRecHits = ctx.get(eeUncalibRecHitsProduct);
168 
169  ecal::rechit::EventInputDataGPU inputDataGPU{ebUncalibRecHits, eeUncalibRecHits};
170 
171  neb_ = ebUncalibRecHits.size;
172  nee_ = eeUncalibRecHits.size;
173 
174  // stop here if there are no uncalibRecHits
175  if (neb_ + nee_ == 0)
176  return;
177 
178  int nchannelsEB = ebUncalibRecHits.size; // --> offsetForInput, first EB and then EE
179 
180  // conditions
181  // - laser correction
182  // - IC
183  // - adt2gev
184 
185  //
188 
189  auto const& ADCToGeVConstantProduct = setup.getData(tokenADCToGeVConstant_).getProduct(ctx.stream());
190  auto const& IntercalibConstantsProduct = IntercalibConstantsHandle_->getProduct(ctx.stream());
191  auto const& ChannelStatusProduct = setup.getData(tokenChannelStatus_).getProduct(ctx.stream());
192 
193  auto const& LaserAPDPNRatiosProduct = setup.getData(tokenLaserAPDPNRatios_).getProduct(ctx.stream());
194  auto const& LaserAPDPNRatiosRefProduct = setup.getData(tokenLaserAPDPNRatiosRef_).getProduct(ctx.stream());
195  auto const& LaserAlphasProduct = setup.getData(tokenLaserAlphas_).getProduct(ctx.stream());
196  auto const& LinearCorrectionsProduct = setup.getData(tokenLinearCorrections_).getProduct(ctx.stream());
197  auto const& recHitParametersProduct = recHitParametersHandle_->getProduct(ctx.stream());
198 
199  // set config ptrs : this is done to avoid changing things downstream
200  configParameters_.ChannelStatusToBeExcluded = recHitParametersProduct.channelStatusToBeExcluded.get();
202  configParameters_.expanded_v_DB_reco_flags = recHitParametersProduct.expanded_v_DB_reco_flags.get();
203  configParameters_.expanded_Sizes_v_DB_reco_flags = recHitParametersProduct.expanded_Sizes_v_DB_reco_flags.get();
204  configParameters_.expanded_flagbit_v_DB_reco_flags = recHitParametersProduct.expanded_flagbit_v_DB_reco_flags.get();
206 
207  // bundle up conditions
208  ecal::rechit::ConditionsProducts conditions{ADCToGeVConstantProduct,
209  IntercalibConstantsProduct,
210  ChannelStatusProduct,
211  LaserAPDPNRatiosProduct,
212  LaserAPDPNRatiosRefProduct,
213  LaserAlphasProduct,
214  LinearCorrectionsProduct,
216 
217  // dev mem
219 
220  //
221  // schedule algorithms
222  //
223 
224  edm::TimeValue_t event_time = event.time().value();
225 
227  inputDataGPU, eventOutputDataGPU_, conditions, configParameters_, nchannelsEB, event_time, ctx.stream());
228 
229  cudaCheck(cudaGetLastError());
230 }
231 
234 
237 
238  // put into the event
241 }
242 
std::vector< uint32_t > expanded_Sizes_v_DB_reco_flags_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Product const & getProduct(cudaStream_t) const
edm::EDGetTokenT< InputProduct > uncalibRecHitsInEBToken_
edm::ESHandle< EcalRecHitParametersGPU > recHitParametersHandle_
RecHit<::calo::common::DevStoragePolicy > recHitsEB
ecal::rechit::EventOutputDataGPU eventOutputDataGPU_
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned long long TimeValue_t
Definition: Timestamp.h:21
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