CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripMeanCMExtractor Class Reference

#include <RecoLocalTracker/SiStripMeanCMExtractor/src/SiStripMeanCMExtractor.cc>

Inheritance diagram for SiStripMeanCMExtractor:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 SiStripMeanCMExtractor (const edm::ParameterSet &)
 ~SiStripMeanCMExtractor ()

Private Member Functions

virtual void beginJob ()
void CMExtractorFromPedestals (const edm::DetSetVector< SiStripRawDigi > &, std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
void ConvertMeanMapToDetSetVector (std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
virtual void endJob ()
void init (const edm::EventSetup &)
virtual void produce (edm::Event &, const edm::EventSetup &)
void StoreMean (const edm::DetSetVector< SiStripProcessedRawDigi > &)

Private Attributes

uint16_t _actualEvent
std::string _Algorithm
CMMap _CMMap
edm::InputTag _inputTag
uint16_t _nEventsToUse
uint32_t pedestal_cache_id_
edm::ESHandle< SiStripPedestalspedestalHandle_

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 54 of file SiStripMeanCMExtractor.cc.


Constructor & Destructor Documentation

SiStripMeanCMExtractor::SiStripMeanCMExtractor ( const edm::ParameterSet conf) [explicit]

Definition at line 81 of file SiStripMeanCMExtractor.cc.

References _nEventsToUse.

                                                                          : 
     _inputTag(conf.getParameter<edm::InputTag> ("CMCollection")),
        _Algorithm(conf.getParameter<std::string>("Algorithm")),
        _nEventsToUse(conf.getParameter<uint32_t>("NEvents"))
{

         
    if(_nEventsToUse < 1) _nEventsToUse=1;
        produces< edm::DetSetVector<SiStripProcessedRawDigi> > ("MEANAPVCM"); 
}
SiStripMeanCMExtractor::~SiStripMeanCMExtractor ( )

Definition at line 93 of file SiStripMeanCMExtractor.cc.

{
 
}

Member Function Documentation

void SiStripMeanCMExtractor::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 212 of file SiStripMeanCMExtractor.cc.

References _actualEvent, and _CMMap.

{
        _actualEvent =1;
                
        _CMMap.clear();
        
}
void SiStripMeanCMExtractor::CMExtractorFromPedestals ( const edm::DetSetVector< SiStripRawDigi > &  input,
std::vector< edm::DetSet< SiStripProcessedRawDigi > > &  meancm 
) [private]

Definition at line 145 of file SiStripMeanCMExtractor.cc.

References sistrip::APV, edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), pedestalHandle_, edm::DetSet< T >::push_back(), and strip().

Referenced by produce().

                                                                                                                                                         {
        meancm.clear();
        meancm.reserve(15000);    
        
         for ( edm::DetSetVector<SiStripRawDigi>::const_iterator 
          rawDigis = input.begin(); rawDigis != input.end(); rawDigis++) {
         SiStripPedestals::Range detPedestalRange = pedestalHandle_->getRange(rawDigis->id);
                 edm::DetSet<SiStripProcessedRawDigi> MeanCMDetSet(rawDigis->id);
                
                for(uint16_t APV = 0; APV < rawDigis->size()/128; ++APV){
                        uint16_t MinPed =0;
                        for(uint16_t strip = APV*128; strip< (APV+1)*128; ++strip){
                          uint16_t ped =  (uint16_t)pedestalHandle_->getPed(strip,detPedestalRange);
                          if(ped < MinPed) MinPed = ped;
                        }
                        if(MinPed>128) MinPed=128;
                        MeanCMDetSet.push_back(MinPed);
                }
                
                meancm.push_back(MeanCMDetSet); 
        }
}
void SiStripMeanCMExtractor::ConvertMeanMapToDetSetVector ( std::vector< edm::DetSet< SiStripProcessedRawDigi > > &  meancm) [private]

Definition at line 197 of file SiStripMeanCMExtractor.cc.

References _actualEvent, _CMMap, end, and edm::DetSet< T >::push_back().

Referenced by produce().

                                                                                                          {
        CMMap::iterator itMap;
        std::vector<float>::const_iterator itMapVector;
        
        meancm.clear();
        meancm.reserve(15000);    
        
    for(itMap = _CMMap.begin(); itMap != _CMMap.end(); ++itMap){
       edm::DetSet<SiStripProcessedRawDigi> MeanCMDetSet(itMap->first);
           for(itMapVector = (itMap->second).begin(); itMapVector != (itMap->second).end(); ++itMapVector) MeanCMDetSet.push_back(*itMapVector/(float)_actualEvent);
           meancm.push_back(MeanCMDetSet);      
        }       
    
}
void SiStripMeanCMExtractor::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 221 of file SiStripMeanCMExtractor.cc.

                               {
    
           
}
void SiStripMeanCMExtractor::init ( const edm::EventSetup es) [private]

Definition at line 98 of file SiStripMeanCMExtractor.cc.

References edm::EventSetup::get(), pedestal_cache_id_, and pedestalHandle_.

Referenced by produce().

                                                        {
     
        uint32_t p_cache_id = es.get<SiStripPedestalsRcd>().cacheIdentifier();
        
        if(p_cache_id != pedestal_cache_id_) {
                es.get<SiStripPedestalsRcd>().get( pedestalHandle_ );
                pedestal_cache_id_ = p_cache_id;
        }
}
void SiStripMeanCMExtractor::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 110 of file SiStripMeanCMExtractor.cc.

References _actualEvent, _Algorithm, _inputTag, CMExtractorFromPedestals(), ConvertMeanMapToDetSetVector(), edm::Event::getByLabel(), init(), LaserDQM_cfg::input, edm::Event::put(), and StoreMean().

{
   using namespace edm;
   
     
   //if(_actualEvent > _nEventsToUse) return;
   
   std::vector<edm::DetSet<SiStripProcessedRawDigi> > meancm;
   
   if(_Algorithm == "StoredCM"){
        edm::Handle< edm::DetSetVector<SiStripProcessedRawDigi> > inputCM;
        iEvent.getByLabel(_inputTag,inputCM);
        
        this->StoreMean(*inputCM);
        this->ConvertMeanMapToDetSetVector(meancm);
        
   } else if (_Algorithm == "Pedestals"){
     this->init(iSetup);
         
     edm::Handle< edm::DetSetVector<SiStripRawDigi> > input;
     iEvent.getByLabel(_inputTag,input);
         
     this->CMExtractorFromPedestals(*input,meancm);
   }
   
   ++_actualEvent;
   
    
        
        
        std::auto_ptr< edm::DetSetVector<SiStripProcessedRawDigi> > outputMeanCM(new edm::DetSetVector<SiStripProcessedRawDigi>(meancm) );
    iEvent.put( outputMeanCM,"MEANAPVCM");
   
}
void SiStripMeanCMExtractor::StoreMean ( const edm::DetSetVector< SiStripProcessedRawDigi > &  Input) [private]

Definition at line 168 of file SiStripMeanCMExtractor.cc.

References _CMMap, edm::DetSetVector< T >::begin(), and edm::DetSetVector< T >::end().

Referenced by produce().

                                                                                           {
        
        uint32_t detId;
        CMMap::iterator itMap;
        edm::DetSetVector<SiStripProcessedRawDigi>::const_iterator itInput;
        
        for(itInput = Input.begin(); itInput != Input.end(); ++itInput){
                detId = itInput->id;
                itMap = _CMMap.find(detId);
                edm::DetSet<SiStripProcessedRawDigi>::const_iterator itCM;
                std::vector<float> MeanCMNValue;
                MeanCMNValue.clear();
                if(itMap!=_CMMap.end()){   //the detId was already found
                    std::vector< float >& MapContent = itMap->second;
                        std::vector<float>::iterator itMapVector = MapContent.begin();
                        for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM, ++itMapVector){
                                MeanCMNValue.push_back(itCM->adc() + *itMapVector); 
            }
                        _CMMap.erase(itMap);
            _CMMap.insert(itMap, std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));                 
                } else {                 //no detId found
                        for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM) MeanCMNValue.push_back(itCM->adc());                       
                        _CMMap.insert(std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));
                }
        }
  
}

Member Data Documentation

Definition at line 75 of file SiStripMeanCMExtractor.cc.

Referenced by beginJob(), ConvertMeanMapToDetSetVector(), and produce().

std::string SiStripMeanCMExtractor::_Algorithm [private]

Definition at line 73 of file SiStripMeanCMExtractor.cc.

Referenced by produce().

Definition at line 77 of file SiStripMeanCMExtractor.cc.

Referenced by beginJob(), ConvertMeanMapToDetSetVector(), and StoreMean().

Definition at line 72 of file SiStripMeanCMExtractor.cc.

Referenced by produce().

Definition at line 74 of file SiStripMeanCMExtractor.cc.

Referenced by SiStripMeanCMExtractor().

Definition at line 67 of file SiStripMeanCMExtractor.cc.

Referenced by init().

Definition at line 66 of file SiStripMeanCMExtractor.cc.

Referenced by CMExtractorFromPedestals(), and init().