CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
Phase2Tracker::Phase2TrackerDigiProducer Class Reference

#include <Phase2TrackerDigiProducer.h>

Inheritance diagram for Phase2Tracker::Phase2TrackerDigiProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  Registry
 

Public Member Functions

void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
 Phase2TrackerDigiProducer (const edm::ParameterSet &pset)
 constructor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~Phase2TrackerDigiProducer () override
 default constructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const Phase2TrackerCablingcabling_
 
uint32_t cacheId_
 
DetIdCollection detids_
 
std::vector< Phase2TrackerDigiproc_work_digis_
 
std::vector< Registryproc_work_registry_
 
unsigned int runNumber_
 
edm::EDGetTokenT< FEDRawDataCollectiontoken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 24 of file Phase2TrackerDigiProducer.h.

Constructor & Destructor Documentation

Phase2Tracker::Phase2TrackerDigiProducer::Phase2TrackerDigiProducer ( const edm::ParameterSet pset)

constructor

Definition at line 25 of file Phase2TrackerDigiProducer.cc.

References edm::ParameterSet::getParameter(), and token_.

26  : runNumber_(0), cabling_(nullptr), cacheId_(0) {
27  // define product
28  produces<edm::DetSetVector<Phase2TrackerDigi>>("ProcessedRaw");
29  token_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"));
30  }
T getParameter(std::string const &) const
edm::EDGetTokenT< FEDRawDataCollection > token_
Phase2Tracker::Phase2TrackerDigiProducer::~Phase2TrackerDigiProducer ( )
override

default constructor

Definition at line 32 of file Phase2TrackerDigiProducer.cc.

32 {}

Member Function Documentation

void Phase2Tracker::Phase2TrackerDigiProducer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 34 of file Phase2TrackerDigiProducer.cc.

34 {}
void Phase2Tracker::Phase2TrackerDigiProducer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
overridevirtual
void Phase2Tracker::Phase2TrackerDigiProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 43 of file Phase2TrackerDigiProducer.cc.

43 {}
void Phase2Tracker::Phase2TrackerDigiProducer::produce ( edm::Event event,
const edm::EventSetup es 
)
override

Definition at line 45 of file Phase2TrackerDigiProducer.cc.

References edmScanValgrind::buffer, Phase2Tracker::Phase2TrackerFEDBuffer::bufferSize(), cabling_, Phase2Tracker::Phase2TrackerFEDHeader::CBCStatus(), Phase2Tracker::Phase2TrackerFEDBuffer::channel(), Phase2Tracker::CMS_FED_ID_MAX, FEDRawData::data(), TauDecayModes::dec, end, Phase2Tracker::FED_ID_MIN, FEDRawDataCollection::FEDData(), Phase2TrackerCabling::findFedCh(), Phase2Tracker::Phase2TrackerFEDHeader::frontendStatus(), Phase2Tracker::Phase2TrackerFEDHeader::getConditionData(), Phase2Tracker::Phase2TrackerFEDHeader::getDataFormatVersion(), Phase2Tracker::Phase2TrackerFEDHeader::getDataType(), Phase2Tracker::Phase2TrackerFEDHeader::getDebugMode(), Phase2TrackerModule::getDetid(), Phase2Tracker::Phase2TrackerFEDHeader::getEventType(), Phase2Tracker::Phase2TrackerFEDHeader::getGlibStatusCode(), Phase2Tracker::Phase2TrackerFEDHeader::getNumberOfCBC(), Phase2Tracker::Phase2TrackerFEDHeader::getReadoutMode(), Phase2Tracker::Phase2TrackerFEDRawChannelUnpacker::hasData(), mps_fire::i, createfilelist::int, Phase2Tracker::Phase2TrackerFEDChannel::length(), LogTrace, Phase2Tracker::MAX_CBC_PER_FE, Phase2Tracker::MAX_FE_PER_FED, mod(), proc_work_digis_, proc_work_registry_, edm::DetSetVector< T >::reserve(), FEDRawData::size(), contentValuesCheck::ss, Phase2Tracker::Phase2TrackerFEDRawChannelUnpacker::stripIndex(), Phase2Tracker::Phase2TrackerFEDRawChannelUnpacker::stripOn(), Phase2Tracker::STRIPS_PER_CBC, edm::DetSetVector< T >::swap(), token_, and Phase2Tracker::Phase2TrackerFEDBuffer::trackerHeader().

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

