CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
edm::DataMixingEMWorker Class Reference

#include <DataMixingEMWorker.h>

Public Member Functions

void addEMPileups (const int bcr, const edm::EventPrincipal *, unsigned int EventId, ModuleCallingContext const *)
 
void addEMSignals (const edm::Event &e)
 
 DataMixingEMWorker ()
 
 DataMixingEMWorker (const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
 
void putEM (edm::Event &e)
 
virtual ~DataMixingEMWorker ()
 

Private Types

typedef std::multimap< DetId, EcalRecHitEBRecHitMap
 
typedef std::multimap< DetId, EcalRecHitEERecHitMap
 
typedef std::multimap< DetId, EcalRecHitESRecHitMap
 

Private Attributes

edm::InputTag EBPileRecHitInputTag_
 
edm::EDGetTokenT< EBRecHitCollectionEBPileRecHitToken_
 
edm::InputTag EBProducerSig_
 
std::string EBRecHitCollectionDM_
 
edm::InputTag EBrechitCollectionSig_
 
EBRecHitMap EBRecHitStorage_
 
edm::EDGetTokenT< EBRecHitCollectionEBRecHitToken_
 
edm::InputTag EEPileRecHitInputTag_
 
edm::EDGetTokenT< EERecHitCollectionEEPileRecHitToken_
 
edm::InputTag EEProducerSig_
 
std::string EERecHitCollectionDM_
 
edm::InputTag EErechitCollectionSig_
 
EERecHitMap EERecHitStorage_
 
edm::EDGetTokenT< EERecHitCollectionEERecHitToken_
 
edm::InputTag ESPileRecHitInputTag_
 
edm::EDGetTokenT< ESRecHitCollectionESPileRecHitToken_
 
edm::InputTag ESProducerSig_
 
std::string ESRecHitCollectionDM_
 
edm::InputTag ESrechitCollectionSig_
 
ESRecHitMap ESRecHitStorage_
 
edm::EDGetTokenT< ESRecHitCollectionESRecHitToken_
 
std::string label_
 

Detailed Description

Definition at line 37 of file DataMixingEMWorker.h.

Member Typedef Documentation

typedef std::multimap<DetId, EcalRecHit> edm::DataMixingEMWorker::EBRecHitMap
private

Definition at line 84 of file DataMixingEMWorker.h.

typedef std::multimap<DetId, EcalRecHit> edm::DataMixingEMWorker::EERecHitMap
private

Definition at line 85 of file DataMixingEMWorker.h.

typedef std::multimap<DetId, EcalRecHit> edm::DataMixingEMWorker::ESRecHitMap
private

Definition at line 86 of file DataMixingEMWorker.h.

Constructor & Destructor Documentation

DataMixingEMWorker::DataMixingEMWorker ( )

Definition at line 21 of file DataMixingEMWorker.cc.

21 {}
DataMixingEMWorker::DataMixingEMWorker ( const edm::ParameterSet ps,
edm::ConsumesCollector &&  iC 
)
explicit

standard constructor

Definition at line 24 of file DataMixingEMWorker.cc.

References EBPileRecHitInputTag_, EBPileRecHitToken_, EBProducerSig_, EBRecHitCollectionDM_, EBrechitCollectionSig_, EBRecHitToken_, EEPileRecHitInputTag_, EEPileRecHitToken_, EEProducerSig_, EERecHitCollectionDM_, EErechitCollectionSig_, EERecHitToken_, ESPileRecHitInputTag_, ESPileRecHitToken_, ESProducerSig_, ESRecHitCollectionDM_, ESrechitCollectionSig_, ESRecHitToken_, edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

25  : label_(ps.getParameter<std::string>("Label"))
26 
27  {
28  // get the subdetector names
29  // this->getSubdetectorNames(); //something like this may be useful to
30  // check what we are supposed to do...
31 
32  // declare the products to produce, retrieve
33 
34  EBProducerSig_ = ps.getParameter<edm::InputTag>("EBProducerSig");
35  EEProducerSig_ = ps.getParameter<edm::InputTag>("EEProducerSig");
36  ESProducerSig_ = ps.getParameter<edm::InputTag>("ESProducerSig");
37 
41 
42  EBrechitCollectionSig_ = ps.getParameter<edm::InputTag>("EBrechitCollectionSig");
43  EErechitCollectionSig_ = ps.getParameter<edm::InputTag>("EErechitCollectionSig");
44  ESrechitCollectionSig_ = ps.getParameter<edm::InputTag>("ESrechitCollectionSig");
45 
46  EBPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("EBPileRecHitInputTag");
47  EEPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("EEPileRecHitInputTag");
48  ESPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("ESPileRecHitInputTag");
49 
53 
54  EBRecHitCollectionDM_ = ps.getParameter<std::string>("EBRecHitCollectionDM");
55  EERecHitCollectionDM_ = ps.getParameter<std::string>("EERecHitCollectionDM");
56  ESRecHitCollectionDM_ = ps.getParameter<std::string>("ESRecHitCollectionDM");
57  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< EERecHitCollection > EEPileRecHitToken_
edm::InputTag EBrechitCollectionSig_
edm::InputTag ESPileRecHitInputTag_
edm::EDGetTokenT< EERecHitCollection > EERecHitToken_
edm::InputTag EErechitCollectionSig_
edm::EDGetTokenT< EBRecHitCollection > EBRecHitToken_
edm::EDGetTokenT< ESRecHitCollection > ESPileRecHitToken_
edm::EDGetTokenT< ESRecHitCollection > ESRecHitToken_
edm::InputTag ESrechitCollectionSig_
edm::InputTag EBPileRecHitInputTag_
edm::InputTag EEPileRecHitInputTag_
edm::EDGetTokenT< EBRecHitCollection > EBPileRecHitToken_
DataMixingEMWorker::~DataMixingEMWorker ( )
virtual

Default destructor

Definition at line 60 of file DataMixingEMWorker.cc.

60 {}

Member Function Documentation

void DataMixingEMWorker::addEMPileups ( const int  bcr,
const edm::EventPrincipal ep,
unsigned int  EventId,
ModuleCallingContext const *  mcc 
)

Definition at line 136 of file DataMixingEMWorker.cc.

References edm::SortedCollection< T, SORT >::begin(), EBPileRecHitInputTag_, filterRecHits_cfi::EBRecHits, EBRecHitStorage_, EEPileRecHitInputTag_, filterRecHits_cfi::EERecHits, EERecHitStorage_, edm::SortedCollection< T, SORT >::end(), SiStripBadComponentsDQMServiceTemplate_cfg::ep, ESPileRecHitInputTag_, ESRecHitStorage_, edm::EventPrincipal::id(), LogDebug, and edm::SortedCollection< T, SORT >::size().

Referenced by edm::DataMixingModule::pileWorker().

139  {
140  LogInfo("DataMixingEMWorker") << "\n===============> adding pileups from event " << ep->id()
141  << " for bunchcrossing " << bcr;
142 
143  // fill in maps of hits; same code as addSignals, except now applied to the
144  // pileup events
145 
146  // EB first
147 
148  std::shared_ptr<Wrapper<EBRecHitCollection> const> EBRecHitsPTR =
149  getProductByTag<EBRecHitCollection>(*ep, EBPileRecHitInputTag_, mcc);
150 
151  if (EBRecHitsPTR) {
152  const EBRecHitCollection *EBRecHits = const_cast<EBRecHitCollection *>(EBRecHitsPTR->product());
153 
154  LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
155 
156  // loop over digis, adding these to the existing maps
157  for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
158  EBRecHitStorage_.insert(EBRecHitMap::value_type((it->id()), *it));
159 
160 #ifdef DEBUG
161  LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: " << it->id().rawId() << "\n"
162  << " rechit energy: " << it->energy();
163 #endif
164  }
165  }
166 
167  // EE Next
168 
169  std::shared_ptr<Wrapper<EERecHitCollection> const> EERecHitsPTR =
170  getProductByTag<EERecHitCollection>(*ep, EEPileRecHitInputTag_, mcc);
171 
172  if (EERecHitsPTR) {
173  const EERecHitCollection *EERecHits = const_cast<EERecHitCollection *>(EERecHitsPTR->product());
174 
175  LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
176 
177  // loop over digis, adding these to the existing maps
178  for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
179  EERecHitStorage_.insert(EERecHitMap::value_type((it->id()), *it));
180 
181 #ifdef DEBUG
182  LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: " << it->id().rawId() << "\n"
183  << " rechit energy: " << it->energy();
184 #endif
185  }
186  }
187 
188  // ES Next
189 
190  std::shared_ptr<Wrapper<ESRecHitCollection> const> ESRecHitsPTR =
191  getProductByTag<ESRecHitCollection>(*ep, ESPileRecHitInputTag_, mcc);
192 
193  if (ESRecHitsPTR) {
194  const ESRecHitCollection *ESRecHits = const_cast<ESRecHitCollection *>(ESRecHitsPTR->product());
195 
196  LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
197 
198  // loop over digis, adding these to the existing maps
199  for (ESRecHitCollection::const_iterator it = ESRecHits->begin(); it != ESRecHits->end(); ++it) {
200  ESRecHitStorage_.insert(ESRecHitMap::value_type((it->id()), *it));
201 
202 #ifdef DEBUG
203  LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: " << it->id().rawId() << "\n"
204  << " rechit energy: " << it->energy();
205 #endif
206  }
207  }
208  }
#define LogDebug(id)
EventID const & id() const
std::vector< EcalRecHit >::const_iterator const_iterator
edm::InputTag ESPileRecHitInputTag_
const_iterator end() const
edm::InputTag EBPileRecHitInputTag_
edm::InputTag EEPileRecHitInputTag_
size_type size() const
const_iterator begin() const
void DataMixingEMWorker::addEMSignals ( const edm::Event e)

