170 for (
typename std::vector<todoListEntryType>::const_iterator todoItem =
todoList_.begin();
171 todoItem !=
todoList_.end(); ++todoItem ) {
173 evt.
getByLabel(todoItem->srcRecHitCollection1_, recHitCollection1);
175 evt.
getByLabel(todoItem->srcRecHitCollection2_, recHitCollection2);
177 std::cout <<
"recHitCollection(input1 = " << todoItem->srcRecHitCollection1_.label() <<
":" << todoItem->srcRecHitCollection1_.instance() <<
":" << todoItem->srcRecHitCollection1_.process() <<
"):"
178 <<
" #entries = " << recHitCollection1->size() << std::endl;
179 std::cout <<
"recHitCollection(input2 = " << todoItem->srcRecHitCollection2_.label() <<
":" << todoItem->srcRecHitCollection2_.instance() <<
":" << todoItem->srcRecHitCollection2_.process() <<
"):"
180 <<
" #entries = " << recHitCollection2->size() << std::endl;
187 std::auto_ptr<RecHitCollection> recHitCollection_output(
new RecHitCollection());
188 std::auto_ptr<double> removedEnergyMuPlus(
new double(0.));
189 std::auto_ptr<double> removedEnergyMuMinus(
new double(0.));
191 double muPlusEnergySum = 0.;
192 double muMinusEnergySum = 0.;
194 for (
typename detIdToMixedRecHitInfoMap::iterator mixedRecHitInfo =
mixedRecHitInfos_.begin();
196 uint32_t rawDetId = mixedRecHitInfo->second.rawDetId_;
198 double muPlusEnergyDeposit = getCorrection(rawDetId, *energyDepositMapMuPlus);
199 double muMinusEnergyDeposit = getCorrection(rawDetId, *energyDepositMapMuMinus);
200 double muonEnergyDeposit = muPlusEnergyDeposit + muMinusEnergyDeposit;
202 muPlusEnergySum += muPlusEnergyDeposit;
203 muMinusEnergySum += muMinusEnergyDeposit;
205 if ( muonEnergyDeposit > 0. ) {
206 if (
verbosity_ )
std::cout <<
"removing muon energy: detId = " << rawDetId <<
", subtracted = " << muonEnergyDeposit << std::endl;
208 if ( todoItem->killNegEnergyBeforeMixing1_ && mixedRecHitInfo->second.energy1_ < muonEnergyDeposit ) {
209 if (
verbosity_ )
std::cout <<
"--> killing recHit1: detId = " << rawDetId <<
", energy = " << (mixedRecHitInfo->second.energy1_ - muonEnergyDeposit) << std::endl;
210 (*removedEnergyMuPlus) += ((mixedRecHitInfo->second.energy1_/muonEnergyDeposit)*muPlusEnergyDeposit);
211 (*removedEnergyMuMinus) += ((mixedRecHitInfo->second.energy1_/muonEnergyDeposit)*muMinusEnergyDeposit);
212 mixedRecHitInfo->second.energy1_ = 0.;
213 mixedRecHitInfo->second.isRecHit1_ =
false;
215 (*removedEnergyMuPlus) += muPlusEnergyDeposit;
216 (*removedEnergyMuMinus) += muMinusEnergyDeposit;
217 mixedRecHitInfo->second.energy1_ -= muonEnergyDeposit;
221 if ( todoItem->killNegEnergyBeforeMixing2_ && mixedRecHitInfo->second.energy2_ < muonEnergyDeposit ) {
222 if (
verbosity_ )
std::cout <<
"--> killing recHit2: detId = " << rawDetId <<
", energy = " << (mixedRecHitInfo->second.energy2_ - muonEnergyDeposit) << std::endl;
223 (*removedEnergyMuPlus) += ((mixedRecHitInfo->second.energy2_/muonEnergyDeposit)*muPlusEnergyDeposit);
224 (*removedEnergyMuMinus) += ((mixedRecHitInfo->second.energy2_/muonEnergyDeposit)*muMinusEnergyDeposit);
225 mixedRecHitInfo->second.energy2_ = 0.;
226 mixedRecHitInfo->second.isRecHit2_ =
false;
228 (*removedEnergyMuPlus) += muPlusEnergyDeposit;
229 (*removedEnergyMuMinus) += muMinusEnergyDeposit;
230 mixedRecHitInfo->second.energy2_ -= muonEnergyDeposit;
235 mixedRecHitInfo->second.energySum_ = 0.;
236 mixedRecHitInfo->second.isRecHitSum_ =
false;
237 if ( mixedRecHitInfo->second.isRecHit1_ ) {
238 mixedRecHitInfo->second.energySum_ += mixedRecHitInfo->second.energy1_;
239 mixedRecHitInfo->second.isRecHitSum_ =
true;
241 if ( mixedRecHitInfo->second.isRecHit2_ ) {
242 mixedRecHitInfo->second.energySum_ += mixedRecHitInfo->second.energy2_;
243 mixedRecHitInfo->second.isRecHitSum_ =
true;
245 if ( muonEnergyDeposit > 0. ) {
247 if ( todoItem->killNegEnergyAfterMixing_ && mixedRecHitInfo->second.energySum_ < muonEnergyDeposit ) {
248 if (
verbosity_ )
std::cout <<
"--> killing recHitSum: detId = " << rawDetId <<
", energy = " << (mixedRecHitInfo->second.energySum_ - muonEnergyDeposit) << std::endl;
249 (*removedEnergyMuPlus) += ((mixedRecHitInfo->second.energySum_/muonEnergyDeposit)*muPlusEnergyDeposit);
250 (*removedEnergyMuMinus) += ((mixedRecHitInfo->second.energySum_/muonEnergyDeposit)*muMinusEnergyDeposit);
251 mixedRecHitInfo->second.energySum_ = 0.;
252 mixedRecHitInfo->second.isRecHitSum_ =
false;
254 (*removedEnergyMuPlus) += muPlusEnergyDeposit;
255 (*removedEnergyMuMinus) += muMinusEnergyDeposit;
256 mixedRecHitInfo->second.energySum_ -= muonEnergyDeposit;
261 if ( mixedRecHitInfo->second.isRecHitSum_ ) {
263 if ( muonEnergyDeposit > 1.
e-3 )
std::cout <<
"--> adding recHitSum (cleaned): detId = " << rawDetId <<
", energy = " << mixedRecHitInfo->second.energySum_ << std::endl;
264 else std::cout <<
"--> adding recHitSum (uncleaned): detId = " << rawDetId <<
", energy = " << mixedRecHitInfo->second.energySum_ << std::endl;
266 recHitCollection_output->push_back(
buildRecHit(mixedRecHitInfo->second));
271 std::cout <<
" mu+: sum(EnergyDeposits) = " << muPlusEnergySum <<
" (removed = " << (*removedEnergyMuPlus) <<
")" << std::endl;
272 std::cout <<
" mu-: sum(EnergyDeposits) = " << muMinusEnergySum <<
" (removed = " << (*removedEnergyMuMinus) <<
")" << std::endl;
273 std::cout <<
"recHitCollection(output = " <<
moduleLabel_ <<
":" << todoItem->srcRecHitCollection1_.instance() <<
"): #entries = " << recHitCollection_output->size() << std::endl;
276 std::string instanceLabel = todoItem->srcRecHitCollection1_.instance();
277 evt.
put(recHitCollection_output, instanceLabel);
278 std::string instanceLabel_removedEnergyMuMinus =
"removedEnergyMuMinus";
279 if ( instanceLabel !=
"" ) instanceLabel_removedEnergyMuMinus.append(
"#").append(instanceLabel);
280 evt.
put(removedEnergyMuMinus, instanceLabel_removedEnergyMuMinus.data());
281 std::string instanceLabel_removedEnergyMuPlus =
"removedEnergyMuPlus";
282 if ( instanceLabel !=
"" ) instanceLabel_removedEnergyMuPlus.append(
"#").append(instanceLabel);
283 evt.
put(removedEnergyMuPlus, instanceLabel_removedEnergyMuPlus.data());
detIdToMixedRecHitInfoMap mixedRecHitInfos_
edm::InputTag srcEnergyDepositMapMuPlus_
edm::InputTag srcEnergyDepositMapMuMinus_
void updateRecHitInfos(const RecHitCollection &, int)
std::vector< todoListEntryType > todoList_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::SortedCollection< T > RecHitCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T buildRecHit(const CaloRecHitMixer_mixedRecHitInfoType &)