CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuonDetCleaner< T1, T2 > Class Template Reference

#include <MuonDetCleaner.h>

Inheritance diagram for MuonDetCleaner< T1, T2 >:
edm::stream::EDProducer<>

Public Member Functions

 MuonDetCleaner (const edm::ParameterSet &)
 
 ~MuonDetCleaner () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef edm::RangeMap< T1, edm::OwnVector< T2 > > RecHitCollection
 

Private Member Functions

bool checkrecHit (const TrackingRecHit &)
 
template<>
bool checkrecHit (const TrackingRecHit &recHit)
 
template<>
bool checkrecHit (const TrackingRecHit &recHit)
 
template<>
bool checkrecHit (const TrackingRecHit &recHit)
 
void fillVetoHits (const TrackingRecHit &, std::vector< uint32_t > *)
 
template<>
uint32_t getRawDetId (const CSCRecHit2D &recHit)
 
template<>
uint32_t getRawDetId (const DTRecHit1DPair &recHit)
 
template<>
uint32_t getRawDetId (const RPCRecHit &recHit)
 
uint32_t getRawDetId (const T2 &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
 
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
 

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 T1, typename T2>
class MuonDetCleaner< T1, T2 >

Clean collections of hits in muon detectors (CSC, DT and RPC) for original Zmumu event and "embedded" simulated tau decay products

Author
Christian Veelken, LLR

Clean Up from STefan Wayand, KIT

Definition at line 36 of file MuonDetCleaner.h.

Member Typedef Documentation

template<typename T1 , typename T2 >
typedef edm::RangeMap<T1, edm::OwnVector<T2> > MuonDetCleaner< T1, T2 >::RecHitCollection
private

Definition at line 45 of file MuonDetCleaner.h.

Constructor & Destructor Documentation

template<typename T1 , typename T2 >
MuonDetCleaner< T1, T2 >::MuonDetCleaner ( const edm::ParameterSet iConfig)
explicit

Definition at line 58 of file MuonDetCleaner.h.

References edm::ParameterSet::getParameter(), and MuonDetCleaner< T1, T2 >::inputs_.

58  :
59  mu_input_(consumes<edm::View<pat::Muon> >(iConfig.getParameter<edm::InputTag>("MuonCollection")))
60 {
61  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag> >("oldCollection");
62  for (auto inCollection : inCollections){
63  inputs_[inCollection.instance()] = consumes<RecHitCollection >(inCollection);
64  produces<RecHitCollection>(inCollection.instance());
65  }
66 
67 }
T getParameter(std::string const &) const
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
template<typename T1 , typename T2 >
MuonDetCleaner< T1, T2 >::~MuonDetCleaner ( )
override

Definition at line 70 of file MuonDetCleaner.h.

71 {
72 // nothing to be done yet...
73 }

Member Function Documentation

template<typename T1 , typename T2 >
bool MuonDetCleaner< T1, T2 >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 56 of file MuonDetCleaner.cc.

Referenced by MuonDetCleaner< T1, T2 >::produce().

57 {
58  edm::LogError("TauEmbedding")<<"!!!! Please add the checkrecHit for the individual class templates "
59  assert(0);
60 }
template<>
bool MuonDetCleaner< CSCDetId, CSCRecHit2D >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 64 of file MuonDetCleaner.cc.

References rpcPointValidation_cfi::recHit.

65 {
66  const std::type_info &hit_type = typeid(recHit);
67  if (hit_type == typeid(CSCSegment)) {return true;} // This should be the default one (which are included in the global (outer) muon track)
68  else if (hit_type == typeid(CSCRecHit2D)) {return true;}
69  //else {std::cout<<"else "<<hit_type.name()<<std::endl;}
70  return false;
71 }
template<>
bool MuonDetCleaner< DTLayerId, DTRecHit1DPair >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 75 of file MuonDetCleaner.cc.

References rpcPointValidation_cfi::recHit.

76 {
77  const std::type_info &hit_type = typeid(recHit);
78  if (hit_type == typeid(DTRecSegment4D)) {return true;} // This should be the default one (which are included in the global (outer) muon track)
79  else if (hit_type == typeid(DTRecHit1D)) {return true;}
80  else if (hit_type == typeid(DTSLRecCluster)) {return true; }
81  else if (hit_type == typeid(DTSLRecSegment2D)) {return true; }
82  // else {std::cout<<"else "<<hit_type.name()<<std::endl;}
83  return false;
84 }
template<>
bool MuonDetCleaner< RPCDetId, RPCRecHit >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 88 of file MuonDetCleaner.cc.

References DEFINE_FWK_MODULE, and rpcPointValidation_cfi::recHit.

89 {
90  const std::type_info &hit_type = typeid(recHit);
91  if (hit_type == typeid(RPCRecHit)) {return true;} // This should be the default one (which are included in the global (outer) muon track)
92  //else {std::cout<<"else "<<hit_type.name()<<std::endl;}
93  return false;
94 }
template<typename T1 , typename T2 >
void MuonDetCleaner< T1, T2 >::fillVetoHits ( const TrackingRecHit rh,
std::vector< uint32_t > *  HitsList 
)
private

Definition at line 133 of file MuonDetCleaner.h.

References TrackingRecHit::rawId(), and TrackingRecHit::recHits().

Referenced by MuonDetCleaner< T1, T2 >::produce().

134 {
135  std::vector<const TrackingRecHit*> rh_components = rh.recHits();
136  if ( rh_components.empty() ) {
137  HitsList->push_back(rh.rawId());
138  }
139  else {
140  for ( std::vector<const TrackingRecHit*>::const_iterator rh_component = rh_components.begin(); rh_component != rh_components.end(); ++rh_component ) {
141  fillVetoHits(**rh_component, HitsList);
142  }
143  }
144 }
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
void fillVetoHits(const TrackingRecHit &, std::vector< uint32_t > *)
id_type rawId() const
template<>
uint32_t MuonDetCleaner< CSCDetId, CSCRecHit2D >::getRawDetId ( const CSCRecHit2D recHit)
private

Definition at line 33 of file MuonDetCleaner.cc.

References CSCRecHit2D::cscDetId(), and DetId::rawId().

34 {
35  return recHit.cscDetId().rawId();
36 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
template<>
uint32_t MuonDetCleaner< DTLayerId, DTRecHit1DPair >::getRawDetId ( const DTRecHit1DPair recHit)
private

Definition at line 39 of file MuonDetCleaner.cc.

References DTRecHit1DPair::geographicalId(), and DetId::rawId().

40 {
41  return recHit.geographicalId().rawId();
42 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
virtual DetId geographicalId() const
Return the detId of the Det (a DTLayer).
template<>
uint32_t MuonDetCleaner< RPCDetId, RPCRecHit >::getRawDetId ( const RPCRecHit recHit)
private

Definition at line 45 of file MuonDetCleaner.cc.

References DetId::rawId(), and RPCRecHit::rpcId().

46 {
47  return recHit.rpcId().rawId();
48 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:103
template<typename T1 , typename T2 >
uint32_t MuonDetCleaner< T1, T2 >::getRawDetId ( const T2 &  recHit)
private

Definition at line 26 of file MuonDetCleaner.cc.

Referenced by MuonDetCleaner< T1, T2 >::produce().

27 {
28  assert(0); // CV: make sure general function never gets called;
29  // always use template specializations
30 }
template<typename T1 , typename T2 >
void MuonDetCleaner< T1, T2 >::produce ( edm::Event iEvent,
const edm::EventSetup es 
)
overrideprivate

Definition at line 76 of file MuonDetCleaner.h.

References edm::View< T >::begin(), MuonDetCleaner< T1, T2 >::checkrecHit(), edm::View< T >::end(), MuonDetCleaner< T1, T2 >::fillVetoHits(), spr::find(), edm::Event::getByToken(), MuonDetCleaner< T1, T2 >::getRawDetId(), MuonDetCleaner< T1, T2 >::inputs_, genParticles_cff::map, eostools::move(), MuonDetCleaner< T1, T2 >::mu_input_, extraflags_cff::muons, convertSQLitetoXML_cfg::output, edm::Event::put(), rpcPointValidation_cfi::recHit, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), and HiIsolationCommonParameters_cff::track.

77 {
78  std::map<T1, std::vector<T2> > recHits_output; // This data format is easyer to handle
79  std::vector<uint32_t> vetoHits;
80 
81  // First fill the veto RecHits colletion with the Hits from the input muons
83  iEvent.getByToken(mu_input_, muonHandle);
84  edm::View<pat::Muon> muons = *muonHandle;
85  for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
86  const reco::Track* track = nullptr;
87  if( iMuon->isGlobalMuon() ) track = iMuon->outerTrack().get();
88  else if ( iMuon->isStandAloneMuon() ) track = iMuon->outerTrack().get();
89  else if ( iMuon->isRPCMuon() ) track = iMuon->innerTrack().get(); // To add, try to access the rpc track
90  else if ( iMuon->isTrackerMuon() ) track = iMuon->innerTrack().get();
91  else {
92  edm::LogError("TauEmbedding")<<"The imput muon: "<<(*iMuon)<<" must be either global or does or be tracker muon";
93  assert(0);
94  }
95 
96 
97  for (trackingRecHit_iterator hitIt = track->recHitsBegin(); hitIt != track->recHitsEnd(); ++hitIt) {
98  const TrackingRecHit &murechit = **hitIt; // Base class for all rechits
99  if(!(murechit).isValid()) continue;
100  if (!checkrecHit(murechit)) continue; // Check if the hit belongs to a specifc detector section
101  fillVetoHits(murechit,&vetoHits); // Go back to the very basic rechits
102  }
103  }
104 
105 
106  // Now this can also handle different instance
107  for (auto input_ : inputs_){
108  // Second read in the RecHit Colltection which is to be replaced, without the vetoRecHits
109  typedef edm::Handle<RecHitCollection> RecHitCollectionHandle;
110  RecHitCollectionHandle RecHitinput;
111  iEvent.getByToken(input_.second, RecHitinput);
112  for ( typename RecHitCollection::const_iterator recHit = RecHitinput->begin(); recHit != RecHitinput->end(); ++recHit ) { // loop over the basic rec hit collection (DT CSC or RPC)
113  //if (find(vetoHits.begin(),vetoHits.end(),getRawDetId(*recHit)) == vetoHits.end()) continue; // For the invertec selcetion
114  if (find(vetoHits.begin(),vetoHits.end(),getRawDetId(*recHit)) != vetoHits.end()) continue; // If the hit is not in the
115  T1 detId(getRawDetId(*recHit));
116  recHits_output[detId].push_back(*recHit);
117  }
118 
119 
120 
121  // Last step savet the output in the CMSSW Data Format
122  std::unique_ptr<RecHitCollection> output(new RecHitCollection());
123  for ( typename std::map<T1, std::vector<T2> >::const_iterator recHit = recHits_output.begin(); recHit != recHits_output.end(); ++recHit ) {
124  output->put(recHit->first, recHit->second.begin(), recHit->second.end());
125  }
126  output->post_insert();
127  iEvent.put(std::move(output),input_.first);
128  }
129 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
uint32_t getRawDetId(const T2 &)
bool checkrecHit(const TrackingRecHit &)
edm::RangeMap< T1, edm::OwnVector< T2 > > RecHitCollection
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
const_iterator begin() const
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_
const edm::EDGetTokenT< edm::View< pat::Muon > > mu_input_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void fillVetoHits(const TrackingRecHit &, std::vector< uint32_t > *)
const_iterator end() const
def move(src, dest)
Definition: eostools.py:510
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109

Member Data Documentation

template<typename T1 , typename T2 >
std::map<std::string, edm::EDGetTokenT<RecHitCollection > > MuonDetCleaner< T1, T2 >::inputs_
private
template<typename T1 , typename T2 >
const edm::EDGetTokenT<edm::View<pat::Muon> > MuonDetCleaner< T1, T2 >::mu_input_
private

Definition at line 51 of file MuonDetCleaner.h.

Referenced by MuonDetCleaner< T1, T2 >::produce().