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

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 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)
 
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 at the moment: EB/EE, HB/HE and HO)

Author
Tomasz Maciej Frueboes; Christian Veelken, LLR

Clean Up from STefan Wayand, KIT

Definition at line 36 of file CaloCleaner.h.

Member Typedef Documentation

◆ RecHitCollection

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

Definition at line 44 of file CaloCleaner.h.

Constructor & Destructor Documentation

◆ CaloCleaner()

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

Definition at line 59 of file CaloCleaner.h.

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

60  : mu_input_(consumes<edm::View<pat::Muon> >(iConfig.getParameter<edm::InputTag>("MuonCollection"))),
61  propagatorToken_(esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))) {
62  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag> >("oldCollection");
63  for (const auto& inCollection : inCollections) {
64  inputs_[inCollection.instance()] = consumes<RecHitCollection>(inCollection);
65  produces<RecHitCollection>(inCollection.instance());
66  }
67 
68  is_preshower_ = iConfig.getUntrackedParameter<bool>("is_preshower", false);
69  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
70  edm::ConsumesCollector iC = consumesCollector();
72  //trackAssociator_.useDefaultPropagator();
73 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:46
T getUntrackedParameter(std::string const &, T const &) const
bool is_preshower_
Definition: CaloCleaner.h:54
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
Definition: CaloCleaner.h:49
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:52
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:48

◆ ~CaloCleaner()

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

Definition at line 76 of file CaloCleaner.h.

76  {
77  // nothing to be done yet...
78 }

Member Function Documentation

◆ fill_correction_map() [1/7]

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

Definition at line 28 of file CaloCleaner.cc.

References info().

28  {
29  if (is_preshower_) {
30  for (std::vector<DetId>::const_iterator detId = info->crossedPreshowerIds.begin();
31  detId != info->crossedPreshowerIds.end();
32  ++detId) {
33  (*cor_map)[detId->rawId()] = 9999999; // just remove all energy (Below 0 is not possible)
34  }
35  } else {
36  for (std::vector<const EcalRecHit *>::const_iterator hit = info->crossedEcalRecHits.begin();
37  hit != info->crossedEcalRecHits.end();
38  hit++) {
39  // (*cor_map) [(*hit)->detid().rawId()] +=(*hit)->energy();
40  (*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
41  }
42  }
43 }
static const TGPicture * info(bool iBackgroundIsBlack)
bool is_preshower_
Definition: CaloCleaner.h:54

◆ fill_correction_map() [2/7]

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

Definition at line 46 of file CaloCleaner.cc.

References info().

46  {
47  for (std::vector<const HBHERecHit *>::const_iterator hit = info->crossedHcalRecHits.begin();
48  hit != info->crossedHcalRecHits.end();
49  hit++) {
50  (*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
51  }
52 }
static const TGPicture * info(bool iBackgroundIsBlack)

◆ fill_correction_map() [3/7]

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

Definition at line 55 of file CaloCleaner.cc.

References info().

55  {
56  for (std::vector<const HORecHit *>::const_iterator hit = info->crossedHORecHits.begin();
57  hit != info->crossedHORecHits.end();
58  hit++) {
59  (*cor_map)[(*hit)->detid().rawId()] = (*hit)->energy();
60  }
61 }
static const TGPicture * info(bool iBackgroundIsBlack)

◆ fill_correction_map() [4/7]

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

Definition at line 22 of file CaloCleaner.cc.

References cms::cuda::assert().

22  {
23  assert(0); // CV: make sure general function never gets called;
24  // always use template specializations
25 }
assert(be >=bs)

◆ fill_correction_map() [5/7]

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

Definition at line 64 of file CaloCleaner.cc.

64  {
65  return; // No corrections for HF
66 }

◆ fill_correction_map() [6/7]

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

Definition at line 69 of file CaloCleaner.cc.

69  {
70  return; // No corrections for Castor
71 }

◆ fill_correction_map() [7/7]

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

Definition at line 74 of file CaloCleaner.cc.

74  {
75  return; // No corrections for Castor
76 }

◆ produce()

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

Definition at line 81 of file CaloCleaner.h.

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

81  {
82  auto const& propagator = iSetup.getData(propagatorToken_);
84 
86  iEvent.getByToken(mu_input_, muonHandle);
87  edm::View<pat::Muon> muons = *muonHandle;
88 
89  std::map<uint32_t, float> correction_map;
90 
91  // Fill the correction map
92  for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
93  // get the basic informaiton like fill reco mouon does
94  // RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc
95  const reco::Track* track = nullptr;
96  if (iMuon->track().isNonnull())
97  track = iMuon->track().get();
98  else if (iMuon->standAloneMuon().isNonnull())
99  track = iMuon->standAloneMuon().get();
100  else
101  throw cms::Exception("FatalError")
102  << "Failed to fill muon id information for a muon with undefined references to tracks";
105  fill_correction_map(&info, &correction_map);
106  }
107 
108  // Copy the old collection and correct if necessary
109  for (auto input_ : inputs_) {
110  std::unique_ptr<RecHitCollection> recHitCollection_output(new RecHitCollection());
111  edm::Handle<RecHitCollection> recHitCollection;
112  // iEvent.getByToken(input_.second[0], recHitCollection);
113  iEvent.getByToken(input_.second, recHitCollection);
114  for (typename RecHitCollection::const_iterator recHit = recHitCollection->begin();
115  recHit != recHitCollection->end();
116  ++recHit) {
117  if (correction_map[recHit->detid().rawId()] > 0) {
118  float new_energy = recHit->energy() - correction_map[recHit->detid().rawId()];
119  if (new_energy <= 0)
120  continue; // Do not save empty Hits
121  T newRecHit(*recHit);
122  newRecHit.setEnergy(new_energy);
123  recHitCollection_output->push_back(newRecHit);
124  } else {
125  recHitCollection_output->push_back(*recHit);
126  }
127  /* For the inveted collection
128  if (correction_map[recHit->detid().rawId()] > 0){
129  float new_energy = correction_map[recHit->detid().rawId()];
130  if (new_energy < 0) new_energy =0;
131  T newRecHit(*recHit);
132  newRecHit.setEnergy(new_energy);
133  recHitCollection_output->push_back(newRecHit);
134  }*/
135  }
136  // Save the new collection
137  recHitCollection_output->sort();
138  iEvent.put(std::move(recHitCollection_output), input_.first);
139  }
140 }
static const TGPicture * info(bool iBackgroundIsBlack)
void fill_correction_map(TrackDetMatchInfo *, std::map< uint32_t, float > *)
Definition: CaloCleaner.cc:22
std::vector< T >::const_iterator const_iterator
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:46
edm::SortedCollection< T > RecHitCollection
Definition: CaloCleaner.h:44
int iEvent
Definition: GenABIO.cc:224
void setPropagator(const Propagator *)
use a user configured propagator
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const_iterator begin() const
const_iterator end() const
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
Definition: CaloCleaner.h:49
TrackDetectorAssociator trackAssociator_
Definition: CaloCleaner.h:51
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:52
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:48
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 48 of file CaloCleaner.h.

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

◆ is_preshower_

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

Definition at line 54 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 46 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 49 of file CaloCleaner.h.

◆ trackAssociator_

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

Definition at line 51 of file CaloCleaner.h.