CMS 3D CMS Logo

Classes | Public Member Functions | Private Types | Private Attributes

edm::DataMixingSiStripWorker Class Reference

#include <DataMixingSiStripWorker.h>

List of all members.

Classes

class  StrictWeakOrdering

Public Member Functions

void addSiStripPileups (const int bcr, edm::EventPrincipal *, unsigned int EventId)
void addSiStripSignals (const edm::Event &e)
 DataMixingSiStripWorker (const edm::ParameterSet &ps)
 DataMixingSiStripWorker ()
void putSiStrip (edm::Event &e)
virtual ~DataMixingSiStripWorker ()

Private Types

typedef std::vector< SiStripDigiOneDetectorMap
typedef std::map< uint32_t,
OneDetectorMap
SiGlobalIndex

Private Attributes

std::string label_
Selectorsel_
SiGlobalIndex SiHitStorage_
std::string SiStripDigiCollectionDM_
edm::InputTag SistripLabelSig_
edm::InputTag SiStripPileInputTag_

Detailed Description

Definition at line 36 of file DataMixingSiStripWorker.h.


Member Typedef Documentation

Definition at line 62 of file DataMixingSiStripWorker.h.

typedef std::map<uint32_t, OneDetectorMap> edm::DataMixingSiStripWorker::SiGlobalIndex [private]

Definition at line 63 of file DataMixingSiStripWorker.h.


Constructor & Destructor Documentation

DataMixingSiStripWorker::DataMixingSiStripWorker ( )

Definition at line 26 of file DataMixingSiStripWorker.cc.

{ sel_=0;}
DataMixingSiStripWorker::DataMixingSiStripWorker ( const edm::ParameterSet ps) [explicit]

standard constructor

Definition at line 29 of file DataMixingSiStripWorker.cc.

References edm::ParameterSet::getParameter(), label_, sel_, SiHitStorage_, SiStripDigiCollectionDM_, SistripLabelSig_, and SiStripPileInputTag_.

                                                                            : 
                                                            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

    SistripLabelSig_   = ps.getParameter<edm::InputTag>("SistripLabelSig");
    SiStripPileInputTag_ = ps.getParameter<edm::InputTag>("SiStripPileInputTag");

    SiStripDigiCollectionDM_  = ps.getParameter<std::string>("SiStripDigiCollectionDM");

    // clear local storage for this event                                                                     
    SiHitStorage_.clear();

  }
DataMixingSiStripWorker::~DataMixingSiStripWorker ( ) [virtual]

Default destructor

Definition at line 59 of file DataMixingSiStripWorker.cc.

References sel_.

                                                    { 
    delete sel_;
    sel_=0;
  }  

Member Function Documentation

void DataMixingSiStripWorker::addSiStripPileups ( const int  bcr,
edm::EventPrincipal ep,
unsigned int  EventId 
)

Definition at line 94 of file DataMixingSiStripWorker.cc.

References edm::DetSetVector< T >::begin(), begin, end, edm::DetSetVector< T >::end(), edm::EventPrincipal::id(), collect_tpl::input, edm::DetSetVector< T >::insert(), LogDebug, SiHitStorage_, and SiStripPileInputTag_.

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

                                                                                                         {
    LogDebug("DataMixingSiStripWorker") <<"\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

    boost::shared_ptr<Wrapper<edm::DetSetVector<SiStripDigi> >  const> inputPTR =
      getProductByTag<edm::DetSetVector<SiStripDigi> >(*ep, SiStripPileInputTag_ );

    if(inputPTR ) {

      const edm::DetSetVector<SiStripDigi>  *input = const_cast< edm::DetSetVector<SiStripDigi> * >(inputPTR->product());

      // Handle< edm::DetSetVector<SiStripDigi> >  input;

      // if( e->getByLabel(Sistripdigi_collectionPile_.label(),SistripLabelPile_.label(),input) ) {

      OneDetectorMap LocalMap;

      //loop on all detsets (detectorIDs) inside the input collection
      edm::DetSetVector<SiStripDigi>::const_iterator DSViter=input->begin();
      for (; DSViter!=input->end();DSViter++){

#ifdef DEBUG
        LogDebug("DataMixingSiStripWorker")  << "Pileups: Processing DetID " << DSViter->id;
#endif

        // find correct local map (or new one) for this detector ID

        SiGlobalIndex::const_iterator itest;

        itest = SiHitStorage_.find(DSViter->id);

        if(itest!=SiHitStorage_.end()) {  // this detID already has hits, add to existing map

          LocalMap = itest->second;

          // fill in local map with extra channels
          LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());
          std::stable_sort(LocalMap.begin(),LocalMap.end(),DataMixingSiStripWorker::StrictWeakOrdering());
          SiHitStorage_[DSViter->id]=LocalMap;
          
        }
        else{ // fill local storage with this information, put in global collection

          LocalMap.clear();
          LocalMap.reserve((DSViter->data).size());
          LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());

          SiHitStorage_.insert( SiGlobalIndex::value_type( DSViter->id, LocalMap ) );
        }
      }
    }
  }
