CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CaloCleaner< T > Class Template Reference

#include <CaloCleaner.h>

Inheritance diagram for CaloCleaner< T >:
edm::stream::EDProducer<>

Public Member Functions

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

Private Types

typedef edm::SortedCollection< TRecHitCollection
 

Private Member Functions

void fill_correction_map (TrackDetMatchInfo *, std::map< uint32_t, float > *)
 
template<>
void fill_correction_map (TrackDetMatchInfo *info, std::map< uint32_t, float > *cor_map)
 
template<>
void fill_correction_map (TrackDetMatchInfo *info, std::map< uint32_t, float > *cor_map)
 
template<>
void fill_correction_map (TrackDetMatchInfo *info, std::map< uint32_t, float > *cor_map)
 
template<>
void fill_correction_map (TrackDetMatchInfo *info, std::map< uint32_t, float > *cor_map)
 
template<>
void fill_correction_map (TrackDetMatchInfo *info, std::map< uint32_t, float > *cor_map)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
 
bool is_preshower_
 
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
 
TrackAssociatorParameters parameters_
 
edm::ESGetToken< Propagator, TrackingComponentsRecordpropagatorToken_
 
TrackDetectorAssociator trackAssociator_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T>
class CaloCleaner< T >

Clean collections of calorimeter recHits (detectors supported: EB/EE, HB/HE and HO)

Author
Tomasz Maciej Frueboes; Christian Veelken, LLR Clean Up from STefan Wayand, KIT Clean Up from Christian Winter & Sebastian Brommer, KIT

Definition at line 34 of file CaloCleaner.h.

Member Typedef Documentation

◆ RecHitCollection

template<typename T >
typedef edm::SortedCollection<T> CaloCleaner< T >::RecHitCollection
private

Definition at line 42 of file CaloCleaner.h.

Constructor & Destructor Documentation

◆ CaloCleaner()

template<typename T >
CaloCleaner< T >::CaloCleaner ( const edm::ParameterSet iConfig)
explicit

Definition at line 16 of file CaloCleaner.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), CaloCleaner< T >::inputs_, CaloCleaner< T >::is_preshower_, TrackAssociatorParameters::loadParameters(), and CaloCleaner< T >::parameters_.

