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 <memory>
24 #include <string>
25 #include "boost/scoped_array.hpp"
26 #include "boost/cstdint.hpp"
27 
28 using edm::LogError;
29 using edm::LogWarning;
30 using edm::LogInfo;
31 
32 namespace sistrip {
33 
35  {
36  public:
38  virtual ~SpyEventSummaryProducer();
39  virtual void produce(edm::Event& event, const edm::EventSetup&) override;
40  private:
42  static const char* messageLabel_;
46  };
47 
48 }
49 
50 namespace sistrip {
51 
52  const char* SpyEventSummaryProducer::messageLabel_ = "SiStripSpyEventSummaryProducer";
53 
55  : rawDataTag_(config.getParameter<edm::InputTag>("RawDataTag")),
56  runType_(sistrip::RunType(config.getParameter<uint32_t>("RunType")))
57  {
58  rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
59  produces<SiStripEventSummary>();
61  }
62 
64 
66  {
68 
69  //get the event number and Bx counter from the first valud FED buffer
71  event.getByToken(rawDataToken_,rawDataHandle);
72  const FEDRawDataCollection& rawData = *rawDataHandle;
73  bool fedFound = false;
74  uint32_t fedEventNumber = 0;
75  uint32_t fedBxNumber = 0;
76  for (uint16_t fedId = sistrip::FED_ID_MIN; fedId <= sistrip::FED_ID_MAX; ++fedId) {
77  const FEDRawData& fedData = rawData.FEDData(fedId);
78  if (fedData.size() && fedData.data()) {
79  std::unique_ptr<sistrip::FEDBufferBase> pBuffer;
80  try {
81  pBuffer.reset(new sistrip::FEDBufferBase(fedData.data(),fedData.size()));
82  } catch (const cms::Exception& e) {
83  LogInfo(messageLabel_) << "Skipping FED " << fedId << " because of exception: " << e.what();
84  continue;
85  }
86  fedEventNumber = pBuffer->daqLvl1ID();
87  fedBxNumber = pBuffer->daqBXID();
88  fedFound = true;
89  break;
90  }
91  }
92  if (!fedFound) {
93  LogError(messageLabel_) << "No SiStrip FED data found in raw data.";
94  return;
95  }
96 
97  //create summary object
98  std::unique_ptr<SiStripEventSummary> pSummary(new SiStripEventSummary);
99  //set the trigger FED number to zero to indicate that it doesn't exist
100  pSummary->triggerFed(0);
101  //set the event number and Bx from the FED packets
102  pSummary->event(fedEventNumber);
103  pSummary->bx(fedBxNumber);
104  //create a fake trigger FED buffer to take comissioning parameters from
105  const int maxTriggerFedBufferSize = 84;
106  boost::scoped_array<uint32_t> fakeTriggerFedData(new uint32_t[maxTriggerFedBufferSize]);
107  for (uint8_t i=0; i<maxTriggerFedBufferSize; ++i) {
108  fakeTriggerFedData[i] = 0;
109  }
110  //set the FED readout mode to virgin raw
111  fakeTriggerFedData[15] = 1;
112  //set the spill number
113  fakeTriggerFedData[0] = 0;
114  //set the number of data senders
115  fakeTriggerFedData[20] = 1;
116  //set the run type
117  fakeTriggerFedData[10] = runType_;
118  //fill the summarry using trigger FED buffer with no data
119  pSummary->commissioningInfo(fakeTriggerFedData.get(),fedEventNumber);
120 
121  //store in event
122  event.put(std::move(pSummary));
123  }
124 
126  {
127  switch(runType_) {
129  case sistrip::PHYSICS:
130  case sistrip::PHYSICS_ZS:
131  case sistrip::PEDESTALS:
132  case sistrip::MULTI_MODE:
133  case sistrip::PEDS_ONLY:
134  case sistrip::NOISE:
138  break;
144  case sistrip::OPTO_SCAN:
145  case sistrip::APV_TIMING:
146  case sistrip::FED_TIMING:
147  case sistrip::FINE_DELAY:
153  case sistrip::VPSP_SCAN:
154  LogWarning(messageLabel_) << "Unsupported run type: " << runType_ << ". Parameters need to be set from real trigger FED. Parameters will be set to 0.";
155  break;
156  }
157  }
158 
159 }
160 
static const uint16_t FED_ID_MIN
virtual void produce(edm::Event &event, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
char const * what() const override
Definition: Exception.cc:141
Constants and enumerated type for sistrip::RunType.
Definition: config.py:1
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
sistrip classes
sistrip::SpyEventSummaryProducer SiStripSpyEventSummaryProducer
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
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:28
static const uint16_t FED_ID_MAX
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1