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
CaloRecHitMixer< T > Class Template Reference

#include <CaloRecHitMixer.h>

Inheritance diagram for CaloRecHitMixer< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  todoListEntryType
 

Public Member Functions

 CaloRecHitMixer (const edm::ParameterSet &)
 
 ~CaloRecHitMixer ()
 
- 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

enum  { kAbsolute }
 
typedef std::map< uint32_t, float > detIdToFloatMap
 
typedef std::map< uint32_t,
CaloRecHitMixer_mixedRecHitInfoType
< T > > 
detIdToMixedRecHitInfoMap
 
typedef edm::SortedCollection< TRecHitCollection
 

Private Member Functions

template<>
EcalRecHit buildRecHit (const CaloRecHitMixer_mixedRecHitInfoType< EcalRecHit > &recHitInfo)
 
T buildRecHit (const CaloRecHitMixer_mixedRecHitInfoType< T > &)
 
template<>
HBHERecHit buildRecHit (const CaloRecHitMixer_mixedRecHitInfoType< HBHERecHit > &recHitInfo)
 
template<>
HORecHit buildRecHit (const CaloRecHitMixer_mixedRecHitInfoType< HORecHit > &recHitInfo)
 
template<>
HFRecHit buildRecHit (const CaloRecHitMixer_mixedRecHitInfoType< HFRecHit > &recHitInfo)
 
template<>
CastorRecHit buildRecHit (const CaloRecHitMixer_mixedRecHitInfoType< CastorRecHit > &recHitInfo)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
void updateRecHitInfos (const RecHitCollection &, int)
 

Private Attributes

detIdToMixedRecHitInfoMap mixedRecHitInfos_
 
std::string moduleLabel_
 
edm::InputTag srcEnergyDepositMapMuMinus_
 
edm::InputTag srcEnergyDepositMapMuPlus_
 
std::vector< todoListEntryTypetodoList_
 
int typeEnergyDepositMap_
 
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 T>
class CaloRecHitMixer< T >

Merge collections of calorimeter recHits for original Zmumu event and "embedded" simulated tau decay products (detectors supported at the moment: EB/EE, HB/HE and HO)

Author
Tomasz Maciej Frueboes; Christian Veelken, LLR
Version
Revision:
1.9
Id:
CaloRecHitMixer.h,v 1.9 2013/03/23 09:12:51 veelken Exp

Definition at line 47 of file CaloRecHitMixer.h.

Member Typedef Documentation

template<typename T >
typedef std::map<uint32_t, float> CaloRecHitMixer< T >::detIdToFloatMap
private

Definition at line 83 of file CaloRecHitMixer.h.

template<typename T >
typedef std::map<uint32_t, CaloRecHitMixer_mixedRecHitInfoType<T> > CaloRecHitMixer< T >::detIdToMixedRecHitInfoMap
private

Definition at line 72 of file CaloRecHitMixer.h.

template<typename T >
typedef edm::SortedCollection<T> CaloRecHitMixer< T >::RecHitCollection
private

Definition at line 70 of file CaloRecHitMixer.h.

Member Enumeration Documentation

template<typename T >
anonymous enum
private
Enumerator
kAbsolute 

Definition at line 80 of file CaloRecHitMixer.h.

Constructor & Destructor Documentation

template<typename T >
CaloRecHitMixer< T >::CaloRecHitMixer ( const edm::ParameterSet cfg)
explicit

Definition at line 89 of file CaloRecHitMixer.h.

References edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::InputTag::instance(), CaloRecHitMixer< T >::kAbsolute, CaloRecHitMixer< T >::todoListEntryType::killNegEnergyAfterMixing_, CaloRecHitMixer< T >::todoListEntryType::killNegEnergyBeforeMixing1_, CaloRecHitMixer< T >::todoListEntryType::killNegEnergyBeforeMixing2_, CaloRecHitMixer< T >::todoListEntryType::kSubtractAfterMixing, CaloRecHitMixer< T >::todoListEntryType::kSubtractFromCollection1BeforeMixing, CaloRecHitMixer< T >::todoListEntryType::kSubtractFromCollection2BeforeMixing, CaloRecHitMixer< T >::todoListEntryType::muonEnSutractionMode_, CaloRecHitMixer< T >::todoListEntryType::srcRecHitCollection1_, CaloRecHitMixer< T >::todoListEntryType::srcRecHitCollection2_, AlCaHLTBitMon_QueryRunRegistry::string, CaloRecHitMixer< T >::todoList_, CaloRecHitMixer< T >::typeEnergyDepositMap_, and CaloRecHitMixer< T >::verbosity_.

90  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
91  srcEnergyDepositMapMuPlus_(cfg.getParameter<edm::InputTag>("srcEnergyDepositMapMuPlus")),
92  srcEnergyDepositMapMuMinus_(cfg.getParameter<edm::InputTag>("srcEnergyDepositMapMuMinus"))
93 {
94  edm::VParameterSet todoList = cfg.getParameter<edm::VParameterSet>("todo");
95  if ( todoList.size() == 0 ) {
96  throw cms::Exception("Configuration")
97  << "Empty to-do list !!\n";
98  }
99 
100  std::string typeEnergyDepositMap_string = cfg.getParameter<std::string>("typeEnergyDepositMap");
101  if ( typeEnergyDepositMap_string == "absolute" ) typeEnergyDepositMap_ = kAbsolute;
102  else throw cms::Exception("Configuration")
103  << "Invalid Configuration parameter 'typeEnergyDepositMap' = " << typeEnergyDepositMap_string << " !!\n";
104 
105  for ( edm::VParameterSet::const_iterator todoItem = todoList.begin();
106  todoItem != todoList.end(); ++todoItem ) {
107  todoListEntryType todoListEntry;
108  todoListEntry.srcRecHitCollection1_ = todoItem->getParameter<edm::InputTag>("collection1");
109  todoListEntry.killNegEnergyBeforeMixing1_ = todoItem->getParameter<bool>("killNegEnergyBeforeMixing1");
110  todoListEntry.srcRecHitCollection2_ = todoItem->getParameter<edm::InputTag>("collection2");
111  todoListEntry.killNegEnergyBeforeMixing2_ = todoItem->getParameter<bool>("killNegEnergyBeforeMixing2");
112  std::string muonEnSutractionMode_string = todoItem->getParameter<std::string>("muonEnSutractionMode");
113  if ( muonEnSutractionMode_string == "subtractFromCollection1BeforeMixing" ) todoListEntry.muonEnSutractionMode_ = todoListEntryType::kSubtractFromCollection1BeforeMixing;
114  else if ( muonEnSutractionMode_string == "subtractFromCollection2BeforeMixing" ) todoListEntry.muonEnSutractionMode_ = todoListEntryType::kSubtractFromCollection2BeforeMixing;
115  else if ( muonEnSutractionMode_string == "subtractAfterMixing" ) todoListEntry.muonEnSutractionMode_ = todoListEntryType::kSubtractAfterMixing;
116  else throw cms::Exception("Configuration")
117  << "Invalid Configuration parameter 'muonEnSutractionMode' = " << muonEnSutractionMode_string << " !!\n";
118  todoListEntry.killNegEnergyAfterMixing_ = todoItem->getParameter<bool>("killNegEnergyAfterMixing");
119 
120  std::string instanceLabel1 = todoListEntry.srcRecHitCollection1_.instance();
121  std::string instanceLabel2 = todoListEntry.srcRecHitCollection2_.instance();
122  if ( instanceLabel1 != instanceLabel2 ) {
123  throw cms::Exception("Configuration")
124  << "Mismatch in Instance labels for collection 1 = " << instanceLabel1 << " and 2 = " << instanceLabel2 << " !!\n";
125  }
126 
127  todoList_.push_back(todoListEntry);
128 
129  produces<RecHitCollection>(instanceLabel1);
130  std::string instanceLabel_removedEnergyMuMinus = "removedEnergyMuMinus";
131  if ( instanceLabel1 != "" ) instanceLabel_removedEnergyMuMinus.append("#").append(instanceLabel1);
132  produces<double>(instanceLabel_removedEnergyMuMinus.data());
133  std::string instanceLabel_removedEnergyMuPlus = "removedEnergyMuPlus";
134  if ( instanceLabel1 != "" ) instanceLabel_removedEnergyMuPlus.append("#").append(instanceLabel1);
135  produces<double>(instanceLabel_removedEnergyMuPlus.data());
136  }
137 
138  verbosity_ = ( cfg.exists("verbosity") ) ?
139  cfg.getParameter<int>("verbosity") : 0;
140 }
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 srcEnergyDepositMapMuPlus_
edm::InputTag srcEnergyDepositMapMuMinus_
std::vector< todoListEntryType > todoList_
std::string moduleLabel_
template<typename T >
CaloRecHitMixer< T >::~CaloRecHitMixer ( )

