CMS 3D CMS Logo

edm::DataMixingEMWorker Class Reference

#include <SimGeneral/DataMixingModule/plugins/DataMixingEMWorker.h>

List of all members.

Public Member Functions

void addEMPileups (const int bcr, edm::Event *, unsigned int EventId)
void addEMSignals (const edm::Event &e)
 DataMixingEMWorker (const edm::ParameterSet &ps)
 standard constructor
 DataMixingEMWorker ()
void putEM (edm::Event &e)
virtual ~DataMixingEMWorker ()
 Default destructor.

Private Types

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

Private Attributes

edm::InputTag EBProducer_
edm::InputTag EBrechitCollection_
std::string EBRecHitCollectionDM_
EBRecHitMap EBRecHitStorage_
edm::InputTag EEProducer_
edm::InputTag EErechitCollection_
std::string EERecHitCollectionDM_
EERecHitMap EERecHitStorage_
edm::InputTag ESProducer_
edm::InputTag ESrechitCollection_
std::string ESRecHitCollectionDM_
ESRecHitMap ESRecHitStorage_
std::string label_
Selectorsel_


Detailed Description

Definition at line 36 of file DataMixingEMWorker.h.


Member Typedef Documentation

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

Definition at line 67 of file DataMixingEMWorker.h.

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

Definition at line 68 of file DataMixingEMWorker.h.

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

Definition at line 69 of file DataMixingEMWorker.h.


Constructor & Destructor Documentation

DataMixingEMWorker::DataMixingEMWorker (  ) 

Definition at line 27 of file DataMixingEMWorker.cc.

00027 { sel_=0;}

DataMixingEMWorker::DataMixingEMWorker ( const edm::ParameterSet ps  )  [explicit]

standard constructor

Definition at line 30 of file DataMixingEMWorker.cc.

References EBProducer_, EBrechitCollection_, EBRecHitCollectionDM_, EEProducer_, EErechitCollection_, EERecHitCollectionDM_, ESProducer_, ESrechitCollection_, ESRecHitCollectionDM_, edm::ParameterSet::getParameter(), label_, and sel_.

00030                                                                   : 
00031                                                             label_(ps.getParameter<std::string>("Label"))
00032 
00033   {                                                         
00034 
00035     // get the subdetector names
00036     //    this->getSubdetectorNames();  //something like this may be useful to check what we are supposed to do...
00037 
00038     // create input selector
00039     if (label_.size()>0){
00040       sel_=new Selector( ModuleLabelSelector(label_));
00041     }
00042     else {
00043       sel_=new Selector( MatchAllSelector());
00044     }
00045 
00046     // declare the products to produce, retrieve
00047 
00048     EBProducer_ = ps.getParameter<edm::InputTag>("EBProducer");
00049     EEProducer_ = ps.getParameter<edm::InputTag>("EEProducer");
00050     ESProducer_ = ps.getParameter<edm::InputTag>("ESProducer");
00051     EBrechitCollection_ = ps.getParameter<edm::InputTag>("EBrechitCollection");
00052     EErechitCollection_ = ps.getParameter<edm::InputTag>("EErechitCollection");
00053     ESrechitCollection_ = ps.getParameter<edm::InputTag>("ESrechitCollection");
00054     EBRecHitCollectionDM_        = ps.getParameter<std::string>("EBRecHitCollectionDM");
00055     EERecHitCollectionDM_        = ps.getParameter<std::string>("EERecHitCollectionDM");
00056     ESRecHitCollectionDM_        = ps.getParameter<std::string>("ESRecHitCollectionDM");
00057    //   nMaxPrintout_            = ps.getUntrackedParameter<int>("nMaxPrintout",10);
00058 
00059    //EBalgo_ = new EcalRecHitSimpleAlgo();
00060    //EEalgo_ = new EcalRecHitSimpleAlgo();
00061 
00062    // don't think I can "produce" in a sub-class...
00063 
00064    //produces< EBRecHitCollection >(EBRecHitCollectionDM_);
00065    //produces< EERecHitCollection >(EERecHitCollectionDM_);
00066 
00067   }

DataMixingEMWorker::~DataMixingEMWorker (  )  [virtual]

