CMS 3D CMS Logo

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

#include <HLTrigger/special/plugins/HLTRechitsToDigis.cc>

Inheritance diagram for HLTRechitsToDigis:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

enum  ecalRegion { invalidRegion =0, barrel, endcap }
 
- 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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 HLTRechitsToDigis (const edm::ParameterSet &)
 
 ~HLTRechitsToDigis () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 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 & itemsToGetFrom (BranchType iType) 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 const HLTRechitsToDigis::ecalRegion stringToRegion (const std::string &region)
 
- 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 Member Functions

void produce (edm::Event &, edm::EventSetup const &) override
 

Private Attributes

edm::EDGetTokenT< EBDigiCollectiondigisEBInToken_
 
edm::EDGetTokenT< EEDigiCollectiondigisEEInToken_
 
edm::InputTag digisIn_
 
std::string digisOut_
 
edm::InputTag recHits_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsToken_
 
ecalRegion region_
 
edm::EDGetTokenT< EBSrFlagCollectionsrFlagsEBInToken_
 
edm::EDGetTokenT< EESrFlagCollectionsrFlagsEEInToken_
 
edm::InputTag srFlagsIn_
 
std::string srFlagsOut_
 

Additional Inherited Members

- 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: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file HLTRechitsToDigis.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

HLTRechitsToDigis::HLTRechitsToDigis ( const edm::ParameterSet iConfig)
explicit

Definition at line 86 of file HLTRechitsToDigis.cc.

References barrel, digisEBInToken_, digisEEInToken_, digisIn_, digisOut_, endcap, edm::ParameterSet::getParameter(), invalidRegion, edm::InputTag::label(), recHits_, recHitsToken_, region_, srFlagsEBInToken_, srFlagsEEInToken_, srFlagsIn_, srFlagsOut_, AlCaHLTBitMon_QueryRunRegistry::string, and stringToRegion().

87 {
88  //region to do rechit digi matching
89  region_ = stringToRegion(iConfig.getParameter<std::string> ("region"));
90 
91  // digis to match to hit collections
92  digisIn_ = iConfig.getParameter<edm::InputTag> ("digisIn");
93  digisOut_ = iConfig.getParameter<std::string> ("digisOut");
94 
95  // hit collections to save digis for
96  recHits_ = iConfig.getParameter<edm::InputTag> ("recHits");
97 
98  // srFlags matched to digis to be saved
99  srFlagsIn_ = iConfig.getParameter<edm::InputTag> ("srFlagsIn");
100  srFlagsOut_ = iConfig.getParameter<std::string> ("srFlagsOut");
101 
102  // region specific tokens
103  switch(region_) {
104  case barrel:
105  digisEBInToken_ = consumes<EBDigiCollection>(digisIn_);
106  produces<EBDigiCollection>(digisOut_);
107  // protection against empty InputTag to allow for backward compatibility
108  if (not srFlagsIn_.label().empty()) {
109  srFlagsEBInToken_ = consumes<EBSrFlagCollection>(srFlagsIn_);
110  produces<EBSrFlagCollection>(srFlagsOut_);
111  }
112  break;
113  case endcap:
114  digisEEInToken_ = consumes<EEDigiCollection>(digisIn_);
115  produces<EEDigiCollection>(digisOut_);
116  // protection against empty InputTag to allow for backward compatibility
117  if (not srFlagsIn_.label().empty()) {
118  srFlagsEEInToken_ = consumes<EESrFlagCollection>(srFlagsIn_);
119  produces<EESrFlagCollection>(srFlagsOut_);
120  }
121  break;
122  case invalidRegion:
123  break;
124  }
125 
126  recHitsToken_ = consumes<EcalRecHitCollection>(recHits_);
127 }
T getParameter(std::string const &) const
edm::EDGetTokenT< EBSrFlagCollection > srFlagsEBInToken_
edm::EDGetTokenT< EESrFlagCollection > srFlagsEEInToken_
edm::EDGetTokenT< EEDigiCollection > digisEEInToken_
static const HLTRechitsToDigis::ecalRegion stringToRegion(const std::string &region)
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
edm::InputTag digisIn_
edm::InputTag recHits_
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag srFlagsIn_
edm::EDGetTokenT< EBDigiCollection > digisEBInToken_
HLTRechitsToDigis::~HLTRechitsToDigis ( )
override

Definition at line 129 of file HLTRechitsToDigis.cc.

130 {
131  // do anything here that needs to be done at desctruction time
132  // (e.g. close files, deallocate resources etc.)
133 }

Member Function Documentation

void HLTRechitsToDigis::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 293 of file HLTRechitsToDigis.cc.

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