Definition at line 62 of file DataMixingEMWorker.cc.

References edm::SortedCollection< T, SORT >::begin(), filterRecHits_cfi::EBRecHits, EBRecHitStorage_, EBRecHitToken_, filterRecHits_cfi::EERecHits, EERecHitStorage_, EERecHitToken_, edm::SortedCollection< T, SORT >::end(), ESRecHitStorage_, ESRecHitToken_, edm::Event::getByToken(), edm::EventBase::id(), LogDebug, edm::Handle< T >::product(), and edm::SortedCollection< T, SORT >::size().

Referenced by edm::DataMixingModule::addSignals().

62  {
63  // fill in maps of hits
64 
65  LogInfo("DataMixingEMWorker") << "===============> adding MC signals for " << e.id();
66 
67  // EB first
68 
69  Handle<EBRecHitCollection> pEBRecHits;
70 
71  const EBRecHitCollection *EBRecHits = nullptr;
72 
73  if (e.getByToken(EBRecHitToken_, pEBRecHits)) {
74  EBRecHits = pEBRecHits.product(); // get a ptr to the product
75  LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
76  }
77 
78  if (EBRecHits) {
79  // loop over rechits, storing them in a map so we can add pileup later
80  for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
81  EBRecHitStorage_.insert(EBRecHitMap::value_type((it->id()), *it));
82 
83  LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: " << it->id().rawId() << "\n"
84  << " rechit energy: " << it->energy();
85  }
86  }
87 
88  // EE next
89 
90  Handle<EERecHitCollection> pEERecHits;
91 
92  const EERecHitCollection *EERecHits = nullptr;
93 
94  if (e.getByToken(EERecHitToken_, pEERecHits)) {
95  EERecHits = pEERecHits.product(); // get a ptr to the product
96  LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
97  }
98 
99  if (EERecHits) {
100  // loop over rechits, storing them in a map so we can add pileup later
101  for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
102  EERecHitStorage_.insert(EERecHitMap::value_type((it->id()), *it));
103 #ifdef DEBUG
104  LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: " << it->id().rawId() << "\n"
105  << " rechit energy: " << it->energy();
106 #endif
107  }
108  }
109  // ES next
110 
111  Handle<ESRecHitCollection> pESRecHits;
112 
113  const ESRecHitCollection *ESRecHits = nullptr;
114 
115  if (e.getByToken(ESRecHitToken_, pESRecHits)) {
116  ESRecHits = pESRecHits.product(); // get a ptr to the product
117 #ifdef DEBUG
118  LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
119 #endif
120  }
121 
122  if (ESRecHits) {
123  // loop over rechits, storing them in a map so we can add pileup later
124  for (ESRecHitCollection::const_iterator it = ESRecHits->begin(); it != ESRecHits->end(); ++it) {
125  ESRecHitStorage_.insert(ESRecHitMap::value_type((it->id()), *it));
126 
127 #ifdef DEBUG
128  LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: " << it->id().rawId() << "\n"
129  << " rechit energy: " << it->energy();
130 #endif
131  }
132  }
133 
134  } // end of addEMSignals
#define LogDebug(id)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< EcalRecHit >::const_iterator const_iterator
edm::EDGetTokenT< EERecHitCollection > EERecHitToken_
edm::EDGetTokenT< EBRecHitCollection > EBRecHitToken_
const_iterator end() const
edm::EDGetTokenT< ESRecHitCollection > ESRecHitToken_
edm::EventID id() const
Definition: EventBase.h:59
size_type size() const
const_iterator begin() const
void DataMixingEMWorker::putEM ( edm::Event e)

