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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HFPreReconstructor (const edm::ParameterSet &)
 
 ~HFPreReconstructor ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

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

Private Member Functions

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

Private Attributes

bool dropZSmarkedPassed_
 
edm::InputTag inputLabel_
 
std::unique_ptr< HcalRecoParamsparamTS_
 
std::vector< HFQIE10Infoqie10Infos_
 
HFPreRecAlgo reco_
 
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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

Implementation: [Notes on implementation]

Definition at line 48 of file HFPreReconstructor.cc.

Member Typedef Documentation

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

Definition at line 57 of file HFPreReconstructor.cc.

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

Definition at line 58 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  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
88  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
89  reco_(conf.getParameter<bool>("sumAllTimeSlices"))
90 {
91  // Describe consumed data
92  tok_hfQIE10_ = consumes<QIE10DigiCollection>(inputLabel_);
93 
94  // Register the product
95  produces<HFPreRecHitCollection>();
96 }
T getParameter(std::string const &) const
edm::InputTag inputLabel_
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
HFPreReconstructor::~HFPreReconstructor ( )

Definition at line 99 of file HFPreReconstructor.cc.

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

Member Function Documentation

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

Definition at line 212 of file HFPreReconstructor.cc.

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

213 {
214  if (tsFromDB_)
215  {
217  es.get<HcalRecoParamsRcd>().get(p);
218  paramTS_ = std::make_unique<HcalRecoParams>(*p.product());
219  }
220 }
std::unique_ptr< HcalRecoParams > paramTS_
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void HFPreReconstructor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 293 of file HFPreReconstructor.cc.

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

294 {
296 
297  desc.add<edm::InputTag>("digiLabel");
298  desc.add<bool>("dropZSmarkedPassed");
299  desc.add<bool>("tsFromDB");
300  desc.add<bool>("sumAllTimeSlices");
301 
302  descriptions.addDefault(desc);
303 }
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 146 of file HFPreReconstructor.cc.

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

Referenced by produce().

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

Definition at line 224 of file HFPreReconstructor.cc.

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

225 {
226  // Process the input data
227  fillInfos(e, eventSetup);
228 
229  // Create a new output collection
230  std::unique_ptr<HFPreRecHitCollection> out(std::make_unique<HFPreRecHitCollection>());
231 
232  // Fill the output collection
233  const unsigned pmtCount = sortDataByPmt();
234  if (pmtCount)
235  {
236  out->reserve(pmtCount);
237  const unsigned sz = sortedQIE10Infos_.size();
238  HcalDetId previousBaseId(sortedQIE10Infos_[0].first.first);
239  unsigned nFound = 1;
240  for (unsigned i=1; i<=sz; ++i)
241  {
242  bool appendData = i == sz;
243  if (i < sz)
244  {
245  const HcalDetId baseId(sortedQIE10Infos_[i].first.first);
246  if (baseId == previousBaseId)
247  ++nFound;
248  else
249  {
250  appendData = true;
251  previousBaseId = baseId;
252  }
253  }
254 
255  if (appendData)
256  {
257  // If we have found more than two QIE10 with the same base id,
258  // there is a bug somewhere in the dataframe. We can't do
259  // anything useful about it here. Once we make sure that
260  // everything works as expected, this assertion can be removed.
261  assert(nFound <= 2);
262 
263  const HFQIE10Info* first = 0;
264  const HFQIE10Info* second = sortedQIE10Infos_[i-1].second;
265 
266  if (nFound >= 2)
267  first = sortedQIE10Infos_[i-2].second;
268  else if (sortedQIE10Infos_[i-1].first.second < 3)
269  {
270  // Only one QIE10 readout found for this PMT.
271  // Arrange for depth 1 and 2 to be "first".
272  first = second;
273  second = 0;
274  }
275 
276  out->push_back(HFPreRecHit(sortedQIE10Infos_[i-nFound].first.first,
277  first, second));
278 
279  // Reset the QIE find count for this base id
280  nFound = 1;
281  }
282  }
283 
284  assert(out->size() == pmtCount);
285  }
286 
287  // Add the output collection to the event record
288  e.put(std::move(out));
289 }
int i
Definition: DBlmapReader.cc:9
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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:510
unsigned HFPreReconstructor::sortDataByPmt ( )
private

Definition at line 112 of file HFPreReconstructor.cc.

References particleFlowClusterECALTimeSelected_cfi::depth, plotBeamSpotDB::first, i, hcalTTPDigis_cfi::id, info(), qie10Infos_, and sortedQIE10Infos_.

Referenced by produce().

113 {
114  sortedQIE10Infos_.clear();
115  unsigned pmtCount = 0;
116  const unsigned sz = qie10Infos_.size();
117  if (sz)
118  {
119  // Perform sorting
120  sortedQIE10Infos_.reserve(sz);
121  const HFQIE10Info* info = &qie10Infos_[0];
122  for (unsigned i=0; i<sz; ++i)
123  {
124  const HcalDetId id(info[i].id());
125  sortedQIE10Infos_.push_back(QIE10InfoWithId(PmtAnodeId(id.baseDetId(), id.depth()), info+i));
126  }
127  std::sort(sortedQIE10Infos_.begin(), sortedQIE10Infos_.end());
128 
129  // Count the PMTs
130  HcalDetId previousBaseId(sortedQIE10Infos_[0].first.first);
131  pmtCount = 1;
132  for (unsigned i=1; i<sz; ++i)
133  {
134  const HcalDetId baseId(sortedQIE10Infos_[i].first.first);
135  if (baseId != previousBaseId)
136  {
137  previousBaseId = baseId;
138  ++pmtCount;
139  }
140  }
141  }
142  return pmtCount;
143 }
std::vector< HFQIE10Info > qie10Infos_
int i
Definition: DBlmapReader.cc:9
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().

edm::InputTag HFPreReconstructor::inputLabel_
private

Definition at line 64 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().

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().