test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripDigiToRaw.cc
Go to the documentation of this file.
1 
2 #include "SiStripDigiToRaw.h"
12 #include <iostream>
13 #include <sstream>
14 #include <vector>
15 
16 namespace sistrip {
17 
18  // -----------------------------------------------------------------------------
21  bool useFedKey ) :
22  mode_(mode),
23  useFedKey_(useFedKey),
24  bufferGenerator_()
25  {
26  if ( edm::isDebugEnabled() ) {
27  LogDebug("DigiToRaw")
28  << "[sistrip::DigiToRaw::DigiToRaw]"
29  << " Constructing object...";
30  }
32  }
33 
34  // -----------------------------------------------------------------------------
37  if ( edm::isDebugEnabled() ) {
38  LogDebug("DigiToRaw")
39  << "[sistrip::DigiToRaw::~DigiToRaw]"
40  << " Destructing object...";
41  }
42  }
43 
44  // -----------------------------------------------------------------------------
56  std::auto_ptr<FEDRawDataCollection>& buffers ) {
57  createFedBuffers_(event, cabling, collection, buffers, true);
58  }
59 
63  std::auto_ptr<FEDRawDataCollection>& buffers ) {
64  createFedBuffers_(event, cabling, collection, buffers, false);
65  }
66 
67  template<class Digi_t>
71  std::auto_ptr<FEDRawDataCollection>& buffers,
72  bool zeroSuppressed) {
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  FEDStripData fedData(zeroSuppressed);
84 
85  for (auto iconn = conns.begin() ; iconn != conns.end(); iconn++ ) {
86 
87  // Determine FED key from cabling
88  uint32_t fed_key = ( ( iconn->fedId() & sistrip::invalid_ ) << 16 ) | ( iconn->fedCh() & sistrip::invalid_ );
89 
90  // Determine whether DetId or FED key should be used to index digi containers
91  uint32_t key = ( useFedKey_ || mode_ == READOUT_MODE_SCOPE ) ? fed_key : iconn->detId();
92 
93  // Check key is non-zero and valid
94  if ( !key || ( key == sistrip::invalid32_ ) ) { continue; }
95 
96  // Determine APV pair number (needed only when using DetId)
97  uint16_t ipair = ( useFedKey_ || mode_ == READOUT_MODE_SCOPE ) ? 0 : iconn->apvPairNumber();
98 
99  FEDStripData::ChannelData& chanData = fedData[iconn->fedCh()];
100 
101  // Find digis for DetID in collection
102  typename std::vector< edm::DetSet<Digi_t> >::const_iterator digis = collection->find( key );
103  if (digis == collection->end()) { continue; }
104 
105  typename edm::DetSet<Digi_t>::const_iterator idigi, digis_begin(digis->data.begin());
106  for ( idigi = digis_begin; idigi != digis->data.end(); idigi++ ) {
107 
108  if ( STRIP(idigi, digis_begin) < ipair*256 ||
109  STRIP(idigi, digis_begin) > ipair*256+255 ) { continue; }
110  const unsigned short strip = STRIP(idigi, digis_begin) % 256;
111 
112  if ( strip >= STRIPS_PER_FEDCH ) {
113  if ( edm::isDebugEnabled() ) {
114  std::stringstream ss;
115  ss << "[sistrip::DigiToRaw::createFedBuffers]"
116  << " strip >= strips_per_fedCh";
117  edm::LogWarning("DigiToRaw") << ss.str();
118  }
119  continue;
120  }
121 
122  // check if value already exists
123  if ( edm::isDebugEnabled() ) {
124  const uint16_t value = 0;//chanData[strip];
125  if ( value && value != (*idigi).adc() ) {
126  std::stringstream ss;
127  ss << "[sistrip::DigiToRaw::createFedBuffers]"
128  << " Incompatible ADC values in buffer!"
129  << " FedId/FedCh: " << *ifed << "/" << iconn->fedCh()
130  << " DetStrip: " << STRIP(idigi, digis_begin)
131  << " FedChStrip: " << strip
132  << " AdcValue: " << (*idigi).adc()
133  << " RawData[" << strip << "]: " << value;
134  edm::LogWarning("DigiToRaw") << ss.str();
135  }
136  }
137 
138  // Add digi to buffer
139  chanData[strip] = (*idigi).adc();
140 
141  }
142  // if ((*idigi).strip() >= (ipair+1)*256) break;
143  }
144 
145  //create the buffer
146  FEDRawData& fedrawdata = buffers->FEDData( *ifed );
147  bufferGenerator_.generateBuffer(&fedrawdata,fedData,*ifed);
148 
149  }
150  }
151  catch (const std::exception& e) {
152  if ( edm::isDebugEnabled() ) {
153  edm::LogWarning("DigiToRaw")
154  << "DigiToRaw::createFedBuffers] "
155  << "Exception caught : " << e.what();
156  }
157  }
158 
159  }
160 
163 
164 }
165 
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:44
bool isDebugEnabled()
void generateBuffer(FEDRawData *rawDataObject, const FEDStripData &data, const uint16_t sourceID) const
void createFedBuffers_(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< Digi_t > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers, bool zeroSuppressed)
FEDBufferGenerator & setReadoutMode(const FEDReadoutMode newReadoutMode)
DigiToRaw(FEDReadoutMode, bool use_fed_key)
static const uint32_t invalid32_
Definition: Constants.h:15
void createFedBuffers(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::auto_ptr< FEDRawDataCollection > &buffers)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
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:56
collection_type data
Definition: DetSet.h:78
#define begin
Definition: vmac.h:30
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:33
FEDBufferGenerator bufferGenerator_