17  : mu_input_(consumes<edm::View<pat::Muon>>(iConfig.getParameter<edm::InputTag>("MuonCollection"))),
18  propagatorToken_(esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))) {
19  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag>>("oldCollection");
20  for (const auto &inCollection : inCollections) {
21  inputs_[inCollection.instance()] = consumes<RecHitCollection>(inCollection);
22  produces<RecHitCollection>(inCollection.instance());
23  }
24 
25  is_preshower_ = iConfig.getUntrackedParameter<bool>("is_preshower", false);
26  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
27  edm::ConsumesCollector iC = consumesCollector();
29 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:44
T getUntrackedParameter(std::string const &, T const &) const
bool is_preshower_
Definition: CaloCleaner.h:52
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
Definition: CaloCleaner.h:47
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:50
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:46

◆ ~CaloCleaner()

template<typename T >
CaloCleaner< T >::~CaloCleaner ( )
override

Definition at line 32 of file CaloCleaner.cc.

32  {
33  // nothing to be done yet...
34 }

Member Function Documentation

◆ fill_correction_map() [1/6]

template<typename T >
void CaloCleaner< T >::fill_correction_map ( TrackDetMatchInfo ,
std::map< uint32_t, float > *   
)
private

Definition at line 92 of file CaloCleaner.cc.

References cms::cuda::assert().

92  {
93  assert(0);
94 }
assert(be >=bs)

◆ fill_correction_map() [2/6]

template<>
void CaloCleaner< EcalRecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 97 of file CaloCleaner.cc.

References hcalRecHitTable_cff::detId, and info().

97  {
98  if (is_preshower_) {
99  for (std::vector<DetId>::const_iterator detId = info->crossedPreshowerIds.begin();
100  detId != info->crossedPreshowerIds.end();
101  ++detId) {
102  (*cor_map)[detId->rawId()] = 9999999; // just remove all energy (Below 0 is not possible)
103  }
104  } else {
105  for (std::vector<const EcalRecHit *>::const_iterator hit = info->crossedEcalRecHits.begin();
106  hit != info->crossedEcalRecHits.end();
107  hit++) {
108  (*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
109  }
110  }
111 }
static const TGPicture * info(bool iBackgroundIsBlack)
bool is_preshower_
Definition: CaloCleaner.h:52

◆ fill_correction_map() [3/6]

template<>
void CaloCleaner< HBHERecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 114 of file CaloCleaner.cc.

References info().

114  {
115  for (std::vector<const HBHERecHit *>::const_iterator hit = info->crossedHcalRecHits.begin();
116  hit != info->crossedHcalRecHits.end();
117  hit++) {
118  (*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
119  }
120 }
static const TGPicture * info(bool iBackgroundIsBlack)

◆ fill_correction_map() [4/6]

template<>
void CaloCleaner< HORecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 123 of file CaloCleaner.cc.

References info().

123  {
124  for (std::vector<const HORecHit *>::const_iterator hit = info->crossedHORecHits.begin();
125  hit != info->crossedHORecHits.end();
126  hit++) {
127  (*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
128  }
129 }
static const TGPicture * info(bool iBackgroundIsBlack)

◆ fill_correction_map() [5/6]

template<>
void CaloCleaner< HFRecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 132 of file CaloCleaner.cc.

132  {
133  return; // No corrections for HF
134 }

◆ fill_correction_map() [6/6]

template<>
void CaloCleaner< ZDCRecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 137 of file CaloCleaner.cc.

137  {
138  return; // No corrections for ZDC
139 }

◆ produce()

template<typename T >
void CaloCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 37 of file CaloCleaner.cc.

References TrackDetectorAssociator::Any, Exception, edm::EventSetup::getData(), iEvent, info(), eostools::move(), DiMuonV_cfg::muons, TrackCandidateProducer_cfi::propagator, rpcPointValidation_cfi::recHit, and HLT_2024v14_cff::track.

37  {
38  auto const &propagator = iSetup.getData(propagatorToken_);
40 
42  iEvent.getByToken(mu_input_, muonHandle);
43  edm::View<pat::Muon> muons = *muonHandle;
44 
45  std::map<uint32_t, float> correction_map;
46 
47  // Fill the correction map
48  for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
49  const reco::Track *track = nullptr;
50  if (iMuon->track().isNonnull())
51  track = iMuon->track().get();
52  else if (iMuon->standAloneMuon().isNonnull())
53  track = iMuon->standAloneMuon().get();
54  else
55  throw cms::Exception("FatalError")
56  << "Failed to fill muon id information for a muon with undefined references to tracks";
59  fill_correction_map(&info, &correction_map);
60  }
61 
62  // Copy the old collection and correct if necessary
63  for (auto input_ : inputs_) {
64  std::unique_ptr<RecHitCollection> recHitCollection_output(new RecHitCollection());
65  edm::Handle<RecHitCollection> recHitCollection;
66  iEvent.getByToken(input_.second, recHitCollection);
67  for (typename RecHitCollection::const_iterator recHit = recHitCollection->begin();
68  recHit != recHitCollection->end();
69  ++recHit) {
70  if (correction_map[recHit->detid().rawId()] > 0) {
71  float new_energy = recHit->energy() - correction_map[recHit->detid().rawId()];
72  if (new_energy <= 0)
73  continue; // Do not save empty Hits
74  T newRecHit(*recHit);
75  newRecHit.setEnergy(new_energy);
76  recHitCollection_output->push_back(newRecHit);
77  } else {
78  recHitCollection_output->push_back(*recHit);
79  }
80  }
81  // Save the new collection
82  recHitCollection_output->sort();
83  iEvent.put(std::move(recHitCollection_output), input_.first);
84  }
85 }
static const TGPicture * info(bool iBackgroundIsBlack)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void fill_correction_map(TrackDetMatchInfo *, std::map< uint32_t, float > *)
Definition: CaloCleaner.cc:92
std::vector< T >::const_iterator const_iterator
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:44
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
edm::SortedCollection< T > RecHitCollection
Definition: CaloCleaner.h:42
int iEvent
Definition: GenABIO.cc:224
void setPropagator(const Propagator *)
use a user configured propagator
const_iterator begin() const
const_iterator end() const
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
Definition: CaloCleaner.h:47
TrackDetectorAssociator trackAssociator_
Definition: CaloCleaner.h:49
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:50
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:46
long double T
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ inputs_

template<typename T >
std::map<std::string, edm::EDGetTokenT<RecHitCollection> > CaloCleaner< T >::inputs_
private

Definition at line 46 of file CaloCleaner.h.

Referenced by CaloCleaner< T >::CaloCleaner().

◆ is_preshower_

template<typename T >
bool CaloCleaner< T >::is_preshower_
private

Definition at line 52 of file CaloCleaner.h.

Referenced by CaloCleaner< T >::CaloCleaner().

◆ mu_input_

template<typename T >
const edm::EDGetTokenT<edm::View<pat::Muon> > CaloCleaner< T >::mu_input_
private

Definition at line 44 of file CaloCleaner.h.

◆ parameters_

template<typename T >
TrackAssociatorParameters CaloCleaner< T >::parameters_
private

◆ propagatorToken_

template<typename T >
edm::ESGetToken<Propagator, TrackingComponentsRecord> CaloCleaner< T >::propagatorToken_
private

Definition at line 47 of file CaloCleaner.h.

◆ trackAssociator_

template<typename T >
TrackDetectorAssociator CaloCleaner< T >::trackAssociator_
private

Definition at line 49 of file CaloCleaner.h.