Definition at line 143 of file CaloRecHitMixer.h.

144 {
145 // nothing to be done yet...
146 }

Member Function Documentation

template<>
EcalRecHit CaloRecHitMixer< EcalRecHit >::buildRecHit ( const CaloRecHitMixer_mixedRecHitInfoType< EcalRecHit > &  recHitInfo)
private

Definition at line 34 of file CaloRecHitMixer.cc.

References CaloRecHitMixer_mixedRecHitInfoType< T >::energySum_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHit1_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHit2_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHitSum_, NULL, CaloRecHitMixer_mixedRecHitInfoType< T >::recHit1_, CaloRecHitMixer_mixedRecHitInfoType< T >::recHit2_, and EcalRecHit::setEnergy().

35 {
36  // CV: take status flags and timing information from simulated tau decay products
37  // (suggested by Florian Beaudette)
38  const EcalRecHit* recHit_ecal = NULL;
39  if ( recHitInfo.isRecHit1_ ) recHit_ecal = recHitInfo.recHit1_;
40  else if ( recHitInfo.isRecHit2_ ) recHit_ecal = recHitInfo.recHit2_;
41 
42  assert(recHit_ecal);
43  assert(recHitInfo.isRecHitSum_);
44 
45  EcalRecHit mergedRecHit(*recHit_ecal);
46  mergedRecHit.setEnergy(recHitInfo.energySum_);
47 
48  /* TODO Does not make sense
49  uint32_t flagBits = 0;
50  for ( int flag = 0; flag < 32; ++flag ) {
51  if ( recHit_ecal->checkFlag(flag) ) flagBits += (0x1 << flag);
52  }
53  EcalRecHit mergedRecHit(recHit_ecal->detid(), recHitInfo.energySum_, recHit_ecal->time(), recHit_ecal->flags(), flagBits);
54  mergedRecHit.setAux(recHit_ecal->aux());
55  */
56 
57  return mergedRecHit;
58 }
#define NULL
Definition: scimark2.h:8
template<typename T >
T CaloRecHitMixer< T >::buildRecHit ( const CaloRecHitMixer_mixedRecHitInfoType< T > &  recHitInfo)
private

Definition at line 22 of file CaloRecHitMixer.cc.

23 {
24  assert(0); // CV: make sure general function never gets called;
25  // always use template specializations
26 }
template<>
HBHERecHit CaloRecHitMixer< HBHERecHit >::buildRecHit ( const CaloRecHitMixer_mixedRecHitInfoType< HBHERecHit > &  recHitInfo)
private

Definition at line 86 of file CaloRecHitMixer.cc.

87 {
88  return buildRecHit_HCAL<HBHERecHit>(recHitInfo);
89 }
template<>
HORecHit CaloRecHitMixer< HORecHit >::buildRecHit ( const CaloRecHitMixer_mixedRecHitInfoType< HORecHit > &  recHitInfo)
private

Definition at line 92 of file CaloRecHitMixer.cc.

93 {
94  return buildRecHit_HCAL<HORecHit>(recHitInfo);
95 }
template<>
HFRecHit CaloRecHitMixer< HFRecHit >::buildRecHit ( const CaloRecHitMixer_mixedRecHitInfoType< HFRecHit > &  recHitInfo)
private

