CMS 3D CMS Logo

CastorDigiToRaw.cc
Go to the documentation of this file.
8 #include <iostream>
9 
12 
13 using namespace std;
14 
16  : castorTag_(conf.getParameter<edm::InputTag>("CASTOR")),
17  usingctdc_(conf.getParameter<bool>("CastorCtdc")),
18  tok_input_(consumes<CastorDigiCollection>(castorTag_)),
19  tok_put_(produces<FEDRawDataCollection>()) {}
20 
21 // Functions that gets called by framework every event
23  CastorCollections colls;
24 
25  // Step A: Get Inputs
27  if (!castorTag_.label().empty()) {
28  e.getByToken(tok_input_, castor);
29  colls.castorCont = castor.product();
30  }
31  // get the mapping
33  es.get<CastorDbRecord>().get(pSetup);
34  const CastorElectronicsMap* readoutMap = pSetup->getCastorMapping();
35  // Step B: Create empty output
37 
38  constexpr int ifed_first = FEDNumbering::MINCASTORFEDID; //690
39  constexpr int ifed_last = FEDNumbering::MAXCASTORFEDID; //693
40 
41  int orbitN = e.id().event();
42  int bcnN = 2000;
43 
44  // Step C: pack all requested FEDs
45  for (int ifed = ifed_first; ifed <= ifed_last; ++ifed) {
46  FEDRawData& fed = raw.FEDData(ifed);
47  try {
48  if (usingctdc_) {
49  CastorCtdcPacker::pack(ifed, ifed - ifed_first, e.id().event(), orbitN, bcnN, colls, *readoutMap, fed);
50  } else {
51  CastorPacker::pack(ifed, ifed - ifed_first, e.id().event(), orbitN, bcnN, colls, *readoutMap, fed);
52  }
53  } catch (cms::Exception& e) {
54  edm::LogWarning("Unpacking error") << e.what();
55  } catch (...) {
56  edm::LogWarning("Unpacking exception");
57  }
58  }
59 
60  e.emplace(tok_put_, std::move(raw));
61 }
EventNumber_t event() const
Definition: EventID.h:40
const edm::EDGetTokenT< CastorDigiCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
char const * what() const override
Definition: Exception.cc:103
const CastorDigiCollection * castorCont
static void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
const bool usingctdc_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const CastorElectronicsMap * getCastorMapping() const
const edm::EDPutTokenT< FEDRawDataCollection > tok_put_
T const * product() const
Definition: Handle.h:69
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:421
static void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
Definition: CastorPacker.cc:41
const edm::InputTag castorTag_
CastorDigiToRaw(const edm::ParameterSet &ps)
std::string const & label() const
Definition: InputTag.h:36
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
T get() const
Definition: EventSetup.h:73
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
def move(src, dest)
Definition: eostools.py:511
#define constexpr