45  {
46  // empty vectors for the next event
47  proc_work_registry_.clear();
48  proc_work_digis_.clear();
49 
50  // Retrieve FEDRawData collection
52  event.getByToken(token_, buffers);
53 
54  // Analyze strip tracker FED buffers in data
55  size_t fedIndex;
56  for (fedIndex = Phase2Tracker::FED_ID_MIN; fedIndex < Phase2Tracker::CMS_FED_ID_MAX; ++fedIndex) {
57  const FEDRawData& fed = buffers->FEDData(fedIndex);
58  if (fed.size() != 0) {
59  // construct buffer
61  buffer = new Phase2Tracker::Phase2TrackerFEDBuffer(fed.data(), fed.size());
62 
63 #ifdef EDM_ML_DEBUG
64  std::ostringstream ss;
65  ss << " -------------------------------------------- " << endl;
66  ss << " buffer debug ------------------------------- " << endl;
67  ss << " -------------------------------------------- " << endl;
68  ss << " buffer size : " << buffer->bufferSize() << endl;
69  ss << " fed id : " << fedIndex << endl;
70  ss << " -------------------------------------------- " << endl;
71  ss << " tracker header debug ------------------------" << endl;
72  ss << " -------------------------------------------- " << endl;
73  LogTrace("Phase2TrackerDigiProducer") << ss.str();
74  ss.clear();
75  ss.str("");
76 
77  Phase2TrackerFEDHeader tr_header = buffer->trackerHeader();
78  ss << " Version : " << hex << setw(2) << (int)tr_header.getDataFormatVersion() << endl;
79  ss << " Mode : " << hex << setw(2) << tr_header.getDebugMode() << endl;
80  ss << " Type : " << hex << setw(2) << (int)tr_header.getEventType() << endl;
81  ss << " Readout : " << hex << setw(2) << tr_header.getReadoutMode() << endl;
82  ss << " Condition Data : " << (tr_header.getConditionData() ? "Present" : "Absent") << "\n";
83  ss << " Data Type : " << (tr_header.getDataType() ? "Real" : "Fake") << "\n";
84  ss << " Status : " << hex << setw(16) << (int)tr_header.getGlibStatusCode() << endl;
85  ss << " FE stat : ";
86  for (int i = 15; i >= 0; i--) {
87  if ((tr_header.frontendStatus())[i]) {
88  ss << "1";
89  } else {
90  ss << "0";
91  }
92  }
93  ss << endl;
94  ss << " Nr CBC : " << hex << setw(16) << (int)tr_header.getNumberOfCBC() << endl;
95  ss << " CBC stat : ";
96  for (int i = 0; i < tr_header.getNumberOfCBC(); i++) {
97  ss << hex << setw(2) << (int)tr_header.CBCStatus()[i] << " ";
98  }
99  ss << endl;
100  LogTrace("Phase2TrackerDigiProducer") << ss.str();
101  ss.clear();
102  ss.str("");
103  ss << " -------------------------------------------- " << endl;
104  ss << " Payload ----------------------------------- " << endl;
105  ss << " -------------------------------------------- " << endl;
106 #endif
107 
108  // loop channels
109  int ichan = 0;
110  for (int ife = 0; ife < MAX_FE_PER_FED; ife++) {
111  for (int icbc = 0; icbc < MAX_CBC_PER_FE; icbc++) {
112  const Phase2TrackerFEDChannel& channel = buffer->channel(ichan);
113  if (channel.length() > 0) {
114  // get fedid from cabling
115  const Phase2TrackerModule mod = cabling_->findFedCh(std::make_pair(fedIndex, ife));
116  uint32_t detid = mod.getDetid();
117 #ifdef EDM_ML_DEBUG
118  ss << dec << " id from cabling : " << detid << endl;
119  ss << dec << " reading channel : " << icbc << " on FE " << ife;
120  ss << dec << " with length : " << (int)channel.length() << endl;
121 #endif
122 
123  // container for this channel's digis
124  std::vector<Phase2TrackerDigi> stripsTop;
125  std::vector<Phase2TrackerDigi> stripsBottom;
126 
127  // unpacking data
128  Phase2TrackerFEDRawChannelUnpacker unpacker = Phase2TrackerFEDRawChannelUnpacker(channel);
129  while (unpacker.hasData()) {
130  if (unpacker.stripOn()) {
131  if (unpacker.stripIndex() % 2) {
132  stripsTop.push_back(Phase2TrackerDigi((int)(STRIPS_PER_CBC * icbc + unpacker.stripIndex()) / 2, 0));
133 #ifdef EDM_ML_DEBUG
134  ss << "t";
135 #endif
136  } else {
137  stripsBottom.push_back(
138  Phase2TrackerDigi((int)(STRIPS_PER_CBC * icbc + unpacker.stripIndex()) / 2, 0));
139 #ifdef EDM_ML_DEBUG
140  ss << "b";
141 #endif
142  }
143  } else {
144 #ifdef EDM_ML_DEBUG
145  ss << "_";
146 #endif
147  }
148  unpacker++;
149  }
150 #ifdef EDM_ML_DEBUG
151  ss << endl;
152  LogTrace("Phase2TrackerDigiProducer") << ss.str();
153  ss.clear();
154  ss.str("");
155 #endif
156 
157  // store beginning and end of this digis for this detid and add this registry to the list
158  // and store data
159  Registry regItemTop(detid + 1, STRIPS_PER_CBC * icbc / 2, proc_work_digis_.size(), stripsTop.size());
160  proc_work_registry_.push_back(regItemTop);
161  proc_work_digis_.insert(proc_work_digis_.end(), stripsTop.begin(), stripsTop.end());
162  Registry regItemBottom(
163  detid + 2, STRIPS_PER_CBC * icbc / 2, proc_work_digis_.size(), stripsBottom.size());
164  proc_work_registry_.push_back(regItemBottom);
165  proc_work_digis_.insert(proc_work_digis_.end(), stripsBottom.begin(), stripsBottom.end());
166  }
167  ichan++;
168  }
169  } // end loop on channels
170  // store digis in edm collections
171  std::sort(proc_work_registry_.begin(), proc_work_registry_.end());
172  std::vector<edm::DetSet<Phase2TrackerDigi>> sorted_and_merged;
173 
175 
176  std::vector<Registry>::iterator it = proc_work_registry_.begin(), it2 = it + 1, end = proc_work_registry_.end();
177  while (it < end) {
178  sorted_and_merged.push_back(edm::DetSet<Phase2TrackerDigi>(it->detid));
179  std::vector<Phase2TrackerDigi>& digis = sorted_and_merged.back().data;
180  // first count how many digis we have
181  size_t len = it->length;
182  for (it2 = it + 1; (it2 != end) && (it2->detid == it->detid); ++it2) {
183  len += it2->length;
184  }
185  // reserve memory
186  digis.reserve(len);
187  // push them in
188  for (it2 = it + 0; (it2 != end) && (it2->detid == it->detid); ++it2) {
189  digis.insert(digis.end(), &proc_work_digis_[it2->index], &proc_work_digis_[it2->index + it2->length]);
190  }
191  it = it2;
192  }
193 
194  edm::DetSetVector<Phase2TrackerDigi> proc_raw_dsv(sorted_and_merged, true);
195  pr->swap(proc_raw_dsv);
196  event.put(std::unique_ptr<edm::DetSetVector<Phase2TrackerDigi>>(pr), "ProcessedRaw");
197  delete buffer;
198  }
199  }
200  }
const Phase2TrackerFEDChannel & channel(const uint8_t internalPhase2TrackerFEDChannelNum) const
const Phase2TrackerModule & findFedCh(std::pair< unsigned int, unsigned int > fedch) const
void reserve(size_t s)
Definition: DetSetVector.h:147
static const uint16_t CMS_FED_ID_MAX
Definition: utils.h:19
edm::EDGetTokenT< FEDRawDataCollection > token_
void swap(DetSetVector &other)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
uint32_t getDetid() const
static const int MAX_CBC_PER_FE
Definition: utils.h:25
std::vector< Phase2TrackerDigi > proc_work_digis_
#define end
Definition: vmac.h:39
#define LogTrace(id)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static const int STRIPS_PER_CBC
Definition: utils.h:26
static const uint16_t FED_ID_MIN
Definition: utils.h:17
Phase2TrackerFEDHeader trackerHeader() const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
static const int MAX_FE_PER_FED
Definition: utils.h:24