293  {
294  //The following says we do not know what parameters are allowed so do no validation
295  // Please change this to state exactly what you do use, even if it is no parameters
297 
298  desc.add<std::string>("region", "barrel")
299  ->setComment("Region of rechits to save Digis for. Allowed values: barrel or endcap.");
300  desc.add<edm::InputTag>("digisIn",edm::InputTag("ecalDigis","ebDigis"))
301  ->setComment("The collection of either barrel or endcap digis which correspond to the rechit collection");
302  desc.add<std::string>("digisOut","pi0EBDigis")
303  ->setComment("Name for the collection of Digis saved by the module");
304  desc.add<edm::InputTag>("recHits",edm::InputTag("hltAlCaPi0EBUncalibrator","pi0EcalRecHitsEB"))
305  ->setComment("Collection of rechits to match Digis to");
306  desc.add<edm::InputTag>("srFlagsIn",edm::InputTag())
307  ->setComment("The collection of either barrel or endcap srFlags which correspond to the rechit collection");
308  desc.add<std::string>("srFlagsOut","pi0EBSrFlags")
309  ->setComment("Name for the collection of SrFlags saved by the module");
310  descriptions.add("hltFindMatchingECALDigisToRechits", desc);
311 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HLTRechitsToDigis::produce ( edm::Event iEvent,
edm::EventSetup const &  setup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 148 of file HLTRechitsToDigis.cc.

References barrel, edm::SortedCollection< T, SORT >::begin(), digisEBInToken_, digisEEInToken_, digisOut_, edm::SortedCollection< T, SORT >::end(), edm::DataFrameContainer::end(), endcap, edm::SortedCollection< T, SORT >::find(), edm::DataFrameContainer::find(), edm::Event::getByToken(), EcalRecHit::id(), invalidRegion, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), EcalReadoutTools::readOutUnitOf(), recHitsToken_, region_, srFlagsEBInToken_, srFlagsEEInToken_, srFlagsOut_, and ecaldqm::ttId().

148  {
149  using namespace edm;
150  // handles for digis
151  Handle<EBDigiCollection> digisEBHandle;
152  Handle<EEDigiCollection> digisEEHandle;
153 
154  // output collections
155  std::unique_ptr<EBDigiCollection> outputEBDigiCollection( new EBDigiCollection );
156  std::unique_ptr<EEDigiCollection> outputEEDigiCollection( new EEDigiCollection );
157 
158  // handles for srFlags
159  Handle<EBSrFlagCollection> srFlagsEBHandle;
160  Handle<EESrFlagCollection> srFlagsEEHandle;
161 
162  // output collections
163  std::unique_ptr<EBSrFlagCollection> outputEBSrFlagCollection( new EBSrFlagCollection );
164  std::unique_ptr<EESrFlagCollection> outputEESrFlagCollection( new EESrFlagCollection );
165  EcalReadoutTools ecalReadOutTool(iEvent, setup);
166 
167  // calibrated rechits
168  Handle<EcalRecHitCollection> recHitsHandle;
169  iEvent.getByToken(recHitsToken_, recHitsHandle);
170 
171  // match the digis based on the region
172  switch(region_) {
173  case barrel: {
174  iEvent.getByToken(digisEBInToken_, digisEBHandle);
175  const EBDigiCollection* digisEB = digisEBHandle.product();
176 
177  const EBSrFlagCollection* srFlagsEB = nullptr;
178  // protection against uninitialized token (empty InputTag) to allow for backward compatibility
179  if (not srFlagsEBInToken_.isUninitialized()) {
180  iEvent.getByToken(srFlagsEBInToken_, srFlagsEBHandle);
181  srFlagsEB = srFlagsEBHandle.product();
182  }
183 
184  // loop over the collection of rechits and match to digis
185  // at the same time, create the new sfFlags collection from the original one, keeping only the flags matched to digis
187  for (ituneEB = recHitsHandle->begin(); ituneEB != recHitsHandle->end(); ituneEB++) {
188  EcalRecHit const & hit = (*ituneEB);
189  EcalDigiCollection::const_iterator digiLookUp = digisEB->find(hit.id());
190  // protect against a digi not existing
191  if( digiLookUp == digisEB->end()) continue;
192  outputEBDigiCollection->push_back( digiLookUp->id(), digiLookUp->begin() );
193 
195  if (not srFlagsEBInToken_.isUninitialized()) {
196  // same matching for srFlags
197  // firstly, get the tower id
198  const EcalTrigTowerDetId& ttId = ecalReadOutTool.readOutUnitOf( static_cast<EBDetId>(hit.id()) );
199  // avoid inserting the same tower twice in the output collection (all the digis in the same tower will have the same SR flag)
200  if (outputEBSrFlagCollection->find(ttId) != outputEBSrFlagCollection->end()) continue;
201  srFlagLookUp = srFlagsEB->find( ttId );
202  // protect against a srFlag not existing
203  if( srFlagLookUp == srFlagsEB->end()) continue;
204  outputEBSrFlagCollection->push_back( *srFlagLookUp );
205  }
206  }
207 
208  // add the built collection to the event
209  iEvent.put(std::move(outputEBDigiCollection), digisOut_);
210  if (not srFlagsEBInToken_.isUninitialized()) iEvent.put(std::move(outputEBSrFlagCollection), srFlagsOut_);
211  break;
212  }
213  case endcap: {
214  iEvent.getByToken(digisEEInToken_, digisEEHandle);
215  const EEDigiCollection* digisEE = digisEEHandle.product();
216 
217  const EESrFlagCollection* srFlagsEE = nullptr;
218  // protection against uninitialized token (empty InputTag) to allow for backward compatibility
219  if (not srFlagsEEInToken_.isUninitialized()) {
220  iEvent.getByToken(srFlagsEEInToken_, srFlagsEEHandle);
221  srFlagsEE = srFlagsEEHandle.product();
222  }
223 
224  // loop over the collection of rechits and match to digis
225  // at the same time, create the new sfFlags collection from the original one, keeping only the flags matched to digis
227  for (ituneEE = recHitsHandle->begin(); ituneEE != recHitsHandle->end(); ituneEE++) {
228  EcalRecHit const & hit = (*ituneEE);
229  EcalDigiCollection::const_iterator digiLookUp = digisEE->find(hit.id());
230  // protect against a digi not existing for the saved rechit
231  if(digiLookUp == digisEE->end()) continue;
232  outputEEDigiCollection->push_back( digiLookUp->id(), digiLookUp->begin() );
233 
235  if (not srFlagsEEInToken_.isUninitialized()) {
236  // same matching for srFlags
237  // firstly, get the tower id
238  const EcalScDetId& scId = ecalReadOutTool.readOutUnitOf( static_cast<EEDetId>(hit.id()) );
239  // avoid inserting the same tower twice in the output collection (all the digis in the same tower will have the same SR flag)
240  if (outputEESrFlagCollection->find(scId) != outputEESrFlagCollection->end()) continue;
241  srFlagLookUp = srFlagsEE->find( scId );
242  // protect against an srFlag not existing for the saved rechit
243  if(srFlagLookUp == srFlagsEE->end()) continue;
244  outputEESrFlagCollection->push_back( *srFlagLookUp );
245  }
246  } // end loop over endcap rechits
247 
248  // add the built collection to the event
249  iEvent.put(std::move(outputEEDigiCollection), digisOut_);
250  if (not srFlagsEEInToken_.isUninitialized()) iEvent.put(std::move(outputEESrFlagCollection), srFlagsOut_);
251  break;
252  }
253  case invalidRegion: {
254  break;
255  }
256  } // end switch statement for the region (barrel, endcap, invalid)
257 }
edm::EDGetTokenT< EBSrFlagCollection > srFlagsEBInToken_
edm::EDGetTokenT< EESrFlagCollection > srFlagsEEInToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
std::vector< EcalRecHit >::const_iterator const_iterator
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
edm::EDGetTokenT< EEDigiCollection > digisEEInToken_
unsigned ttId(DetId const &)
const_iterator find(id_type i) const
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
const_iterator end() const
DetId id() const
get the id
Definition: EcalRecHit.h:77
T const * product() const
Definition: Handle.h:81
const_iterator end() const
iterator find(key_type k)
HLT enums.
edm::EDGetTokenT< EBDigiCollection > digisEBInToken_
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const
const HLTRechitsToDigis::ecalRegion HLTRechitsToDigis::stringToRegion ( const std::string &  region)
static

Definition at line 139 of file HLTRechitsToDigis.cc.

References barrel, endcap, and invalidRegion.

Referenced by HLTRechitsToDigis().

139  {
140  if (region == "barrel") return barrel;
141  else if (region == "endcap") return endcap;
142  else return invalidRegion;
143 }

Member Data Documentation

edm::EDGetTokenT<EBDigiCollection> HLTRechitsToDigis::digisEBInToken_
private

Definition at line 61 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

edm::EDGetTokenT<EEDigiCollection> HLTRechitsToDigis::digisEEInToken_
private

Definition at line 62 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

edm::InputTag HLTRechitsToDigis::digisIn_
private

Definition at line 69 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis().

std::string HLTRechitsToDigis::digisOut_
private

Definition at line 75 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

edm::InputTag HLTRechitsToDigis::recHits_
private

Definition at line 70 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis().

edm::EDGetTokenT<EcalRecHitCollection> HLTRechitsToDigis::recHitsToken_
private

Definition at line 63 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

ecalRegion HLTRechitsToDigis::region_
private

Definition at line 76 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

edm::EDGetTokenT<EBSrFlagCollection> HLTRechitsToDigis::srFlagsEBInToken_
private

Definition at line 65 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

edm::EDGetTokenT<EESrFlagCollection> HLTRechitsToDigis::srFlagsEEInToken_
private

Definition at line 66 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

edm::InputTag HLTRechitsToDigis::srFlagsIn_
private

Definition at line 72 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis().

std::string HLTRechitsToDigis::srFlagsOut_
private

Definition at line 78 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().