CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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.add<uint32_t>("maxNumberHitsEB", 61200);
108  desc.add<uint32_t>("maxNumberHitsEE", 14648);
109 }
110 
112  //---- input
113  uncalibRecHitsInEBToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEB"));
114  uncalibRecHitsInEEToken_ = consumes<InputProduct>(ps.getParameter<edm::InputTag>("uncalibrecHitsInLabelEE"));
115 
116  //---- output
117  recHitsTokenEB_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEB"));
118  recHitsTokenEE_ = produces<OutputProduct>(ps.getParameter<std::string>("recHitsLabelEE"));
119 
120  bool killDeadChannels = ps.getParameter<bool>("killDeadChannels");
122 
123  configParameters_.EBLaserMIN = ps.getParameter<double>("EBLaserMIN");
124  configParameters_.EELaserMIN = ps.getParameter<double>("EELaserMIN");
125  configParameters_.EBLaserMAX = ps.getParameter<double>("EBLaserMAX");
126  configParameters_.EELaserMAX = ps.getParameter<double>("EELaserMAX");
127 
128  // max number of digis to allocate for
129  configParameters_.maxNumberHitsEB = ps.getParameter<uint32_t>("maxNumberHitsEB");
130  configParameters_.maxNumberHitsEE = ps.getParameter<uint32_t>("maxNumberHitsEE");
131 
132  flagmask_ = 0;
133  flagmask_ |= 0x1 << EcalRecHit::kNeighboursRecovered;
134  flagmask_ |= 0x1 << EcalRecHit::kTowerRecovered;
135  flagmask_ |= 0x1 << EcalRecHit::kDead;
136  flagmask_ |= 0x1 << EcalRecHit::kKilled;
137  flagmask_ |= 0x1 << EcalRecHit::kTPSaturated;
138  flagmask_ |= 0x1 << EcalRecHit::kL1SpikeFlag;
139 
141 
142  // for recovery and killing
143 
144  configParameters_.recoverEBIsolatedChannels = ps.getParameter<bool>("recoverEBIsolatedChannels");
145  configParameters_.recoverEEIsolatedChannels = ps.getParameter<bool>("recoverEEIsolatedChannels");
146  configParameters_.recoverEBVFE = ps.getParameter<bool>("recoverEBVFE");
147  configParameters_.recoverEEVFE = ps.getParameter<bool>("recoverEEVFE");
148  configParameters_.recoverEBFE = ps.getParameter<bool>("recoverEBFE");
149  configParameters_.recoverEEFE = ps.getParameter<bool>("recoverEEFE");
150 
151  // conditions tokens
152  tokenADCToGeVConstant_ = esConsumes<EcalRechitADCToGeVConstantGPU, EcalADCToGeVConstantRcd>();
153  tokenIntercalibConstants_ = esConsumes<EcalIntercalibConstantsGPU, EcalIntercalibConstantsRcd>();
154  tokenChannelStatus_ = esConsumes<EcalRechitChannelStatusGPU, EcalChannelStatusRcd>();
155  tokenLaserAPDPNRatios_ = esConsumes<EcalLaserAPDPNRatiosGPU, EcalLaserAPDPNRatiosRcd>();
156  tokenLaserAPDPNRatiosRef_ = esConsumes<EcalLaserAPDPNRatiosRefGPU, EcalLaserAPDPNRatiosRefRcd>();
157  tokenLaserAlphas_ = esConsumes<EcalLaserAlphasGPU, EcalLaserAlphasRcd>();
158  tokenLinearCorrections_ = esConsumes<EcalLinearCorrectionsGPU, EcalLinearCorrectionsRcd>();
159  tokenRecHitParameters_ = esConsumes<EcalRecHitParametersGPU, JobConfigurationGPURecord>();
160 }
161 
163 
165  edm::EventSetup const& setup,
167  // cuda products
168  auto const& ebUncalibRecHitsProduct = event.get(uncalibRecHitsInEBToken_);
169  auto const& eeUncalibRecHitsProduct = event.get(uncalibRecHitsInEEToken_);
170  // raii
171  cms::cuda::ScopedContextAcquire ctx{ebUncalibRecHitsProduct, std::move(holder), cudaState_};
172  // get actual object
173  auto const& ebUncalibRecHits = ctx.get(ebUncalibRecHitsProduct);
174  auto const& eeUncalibRecHits = ctx.get(eeUncalibRecHitsProduct);
175 
176  ecal::rechit::EventInputDataGPU inputDataGPU{ebUncalibRecHits, eeUncalibRecHits};
177 
178  neb_ = ebUncalibRecHits.size;
179  nee_ = eeUncalibRecHits.size;
180 
181  // stop here if there are no uncalibRecHits
182  if (neb_ + nee_ == 0)
183  return;
184 
186  edm::LogError("EcalRecHitProducerGPU")
187  << "max number of channels exceeded. See options 'maxNumberHitsEB and maxNumberHitsEE' ";
188  }
189 
190  int nchannelsEB = ebUncalibRecHits.size; // --> offsetForInput, first EB and then EE
191 
192  // conditions
193  // - laser correction
194  // - IC
195  // - adt2gev
196 
197  //
200 
201  auto const& ADCToGeVConstantProduct = setup.getData(tokenADCToGeVConstant_).getProduct(ctx.stream());
202  auto const& IntercalibConstantsProduct = IntercalibConstantsHandle_->getProduct(ctx.stream());
203  auto const& ChannelStatusProduct = setup.getData(tokenChannelStatus_).getProduct(ctx.stream());
204 
205  auto const& LaserAPDPNRatiosProduct = setup.getData(tokenLaserAPDPNRatios_).getProduct(ctx.stream());
206  auto const& LaserAPDPNRatiosRefProduct = setup.getData(tokenLaserAPDPNRatiosRef_).getProduct(ctx.stream());
207  auto const& LaserAlphasProduct = setup.getData(tokenLaserAlphas_).getProduct(ctx.stream());
208  auto const& LinearCorrectionsProduct = setup.getData(tokenLinearCorrections_).getProduct(ctx.stream());
209  auto const& recHitParametersProduct = recHitParametersHandle_->getProduct(ctx.stream());
210 
211  // set config ptrs : this is done to avoid changing things downstream
212  configParameters_.ChannelStatusToBeExcluded = recHitParametersProduct.channelStatusToBeExcluded.get();
213  configParameters_.ChannelStatusToBeExcludedSize = std::get<0>(recHitParametersHandle_->getValues()).get().size();
214  configParameters_.expanded_v_DB_reco_flags = recHitParametersProduct.expanded_v_DB_reco_flags.get();
215  configParameters_.expanded_Sizes_v_DB_reco_flags = recHitParametersProduct.expanded_Sizes_v_DB_reco_flags.get();
216  configParameters_.expanded_flagbit_v_DB_reco_flags = recHitParametersProduct.expanded_flagbit_v_DB_reco_flags.get();
217  configParameters_.expanded_v_DB_reco_flagsSize = std::get<3>(recHitParametersHandle_->getValues()).get().size();
218 
219  // bundle up conditions
220  ecal::rechit::ConditionsProducts conditions{ADCToGeVConstantProduct,
221  IntercalibConstantsProduct,
222  ChannelStatusProduct,
223  LaserAPDPNRatiosProduct,
224  LaserAPDPNRatiosRefProduct,
225  LaserAlphasProduct,
226  LinearCorrectionsProduct,
227  IntercalibConstantsHandle_->getOffset()};
228 
229  // dev mem
231 
232  //
233  // schedule algorithms
234  //
235 
236  edm::TimeValue_t event_time = event.time().value();
237 
239  inputDataGPU, eventOutputDataGPU_, conditions, configParameters_, nchannelsEB, event_time, ctx.stream());
240 
241  cudaCheck(cudaGetLastError());
242 }
243 
246 
249 
250  // put into the event
253 }
254 
std::vector< uint32_t > expanded_Sizes_v_DB_reco_flags_
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_
tuple killDeadChannels
void allocate(ConfigurationParameters const &configParameters, cudaStream_t cudaStream)
edm::ESGetToken< EcalIntercalibConstantsGPU, EcalIntercalibConstantsRcd > tokenIntercalibConstants_
EcalRecHitProducerGPU(edm::ParameterSet const &ps)
edm::EDPutTokenT< OutputProduct > recHitsTokenEB_
Log< level::Error, false > LogError
edm::EDPutTokenT< OutputProduct > recHitsTokenEE_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::ESGetToken< EcalLaserAlphasGPU, EcalLaserAlphasRcd > tokenLaserAlphas_
edm::EDGetTokenT< InputProduct > uncalibRecHitsInEEToken_
edm::ESGetToken< EcalLinearCorrectionsGPU, EcalLinearCorrectionsRcd > tokenLinearCorrections_
std::vector< uint32_t > expanded_flagbit_v_DB_reco_flags_
def move
Definition: eostools.py:511
static void fillDescriptions(edm::ConfigurationDescriptions &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
cms::cuda::ContextState cudaState_
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override