CMS 3D CMS Logo

SiStripSpyEventSummaryProducer.cc
Go to the documentation of this file.
1 //Class to produce a dummy SiStripEventSummary object so that spy channel data can be used with commissioning software.
2 //Run types which need additional parameters from the trigger FED buffer or DAQ registers are not supported.
3 //If an unsupported run type is used, an error message will be printed and parameters will be set to zero.
4 //Author: Nick Cripps
5 //Date: 10/05/2010
6 
23 #include <cstdint>
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 using edm::LogError;
29 using edm::LogInfo;
30 using edm::LogWarning;
31 
32 namespace sistrip {
33 
35  public:
37  void produce(edm::StreamID, edm::Event& event, const edm::EventSetup&) const override;
38 
39  private:
40  void warnAboutUnsupportedRunType() const;
41  static const char* const messageLabel_;
45  };
46 
47 } // namespace sistrip
48 
49 namespace sistrip {
50 
51  const char* const SpyEventSummaryProducer::messageLabel_ = "SiStripSpyEventSummaryProducer";
52 
54  : rawDataTag_(config.getParameter<edm::InputTag>("RawDataTag")),
55  runType_(sistrip::RunType(config.getParameter<uint32_t>("RunType"))) {
56  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
57  produces<SiStripEventSummary>();
59  }
60 
63 
64  //get the event number and Bx counter from the first valud FED buffer
66  event.getByToken(rawDataToken_, rawDataHandle);
67  const FEDRawDataCollection& rawData = *rawDataHandle;
68  bool fedFound = false;
69  uint32_t fedEventNumber = 0;
70  uint32_t fedBxNumber = 0;
71  for (uint16_t fedId = sistrip::FED_ID_MIN; fedId <= sistrip::FED_ID_MAX; ++fedId) {
72  const FEDRawData& fedData = rawData.FEDData(fedId);
73  if (fedData.size() && fedData.data()) {
74  const auto st_buffer = preconstructCheckFEDBufferBase(fedData);
75  if (sistrip::FEDBufferStatusCode::SUCCESS != st_buffer) {
76  LogInfo(messageLabel_) << "Skipping FED " << fedId << " because of exception: "
77  << "An exception of category 'FEDBuffer' occurred.\n"
78  << st_buffer;
79  continue;
80  }
81  const sistrip::FEDBufferBase buffer{fedData};
82  fedEventNumber = buffer.daqLvl1ID();
83  fedBxNumber = buffer.daqBXID();
84  fedFound = true;
85  break;
86  }
87  }
88  if (!fedFound) {
89  LogError(messageLabel_) << "No SiStrip FED data found in raw data.";
90  return;
91  }
92 
93  //create summary object
94  std::unique_ptr<SiStripEventSummary> pSummary(new SiStripEventSummary);
95  //set the trigger FED number to zero to indicate that it doesn't exist
96  pSummary->triggerFed(0);
97  //set the event number and Bx from the FED packets
98  pSummary->event(fedEventNumber);
99  pSummary->bx(fedBxNumber);
100  //create a fake trigger FED buffer to take comissioning parameters from
101  const int maxTriggerFedBufferSize = 84;
102  std::vector<uint32_t> fakeTriggerFedData(maxTriggerFedBufferSize);
103  for (uint8_t i = 0; i < maxTriggerFedBufferSize; ++i) {
104  fakeTriggerFedData[i] = 0;
105  }
106  //set the FED readout mode to virgin raw
107  fakeTriggerFedData[15] = 1;
108  //set the spill number
109  fakeTriggerFedData[0] = 0;
110  //set the number of data senders
111  fakeTriggerFedData[20] = 1;
112  //set the run type
113  fakeTriggerFedData[10] = runType_;
114  //fill the summarry using trigger FED buffer with no data
115  pSummary->commissioningInfo(fakeTriggerFedData.data(), fedEventNumber);
116 
117  //store in event
118  event.put(std::move(pSummary));
119  }
120 
122  switch (runType_) {
124  case sistrip::PHYSICS:
125  case sistrip::PHYSICS_ZS:
126  case sistrip::PEDESTALS:
127  case sistrip::MULTI_MODE:
128  case sistrip::PEDS_ONLY:
129  case sistrip::NOISE:
133  break;
139  case sistrip::OPTO_SCAN:
140  case sistrip::APV_TIMING:
141  case sistrip::FED_TIMING:
142  case sistrip::FINE_DELAY:
148  case sistrip::VPSP_SCAN:
149  LogWarning(messageLabel_) << "Unsupported run type: " << runType_
150  << ". Parameters need to be set from real trigger FED. Parameters will be set to 0.";
151  break;
152  }
153  }
154 
155 } // namespace sistrip
156 
static const uint16_t FED_ID_MIN
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
Constants and enumerated type for sistrip::RunType.
Definition: config.py:1
Log< level::Error, false > LogError
sistrip classes
sistrip::SpyEventSummaryProducer SiStripSpyEventSummaryProducer
void produce(edm::StreamID, edm::Event &event, const edm::EventSetup &) const override
Log< level::Info, false > LogInfo
SpyEventSummaryProducer(const edm::ParameterSet &config)
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
static const uint16_t FED_ID_MAX
FEDBufferStatusCode preconstructCheckFEDBufferBase(const FEDRawData &fedBuffer, bool checkRecognizedFormat=true)
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1