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 29 of file SiStripDigiToRaw.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file SiStripDigiToRaw.cc.

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

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

Definition at line 37 of file SiStripDigiToRaw.cc.

References edm::isDebugEnabled(), and LogDebug.

37  {
38  if ( edm::isDebugEnabled() ) {
39  LogDebug("DigiToRaw")
40  << "[sistrip::DigiToRaw::~DigiToRaw]"
41  << " Destructing object...";
42  }
43  }
#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 54 of file SiStripDigiToRaw.cc.

References runEdmFileComparison::collection, and createFedBuffers_().

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

57  {
58  createFedBuffers_(event, cabling, collection, buffers, true);
59  }
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 61 of file SiStripDigiToRaw.cc.

References runEdmFileComparison::collection, and createFedBuffers_().

64  {
65  createFedBuffers_(event, cabling, collection, buffers, false);
66  }
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 69 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(), combine::key, mode_, sistrip::READOUT_MODE_SCOPE, sistrip::FEDBufferGenerator::setL1ID(), strip(), STRIP(), sistrip::STRIPS_PER_FEDCH, useFedKey_, and relativeConstraints::value.

Referenced by createFedBuffers().

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

Definition at line 45 of file SiStripDigiToRaw.h.

References alignBH_cfg::mode, and mode_.

45 { 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 165 of file SiStripDigiToRaw.cc.

Referenced by createFedBuffers_().

165 {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 166 of file SiStripDigiToRaw.cc.

References begin.

166 {return it-begin;}
#define begin
Definition: vmac.h:31

Member Data Documentation

FEDBufferGenerator sistrip::DigiToRaw::bufferGenerator_
private

Definition at line 60 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), and DigiToRaw().

FEDReadoutMode sistrip::DigiToRaw::mode_
private

Definition at line 58 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_(), DigiToRaw(), and fedReadoutMode().

bool sistrip::DigiToRaw::useFedKey_
private

Definition at line 59 of file SiStripDigiToRaw.h.

Referenced by createFedBuffers_().