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<>

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 Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static const HLTRechitsToDigis::ecalRegion stringToRegion (const std::string &region)
 

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_
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 46 of file HLTRechitsToDigis.cc.

Member Enumeration Documentation

◆ ecalRegion

Enumerator
invalidRegion 
barrel 
endcap 

Definition at line 51 of file HLTRechitsToDigis.cc.

51 { invalidRegion = 0, barrel, endcap };

Constructor & Destructor Documentation

◆ HLTRechitsToDigis()

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

Definition at line 83 of file HLTRechitsToDigis.cc.

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

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

◆ ~HLTRechitsToDigis()

HLTRechitsToDigis::~HLTRechitsToDigis ( )
override

Definition at line 125 of file HLTRechitsToDigis.cc.

125  {
126  // do anything here that needs to be done at desctruction time
127  // (e.g. close files, deallocate resources etc.)
128 }

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 295 of file HLTRechitsToDigis.cc.

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

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ produce()

void HLTRechitsToDigis::produce ( edm::Event iEvent,
edm::EventSetup const &  setup 
)
overrideprivate

Definition at line 143 of file HLTRechitsToDigis.cc.

143  {
144  using namespace edm;
145  // handles for digis
146  Handle<EBDigiCollection> digisEBHandle;
147  Handle<EEDigiCollection> digisEEHandle;
148 
149  // output collections
150  std::unique_ptr<EBDigiCollection> outputEBDigiCollection(new EBDigiCollection);
151  std::unique_ptr<EEDigiCollection> outputEEDigiCollection(new EEDigiCollection);
152 
153  // handles for srFlags
154  Handle<EBSrFlagCollection> srFlagsEBHandle;
155  Handle<EESrFlagCollection> srFlagsEEHandle;
156 
157  // output collections
158  std::unique_ptr<EBSrFlagCollection> outputEBSrFlagCollection(new EBSrFlagCollection);
159  std::unique_ptr<EESrFlagCollection> outputEESrFlagCollection(new EESrFlagCollection);
160  EcalReadoutTools ecalReadOutTool(iEvent, setup);
161 
162  // calibrated rechits
163  Handle<EcalRecHitCollection> recHitsHandle;
164  iEvent.getByToken(recHitsToken_, recHitsHandle);
165 
166  // match the digis based on the region
167  switch (region_) {
168  case barrel: {
169  iEvent.getByToken(digisEBInToken_, digisEBHandle);
170  const EBDigiCollection* digisEB = digisEBHandle.product();
171 
172  const EBSrFlagCollection* srFlagsEB = nullptr;
173  // protection against uninitialized token (empty InputTag) to allow for backward compatibility
174  if (not srFlagsEBInToken_.isUninitialized()) {
175  iEvent.getByToken(srFlagsEBInToken_, srFlagsEBHandle);
176  srFlagsEB = srFlagsEBHandle.product();
177  }
178 
179  // loop over the collection of rechits and match to digis
180  // at the same time, create the new sfFlags collection from the original one, keeping only the flags matched to digis
182  for (ituneEB = recHitsHandle->begin(); ituneEB != recHitsHandle->end(); ituneEB++) {
183  EcalRecHit const& hit = (*ituneEB);
184  EcalDigiCollection::const_iterator digiLookUp = digisEB->find(hit.id());
185  // protect against a digi not existing
186  if (digiLookUp == digisEB->end())
187  continue;
188  outputEBDigiCollection->push_back(digiLookUp->id(), digiLookUp->begin());
189 
191  if (not srFlagsEBInToken_.isUninitialized()) {
192  // same matching for srFlags
193  // firstly, get the tower id
194  const EcalTrigTowerDetId& ttId = ecalReadOutTool.readOutUnitOf(static_cast<EBDetId>(hit.id()));
195  // avoid inserting the same tower twice in the output collection (all the digis in the same tower will have the same SR flag)
196  if (outputEBSrFlagCollection->find(ttId) != outputEBSrFlagCollection->end())
197  continue;
198  srFlagLookUp = srFlagsEB->find(ttId);
199  // protect against a srFlag not existing
200  if (srFlagLookUp == srFlagsEB->end())
201  continue;
202  outputEBSrFlagCollection->push_back(*srFlagLookUp);
203  }
204  }
205 
206  // add the built collection to the event
207  iEvent.put(std::move(outputEBDigiCollection), digisOut_);
208  if (not srFlagsEBInToken_.isUninitialized())
209  iEvent.put(std::move(outputEBSrFlagCollection), srFlagsOut_);
210  break;
211  }
212  case endcap: {
213  iEvent.getByToken(digisEEInToken_, digisEEHandle);
214  const EEDigiCollection* digisEE = digisEEHandle.product();
215 
216  const EESrFlagCollection* srFlagsEE = nullptr;
217  // protection against uninitialized token (empty InputTag) to allow for backward compatibility
218  if (not srFlagsEEInToken_.isUninitialized()) {
219  iEvent.getByToken(srFlagsEEInToken_, srFlagsEEHandle);
220  srFlagsEE = srFlagsEEHandle.product();
221  }
222 
223  // loop over the collection of rechits and match to digis
224  // at the same time, create the new sfFlags collection from the original one, keeping only the flags matched to digis
226  for (ituneEE = recHitsHandle->begin(); ituneEE != recHitsHandle->end(); ituneEE++) {
227  EcalRecHit const& hit = (*ituneEE);
228  EcalDigiCollection::const_iterator digiLookUp = digisEE->find(hit.id());
229  // protect against a digi not existing for the saved rechit
230  if (digiLookUp == digisEE->end())
231  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())
241  continue;
242  srFlagLookUp = srFlagsEE->find(scId);
243  // protect against an srFlag not existing for the saved rechit
244  if (srFlagLookUp == srFlagsEE->end())
245  continue;
246  outputEESrFlagCollection->push_back(*srFlagLookUp);
247  }
248  } // end loop over endcap rechits
249 
250  // add the built collection to the event
251  iEvent.put(std::move(outputEEDigiCollection), digisOut_);
252  if (not srFlagsEEInToken_.isUninitialized())
253  iEvent.put(std::move(outputEESrFlagCollection), srFlagsOut_);
254  break;
255  }
256  case invalidRegion: {
257  break;
258  }
259  } // end switch statement for the region (barrel, endcap, invalid)
260 }

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(), hit::id, iEvent, invalidRegion, eostools::move(), edm::Handle< T >::product(), EcalReadoutTools::readOutUnitOf(), recHitsToken_, region_, singleTopDQM_cfi::setup, srFlagsEBInToken_, srFlagsEEInToken_, srFlagsOut_, and ecaldqm::ttId().

