CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
SiPixelRawToDigi Class Reference

#include <SiPixelRawToDigi.h>

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

Public Member Functions

virtual void endJob ()
 dummy end of job More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 get data, convert to digis attach againe to Event More...
 
 SiPixelRawToDigi (const edm::ParameterSet &)
 ctor More...
 
virtual ~SiPixelRawToDigi ()
 dtor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

const SiPixelQualitybadPixelInfo_
 
const SiPixelFedCablingcabling_
 
edm::ParameterSet config_
 
bool debug
 
std::vector< unsigned int > fedIds
 
TH1D * hCPU
 
TH1D * hDigi
 
bool includeErrors
 
edm::InputTag label
 
int ndigis
 
int nwords
 
edm::ESWatcher< SiPixelQualityRcdqualityWatcher
 
edm::ESWatcher
< SiPixelFedCablingMapRcd
recordWatcher
 
R2DTimerObservertheTimer
 
bool useCablingTree_
 
bool useQuality
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 23 of file SiPixelRawToDigi.h.

Constructor & Destructor Documentation

SiPixelRawToDigi::SiPixelRawToDigi ( const edm::ParameterSet conf)
explicit

ctor

Definition at line 38 of file SiPixelRawToDigi.cc.

References config_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hCPU, hDigi, includeErrors, ndigis, nwords, theTimer, useCablingTree_, and useQuality.