Definition at line 210 of file DataMixingEMWorker.cc.

References EBRecHitCollectionDM_, EBRecHitStorage_, EERecHitCollectionDM_, EERecHitStorage_, HCALHighEnergyHPDFilter_cfi::energy, ESRecHitCollectionDM_, ESRecHitStorage_, eostools::move(), edm::Event::put(), and ntuplemaker::time.

Referenced by edm::DataMixingModule::put().

210  {
211  // collection of rechits to put in the event
212  std::unique_ptr<EBRecHitCollection> EBrechits(new EBRecHitCollection);
213  std::unique_ptr<EERecHitCollection> EErechits(new EERecHitCollection);
214  std::unique_ptr<ESRecHitCollection> ESrechits(new ESRecHitCollection);
215 
216  // loop over the maps we have, re-making individual hits or digis if
217  // necessary.
218  DetId formerID = 0;
219  DetId currentID;
220  float ESum = 0.;
221  float EBTime = 0.;
222 
223  // EB first...
224 
225  EBRecHitMap::const_iterator iEBchk;
226 
227  for (EBRecHitMap::const_iterator iEB = EBRecHitStorage_.begin(); iEB != EBRecHitStorage_.end(); ++iEB) {
228  currentID = iEB->first;
229 
230  if (currentID == formerID) { // we have to add these rechits together
231 
232  ESum += (iEB->second).energy();
233  } else {
234  if (formerID > 0) {
235  // cutoff for ESum?
236  EcalRecHit aHit(formerID, ESum, EBTime);
237  EBrechits->push_back(aHit);
238  }
239  // save pointers for next iteration
240  formerID = currentID;
241  ESum = (iEB->second).energy();
242  EBTime = (iEB->second).time(); // take time of first hit in sequence - is this ok?
243  }
244 
245  iEBchk = iEB;
246  if ((++iEBchk) == EBRecHitStorage_.end()) { // make sure not to lose the last one
247  EcalRecHit aHit(formerID, ESum, EBTime);
248  EBrechits->push_back(aHit);
249  }
250  }
251 
252  // EE next...
253 
254  // loop over the maps we have, re-making individual hits or digis if
255  // necessary.
256  formerID = 0;
257  ESum = 0.;
258  float EETime = 0.;
259 
260  EERecHitMap::const_iterator iEEchk;
261 
262  for (EERecHitMap::const_iterator iEE = EERecHitStorage_.begin(); iEE != EERecHitStorage_.end(); ++iEE) {
263  currentID = iEE->first;
264 
265  if (currentID == formerID) { // we have to add these rechits together
266 
267  ESum += (iEE->second).energy();
268  } else {
269  if (formerID > 0) {
270  // cutoff for ESum?
271  EcalRecHit aHit(formerID, ESum, EETime);
272  EErechits->push_back(aHit);
273  }
274  // save pointers for next iteration
275  formerID = currentID;
276  ESum = (iEE->second).energy();
277  EETime = (iEE->second).time(); // take time of first hit in sequence - is this ok?
278  }
279 
280  iEEchk = iEE;
281  if ((++iEEchk) == EERecHitStorage_.end()) { // make sure not to lose the last one
282  EcalRecHit aHit(formerID, ESum, EETime);
283  EErechits->push_back(aHit);
284  }
285  }
286 
287  // ES next...
288 
289  // loop over the maps we have, re-making individual hits or digis if
290  // necessary.
291  formerID = 0;
292  ESum = 0.;
293  float ESTime = 0.;
294 
295  ESRecHitMap::const_iterator iESchk;
296 
297  for (ESRecHitMap::const_iterator iES = ESRecHitStorage_.begin(); iES != ESRecHitStorage_.end(); ++iES) {
298  currentID = iES->first;
299 
300  if (currentID == formerID) { // we have to add these rechits together
301 
302  ESum += (iES->second).energy();
303  } else {
304  if (formerID > 0) {
305  // cutoff for ESum?
306  EcalRecHit aHit(formerID, ESum, ESTime);
307  ESrechits->push_back(aHit);
308  }
309  // save pointers for next iteration
310  formerID = currentID;
311  ESum = (iES->second).energy();
312  ESTime = (iES->second).time(); // take time of first hit in sequence - is this ok?
313  }
314 
315  iESchk = iES;
316  if ((++iESchk) == ESRecHitStorage_.end()) { // make sure not to lose the last one
317  EcalRecHit aHit(formerID, ESum, ESTime);
318  ESrechits->push_back(aHit);
319  }
320  }
321 
322  // done merging
323 
324  // put the collection of reconstructed hits in the event
325  LogInfo("DataMixingEMWorker") << "total # EB Merged rechits: " << EBrechits->size();
326  LogInfo("DataMixingEMWorker") << "total # EE Merged rechits: " << EErechits->size();
327  LogInfo("DataMixingEMWorker") << "total # ES Merged rechits: " << ESrechits->size();
328 
329  e.put(std::move(EBrechits), EBRecHitCollectionDM_);
330  e.put(std::move(EErechits), EERecHitCollectionDM_);
331  e.put(std::move(ESrechits), ESRecHitCollectionDM_);
332 
333  // clear local storage after this event
334 
335  EBRecHitStorage_.clear();
336  EERecHitStorage_.clear();
337  ESRecHitStorage_.clear();
338  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
Definition: DetId.h:17
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::InputTag edm::DataMixingEMWorker::EBPileRecHitInputTag_
private

Definition at line 65 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

edm::EDGetTokenT<EBRecHitCollection> edm::DataMixingEMWorker::EBPileRecHitToken_
private

Definition at line 73 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::EBProducerSig_
private

Definition at line 54 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

std::string edm::DataMixingEMWorker::EBRecHitCollectionDM_
private

Definition at line 77 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

edm::InputTag edm::DataMixingEMWorker::EBrechitCollectionSig_
private

Definition at line 58 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

EBRecHitMap edm::DataMixingEMWorker::EBRecHitStorage_
private

Definition at line 88 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), addEMSignals(), and putEM().

