1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// -*- C++ -*-
//
// Package: LTCRawToDigi
// Class: LTCRawToDigi
//
/**\class LTCRawToDigi LTCRawToDigi.cc EventFilter/LTCRawToDigi/src/LTCRawToDigi.cc
Description: Unpack FED data to LTC bank. LTCs are FED id 816-823.
Implementation:
No comments
*/
//
// Original Author: Peter Wittich
// Created: Tue May 9 07:47:59 CDT 2006
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
//FEDRawData
#include "DataFormats/FEDRawData/interface/FEDRawData.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
// LTC class
#include "DataFormats/LTCDigi/interface/LTCDigi.h"
//
// class declaration
//
class LTCRawToDigi : public edm::global::EDProducer<> {
public:
explicit LTCRawToDigi(const edm::ParameterSet&);
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
private:
// ----------member data ---------------------------
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
LTCRawToDigi::LTCRawToDigi(const edm::ParameterSet& iConfig) {
//register your products
produces<LTCDigiCollection>();
}
//
// member functions
//
// ------------ method called to produce the data ------------
void LTCRawToDigi::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
using namespace edm;
const int LTCFedIDLo = 815;
const int LTCFedIDHi = 823;
// Get a handle to the FED data collection
edm::Handle<FEDRawDataCollection> rawdata;
iEvent.getByLabel("source", rawdata);
// create collection we'll save in the event record
auto pOut = std::make_unique<LTCDigiCollection>();
// Loop over all possible FED's with the appropriate FED ID
for (int id = LTCFedIDLo; id <= LTCFedIDHi; ++id) {
/// Take a reference to this FED's data
const FEDRawData& fedData = rawdata->FEDData(id);
unsigned short int length = fedData.size();
if (!length)
continue; // bank does not exist
LTCDigi ltcDigi(fedData.data());
pOut->push_back(ltcDigi);
}
iEvent.put(std::move(pOut));
}
//define this as a plug-in
DEFINE_FWK_MODULE(LTCRawToDigi);
|