CMS 3D CMS Logo

SiStripDigiToRawModule.cc
Go to the documentation of this file.
2 #include "SiStripDigiToRaw.h"
3 
16 #include <cstdlib>
17 
18 namespace sistrip {
19 
20  //fill Descriptions needed to define default parameters
23  desc.add<std::string>("FedReadoutMode", "ZERO_SUPPRESSED");
24  desc.add<std::string>("PacketCode", "ZERO_SUPPRESSED");
25  desc.add<bool>("UseFedKey", false);
26  desc.add<bool>("UseWrongDigiType", false);
27  desc.add<bool>("CopyBufferHeader", false);
28  desc.add<edm::InputTag>("InputDigis", edm::InputTag("simSiStripDigis", "ZeroSuppressed"));
29  desc.add<edm::InputTag>("RawDataTag", edm::InputTag("rawDataCollector"));
30  descriptions.add("SiStripDigiToRawModule",desc);
31  }
32 
33  // -----------------------------------------------------------------------------
38  copyBufferHeader_(pset.getParameter<bool>("CopyBufferHeader")),
39  mode_( fedReadoutModeFromString(pset.getParameter<std::string>( "FedReadoutMode" ))),
40  packetCode_(packetCodeFromString(pset.getParameter<std::string>("PacketCode"), mode_)),
41  rawdigi_( false ),
43  eventCounter_(0),
44  inputDigiTag_(pset.getParameter<edm::InputTag>("InputDigis")),
45  rawDataTag_(pset.getParameter<edm::InputTag>("RawDataTag"))
46  {
47  if ( edm::isDebugEnabled() ) {
48  LogDebug("DigiToRawModule")
49  << "[sistrip::DigiToRawModule::DigiToRawModule]"
50  << " Constructing object...";
51  }
52 
53 
54  switch(mode_) {
55  case READOUT_MODE_ZERO_SUPPRESSED: rawdigi_ = false; break;
56  case READOUT_MODE_ZERO_SUPPRESSED_FAKE: rawdigi_ = false; break;
57  case READOUT_MODE_ZERO_SUPPRESSED_LITE10: rawdigi_ = false; break;
59  case READOUT_MODE_ZERO_SUPPRESSED_LITE8: rawdigi_ = false; break;
65  case READOUT_MODE_PREMIX_RAW: rawdigi_ = false; break;
66  case READOUT_MODE_VIRGIN_RAW: rawdigi_ = true; break;
67  case READOUT_MODE_PROC_RAW: rawdigi_ = true; break;
68  case READOUT_MODE_SCOPE: rawdigi_ = true; break;
69  case READOUT_MODE_INVALID: {
70  if( edm::isDebugEnabled()) {
71  edm::LogWarning("DigiToRawModule")
72  << "[sistrip::DigiToRawModule::DigiToRawModule]"
73  << " UNKNOWN readout mode: " << pset.getParameter<std::string>("FedReadoutMode");
74  }} break;
75  case READOUT_MODE_SPY: {
76  if( edm::isDebugEnabled()) {
77  edm::LogWarning("DigiToRawModule")
78  << "[sistrip::DigiToRawModule::DigiToRawModule]"
79  << " Digi to raw is not supported for spy channel data";
80  }} break;
81  }
82  if(pset.getParameter<bool>("UseWrongDigiType")) {
83  rawdigi_ = !rawdigi_;
84  if( edm::isDebugEnabled()) {
85  edm::LogWarning("DigiToRawModule")
86  << "[sistrip::DigiToRawModule::DigiToRawModule]"
87  << " You are using the wrong type of digis!";
88  }
89  }
90 
91  // Create instance of DigiToRaw formatter
92  digiToRaw_ = new DigiToRaw(mode_, packetCode_, pset.getParameter<bool>("UseFedKey"));
93 
94  if (rawdigi_) {
95  tokenRawDigi = consumes< edm::DetSetVector<SiStripRawDigi> >(inputDigiTag_);
96  } else {
97  tokenDigi = consumes< edm::DetSetVector<SiStripDigi> >(inputDigiTag_);
98  }
99  if (copyBufferHeader_){
100  //CAMM input raw module label or same as digi ????
101  if( edm::isDebugEnabled()) {
102  edm::LogWarning("DigiToRawModule")
103  << "[sistrip::DigiToRawModule::DigiToRawModule]"
104  << "Copying buffer header from collection " << rawDataTag_;
105  }
106  tokenRawBuffer = consumes<FEDRawDataCollection>(rawDataTag_);
107  }
108 
109  produces<FEDRawDataCollection>();
110 
111  }
112 
113  // -----------------------------------------------------------------------------
116  if ( edm::isDebugEnabled() ) {
117  LogDebug("DigiToRaw")
118  << "[sistrip::DigiToRawModule::~DigiToRawModule]"
119  << " Destructing object...";
120  }
121  if ( digiToRaw_ ) delete digiToRaw_;
122  }
123 
124  // -----------------------------------------------------------------------------
132  const edm::EventSetup& iSetup ) {
133 
134  eventCounter_++;
135 
136  auto buffers = std::make_unique<FEDRawDataCollection>();
137 
139  iSetup.get<SiStripFedCablingRcd>().get( cabling );
140 
141  //get buffer header from original rawdata
143  if (copyBufferHeader_){
144  if( edm::isDebugEnabled()) {
145  edm::LogWarning("DigiToRawModule")
146  << "[sistrip::DigiToRawModule::DigiToRawModule]"
147  << "Getting raw buffer: ";
148  }
149  try {
150  iEvent.getByToken( tokenRawBuffer, rawbuffers );
151  } catch (const cms::Exception& e){
152  if( edm::isDebugEnabled()) {
153  edm::LogWarning("DigiToRawModule")
154  << "[sistrip::DigiToRawModule::DigiToRawModule]"
155  << " Failed to get collection " << rawDataTag_;
156  }
157  }
158  }
159 
160  if( rawdigi_ ) {
162  iEvent.getByToken( tokenRawDigi, rawdigis );
163  if (copyBufferHeader_) digiToRaw_->createFedBuffers( iEvent, cabling, rawbuffers, rawdigis, buffers );
164  else digiToRaw_->createFedBuffers( iEvent, cabling, rawdigis, buffers );
165  } else {
167  iEvent.getByToken( tokenDigi, digis );
168  if (copyBufferHeader_) digiToRaw_->createFedBuffers( iEvent, cabling, rawbuffers, digis, buffers );
169  else digiToRaw_->createFedBuffers( iEvent, cabling, digis, buffers );
170  }
171 
172 
173  iEvent.put(std::move(buffers));
174 
175  }
176 
178  {
180  }
181 }
182 
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
Input: edm::DetSetVector<SiStripDigi>. Output: FEDRawDataCollection.
edm::EDGetTokenT< FEDRawDataCollection > tokenRawBuffer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
#define nullptr
uint8_t packetCodeFromString(const std::string &packetCodeString, FEDReadoutMode mode)
void printWarningSummary() const
sistrip classes
FEDReadoutMode fedReadoutModeFromString(const std::string &readoutModeString)
DigiToRawModule(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void createFedBuffers(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
T get() const
Definition: EventSetup.h:71
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > tokenDigi
void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > tokenRawDigi
def move(src, dest)
Definition: eostools.py:511