CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTUnpackingModule.cc
Go to the documentation of this file.
1 
8 
14 
17 
22 
24 
28 
29 
30 using namespace edm;
31 using namespace std;
32 
33 
34 
35 #define SLINK_WORD_SIZE 8
36 
37 
39 
40  dataType = ps.getParameter<string>("dataType");
41 
42  ParameterSet unpackerParameters = ps.getParameter<ParameterSet>("readOutParameters");
43 
44  if (dataType == "DDU") {
45  unpacker = new DTDDUUnpacker(unpackerParameters);
46  }
47  else if (dataType == "ROS25") {
48  unpacker = new DTROS25Unpacker(unpackerParameters.getParameter<ParameterSet>("rosParameters"));
49  }
50  else if (dataType == "ROS8") {
51  unpacker = new DTROS8Unpacker(unpackerParameters);
52  }
53  else {
54  throw cms::Exception("InvalidParameter") << "DTUnpackingModule: dataType "
55  << dataType << " is unknown";
56  }
57 
58  inputLabel = consumes<FEDRawDataCollection>(ps.getParameter<InputTag>("inputLabel")); // default was: source
59  useStandardFEDid_ = ps.getParameter<bool>("useStandardFEDid"); // default was: true
60  minFEDid_ = ps.getUntrackedParameter<int>("minFEDid",770); // default: 770
61  maxFEDid_ = ps.getUntrackedParameter<int>("maxFEDid",779); // default 779
62  dqmOnly = ps.getParameter<bool>("dqmOnly"); // default: false
63  performDataIntegrityMonitor = unpackerParameters.getUntrackedParameter<bool>("performDataIntegrityMonitor",false); // default: false
64 
65  if(!dqmOnly) {
66  produces<DTDigiCollection>();
67  produces<DTLocalTriggerCollection>();
68  }
69  if(performDataIntegrityMonitor) {
70  produces<std::vector<DTDDUData> >();
71  produces<std::vector<std::vector<DTROS25Data> > >();
72  }
73 }
74 
76  delete unpacker;
77 }
78 
79 
80 void DTUnpackingModule::produce(Event & e, const EventSetup& context){
81 
83  e.getByToken(inputLabel, rawdata);
84 
85  if(!rawdata.isValid()){
86  LogError("DTUnpackingModule::produce") << " unable to get raw data from the event" << endl;
87  return;
88  }
89 
90  // Get the mapping from the setup
92  context.get<DTReadOutMappingRcd>().get(mapping);
93 
94  // Create the result i.e. the collections of MB Digis and SC local triggers
95  auto_ptr<DTDigiCollection> detectorProduct(new DTDigiCollection);
96  auto_ptr<DTLocalTriggerCollection> triggerProduct(new DTLocalTriggerCollection);
97 
98  auto_ptr<std::vector<DTDDUData> > dduProduct(new std::vector<DTDDUData>);
99  auto_ptr<DTROS25Collection> ros25Product(new DTROS25Collection);
100 
101  // Loop over the DT FEDs
102  int FEDIDmin = 0, FEDIDMax = 0;
103  if (useStandardFEDid_){
104  FEDIDmin = FEDNumbering::MINDTFEDID;
105  FEDIDMax = FEDNumbering::MAXDTFEDID;
106  }
107  else {
108  FEDIDmin = minFEDid_;
109  FEDIDMax = maxFEDid_;
110  }
111 
112  for (int id=FEDIDmin; id<=FEDIDMax; ++id){
113  const FEDRawData& feddata = rawdata->FEDData(id);
114 
115  if (feddata.size()){
116  // Unpack the data
117  unpacker->interpretRawData(reinterpret_cast<const unsigned int*>(feddata.data()),
118  feddata.size(), id, mapping, detectorProduct, triggerProduct);
120  if(dataType == "DDU") {
121  dduProduct->push_back(dynamic_cast<DTDDUUnpacker*>(unpacker)->getDDUControlData());
122  ros25Product->push_back(dynamic_cast<DTDDUUnpacker*>(unpacker)->getROSsControlData());
123  }
124  else if(dataType == "ROS25") {
125  ros25Product->push_back(dynamic_cast<DTROS25Unpacker*>(unpacker)->getROSsControlData());
126  }
127  }
128  }
129  }
130 
131  // commit to the event
132  if(!dqmOnly) {
133  e.put(detectorProduct);
134  e.put(triggerProduct);
135  }
137  e.put(dduProduct);
138  e.put(ros25Product);
139  }
140 }
141 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void produce(edm::Event &e, const edm::EventSetup &c)
Call the Unpackers and create the digis.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
edm::EDGetTokenT< FEDRawDataCollection > inputLabel
if not you need the label
virtual void interpretRawData(const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::auto_ptr< DTDigiCollection > &product, std::auto_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0)=0
std::vector< std::vector< DTROS25Data > > DTROS25Collection
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
virtual ~DTUnpackingModule()
Destructor.
int minFEDid_
if not you need to set the range by hand
DTUnpackingModule(const edm::ParameterSet &pset)
Constructor.
bool useStandardFEDid_
do you want to use the standard DT FED ID&#39;s, i.e. [770-775]? (why the hell 6??)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
bool isValid() const
Definition: HandleBase.h:76
const T & get() const
Definition: EventSetup.h:55
DTUnpacker * unpacker
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
dictionary rawdata
Definition: lumiPlot.py:393