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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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)
 
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)
 
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_
 
TrackDetectorAssociator trackAssociator_
 

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
 

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

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

Definition at line 44 of file CaloCleaner.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file CaloCleaner.h.

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

59  : mu_input_(consumes<edm::View<pat::Muon> >(iConfig.getParameter<edm::InputTag>("MuonCollection"))) {
60  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag> >("oldCollection");
61  for (auto inCollection : inCollections) {
62  inputs_[inCollection.instance()] = consumes<RecHitCollection>(inCollection);
63  produces<RecHitCollection>(inCollection.instance());
64  }
65 
66  is_preshower_ = iConfig.getUntrackedParameter<bool>("is_preshower", false);
67  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
68  edm::ConsumesCollector iC = consumesCollector();
69  parameters_.loadParameters(parameters, iC);
70  //trackAssociator_.useDefaultPropagator();
71 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:46
bool is_preshower_
Definition: CaloCleaner.h:53
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:51
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:48
template<typename T >
CaloCleaner< T >::~CaloCleaner ( )
override

Definition at line 74 of file CaloCleaner.h.

74  {
75  // nothing to be done yet...
76 }

Member Function Documentation

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 TrackDetMatchInfo::crossedEcalRecHits, and TrackDetMatchInfo::crossedPreshowerIds.

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 }
std::vector< DetId > crossedPreshowerIds
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
bool is_preshower_
Definition: CaloCleaner.h:53
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 TrackDetMatchInfo::crossedHcalRecHits.

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 }
std::vector< const HBHERecHit * > crossedHcalRecHits
template<typename T >
void CaloCleaner< T >::fill_correction_map ( TrackDetMatchInfo ,
std::map< uint32_t, float > *   
)
private

Definition at line 22 of file CaloCleaner.cc.

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

22  {
23  assert(0); // CV: make sure general function never gets called;
24  // always use template specializations
25 }
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 TrackDetMatchInfo::crossedHORecHits.

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 }
std::vector< const HORecHit * > crossedHORecHits
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 }
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 }
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.

References DEFINE_FWK_MODULE.

74  {
75  return; // No corrections for Castor
76 }
template<typename T >
void CaloCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 79 of file CaloCleaner.h.

References TrackDetectorAssociator::Any, TrackDetectorAssociator::associate(), edm::View< T >::begin(), edm::SortedCollection< T, SORT >::begin(), edm::View< T >::end(), edm::SortedCollection< T, SORT >::end(), Exception, CaloCleaner< T >::fill_correction_map(), edm::EventSetup::get(), edm::Event::getByToken(), info(), CaloCleaner< T >::inputs_, eostools::move(), CaloCleaner< T >::mu_input_, PDWG_BPHSkim_cff::muons, CaloCleaner< T >::parameters_, edm::ESHandle< T >::product(), TrackCandidateProducer_cfi::propagator, edm::Event::put(), rpcPointValidation_cfi::recHit, TrackDetectorAssociator::setPropagator(), reco::TrackBase::standAloneMuon, HLT_2018_cff::track, and CaloCleaner< T >::trackAssociator_.

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

Member Data Documentation

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(), and CaloCleaner< T >::produce().

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

Definition at line 53 of file CaloCleaner.h.

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

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

Definition at line 46 of file CaloCleaner.h.

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

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

Definition at line 50 of file CaloCleaner.h.

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