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

virtual void beginJob () override
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void endJob () override
 
 Phase2TrackerDigiProducer (const edm::ParameterSet &pset)
 constructor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~Phase2TrackerDigiProducer ()
 default constructor 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
 
 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 & itemsToGetFromEvent () 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

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
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 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_.

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

default constructor

Definition at line 35 of file Phase2TrackerDigiProducer.cc.

36  {
37  }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 39 of file Phase2TrackerDigiProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 43 of file Phase2TrackerDigiProducer.cc.

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

44  {
45  // fetch cabling from event setup
47  es.get<Phase2TrackerCablingRcd>().get( c );
48  cabling_ = c.product();
49  }
T const * product() const
Definition: ESHandle.h:86
void Phase2Tracker::Phase2TrackerDigiProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 51 of file Phase2TrackerDigiProducer.cc.

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

Definition at line 55 of file Phase2TrackerDigiProducer.cc.

References 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(), 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().

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

Referenced by beginRun(), and produce().

uint32_t Phase2Tracker::Phase2TrackerDigiProducer::cacheId_
private

Definition at line 40 of file Phase2TrackerDigiProducer.h.

DetIdCollection Phase2Tracker::Phase2TrackerDigiProducer::detids_
private

Definition at line 41 of file Phase2TrackerDigiProducer.h.

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

Definition at line 56 of file Phase2TrackerDigiProducer.h.

Referenced by produce().

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

Definition at line 55 of file Phase2TrackerDigiProducer.h.

Referenced by produce().

unsigned int Phase2Tracker::Phase2TrackerDigiProducer::runNumber_
private

Definition at line 37 of file Phase2TrackerDigiProducer.h.

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

Definition at line 38 of file Phase2TrackerDigiProducer.h.

Referenced by Phase2TrackerDigiProducer(), and produce().