CMS 3D CMS Logo

Public Member Functions | Private Attributes

SiPixelDigiToRaw Class Reference

#include <SiPixelDigiToRaw.h>

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

List of all members.

Public Member Functions

virtual void endJob ()
 dummy end of job
virtual void produce (edm::Event &, const edm::EventSetup &)
 get data, convert to raw event, attach again to Event
 SiPixelDigiToRaw (const edm::ParameterSet &)
 ctor
virtual ~SiPixelDigiToRaw ()
 dtor

Private Attributes

int allDigiCounter
int allWordCounter
SiPixelFedCablingTreecablingTree_
edm::ParameterSet config_
bool debug
unsigned long eventCounter
std::vector< unsigned int > fedIds
SiPixelFrameReverterframeReverter_
TH1D * hCPU
TH1D * hDigi
edm::InputTag label
edm::ESWatcher
< SiPixelFedCablingMapRcd
recordWatcher
R2DTimerObservertheTimer

Detailed Description

Definition at line 21 of file SiPixelDigiToRaw.h.


Constructor & Destructor Documentation

SiPixelDigiToRaw::SiPixelDigiToRaw ( const edm::ParameterSet pset) [explicit]

ctor

Definition at line 25 of file SiPixelDigiToRaw.cc.

References allDigiCounter, allWordCounter, config_, eventCounter, edm::ParameterSet::getUntrackedParameter(), hCPU, hDigi, and theTimer.

                                                                :
  cablingTree_(0),
  frameReverter_(0),
  config_(pset),
  hCPU(0), hDigi(0), theTimer(0)
{

  // Define EDProduct type
  produces<FEDRawDataCollection>();

  // start the counters
  eventCounter = 0;
  allDigiCounter = 0;
  allWordCounter = 0;

  // Timing
  bool timing = config_.getUntrackedParameter<bool>("Timing",false);
  if (timing) {
    theTimer = new R2DTimerObserver("**** MY TIMING REPORT ***");
    hCPU = new TH1D ("hCPU","hCPU",100,0.,0.050);
    hDigi = new TH1D("hDigi","hDigi",50,0.,15000.);
  }
}
SiPixelDigiToRaw::~SiPixelDigiToRaw ( ) [virtual]

dtor

Definition at line 50 of file SiPixelDigiToRaw.cc.

References cablingTree_, frameReverter_, hCPU, hDigi, BuildWebpage::rootFile, and theTimer.

                                    {
  delete cablingTree_;
  delete frameReverter_;

  if (theTimer) {
    TFile rootFile("analysis.root", "RECREATE", "my histograms");
    hCPU->Write();
    hDigi->Write();
    delete theTimer;
  }
}

Member Function Documentation

virtual void SiPixelDigiToRaw::endJob ( void  ) [inline, virtual]

dummy end of job

Reimplemented from edm::EDProducer.

Definition at line 32 of file SiPixelDigiToRaw.h.

{}
void SiPixelDigiToRaw::produce ( edm::Event ev,
const edm::EventSetup es 
) [virtual]

get data, convert to raw event, attach again to Event

Implements edm::EDProducer.

Definition at line 65 of file SiPixelDigiToRaw.cc.

References allDigiCounter, allWordCounter, cablingTree_, edm::ESWatcher< T >::check(), config_, debug, reco_application_2006_simpleTBanalysis_cfg::digiCollection, edm::EventID::event(), eventCounter, fedIds, SiPixelFedCablingTree::fedList(), PixelDataFormatter::formatRawData(), frameReverter_, edm::EventSetup::get(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), hCPU, hDigi, edm::EventBase::id(), edm::MessageDrop::instance(), label, R2DTimerObserver::lastMeasurement(), LogDebug, PixelDataFormatter::nDigis(), PixelDataFormatter::nWords(), PixelDataFormatter::passFrameReverter(), edm::ESHandle< T >::product(), edm::Event::put(), recordWatcher, findQualityFiles::size, FEDRawData::size(), R2DTimerObserver::start(), R2DTimerObserver::stop(), theTimer, and SiPixelFedCablingTree::version().

