CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Attributes
Phase2Tracker::Phase2TrackerDigiProducer Class Reference
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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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
< FEDRawDataCollection
token_
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 26 of file Phase2TrackerDigiProducer.cc.

Constructor & Destructor Documentation

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

constructor

Definition at line 71 of file Phase2TrackerDigiProducer.cc.

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

72  : runNumber_(0), cabling_(nullptr), cacheId_(0) {
73  // define product
74  produces<edm::DetSetVector<Phase2TrackerDigi>>("ProcessedRaw");
75  token_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"));
76  }
edm::EDGetTokenT< FEDRawDataCollection > token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Phase2Tracker::Phase2TrackerDigiProducer::~Phase2TrackerDigiProducer ( )
override

default constructor

Definition at line 78 of file Phase2TrackerDigiProducer.cc.

78 {}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 80 of file Phase2TrackerDigiProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 82 of file Phase2TrackerDigiProducer.cc.

References c, cabling_, edm::EventSetup::get(), and edm::ESHandle< class >::product().

82  {
83  // fetch cabling from event setup
85  es.get<Phase2TrackerCablingRcd>().get(c);
86  cabling_ = c.product();
87  }
const edm::EventSetup & c
T const * product() const
Definition: ESHandle.h:86
T get() const
Definition: EventSetup.h:88
void Phase2Tracker::Phase2TrackerDigiProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 89 of file Phase2TrackerDigiProducer.cc.

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

Implements edm::EDProducer.

Definition at line 91 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, dataset::end, Phase2Tracker::FED_ID_MIN, sistrip::SpyUtilities::fedIndex(), 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, 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().