39  : config_(conf),
40  cabling_(0),
41  badPixelInfo_(0),
42  hCPU(0), hDigi(0), theTimer(0)
43 {
44 
45  includeErrors = config_.getParameter<bool>("IncludeErrors");
46  useQuality = config_.getParameter<bool>("UseQualityInfo");
47  useCablingTree_ = config_.getUntrackedParameter<bool>("UseCablingTree",true);
48 
49  //start counters
50  ndigis = 0;
51  nwords = 0;
52 
53  // Products
54  produces< edm::DetSetVector<PixelDigi> >();
55  if(includeErrors) produces< edm::DetSetVector<SiPixelRawDataError> >();
56 
57  // Timing
58  bool timing = config_.getUntrackedParameter<bool>("Timing",false);
59  if (timing) {
60  theTimer = new R2DTimerObserver("**** MY TIMING REPORT ***");
61  hCPU = new TH1D ("hCPU","hCPU",100,0.,0.050);
62  hDigi = new TH1D("hDigi","hDigi",50,0.,15000.);
63  }
64 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ParameterSet config_
R2DTimerObserver * theTimer
const SiPixelQuality * badPixelInfo_
const SiPixelFedCabling * cabling_
SiPixelRawToDigi::~SiPixelRawToDigi ( )
virtual

dtor

Definition at line 68 of file SiPixelRawToDigi.cc.

References cabling_, hCPU, hDigi, BuildWebpage::rootFile, theTimer, and useCablingTree_.

68  {
69  edm::LogInfo("SiPixelRawToDigi") << " HERE ** SiPixelRawToDigi destructor!";
70 
71  if(useCablingTree_) delete cabling_;
72 
73  if (theTimer) {
74  TFile rootFile("analysis.root", "RECREATE", "my histograms");
75  hCPU->Write();
76  hDigi->Write();
77  delete theTimer;
78  }
79 
80 }
R2DTimerObserver * theTimer
const SiPixelFedCabling * cabling_

Member Function Documentation

virtual void SiPixelRawToDigi::endJob ( void  )
inlinevirtual

dummy end of job

Reimplemented from edm::EDProducer.

Definition at line 34 of file SiPixelRawToDigi.h.

34 {}
void SiPixelRawToDigi::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

get data, convert to digis attach againe to Event

Implements edm::EDProducer.

Definition at line 87 of file SiPixelRawToDigi.cc.

References badPixelInfo_, cabling_, edm::ESWatcher< T >::check(), runEdmFileComparison::collection, config_, edm::DetSet< T >::data, debug, edm::MessageDrop::debugEnabled, cond::rpcobgas::detid, benchmark_cfg::errors, fedIds, edm::EventSetup::get(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), hCPU, hDigi, includeErrors, edm::MessageDrop::instance(), PixelDataFormatter::interpretRawData(), label, R2DTimerObserver::lastMeasurement(), LogDebug, ndigis, PixelDataFormatter::nDigis(), nwords, PixelDataFormatter::nWords(), edm::ESTransientHandle< T >::product(), edm::ESHandle< class >::product(), edm::Event::put(), qualityWatcher, R2DTimerObserver::LastMeasurement::real(), recordWatcher, PixelDataFormatter::setErrorStatus(), PixelDataFormatter::setQualityStatus(), R2DTimerObserver::start(), R2DTimerObserver::stop(), theTimer, useCablingTree_, useQuality, and SiPixelFedCabling::version().

Referenced by python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

89 {
90  const uint32_t dummydetid = 0xffffffff;
92 
93 // initialize cabling map or update if necessary
94  if (recordWatcher.check( es )) {
95  // cabling map, which maps online address (fed->link->ROC->local pixel) to offline (DetId->global pixel)
97  es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
98  fedIds = cablingMap->fedIds();
99  if (useCablingTree_ && cabling_) delete cabling_;
100  if (useCablingTree_) cabling_ = cablingMap->cablingTree();
101  else cabling_ = cablingMap.product();
102  LogDebug("map version:")<< cabling_->version();
103  }
104 // initialize quality record or update if necessary
105  if (qualityWatcher.check( es )&&useQuality) {
106  // quality info for dead pixel modules or ROCs
107  edm::ESHandle<SiPixelQuality> qualityInfo;
108  es.get<SiPixelQualityRcd>().get( qualityInfo );
109  badPixelInfo_ = qualityInfo.product();
110  if (!badPixelInfo_) {
111  edm::LogError("**SiPixelRawToDigi**")<<" Configured to use SiPixelQuality, but SiPixelQuality not present"<<endl;
112  }
113  }
114 
116  label = config_.getParameter<edm::InputTag>("InputLabel");
117  ev.getByLabel( label, buffers);
118 
119 // create product (digis & errors)
120  std::auto_ptr< edm::DetSetVector<PixelDigi> > collection( new edm::DetSetVector<PixelDigi> );
121  std::auto_ptr< edm::DetSetVector<SiPixelRawDataError> > errorcollection( new edm::DetSetVector<SiPixelRawDataError> );
122 
123  PixelDataFormatter formatter(cabling_);
124  formatter.setErrorStatus(includeErrors);
125  if (useQuality) formatter.setQualityStatus(useQuality, badPixelInfo_);
126 
127  if (theTimer) theTimer->start();
128  bool errorsInEvent = false;
129  PixelDataFormatter::DetErrors nodeterrors;
130 
131  typedef std::vector<unsigned int>::const_iterator IF;
132  for (IF aFed = fedIds.begin(); aFed != fedIds.end(); ++aFed) {
133  int fedId = *aFed;
134  if(debug) LogDebug("SiPixelRawToDigi")<< " PRODUCE DIGI FOR FED: " << fedId << endl;
137 
138  //get event data for this fed
139  const FEDRawData& fedRawData = buffers->FEDData( fedId );
140 
141  //convert data to digi and strip off errors
142  formatter.interpretRawData( errorsInEvent, fedId, fedRawData, digis, errors);
143 
144  //pack digi into collection
145  typedef PixelDataFormatter::Digis::iterator ID;
146  for (ID it = digis.begin(); it != digis.end(); it++) {
147  uint32_t detid = it->first;
148  edm::DetSet<PixelDigi>& detSet = collection->find_or_insert(detid);
149  detSet.data = it->second;
150  }
151 
152  //pack errors into collection
153  if(includeErrors) {
154  typedef PixelDataFormatter::Errors::iterator IE;
155  for (IE is = errors.begin(); is != errors.end(); is++) {
156  uint32_t errordetid = is->first;
157  if (errordetid==dummydetid) { // errors given dummy detId must be sorted by Fed
158  nodeterrors.insert( nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end() );
159  } else {
160  edm::DetSet<SiPixelRawDataError>& errorDetSet = errorcollection->find_or_insert(errordetid);
161  errorDetSet.data = is->second;
162  }
163  }
164  }
165  }
166 
167  if(includeErrors) {
168  edm::DetSet<SiPixelRawDataError>& errorDetSet = errorcollection->find_or_insert(dummydetid);
169  errorDetSet.data = nodeterrors;
170  }
171  if (errorsInEvent) LogDebug("SiPixelRawToDigi") << "Error words were stored in this event";
172 
173  if (theTimer) {
174  theTimer->stop();
175  LogDebug("SiPixelRawToDigi") << "TIMING IS: (real)" << theTimer->lastMeasurement().real() ;
176  ndigis += formatter.nDigis();
177  nwords += formatter.nWords();
178  LogDebug("SiPixelRawToDigi") << " (Words/Digis) this ev: "
179  <<formatter.nWords()<<"/"<<formatter.nDigis() << "--- all :"<<nwords<<"/"<<ndigis;
180  hCPU->Fill( theTimer->lastMeasurement().real() );
181  hDigi->Fill(formatter.nDigis());
182  }
183 
184  //send digis and errors back to framework
185  ev.put( collection );
186  if(includeErrors) ev.put( errorcollection );
187 }
#define LogDebug(id)
T getParameter(std::string const &) const
uint32_t ID
Definition: Definitions.h:26
static MessageDrop * instance()
Definition: MessageDrop.cc:65
std::map< uint32_t, DetErrors > Errors
static bool debugEnabled
Definition: MessageDrop.h:100
virtual std::string version() const =0
edm::InputTag label
std::vector< SiPixelRawDataError > DetErrors
std::vector< unsigned int > fedIds
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
edm::ESWatcher< SiPixelFedCablingMapRcd > recordWatcher
const LastMeasurement & lastMeasurement()
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
edm::ParameterSet config_
collection_type data
Definition: DetSet.h:77
std::map< uint32_t, DetDigis > Digis
R2DTimerObserver * theTimer
edm::ESWatcher< SiPixelQualityRcd > qualityWatcher
const SiPixelQuality * badPixelInfo_
const SiPixelFedCabling * cabling_

Member Data Documentation

const SiPixelQuality* SiPixelRawToDigi::badPixelInfo_
private

Definition at line 43 of file SiPixelRawToDigi.h.

Referenced by produce().

const SiPixelFedCabling* SiPixelRawToDigi::cabling_
private

Definition at line 42 of file SiPixelRawToDigi.h.

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

edm::ParameterSet SiPixelRawToDigi::config_
private

Definition at line 41 of file SiPixelRawToDigi.h.

Referenced by produce(), and SiPixelRawToDigi().

bool SiPixelRawToDigi::debug
private

Definition at line 49 of file SiPixelRawToDigi.h.

Referenced by produce().

std::vector<unsigned int> SiPixelRawToDigi::fedIds
private

Definition at line 50 of file SiPixelRawToDigi.h.

Referenced by produce().

TH1D* SiPixelRawToDigi::hCPU
private

Definition at line 45 of file SiPixelRawToDigi.h.

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

TH1D * SiPixelRawToDigi::hDigi
private

Definition at line 45 of file SiPixelRawToDigi.h.

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

bool SiPixelRawToDigi::includeErrors
private

Definition at line 47 of file SiPixelRawToDigi.h.

Referenced by produce(), and SiPixelRawToDigi().

edm::InputTag SiPixelRawToDigi::label
private
int SiPixelRawToDigi::ndigis
private

Definition at line 54 of file SiPixelRawToDigi.h.

Referenced by produce(), and SiPixelRawToDigi().

int SiPixelRawToDigi::nwords
private

Definition at line 55 of file SiPixelRawToDigi.h.

Referenced by produce(), and SiPixelRawToDigi().

edm::ESWatcher<SiPixelQualityRcd> SiPixelRawToDigi::qualityWatcher
private

Definition at line 52 of file SiPixelRawToDigi.h.

Referenced by produce().

edm::ESWatcher<SiPixelFedCablingMapRcd> SiPixelRawToDigi::recordWatcher
private

Definition at line 51 of file SiPixelRawToDigi.h.

Referenced by produce().

R2DTimerObserver* SiPixelRawToDigi::theTimer
private

Definition at line 46 of file SiPixelRawToDigi.h.

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

bool SiPixelRawToDigi::useCablingTree_
private

Definition at line 44 of file SiPixelRawToDigi.h.

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

bool SiPixelRawToDigi::useQuality
private

Definition at line 48 of file SiPixelRawToDigi.h.

Referenced by produce(), and SiPixelRawToDigi().