{
  using namespace sipixelobjects;
  eventCounter++;
  edm::LogInfo("SiPixelDigiToRaw") << "[SiPixelDigiToRaw::produce] "
                                   << "event number: " << eventCounter;

  edm::Handle< edm::DetSetVector<PixelDigi> > digiCollection;
  label = config_.getParameter<edm::InputTag>("InputLabel");
  ev.getByLabel( label, digiCollection);

  PixelDataFormatter::RawData rawdata;
  PixelDataFormatter::Digis digis;
  typedef vector< edm::DetSet<PixelDigi> >::const_iterator DI;

  int digiCounter = 0; 
  for (DI di=digiCollection->begin(); di != digiCollection->end(); di++) {
    digiCounter += (di->data).size(); 
    digis[ di->id] = di->data;
  }
  allDigiCounter += digiCounter;

  if (recordWatcher.check( es )) {
    edm::ESHandle<SiPixelFedCablingMap> cablingMap;
    es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
    fedIds = cablingMap->fedIds();
    if (cablingTree_) delete cablingTree_; cablingTree_= cablingMap->cablingTree();
    if (frameReverter_) delete frameReverter_; frameReverter_ = new SiPixelFrameReverter( es, cablingMap.product() );
  }

  debug = edm::MessageDrop::instance()->debugEnabled;
  if (debug) LogDebug("SiPixelDigiToRaw") << cablingTree_->version();

  PixelDataFormatter formatter(cablingTree_);
  formatter.passFrameReverter(frameReverter_);
  if (theTimer) theTimer->start();

  // create product (raw data)
  std::auto_ptr<FEDRawDataCollection> buffers( new FEDRawDataCollection );

  const vector<const PixelFEDCabling *>  fedList = cablingTree_->fedList();

  // convert data to raw
  formatter.formatRawData( ev.id().event(), rawdata, digis );

  // pack raw data into collection
  typedef vector<const PixelFEDCabling *>::const_iterator FI;
  for (FI it = fedList.begin(); it != fedList.end(); it++) {
    LogDebug("SiPixelDigiToRaw")<<" PRODUCE DATA FOR FED_id: " << (**it).id();
    FEDRawData& fedRawData = buffers->FEDData( (**it).id() );
    PixelDataFormatter::RawData::iterator fedbuffer = rawdata.find( (**it).id() );
    if( fedbuffer != rawdata.end() ) fedRawData = fedbuffer->second;
    LogDebug("SiPixelDigiToRaw")<<"size of data in fedRawData: "<<fedRawData.size();
  }
  allWordCounter += formatter.nWords();
  if (debug) LogDebug("SiPixelDigiToRaw") 

        << "Words/Digis this ev: "<<digiCounter<<"(fm:"<<formatter.nDigis()<<")/"
        <<formatter.nWords()
        <<"  all: "<< allDigiCounter <<"/"<<allWordCounter;

  if (theTimer) {
    theTimer->stop();
    LogDebug("SiPixelDigiToRaw") << "TIMING IS: (real)" << theTimer->lastMeasurement().real() ;
    LogDebug("SiPixelDigiToRaw") << " (Words/Digis) this ev: "
         <<formatter.nWords()<<"/"<<formatter.nDigis() << "--- all :"<<allWordCounter<<"/"<<allDigiCounter;
    hCPU->Fill( theTimer->lastMeasurement().real() ); 
    hDigi->Fill(formatter.nDigis());
  }
  
  ev.put( buffers );
  
}

Member Data Documentation

Definition at line 46 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

Definition at line 47 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

Definition at line 39 of file SiPixelDigiToRaw.h.

Referenced by produce(), and ~SiPixelDigiToRaw().

Definition at line 41 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

bool SiPixelDigiToRaw::debug [private]

Definition at line 50 of file SiPixelDigiToRaw.h.

Referenced by produce().

unsigned long SiPixelDigiToRaw::eventCounter [private]

Definition at line 44 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

std::vector<unsigned int> SiPixelDigiToRaw::fedIds [private]

Definition at line 48 of file SiPixelDigiToRaw.h.

Referenced by produce().

Definition at line 40 of file SiPixelDigiToRaw.h.

Referenced by produce(), and ~SiPixelDigiToRaw().

TH1D* SiPixelDigiToRaw::hCPU [private]

Definition at line 42 of file SiPixelDigiToRaw.h.

Referenced by produce(), SiPixelDigiToRaw(), and ~SiPixelDigiToRaw().

TH1D * SiPixelDigiToRaw::hDigi [private]

Definition at line 42 of file SiPixelDigiToRaw.h.

Referenced by produce(), SiPixelDigiToRaw(), and ~SiPixelDigiToRaw().

Definition at line 45 of file SiPixelDigiToRaw.h.

Referenced by produce().

Definition at line 49 of file SiPixelDigiToRaw.h.

Referenced by produce().

Definition at line 43 of file SiPixelDigiToRaw.h.

Referenced by produce(), SiPixelDigiToRaw(), and ~SiPixelDigiToRaw().