29 template <
typename T1,
typename T2>
66 template <
typename T1,
typename T2>
69 srcHitMapMuPlus_(cfg.getParameter<edm::
InputTag>(
"srcHitMapMuPlus")),
70 srcHitMapMuMinus_(cfg.getParameter<edm::
InputTag>(
"srcHitMapMuMinus"))
73 for ( edm::VParameterSet::const_iterator cfgTodoItem = cfgTodoList.begin();
74 cfgTodoItem != cfgTodoList.end(); ++cfgTodoItem ) {
83 if ( instanceLabel1 != instanceLabel2 ) {
85 <<
"Mismatch in Instance labels for collection 1 = " << instanceLabel1 <<
" and 2 = " << instanceLabel2 <<
" !!\n";
88 if ( instanceLabel1 ==
"" ) produces<RecHitCollection>();
89 else produces<RecHitCollection>(instanceLabel1);
96 <<
"Empty to-do list !!\n";
103 template <
typename T1,
typename T2>
109 template <
typename T1,
typename T2>
113 evt.
getByLabel(srcHitMapMuPlus_, hitMapMuPlus);
115 evt.
getByLabel(srcHitMapMuMinus_, hitMapMuMinus);
117 for (
typename std::vector<TodoListEntry>::const_iterator todoItem = todoList_.begin();
118 todoItem != todoList_.end(); ++todoItem ) {
121 RecHitCollectionHandle recHitCollection1;
122 evt.
getByLabel(todoItem->srcCollection1_, recHitCollection1);
123 RecHitCollectionHandle recHitCollection2;
124 evt.
getByLabel(todoItem->srcCollection2_, recHitCollection2);
126 std::map<T1, std::vector<T2> > recHits_output;
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);
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());
137 std::string instanceLabel = todoItem->srcCollection1_.instance();
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;
148 evt.
put(recHitCollection_output, instanceLabel);
154 bool matchHitMapRH(uint32_t rawDetId,
const std::map<uint32_t, int>& hitMap)
156 for ( std::map<uint32_t, int>::const_iterator rh = hitMap.begin();
157 rh != hitMap.end(); ++rh ) {
158 if (
matchMuonDetId(rawDetId, rh->first) && rh->second > 0 )
return true;
164 template <
typename T1,
typename T2>
169 recHit != recHitCollection_input.
end(); ++recHit ) {
170 uint32_t rawDetId = getRawDetId(*recHit);
172 bool isToBeCleaned =
false;
173 if ( applyCleaning ) {
174 isToBeCleaned |= matchHitMapRH(rawDetId, hitMapMuPlus);
175 isToBeCleaned |= matchHitMapRH(rawDetId, hitMapMuMinus);
178 if ( !isToBeCleaned ) {
180 recHits_output[detId].push_back(*recHit);
187 template <
typename T1,
typename T2>
192 rh != recHits.
end(); ++rh ) {
std::vector< TodoListEntry > todoList_
std::map< uint32_t, int > detIdToIntMap
T getParameter(std::string const &) const
edm::RangeMap< T1, edm::OwnVector< T2 > > RecHitCollection
bool matchMuonDetId(uint32_t, uint32_t)
std::vector< ParameterSet > VParameterSet
C::const_iterator begin() const
first collection iterator
bool exists(std::string const ¶meterName) const
checks if a parameter exists
uint32_t getRawDetId(const T2 &)
C::const_iterator const_iterator
constant access iterator type
edm::InputTag srcHitMapMuPlus_
virtual void produce(edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::InputTag srcHitMapMuMinus_
MuonDetRecHitMixer(const edm::ParameterSet &)
void printHitMapRH(const edm::EventSetup &, const RecHitCollection &)
edm::InputTag srcCollection1_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void printMuonDetId(const edm::EventSetup &, uint32_t)
C::const_iterator end() const
last collection iterator
void addRecHits(std::map< T1, std::vector< T2 > > &, const RecHitCollection &, bool, const detIdToIntMap &, const detIdToIntMap &, int &)
edm::InputTag srcCollection2_