91  {
92  // empty vectors for the next event
93  proc_work_registry_.clear();
94  proc_work_digis_.clear();
95 
96  // Retrieve FEDRawData collection
98  event.getByToken(token_, buffers);
99 
100  // Analyze strip tracker FED buffers in data
101  size_t fedIndex;
102  for (fedIndex = Phase2Tracker::FED_ID_MIN; fedIndex < Phase2Tracker::CMS_FED_ID_MAX; ++fedIndex) {
103  const FEDRawData& fed = buffers->FEDData(fedIndex);
104  if (fed.size() != 0) {
105  // construct buffer
107  buffer = new Phase2Tracker::Phase2TrackerFEDBuffer(fed.data(), fed.size());
108 
109 #ifdef EDM_ML_DEBUG
110  std::ostringstream ss;
111  ss << " -------------------------------------------- " << endl;
112  ss << " buffer debug ------------------------------- " << endl;
113  ss << " -------------------------------------------- " << endl;
114  ss << " buffer size : " << buffer->bufferSize() << endl;
115  ss << " fed id : " << fedIndex << endl;
116  ss << " -------------------------------------------- " << endl;
117  ss << " tracker header debug ------------------------" << endl;
118  ss << " -------------------------------------------- " << endl;
119  LogTrace("Phase2TrackerDigiProducer") << ss.str();
120  ss.clear();
121  ss.str("");
122 
123  Phase2TrackerFEDHeader tr_header = buffer->trackerHeader();
124  ss << " Version : " << hex << setw(2) << (int)tr_header.getDataFormatVersion() << endl;
125  ss << " Mode : " << hex << setw(2) << tr_header.getDebugMode() << endl;
126  ss << " Type : " << hex << setw(2) << (int)tr_header.getEventType() << endl;
127  ss << " Readout : " << hex << setw(2) << tr_header.getReadoutMode() << endl;
128  ss << " Condition Data : " << (tr_header.getConditionData() ? "Present" : "Absent") << "\n";
129  ss << " Data Type : " << (tr_header.getDataType() ? "Real" : "Fake") << "\n";
130  ss << " Status : " << hex << setw(16) << (int)tr_header.getGlibStatusCode() << endl;
131  ss << " FE stat : ";
132  for (int i = 15; i >= 0; i--) {
133  if ((tr_header.frontendStatus())[i]) {
134  ss << "1";
135  } else {
136  ss << "0";
137  }
138  }
139  ss << endl;
140  ss << " Nr CBC : " << hex << setw(16) << (int)tr_header.getNumberOfCBC() << endl;
141  ss << " CBC stat : ";
142  for (int i = 0; i < tr_header.getNumberOfCBC(); i++) {
143  ss << hex << setw(2) << (int)tr_header.CBCStatus()[i] << " ";
144  }
145  ss << endl;
146  LogTrace("Phase2TrackerDigiProducer") << ss.str();
147  ss.clear();
148  ss.str("");
149  ss << " -------------------------------------------- " << endl;
150  ss << " Payload ----------------------------------- " << endl;
151  ss << " -------------------------------------------- " << endl;
152 #endif
153 
154  // loop channels
155  int ichan = 0;
156  for (int ife = 0; ife < MAX_FE_PER_FED; ife++) {
157  for (int icbc = 0; icbc < MAX_CBC_PER_FE; icbc++) {
158  const Phase2TrackerFEDChannel& channel = buffer->channel(ichan);
159  if (channel.length() > 0) {
160  // get fedid from cabling
161  const Phase2TrackerModule mod = cabling_->findFedCh(std::make_pair(fedIndex, ife));
162  uint32_t detid = mod.getDetid();
163 #ifdef EDM_ML_DEBUG
164  ss << dec << " id from cabling : " << detid << endl;
165  ss << dec << " reading channel : " << icbc << " on FE " << ife;
166  ss << dec << " with length : " << (int)channel.length() << endl;
167 #endif
168 
169  // container for this channel's digis
170  std::vector<Phase2TrackerDigi> stripsTop;
171  std::vector<Phase2TrackerDigi> stripsBottom;
172 
173  // unpacking data
174  Phase2TrackerFEDRawChannelUnpacker unpacker = Phase2TrackerFEDRawChannelUnpacker(channel);
175  while (unpacker.hasData()) {
176  if (unpacker.stripOn()) {
177  if (unpacker.stripIndex() % 2) {
178  stripsTop.push_back(Phase2TrackerDigi((int)(STRIPS_PER_CBC * icbc + unpacker.stripIndex()) / 2, 0));
179 #ifdef EDM_ML_DEBUG
180  ss << "t";
181 #endif
182  } else {
183  stripsBottom.push_back(
184  Phase2TrackerDigi((int)(STRIPS_PER_CBC * icbc + unpacker.stripIndex()) / 2, 0));
185 #ifdef EDM_ML_DEBUG
186  ss << "b";
187 #endif
188  }
189  } else {
190 #ifdef EDM_ML_DEBUG
191  ss << "_";
192 #endif
193  }
194  unpacker++;
195  }
196 #ifdef EDM_ML_DEBUG
197  ss << endl;
198  LogTrace("Phase2TrackerDigiProducer") << ss.str();
199  ss.clear();
200  ss.str("");
201 #endif
202 
203  // store beginning and end of this digis for this detid and add this registry to the list
204  // and store data
205  Registry regItemTop(detid + 1, STRIPS_PER_CBC * icbc / 2, proc_work_digis_.size(), stripsTop.size());
206  proc_work_registry_.push_back(regItemTop);
207  proc_work_digis_.insert(proc_work_digis_.end(), stripsTop.begin(), stripsTop.end());
208  Registry regItemBottom(
209  detid + 2, STRIPS_PER_CBC * icbc / 2, proc_work_digis_.size(), stripsBottom.size());
210  proc_work_registry_.push_back(regItemBottom);
211  proc_work_digis_.insert(proc_work_digis_.end(), stripsBottom.begin(), stripsBottom.end());
212  }
213  ichan++;
214  }
215  } // end loop on channels
216  // store digis in edm collections
217  std::sort(proc_work_registry_.begin(), proc_work_registry_.end());
218  std::vector<edm::DetSet<Phase2TrackerDigi>> sorted_and_merged;
219 
221 
222  std::vector<Registry>::iterator it = proc_work_registry_.begin(), it2 = it + 1, end = proc_work_registry_.end();
223  while (it < end) {
224  sorted_and_merged.push_back(edm::DetSet<Phase2TrackerDigi>(it->detid));
225  std::vector<Phase2TrackerDigi>& digis = sorted_and_merged.back().data;
226  // first count how many digis we have
227  size_t len = it->length;
228  for (it2 = it + 1; (it2 != end) && (it2->detid == it->detid); ++it2) {
229  len += it2->length;
230  }
231  // reserve memory
232  digis.reserve(len);
233  // push them in
234  for (it2 = it + 0; (it2 != end) && (it2->detid == it->detid); ++it2) {
235  digis.insert(digis.end(), &proc_work_digis_[it2->index], &proc_work_digis_[it2->index + it2->length]);
236  }
237  it = it2;
238  }
239 
240  edm::DetSetVector<Phase2TrackerDigi> proc_raw_dsv(sorted_and_merged, true);
241  pr->swap(proc_raw_dsv);
242  event.put(std::unique_ptr<edm::DetSetVector<Phase2TrackerDigi>>(pr), "ProcessedRaw");
243  delete buffer;
244  }
245  }
246  }
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
void fedIndex(uint32_t aFedIndex, uint16_t &aFedId, uint16_t &aFedChannel)
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
edm::EDGetTokenT< FEDRawDataCollection > token_
void swap(DetSetVector &other)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
#define LogTrace(id)
uint32_t getDetid() const
static const int MAX_CBC_PER_FE
Definition: utils.h:25
std::vector< Phase2TrackerDigi > proc_work_digis_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
string end
Definition: dataset.py:937
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 40 of file Phase2TrackerDigiProducer.cc.

Referenced by beginRun(), and produce().

uint32_t Phase2Tracker::Phase2TrackerDigiProducer::cacheId_
private

Definition at line 41 of file Phase2TrackerDigiProducer.cc.

DetIdCollection Phase2Tracker::Phase2TrackerDigiProducer::detids_
private

Definition at line 42 of file Phase2TrackerDigiProducer.cc.

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

Definition at line 59 of file Phase2TrackerDigiProducer.cc.

Referenced by produce().

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

Definition at line 58 of file Phase2TrackerDigiProducer.cc.

Referenced by produce().

unsigned int Phase2Tracker::Phase2TrackerDigiProducer::runNumber_
private

Definition at line 38 of file Phase2TrackerDigiProducer.cc.

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

Definition at line 39 of file Phase2TrackerDigiProducer.cc.

Referenced by Phase2TrackerDigiProducer(), and produce().