Default destructor.

Definition at line 71 of file DataMixingEMWorker.cc.

00071                                           { 
00072     delete sel_;
00073     sel_=0;
00074   }  


Member Function Documentation

void DataMixingEMWorker::addEMPileups ( const int  bcr,
edm::Event e,
unsigned int  EventId 
)

Definition at line 170 of file DataMixingEMWorker.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), edm::Event::getByLabel(), edm::Event::id(), it, LogDebug, edm::Handle< T >::product(), and edm::SortedCollection< T, SORT >::size().

00170                                                                                      {
00171   
00172     LogInfo("DataMixingEMWorker") <<"\n===============> adding pileups from event  "<<e->id()<<" for bunchcrossing "<<bcr;
00173 
00174     // fill in maps of hits; same code as addSignals, except now applied to the pileup events
00175 
00176     // EB first
00177 
00178    Handle< EBRecHitCollection > pEBRecHits;
00179    const EBRecHitCollection*  EBRecHits = 0;
00180 
00181   
00182    if( e->getByLabel(EBProducer_.label(),EBrechitCollection_.label(), pEBRecHits) ){
00183      EBRecHits = pEBRecHits.product(); // get a ptr to the product
00184 #ifdef DEBUG
00185      LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
00186 #endif
00187    } 
00188    
00189  
00190    if (EBRecHits)
00191      {
00192        // loop over rechits, adding these to the existing maps
00193        for(EBRecHitCollection::const_iterator it  = EBRecHits->begin();
00194            it != EBRecHits->end(); ++it) {
00195 
00196          EBRecHitStorage_.insert(EBRecHitMap::value_type( (it->id()), *it ));
00197          
00198 #ifdef DEBUG     
00199          LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: "
00200                                       << it->id().rawId() << "\n"
00201                                       << " rechit energy: " << it->energy();
00202 #endif
00203        }
00204      }
00205     // EE Next
00206 
00207    Handle< EERecHitCollection > pEERecHits;
00208    const EERecHitCollection*  EERecHits = 0;
00209 
00210    
00211    if( e->getByLabel( EEProducer_.label(),EErechitCollection_.label(), pEERecHits) ){
00212      EERecHits = pEERecHits.product(); // get a ptr to the product
00213 #ifdef DEBUG
00214      LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
00215 #endif
00216    }
00217    
00218  
00219    if (EERecHits)
00220      {
00221        // loop over rechits, adding these to the existing maps
00222        for(EERecHitCollection::const_iterator it  = EERecHits->begin();
00223            it != EERecHits->end(); ++it) {
00224 
00225          EERecHitStorage_.insert(EERecHitMap::value_type( (it->id()), *it ));
00226          
00227 #ifdef DEBUG     
00228          LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: "
00229                                       << it->id().rawId() << "\n"
00230                                       << " rechit energy: " << it->energy();
00231 #endif
00232        }
00233      }
00234     // ES Next
00235 
00236    Handle< ESRecHitCollection > pESRecHits;
00237    const ESRecHitCollection*  ESRecHits = 0;
00238 
00239    
00240    if( e->getByLabel( ESProducer_.label(),ESrechitCollection_.label(), pESRecHits) ){
00241      ESRecHits = pESRecHits.product(); // get a ptr to the product
00242 #ifdef DEBUG
00243      LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
00244 #endif
00245    } 
00246    
00247  
00248    if (ESRecHits)
00249      {
00250        // loop over rechits, adding these to the existing maps
00251        for(ESRecHitCollection::const_iterator it  = ESRecHits->begin();
00252            it != ESRecHits->end(); ++it) {
00253 
00254          ESRecHitStorage_.insert(ESRecHitMap::value_type( (it->id()), *it ));
00255          
00256 #ifdef DEBUG     
00257          LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: "
00258                                       << it->id().rawId() << "\n"
00259                                       << " rechit energy: " << it->energy();
00260 #endif
00261        }
00262      }
00263 
00264   }

void DataMixingEMWorker::addEMSignals ( const edm::Event e  ) 