Definition at line 98 of file CaloRecHitMixer.cc.

99 {
100  return buildRecHit_HCAL<HFRecHit>(recHitInfo);
101 }
template<>
CastorRecHit CaloRecHitMixer< CastorRecHit >::buildRecHit ( const CaloRecHitMixer_mixedRecHitInfoType< CastorRecHit > &  recHitInfo)
private

Definition at line 109 of file CaloRecHitMixer.cc.

References CaloRecHit::aux(), CaloRecHit::detid(), CaloRecHitMixer_mixedRecHitInfoType< T >::energySum_, CaloRecHit::flags(), CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHit1_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHit2_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHitSum_, CaloRecHitMixer_mixedRecHitInfoType< T >::recHit1_, CaloRecHitMixer_mixedRecHitInfoType< T >::recHit2_, CaloRecHit::setFlags(), and CaloRecHit::time().

110 {
111  // CV: take status flags and timing information from simulated tau decay products
112  // (suggested by Florian Beaudette)
113  const CaloRecHit* recHit = 0;
114  if ( recHitInfo.isRecHit1_ ) recHit = recHitInfo.recHit1_;
115  else if ( recHitInfo.isRecHit2_ ) recHit = recHitInfo.recHit2_;
116  const CastorRecHit* recHit_castor = static_cast<const CastorRecHit*>(recHit);
117  assert(recHit_castor);
118  assert(recHitInfo.isRecHitSum_);
119  CastorRecHit mergedRecHit(recHit_castor->detid(), recHitInfo.energySum_, recHit_castor->time());
120  mergedRecHit.setFlags(recHit_castor->flags());
121  mergedRecHit.setAux(recHit_castor->aux());
122  return mergedRecHit;
123 }
uint32_t aux() const
Definition: CaloRecHit.h:26
const DetId & detid() const
Definition: CaloRecHit.h:20
float time() const
Definition: CaloRecHit.h:19
uint32_t flags() const
Definition: CaloRecHit.h:21
void setFlags(uint32_t flags)
Definition: CaloRecHit.h:22
template<typename T >
void CaloRecHitMixer< T >::produce ( edm::Event evt,
const edm::EventSetup es 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 162 of file CaloRecHitMixer.h.

References edm::HandleBase::clear(), gather_cfg::cout, alignCSCRings::e, edm::Event::getByLabel(), moduleLabel_(), edm::Event::put(), and AlCaHLTBitMon_QueryRunRegistry::string.

163 {
164  if ( verbosity_ ) std::cout << "<CaloRecHitMixer::produce (" << moduleLabel_ << ")>:" << std::endl;
165 
166  edm::Handle<detIdToFloatMap> energyDepositMapMuPlus;
167  evt.getByLabel(srcEnergyDepositMapMuPlus_, energyDepositMapMuPlus);
168  edm::Handle<detIdToFloatMap> energyDepositMapMuMinus;
169  evt.getByLabel(srcEnergyDepositMapMuMinus_, energyDepositMapMuMinus);
170 
171  for ( typename std::vector<todoListEntryType>::const_iterator todoItem = todoList_.begin();
172  todoItem != todoList_.end(); ++todoItem ) {
173  edm::Handle<RecHitCollection> recHitCollection1;
174  evt.getByLabel(todoItem->srcRecHitCollection1_, recHitCollection1);
175  edm::Handle<RecHitCollection> recHitCollection2;
176  evt.getByLabel(todoItem->srcRecHitCollection2_, recHitCollection2);
177  if ( verbosity_ ) {
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;
182  }
183 
184  mixedRecHitInfos_.clear();
185  updateRecHitInfos(*recHitCollection1, 0);
186  updateRecHitInfos(*recHitCollection2, 1);
187 
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.));
191 
192  double muPlusEnergySum = 0.;
193  double muMinusEnergySum = 0.;
194 
195  for ( typename detIdToMixedRecHitInfoMap::iterator mixedRecHitInfo = mixedRecHitInfos_.begin();
196  mixedRecHitInfo != mixedRecHitInfos_.end(); ++mixedRecHitInfo ) {
197  uint32_t rawDetId = mixedRecHitInfo->second.rawDetId_;
198 
199  double muPlusEnergyDeposit = getCorrection(rawDetId, *energyDepositMapMuPlus);
200  double muMinusEnergyDeposit = getCorrection(rawDetId, *energyDepositMapMuMinus);
201  double muonEnergyDeposit = muPlusEnergyDeposit + muMinusEnergyDeposit;
202 
203  muPlusEnergySum += muPlusEnergyDeposit;
204  muMinusEnergySum += muMinusEnergyDeposit;
205 
206  if ( muonEnergyDeposit > 0. ) {
207  if ( verbosity_ ) std::cout << "removing muon energy: detId = " << rawDetId << ", subtracted = " << muonEnergyDeposit << std::endl;
208  if ( mixedRecHitInfo->second.isRecHit1_ && todoItem->muonEnSutractionMode_ == todoListEntryType::kSubtractFromCollection1BeforeMixing ) {
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;
215  } else {
216  (*removedEnergyMuPlus) += muPlusEnergyDeposit;
217  (*removedEnergyMuMinus) += muMinusEnergyDeposit;
218  mixedRecHitInfo->second.energy1_ -= muonEnergyDeposit;
219  }
220  }
221  if ( mixedRecHitInfo->second.isRecHit2_ && todoItem->muonEnSutractionMode_ == todoListEntryType::kSubtractFromCollection2BeforeMixing ) {
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;
228  } else {
229  (*removedEnergyMuPlus) += muPlusEnergyDeposit;
230  (*removedEnergyMuMinus) += muMinusEnergyDeposit;
231  mixedRecHitInfo->second.energy2_ -= muonEnergyDeposit;
232  }
233  }
234  }
235 
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;
241  }
242  if ( mixedRecHitInfo->second.isRecHit2_ ) {
243  mixedRecHitInfo->second.energySum_ += mixedRecHitInfo->second.energy2_;
244  mixedRecHitInfo->second.isRecHitSum_ = true;
245  }
246  if ( muonEnergyDeposit > 0. ) {
247  if ( mixedRecHitInfo->second.isRecHitSum_ && todoItem->muonEnSutractionMode_ == todoListEntryType::kSubtractAfterMixing ) {
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;
254  } else {
255  (*removedEnergyMuPlus) += muPlusEnergyDeposit;
256  (*removedEnergyMuMinus) += muMinusEnergyDeposit;
257  mixedRecHitInfo->second.energySum_ -= muonEnergyDeposit;
258  }
259  }
260  }
261 
262  if ( mixedRecHitInfo->second.isRecHitSum_ ) {
263  if ( verbosity_ ) {
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;
266  }
267  recHitCollection_output->push_back(buildRecHit(mixedRecHitInfo->second));
268  }
269  }
270 
271  if ( verbosity_ ) {
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;
275  }
276 
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());
285  }
286 }
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.
Definition: Event.h:113
edm::SortedCollection< T > RecHitCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
std::string moduleLabel_
tuple cout
Definition: gather_cfg.py:121
template<typename T >
void CaloRecHitMixer< T >::updateRecHitInfos ( const RecHitCollection recHitCollection,
int  idx 
)
private

