CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuonDetRecHitMixer< T1, T2 > Class Template Reference

#include <MuonDetRecHitMixer.h>

Inheritance diagram for MuonDetRecHitMixer< T1, T2 >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  TodoListEntry
 

Public Member Functions

 MuonDetRecHitMixer (const edm::ParameterSet &)
 
 ~MuonDetRecHitMixer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::map< uint32_t, int > detIdToIntMap
 
typedef edm::RangeMap< T1,
edm::OwnVector< T2 > > 
RecHitCollection
 

Private Member Functions

void addRecHits (std::map< T1, std::vector< T2 > > &, const RecHitCollection &, bool, const detIdToIntMap &, const detIdToIntMap &, int &)
 
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 printHitMapRH (const edm::EventSetup &, const RecHitCollection &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::string moduleLabel_
 
edm::InputTag srcHitMapMuMinus_
 
edm::InputTag srcHitMapMuPlus_
 
std::vector< TodoListEntrytodoList_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 T1, typename T2>
class MuonDetRecHitMixer< T1, T2 >

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

Author
Christian Veelken, LLR
Version
Revision:
1.2
Id:
MuonDetRecHitMixer.h,v 1.2 2012/12/13 09:52:06 veelken Exp

Definition at line 30 of file MuonDetRecHitMixer.h.

Member Typedef Documentation

template<typename T1 , typename T2 >
typedef std::map<uint32_t, int> MuonDetRecHitMixer< T1, T2 >::detIdToIntMap
private

Definition at line 41 of file MuonDetRecHitMixer.h.

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

Definition at line 39 of file MuonDetRecHitMixer.h.

Constructor & Destructor Documentation

template<typename T1 , typename T2 >
MuonDetRecHitMixer< T1, T2 >::MuonDetRecHitMixer ( const edm::ParameterSet cfg)
explicit

Definition at line 67 of file MuonDetRecHitMixer.h.

References MuonDetRecHitMixer< T1, T2 >::TodoListEntry::cleanCollection1_, MuonDetRecHitMixer< T1, T2 >::TodoListEntry::cleanCollection2_, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::InputTag::instance(), MuonDetRecHitMixer< T1, T2 >::TodoListEntry::srcCollection1_, MuonDetRecHitMixer< T1, T2 >::TodoListEntry::srcCollection2_, AlCaHLTBitMon_QueryRunRegistry::string, MuonDetRecHitMixer< T1, T2 >::todoList_, and MuonDetRecHitMixer< T1, T2 >::verbosity_.

68  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
69  srcHitMapMuPlus_(cfg.getParameter<edm::InputTag>("srcHitMapMuPlus")),
70  srcHitMapMuMinus_(cfg.getParameter<edm::InputTag>("srcHitMapMuMinus"))
71 {
72  edm::VParameterSet cfgTodoList = cfg.getParameter<edm::VParameterSet>("todo");
73  for ( edm::VParameterSet::const_iterator cfgTodoItem = cfgTodoList.begin();
74  cfgTodoItem != cfgTodoList.end(); ++cfgTodoItem ) {
75  TodoListEntry todoItem;
76  todoItem.srcCollection1_ = cfgTodoItem->getParameter<edm::InputTag>("collection1");
77  todoItem.cleanCollection1_ = cfgTodoItem->getParameter<bool>("cleanCollection1");
78  todoItem.srcCollection2_ = cfgTodoItem->getParameter<edm::InputTag>("collection2");
79  todoItem.cleanCollection2_ = cfgTodoItem->getParameter<bool>("cleanCollection2");
80 
81  std::string instanceLabel1 = todoItem.srcCollection1_.instance();
82  std::string instanceLabel2 = todoItem.srcCollection2_.instance();
83  if ( instanceLabel1 != instanceLabel2 ) {
84  throw cms::Exception("Configuration")
85  << "Mismatch in Instance labels for collection 1 = " << instanceLabel1 << " and 2 = " << instanceLabel2 << " !!\n";
86  }
87 
88  if ( instanceLabel1 == "" ) produces<RecHitCollection>();
89  else produces<RecHitCollection>(instanceLabel1);
90 
91  todoList_.push_back(todoItem);
92  }
93 
94  if ( todoList_.size() == 0 ) {
95  throw cms::Exception("Configuration")
96  << "Empty to-do list !!\n";
97  }
98 
99  verbosity_ = ( cfg.exists("verbosity") ) ?
100  cfg.getParameter<int>("verbosity") : 0;
101 }
std::vector< TodoListEntry > todoList_
T getParameter(std::string const &) const
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag srcHitMapMuPlus_
edm::InputTag srcHitMapMuMinus_
template<typename T1 , typename T2 >
MuonDetRecHitMixer< T1, T2 >::~MuonDetRecHitMixer ( )

Definition at line 104 of file MuonDetRecHitMixer.h.

105 {
106 // nothing to be done yet...
107 }

Member Function Documentation

template<typename T1 , typename T2 >
void MuonDetRecHitMixer< T1, T2 >::addRecHits ( std::map< T1, std::vector< T2 > > &  recHits_output,
const RecHitCollection recHitCollection_input,
bool  applyCleaning,
const detIdToIntMap hitMapMuPlus,
const detIdToIntMap hitMapMuMinus,
int &  numHits_cleaned 
)
private

Definition at line 165 of file MuonDetRecHitMixer.h.

References edm::RangeMap< ID, C, P >::begin(), and edm::RangeMap< ID, C, P >::end().

167 {
168  for ( typename RecHitCollection::const_iterator recHit = recHitCollection_input.begin();
169  recHit != recHitCollection_input.end(); ++recHit ) {
170  uint32_t rawDetId = getRawDetId(*recHit);
171 
172  bool isToBeCleaned = false;
173  if ( applyCleaning ) {
174  isToBeCleaned |= matchHitMapRH(rawDetId, hitMapMuPlus);
175  isToBeCleaned |= matchHitMapRH(rawDetId, hitMapMuMinus);
176  }
177 
178  if ( !isToBeCleaned ) {
179  T1 detId(rawDetId);
180  recHits_output[detId].push_back(*recHit);
181  } else {
182  ++numHits_cleaned;
183  }
184  }
185 }
uint32_t getRawDetId(const T2 &)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
template<>
uint32_t MuonDetRecHitMixer< CSCDetId, CSCRecHit2D >::getRawDetId ( const CSCRecHit2D recHit)
private

Definition at line 27 of file MuonDetRecHitMixer.cc.

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

28 {
29  return recHit.cscDetId().rawId();
30 }
CSCDetId cscDetId() const
Definition: CSCRecHit2D.h:52
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
template<>
uint32_t MuonDetRecHitMixer< DTLayerId, DTRecHit1DPair >::getRawDetId ( const DTRecHit1DPair recHit)
private

Definition at line 33 of file MuonDetRecHitMixer.cc.

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

34 {
35  return recHit.geographicalId().rawId();
36 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual DetId geographicalId() const
Return the detId of the Det (a DTLayer).
template<>
uint32_t MuonDetRecHitMixer< RPCDetId, RPCRecHit >::getRawDetId ( const RPCRecHit recHit)
private

Definition at line 39 of file MuonDetRecHitMixer.cc.

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

40 {
41  return recHit.rpcId().rawId();
42 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
RPCDetId rpcId() const
Return the rpcId.
Definition: RPCRecHit.h:97
template<typename T1 , typename T2 >
uint32_t MuonDetRecHitMixer< T1, T2 >::getRawDetId ( const T2 &  recHit)
private

Definition at line 19 of file MuonDetRecHitMixer.cc.

References assert().

20 {
21  assert(0); // CV: make sure general function never gets called;
22  // always use template specializations
23 }
assert(m_qm.get())
template<typename T1 , typename T2 >
void MuonDetRecHitMixer< T1, T2 >::printHitMapRH ( const edm::EventSetup es,
const RecHitCollection recHits 
)
private

Definition at line 188 of file MuonDetRecHitMixer.h.

References edm::RangeMap< ID, C, P >::begin(), gather_cfg::cout, edm::RangeMap< ID, C, P >::end(), and printMuonDetId().

189 {
190  std::cout << "detIds:";
191  for ( typename RecHitCollection::const_iterator rh = recHits.begin();
192  rh != recHits.end(); ++rh ) {
193  printMuonDetId(es, getRawDetId(*rh));
194  }
195 }
uint32_t getRawDetId(const T2 &)
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void printMuonDetId(const edm::EventSetup &, uint32_t)
tuple cout
Definition: gather_cfg.py:121
template<typename T1 , typename T2 >
void MuonDetRecHitMixer< T1, T2 >::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 110 of file MuonDetRecHitMixer.h.

References gather_cfg::cout, edm::Event::getByLabel(), python.multivaluedict::map(), moduleLabel_(), edm::Event::put(), and AlCaHLTBitMon_QueryRunRegistry::string.

111 {
112  edm::Handle<detIdToIntMap> hitMapMuPlus;
113  evt.getByLabel(srcHitMapMuPlus_, hitMapMuPlus);
114  edm::Handle<detIdToIntMap> hitMapMuMinus;
115  evt.getByLabel(srcHitMapMuMinus_, hitMapMuMinus);
116 
117  for ( typename std::vector<TodoListEntry>::const_iterator todoItem = todoList_.begin();
118  todoItem != todoList_.end(); ++todoItem ) {
119 
120  typedef edm::Handle<RecHitCollection> RecHitCollectionHandle;
121  RecHitCollectionHandle recHitCollection1;
122  evt.getByLabel(todoItem->srcCollection1_, recHitCollection1);
123  RecHitCollectionHandle recHitCollection2;
124  evt.getByLabel(todoItem->srcCollection2_, recHitCollection2);
125 
126  std::map<T1, std::vector<T2> > recHits_output;
127 
128  int numHits_cleaned = 0;
129  addRecHits(recHits_output, *recHitCollection1, todoItem->cleanCollection1_, *hitMapMuPlus, *hitMapMuMinus, numHits_cleaned);
130  addRecHits(recHits_output, *recHitCollection2, todoItem->cleanCollection2_, *hitMapMuPlus, *hitMapMuMinus, numHits_cleaned);
131 
132  std::auto_ptr<RecHitCollection> recHitCollection_output(new RecHitCollection());
133  for ( typename std::map<T1, std::vector<T2> >::const_iterator recHit = recHits_output.begin();
134  recHit != recHits_output.end(); ++recHit ) {
135  recHitCollection_output->put(recHit->first, recHit->second.begin(), recHit->second.end());
136  }
137  std::string instanceLabel = todoItem->srcCollection1_.instance();
138  if ( verbosity_ ) {
139  std::cout << "<MuonDetRecHitMixer::produce>:" << std::endl;
140  std::cout << " #Hits(input1 = " << todoItem->srcCollection1_.label() << ":" << todoItem->srcCollection1_.instance() << ") = " << recHitCollection1->size() << std::endl;
141  if ( verbosity_ >= 2 ) printHitMapRH(es, *recHitCollection1);
142  std::cout << " #Hits(input2 = " << todoItem->srcCollection2_.label() << ":" << todoItem->srcCollection2_.instance() << ") = " << recHitCollection2->size() << std::endl;
143  if ( verbosity_ >= 2 ) printHitMapRH(es, *recHitCollection2);
144  std::cout << " #Hits(output = " << moduleLabel_ << ":" << instanceLabel << ") = " << recHitCollection_output->size() << std::endl;
145  if ( verbosity_ >= 2 ) printHitMapRH(es, *recHitCollection_output);
146  std::cout << " #Hits = " << numHits_cleaned << " removed during cleaning." << std::endl;
147  }
148  evt.put(recHitCollection_output, instanceLabel);
149  }
150 }
std::vector< TodoListEntry > todoList_
edm::RangeMap< T1, edm::OwnVector< T2 > > RecHitCollection
edm::InputTag srcHitMapMuPlus_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::InputTag srcHitMapMuMinus_
void printHitMapRH(const edm::EventSetup &, const RecHitCollection &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
tuple cout
Definition: gather_cfg.py:121
void addRecHits(std::map< T1, std::vector< T2 > > &, const RecHitCollection &, bool, const detIdToIntMap &, const detIdToIntMap &, int &)

Member Data Documentation

template<typename T1 , typename T2 >
std::string MuonDetRecHitMixer< T1, T2 >::moduleLabel_
private
template<typename T1 , typename T2 >
edm::InputTag MuonDetRecHitMixer< T1, T2 >::srcHitMapMuMinus_
private

Definition at line 61 of file MuonDetRecHitMixer.h.

template<typename T1 , typename T2 >
edm::InputTag MuonDetRecHitMixer< T1, T2 >::srcHitMapMuPlus_
private

Definition at line 60 of file MuonDetRecHitMixer.h.

template<typename T1 , typename T2 >
std::vector<TodoListEntry> MuonDetRecHitMixer< T1, T2 >::todoList_
private
template<typename T1 , typename T2 >
int MuonDetRecHitMixer< T1, T2 >::verbosity_
private