Definition at line 76 of file DataMixingEMWorker.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), edm::Event::getByLabel(), edm::Event::id(), it, LogDebug, edm::Handle< T >::product(), and edm::SortedCollection< T, SORT >::size().

00076                                                          { 
00077     // fill in maps of hits
00078 
00079     LogInfo("DataMixingEMWorker")<<"===============> adding MC signals for "<<e.id();
00080 
00081     // EB first
00082 
00083    Handle< EBRecHitCollection > pEBRecHits;
00084 
00085    const EBRecHitCollection*  EBRecHits = 0;
00086 
00087    if(e.getByLabel(EBProducer_.label(),EBrechitCollection_.label(), pEBRecHits) ){
00088      EBRecHits = pEBRecHits.product(); // get a ptr to the product
00089      LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
00090    }
00091    
00092  
00093    if (EBRecHits)
00094      {
00095        // loop over rechits, storing them in a map so we can add pileup later
00096        for(EBRecHitCollection::const_iterator it  = EBRecHits->begin(); 
00097            it != EBRecHits->end(); ++it) {
00098 
00099          EBRecHitStorage_.insert(EBRecHitMap::value_type( ( it->id() ), *it ));
00100          
00101          LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: "
00102                                       << it->id().rawId() << "\n"
00103                                       << " rechit energy: " << it->energy();
00104 
00105        }
00106      }
00107 
00108    // EE next
00109 
00110    Handle< EERecHitCollection > pEERecHits;
00111 
00112    const EERecHitCollection*  EERecHits = 0;
00113 
00114    
00115    if(e.getByLabel(EEProducer_.label(),EErechitCollection_.label(), pEERecHits) ){
00116      EERecHits = pEERecHits.product(); // get a ptr to the product
00117      LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
00118    } 
00119    
00120  
00121    if (EERecHits)
00122      {
00123        // loop over rechits, storing them in a map so we can add pileup later
00124        for(EERecHitCollection::const_iterator it  = EERecHits->begin(); 
00125            it != EERecHits->end(); ++it) {
00126 
00127          EERecHitStorage_.insert(EERecHitMap::value_type( ( it->id() ), *it ));
00128 #ifdef DEBUG     
00129          LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: "
00130                                       << it->id().rawId() << "\n"
00131                                       << " rechit energy: " << it->energy();
00132 #endif
00133 
00134        }
00135      }
00136    // ES next
00137 
00138    Handle< ESRecHitCollection > pESRecHits;
00139 
00140    const ESRecHitCollection*  ESRecHits = 0;
00141 
00142    
00143    if(e.getByLabel( ESProducer_.label(),ESrechitCollection_.label(), pESRecHits) ){
00144      ESRecHits = pESRecHits.product(); // get a ptr to the product
00145 #ifdef DEBUG
00146      LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
00147 #endif
00148    } 
00149    
00150  
00151    if (ESRecHits)
00152      {
00153        // loop over rechits, storing them in a map so we can add pileup later
00154        for(ESRecHitCollection::const_iterator it  = ESRecHits->begin(); 
00155            it != ESRecHits->end(); ++it) {
00156 
00157          ESRecHitStorage_.insert(ESRecHitMap::value_type( ( it->id() ), *it ));
00158          
00159 #ifdef DEBUG     
00160          LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: "
00161                                       << it->id().rawId() << "\n"
00162                                       << " rechit energy: " << it->energy();
00163 #endif
00164 
00165        }
00166      }
00167     
00168   } // end of addEMSignals

void DataMixingEMWorker::putEM ( edm::Event e  ) 

Definition at line 266 of file DataMixingEMWorker.cc.

References relval_parameters_module::energy, and edm::Event::put().