Definition at line 289 of file CaloRecHitMixer.h.

References edm::SortedCollection< T, SORT >::begin(), gather_cfg::cout, edm::SortedCollection< T, SORT >::end(), CaloRecHitMixer_mixedRecHitInfoType< T >::energy1_, CaloRecHitMixer_mixedRecHitInfoType< T >::energy2_, CaloRecHitMixer_mixedRecHitInfoType< T >::energySum_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHit1_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHit2_, CaloRecHitMixer_mixedRecHitInfoType< T >::isRecHitSum_, CaloRecHitMixer_mixedRecHitInfoType< T >::rawDetId_, CaloRecHitMixer_mixedRecHitInfoType< T >::recHit1_, and CaloRecHitMixer_mixedRecHitInfoType< T >::recHit2_.

290 {
291  for ( typename RecHitCollection::const_iterator recHit = recHitCollection.begin();
292  recHit != recHitCollection.end(); ++recHit ) {
293  uint32_t rawDetId = recHit->detid().rawId();
294 
295  bool isNewRecHit = (mixedRecHitInfos_.find(rawDetId) == mixedRecHitInfos_.end());
296  if ( isNewRecHit ) {
298  mixedRecHitInfo.rawDetId_ = rawDetId;
299  mixedRecHitInfo.energy1_ = 0.;
300  mixedRecHitInfo.isRecHit1_ = false;
301  mixedRecHitInfo.recHit1_ = 0;
302  mixedRecHitInfo.energy2_ = 0.;
303  mixedRecHitInfo.isRecHit2_ = false;
304  mixedRecHitInfo.recHit2_ = 0;
305  mixedRecHitInfo.energySum_ = 0.;
306  mixedRecHitInfo.isRecHitSum_ = false;
307  mixedRecHitInfos_.insert(std::pair<uint32_t, CaloRecHitMixer_mixedRecHitInfoType<T> >(rawDetId, mixedRecHitInfo));
308  }
309 
310  typename detIdToMixedRecHitInfoMap::iterator mixedRecHitInfo = mixedRecHitInfos_.find(rawDetId);
311  assert(mixedRecHitInfo != mixedRecHitInfos_.end());
312 
313  if ( verbosity_ ) {
314  if ( isNewRecHit ) std::cout << "creating new recHit: detId = " << rawDetId << ", energy = " << recHit->energy() << std::endl;
315  else std::cout << "merging recHits: detId = " << rawDetId << ", total energy = " << (mixedRecHitInfo->second.energy1_ + mixedRecHitInfo->second.energy2_)
316  << " (added = " << recHit->energy() << ")" << std::endl;
317  }
318 
319  if ( idx == 0 ) {
320  mixedRecHitInfo->second.energy1_ = recHit->energy();
321  mixedRecHitInfo->second.isRecHit1_ = true;
322  mixedRecHitInfo->second.recHit1_ = &(*recHit);
323  } else if ( idx == 1 ) {
324  mixedRecHitInfo->second.energy2_ = recHit->energy();
325  mixedRecHitInfo->second.isRecHit2_ = true;
326  mixedRecHitInfo->second.recHit2_ = &(*recHit);
327  } else assert(0);
328  }
329 }
detIdToMixedRecHitInfoMap mixedRecHitInfos_
std::vector< T >::const_iterator const_iterator
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

