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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CaloCleaner (const edm::ParameterSet &)
 
 ~CaloCleaner ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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)
 
virtual 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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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

Member Typedef Documentation

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

Definition at line 46 of file CaloCleaner.h.

Constructor & Destructor Documentation

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

Definition at line 61 of file CaloCleaner.h.

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

61  :
63 {
64  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag> >("oldCollection");
65  for (auto inCollection : inCollections){
66  inputs_[inCollection.instance()] = consumes<RecHitCollection >(inCollection);
67  produces<RecHitCollection>(inCollection.instance());
68  }
69 
70  is_preshower_ =iConfig.getUntrackedParameter<bool>("is_preshower", false);
71  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
73  parameters_.loadParameters( parameters, iC );
74  //trackAssociator_.useDefaultPropagator();
75 
76 }
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:48
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:50
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
bool is_preshower_
Definition: CaloCleaner.h:55
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:53
template<typename T >
CaloCleaner< T >::~CaloCleaner ( )

Definition at line 79 of file CaloCleaner.h.

80 {
81 // nothing to be done yet...
82 }

Member Function Documentation

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

Definition at line 32 of file CaloCleaner.cc.

References TrackDetMatchInfo::crossedEcalRecHits, and TrackDetMatchInfo::crossedPreshowerIds.

33 {
34  if (is_preshower_){
35  for ( std::vector<DetId>::const_iterator detId = info->crossedPreshowerIds.begin(); detId != info->crossedPreshowerIds.end(); ++detId ) {
36  (*cor_map) [detId->rawId()] = 9999999; // just remove all energy (Below 0 is not possible)
37  }
38  }
39  else {
40  for(std::vector<const EcalRecHit*>::const_iterator hit=info->crossedEcalRecHits.begin(); hit!=info->crossedEcalRecHits.end(); hit++){
41  // (*cor_map) [(*hit)->detid().rawId()] +=(*hit)->energy();
42  (*cor_map) [(*hit)->detid().rawId()] =(*hit)->energy();
43  }
44  }
45 }
std::vector< DetId > crossedPreshowerIds
std::vector< const EcalRecHit * > crossedEcalRecHits
hits in detector elements crossed by a track
bool is_preshower_
Definition: CaloCleaner.h:55
template<>
void CaloCleaner< HBHERecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 49 of file CaloCleaner.cc.

References TrackDetMatchInfo::crossedHcalRecHits.

50 {
51  for(std::vector<const HBHERecHit*>::const_iterator hit = info->crossedHcalRecHits.begin(); hit != info->crossedHcalRecHits.end(); hit++) {
52  (*cor_map) [(*hit)->detid().rawId()] =(*hit)->energy();
53  }
54 }
std::vector< const HBHERecHit * > crossedHcalRecHits
template<typename T >
void CaloCleaner< T >::fill_correction_map ( TrackDetMatchInfo ,
std::map< uint32_t, float > *   
)
private

Definition at line 25 of file CaloCleaner.cc.

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

26 {
27  assert(0); // CV: make sure general function never gets called;
28  // always use template specializations
29 }
template<>
void CaloCleaner< HORecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 58 of file CaloCleaner.cc.

References TrackDetMatchInfo::crossedHORecHits.

59 {
60  for(std::vector<const HORecHit*>::const_iterator hit = info->crossedHORecHits.begin(); hit != info->crossedHORecHits.end(); hit++) {
61  (*cor_map) [(*hit)->detid().rawId()] =(*hit)->energy();
62  }
63 }
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 67 of file CaloCleaner.cc.

68 {
69  return; // No corrections for HF
70 }
template<>
void CaloCleaner< CastorRecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 73 of file CaloCleaner.cc.

74 {
75  return;// No corrections for Castor
76 }
template<>
void CaloCleaner< ZDCRecHit >::fill_correction_map ( TrackDetMatchInfo info,
std::map< uint32_t, float > *  cor_map 
)
private

Definition at line 79 of file CaloCleaner.cc.

References DEFINE_FWK_MODULE.

80 {
81  return;// No corrections for Castor
82 }
template<typename T >
void CaloCleaner< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 86 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_, electronCleaner_cfi::muons, CaloCleaner< T >::parameters_, edm::ESHandle< T >::product(), PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator, edm::Event::put(), rpcPointValidation_cfi::recHit, TrackDetectorAssociator::setPropagator(), reco::TrackBase::standAloneMuon, HiIsolationCommonParameters_cff::track, and CaloCleaner< T >::trackAssociator_.

87 {
89  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator);
91 
93  iEvent.getByToken(mu_input_, muonHandle);
94  edm::View<pat::Muon> muons = *muonHandle;
95 
96  std::map<uint32_t, float> correction_map;
97 
98  // Fill the correction map
99  for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
100  // get the basic informaiton like fill reco mouon does
101  // RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc
102  const reco::Track* track = 0;
103  if ( iMuon->track().isNonnull() ) track = iMuon->track().get();
104  else if ( iMuon->standAloneMuon().isNonnull() ) track = iMuon->standAloneMuon().get();
105  else throw cms::Exception("FatalError") << "Failed to fill muon id information for a muon with undefined references to tracks";
107  fill_correction_map(&info,&correction_map);
108  }
109 
110  // Copy the old collection and correct if necessary
111  for (auto input_ : inputs_){
112  std::unique_ptr<RecHitCollection> recHitCollection_output(new RecHitCollection());
113  edm::Handle<RecHitCollection> recHitCollection;
114  // iEvent.getByToken(input_.second[0], recHitCollection);
115  iEvent.getByToken(input_.second, recHitCollection);
116  for ( typename RecHitCollection::const_iterator recHit = recHitCollection->begin(); recHit != recHitCollection->end(); ++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) continue; // Do not save empty Hits
120  T newRecHit(*recHit);
121  newRecHit.setEnergy(new_energy);
122  recHitCollection_output->push_back(newRecHit);
123  }
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 
137 
138 
139  }
140  // Save the new collection
141  recHitCollection_output->sort();
142  iEvent.put(std::move(recHitCollection_output),input_.first);
143  }
144 
145 }
static const TGPicture * info(bool iBackgroundIsBlack)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void fill_correction_map(TrackDetMatchInfo *, std::map< uint32_t, float > *)
Definition: CaloCleaner.cc:25
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
std::vector< T >::const_iterator const_iterator
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
Definition: CaloCleaner.h:48
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
Definition: CaloCleaner.h:50
edm::SortedCollection< T > RecHitCollection
Definition: CaloCleaner.h:46
const_iterator begin() const
void setPropagator(const Propagator *)
use a user configured propagator
const_iterator end() const
const T & get() const
Definition: EventSetup.h:56
TrackDetectorAssociator trackAssociator_
Definition: CaloCleaner.h:52
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TrackAssociatorParameters parameters_
Definition: CaloCleaner.h:53
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
const_iterator end() const
long double T
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const

Member Data Documentation

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

Definition at line 50 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 55 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 48 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 52 of file CaloCleaner.h.

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