171 for (
typename std::vector<todoListEntryType>::const_iterator todoItem =
todoList_.begin();
172 todoItem !=
todoList_.end(); ++todoItem ) {
174 evt.
getByLabel(todoItem->srcRecHitCollection1_, recHitCollection1);
176 evt.
getByLabel(todoItem->srcRecHitCollection2_, recHitCollection2);
178 std::cout <<
"recHitCollection(input1 = " << todoItem->srcRecHitCollection1_.label() <<
":" << todoItem->srcRecHitCollection1_.instance() <<
":" << todoItem->srcRecHitCollection1_.process() <<
"):"
179 <<
" #entries = " << recHitCollection1->size() << std::endl;
180 std::cout <<
"recHitCollection(input2 = " << todoItem->srcRecHitCollection2_.label() <<
":" << todoItem->srcRecHitCollection2_.instance() <<
":" << todoItem->srcRecHitCollection2_.process() <<
"):"
181 <<
" #entries = " << recHitCollection2->size() << std::endl;
188 std::auto_ptr<RecHitCollection> recHitCollection_output(
new RecHitCollection());
189 std::auto_ptr<double> removedEnergyMuPlus(
new double(0.));
190 std::auto_ptr<double> removedEnergyMuMinus(
new double(0.));
192 double muPlusEnergySum = 0.;
193 double muMinusEnergySum = 0.;
195 for (
typename detIdToMixedRecHitInfoMap::iterator mixedRecHitInfo =
mixedRecHitInfos_.begin();
197 uint32_t rawDetId = mixedRecHitInfo->second.rawDetId_;
199 double muPlusEnergyDeposit = getCorrection(rawDetId, *energyDepositMapMuPlus);
200 double muMinusEnergyDeposit = getCorrection(rawDetId, *energyDepositMapMuMinus);
201 double muonEnergyDeposit = muPlusEnergyDeposit + muMinusEnergyDeposit;
203 muPlusEnergySum += muPlusEnergyDeposit;
204 muMinusEnergySum += muMinusEnergyDeposit;
206 if ( muonEnergyDeposit > 0. ) {
207 if (
verbosity_ )
std::cout <<
"removing muon energy: detId = " << rawDetId <<
", subtracted = " << muonEnergyDeposit << std::endl;
209 if ( todoItem->killNegEnergyBeforeMixing1_ && mixedRecHitInfo->second.energy1_ < muonEnergyDeposit ) {
210 if (
verbosity_ )
std::cout <<
"--> killing recHit1: detId = " << rawDetId <<
", energy = " << (mixedRecHitInfo->second.energy1_ - muonEnergyDeposit) << std::endl;
211 (*removedEnergyMuPlus) += ((mixedRecHitInfo->second.energy1_/muonEnergyDeposit)*muPlusEnergyDeposit);
212 (*removedEnergyMuMinus) += ((mixedRecHitInfo->second.energy1_/muonEnergyDeposit)*muMinusEnergyDeposit);
213 mixedRecHitInfo->second.energy1_ = 0.;
214 mixedRecHitInfo->second.isRecHit1_ =
false;
216 (*removedEnergyMuPlus) += muPlusEnergyDeposit;
217 (*removedEnergyMuMinus) += muMinusEnergyDeposit;
218 mixedRecHitInfo->second.energy1_ -= muonEnergyDeposit;
222 if ( todoItem->killNegEnergyBeforeMixing2_ && mixedRecHitInfo->second.energy2_ < muonEnergyDeposit ) {
223 if (
verbosity_ )
std::cout <<
"--> killing recHit2: detId = " << rawDetId <<
", energy = " << (mixedRecHitInfo->second.energy2_ - muonEnergyDeposit) << std::endl;
224 (*removedEnergyMuPlus) += ((mixedRecHitInfo->second.energy2_/muonEnergyDeposit)*muPlusEnergyDeposit);
225 (*removedEnergyMuMinus) += ((mixedRecHitInfo->second.energy2_/muonEnergyDeposit)*muMinusEnergyDeposit);
226 mixedRecHitInfo->second.energy2_ = 0.;
227 mixedRecHitInfo->second.isRecHit2_ =
false;
229 (*removedEnergyMuPlus) += muPlusEnergyDeposit;
230 (*removedEnergyMuMinus) += muMinusEnergyDeposit;
231 mixedRecHitInfo->second.energy2_ -= muonEnergyDeposit;
236 mixedRecHitInfo->second.energySum_ = 0.;
237 mixedRecHitInfo->second.isRecHitSum_ =
false;
238 if ( mixedRecHitInfo->second.isRecHit1_ ) {
239 mixedRecHitInfo->second.energySum_ += mixedRecHitInfo->second.energy1_;
240 mixedRecHitInfo->second.isRecHitSum_ =
true;
242 if ( mixedRecHitInfo->second.isRecHit2_ ) {
243 mixedRecHitInfo->second.energySum_ += mixedRecHitInfo->second.energy2_;
244 mixedRecHitInfo->second.isRecHitSum_ =
true;
246 if ( muonEnergyDeposit > 0. ) {
248 if ( todoItem->killNegEnergyAfterMixing_ && mixedRecHitInfo->second.energySum_ < muonEnergyDeposit ) {
249 if (
verbosity_ )
std::cout <<
"--> killing recHitSum: detId = " << rawDetId <<
", energy = " << (mixedRecHitInfo->second.energySum_ - muonEnergyDeposit) << std::endl;
250 (*removedEnergyMuPlus) += ((mixedRecHitInfo->second.energySum_/muonEnergyDeposit)*muPlusEnergyDeposit);
251 (*removedEnergyMuMinus) += ((mixedRecHitInfo->second.energySum_/muonEnergyDeposit)*muMinusEnergyDeposit);
252 mixedRecHitInfo->second.energySum_ = 0.;
253 mixedRecHitInfo->second.isRecHitSum_ =
false;
255 (*removedEnergyMuPlus) += muPlusEnergyDeposit;
256 (*removedEnergyMuMinus) += muMinusEnergyDeposit;
257 mixedRecHitInfo->second.energySum_ -= muonEnergyDeposit;
262 if ( mixedRecHitInfo->second.isRecHitSum_ ) {
264 if ( muonEnergyDeposit > 1.
e-3 )
std::cout <<
"--> adding recHitSum (cleaned): detId = " << rawDetId <<
", energy = " << mixedRecHitInfo->second.energySum_ << std::endl;
265 else std::cout <<
"--> adding recHitSum (uncleaned): detId = " << rawDetId <<
", energy = " << mixedRecHitInfo->second.energySum_ << std::endl;
267 recHitCollection_output->push_back(
buildRecHit(mixedRecHitInfo->second));
272 std::cout <<
" mu+: sum(EnergyDeposits) = " << muPlusEnergySum <<
" (removed = " << (*removedEnergyMuPlus) <<
")" << std::endl;
273 std::cout <<
" mu-: sum(EnergyDeposits) = " << muMinusEnergySum <<
" (removed = " << (*removedEnergyMuMinus) <<
")" << std::endl;
274 std::cout <<
"recHitCollection(output = " <<
moduleLabel_ <<
":" << todoItem->srcRecHitCollection1_.instance() <<
"): #entries = " << recHitCollection_output->size() << std::endl;
277 std::string instanceLabel = todoItem->srcRecHitCollection1_.instance();
278 evt.
put(recHitCollection_output, instanceLabel);
279 std::string instanceLabel_removedEnergyMuMinus =
"removedEnergyMuMinus";
280 if ( instanceLabel !=
"" ) instanceLabel_removedEnergyMuMinus.append(
"#").append(instanceLabel);
281 evt.
put(removedEnergyMuMinus, instanceLabel_removedEnergyMuMinus.data());
282 std::string instanceLabel_removedEnergyMuPlus =
"removedEnergyMuPlus";
283 if ( instanceLabel !=
"" ) instanceLabel_removedEnergyMuPlus.append(
"#").append(instanceLabel);
284 evt.
put(removedEnergyMuPlus, instanceLabel_removedEnergyMuPlus.data());
T buildRecHit(const CaloRecHitMixer_mixedRecHitInfoType< T > &)
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