Member Data Documentation

const Phase2TrackerCabling* Phase2Tracker::Phase2TrackerDigiProducer::cabling_
private

Definition at line 38 of file Phase2TrackerDigiProducer.h.

Referenced by beginRun(), and produce().

uint32_t Phase2Tracker::Phase2TrackerDigiProducer::cacheId_
private

Definition at line 39 of file Phase2TrackerDigiProducer.h.

DetIdCollection Phase2Tracker::Phase2TrackerDigiProducer::detids_
private

Definition at line 40 of file Phase2TrackerDigiProducer.h.

std::vector<Phase2TrackerDigi> Phase2Tracker::Phase2TrackerDigiProducer::proc_work_digis_
private

Definition at line 57 of file Phase2TrackerDigiProducer.h.

Referenced by produce().

std::vector<Registry> Phase2Tracker::Phase2TrackerDigiProducer::proc_work_registry_
private

Definition at line 56 of file Phase2TrackerDigiProducer.h.

Referenced by produce().

unsigned int Phase2Tracker::Phase2TrackerDigiProducer::runNumber_
private

Definition at line 36 of file Phase2TrackerDigiProducer.h.

edm::EDGetTokenT<FEDRawDataCollection> Phase2Tracker::Phase2TrackerDigiProducer::token_
private

Definition at line 37 of file Phase2TrackerDigiProducer.h.

Referenced by Phase2TrackerDigiProducer(), and produce().