CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
SiPixelDigiToRaw Class Referencefinal

#include <SiPixelDigiToRaw.h>

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

Public Member Functions

virtual void endJob () override
 dummy end of job More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 get data, convert to raw event, attach again to Event More...
 
 SiPixelDigiToRaw (const edm::ParameterSet &)
 ctor More...
 
virtual ~SiPixelDigiToRaw ()
 dtor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

int allDigiCounter
 
int allWordCounter
 
std::unique_ptr< SiPixelFedCablingTreecablingTree_
 
edm::ParameterSet config_
 
bool debug
 
unsigned long eventCounter
 
std::vector< unsigned int > fedIds
 
SiPixelFrameReverterframeReverter_
 
TH1D * hCPU
 
TH1D * hDigi
 
edm::InputTag label
 
edm::ESWatcher< SiPixelFedCablingMapRcdrecordWatcher
 
std::unique_ptr< edm::CPUTimertheTimer
 
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
 
bool usePhase1
 
bool usePilotBlade
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 23 of file SiPixelDigiToRaw.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 24 of file SiPixelDigiToRaw.cc.

References allDigiCounter, allWordCounter, config_, eventCounter, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hCPU, hDigi, theTimer, tPixelDigi, usePhase1, and usePilotBlade.

24  :
25  frameReverter_(nullptr),
26  config_(pset),
27  hCPU(0), hDigi(0)
28 {
29 
30  tPixelDigi = consumes<edm::DetSetVector<PixelDigi> >(config_.getParameter<edm::InputTag>("InputLabel"));
31 
32  // Define EDProduct type
33  produces<FEDRawDataCollection>();
34 
35  // start the counters
36  eventCounter = 0;
37  allDigiCounter = 0;
38  allWordCounter = 0;
39 
40  // Timing
41  bool timing = config_.getUntrackedParameter<bool>("Timing",false);
42  if (timing) {
43  theTimer.reset(new edm::CPUTimer);
44  hCPU = new TH1D ("hCPU","hCPU",100,0.,0.050);
45  hDigi = new TH1D("hDigi","hDigi",50,0.,15000.);
46  }
47 
48  // Control the usage of phase1
49  usePhase1 = false;
50  if (config_.exists("UsePhase1")) {
51  usePhase1 = config_.getParameter<bool> ("UsePhase1");
52  if(usePhase1) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)";
53  }
54 
55  usePilotBlade=false; // I am not yet sure we need it here?
56 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
unsigned long eventCounter
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
std::unique_ptr< edm::CPUTimer > theTimer
edm::ParameterSet config_
SiPixelFrameReverter * frameReverter_
SiPixelDigiToRaw::~SiPixelDigiToRaw ( )
virtual

dtor

Definition at line 59 of file SiPixelDigiToRaw.cc.

References frameReverter_, hCPU, hDigi, indexGen::rootFile, and theTimer.

59  {
60  delete frameReverter_;
61 
62  if (theTimer) {
63  TFile rootFile("analysis.root", "RECREATE", "my histograms");
64  hCPU->Write();
65  hDigi->Write();
66  }
67 }
std::unique_ptr< edm::CPUTimer > theTimer
SiPixelFrameReverter * frameReverter_

Member Function Documentation

virtual void SiPixelDigiToRaw::endJob ( void  )
inlineoverridevirtual

dummy end of job

Reimplemented from edm::EDProducer.

Definition at line 34 of file SiPixelDigiToRaw.h.

References produce().

34 {}
void SiPixelDigiToRaw::produce ( edm::Event ev,
const edm::EventSetup es 
)
overridevirtual

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

Definition at line 72 of file SiPixelDigiToRaw.cc.

References allDigiCounter, allWordCounter, SiPixelFedCablingMap::cablingTree(), cablingTree_, edm::ESWatcher< T >::check(), config_, debug, edm::MessageDrop::debugEnabled, hgcalDigitizer_cfi::digiCollection, edm::EventID::event(), eventCounter, SiPixelFedCablingMap::fedIds(), fedIds, hcaldqm::constants::fedList, frameReverter_, edm::EventSetup::get(), edm::Event::getByToken(), edm::ParameterSet::getParameter(), hCPU, hDigi, edm::EventBase::id(), edm::MessageDrop::instance(), label, LogDebug, eostools::move(), PixelDataFormatter::passFrameReverter(), edm::ESHandle< T >::product(), edm::Event::put(), matplotRender::rawdata, recordWatcher, FEDRawData::size(), findQualityFiles::size, theTimer, tPixelDigi, and usePhase1.

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

