CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
void addEMSignals (const edm::Event &e)
 
 DataMixingEMWorker ()
 
 DataMixingEMWorker (const edm::ParameterSet &ps)
 
void putEM (edm::Event &e)
 
virtual ~DataMixingEMWorker ()
 

Private Types

typedef std::multimap< DetId,
EcalRecHit
EBRecHitMap
 
typedef std::multimap< DetId,
EcalRecHit
EERecHitMap
 
typedef std::multimap< DetId,
EcalRecHit
ESRecHitMap
 

Private Attributes

edm::InputTag EBPileRecHitInputTag_
 
edm::InputTag EBProducerSig_
 
std::string EBRecHitCollectionDM_
 
edm::InputTag EBrechitCollectionSig_
 
EBRecHitMap EBRecHitStorage_
 
edm::InputTag EEPileRecHitInputTag_
 
edm::InputTag EEProducerSig_
 
std::string EERecHitCollectionDM_
 
edm::InputTag EErechitCollectionSig_
 
EERecHitMap EERecHitStorage_
 
edm::InputTag ESPileRecHitInputTag_
 
edm::InputTag ESProducerSig_
 
std::string ESRecHitCollectionDM_
 
edm::InputTag ESrechitCollectionSig_
 
ESRecHitMap ESRecHitStorage_
 
std::string label_
 
Selectorsel_
 

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 76 of file DataMixingEMWorker.h.

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

Definition at line 77 of file DataMixingEMWorker.h.

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

Definition at line 78 of file DataMixingEMWorker.h.

Constructor & Destructor Documentation

DataMixingEMWorker::DataMixingEMWorker ( )

Definition at line 27 of file DataMixingEMWorker.cc.

27 { sel_=0;}
DataMixingEMWorker::DataMixingEMWorker ( const edm::ParameterSet ps)
explicit

standard constructor

Definition at line 30 of file DataMixingEMWorker.cc.

References EBPileRecHitInputTag_, EBProducerSig_, EBRecHitCollectionDM_, EBrechitCollectionSig_, EEPileRecHitInputTag_, EEProducerSig_, EERecHitCollectionDM_, EErechitCollectionSig_, ESPileRecHitInputTag_, ESProducerSig_, ESRecHitCollectionDM_, ESrechitCollectionSig_, edm::ParameterSet::getParameter(), label_, and sel_.

30  :
31  label_(ps.getParameter<std::string>("Label"))
32 
33  {
34 
35  // get the subdetector names
36  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
37 
38  // create input selector
39  if (label_.size()>0){
40  sel_=new Selector( ModuleLabelSelector(label_));
41  }
42  else {
43  sel_=new Selector( MatchAllSelector());
44  }
45 
46  // declare the products to produce, retrieve
47 
48  EBProducerSig_ = ps.getParameter<edm::InputTag>("EBProducerSig");
49  EEProducerSig_ = ps.getParameter<edm::InputTag>("EEProducerSig");
50  ESProducerSig_ = ps.getParameter<edm::InputTag>("ESProducerSig");
51 
52 
53  EBrechitCollectionSig_ = ps.getParameter<edm::InputTag>("EBrechitCollectionSig");
54  EErechitCollectionSig_ = ps.getParameter<edm::InputTag>("EErechitCollectionSig");
55  ESrechitCollectionSig_ = ps.getParameter<edm::InputTag>("ESrechitCollectionSig");
56 
57  EBPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("EBPileRecHitInputTag");
58  EEPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("EEPileRecHitInputTag");
59  ESPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("ESPileRecHitInputTag");
60 
61 
62  EBRecHitCollectionDM_ = ps.getParameter<std::string>("EBRecHitCollectionDM");
63  EERecHitCollectionDM_ = ps.getParameter<std::string>("EERecHitCollectionDM");
64  ESRecHitCollectionDM_ = ps.getParameter<std::string>("ESRecHitCollectionDM");
65  // nMaxPrintout_ = ps.getUntrackedParameter<int>("nMaxPrintout",10);
66 
67  //EBalgo_ = new EcalRecHitSimpleAlgo();
68  //EEalgo_ = new EcalRecHitSimpleAlgo();
69 
70  // don't think I can "produce" in a sub-class...
71 
72  //produces< EBRecHitCollection >(EBRecHitCollectionDM_);
73  //produces< EERecHitCollection >(EERecHitCollectionDM_);
74 
75  }
T getParameter(std::string const &) const
edm::InputTag EBrechitCollectionSig_
edm::InputTag ESPileRecHitInputTag_
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
edm::InputTag EErechitCollectionSig_
edm::InputTag ESrechitCollectionSig_
edm::InputTag EBPileRecHitInputTag_
edm::InputTag EEPileRecHitInputTag_
DataMixingEMWorker::~DataMixingEMWorker ( )
virtual

