CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 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::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<>
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 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 35 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 43 of file MuonDetCleaner.h.

Constructor & Destructor Documentation

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

Definition at line 55 of file MuonDetCleaner.h.

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

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

Definition at line 65 of file MuonDetCleaner.h.

65  {
66  // nothing to be done yet...
67 }

Member Function Documentation

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

Definition at line 46 of file MuonDetCleaner.cc.

References cms::cuda::assert().

46  {
47  edm::LogError("TauEmbedding") << "!!!! Please add the checkrecHit for the individual class templates " assert(0);
48 }
Log< level::Error, false > LogError
assert(be >=bs)
template<>
bool MuonDetCleaner< CSCDetId, CSCRecHit2D >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 51 of file MuonDetCleaner.cc.

51  {
52  const std::type_info& hit_type = typeid(recHit);
53  if (hit_type == typeid(CSCSegment)) {
54  return true;
55  } // This should be the default one (which are included in the global (outer) muon track)
56  else if (hit_type == typeid(CSCRecHit2D)) {
57  return true;
58  }
59  //else {std::cout<<"else "<<hit_type.name()<<std::endl;}
60  return false;
61 }
template<>
bool MuonDetCleaner< DTLayerId, DTRecHit1DPair >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 64 of file MuonDetCleaner.cc.

64  {
65  const std::type_info& hit_type = typeid(recHit);
66  if (hit_type == typeid(DTRecSegment4D)) {
67  return true;
68  } // This should be the default one (which are included in the global (outer) muon track)
69  else if (hit_type == typeid(DTRecHit1D)) {
70  return true;
71  } else if (hit_type == typeid(DTSLRecCluster)) {
72  return true;
73  } else if (hit_type == typeid(DTSLRecSegment2D)) {
74  return true;
75  }
76  // else {std::cout<<"else "<<hit_type.name()<<std::endl;}
77  return false;
78 }
template<>
bool MuonDetCleaner< RPCDetId, RPCRecHit >::checkrecHit ( const TrackingRecHit recHit)
private

Definition at line 81 of file MuonDetCleaner.cc.

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

Definition at line 132 of file MuonDetCleaner.h.

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

132  {
133  std::vector<const TrackingRecHit*> rh_components = rh.recHits();
134  if (rh_components.empty()) {
135  HitsList->push_back(rh.rawId());
136  } else {
137  for (std::vector<const TrackingRecHit*>::const_iterator rh_component = rh_components.begin();
138  rh_component != rh_components.end();
139  ++rh_component) {
140  fillVetoHits(**rh_component, HitsList);
141  }
142  }
143 }
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 27 of file MuonDetCleaner.cc.

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

27  {
28  return recHit.cscDetId().rawId();
29 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:58
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
template<>
uint32_t MuonDetCleaner< DTLayerId, DTRecHit1DPair >::getRawDetId ( const DTRecHit1DPair recHit)
private

Definition at line 32 of file MuonDetCleaner.cc.

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

32  {
33  return recHit.geographicalId().rawId();
34 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
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 37 of file MuonDetCleaner.cc.

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

37  {
38  return recHit.rpcId().rawId();
39 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:71
template<typename T1 , typename T2 >
uint32_t MuonDetCleaner< T1, T2 >::getRawDetId ( const T2 &  recHit)
private

Definition at line 21 of file MuonDetCleaner.cc.

References cms::cuda::assert().

21  {
22  assert(0); // CV: make sure general function never gets called;
23  // always use template specializations
24 }
assert(be >=bs)
template<typename T1 , typename T2 >
void MuonDetCleaner< T1, T2 >::produce ( edm::Event iEvent,
const edm::EventSetup es 
)
overrideprivate

Definition at line 70 of file MuonDetCleaner.h.

References cms::cuda::assert(), edm::View< T >::begin(), edm::View< T >::end(), spr::find(), edm::Event::getByToken(), eostools::move(), patZpeak::muons, convertSQLitetoXML_cfg::output, edm::Event::put(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), and HLT_FULL_cff::track.

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

Member Data Documentation

template<typename T1 , typename T2 >
std::map<std::string, edm::EDGetTokenT<RecHitCollection> > MuonDetCleaner< T1, T2 >::inputs_
private

Definition at line 51 of file MuonDetCleaner.h.

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

template<typename T1 , typename T2 >
const edm::EDGetTokenT<edm::View<pat::Muon> > MuonDetCleaner< T1, T2 >::mu_input_
private

Definition at line 49 of file MuonDetCleaner.h.