74 {
75  using namespace sipixelobjects;
76  eventCounter++;
77  edm::LogInfo("SiPixelDigiToRaw") << "[SiPixelDigiToRaw::produce] "
78  << "event number: " << eventCounter;
79 
81  label = config_.getParameter<edm::InputTag>("InputLabel");
82  ev.getByToken( tPixelDigi, digiCollection);
83 
86  typedef vector< edm::DetSet<PixelDigi> >::const_iterator DI;
87 
88  int digiCounter = 0;
89  for (DI di=digiCollection->begin(); di != digiCollection->end(); di++) {
90  digiCounter += (di->data).size();
91  digis[ di->id] = di->data;
92  }
93  allDigiCounter += digiCounter;
94 
95  if (recordWatcher.check( es )) {
97  es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
98  fedIds = cablingMap->fedIds();
99  cablingTree_= cablingMap->cablingTree();
100  if (frameReverter_) delete frameReverter_;
101  frameReverter_ = new SiPixelFrameReverter( es, cablingMap.product() );
102  }
103 
105  if (debug) LogDebug("SiPixelDigiToRaw") << cablingTree_->version();
106 
107  //PixelDataFormatter formatter(cablingTree_.get());
108  PixelDataFormatter formatter(cablingTree_.get(), usePhase1);
109 
111  if (theTimer) theTimer->start();
112 
113  // create product (raw data)
114  auto buffers = std::make_unique<FEDRawDataCollection>();
115 
116  const vector<const PixelFEDCabling *> fedList = cablingTree_->fedList();
117 
118  // convert data to raw
119  formatter.formatRawData( ev.id().event(), rawdata, digis );
120 
121  // pack raw data into collection
122  typedef vector<const PixelFEDCabling *>::const_iterator FI;
123  for (FI it = fedList.begin(); it != fedList.end(); it++) {
124  LogDebug("SiPixelDigiToRaw")<<" PRODUCE DATA FOR FED_id: " << (**it).id();
125  FEDRawData& fedRawData = buffers->FEDData( (**it).id() );
126  PixelDataFormatter::RawData::iterator fedbuffer = rawdata.find( (**it).id() );
127  if( fedbuffer != rawdata.end() ) fedRawData = fedbuffer->second;
128  LogDebug("SiPixelDigiToRaw")<<"size of data in fedRawData: "<<fedRawData.size();
129  }
130  allWordCounter += formatter.nWords();
131  if (debug) LogDebug("SiPixelDigiToRaw")
132 
133  << "Words/Digis this ev: "<<digiCounter<<"(fm:"<<formatter.nDigis()<<")/"
134  <<formatter.nWords()
135  <<" all: "<< allDigiCounter <<"/"<<allWordCounter;
136 
137  if (theTimer) {
138  theTimer->stop();
139  LogDebug("SiPixelDigiToRaw") << "TIMING IS: (real)" << theTimer->realTime() ;
140  LogDebug("SiPixelDigiToRaw") << " (Words/Digis) this ev: "
141  <<formatter.nWords()<<"/"<<formatter.nDigis() << "--- all :"<<allWordCounter<<"/"<<allDigiCounter;
142  hCPU->Fill( theTimer->realTime() );
143  hDigi->Fill(formatter.nDigis());
144  }
145 
146  ev.put(std::move(buffers));
147 
148 }
#define LogDebug(id)
size
Write out results.
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
std::map< cms_uint32_t, DetDigis > Digis
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void passFrameReverter(const SiPixelFrameReverter *reverter)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
static MessageDrop * instance()
Definition: MessageDrop.cc:60
unsigned long eventCounter
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
std::unique_ptr< SiPixelFedCablingTree > cablingTree_
std::vector< unsigned int > fedIds
std::vector< unsigned int > const fedList
Definition: Constants.h:87
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
std::unique_ptr< edm::CPUTimer > theTimer
const T & get() const
Definition: EventSetup.h:55
std::map< int, FEDRawData > RawData
edm::ESWatcher< SiPixelFedCablingMapRcd > recordWatcher
edm::ParameterSet config_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::EventID id() const
Definition: EventBase.h:60
SiPixelFrameReverter * frameReverter_
std::vector< unsigned int > fedIds() const
T const * product() const
Definition: ESHandle.h:86
edm::InputTag label
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

int SiPixelDigiToRaw::allDigiCounter
private

Definition at line 48 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

int SiPixelDigiToRaw::allWordCounter
private

Definition at line 49 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

std::unique_ptr<SiPixelFedCablingTree> SiPixelDigiToRaw::cablingTree_
private

Definition at line 41 of file SiPixelDigiToRaw.h.

Referenced by produce().

edm::ParameterSet SiPixelDigiToRaw::config_
private

Definition at line 43 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

bool SiPixelDigiToRaw::debug
private
unsigned long SiPixelDigiToRaw::eventCounter
private

Definition at line 46 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

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

Definition at line 50 of file SiPixelDigiToRaw.h.

Referenced by produce().

SiPixelFrameReverter* SiPixelDigiToRaw::frameReverter_
private

Definition at line 42 of file SiPixelDigiToRaw.h.

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

TH1D* SiPixelDigiToRaw::hCPU
private

Definition at line 44 of file SiPixelDigiToRaw.h.

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

TH1D * SiPixelDigiToRaw::hDigi
private

Definition at line 44 of file SiPixelDigiToRaw.h.

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

edm::InputTag SiPixelDigiToRaw::label
private
edm::ESWatcher<SiPixelFedCablingMapRcd> SiPixelDigiToRaw::recordWatcher
private

Definition at line 51 of file SiPixelDigiToRaw.h.

Referenced by produce().

std::unique_ptr<edm::CPUTimer> SiPixelDigiToRaw::theTimer
private

Definition at line 45 of file SiPixelDigiToRaw.h.

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

edm::EDGetTokenT<edm::DetSetVector<PixelDigi> > SiPixelDigiToRaw::tPixelDigi
private

Definition at line 53 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

bool SiPixelDigiToRaw::usePhase1
private

Definition at line 55 of file SiPixelDigiToRaw.h.

Referenced by produce(), and SiPixelDigiToRaw().

bool SiPixelDigiToRaw::usePilotBlade
private

Definition at line 54 of file SiPixelDigiToRaw.h.

Referenced by SiPixelDigiToRaw().