CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
Phase2Tracker::Phase2TrackerDigiProducer Class Reference
Inheritance diagram for Phase2Tracker::Phase2TrackerDigiProducer:
edm::stream::EDProducer<>

Classes

class  Registry
 

Public Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 Phase2TrackerDigiProducer (const edm::ParameterSet &pset)
 constructor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~Phase2TrackerDigiProducer () override=default
 default constructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 25 of file Phase2TrackerDigiProducer.cc.

Constructor & Destructor Documentation

◆ Phase2TrackerDigiProducer()

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

constructor

Definition at line 70 of file Phase2TrackerDigiProducer.cc.

References muonDTDigis_cfi::pset, and token_.

71  : ph2CablingESToken_(esConsumes<edm::Transition::BeginRun>()), runNumber_(0), cabling_(nullptr), cacheId_(0) {
72  // define product
73  produces<edm::DetSetVector<Phase2TrackerDigi>>("ProcessedRaw");
74  token_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("ProductLabel"));
75  }
edm::EDGetTokenT< FEDRawDataCollection > token_
const edm::ESGetToken< Phase2TrackerCabling, Phase2TrackerCablingRcd > ph2CablingESToken_

◆ ~Phase2TrackerDigiProducer()

Phase2Tracker::Phase2TrackerDigiProducer::~Phase2TrackerDigiProducer ( )
overridedefault

default constructor

Member Function Documentation

◆ beginRun()

void Phase2Tracker::Phase2TrackerDigiProducer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
override

Definition at line 77 of file Phase2TrackerDigiProducer.cc.

References cabling_, edm::EventSetup::getData(), and ph2CablingESToken_.

77  {
78  // fetch cabling from event setup
79  cabling_ = &es.getData(ph2CablingESToken_);
80  }
const edm::ESGetToken< Phase2TrackerCabling, Phase2TrackerCablingRcd > ph2CablingESToken_

◆ produce()

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

Definition at line 82 of file Phase2TrackerDigiProducer.cc.

References edmScanValgrind::buffer, cabling_, Phase2Tracker::Phase2TrackerFEDHeader::CBCStatus(), Phase2Tracker::CMS_FED_ID_MAX, FEDRawData::data(), TauDecayModes::dec, Phase2Tracker::FED_ID_MIN, FEDRawDataCollection::FEDData(), sistrip::SpyUtilities::fedIndex(), Phase2TrackerCabling::findFedCh(), Phase2Tracker::Phase2TrackerFEDHeader::frontendStatus(), Phase2Tracker::Phase2TrackerFEDHeader::getConditionData(), Phase2Tracker::Phase2TrackerFEDHeader::getDataFormatVersion(), Phase2Tracker::Phase2TrackerFEDHeader::getDataType(), Phase2Tracker::Phase2TrackerFEDHeader::getDebugMode(), 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(), jetsAK4_CHS_cff::sort, contentValuesCheck::ss, Phase2Tracker::Phase2TrackerFEDRawChannelUnpacker::stripIndex(), Phase2Tracker::Phase2TrackerFEDRawChannelUnpacker::stripOn(), Phase2Tracker::STRIPS_PER_CBC, and token_.

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

◆ cabling_

const Phase2TrackerCabling* Phase2Tracker::Phase2TrackerDigiProducer::cabling_
private

Definition at line 39 of file Phase2TrackerDigiProducer.cc.

Referenced by beginRun(), and produce().

◆ cacheId_

uint32_t Phase2Tracker::Phase2TrackerDigiProducer::cacheId_
private

Definition at line 40 of file Phase2TrackerDigiProducer.cc.

◆ detids_

DetIdCollection Phase2Tracker::Phase2TrackerDigiProducer::detids_
private

Definition at line 41 of file Phase2TrackerDigiProducer.cc.

◆ ph2CablingESToken_

const edm::ESGetToken<Phase2TrackerCabling, Phase2TrackerCablingRcd> Phase2Tracker::Phase2TrackerDigiProducer::ph2CablingESToken_
private

Definition at line 35 of file Phase2TrackerDigiProducer.cc.

Referenced by beginRun().

◆ proc_work_digis_

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

Definition at line 58 of file Phase2TrackerDigiProducer.cc.

Referenced by produce().

◆ proc_work_registry_

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

Definition at line 57 of file Phase2TrackerDigiProducer.cc.

Referenced by produce().

◆ runNumber_

unsigned int Phase2Tracker::Phase2TrackerDigiProducer::runNumber_
private

Definition at line 37 of file Phase2TrackerDigiProducer.cc.

◆ token_

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

Definition at line 38 of file Phase2TrackerDigiProducer.cc.

Referenced by Phase2TrackerDigiProducer(), and produce().