00266                                             {
00267 
00268     // collection of rechits to put in the event
00269     std::auto_ptr< EBRecHitCollection > EBrechits( new EBRecHitCollection );
00270     std::auto_ptr< EERecHitCollection > EErechits( new EERecHitCollection );
00271     std::auto_ptr< ESRecHitCollection > ESrechits( new ESRecHitCollection );
00272 
00273     // loop over the maps we have, re-making individual hits or digis if necessary.
00274     DetId formerID = 0;
00275     DetId currentID;
00276     float ESum = 0.;
00277     float EBTime = 0.;
00278     EcalRecHit OldHit;
00279     int nmatch=0;
00280 
00281     // EB first...
00282 
00283     EBRecHitMap::const_iterator iEBchk;
00284 
00285     for(EBRecHitMap::const_iterator iEB  = EBRecHitStorage_.begin();
00286         iEB != EBRecHitStorage_.end(); ++iEB) {
00287 
00288       currentID = iEB->first; 
00289 
00290       if (currentID == formerID) { // we have to add these rechits together
00291         nmatch++;                  // use this to avoid using the "count" function
00292         ESum+=(iEB->second).energy();          // on every element...
00293 
00294         iEBchk = iEB;
00295         if((iEBchk++) == EBRecHitStorage_.end()) {  //make sure not to lose the last one
00296           EcalRecHit aHit(formerID, ESum, EBTime);
00297           EBrechits->push_back( aHit );   
00298           // reset energy sum, nmatch
00299           ESum = 0 ;
00300           nmatch=0;       
00301         }
00302       }
00303       else {
00304         if(nmatch>0) {
00305           EcalRecHit aHit(formerID, ESum, EBTime);
00306           EBrechits->push_back( aHit );   
00307           // reset energy sum, nmatch
00308           ESum = 0 ;
00309           nmatch=0;       
00310         }
00311         else {
00312           if(formerID>0) EBrechits->push_back( OldHit );
00313         }
00314         
00315         iEBchk = iEB;
00316         if((iEBchk++) == EBRecHitStorage_.end()) {  //make sure not to lose the last one
00317           EBrechits->push_back( iEB->second );
00318         }
00319 
00320         // save pointers for next iteration
00321         OldHit = iEB->second;
00322         formerID = currentID;
00323         ESum = (iEB->second).energy();
00324         EBTime = (iEB->second).time();  // take time of first hit in sequence - is this ok?
00325       }
00326     }
00327 
00328     // EE next...
00329 
00330     // loop over the maps we have, re-making individual hits or digis if necessary.
00331     formerID = 0;
00332     ESum = 0.;
00333     float EETime = 0.;
00334     
00335     nmatch=0;
00336 
00337     EERecHitMap::const_iterator iEEchk;
00338 
00339     for(EERecHitMap::const_iterator iEE  = EERecHitStorage_.begin();
00340         iEE != EERecHitStorage_.end(); ++iEE) {
00341 
00342       currentID = iEE->first; 
00343 
00344       if (currentID == formerID) { // we have to add these rechits together
00345         nmatch++;                  // use this to avoid using the "count" function
00346         ESum+=(iEE->second).energy();          // on every element...
00347 
00348         iEEchk = iEE;
00349         if((iEEchk++) == EERecHitStorage_.end()) {  //make sure not to lose the last one
00350           EcalRecHit aHit(formerID, ESum, EETime);
00351           EErechits->push_back( aHit );   
00352           // reset energy sum, nmatch
00353           ESum = 0 ;
00354           nmatch=0;       
00355         }
00356       }
00357       else {
00358         if(nmatch>0) {
00359           EcalRecHit aHit(formerID, ESum, EETime);
00360           EErechits->push_back( aHit );   
00361           // reset energy sum, nmatch
00362           ESum = 0 ;
00363           nmatch=0;       
00364         }
00365         else {
00366           if(formerID>0) EErechits->push_back( OldHit );
00367         }
00368         
00369         iEEchk = iEE;
00370         if((iEEchk++) == EERecHitStorage_.end()) {  //make sure not to lose the last one
00371           EErechits->push_back( iEE->second );
00372         }
00373 
00374         // save pointers for next iteration
00375         OldHit = iEE->second;
00376         formerID = currentID;
00377         ESum = (iEE->second).energy();
00378         EETime = (iEE->second).time();  // take time of first hit in sequence - is this ok?
00379       }
00380     }
00381 
00382     // ES next...
00383 
00384     // loop over the maps we have, re-making individual hits or digis if necessary.
00385     formerID = 0;
00386     ESum = 0.;
00387     float ESTime = 0.;
00388     nmatch=0;
00389 
00390     ESRecHitMap::const_iterator iESchk;
00391 
00392     for(ESRecHitMap::const_iterator iES  = ESRecHitStorage_.begin();
00393         iES != ESRecHitStorage_.end(); ++iES) {
00394 
00395       currentID = iES->first; 
00396 
00397       if (currentID == formerID) { // we have to add these rechits together
00398         nmatch++;                  // use this to avoid using the "count" function
00399         ESum+=(iES->second).energy();          // on every element...
00400 
00401         iESchk = iES;
00402         if((iESchk++) == ESRecHitStorage_.end()) {  //make sure not to lose the last one
00403           EcalRecHit aHit(formerID, ESum, ESTime);
00404           ESrechits->push_back( aHit );   
00405           // reset energy sum, nmatch
00406           ESum = 0 ;
00407           nmatch=0;       
00408         }
00409       }
00410       else {
00411         if(nmatch>0) {
00412           EcalRecHit aHit(formerID, ESum, ESTime);
00413           ESrechits->push_back( aHit );   
00414           // reset energy sum, nmatch
00415           ESum = 0 ;
00416           nmatch=0;       
00417         }
00418         else {
00419           if(formerID>0) ESrechits->push_back( OldHit );
00420         }
00421         
00422         iESchk = iES;
00423         if((iESchk++) == ESRecHitStorage_.end()) {  //make sure not to lose the last one
00424           ESrechits->push_back( iES->second );
00425         }
00426 
00427         // save pointers for next iteration
00428         OldHit = iES->second;
00429         formerID = currentID;
00430         ESum = (iES->second).energy();
00431         ESTime = (iES->second).time();  // take time of first hit in sequence - is this ok?
00432       }
00433     }
00434 
00435     // put the collection of reconstructed hits in the event   
00436     LogInfo("DataMixingEMWorker") << "total # EB Merged rechits: " << EBrechits->size() ;
00437     LogInfo("DataMixingEMWorker") << "total # EE Merged rechits: " << EErechits->size() ;
00438     LogInfo("DataMixingEMWorker") << "total # ES Merged rechits: " << ESrechits->size() ;
00439 
00440     e.put( EBrechits, EBRecHitCollectionDM_ );
00441     e.put( EErechits, EERecHitCollectionDM_ );
00442     e.put( ESrechits, ESRecHitCollectionDM_ );
00443     
00444     // clear local storage after this event
00445 
00446     EBRecHitStorage_.clear();
00447     EERecHitStorage_.clear();
00448     ESRecHitStorage_.clear();
00449 
00450   }


