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),
42  digiToRaw_(nullptr),
43  eventCounter_(0),
44  inputDigiTag_(pset.getParameter<edm::InputTag>("InputDigis")),
45  rawDataTag_(pset.getParameter<edm::InputTag>("RawDataTag")) {
46  if (edm::isDebugEnabled()) {
47  LogDebug("DigiToRawModule") << "[sistrip::DigiToRawModule::DigiToRawModule]"
48  << " Constructing object...";
49  }
50 
51  switch (mode_) {
53  rawdigi_ = false;
54  break;
56  rawdigi_ = false;
57  break;
59  rawdigi_ = false;
60  break;
62  rawdigi_ = false;
63  break;
65  rawdigi_ = false;
66  break;
68  rawdigi_ = false;
69  break;
71  rawdigi_ = false;
72  break;
74  rawdigi_ = false;
75  break;
77  rawdigi_ = false;
78  break;
80  rawdigi_ = false;
81  break;
83  rawdigi_ = false;
84  break;
86  rawdigi_ = true;
87  break;
89  rawdigi_ = true;
90  break;
91  case READOUT_MODE_SCOPE:
92  rawdigi_ = true;
93  break;
94  case READOUT_MODE_INVALID: {
95  if (edm::isDebugEnabled()) {
96  edm::LogWarning("DigiToRawModule")
97  << "[sistrip::DigiToRawModule::DigiToRawModule]"
98  << " UNKNOWN readout mode: " << pset.getParameter<std::string>("FedReadoutMode");
99  }
100  } break;
101  case READOUT_MODE_SPY: {
102  if (edm::isDebugEnabled()) {
103  edm::LogWarning("DigiToRawModule") << "[sistrip::DigiToRawModule::DigiToRawModule]"
104  << " Digi to raw is not supported for spy channel data";
105  }
106  } break;
107  }
108  if (pset.getParameter<bool>("UseWrongDigiType")) {
109  rawdigi_ = !rawdigi_;
110  if (edm::isDebugEnabled()) {
111  edm::LogWarning("DigiToRawModule") << "[sistrip::DigiToRawModule::DigiToRawModule]"
112  << " You are using the wrong type of digis!";
113  }
114  }
115 
116  // Create instance of DigiToRaw formatter
117  digiToRaw_ = new DigiToRaw(mode_, packetCode_, pset.getParameter<bool>("UseFedKey"));
118 
119  if (rawdigi_) {
120  tokenRawDigi = consumes<edm::DetSetVector<SiStripRawDigi> >(inputDigiTag_);
121  } else {
122  tokenDigi = consumes<edm::DetSetVector<SiStripDigi> >(inputDigiTag_);
123  }
124  if (copyBufferHeader_) {
125  //CAMM input raw module label or same as digi ????
126  if (edm::isDebugEnabled()) {
127  edm::LogWarning("DigiToRawModule") << "[sistrip::DigiToRawModule::DigiToRawModule]"
128  << "Copying buffer header from collection " << rawDataTag_;
129  }
130  tokenRawBuffer = consumes<FEDRawDataCollection>(rawDataTag_);
131  }
132 
133  produces<FEDRawDataCollection>();
134  }
135 
136  // -----------------------------------------------------------------------------
139  if (edm::isDebugEnabled()) {
140  LogDebug("DigiToRaw") << "[sistrip::DigiToRawModule::~DigiToRawModule]"
141  << " Destructing object...";
142  }
143  if (digiToRaw_)
144  delete digiToRaw_;
145  }
146 
147  // -----------------------------------------------------------------------------
155  eventCounter_++;
156 
157  auto buffers = std::make_unique<FEDRawDataCollection>();
158 
160  iSetup.get<SiStripFedCablingRcd>().get(cabling);
161 
162  //get buffer header from original rawdata
164  if (copyBufferHeader_) {
165  if (edm::isDebugEnabled()) {
166  edm::LogWarning("DigiToRawModule") << "[sistrip::DigiToRawModule::DigiToRawModule]"
167  << "Getting raw buffer: ";
168  }
169  try {
170  iEvent.getByToken(tokenRawBuffer, rawbuffers);
171  } catch (const cms::Exception& e) {
172  if (edm::isDebugEnabled()) {
173  edm::LogWarning("DigiToRawModule") << "[sistrip::DigiToRawModule::DigiToRawModule]"
174  << " Failed to get collection " << rawDataTag_;
175  }
176  }
177  }
178 
179  if (rawdigi_) {
181  iEvent.getByToken(tokenRawDigi, rawdigis);
182  if (copyBufferHeader_)
183  digiToRaw_->createFedBuffers(iEvent, cabling, rawbuffers, rawdigis, buffers);
184  else
185  digiToRaw_->createFedBuffers(iEvent, cabling, rawdigis, buffers);
186  } else {
188  iEvent.getByToken(tokenDigi, digis);
189  if (copyBufferHeader_)
190  digiToRaw_->createFedBuffers(iEvent, cabling, rawbuffers, digis, buffers);
191  else
192  digiToRaw_->createFedBuffers(iEvent, cabling, digis, buffers);
193  }
194 
195  iEvent.put(std::move(buffers));
196  }
197 
199 } // namespace sistrip
ConfigurationDescriptions.h
Handle.h
sistrip::DigiToRaw::createFedBuffers
void createFedBuffers(edm::Event &, edm::ESHandle< SiStripFedCabling > &cabling, edm::Handle< edm::DetSetVector< SiStripDigi > > &digis, std::unique_ptr< FEDRawDataCollection > &buffers)
Definition: SiStripDigiToRaw.cc:53
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
sistrip::READOUT_MODE_PREMIX_RAW
Definition: SiStripFEDBufferComponents.h:61
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
ESHandle.h
DigiToRaw_cff.DigiToRaw
DigiToRaw
Definition: DigiToRaw_cff.py:22
sistrip::DigiToRawModule::copyBufferHeader_
bool copyBufferHeader_
Definition: SiStripDigiToRawModule.h:43
sistrip::packetCodeFromString
uint8_t packetCodeFromString(const std::string &packetCodeString, FEDReadoutMode mode)
Definition: SiStripFEDBufferComponents.cc:464
sistrip::READOUT_MODE_SCOPE
Definition: SiStripFEDBufferComponents.h:47
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
sistrip::READOUT_MODE_SPY
Definition: SiStripFEDBufferComponents.h:60
sistrip::fedReadoutModeFromString
FEDReadoutMode fedReadoutModeFromString(const std::string &readoutModeString)
Definition: SiStripFEDBufferComponents.cc:418
edm::Handle
Definition: AssociativeIterator.h:50
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT
Definition: SiStripFEDBufferComponents.h:51
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:50
sistrip::DigiToRawModule::inputDigiTag_
edm::InputTag inputDigiTag_
Definition: SiStripDigiToRawModule.h:49
sistrip::DigiToRawModule::packetCode_
uint8_t packetCode_
Definition: SiStripDigiToRawModule.h:45
SiStripFedCablingRcd
Definition: SiStripCondDataRecords.h:22
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
SiStripDigiToRaw.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiStripDigiToRawModule.h
sistrip::DigiToRawModule::DigiToRawModule
DigiToRawModule(const edm::ParameterSet &)
Definition: SiStripDigiToRawModule.cc:37
edm::ESHandle< SiStripFedCabling >
sistrip::READOUT_MODE_PROC_RAW
Definition: SiStripFEDBufferComponents.h:52
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8
Definition: SiStripFEDBufferComponents.h:58
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:59
ParameterSetDescription.h
EDGetToken.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10
Definition: SiStripFEDBufferComponents.h:49
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:53
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT
Definition: SiStripFEDBufferComponents.h:55
sistrip::DigiToRawModule::rawDataTag_
edm::InputTag rawDataTag_
Definition: SiStripDigiToRawModule.h:52
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
sistrip::READOUT_MODE_VIRGIN_RAW
Definition: SiStripFEDBufferComponents.h:48
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
sistrip::READOUT_MODE_INVALID
Definition: SiStripFEDBufferComponents.h:46
sistrip::DigiToRawModule::tokenDigi
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > tokenDigi
Definition: SiStripDigiToRawModule.h:51
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
sistrip::DigiToRawModule::rawdigi_
bool rawdigi_
Definition: SiStripDigiToRawModule.h:46
sistrip::DigiToRawModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiStripDigiToRawModule.cc:21
sistrip::DigiToRawModule::mode_
FEDReadoutMode mode_
Definition: SiStripDigiToRawModule.h:44
sistrip::DigiToRawModule::tokenRawDigi
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > tokenRawDigi
Definition: SiStripDigiToRawModule.h:50
sistrip::DigiToRawModule::digiToRaw_
DigiToRaw * digiToRaw_
Definition: SiStripDigiToRawModule.h:47
EventSetup.h
SiStripFedCablingRcd.h
sistrip::DigiToRaw::printWarningSummary
void printWarningSummary() const
Definition: SiStripDigiToRaw.h:59
edm::isDebugEnabled
bool isDebugEnabled()
Definition: MessageLogger.cc:71
sistrip::DigiToRawModule::~DigiToRawModule
~DigiToRawModule() override
Definition: SiStripDigiToRawModule.cc:138
cms::Exception
Definition: Exception.h:70
ParameterSet.h
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
edm::Event
Definition: Event.h:73
sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_CMOVERRIDE
Definition: SiStripFEDBufferComponents.h:54
edm::InputTag
Definition: InputTag.h:15
sistrip::READOUT_MODE_ZERO_SUPPRESSED_FAKE
Definition: SiStripFEDBufferComponents.h:57
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
sistrip::DigiToRawModule::endStream
void endStream() override
Definition: SiStripDigiToRawModule.cc:198
sistrip::DigiToRawModule::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: SiStripDigiToRawModule.cc:154
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
sistrip::READOUT_MODE_ZERO_SUPPRESSED
Definition: SiStripFEDBufferComponents.h:56
sistrip::DigiToRawModule::eventCounter_
uint32_t eventCounter_
Definition: SiStripDigiToRawModule.h:48
sistrip::DigiToRawModule::tokenRawBuffer
edm::EDGetTokenT< FEDRawDataCollection > tokenRawBuffer
Definition: SiStripDigiToRawModule.h:53