CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
HFPreReconstructor Class Reference

#include <RecoLocalCalo/HcalRecProducers/src/HFPreReconstructor.cc>

Inheritance diagram for HFPreReconstructor:
edm::stream::EDProducer<>

Public Member Functions

 HFPreReconstructor (const edm::ParameterSet &)
 
 ~HFPreReconstructor () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::pair< HcalDetId, int > PmtAnodeId
 
typedef std::pair< PmtAnodeId, const HFQIE10Info * > QIE10InfoWithId
 

Private Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void fillInfos (const edm::Event &e, const edm::EventSetup &eventSetup)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
unsigned sortDataByPmt ()
 

Private Attributes

bool dropZSmarkedPassed_
 
int forceSOI_
 
edm::InputTag inputLabel_
 
std::unique_ptr< HcalRecoParamsparamTS_
 
std::vector< HFQIE10Infoqie10Infos_
 
HFPreRecAlgo reco_
 
int soiShift_
 
std::vector< QIE10InfoWithIdsortedQIE10Infos_
 
edm::EDGetTokenT< QIE10DigiCollectiontok_hfQIE10_
 
bool tsFromDB_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: Phase 1 HF reco with QIE 10 and split-anode readout

Implementation: [Notes on implementation]

Definition at line 47 of file HFPreReconstructor.cc.

Member Typedef Documentation

typedef std::pair<HcalDetId, int> HFPreReconstructor::PmtAnodeId
private

Definition at line 55 of file HFPreReconstructor.cc.

typedef std::pair<PmtAnodeId, const HFQIE10Info*> HFPreReconstructor::QIE10InfoWithId
private

Definition at line 56 of file HFPreReconstructor.cc.

Constructor & Destructor Documentation

HFPreReconstructor::HFPreReconstructor ( const edm::ParameterSet conf)
explicit

Definition at line 85 of file HFPreReconstructor.cc.

References inputLabel_, and tok_hfQIE10_.

86  : inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
87  forceSOI_(conf.getParameter<int>("forceSOI")),
88  soiShift_(conf.getParameter<int>("soiShift")),
89  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
90  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
91  reco_(conf.getParameter<bool>("sumAllTimeSlices")) {
92  // Describe consumed data
93  tok_hfQIE10_ = consumes<QIE10DigiCollection>(inputLabel_);
94 
95  // Register the product
96  produces<HFPreRecHitCollection>();
97 }
T getParameter(std::string const &) const
edm::InputTag inputLabel_
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
HFPreReconstructor::~HFPreReconstructor ( )
override

Definition at line 99 of file HFPreReconstructor.cc.

99  {
100  // do anything here that needs to be done at destruction time
101  // (e.g. close files, deallocate resources etc.)
102 }

Member Function Documentation

void HFPreReconstructor::beginRun ( const edm::Run r,
const edm::EventSetup es 
)
overrideprivate

Definition at line 199 of file HFPreReconstructor.cc.

References edm::EventSetup::get(), AlCaHLTBitMon_ParallelJobs::p, paramTS_, edm::ESHandle< T >::product(), and tsFromDB_.

199  {
200  if (tsFromDB_) {
202  es.get<HcalRecoParamsRcd>().get(p);
203  paramTS_ = std::make_unique<HcalRecoParams>(*p.product());
204  }
205 }
std::unique_ptr< HcalRecoParams > paramTS_
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
void HFPreReconstructor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 268 of file HFPreReconstructor.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), and DEFINE_FWK_MODULE.

268  {
270 
271  desc.add<edm::InputTag>("digiLabel");
272  desc.add<int>("forceSOI", -1);
273  desc.add<int>("soiShift", 0);
274  desc.add<bool>("dropZSmarkedPassed");
275  desc.add<bool>("tsFromDB");
276  desc.add<bool>("sumAllTimeSlices");
277 
278  descriptions.addDefault(desc);
279 }
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void HFPreReconstructor::fillInfos ( const edm::Event e,
const edm::EventSetup eventSetup 
)
private

Definition at line 135 of file HFPreReconstructor.cc.