template<typename T >
detIdToMixedRecHitInfoMap CaloRecHitMixer< T >::mixedRecHitInfos_
private

Definition at line 73 of file CaloRecHitMixer.h.

template<typename T >
std::string CaloRecHitMixer< T >::moduleLabel_
private
template<typename T >
edm::InputTag CaloRecHitMixer< T >::srcEnergyDepositMapMuMinus_
private

Definition at line 79 of file CaloRecHitMixer.h.

template<typename T >
edm::InputTag CaloRecHitMixer< T >::srcEnergyDepositMapMuPlus_
private

Definition at line 78 of file CaloRecHitMixer.h.

template<typename T >
std::vector<todoListEntryType> CaloRecHitMixer< T >::todoList_
private

Definition at line 68 of file CaloRecHitMixer.h.

Referenced by CaloRecHitMixer< T >::CaloRecHitMixer().

template<typename T >
int CaloRecHitMixer< T >::typeEnergyDepositMap_
private

Definition at line 81 of file CaloRecHitMixer.h.

Referenced by CaloRecHitMixer< T >::CaloRecHitMixer().

template<typename T >
int CaloRecHitMixer< T >::verbosity_
private

Definition at line 85 of file CaloRecHitMixer.h.

Referenced by CaloRecHitMixer< T >::CaloRecHitMixer().