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

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

◆ 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 58 of file CaloCleaner.h.

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();
70  //trackAssociator_.useDefaultPropagator();
71 }

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

◆ ~CaloCleaner()

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

◆ fill_correction_map() [1/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.

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

References cms::cuda::assert().

◆ fill_correction_map() [2/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.

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 }

References info().

◆ fill_correction_map() [3/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.

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 }

References info().

◆ fill_correction_map() [4/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.

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 }

References info().

◆ 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 79 of file CaloCleaner.h.

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 }

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

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

◆ trackAssociator_

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

Definition at line 50 of file CaloCleaner.h.

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:29
TrackDetectorAssociator::Any
Definition: TrackDetectorAssociator.h:50
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
CaloCleaner::mu_input_
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:46
CaloCleaner::fill_correction_map
void fill_correction_map(TrackDetMatchInfo *, std::map< uint32_t, float > *)
Definition: CaloCleaner.cc:22
cms::cuda::assert
assert(be >=bs)
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
CaloCleaner::RecHitCollection
edm::SortedCollection< T > RecHitCollection
Definition: CaloCleaner.h:44
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
reco::Track
Definition: Track.h:27
edm::ESHandle< Propagator >
TrackAssociatorParameters::loadParameters
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: TrackAssociatorParameters.cc:18
TrackDetectorAssociator::setPropagator
void setPropagator(const Propagator *)
use a user configured propagator
Definition: TrackDetectorAssociator.cc:76
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
iEvent
int iEvent
Definition: GenABIO.cc:224
get
#define get
CaloCleaner::inputs_
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:48
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:13
eostools.move
def move(src, dest)
Definition: eostools.py:511
T
long double T
Definition: Basic3DVectorLD.h:48
CaloCleaner::trackAssociator_
TrackDetectorAssociator trackAssociator_
Definition: CaloCleaner.h:50
Exception
Definition: hltDiff.cc:246
CaloCleaner::is_preshower_
bool is_preshower_
Definition: CaloCleaner.h:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TrackDetectorAssociator::associate
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
Definition: TrackDetectorAssociator.cc:110
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
hit
Definition: SiStripHitEffFromCalibTree.cc:88
CaloCleaner::parameters_
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:51
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12