References edm::DataFrameContainer::begin(), AlignmentProducer_cff::calibrations, dropZSmarkedPassed_, edm::DataFrameContainer::end(), HcalRecoParam::firstSample(), forceSOI_, amptDefault_cfi::frame, edm::EventSetup::get(), edm::Event::getByToken(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalForward, QIE10DataFrame::id(), HFQIE10Info::id(), info(), paramTS_, QIE10DataFrame::presamples(), edm::ESHandle< T >::product(), qie10Infos_, DetId::rawId(), reco_, HFPreRecAlgo::reconstruct(), edm::DataFrameContainer::size(), soiShift_, tok_hfQIE10_, tsFromDB_, and QIE10DataFrame::zsMarkAndPass().

Referenced by produce().

135  {
136  using namespace edm;
137 
138  // Clear the collection we want to fill in this method
139  qie10Infos_.clear();
140 
141  // Get the Hcal topology if needed
143  if (tsFromDB_) {
144  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
145  paramTS_->setTopo(htopo.product());
146  }
147 
148  // Get the calibrations
149  ESHandle<HcalDbService> conditions;
150  eventSetup.get<HcalDbRecord>().get(conditions);
151 
152  // Get the input collection
154  e.getByToken(tok_hfQIE10_, digi);
155 
156  const unsigned inputSize = digi->size();
157  if (inputSize) {
158  // Process the digis and fill out the HFQIE10Info vector
159  qie10Infos_.reserve(inputSize);
160 
161  for (QIE10DigiCollection::const_iterator it = digi->begin(); it != digi->end(); ++it) {
162  const QIE10DataFrame& frame(*it);
163  const HcalDetId cell(frame.id());
164 
165  // Protection against calibration channels which are not
166  // in the database but can still come in the QIE10DataFrame
167  // in the laser calibs, etc.
168  if (cell.subdet() != HcalSubdetector::HcalForward)
169  continue;
170 
171  // Check zero suppression
173  if (frame.zsMarkAndPass())
174  continue;
175 
176  const HcalCalibrations& calibrations(conditions->getHcalCalibrations(cell));
177  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
178  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
179  const HcalCoderDb coder(*channelCoder, *shape);
180 
181  int tsToUse = forceSOI_;
182  if (tsToUse < 0) {
183  if (tsFromDB_) {
184  const HcalRecoParam* param_ts = paramTS_->getValues(cell.rawId());
185  tsToUse = param_ts->firstSample();
186  } else
187  // Get the "sample of interest" from the data frame itself
188  tsToUse = frame.presamples();
189  }
190 
191  // Reconstruct the charge, energy, etc
192  const HFQIE10Info& info = reco_.reconstruct(frame, tsToUse + soiShift_, coder, calibrations);
193  if (info.id().rawId())
194  qie10Infos_.push_back(info);
195  }
196  }
197 }
HFQIE10Info reconstruct(const QIE10DataFrame &digi, int tsToUse, const HcalCoder &coder, const HcalCalibrations &calibs) const
Definition: HFPreRecAlgo.cc:12
std::vector< HFQIE10Info > qie10Infos_
static const TGPicture * info(bool iBackgroundIsBlack)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::unique_ptr< HcalRecoParams > paramTS_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const_iterator begin() const
HcalDetId id() const
Definition: HFQIE10Info.h:77
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
const_iterator end() const
HLT enums.
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
T get() const
Definition: EventSetup.h:73
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
T const * product() const
Definition: ESHandle.h:86
constexpr unsigned int firstSample() const
Definition: HcalRecoParam.h:31
void HFPreReconstructor::produce ( edm::Event e,
const edm::EventSetup eventSetup 
)
overrideprivate

Definition at line 208 of file HFPreReconstructor.cc.

References fillInfos(), dqmdumpme::first, mps_fire::i, eostools::move(), MillePedeFileConverter_cfg::out, edm::Event::put(), edm::second(), sortDataByPmt(), and sortedQIE10Infos_.

208  {
209  // Process the input data
210  fillInfos(e, eventSetup);
211 
212  // Create a new output collection
213  std::unique_ptr<HFPreRecHitCollection> out(std::make_unique<HFPreRecHitCollection>());
214 
215  // Fill the output collection
216  const unsigned pmtCount = sortDataByPmt();
217  if (pmtCount) {
218  out->reserve(pmtCount);
219  const unsigned sz = sortedQIE10Infos_.size();
220  HcalDetId previousBaseId(sortedQIE10Infos_[0].first.first);
221  unsigned nFound = 1;
222  for (unsigned i = 1; i <= sz; ++i) {
223  bool appendData = i == sz;
224  if (i < sz) {
225  const HcalDetId baseId(sortedQIE10Infos_[i].first.first);
226  if (baseId == previousBaseId)
227  ++nFound;
228  else {
229  appendData = true;
230  previousBaseId = baseId;
231  }
232  }
233 
234  if (appendData) {
235  // If we have found more than two QIE10 with the same base id,
236  // there is a bug somewhere in the dataframe. We can't do
237  // anything useful about it here. Once we make sure that
238  // everything works as expected, this assertion can be removed.
239  assert(nFound <= 2);
240 
241  const HFQIE10Info* first = nullptr;
242  const HFQIE10Info* second = sortedQIE10Infos_[i - 1].second;
243 
244  if (nFound >= 2)
245  first = sortedQIE10Infos_[i - 2].second;
246  else if (sortedQIE10Infos_[i - 1].first.second < 3) {
247  // Only one QIE10 readout found for this PMT.
248  // Arrange for depth 1 and 2 to be "first".
249  first = second;
250  second = nullptr;
251  }
252 
253  out->push_back(HFPreRecHit(sortedQIE10Infos_[i - nFound].first.first, first, second));
254 
255  // Reset the QIE find count for this base id
256  nFound = 1;
257  }
258  }
259 
260  assert(out->size() == pmtCount);
261  }
262 
263  // Add the output collection to the event record
264  e.put(std::move(out));
265 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
std::vector< QIE10InfoWithId > sortedQIE10Infos_
U second(std::pair< T, U > const &p)
void fillInfos(const edm::Event &e, const edm::EventSetup &eventSetup)
def move(src, dest)
Definition: eostools.py:511
unsigned HFPreReconstructor::sortDataByPmt ( )
private

Definition at line 107 of file HFPreReconstructor.cc.

References LEDCalibrationChannels::depth, dqmdumpme::first, mps_fire::i, triggerObjects_cff::id, info(), qie10Infos_, and sortedQIE10Infos_.

Referenced by produce().

107  {
108  sortedQIE10Infos_.clear();
109  unsigned pmtCount = 0;
110  const unsigned sz = qie10Infos_.size();
111  if (sz) {
112  // Perform sorting
113  sortedQIE10Infos_.reserve(sz);
114  const HFQIE10Info* info = &qie10Infos_[0];
115  for (unsigned i = 0; i < sz; ++i) {
116  const HcalDetId id(info[i].id());
117  sortedQIE10Infos_.push_back(QIE10InfoWithId(PmtAnodeId(id.baseDetId(), id.depth()), info + i));
118  }
119  std::sort(sortedQIE10Infos_.begin(), sortedQIE10Infos_.end());
120 
121  // Count the PMTs
122  HcalDetId previousBaseId(sortedQIE10Infos_[0].first.first);
123  pmtCount = 1;
124  for (unsigned i = 1; i < sz; ++i) {
125  const HcalDetId baseId(sortedQIE10Infos_[i].first.first);
126  if (baseId != previousBaseId) {
127  previousBaseId = baseId;
128  ++pmtCount;
129  }
130  }
131  }
132  return pmtCount;
133 }
std::vector< HFQIE10Info > qie10Infos_
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< QIE10InfoWithId > sortedQIE10Infos_
std::pair< PmtAnodeId, const HFQIE10Info * > QIE10InfoWithId
std::pair< HcalDetId, int > PmtAnodeId

Member Data Documentation

bool HFPreReconstructor::dropZSmarkedPassed_
private

Definition at line 65 of file HFPreReconstructor.cc.

Referenced by fillInfos().

int HFPreReconstructor::forceSOI_
private

Definition at line 63 of file HFPreReconstructor.cc.

Referenced by fillInfos().

edm::InputTag HFPreReconstructor::inputLabel_
private

Definition at line 62 of file HFPreReconstructor.cc.

Referenced by HFPreReconstructor().

std::unique_ptr<HcalRecoParams> HFPreReconstructor::paramTS_
private

Definition at line 73 of file HFPreReconstructor.cc.

Referenced by beginRun(), and fillInfos().

std::vector<HFQIE10Info> HFPreReconstructor::qie10Infos_
private

Definition at line 71 of file HFPreReconstructor.cc.

Referenced by fillInfos(), and sortDataByPmt().

HFPreRecAlgo HFPreReconstructor::reco_
private

Definition at line 69 of file HFPreReconstructor.cc.

Referenced by fillInfos().

int HFPreReconstructor::soiShift_
private

Definition at line 64 of file HFPreReconstructor.cc.

Referenced by fillInfos().

std::vector<QIE10InfoWithId> HFPreReconstructor::sortedQIE10Infos_
private

Definition at line 72 of file HFPreReconstructor.cc.

Referenced by produce(), and sortDataByPmt().

edm::EDGetTokenT<QIE10DigiCollection> HFPreReconstructor::tok_hfQIE10_
private

Definition at line 70 of file HFPreReconstructor.cc.

Referenced by fillInfos(), and HFPreReconstructor().

bool HFPreReconstructor::tsFromDB_
private

Definition at line 66 of file HFPreReconstructor.cc.

Referenced by beginRun(), and fillInfos().