void DataMixingSiStripWorker::addSiStripSignals ( const edm::Event e)

Definition at line 66 of file DataMixingSiStripWorker.cc.

References begin, end, edm::Event::getByLabel(), collect_tpl::input, edm::DetSetVector< T >::insert(), LogDebug, SiHitStorage_, and SistripLabelSig_.

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

                                                                   { 
    // fill in maps of hits

    Handle< edm::DetSetVector<SiStripDigi> >  input;

    if( e.getByLabel(SistripLabelSig_,input) ) {
      OneDetectorMap LocalMap;

      //loop on all detsets (detectorIDs) inside the input collection
      edm::DetSetVector<SiStripDigi>::const_iterator DSViter=input->begin();
      for (; DSViter!=input->end();DSViter++){

#ifdef DEBUG
        LogDebug("DataMixingSiStripWorker")  << "Processing DetID " << DSViter->id;
#endif

        LocalMap.clear();
        LocalMap.reserve((DSViter->data).size());
        LocalMap.insert(LocalMap.end(),(DSViter->data).begin(),(DSViter->data).end());  
        
        SiHitStorage_.insert( SiGlobalIndex::value_type( DSViter->id, LocalMap ) );
      }
 
    }
  } // end of addSiStripSignals
void DataMixingSiStripWorker::putSiStrip ( edm::Event e)

Definition at line 150 of file DataMixingSiStripWorker.cc.

References edm::DetSet< T >::push_back(), edm::Event::put(), SiHitStorage_, and SiStripDigiCollectionDM_.

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

                                                      {

    // collection of Digis to put in the event
    std::vector< edm::DetSet<SiStripDigi> > vSiStripDigi;

    // loop through our collection of detectors, merging hits and putting new ones in the output

    // big loop over Detector IDs:

    for(SiGlobalIndex::const_iterator IDet = SiHitStorage_.begin();
        IDet != SiHitStorage_.end(); IDet++) {

      edm::DetSet<SiStripDigi> SSD(IDet->first); // Make empty collection with this detector ID
        
      OneDetectorMap LocalMap = IDet->second;

      //counter variables
      int formerStrip = -1;
      int currentStrip;
      int ADCSum = 0;

      OneDetectorMap::const_iterator iLocalchk;
      OneDetectorMap::const_iterator iLocal  = LocalMap.begin();
      for(;iLocal != LocalMap.end(); ++iLocal) {

        currentStrip = iLocal->strip(); 

        if (currentStrip == formerStrip) { // we have to add these digis together
          ADCSum+=iLocal->adc();          // on every element...
        }
        else{
          if(formerStrip!=-1){
            if (ADCSum > 511) ADCSum = 255;
            else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
            SiStripDigi aHit(formerStrip, ADCSum);
            SSD.push_back( aHit );        
          }
          // save pointers for next iteration
          formerStrip = currentStrip;
          ADCSum = iLocal->adc();
        }

        iLocalchk = iLocal;
        if((++iLocalchk) == LocalMap.end()) {  //make sure not to lose the last one
          if (ADCSum > 511) ADCSum = 255;
          else if (ADCSum > 253 && ADCSum < 512) ADCSum = 254;
          SSD.push_back( SiStripDigi(formerStrip, ADCSum) );      
        } // end of loop over one detector
        
      }
      // stick this into the global vector of detector info
      vSiStripDigi.push_back(SSD);

    } // end of big loop over all detector IDs

    // put the collection of digis in the event   
    LogInfo("DataMixingSiStripWorker") << "total # Merged strips: " << vSiStripDigi.size() ;

    // make new digi collection
    
    std::auto_ptr< edm::DetSetVector<SiStripDigi> > MySiStripDigis(new edm::DetSetVector<SiStripDigi>(vSiStripDigi) );

    // put collection

    e.put( MySiStripDigis, SiStripDigiCollectionDM_ );

    // clear local storage for this event
    SiHitStorage_.clear();
  }

Member Data Documentation

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

Definition at line 71 of file DataMixingSiStripWorker.h.

Referenced by DataMixingSiStripWorker().

Definition at line 70 of file DataMixingSiStripWorker.h.

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

Definition at line 58 of file DataMixingSiStripWorker.h.

Referenced by DataMixingSiStripWorker(), and putSiStrip().

Definition at line 56 of file DataMixingSiStripWorker.h.

Referenced by addSiStripSignals(), and DataMixingSiStripWorker().

Definition at line 57 of file DataMixingSiStripWorker.h.

Referenced by addSiStripPileups(), and DataMixingSiStripWorker().