CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

edm::DataMixingEMWorker Class Reference

#include <DataMixingEMWorker.h>

List of all members.

Public Member Functions

void addEMPileups (const int bcr, edm::EventPrincipal *, unsigned int EventId)
void addEMSignals (const edm::Event &e)
 DataMixingEMWorker (const edm::ParameterSet &ps)
 DataMixingEMWorker ()
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.

{ 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_.

                                                                  : 
                                                            label_(ps.getParameter<std::string>("Label"))

  {                                                         

    // get the subdetector names
    //    this->getSubdetectorNames();  //something like this may be useful to check what we are supposed to do...

    // create input selector
    if (label_.size()>0){
      sel_=new Selector( ModuleLabelSelector(label_));
    }
    else {
      sel_=new Selector( MatchAllSelector());
    }

    // declare the products to produce, retrieve

    EBProducerSig_ = ps.getParameter<edm::InputTag>("EBProducerSig");
    EEProducerSig_ = ps.getParameter<edm::InputTag>("EEProducerSig");
    ESProducerSig_ = ps.getParameter<edm::InputTag>("ESProducerSig");


    EBrechitCollectionSig_ = ps.getParameter<edm::InputTag>("EBrechitCollectionSig");
    EErechitCollectionSig_ = ps.getParameter<edm::InputTag>("EErechitCollectionSig");
    ESrechitCollectionSig_ = ps.getParameter<edm::InputTag>("ESrechitCollectionSig");

    EBPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("EBPileRecHitInputTag");
    EEPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("EEPileRecHitInputTag");
    ESPileRecHitInputTag_ = ps.getParameter<edm::InputTag>("ESPileRecHitInputTag");


    EBRecHitCollectionDM_        = ps.getParameter<std::string>("EBRecHitCollectionDM");
    EERecHitCollectionDM_        = ps.getParameter<std::string>("EERecHitCollectionDM");
    ESRecHitCollectionDM_        = ps.getParameter<std::string>("ESRecHitCollectionDM");
   //   nMaxPrintout_            = ps.getUntrackedParameter<int>("nMaxPrintout",10);

   //EBalgo_ = new EcalRecHitSimpleAlgo();
   //EEalgo_ = new EcalRecHitSimpleAlgo();

   // don't think I can "produce" in a sub-class...

   //produces< EBRecHitCollection >(EBRecHitCollectionDM_);
   //produces< EERecHitCollection >(EERecHitCollectionDM_);

  }
DataMixingEMWorker::~DataMixingEMWorker ( ) [virtual]

Default destructor

Definition at line 79 of file DataMixingEMWorker.cc.

References sel_.

                                          { 
    delete sel_;
    sel_=0;
  }  

Member Function Documentation

void DataMixingEMWorker::addEMPileups ( const int  bcr,
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::addPileups().

                                                                                               {
  
    LogInfo("DataMixingEMWorker") <<"\n===============> adding pileups from event  "<<ep->id()<<" for bunchcrossing "<<bcr;

    // fill in maps of hits; same code as addSignals, except now applied to the pileup events

    // EB first

    boost::shared_ptr<Wrapper<EBRecHitCollection>  const> EBRecHitsPTR =
      getProductByTag<EBRecHitCollection>(*ep, EBPileRecHitInputTag_ );

    if(EBRecHitsPTR ) {

      const EBRecHitCollection*  EBRecHits = const_cast< EBRecHitCollection * >(EBRecHitsPTR->product());

      LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();

      // loop over digis, adding these to the existing maps                                         
      for(EBRecHitCollection::const_iterator it  = EBRecHits->begin();
          it != EBRecHits->end(); ++it) {

        EBRecHitStorage_.insert(EBRecHitMap::value_type( (it->id()), *it ));

#ifdef DEBUG
        LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: "
                                           << it->id().rawId() << "\n"
                                           << " rechit energy: " << it->energy();
#endif
      }
    }

    // EE Next

    boost::shared_ptr<Wrapper<EERecHitCollection>  const> EERecHitsPTR =
      getProductByTag<EERecHitCollection>(*ep, EEPileRecHitInputTag_ );

    if(EERecHitsPTR ) {

      const EERecHitCollection*  EERecHits = const_cast< EERecHitCollection * >(EERecHitsPTR->product());

      LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();

      // loop over digis, adding these to the existing maps                                         
      for(EERecHitCollection::const_iterator it  = EERecHits->begin();
          it != EERecHits->end(); ++it) {

        EERecHitStorage_.insert(EERecHitMap::value_type( (it->id()), *it ));

#ifdef DEBUG
        LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: "
                                       << it->id().rawId() << "\n"
                                       << " rechit energy: " << it->energy();
#endif
      }
    }

    // ES Next

    boost::shared_ptr<Wrapper<ESRecHitCollection>  const> ESRecHitsPTR =
      getProductByTag<ESRecHitCollection>(*ep, ESPileRecHitInputTag_ );

    if(ESRecHitsPTR ) {

      const ESRecHitCollection*  ESRecHits = const_cast< ESRecHitCollection * >(ESRecHitsPTR->product());

      LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();

      // loop over digis, adding these to the existing maps                                         
      for(ESRecHitCollection::const_iterator it  = ESRecHits->begin();
          it != ESRecHits->end(); ++it) {

        ESRecHitStorage_.insert(ESRecHitMap::value_type( (it->id()), *it ));

#ifdef DEBUG
        LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: "
                                       << it->id().rawId() << "\n"
                                       << " rechit energy: " << it->energy();
#endif
      }
    }


  }
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().

                                                         { 
    // fill in maps of hits

    LogInfo("DataMixingEMWorker")<<"===============> adding MC signals for "<<e.id();

    // EB first

   Handle< EBRecHitCollection > pEBRecHits;

   const EBRecHitCollection*  EBRecHits = 0;

   if(e.getByLabel(EBProducerSig_, pEBRecHits) ){
     EBRecHits = pEBRecHits.product(); // get a ptr to the product
     LogDebug("DataMixingEMWorker") << "total # EB rechits: " << EBRecHits->size();
   }
   
 
   if (EBRecHits)
     {
       // loop over rechits, storing them in a map so we can add pileup later
       for(EBRecHitCollection::const_iterator it  = EBRecHits->begin(); 
           it != EBRecHits->end(); ++it) {

         EBRecHitStorage_.insert(EBRecHitMap::value_type( ( it->id() ), *it ));
         
         LogDebug("DataMixingEMWorker") << "processed EBRecHit with rawId: "
                                      << it->id().rawId() << "\n"
                                      << " rechit energy: " << it->energy();

       }
     }

   // EE next

   Handle< EERecHitCollection > pEERecHits;

   const EERecHitCollection*  EERecHits = 0;

   
   if(e.getByLabel(EEProducerSig_, pEERecHits) ){
     EERecHits = pEERecHits.product(); // get a ptr to the product
     LogDebug("DataMixingEMWorker") << "total # EE rechits: " << EERecHits->size();
   } 
   
 
   if (EERecHits)
     {
       // loop over rechits, storing them in a map so we can add pileup later
       for(EERecHitCollection::const_iterator it  = EERecHits->begin(); 
           it != EERecHits->end(); ++it) {

         EERecHitStorage_.insert(EERecHitMap::value_type( ( it->id() ), *it ));
#ifdef DEBUG     
         LogDebug("DataMixingEMWorker") << "processed EERecHit with rawId: "
                                      << it->id().rawId() << "\n"
                                      << " rechit energy: " << it->energy();
#endif

       }
     }
   // ES next

   Handle< ESRecHitCollection > pESRecHits;

   const ESRecHitCollection*  ESRecHits = 0;

   
   if(e.getByLabel( ESProducerSig_, pESRecHits) ){
     ESRecHits = pESRecHits.product(); // get a ptr to the product
#ifdef DEBUG
     LogDebug("DataMixingEMWorker") << "total # ES rechits: " << ESRecHits->size();
#endif
   } 
   
 
   if (ESRecHits)
     {
       // loop over rechits, storing them in a map so we can add pileup later
       for(ESRecHitCollection::const_iterator it  = ESRecHits->begin(); 
           it != ESRecHits->end(); ++it) {

         ESRecHitStorage_.insert(ESRecHitMap::value_type( ( it->id() ), *it ));
         
#ifdef DEBUG     
         LogDebug("DataMixingEMWorker") << "processed ESRecHit with rawId: "
                                      << it->id().rawId() << "\n"
                                      << " rechit energy: " << it->energy();
#endif

       }
     }
    
  } // end of addEMSignals
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().

                                            {

    // collection of rechits to put in the event
    std::auto_ptr< EBRecHitCollection > EBrechits( new EBRecHitCollection );
    std::auto_ptr< EERecHitCollection > EErechits( new EERecHitCollection );
    std::auto_ptr< ESRecHitCollection > ESrechits( new ESRecHitCollection );

    // loop over the maps we have, re-making individual hits or digis if necessary.
    DetId formerID = 0;
    DetId currentID;
    float ESum = 0.;
    float EBTime = 0.;

    // EB first...

    EBRecHitMap::const_iterator iEBchk;

    for(EBRecHitMap::const_iterator iEB  = EBRecHitStorage_.begin();
        iEB != EBRecHitStorage_.end(); ++iEB) {

      currentID = iEB->first; 

      if (currentID == formerID) { // we have to add these rechits together

        ESum+=(iEB->second).energy(); 
      }
      else {
          if(formerID>0) {
            // cutoff for ESum?
            EcalRecHit aHit(formerID, ESum, EBTime);
            EBrechits->push_back( aHit );
          }
          //save pointers for next iteration
          formerID = currentID;
          ESum = (iEB->second).energy();
          EBTime = (iEB->second).time();  // take time of first hit in sequence - is this ok?
      }

      iEBchk = iEB;
      if((++iEBchk) == EBRecHitStorage_.end()) {  //make sure not to lose the last one
        EcalRecHit aHit(formerID, ESum, EBTime);
        EBrechits->push_back( aHit );     
      }
    }

    // EE next...

    // loop over the maps we have, re-making individual hits or digis if necessary.
    formerID = 0;
    ESum = 0.;
    float EETime = 0.;
    
    EERecHitMap::const_iterator iEEchk;

    for(EERecHitMap::const_iterator iEE  = EERecHitStorage_.begin();
        iEE != EERecHitStorage_.end(); ++iEE) {

      currentID = iEE->first; 

      if (currentID == formerID) { // we have to add these rechits together

        ESum+=(iEE->second).energy(); 
      }
      else {
          if(formerID>0) {
            // cutoff for ESum?
            EcalRecHit aHit(formerID, ESum, EETime);
            EErechits->push_back( aHit );
          }
          //save pointers for next iteration
          formerID = currentID;
          ESum = (iEE->second).energy();
          EETime = (iEE->second).time();  // take time of first hit in sequence - is this ok?
      }

      iEEchk = iEE;
      if((++iEEchk) == EERecHitStorage_.end()) {  //make sure not to lose the last one
        EcalRecHit aHit(formerID, ESum, EETime);
        EErechits->push_back( aHit );     
      }
    }

    // ES next...

    // loop over the maps we have, re-making individual hits or digis if necessary.
    formerID = 0;
    ESum = 0.;
    float ESTime = 0.;

    ESRecHitMap::const_iterator iESchk;

    for(ESRecHitMap::const_iterator iES  = ESRecHitStorage_.begin();
        iES != ESRecHitStorage_.end(); ++iES) {

      currentID = iES->first; 

      if (currentID == formerID) { // we have to add these rechits together

        ESum+=(iES->second).energy(); 
      }
      else {
          if(formerID>0) {
            // cutoff for ESum?
            EcalRecHit aHit(formerID, ESum, ESTime);
            ESrechits->push_back( aHit );
          }
          //save pointers for next iteration
          formerID = currentID;
          ESum = (iES->second).energy();
          ESTime = (iES->second).time();  // take time of first hit in sequence - is this ok?
      }

      iESchk = iES;
      if((++iESchk) == ESRecHitStorage_.end()) {  //make sure not to lose the last one
        EcalRecHit aHit(formerID, ESum, ESTime);
        ESrechits->push_back( aHit );     
      }
    }

    // done merging

    // put the collection of reconstructed hits in the event   
    LogInfo("DataMixingEMWorker") << "total # EB Merged rechits: " << EBrechits->size() ;
    LogInfo("DataMixingEMWorker") << "total # EE Merged rechits: " << EErechits->size() ;
    LogInfo("DataMixingEMWorker") << "total # ES Merged rechits: " << ESrechits->size() ;

    e.put( EBrechits, EBRecHitCollectionDM_ );
    e.put( EErechits, EERecHitCollectionDM_ );
    e.put( ESrechits, ESRecHitCollectionDM_ );
    
    // clear local storage after this event

    EBRecHitStorage_.clear();
    EERecHitStorage_.clear();
    ESRecHitStorage_.clear();

  }

Member Data Documentation

Definition at line 65 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

Definition at line 57 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

Definition at line 72 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

Definition at line 61 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

Definition at line 80 of file DataMixingEMWorker.h.

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

Definition at line 66 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

Definition at line 58 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

Definition at line 73 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

Definition at line 62 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

Definition at line 81 of file DataMixingEMWorker.h.

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

Definition at line 67 of file DataMixingEMWorker.h.

Referenced by addEMPileups(), and DataMixingEMWorker().

Definition at line 59 of file DataMixingEMWorker.h.

Referenced by addEMSignals(), and DataMixingEMWorker().

Definition at line 74 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker(), and putEM().

Definition at line 63 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

Definition at line 82 of file DataMixingEMWorker.h.

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

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

Definition at line 88 of file DataMixingEMWorker.h.

Referenced by DataMixingEMWorker().

Definition at line 87 of file DataMixingEMWorker.h.

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