Member Data Documentation

edm::InputTag edm::DataMixingEMWorker::EBProducer_ [private]

Definition at line 56 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::EBrechitCollection_ [private]

Definition at line 60 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

std::string edm::DataMixingEMWorker::EBRecHitCollectionDM_ [private]

Definition at line 63 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

EBRecHitMap edm::DataMixingEMWorker::EBRecHitStorage_ [private]

Definition at line 71 of file DataMixingEMWorker.h.

edm::InputTag edm::DataMixingEMWorker::EEProducer_ [private]

Definition at line 57 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::EErechitCollection_ [private]

Definition at line 61 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

std::string edm::DataMixingEMWorker::EERecHitCollectionDM_ [private]

Definition at line 64 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

EERecHitMap edm::DataMixingEMWorker::EERecHitStorage_ [private]

Definition at line 72 of file DataMixingEMWorker.h.

edm::InputTag edm::DataMixingEMWorker::ESProducer_ [private]

Definition at line 58 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

edm::InputTag edm::DataMixingEMWorker::ESrechitCollection_ [private]

Definition at line 62 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

std::string edm::DataMixingEMWorker::ESRecHitCollectionDM_ [private]

Definition at line 65 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

ESRecHitMap edm::DataMixingEMWorker::ESRecHitStorage_ [private]

Definition at line 73 of file DataMixingEMWorker.h.

std::string edm::DataMixingEMWorker::label_ [private]

Definition at line 79 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

Selector* edm::DataMixingEMWorker::sel_ [private]

Definition at line 78 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:40:03 2009 for CMSSW by  doxygen 1.5.4