Default destructor

Definition at line 79 of file DataMixingEMWorker.cc.

References sel_.

79  {
80  delete sel_;
81  sel_=0;
82  }

Member Function Documentation

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

Definition at line 178 of file DataMixingEMWorker.cc.

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

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

178  {
179 
180  LogInfo("DataMixingEMWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
181 
182  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
183 
184  // EB first
185 
186  boost::shared_ptr<Wrapper<EBRecHitCollection> const> EBRecHitsPTR =
187  getProductByTag<EBRecHitCollection>(*ep, EBPileRecHitInputTag_ );
188 
189  if(EBRecHitsPTR ) {
190 
191  const EBRecHitCollection* EBRecHits = const_cast< EBRecHitCollection * >(EBRecHitsPTR->product());
192 
193  LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
194 
195  // loop over digis, adding these to the existing maps
196  for(EBRecHitCollection::const_iterator it = EBRecHits->begin();
197  it != EBRecHits->end(); ++it) {
198 
199  EBRecHitStorage_.insert(EBRecHitMap::value_type( (it->id()), *it ));
200 
201 #ifdef DEBUG
202  LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: "
203  << it->id().rawId() << "\n"
204  << " rechit energy: " << it->energy();
205 #endif
206  }
207  }
208 
209  // EE Next
210 
211  boost::shared_ptr<Wrapper<EERecHitCollection> const> EERecHitsPTR =
212  getProductByTag<EERecHitCollection>(*ep, EEPileRecHitInputTag_ );
213 
214  if(EERecHitsPTR ) {
215 
216  const EERecHitCollection* EERecHits = const_cast< EERecHitCollection * >(EERecHitsPTR->product());
217 
218  LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
219 
220  // loop over digis, adding these to the existing maps
221  for(EERecHitCollection::const_iterator it = EERecHits->begin();
222  it != EERecHits->end(); ++it) {
223 
224  EERecHitStorage_.insert(EERecHitMap::value_type( (it->id()), *it ));
225 
226 #ifdef DEBUG
227  LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: "
228  << it->id().rawId() << "\n"
229  << " rechit energy: " << it->energy();
230 #endif
231  }
232  }
233 
234  // ES Next
235 
236  boost::shared_ptr<Wrapper<ESRecHitCollection> const> ESRecHitsPTR =
237  getProductByTag<ESRecHitCollection>(*ep, ESPileRecHitInputTag_ );
238 
239  if(ESRecHitsPTR ) {
240 
241  const ESRecHitCollection* ESRecHits = const_cast< ESRecHitCollection * >(ESRecHitsPTR->product());
242 
243  LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
244 
245  // loop over digis, adding these to the existing maps
246  for(ESRecHitCollection::const_iterator it = ESRecHits->begin();
247  it != ESRecHits->end(); ++it) {
248 
249  ESRecHitStorage_.insert(ESRecHitMap::value_type( (it->id()), *it ));
250 
251 #ifdef DEBUG
252  LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: "
253  << it->id().rawId() << "\n"
254  << " rechit energy: " << it->energy();
255 #endif
256  }
257  }
258 
259 
260  }
#define LogDebug(id)
EventID const & id() const
std::vector< EcalRecHit >::const_iterator const_iterator
edm::InputTag ESPileRecHitInputTag_
Container::value_type value_type
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 84 of file DataMixingEMWorker.cc.

References edm::SortedCollection< T, SORT >::begin(), EBProducerSig_, egHLT::errCodes::EBRecHits, EBRecHitStorage_, EEProducerSig_, egHLT::errCodes::EERecHits, EERecHitStorage_, edm::SortedCollection< T, SORT >::end(), ESProducerSig_, ESRecHitStorage_, edm::Event::getByLabel(), edm::EventBase::id(), LogDebug, edm::Handle< T >::product(), and edm::SortedCollection< T, SORT >::size().

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

84  {
85  // fill in maps of hits
86 
87  LogInfo("DataMixingEMWorker")<<"===============> adding MC signals for "<<e.id();
88 
89  // EB first
90 
91  Handle< EBRecHitCollection > pEBRecHits;
92 
93  const EBRecHitCollection* EBRecHits = 0;
94 
95  if(e.getByLabel(EBProducerSig_, pEBRecHits) ){
96  EBRecHits = pEBRecHits.product(); // get a ptr to the product
97  LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
98  }
99 
100 
101  if (EBRecHits)
102  {
103  // loop over rechits, storing them in a map so we can add pileup later
104  for(EBRecHitCollection::const_iterator it = EBRecHits->begin();
105  it != EBRecHits->end(); ++it) {
106 
107  EBRecHitStorage_.insert(EBRecHitMap::value_type( ( it->id() ), *it ));
108 
109  LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: "
110  << it->id().rawId() << "\n"
111  << " rechit energy: " << it->energy();
112 
113  }
114  }
115 
116  // EE next
117 
118  Handle< EERecHitCollection > pEERecHits;
119 
120  const EERecHitCollection* EERecHits = 0;
121 
122 
123  if(e.getByLabel(EEProducerSig_, pEERecHits) ){
124  EERecHits = pEERecHits.product(); // get a ptr to the product
125  LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
126  }
127 
128 
129  if (EERecHits)
130  {
131  // loop over rechits, storing them in a map so we can add pileup later
132  for(EERecHitCollection::const_iterator it = EERecHits->begin();
133  it != EERecHits->end(); ++it) {
134 
135  EERecHitStorage_.insert(EERecHitMap::value_type( ( it->id() ), *it ));
136 #ifdef DEBUG
137  LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: "
138  << it->id().rawId() << "\n"
139  << " rechit energy: " << it->energy();
140 #endif
141 
142  }
143  }
144  // ES next
145 
146  Handle< ESRecHitCollection > pESRecHits;
147 
148  const ESRecHitCollection* ESRecHits = 0;
149 
150 
151  if(e.getByLabel( ESProducerSig_, pESRecHits) ){
152  ESRecHits = pESRecHits.product(); // get a ptr to the product
153 #ifdef DEBUG
154  LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
155 #endif
156  }
157 
158 
159  if (ESRecHits)
160  {
161  // loop over rechits, storing them in a map so we can add pileup later
162  for(ESRecHitCollection::const_iterator it = ESRecHits->begin();
163  it != ESRecHits->end(); ++it) {
164 
165  ESRecHitStorage_.insert(ESRecHitMap::value_type( ( it->id() ), *it ));
166 
167 #ifdef DEBUG
168  LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: "
169  << it->id().rawId() << "\n"
170  << " rechit energy: " << it->energy();
171 #endif
172 
173  }
174  }
175 
176  } // end of addEMSignals
#define LogDebug(id)
std::vector< EcalRecHit >::const_iterator const_iterator
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const_iterator end() const
edm::EventID id() const
Definition: EventBase.h:56
size_type size() const
const_iterator begin() const
void DataMixingEMWorker::putEM ( edm::Event e)

Definition at line 262 of file DataMixingEMWorker.cc.

References EBRecHitCollectionDM_, EBRecHitStorage_, EERecHitCollectionDM_, EERecHitStorage_, relval_parameters_module::energy, ESRecHitCollectionDM_, ESRecHitStorage_, edm::Event::put(), and cond::rpcobgas::time.

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

262  {
263 
264  // collection of rechits to put in the event
265  std::auto_ptr< EBRecHitCollection > EBrechits( new EBRecHitCollection );
266  std::auto_ptr< EERecHitCollection > EErechits( new EERecHitCollection );
267  std::auto_ptr< ESRecHitCollection > ESrechits( new ESRecHitCollection );
268 
269  // loop over the maps we have, re-making individual hits or digis if necessary.
270  DetId formerID = 0;
271  DetId currentID;
272  float ESum = 0.;
273  float EBTime = 0.;
274 
275  // EB first...
276 
277  EBRecHitMap::const_iterator iEBchk;
278 
279  for(EBRecHitMap::const_iterator iEB = EBRecHitStorage_.begin();
280  iEB != EBRecHitStorage_.end(); ++iEB) {
281 
282  currentID = iEB->first;
283 
284  if (currentID == formerID) { // we have to add these rechits together
285 
286  ESum+=(iEB->second).energy();
287  }
288  else {
289  if(formerID>0) {
290  // cutoff for ESum?
291  EcalRecHit aHit(formerID, ESum, EBTime);
292  EBrechits->push_back( aHit );
293  }
294  //save pointers for next iteration
295  formerID = currentID;
296  ESum = (iEB->second).energy();
297  EBTime = (iEB->second).time(); // take time of first hit in sequence - is this ok?
298  }
299 
300  iEBchk = iEB;
301  if((++iEBchk) == EBRecHitStorage_.end()) { //make sure not to lose the last one
302  EcalRecHit aHit(formerID, ESum, EBTime);
303  EBrechits->push_back( aHit );
304  }
305  }
306 
307  // EE next...
308 
309  // loop over the maps we have, re-making individual hits or digis if necessary.
310  formerID = 0;
311  ESum = 0.;
312  float EETime = 0.;
313 
314  EERecHitMap::const_iterator iEEchk;
315 
316  for(EERecHitMap::const_iterator iEE = EERecHitStorage_.begin();
317  iEE != EERecHitStorage_.end(); ++iEE) {
318 
319  currentID = iEE->first;
320 
321  if (currentID == formerID) { // we have to add these rechits together
322 
323  ESum+=(iEE->second).energy();
324  }
325  else {
326  if(formerID>0) {
327  // cutoff for ESum?
328  EcalRecHit aHit(formerID, ESum, EETime);
329  EErechits->push_back( aHit );
330  }
331  //save pointers for next iteration
332  formerID = currentID;
333  ESum = (iEE->second).energy();
334  EETime = (iEE->second).time(); // take time of first hit in sequence - is this ok?
335  }
336 
337  iEEchk = iEE;
338  if((++iEEchk) == EERecHitStorage_.end()) { //make sure not to lose the last one
339  EcalRecHit aHit(formerID, ESum, EETime);
340  EErechits->push_back( aHit );
341  }
342  }
343 
344  // ES next...
345 
346  // loop over the maps we have, re-making individual hits or digis if necessary.
347  formerID = 0;
348  ESum = 0.;
349  float ESTime = 0.;
350 
351  ESRecHitMap::const_iterator iESchk;
352 
353  for(ESRecHitMap::const_iterator iES = ESRecHitStorage_.begin();
354  iES != ESRecHitStorage_.end(); ++iES) {
355 
356  currentID = iES->first;
357 
358  if (currentID == formerID) { // we have to add these rechits together
359 
360  ESum+=(iES->second).energy();
361  }
362  else {
363  if(formerID>0) {
364  // cutoff for ESum?
365  EcalRecHit aHit(formerID, ESum, ESTime);
366  ESrechits->push_back( aHit );
367  }
368  //save pointers for next iteration
369  formerID = currentID;
370  ESum = (iES->second).energy();
371  ESTime = (iES->second).time(); // take time of first hit in sequence - is this ok?
372  }
373 
374  iESchk = iES;
375  if((++iESchk) == ESRecHitStorage_.end()) { //make sure not to lose the last one
376  EcalRecHit aHit(formerID, ESum, ESTime);
377  ESrechits->push_back( aHit );
378  }
379  }
380 
381  // done merging
382 
383  // put the collection of reconstructed hits in the event
384  LogInfo("DataMixingEMWorker") << "total # EB Merged rechits: " << EBrechits->size() ;
385  LogInfo("DataMixingEMWorker") << "total # EE Merged rechits: " << EErechits->size() ;
386  LogInfo("DataMixingEMWorker") << "total # ES Merged rechits: " << ESrechits->size() ;
387 
388  e.put( EBrechits, EBRecHitCollectionDM_ );
389  e.put( EErechits, EERecHitCollectionDM_ );
390  e.put( ESrechits, ESRecHitCollectionDM_ );
391 
392  // clear local storage after this event
393 
394  EBRecHitStorage_.clear();
395  EERecHitStorage_.clear();
396  ESRecHitStorage_.clear();
397 
398  }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
Definition: DetId.h:20

Member Data Documentation

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

Definition at line 65 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

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

Definition at line 57 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

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

Definition at line 72 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

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

Definition at line 61 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

EBRecHitMap edm::DataMixingEMWorker::EBRecHitStorage_
private

Definition at line 80 of file DataMixingEMWorker.h.

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

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

Definition at line 66 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

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

Definition at line 58 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

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

Definition at line 73 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

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

Definition at line 62 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

EERecHitMap edm::DataMixingEMWorker::EERecHitStorage_
private

Definition at line 81 of file DataMixingEMWorker.h.

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

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

Definition at line 67 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

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

Definition at line 59 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

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

Definition at line 74 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

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

Definition at line 63 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

ESRecHitMap edm::DataMixingEMWorker::ESRecHitStorage_
private

Definition at line 82 of file DataMixingEMWorker.h.

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

std::string edm::DataMixingEMWorker::label_
private
Selector* edm::DataMixingEMWorker::sel_
private

Definition at line 87 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and ~DataMixingEMWorker().