edm::EDGetTokenT<EBRecHitCollection> edm::DataMixingEMWorker::EBRecHitToken_
private

Definition at line 69 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::EEPileRecHitInputTag_
private

Definition at line 66 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

edm::EDGetTokenT<EERecHitCollection> edm::DataMixingEMWorker::EEPileRecHitToken_
private

Definition at line 74 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::EEProducerSig_
private

Definition at line 55 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

std::string edm::DataMixingEMWorker::EERecHitCollectionDM_
private

Definition at line 79 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

edm::InputTag edm::DataMixingEMWorker::EErechitCollectionSig_
private

Definition at line 60 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

EERecHitMap edm::DataMixingEMWorker::EERecHitStorage_
private

Definition at line 89 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), addEMSignals(), and putEM().

edm::EDGetTokenT<EERecHitCollection> edm::DataMixingEMWorker::EERecHitToken_
private

Definition at line 70 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::ESPileRecHitInputTag_
private

Definition at line 67 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

edm::EDGetTokenT<ESRecHitCollection> edm::DataMixingEMWorker::ESPileRecHitToken_
private

Definition at line 75 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::ESProducerSig_
private

Definition at line 56 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

std::string edm::DataMixingEMWorker::ESRecHitCollectionDM_
private

Definition at line 81 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

edm::InputTag edm::DataMixingEMWorker::ESrechitCollectionSig_
private

Definition at line 62 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

ESRecHitMap edm::DataMixingEMWorker::ESRecHitStorage_
private

Definition at line 90 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), addEMSignals(), and putEM().

edm::EDGetTokenT<ESRecHitCollection> edm::DataMixingEMWorker::ESRecHitToken_
private

Definition at line 71 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

std::string edm::DataMixingEMWorker::label_
private