◆ stringToRegion()

const HLTRechitsToDigis::ecalRegion HLTRechitsToDigis::stringToRegion ( const std::string &  region)
static

Definition at line 133 of file HLTRechitsToDigis.cc.

133  {
134  if (region == "barrel")
135  return barrel;
136  else if (region == "endcap")
137  return endcap;
138  else
139  return invalidRegion;
140 }

References barrel, endcap, invalidRegion, and HLT_FULL_cff::region.

Referenced by HLTRechitsToDigis().

Member Data Documentation

◆ digisEBInToken_

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

Definition at line 59 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ digisEEInToken_

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

Definition at line 60 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ digisIn_

edm::InputTag HLTRechitsToDigis::digisIn_
private

Definition at line 67 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis().

◆ digisOut_

std::string HLTRechitsToDigis::digisOut_
private

Definition at line 73 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ recHits_

edm::InputTag HLTRechitsToDigis::recHits_
private

Definition at line 68 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis().

◆ recHitsToken_

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

Definition at line 61 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ region_

ecalRegion HLTRechitsToDigis::region_
private

Definition at line 74 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ srFlagsEBInToken_

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

Definition at line 63 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ srFlagsEEInToken_

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

Definition at line 64 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

◆ srFlagsIn_

edm::InputTag HLTRechitsToDigis::srFlagsIn_
private

Definition at line 70 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis().

◆ srFlagsOut_

std::string HLTRechitsToDigis::srFlagsOut_
private

Definition at line 76 of file HLTRechitsToDigis.cc.

Referenced by HLTRechitsToDigis(), and produce().

EcalRecHit
Definition: EcalRecHit.h:15
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HLTRechitsToDigis::digisOut_
std::string digisOut_
Definition: HLTRechitsToDigis.cc:73
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
HLTRechitsToDigis::digisEBInToken_
edm::EDGetTokenT< EBDigiCollection > digisEBInToken_
Definition: HLTRechitsToDigis.cc:59
HLTRechitsToDigis::srFlagsOut_
std::string srFlagsOut_
Definition: HLTRechitsToDigis.cc:76
HLTRechitsToDigis::digisEEInToken_
edm::EDGetTokenT< EEDigiCollection > digisEEInToken_
Definition: HLTRechitsToDigis.cc:60
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ecaldqm::ttId
unsigned ttId(DetId const &)
Definition: EcalDQMCommonUtils.cc:101
edm::SortedCollection
Definition: SortedCollection.h:49
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
edm::Handle< EBDigiCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
HLTRechitsToDigis::invalidRegion
Definition: HLTRechitsToDigis.cc:51
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
EcalScDetId
Definition: EcalScDetId.h:24
HLTRechitsToDigis::digisIn_
edm::InputTag digisIn_
Definition: HLTRechitsToDigis.cc:67
HLTRechitsToDigis::recHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
Definition: HLTRechitsToDigis.cc:61
HLTRechitsToDigis::stringToRegion
static const HLTRechitsToDigis::ecalRegion stringToRegion(const std::string &region)
Definition: HLTRechitsToDigis.cc:133
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EBDigiCollection
Definition: EcalDigiCollections.h:56
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EEDigiCollection
Definition: EcalDigiCollections.h:69
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
iEvent
int iEvent
Definition: GenABIO.cc:224
HLTRechitsToDigis::barrel
Definition: HLTRechitsToDigis.cc:51
edm::DataFrameContainer::find
const_iterator find(id_type i) const
Definition: DataFrameContainer.h:141
HLTRechitsToDigis::endcap
Definition: HLTRechitsToDigis.cc:51
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTRechitsToDigis::srFlagsIn_
edm::InputTag srFlagsIn_
Definition: HLTRechitsToDigis.cc:70
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HLTRechitsToDigis::region_
ecalRegion region_
Definition: HLTRechitsToDigis.cc:74
HLTRechitsToDigis::srFlagsEEInToken_
edm::EDGetTokenT< EESrFlagCollection > srFlagsEEInToken_
Definition: HLTRechitsToDigis.cc:64
HLTRechitsToDigis::recHits_
edm::InputTag recHits_
Definition: HLTRechitsToDigis.cc:68
EcalReadoutTools
Definition: EcalReadoutTools.h:13
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
edm::InputTag
Definition: InputTag.h:15
HLTRechitsToDigis::srFlagsEBInToken_
edm::EDGetTokenT< EBSrFlagCollection > srFlagsEBInToken_
Definition: HLTRechitsToDigis.cc:63
hit
Definition: SiStripHitEffFromCalibTree.cc:88