CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::DigiToRaw Class Reference

Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection. More...

#include <SiStripDigiToRaw.h>

Public Member Functions

void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
 
void createFedBuffers (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripRawDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
 
 DigiToRaw (FEDReadoutMode, bool use_fed_key)
 
void fedReadoutMode (FEDReadoutMode mode)
 
 ~DigiToRaw ()
 

Private Member Functions

template<class Digi_t >
void createFedBuffers_ (edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
 
uint16_t STRIP (const edm::DetSet< SiStripDigi >::const_iterator &it, const edm::DetSet< SiStripDigi >::const_iterator &begin) const
 
uint16_t STRIP (const edm::DetSet< SiStripRawDigi >::const_iterator &it, const edm::DetSet< SiStripRawDigi >::const_iterator &begin) const
 

Private Attributes

FEDBufferGenerator bufferGenerator_
 
FEDReadoutMode mode_
 
bool useFedKey_
 

Detailed Description

Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection.

Definition at line 28 of file SiStripDigiToRaw.h.

Constructor & Destructor Documentation

sistrip::DigiToRaw::DigiToRaw ( FEDReadoutMode  mode,
bool  use_fed_key 
)

Definition at line 20 of file SiStripDigiToRaw.cc.

References bufferGenerator_, edm::isDebugEnabled(), LogDebug, mode_, and sistrip::FEDBufferGenerator::setReadoutMode().

21  :
22  mode_(mode),
23  useFedKey_(useFedKey),
25  {
26  if ( edm::isDebugEnabled() ) {
27  LogDebug("DigiToRaw")
28  << "[sistrip::DigiToRaw::DigiToRaw]"
29  << " Constructing object...";
30  }
32  }
#define LogDebug(id)
bool isDebugEnabled()
FEDBufferGenerator & setReadoutMode(const FEDReadoutMode newReadoutMode)
FEDReadoutMode mode_
FEDBufferGenerator bufferGenerator_
sistrip::DigiToRaw::~DigiToRaw ( )

Definition at line 36 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

36  {
37  if ( edm::isDebugEnabled() ) {
38  LogDebug("DigiToRaw")
39  << "[sistrip::DigiToRaw::~DigiToRaw]"
40  << " Destructing object...";
41  }
42  }
#define LogDebug(id)
bool isDebugEnabled()

Member Function Documentation

void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripDigi > > &  collection,
std::auto_ptr< FEDRawDataCollection > &  buffers 
)

Input: DetSetVector of SiStripDigis. Output: FEDRawDataCollection. Retrieves and iterates through FED buffers, extract FEDRawData from collection and (optionally) dumps raw data to stdout, locates start of FED buffer by identifying DAQ header, creates new Fed9UEvent object using current FEDRawData buffer, dumps FED buffer to stdout, retrieves data from various header fields

Definition at line 53 of file SiStripDigiToRaw.cc.

References runEdmFileComparison::collection, and createFedBuffers_().

Referenced by sistrip::DigiToRawModule::produce().

56  {
57  createFedBuffers_(event, cabling, collection, buffers, true);
58  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
void sistrip::DigiToRaw::createFedBuffers ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< SiStripRawDigi > > &  digis,
std::auto_ptr< FEDRawDataCollection > &  buffers 
)

Definition at line 60 of file SiStripDigiToRaw.cc.

References runEdmFileComparison::collection, and createFedBuffers_().

63  {
64  createFedBuffers_(event, cabling, collection, buffers, false);
65  }
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
template<class Digi_t >
void sistrip::DigiToRaw::createFedBuffers_ ( edm::Event event,
edm::ESHandle< SiStripFedCabling > &  cabling,
edm::Handle< edm::DetSetVector< Digi_t > > &  digis,
std::auto_ptr< FEDRawDataCollection > &  buffers,
bool  zeroSuppressed 
)
private

Definition at line 68 of file SiStripDigiToRaw.cc.

References bufferGenerator_, runEdmFileComparison::collection, edm::DetSet< T >::data, alignCSCRings::e, edm::EventID::event(), cppFunctionSkipper::exception, sistrip::FEDBufferGenerator::generateBuffer(), edm::EventBase::id(), sistrip::invalid32_, sistrip::invalid_, edm::isDebugEnabled(), relval_steps::key, mode_, sistrip::READOUT_MODE_PREMIX_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::FEDBufferGenerator::setL1ID(), contentValuesCheck::ss, STRIP(), sistrip::STRIPS_PER_FEDCH, useFedKey_, and relativeConstraints::value.

Referenced by createFedBuffers().

72  {
73  try {
74 
75  //set the L1ID to use in the buffers
76  bufferGenerator_.setL1ID(0xFFFFFF & event.id().event());
77 
78  auto fed_ids = cabling->fedIds();
79  for ( auto ifed = fed_ids.begin(); ifed != fed_ids.end(); ++ifed ) {
80 
81  auto conns = cabling->fedConnections(*ifed);
82 
83  //for special mode premix raw, data is zero-suppressed but not converted to 8 bit
84  //zeroSuppressed here means converted to 8 bit...
85  if (mode_ == READOUT_MODE_PREMIX_RAW) zeroSuppressed=false;
86  FEDStripData fedData(zeroSuppressed);
87 
88  for (auto iconn = conns.begin() ; iconn != conns.end(); iconn++ ) {
89 
90  // Determine FED key from cabling
91  uint32_t fed_key = ( ( iconn->fedId() & sistrip::invalid_ ) << 16 ) | ( iconn->fedCh() & sistrip::invalid_ );
92 
93  // Determine whether DetId or FED key should be used to index digi containers
94  uint32_t key = ( useFedKey_ || mode_ == READOUT_MODE_SCOPE ) ? fed_key : iconn->detId();
95 
96  // Check key is non-zero and valid
97  if ( !key || ( key == sistrip::invalid32_ ) ) { continue; }
98 
99  // Determine APV pair number (needed only when using DetId)
100  uint16_t ipair = ( useFedKey_ || mode_ == READOUT_MODE_SCOPE ) ? 0 : iconn->apvPairNumber();
101 
102  FEDStripData::ChannelData& chanData = fedData[iconn->fedCh()];
103 
104  // Find digis for DetID in collection
105  typename std::vector< edm::DetSet<Digi_t> >::const_iterator digis = collection->find( key );
106  if (digis == collection->end()) { continue; }
107 
108  typename edm::DetSet<Digi_t>::const_iterator idigi, digis_begin(digis->data.begin());
109  for ( idigi = digis_begin; idigi != digis->data.end(); idigi++ ) {
110 
111  if ( STRIP(idigi, digis_begin) < ipair*256 ||
112  STRIP(idigi, digis_begin) > ipair*256+255 ) { continue; }
113  const unsigned short strip = STRIP(idigi, digis_begin) % 256;
114 
115  if ( strip >= STRIPS_PER_FEDCH ) {
116  if ( edm::isDebugEnabled() ) {
117  std::stringstream ss;
118  ss << "[sistrip::DigiToRaw::createFedBuffers]"
119  << " strip >= strips_per_fedCh";
120  edm::LogWarning("DigiToRaw") << ss.str();
121  }
122  continue;
123  }
124 
125  // check if value already exists
126  if ( edm::isDebugEnabled() ) {
127  const uint16_t value = 0;//chanData[strip];
128  if ( value && value != (*idigi).adc() ) {
129  std::stringstream ss;
130  ss << "[sistrip::DigiToRaw::createFedBuffers]"
131  << " Incompatible ADC values in buffer!"
132  << " FedId/FedCh: " << *ifed << "/" << iconn->fedCh()
133  << " DetStrip: " << STRIP(idigi, digis_begin)
134  << " FedChStrip: " << strip
135  << " AdcValue: " << (*idigi).adc()
136  << " RawData[" << strip << "]: " << value;
137  edm::LogWarning("DigiToRaw") << ss.str();
138  }
139  }
140 
141  // Add digi to buffer
142  chanData[strip] = (*idigi).adc();
143 
144  }
145  // if ((*idigi).strip() >= (ipair+1)*256) break;
146  }
147 
148  //create the buffer
149  FEDRawData& fedrawdata = buffers->FEDData( *ifed );
150  bufferGenerator_.generateBuffer(&fedrawdata,fedData,*ifed);
151 
152  }
153  }
154  catch (const std::exception& e) {
155  if ( edm::isDebugEnabled() ) {
156  edm::LogWarning("DigiToRaw")
157  << "DigiToRaw::createFedBuffers] "
158  << "Exception caught : " << e.what();
159  }
160  }
161 
162  }
EventNumber_t event() const
Definition: EventID.h:41
bool isDebugEnabled()
void generateBuffer(FEDRawData *rawDataObject, const FEDStripData &data, const uint16_t sourceID) const
static const uint32_t invalid32_
Definition: Constants.h:15
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
FEDReadoutMode mode_
static const uint16_t STRIPS_PER_FEDCH
FEDBufferGenerator & setL1ID(const uint32_t newL1ID)
static const uint16_t invalid_
Definition: Constants.h:16
edm::EventID id() const
Definition: EventBase.h:60
collection_type data
Definition: DetSet.h:78
uint16_t STRIP(const edm::DetSet< SiStripDigi >::const_iterator &it, const edm::DetSet< SiStripDigi >::const_iterator &begin) const
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
FEDBufferGenerator bufferGenerator_
void sistrip::DigiToRaw::fedReadoutMode ( FEDReadoutMode  mode)
inline

Definition at line 44 of file SiStripDigiToRaw.h.

References alignBH_cfg::mode.

44 { mode_ = mode; }
FEDReadoutMode mode_
uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripDigi >::const_iterator &  it,
const edm::DetSet< SiStripDigi >::const_iterator &  begin 
) const
inlineprivate

Definition at line 164 of file SiStripDigiToRaw.cc.

Referenced by createFedBuffers_().

164 {return it->strip();}
uint16_t sistrip::DigiToRaw::STRIP ( const edm::DetSet< SiStripRawDigi >::const_iterator &  it,
const edm::DetSet< SiStripRawDigi >::const_iterator &  begin 
) const
inlineprivate

Definition at line 165 of file SiStripDigiToRaw.cc.

References begin.

165 {return it-begin;}
#define begin
Definition: vmac.h:30

Member Data Documentation

FEDBufferGenerator sistrip::DigiToRaw::bufferGenerator_
private

Definition at line 59 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

FEDReadoutMode sistrip::DigiToRaw::mode_
private

Definition at line 57 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

bool sistrip::DigiToRaw::useFedKey_
private

Definition at line 58 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().